[Pkg-lustre-svn-commit] updated: [a9cfa18] Imported Upstream version 1.8.1

Patrick Winnertz winnie at debian.org
Tue Aug 11 10:39:32 UTC 2009


The following commit has been merged in the master branch:
commit a9cfa1872413e44e2e0bc8c1ddd01a0d2e231efb
Author: Patrick Winnertz <winnie at debian.org>
Date:   Tue Aug 11 12:37:04 2009 +0200

    Imported Upstream version 1.8.1

diff --git a/aclocal.m4 b/aclocal.m4
index 48dc04a..45b6f1f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -102,19 +102,6 @@ AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([lb_File])dnl
 ])# LB_CHECK_FILE
 
-#
-# LB_CHECK_FILES
-#
-# LB_CHECK_FILE over multiple files
-#
-AC_DEFUN([LB_CHECK_FILES],
-[AC_FOREACH([AC_FILE_NAME], [$1],
-  [LB_CHECK_FILE(AC_FILE_NAME,
-                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
-                                    [Define to 1 if you have the
-                                     file `]AC_File['.])
-$2],
-                 [$3])])])
 
 #
 # LB_ARG_LIBS_INCLUDES
@@ -297,6 +284,10 @@ AC_SUBST(LDISKFS_DIR)
 AC_SUBST(LDISKFS_SUBDIR)
 AM_CONDITIONAL(LDISKFS_ENABLED, test x$with_ldiskfs != xno)
 
+if test x$enable_ext4 = xyes ; then
+	AC_DEFINE(HAVE_EXT4_LDISKFS, 1, [build ext4 based ldiskfs])
+fi
+
 # We have to configure even if we don't build here for make dist to work
 AC_CONFIG_SUBDIRS(ldiskfs)
 ])
@@ -330,6 +321,131 @@ AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
 	AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1, [enable extented attributes for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFS_FS_NFS4ACL, 1, [enable fs security for ldiskfs])
+
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
 ])
 
 #
@@ -465,11 +581,11 @@ if test x$dmu_osd = xyes; then
 
 		AC_SUBST(spl_src)
 
-		LB_CHECK_FILE([$SPL_DIR/modules/spl/spl-generic.c],[],[
+		LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
 			AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
 		])
 
-		LB_CHECK_FILE([$ZFS_DIR/zfs/lib/libzpool/dmu.c],[],[
+		LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
 			AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
 		])
 
@@ -617,7 +733,7 @@ AC_SUBST(ENABLE_INIT_SCRIPTS)
 #
 AC_DEFUN([LB_CONFIG_HEADERS],
 [AC_CONFIG_HEADERS([config.h])
-CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
+CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
 AC_SUBST(EXTRA_KCFLAGS)
 ])
@@ -705,7 +821,7 @@ if test $target_cpu == "powerpc64"; then
 	CC="$CC -m64"
 fi
 
-CPPFLAGS="-I\$(top_builddir)/$LIBCFS_INCLUDE_DIR -I\$(top_srcdir)/$LIBCFS_INCLUDE_DIR-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
+CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
 
 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
 AC_SUBST(LLCPPFLAGS)
@@ -803,12 +919,20 @@ LC_QUOTA
 
 LB_CONFIG_MODULES
 
+LN_CONFIG_USERSPACE
+
 LB_PATH_DMU
 LB_PATH_LIBSYSIO
 LB_PATH_SNMP
 LB_PATH_LDISKFS
 LB_PATH_LUSTREIOKIT
 
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
 LC_CONFIG_LIBLUSTRE
 LIBCFS_CONFIGURE
 LN_CONFIGURE
@@ -937,77 +1061,26 @@ $2
 ])
 
 #
-# LC_STRUCT_KIOBUF
-#
-# rh 2.4.18 has iobuf->dovary, but other kernels do not
-#
-AC_DEFUN([LC_STRUCT_KIOBUF],
-[AC_MSG_CHECKING([if struct kiobuf has a dovary field])
-LB_LINUX_TRY_COMPILE([
-	#include <linux/iobuf.h>
-],[
-	struct kiobuf iobuf;
-	iobuf.dovary = 1;
-],[
-	AC_MSG_RESULT([yes])
-	AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
-],[
-	AC_MSG_RESULT([no])
-])
-])
-
-#
-# LC_FUNC_COND_RESCHED
-#
-# cond_resched() was introduced in 2.4.20
-#
-AC_DEFUN([LC_FUNC_COND_RESCHED],
-[AC_MSG_CHECKING([if kernel offers cond_resched])
-LB_LINUX_TRY_COMPILE([
-	#include <linux/sched.h>
-],[
-	cond_resched();
-],[
-	AC_MSG_RESULT([yes])
-	AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
-],[
-	AC_MSG_RESULT([no])
-])
-])
 
 #
-# LC_FUNC_ZAP_PAGE_RANGE
+# LC_FUNC_RELEASEPAGE_WITH_GFP
 #
-# if zap_page_range() takes a vma arg
+# if ->releasepage() takes a gfp_t arg in 2.6.9
+# This kernel defines gfp_t (HAS_GFP_T) but doesn't use it for this function,
+# while others either don't have gfp_t or pass gfp_t as the parameter.
 #
-AC_DEFUN([LC_FUNC_ZAP_PAGE_RANGE],
-[AC_MSG_CHECKING([if zap_page_range with vma parameter])
-ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
-if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
-	AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
+AC_DEFUN([LC_FUNC_RELEASEPAGE_WITH_GFP],
+[AC_MSG_CHECKING([if releasepage has a gfp_t parameter])
+RELEASEPAGE_WITH_GFP="`grep -c 'releasepage.*gfp_t' $LINUX/include/linux/fs.h`"
+if test "$RELEASEPAGE_WITH_GFP" != 0 ; then
+	AC_DEFINE(HAVE_RELEASEPAGE_WITH_GFP, 1,
+                  [releasepage with gfp_t parameter])
 	AC_MSG_RESULT([yes])
 else
 	AC_MSG_RESULT([no])
 fi
 ])
 
-#
-# LC_FUNC_PDE
-#
-# if proc_fs.h defines PDE()
-#
-AC_DEFUN([LC_FUNC_PDE],
-[AC_MSG_CHECKING([if kernel defines PDE])
-HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
-if test "$HAVE_PDE" != 0 ; then
-	AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
-	AC_MSG_RESULT([yes])
-else
-	AC_MSG_RESULT([no])
-fi
-])
-
-#
 # LC_FUNC_FILEMAP_FDATASYNC
 #
 # if filemap_fdatasync() exists
@@ -1027,22 +1100,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LC_FUNC_DIRECT_IO
-#
-# if direct_IO takes a struct file argument
-#
-AC_DEFUN([LC_FUNC_DIRECT_IO],
-[AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
-HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
-if test "$HAVE_DIO_FILE" != 0 ; then
-	AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
-	AC_MSG_RESULT(yes)
-else
-	AC_MSG_RESULT(no)
-fi
-])
-
-#
 # LC_HEADER_MM_INLINE
 #
 # RHEL kernels define page_count in mm_inline.h
@@ -1088,27 +1145,52 @@ LB_LINUX_TRY_COMPILE([
 # LC_FUNC_REGISTER_CACHE
 #
 # if register_cache() is defined by kernel
+# 
+# There are two ways to shrink one customized cache in linux kernels. For the
+# kernels are prior than 2.6.5(?), register_cache() is used, and for latest 
+# kernels, set_shrinker() is used instead.
 #
 AC_DEFUN([LC_FUNC_REGISTER_CACHE],
-[AC_MSG_CHECKING([if kernel defines register_cache()])
+[AC_MSG_CHECKING([if kernel defines cache pressure hook])
 LB_LINUX_TRY_COMPILE([
-	#include <linux/list.h>
-	#include <linux/cache_def.h>
+	#include <linux/mm.h>
 ],[
-	struct cache_definition cache;
+	shrinker_t shrinker;
+
+	set_shrinker(1, shrinker);
 ],[
-	AC_MSG_RESULT([yes])
-	AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
-	AC_MSG_CHECKING([if kernel expects return from cache shrink function])
-	HAVE_CACHE_RETURN_INT="`grep -c 'int.*shrink' $LINUX/include/linux/cache_def.h`"
-	if test "$HAVE_CACHE_RETURN_INT" != 0 ; then
-		AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [kernel expects return from shrink_cache])
-		AC_MSG_RESULT(yes)
-	else
-		AC_MSG_RESULT(no)
-	fi
+	AC_MSG_RESULT([set_shrinker])
+	AC_DEFINE(HAVE_SHRINKER_CACHE, 1, [shrinker_cache found])
+	AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [shrinkers should return int])
 ],[
-	AC_MSG_RESULT([no])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/list.h>
+		#include <linux/cache_def.h>
+	],[
+		struct cache_definition cache;
+	],[
+		AC_MSG_RESULT([register_cache])
+		AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
+		AC_MSG_CHECKING([if kernel expects return from cache shrink ])
+		tmp_flags="$EXTRA_KCFLAGS"
+		EXTRA_KCFLAGS="-Werror"
+		LB_LINUX_TRY_COMPILE([
+			#include <linux/list.h>
+			#include <linux/cache_def.h>
+		],[
+			struct cache_definition c;
+			c.shrinker = (int (*)(int, unsigned int))1;
+		],[
+			AC_DEFINE(HAVE_CACHE_RETURN_INT, 1,
+				  [kernel expects return from shrink_cache])
+			AC_MSG_RESULT(yes)
+		],[
+			AC_MSG_RESULT(no)
+		])
+		EXTRA_KCFLAGS="$tmp_flags"
+	],[
+		AC_MSG_RESULT([no])
+	])
 ])
 ])
 
@@ -1164,7 +1246,7 @@ BACKINGFS="ldiskfs"
 if test x$with_ldiskfs = xno ; then
 	BACKINGFS="ext3"
 
-	if test x$linux25$enable_server = xyesyes ; then
+	if test x$enable_server = xyes ; then
 		AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
 	fi
 
@@ -1484,14 +1566,18 @@ AC_DEFUN([LC_LUSTRE_VERSION_H],
         	enable_server='no'
 	fi
 ])
-])
-
-AC_DEFUN([LC_FUNC_SET_FS_PWD],
-[LB_CHECK_SYMBOL_EXPORT([set_fs_pwd],
-[fs/namespace.c],[
-        AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd is exported])
-],[
-])
+	if test x$enable_server = xyes ; then
+		if test x$RHEL_KERNEL = xyes -a x$LINUXRELEASE != x${LINUXRELEASE##2.6.9} ; then
+        		AC_MSG_WARN([Lustre server has been disabled with rhel4 kernel;])
+        		AC_MSG_WARN([disabling server build])
+        		enable_server='no'
+		fi
+		if test x$SUSE_KERNEL = xyes -a x$LINUXRELEASE != x${LINUXRELEASE##2.6.5} ; then
+        		AC_MSG_WARN([Lustre server has been disabled with sles9 kernel;])
+        		AC_MSG_WARN([disabling server build])
+			enable_server='no'
+		fi
+	fi
 ])
 
 #
@@ -1662,6 +1748,17 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# LC_EXPORT_SYNCHRONIZE_RCU
+# after 2.6.12 synchronize_rcu is preferred over synchronize_kernel
+AC_DEFUN([LC_EXPORT_SYNCHRONIZE_RCU],
+[LB_CHECK_SYMBOL_EXPORT([synchronize_rcu],
+[kernel/rcupdate.c],[
+        AC_DEFINE(HAVE_SYNCHRONIZE_RCU, 1,
+                [in 2.6.12 synchronize_rcu preferred over synchronize_kernel])
+],[
+])
+])
+
 # LC_INODE_I_MUTEX
 # after 2.6.15 inode have i_mutex intead of i_sem
 AC_DEFUN([LC_INODE_I_MUTEX],
@@ -1794,6 +1891,23 @@ LB_LINUX_TRY_COMPILE([
 EXTRA_KCFLAGS="$tmp_flags"
 ])
 
+# inode have i_private field since 2.6.17
+AC_DEFUN([LC_INODE_IPRIVATE],
+[AC_MSG_CHECKING([if inode has a i_private field])
+LB_LINUX_TRY_COMPILE([
+#include <linux/fs.h>
+],[
+	struct inode i;
+	i.i_private = NULL; 
+],[
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(HAVE_INODE_IPRIVATE, 1,
+		[struct inode has i_private field])
+],[
+	AC_MSG_RESULT(no)
+])
+])
+
 # 2.6.19 API changes
 # inode don't have i_blksize field
 AC_DEFUN([LC_INODE_BLKSIZE],
@@ -1840,6 +1954,23 @@ LB_LINUX_TRY_COMPILE([
 EXTRA_KCFLAGS="$tmp_flags"
 ])
 
+# LC_FILE_UPDATE_TIME
+# 2.6.9 has inode_update_time instead of file_update_time
+AC_DEFUN([LC_FILE_UPDATE_TIME],
+[AC_MSG_CHECKING([if file_update_time is exported])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        file_update_time(NULL);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_FILE_UPDATE_TIME, 1,
+                [use file_update_time])
+],[
+       AC_MSG_RESULT(no)
+])
+])
+
 # LC_FILE_WRITEV
 # 2.6.19 replaced writev with aio_write
 AC_DEFUN([LC_FILE_WRITEV],
@@ -1902,6 +2033,10 @@ LB_LINUX_TRY_COMPILE([
         #include <linux/mm.h>
         #include <linux/page-flags.h>
 ],[
+        /* tmp workaround for broken OFED 1.4.1 at SLES10 */
+        #if defined(CONFIG_SLE_VERSION) && CONFIG_SLE_VERSION == 10 && defined(_BACKPORT_LINUX_MM_H_)
+        #error badly implementation of cancel_dirty_pages
+        #endif
         cancel_dirty_page(NULL, 0);
 ],[
         AC_MSG_RESULT(yes)
@@ -1960,15 +2095,20 @@ LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_PAGE_CHECKED],
 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/mm.h>
-        #include <linux/page-flags.h>
+        #include <linux/autoconf.h>
+#ifdef HAVE_LINUX_MMTYPES_H
+        #include <linux/mm_types.h>
+#endif
+	#include <linux/page-flags.h>
 ],[
-        #ifndef PageChecked
-        #error PageChecked not defined in kernel
-        #endif
-        #ifndef SetPageChecked
-        #error SetPageChecked not defined in kernel
-        #endif
+ 	struct page *p;
+
+        /* before 2.6.26 this define*/
+        #ifndef PageChecked	
+ 	/* 2.6.26 use function instead of define for it */
+ 	SetPageChecked(p);
+ 	PageChecked(p);
+ 	#endif
 ],[
         AC_MSG_RESULT(yes)
         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
@@ -1978,7 +2118,7 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
+AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE_PAGE],
 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
 [mm/truncate.c],[
 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
@@ -1987,6 +2127,15 @@ AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
 ])
 ])
 
+AC_DEFUN([LC_EXPORT_TRUNCATE_RANGE],
+[LB_CHECK_SYMBOL_EXPORT([truncate_inode_pages_range],
+[mm/truncate.c],[
+AC_DEFINE(HAVE_TRUNCATE_RANGE, 1,
+            [kernel export truncate_inode_pages_range])
+],[
+])
+])
+
 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
 [fs/dcache.c],[
@@ -2023,6 +2172,38 @@ AC_DEFINE(HAVE___D_MOVE, 1,
 ])
 ])
 
+#
+# LC_EXPORT_INVALIDATE_MAPPING_PAGES
+#
+# SLES9, RHEL4, RHEL5, vanilla 2.6.24 export invalidate_mapping_pages() but
+# SLES10 2.6.16 does not, for some reason.  For filter cache invalidation.
+#
+AC_DEFUN([LC_EXPORT_INVALIDATE_MAPPING_PAGES],
+    [LB_CHECK_SYMBOL_EXPORT([invalidate_mapping_pages], [mm/truncate.c], [
+         AC_DEFINE(HAVE_INVALIDATE_MAPPING_PAGES, 1,
+                        [exported invalidate_mapping_pages])],
+    [LB_CHECK_SYMBOL_EXPORT([invalidate_inode_pages], [mm/truncate.c], [
+         AC_DEFINE(HAVE_INVALIDATE_INODE_PAGES, 1,
+                        [exported invalidate_inode_pages])], [
+       AC_MSG_ERROR([no way to invalidate pages])
+  ])
+    ],[])
+])
+
+#
+# LC_EXPORT_FILEMAP_FDATASYNC_RANGE
+#
+# No standard kernels export this
+#
+AC_DEFUN([LC_EXPORT_FILEMAP_FDATAWRITE_RANGE],
+[LB_CHECK_SYMBOL_EXPORT([filemap_fdatawrite_range],
+[mm/filemap.c],[
+AC_DEFINE(HAVE_FILEMAP_FDATAWRITE_RANGE, 1,
+            [filemap_fdatawrite_range is exported by the kernel])
+],[
+])
+])
+
 # The actual symbol exported varies among architectures, so we need
 # to check many symbols (but only in the current architecture.)  No
 # matter what symbol is exported, the kernel #defines node_to_cpumask
@@ -2086,6 +2267,29 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# 2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
+AC_DEFUN([LC_RW_TREE_LOCK],
+[AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct address_space a;
+
+        write_lock(&a.tree_lock);
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
+],[
+        AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+# 2.6.18
+
+
 # 2.6.23 have return type 'void' for unregister_blkdev
 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
 [AC_MSG_CHECKING([if unregister_blkdev return int])
@@ -2103,6 +2307,25 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 # 2.6.23 change .sendfile to .splice_read
+# RHEL4 (-92 kernel) have both sendfile and .splice_read API
+AC_DEFUN([LC_KERNEL_SENDFILE],
+[AC_MSG_CHECKING([if kernel has .sendfile])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct file_operations file;
+
+        file.sendfile = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_KERNEL_SENDFILE, 1,
+                [kernel has .sendfile])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.23 change .sendfile to .splice_read
 AC_DEFUN([LC_KERNEL_SPLICE_READ],
 [AC_MSG_CHECKING([if kernel has .splice_read])
 LB_LINUX_TRY_COMPILE([
@@ -2122,11 +2345,446 @@ LB_LINUX_TRY_COMPILE([
 
 # 2.6.23 extract nfs export related data into exportfs.h
 AC_DEFUN([LC_HAVE_EXPORTFS_H],
-[
-tmpfl="$CFLAGS"
-CFLAGS="$CFLAGS -I$LINUX_OBJ/include"
-AC_CHECK_HEADERS([linux/exportfs.h])
-CFLAGS="$tmpfl"
+[LB_CHECK_FILE([$LINUX/include/linux/exportfs.h], [
+        AC_DEFINE(HAVE_LINUX_EXPORTFS_H, 1,
+                [kernel has include/exportfs.h])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.23 have new page fault handling API
+AC_DEFUN([LC_VM_OP_FAULT],
+[AC_MSG_CHECKING([if kernel has .fault in vm_operation_struct])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/mm.h>
+],[
+        struct vm_operations_struct op;
+
+        op.fault = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_VM_OP_FAULT, 1,
+                [if kernel has .fault in vm_operation_struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#2.6.23 has new shrinker API
+AC_DEFUN([LC_REGISTER_SHRINKER],
+[AC_MSG_CHECKING([if kernel has register_shrinker])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/mm.h>
+],[
+        register_shrinker(NULL);
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
+                [if kernel has register_shrinker])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.23 add code to wait other users to complete before removing procfs entry
+AC_DEFUN([LC_PROCFS_USERS],
+[AC_MSG_CHECKING([if kernel has pde_users member in procfs entry struct])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/proc_fs.h>
+],[
+        struct proc_dir_entry pde;
+
+        pde.pde_users   = 0;
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_PROCFS_USERS, 1, 
+                [kernel has pde_users member in procfs entry struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 has bio_endio with 2 args
+AC_DEFUN([LC_BIO_ENDIO_2ARG],
+[AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/bio.h>
+],[
+        bio_endio(NULL, 0);
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
+                [if kernel has bio_endio with 2 args])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 has new members in exports struct.
+AC_DEFUN([LC_FH_TO_DENTRY],
+[AC_MSG_CHECKING([if kernel has .fh_to_dentry member in export_operations struct])
+LB_LINUX_TRY_COMPILE([
+#ifdef HAVE_LINUX_EXPORTFS_H
+        #include <linux/exportfs.h>
+#else
+        #include <linux/fs.h>
+#endif
+],[
+        struct export_operations exp;
+
+        exp.fh_to_dentry   = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_FH_TO_DENTRY, 1,
+                [kernel has .fh_to_dentry member in export_operations struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 need linux/mm_types.h included
+AC_DEFUN([LC_HAVE_MMTYPES_H],
+[LB_CHECK_FILE([$LINUX/include/linux/mm_types.h], [
+        AC_DEFINE(HAVE_LINUX_MMTYPES_H, 1,
+                [kernel has include/mm_types.h])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 remove long aged procfs entry -> deleted member
+AC_DEFUN([LC_PROCFS_DELETED],
+[AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/proc_fs.h>
+],[
+        struct proc_dir_entry pde;
+
+        pde.deleted   = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_PROCFS_DELETED, 1,
+                [kernel has deleted member in procfs entry struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.25 change define to inline
+AC_DEFUN([LC_MAPPING_CAP_WRITEBACK_DIRTY],
+[AC_MSG_CHECKING([if kernel have mapping_cap_writeback_dirty])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/backing-dev.h>
+],[
+        #ifndef mapping_cap_writeback_dirty
+        mapping_cap_writeback_dirty(NULL);
+        #endif
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_MAPPING_CAP_WRITEBACK_DIRTY, 1,
+                [kernel have mapping_cap_writeback_dirty])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+
+
+# 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
+AC_DEFUN([LC_FS_STRUCT_USE_PATH],
+[AC_MSG_CHECKING([fs_struct use path structure])
+LB_LINUX_TRY_COMPILE([
+        #include <asm/atomic.h>
+        #include <linux/spinlock.h>
+        #include <linux/fs_struct.h>
+],[
+        struct path path;
+        struct fs_struct fs;
+
+        fs.pwd = path;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
+                [fs_struct use path structure])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#2.6.27
+AC_DEFUN([LC_INODE_PERMISION_2ARGS],
+[AC_MSG_CHECKING([inode_operations->permission have two args])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct inode *inode;
+
+        inode->i_op->permission(NULL,0);
+],[
+        AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1, 
+                  [inode_operations->permission have two args])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 have file_remove_suid instead of remove_suid
+AC_DEFUN([LC_FILE_REMOVE_SUID],
+[AC_MSG_CHECKING([kernel have file_remove_suid])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        file_remove_suid(NULL);
+],[
+        AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
+                  [kernel have file_remove_suid])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 have new page locking API
+AC_DEFUN([LC_TRYLOCKPAGE],
+[AC_MSG_CHECKING([kernel use trylock_page for page lock])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/pagemap.h>
+],[
+        trylock_page(NULL);
+],[
+        AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
+                  [kernel use trylock_page for page lock])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 and some older have mapping->tree_lock as spin_lock
+AC_DEFUN([LC_RW_TREE_LOCK],
+[AC_MSG_CHECKING([mapping->tree_lock is rw_lock])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+	#include <linux/fs.h>
+],[
+	struct address_space *map = NULL;
+
+	write_lock_irq(&map->tree_lock);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_RW_TREE_LOCK, 1,
+                [mapping->tree_lock is rw_lock])
+],[
+        AC_MSG_RESULT(no)
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+# 2.6.5 sles9 hasn't define sysctl_vfs_cache_pressure
+AC_DEFUN([LC_HAVE_SYSCTL_VFS_CACHE_PRESSURE],
+[LB_CHECK_SYMBOL_EXPORT([sysctl_vfs_cache_pressure],
+[fs/dcache.c],[
+        AC_DEFINE(HAVE_SYSCTL_VFS_CACHE_PRESSURE, 1, [kernel exports sysctl_vfs_cache_pressure])
+],[
+])
+])
+
+# vfs_symlink seems to have started out with 3 args until 2.6.7 where a
+# "mode" argument was added, but then again, in some later version it was
+# removed
+AC_DEFUN([LC_4ARGS_VFS_SYMLINK],
+[AC_MSG_CHECKING([if vfs_symlink wants 4 args])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/fs.h>
+],[
+	struct inode *dir;
+	struct dentry *dentry;
+	const char *oldname = NULL;
+	int mode = 0;
+
+	vfs_symlink(dir, dentry, oldname, mode);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
+                  [vfs_symlink wants 4 args])
+],[
+        AC_MSG_RESULT(no)
+])
+])
+
+# 2.6.27 sles11 remove the bi_hw_segments
+AC_DEFUN([LC_BI_HW_SEGMENTS],
+[AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/bio.h>
+],[
+        struct bio io;
+        io.bi_hw_segments = 0;
+],[
+        AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
+                [struct bio has a bi_hw_segments field])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 sles11 move the quotaio_v1.h to fs
+AC_DEFUN([LC_HAVE_QUOTAIO_V1_H],
+[LB_CHECK_FILE([$LINUX/include/linux/quotaio_v1.h],[
+        AC_DEFINE(HAVE_QUOTAIO_V1_H, 1,
+                [kernel has include/linux/quotaio_v1.h])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# sles10 sp2 need 5 parameter for vfs_symlink
+AC_DEFUN([LC_VFS_SYMLINK_5ARGS],
+[AC_MSG_CHECKING([vfs_symlink need 5 parameter])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct inode *dir = NULL;
+        struct dentry *dentry = NULL;
+        struct vfsmount *mnt = NULL;
+        const char * path = NULL;
+        vfs_symlink(dir, dentry, mnt, path, 0);
+],[
+        AC_DEFINE(HAVE_VFS_SYMLINK_5ARGS, 1,
+                [vfs_symlink need 5 parameteres])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 removed the read_inode from super_operations.
+AC_DEFUN([LC_READ_INODE_IN_SBOPS],
+[AC_MSG_CHECKING([super_operations has a read_inode field])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct super_operations *sop;
+        sop->read_inode(NULL);
+],[
+        AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1,
+                [super_operations has a read_inode])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 sles11 has sb_any_quota_active
+AC_DEFUN([LC_SB_ANY_QUOTA_ACTIVE],
+[AC_MSG_CHECKING([Kernel has sb_any_quota_active])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quotaops.h>
+],[
+        sb_any_quota_active(NULL);
+],[
+        AC_DEFINE(HAVE_SB_ANY_QUOTA_ACTIVE, 1,
+                [Kernel has a sb_any_quota_active])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 sles11 has sb_has_quota_active
+AC_DEFUN([LC_SB_HAS_QUOTA_ACTIVE],
+[AC_MSG_CHECKING([Kernel has sb_has_quota_active])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quotaops.h>
+],[
+        sb_has_quota_active(NULL, 0);
+],[
+        AC_DEFINE(HAVE_SB_HAS_QUOTA_ACTIVE, 1,
+                [Kernel has a sb_has_quota_active])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 has inode_permission instead of permisson
+AC_DEFUN([LC_EXPORT_INODE_PERMISSION],
+[LB_CHECK_SYMBOL_EXPORT([inode_permission],
+[fs/namei.c],[
+AC_DEFINE(HAVE_EXPORT_INODE_PERMISSION, 1,
+            [inode_permission is exported by the kernel])
+],[
+])
+])
+
+# 2.6.27 use 5th parameter in quota_on for remount.
+AC_DEFUN([LC_QUOTA_ON_5ARGS],
+[AC_MSG_CHECKING([quota_on needs 5 parameters])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quota.h>
+],[
+        struct quotactl_ops *qop;
+        qop->quota_on(NULL, 0, 0, NULL, 0);
+],[
+        AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
+                [quota_on needs 5 paramters])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 use 3th parameter in quota_off for remount.
+AC_DEFUN([LC_QUOTA_OFF_3ARGS],
+[AC_MSG_CHECKING([quota_off needs 3 parameters])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quota.h>
+],[
+        struct quotactl_ops *qop;
+        qop->quota_off(NULL, 0, 0);
+],[
+        AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
+                [quota_off needs 3 paramters])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 has vfs_dq_off inline function.
+AC_DEFUN([LC_VFS_DQ_OFF],
+[AC_MSG_CHECKING([vfs_dq_off is defined])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quotaops.h>
+],[
+        vfs_dq_off(NULL, 0);
+],[
+        AC_DEFINE(HAVE_VFS_DQ_OFF, 1, [vfs_dq_off is defined])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
+# Ensure stack size big than 8k in Lustre server
+AC_DEFUN([LC_STACK_SIZE],
+[AC_MSG_CHECKING([stack size big than 8k])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/thread_info.h>
+],[
+        #if THREAD_SIZE < 8192
+        #error "stack size < 8192"
+        #endif
+],[
+        AC_MSG_RESULT(yes)
+],[
+        AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
+])
 ])
 
 #
@@ -2138,6 +2796,7 @@ AC_DEFUN([LC_PROG_LINUX],
          [LC_LUSTRE_VERSION_H
           if test x$enable_server = xyes ; then
               LC_CONFIG_BACKINGFS
+              LC_STACK_SIZE
           fi
           LC_CONFIG_PINGER
           LC_CONFIG_CHECKSUM
@@ -2145,22 +2804,20 @@ AC_DEFUN([LC_PROG_LINUX],
           LC_CONFIG_HEALTH_CHECK_WRITE
           LC_CONFIG_LRU_RESIZE
           LC_CONFIG_ADAPTIVE_TIMEOUTS
+          LC_CONFIG_DELAYED_RECOVERY
           LC_QUOTA_MODULE
 
           LC_TASK_PPTR
           # RHEL4 patches
-          LC_EXPORT_TRUNCATE_COMPLETE
+          LC_EXPORT_TRUNCATE_COMPLETE_PAGE
+          LC_EXPORT_TRUNCATE_RANGE
           LC_EXPORT_D_REHASH_COND
           LC_EXPORT___D_REHASH
           LC_EXPORT_D_MOVE_LOCKED
           LC_EXPORT___D_MOVE
           LC_EXPORT_NODE_TO_CPUMASK
 
-          LC_STRUCT_KIOBUF
-          LC_FUNC_COND_RESCHED
-          LC_FUNC_ZAP_PAGE_RANGE
-          LC_FUNC_PDE
-          LC_FUNC_DIRECT_IO
+          LC_FUNC_RELEASEPAGE_WITH_GFP
           LC_HEADER_MM_INLINE
           LC_STRUCT_INODE
           LC_FUNC_REGISTER_CACHE
@@ -2177,18 +2834,26 @@ AC_DEFUN([LC_PROG_LINUX],
           LC_STRUCT_INTENT_FILE
           LC_POSIX_ACL_XATTR_H
           LC_EXPORT___IGET
-          LC_FUNC_SET_FS_PWD
           LC_FUNC_MS_FLOCK_LOCK
           LC_FUNC_HAVE_CAN_SLEEP_ARG
           LC_FUNC_F_OP_FLOCK
           LC_QUOTA_READ
           LC_COOKIE_FOLLOW_LINK
           LC_FUNC_RCU
+          LC_PERCPU_COUNTER
           LC_QUOTA64
+          LC_4ARGS_VFS_SYMLINK
 
           # does the kernel have VFS intent patches?
           LC_VFS_INTENT_PATCHES
 
+	  # 2.6.5 sles9
+	  LC_HAVE_SYSCTL_VFS_CACHE_PRESSURE
+
+          # 2.6.12
+          LC_RW_TREE_LOCK
+          LC_EXPORT_SYNCHRONIZE_RCU
+
           # 2.6.15
           LC_INODE_I_MUTEX
 
@@ -2204,6 +2869,11 @@ AC_DEFUN([LC_PROG_LINUX],
           LC_VFS_KERN_MOUNT
           LC_INVALIDATEPAGE_RETURN_INT
           LC_UMOUNTBEGIN_HAS_VFSMOUNT
+          LC_INODE_IPRIVATE
+          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
+          if test x$enable_server = xyes ; then
+                LC_EXPORT_INVALIDATE_MAPPING_PAGES
+          fi
 
           #2.6.18 + RHEL5 (fc6)
           LC_PG_FS_MISC
@@ -2212,6 +2882,7 @@ AC_DEFUN([LC_PROG_LINUX],
           # 2.6.19
           LC_INODE_BLKSIZE
           LC_VFS_READDIR_U64_INO
+          LC_FILE_UPDATE_TIME
           LC_FILE_WRITEV
           LC_FILE_READV
 
@@ -2220,14 +2891,49 @@ AC_DEFUN([LC_PROG_LINUX],
 
           # raid5-zerocopy patch
           LC_PAGE_CONSTANT
-	  
-	  # 2.6.22
+
+          # 2.6.22
           LC_INVALIDATE_BDEV_2ARG
           LC_FS_RENAME_DOES_D_MOVE
           # 2.6.23
           LC_UNREGISTER_BLKDEV_RETURN_INT
+          LC_KERNEL_SENDFILE
           LC_KERNEL_SPLICE_READ
           LC_HAVE_EXPORTFS_H
+          LC_VM_OP_FAULT
+          LC_REGISTER_SHRINKER
+          LC_PROCFS_USERS
+
+          # 2.6.25
+          LC_MAPPING_CAP_WRITEBACK_DIRTY
+
+          # 2.6.24
+          LC_HAVE_MMTYPES_H
+          LC_BIO_ENDIO_2ARG
+          LC_FH_TO_DENTRY
+          LC_PROCFS_DELETED
+
+          # 2.6.26
+          LC_FS_STRUCT_USE_PATH
+          LC_RCU_LIST_SAFE
+
+          # 2.6.27
+          LC_INODE_PERMISION_2ARGS
+          LC_FILE_REMOVE_SUID
+          LC_TRYLOCKPAGE
+          LC_RW_TREE_LOCK
+          LC_READ_INODE_IN_SBOPS
+          LC_EXPORT_INODE_PERMISSION
+          LC_QUOTA_ON_5ARGS
+          LC_QUOTA_OFF_3ARGS
+          LC_VFS_DQ_OFF
+
+          # 2.6.27.15-2 sles11
+          LC_BI_HW_SEGMENTS
+          LC_HAVE_QUOTAIO_V1_H
+          LC_VFS_SYMLINK_5ARGS
+          LC_SB_ANY_QUOTA_ACTIVE
+          LC_SB_HAS_QUOTA_ACTIVE
 ])
 
 #
@@ -2289,46 +2995,48 @@ fi
 # --enable-mpitest
 #
 AC_ARG_ENABLE(mpitests,
-	AC_HELP_STRING([--enable-mpitest=yes|no|mpich directory],
+	AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
                            [include mpi tests]),
 	[
 	 enable_mpitests=yes
          case $enableval in
          yes)
-		MPI_ROOT=/opt/mpich
-		LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
-		CFLAGS="$CFLAGS -I$MPI_ROOT/include"
+		MPICC_WRAPPER=mpicc
 		;;
          no)
 		enable_mpitests=no
 		;;
-	 [[\\/$]]* | ?:[[\\/]]* )
-		MPI_ROOT=$enableval
-		LDFLAGS="$LDFLAGS -L$with_mpi/lib"
-		CFLAGS="$CFLAGS -I$MPI_ROOT/include"
-                ;;
          *)
-                 AC_MSG_ERROR([expected absolute directory name for --enable-mpitests or yes or no])
+		MPICC_WRAPPER=$enableval
                  ;;
 	 esac
 	],
 	[
-	MPI_ROOT=/opt/mpich
-        LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
-        CFLAGS="$CFLAGS -I$MPI_ROOT/include"
+	MPICC_WRAPPER=mpicc
 	enable_mpitests=yes
 	]
 )
-AC_SUBST(MPI_ROOT)
 
 if test x$enable_mpitests != xno; then
-	AC_MSG_CHECKING([whether to mpitests can be built])
-        AC_CHECK_FILE([$MPI_ROOT/include/mpi.h],
-                      [AC_CHECK_LIB([mpich],[MPI_Start],[enable_mpitests=yes],[enable_mpitests=no])],
-                      [enable_mpitests=no])
+	AC_MSG_CHECKING([whether mpitests can be built])
+	oldcc=$CC
+	CC=$MPICC_WRAPPER
+	AC_LINK_IFELSE(
+	    [AC_LANG_PROGRAM([[
+		    #include <mpi.h>
+	        ]],[[
+		    int flag;
+		    MPI_Initialized(&flag);
+		]])],
+	    [
+		    AC_MSG_RESULT([yes])
+	    ],[
+		    AC_MSG_RESULT([no])
+		    enable_mpitests=no
+	])
+	CC=$oldcc
 fi
-AC_MSG_RESULT([$enable_mpitests])
-
+AC_SUBST(MPICC_WRAPPER)
 
 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
@@ -2352,15 +3060,28 @@ fi
 AC_DEFUN([LC_CONFIG_ADAPTIVE_TIMEOUTS],
 [AC_MSG_CHECKING([whether to enable ptlrpc adaptive timeouts support])
 AC_ARG_ENABLE([adaptive_timeouts],
-	AC_HELP_STRING([--enable-adaptive-timeouts],
-			[enable ptlrpc adaptive timeouts support]),
-	[],[enable_adaptive_timeouts='no'])
+	AC_HELP_STRING([--disable-adaptive-timeouts],
+			[disable ptlrpc adaptive timeouts support]),
+	[],[enable_adaptive_timeouts='yes'])
 AC_MSG_RESULT([$enable_adaptive_timeouts])
 if test x$enable_adaptive_timeouts == xyes; then
    AC_DEFINE(HAVE_AT_SUPPORT, 1, [Enable adaptive timeouts support])
 fi
 ])
 
+# config delayed recovery
+AC_DEFUN([LC_CONFIG_DELAYED_RECOVERY],
+[AC_MSG_CHECKING([whether to enable delayed recovery support])
+AC_ARG_ENABLE([delayed-recovery],
+	AC_HELP_STRING([--enable-delayed-recovery],
+			[enable late recovery after main one]),
+	[],[enable_delayed_recovery='no'])
+AC_MSG_RESULT([$enable_delayed_recovery])
+if test x$enable_delayed_recovery == xyes; then
+   AC_DEFINE(HAVE_DELAYED_RECOVERY, 1, [Enable delayed recovery support])
+fi
+])
+
 #
 # LC_CONFIG_QUOTA
 #
@@ -2460,6 +3181,7 @@ LB_LINUX_TRY_COMPILE([
         ],[
                 AC_MSG_RESULT([no]) 
         ])
+
 ],[
         AC_MSG_RESULT([no])
 ])
@@ -2470,6 +3192,7 @@ LB_LINUX_TRY_COMPILE([
 # linux kernel may have 64-bit limits support
 #
 AC_DEFUN([LC_QUOTA64],
+if test x$enable_server = xyes ; then
 [AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
 LB_LINUX_TRY_COMPILE([
         #include <linux/kernel.h>
@@ -2480,17 +3203,30 @@ LB_LINUX_TRY_COMPILE([
 ],[],[
         AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
         AC_MSG_RESULT([yes])
-
 ],[
-        AC_MSG_WARN([4 TB (or larger) block quota limits can only be used with OSTs not larger than 4 TB.])
-        AC_MSG_WARN([Continuing with limited quota support.])
-        AC_MSG_WARN([quotacheck is needed for filesystems with recent quota versions.])
-        AC_MSG_RESULT([no])
+        tmp_flags="$EXTRA_KCFLAGS"
+        EXTRA_KCFLAGS="-I $LINUX/fs"
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/kernel.h>
+                #include <linux/fs.h>
+                #include <quotaio_v2.h>
+                struct v2r1_disk_dqblk dqblk_r1;
+        ],[],[
+                AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
+                AC_MSG_RESULT([yes])
+        ],[
+                AC_MSG_RESULT([no])
+                AC_MSG_WARN([4 TB (or larger) block quota limits can only be used with OSTs not larger than 4 TB.])
+                AC_MSG_WARN([Continuing with limited quota support.])
+                AC_MSG_WARN([quotacheck is needed for filesystems with recent quota versions.])
+        ])
+        EXTRA_KCFLAGS=$tmp_flags
 ])
+fi
 ])
 
 # LC_SECURITY_PLUG  # for SLES10 SP2
-# check security plug in sles10 sp2 kernel 
+# check security plug in sles10 sp2 kernel
 AC_DEFUN([LC_SECURITY_PLUG],
 [AC_MSG_CHECKING([If kernel has security plug support])
 LB_LINUX_TRY_COMPILE([
@@ -2510,6 +3246,32 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+AC_DEFUN([LC_PERCPU_COUNTER],
+[AC_MSG_CHECKING([if have struct percpu_counter defined])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/percpu_counter.h>
+],[],[
+        AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
+        AC_MSG_RESULT([yes])
+
+        AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/percpu_counter.h>
+        ],[
+                struct percpu_counter c;
+                percpu_counter_init(&c, 0);
+        ],[
+                AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
+                                                   arguments])
+                AC_MSG_RESULT([yes])
+        ],[
+                AC_MSG_RESULT([no])
+        ])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
 #
 # LC_CONFIGURE
 #
@@ -2518,6 +3280,10 @@ LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_CONFIGURE],
 [LC_CONFIG_OBD_BUFFER_SIZE
 
+if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
+        CFLAGS="$CFLAGS -Werror"
+fi
+
 # include/liblustre.h
 AC_CHECK_HEADERS([asm/page.h sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
 
@@ -2620,6 +3386,7 @@ lustre/kernel_patches/targets/2.6-rhel5.target
 lustre/kernel_patches/targets/2.6-fc5.target
 lustre/kernel_patches/targets/2.6-patchless.target
 lustre/kernel_patches/targets/2.6-sles10.target
+lustre/kernel_patches/targets/2.6-sles11.target
 lustre/kernel_patches/targets/hp_pnnl-2.4.target
 lustre/kernel_patches/targets/rh-2.4.target
 lustre/kernel_patches/targets/rhel-2.4.target
@@ -2628,6 +3395,7 @@ lustre/kernel_patches/targets/sles-2.4.target
 lustre/ldlm/Makefile
 lustre/liblustre/Makefile
 lustre/liblustre/tests/Makefile
+lustre/liblustre/tests/mpi/Makefile
 lustre/llite/Makefile
 lustre/llite/autoMakefile
 lustre/lov/Makefile
@@ -2658,8 +3426,8 @@ lustre/ptlrpc/autoMakefile
 lustre/quota/Makefile
 lustre/quota/autoMakefile
 lustre/scripts/Makefile
-lustre/scripts/version_tag.pl
 lustre/tests/Makefile
+lustre/tests/mpi/Makefile
 lustre/utils/Makefile
 ])
 case $lb_target_os in
@@ -2776,29 +3544,18 @@ AC_MSG_CHECKING([that RedHat kernel])
 LB_LINUX_TRY_COMPILE([
 		#include <linux/version.h>
 	],[
-		#ifndef RHEL_MAJOR
+		#ifndef RHEL_RELEASE_CODE
 		#error "not redhat kernel"
 		#endif
 	],[
 		RHEL_KENEL="yes"
+		RHEL_KERNEL="yes"
 		AC_MSG_RESULT([yes])
 	],[
-		AC_MSG_RESULT([no])
+	        AC_MSG_RESULT([no])
 ])
 
-AC_MSG_CHECKING([that SuSe kernel])
-LB_LINUX_TRY_COMPILE([
-		#include <linux/version.h>
-	],[
-		#ifndef SLE_VERSION_CODE
-		#error "not sles kernel"
-		#endif
-	],[
-		SUSE_KERNEL="yes"
-		AC_MSG_RESULT([yes])
-	],[
-		AC_MSG_RESULT([no])
-])
+LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
 
 ])
 
@@ -2813,7 +3570,13 @@ AC_DEFUN([LB_LINUX_PATH],
 AC_ARG_WITH([linux],
 	AC_HELP_STRING([--with-linux=path],
 		       [set path to Linux source (default=/usr/src/linux)]),
-	[LINUX=$with_linux],
+	[
+		if ! [[[ $with_linux = /* ]]]; then
+			AC_MSG_ERROR([You must provide an absolute pathname to the --with-linux= option.])
+		else
+			LINUX=$with_linux
+		fi
+	],
 	[LINUX=/usr/src/linux])
 AC_MSG_RESULT([$LINUX])
 AC_SUBST(LINUX)
@@ -2858,9 +3621,9 @@ LB_CHECK_FILE([$LINUX_CONFIG],[],
 # at 2.6.19 # $LINUX/include/linux/config.h is removed
 # and at more old has only one line
 # include <autoconf.h>
-LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
-		$LINUX_OBJ/include/linux/version.h
-		],[],
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[],
+	[AC_MSG_ERROR([Run make config in $LINUX.])])
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
 	[AC_MSG_ERROR([Run make config in $LINUX.])])
 
 # ------------ rhconfig.h includes runtime-generated bits --
@@ -2971,7 +3734,7 @@ if test -e $LINUX/include/asm-um ; then
 		UML_CFLAGS='-O0'
 		AC_MSG_RESULT(yes)
     	else
-		AC_MSG_RESULT([no (asm doesn't point at asm-um)])
+		AC_MSG_RESULT([no])
 	fi
 else
 	AC_MSG_RESULT([no (asm-um missing)])
@@ -3033,7 +3796,7 @@ AC_DEFUN([LB_LINUX_ARCH],
          [AC_MSG_CHECKING([Linux kernel architecture])
           AS_IF([rm -f $PWD/build/arch
                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
-                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX_OBJ $ARCH_UM \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
                 [AC_MSG_RESULT([$LINUX_ARCH])],
                 [AC_MSG_ERROR([Could not determine the kernel architecture.])])
@@ -3125,6 +3888,72 @@ fi
 ])
 
 #
+# LB_CONFIG_OFED_BACKPORTS
+#
+# include any OFED backport headers in all compile commands
+# NOTE: this does only include the backport paths, not the OFED headers
+#       adding the OFED headers is done in the lnet portion
+AC_DEFUN([LB_CONFIG_OFED_BACKPORTS],
+[AC_MSG_CHECKING([whether to use any OFED backport headers])
+# set default
+AC_ARG_WITH([o2ib],
+	AC_HELP_STRING([--with-o2ib=path],
+	               [build o2iblnd against path]),
+	[
+		case $with_o2ib in
+		yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+			ENABLEO2IB=2
+			;;
+		no)     ENABLEO2IB=0
+			;;
+		*)      O2IBPATHS=$with_o2ib
+			ENABLEO2IB=3
+			;;
+		esac
+	],[
+		O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+		ENABLEO2IB=1
+	])
+if test $ENABLEO2IB -eq 0; then
+	AC_MSG_RESULT([no])
+else
+	o2ib_found=false
+	for O2IBPATH in $O2IBPATHS; do
+		if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+			o2ib_found=true
+			break
+		fi
+	done
+	if ! $o2ib_found; then
+		AC_MSG_RESULT([no])
+		case $ENABLEO2IB in
+			1) ;;
+			2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
+			3) AC_MSG_ERROR([bad --with-o2ib path]);;
+			*) AC_MSG_ERROR([internal error]);;
+		esac
+	else
+                if test -f $O2IBPATH/config.mk; then
+			. $O2IBPATH/config.mk
+                elif test -f $O2IBPATH/ofed_patch.mk; then
+			. $O2IBPATH/ofed_patch.mk
+		fi
+		if test -n "$BACKPORT_INCLUDES"; then
+			OFED_BACKPORT_PATH=`echo $BACKPORT_INCLUDES | sed "s#.*/src/ofa_kernel/#$O2IBPATH/#"`
+			EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
+			AC_MSG_RESULT([yes])
+		else
+			AC_MSG_RESULT([no])
+                fi
+	fi
+fi
+])
+
+
+#
 # LB_PROG_LINUX
 #
 # linux tests
@@ -3134,11 +3963,6 @@ AC_DEFUN([LB_PROG_LINUX],
 LB_LINUX_ARCH
 LB_LINUX_SYMVERFILE
 
-#if test $LINUX_ARCH == "powerpc64"; then
-#	AC_MSG_WARN([set compiler with -m64])
-#	CFLAGS="$CFLAGS -m64"
-#	CC="$CC -m64"
-#fi
 
 LB_LINUX_CONFIG([MODULES],[],[
 	AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
@@ -3146,10 +3970,6 @@ LB_LINUX_CONFIG([MODULES],[],[
 
 LB_LINUX_CONFIG([MODVERSIONS])
 
-LB_LINUX_CONFIG([PREEMPT],[
-	AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
-])
-
 LB_LINUX_CONFIG([KALLSYMS],[],[
 if test "x$ARCH_UM" = "x" ; then
 	AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
@@ -3164,6 +3984,10 @@ LB_LINUX_CONFIG([KMOD],[],[
 
 #LB_LINUX_CONFIG_BIG_STACK
 
+# it's ugly to be doing anything with OFED outside of the lnet module, but
+# this has to be done here so that the backports path is set before all of
+# the LN_PROG_LINUX checks are done
+LB_CONFIG_OFED_BACKPORTS
 ])
 
 #
@@ -3187,7 +4011,7 @@ AC_DEFUN([LB_LINUX_CONDITIONALS],
 # 2.6 based kernels - put modversion info into $LINUX/Module.modvers
 # or check
 AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
-[AC_MSG_CHECKING([if Linux was built with symbol $1 is exported])
+[AC_MSG_CHECKING([if Linux was built with symbol $1 exported])
 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -3214,6 +4038,21 @@ fi
 ])
 
 #
+# Like AC_CHECK_HEADER but checks for a kernel-space header
+#
+m4_define([LB_CHECK_LINUX_HEADER],
+[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+AC_CACHE_CHECK([for $1], ac_Header,
+	       [LB_LINUX_COMPILE_IFELSE([LB_LANG_PROGRAM([@%:@include <$1>])],
+				  [modules],
+				  [test -s build/conftest.o],
+				  [AS_VAR_SET(ac_Header, [yes])],
+				  [AS_VAR_SET(ac_Header, [no])])])
+AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
+AS_VAR_POPDEF([ac_Header])dnl
+])
+
+#
 # LN_CONFIG_MAX_PAYLOAD
 #
 # configure maximum payload
@@ -3761,7 +4600,8 @@ else
 		O2IBCPPFLAGS="-I$O2IBPATH/include"
 		EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
 		EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
-		EXTRA_LNET_INCLUDE="$O2IBCPPFLAGS $EXTRA_LNET_INCLUDE"
+		EXTRA_LNET_INCLUDE="$EXTRA_LNET_INCLUDE $O2IBCPPFLAGS"
+
 		LB_LINUX_TRY_COMPILE([
 		        #include <linux/version.h>
 		        #include <linux/pci.h>
@@ -3806,52 +4646,22 @@ else
 					break;
 				fi
 			done
-			if test -n $O2IB_SYMVER ; then
+			if test -n "$O2IB_SYMVER"; then
 				AC_MSG_NOTICE([adding $O2IBPATH/Module.symvers to $PWD/$SYMVERFILE])
 				# strip out the existing symbols versions first
-				egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
+				if test -f $PWD/$SYMVERFILE; then
+				    egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
+				else
+				    touch $PWD/$SYMVERFILE.old
+				fi
 				cat $PWD/$SYMVERFILE.old $O2IBPATH/$O2IB_SYMVER > $PWD/$SYMVERFILE
+				rm $PWD/$SYMVERFILE.old
 			else
 				AC_MSG_ERROR([an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
 			fi
 		fi
 
-		LB_LINUX_TRY_COMPILE([
-			#include <linux/version.h>
-			#include <linux/pci.h>
-			#if !HAVE_GFP_T
-			typedef int gfp_t;
-			#endif
-			#include <rdma/ib_verbs.h>
-		],[
-			ib_dma_map_single(NULL, NULL, 0, 0);
-			return 0;
-		],[
-			AC_MSG_RESULT(yes)
-			AC_DEFINE(HAVE_OFED_IB_DMA_MAP, 1,
-				  [ib_dma_map_single defined])
-		],[
-			AC_MSG_RESULT(NO)
-		])
-
-		LB_LINUX_TRY_COMPILE([
-			#include <linux/version.h>
-			#include <linux/pci.h>
-			#if !HAVE_GFP_T
-			typedef int gfp_t;
-			#endif
-			#include <rdma/ib_verbs.h>
-		],[
-			ib_create_cq(NULL, NULL, NULL, NULL, 0, 0);
-			return 0;
-		],[
-			AC_MSG_RESULT(yes)
-			AC_DEFINE(HAVE_OFED_IB_COMP_VECTOR, 1,
-				  [has completion vector])
-		],[
-			AC_MSG_RESULT(NO)
-		])
-
+		LN_CONFIG_OFED_SPEC
 		EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 	fi
 fi
@@ -4313,24 +5123,48 @@ AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
 ])
 ])
 
+# check kernel __u64 type
+AC_DEFUN([LN_KERN__U64_LONG_LONG],
+[AC_MSG_CHECKING([kernel __u64 is long long type])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
+LB_LINUX_TRY_COMPILE([
+	#include <linux/types.h>
+	#include <linux/stddef.h>
+],[
+	unsigned long long *data1;
+	__u64 *data2 = NULL;
+		
+	data1 = data2;
+],[
+	AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
+                  [kernel __u64 is long long type])
+],[
+	AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
 # check userland __u64 type
-AC_DEFUN([LN_U64_LONG_LONG],
-[AC_MSG_CHECKING([__u64 is long long type])
+AC_DEFUN([LN_USER__U64_LONG_LONG],
+[AC_MSG_CHECKING([userspace __u64 is long long type])
 tmp_flags="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE([
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		unsigned long long *data1;
-		__u64 *data2;
+		__u64 *data2 = NULL;
 		
 		data1 = data2;
 		return 0;
 	}
 ],[
 	AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_U64_LONG_LONG, 1,
-                  [__u64 is long long type])
+        AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
+                  [userspace __u64 is long long type])
 ],[
 	AC_MSG_RESULT([no])
 ])
@@ -4344,9 +5178,10 @@ tmp_flags="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE([
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		unsigned long *data1;
-		size_t *data2;
+		size_t *data2 = NULL;
 		
 		data1 = data2;
 		return 0;
@@ -4367,9 +5202,10 @@ tmp_flags="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE([
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		long *data1;
-		ssize_t *data2;
+		ssize_t *data2 = NULL;
 		
 		data1 = data2;
 		return 0;
@@ -4403,6 +5239,24 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 
+# check if task_struct with rcu memeber
+AC_DEFUN([LN_TASK_RCU],
+[AC_MSG_CHECKING([if task_struct has a rcu field])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/sched.h>
+],[
+        struct task_struct tsk;
+
+        tsk.rcu.next = NULL;
+],[
+	AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_TASK_RCU, 1,
+                  [task_struct has rcu field])
+],[
+	AC_MSG_RESULT([no])
+])
+])
+
 # LN_TASKLIST_LOCK
 # 2.6.18 remove tasklist_lock export
 AC_DEFUN([LN_TASKLIST_LOCK],
@@ -4509,6 +5363,7 @@ LB_LINUX_TRY_COMPILE([
 ])
 EXTRA_KCFLAGS="$tmp_flags"
 ])
+
 # 2.6.23 lost dtor argument
 AC_DEFUN([LN_KMEM_CACHE_CREATE_DTOR],
 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
@@ -4525,6 +5380,52 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+#
+# LN_FUNC_DUMP_TRACE
+#
+# 2.6.23 exports dump_trace() so we can dump_stack() on any task
+# 2.6.24 has stacktrace_ops.address with "reliable" parameter
+#
+AC_DEFUN([LN_FUNC_DUMP_TRACE],
+[LB_CHECK_SYMBOL_EXPORT([dump_trace],
+[kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c],[
+	tmp_flags="$EXTRA_KCFLAGS"
+	EXTRA_KCFLAGS="-Werror"
+	AC_MSG_CHECKING([whether we can really use dump_stack])
+	LB_LINUX_TRY_COMPILE([
+		struct task_struct;
+		struct pt_regs;
+		#include <asm/stacktrace.h>
+	],[
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
+	],[
+		AC_MSG_RESULT(no)
+	],[
+	])
+	AC_MSG_CHECKING([whether print_trace_address has reliable argument])
+	LB_LINUX_TRY_COMPILE([
+		struct task_struct;
+		struct pt_regs;
+		void print_addr(void *data, unsigned long addr, int reliable);
+		#include <asm/stacktrace.h>
+	],[
+		struct stacktrace_ops ops;
+
+		ops.address = print_addr;
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
+			  [print_trace_address has reliable argument])
+	],[
+		AC_MSG_RESULT(no)
+	],[
+	])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+])
+
 # 2.6.24 request not use real numbers for ctl_name
 AC_DEFUN([LN_SYSCTL_UNNUMBERED],
 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
@@ -4539,7 +5440,7 @@ LB_LINUX_TRY_COMPILE([
         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
                   [sysctl has CTL_UNNUMBERED])
 ],[
-        AC_MSG_RESULT(NO)
+        AC_MSG_RESULT(no)
 ])
 ])
 
@@ -4555,7 +5456,7 @@ LB_LINUX_TRY_COMPILE([
         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
                   [struct scatterlist has page member])
 ],[
-        AC_MSG_RESULT(NO)
+        AC_MSG_RESULT(no)
 ])
 ])
 
@@ -4573,10 +5474,36 @@ LB_LINUX_TRY_COMPILE([
         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
                   [semaphore counter is atomic])
 ],[
-        AC_MSG_RESULT(NO)
+        AC_MSG_RESULT(no)
 ])
 ])
 
+# 2.6.27 have second argument to sock_map_fd
+AC_DEFUN([LN_SOCK_MAP_FD_2ARG],
+[AC_MSG_CHECKING([sock_map_fd have second argument])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/net.h>
+],[
+        sock_map_fd(NULL, 0);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
+                  [sock_map_fd have second argument])
+],[
+        AC_MSG_RESULT(no)
+])
+])
+
+#
+#
+# LN_CONFIG_USERSPACE
+#
+#
+AC_DEFUN([LN_CONFIG_USERSPACE],
+[
+LN_USER__U64_LONG_LONG
+])
+
 #
 # LN_PROG_LINUX
 #
@@ -4604,10 +5531,11 @@ LN_CONFIG_MX
 LN_STRUCT_PAGE_LIST
 LN_STRUCT_SIGHAND
 LN_FUNC_SHOW_TASK
-LN_U64_LONG_LONG
+LN_KERN__U64_LONG_LONG
 LN_SSIZE_T_LONG
 LN_SIZE_T_LONG
 LN_LE_TYPES
+LN_TASK_RCU
 # 2.6.18
 LN_TASKLIST_LOCK
 # 2.6.19
@@ -4625,6 +5553,9 @@ LN_SYSCTL_UNNUMBERED
 LN_SCATTERLIST_SETPAGE
 # 2.6.26
 LN_SEM_COUNT
+# 2.6.27
+LN_SOCK_MAP_FD_2ARG
+LN_FUNC_DUMP_TRACE
 ])
 
 #
@@ -4889,6 +5820,103 @@ AC_DEFUN([LIBCFS_CONDITIONALS], [])
 AC_DEFUN([LIBCFS_CONFIGURE], [])
 AC_DEFUN([LIBCFS_CONFIG_FILES], [])
 
+dnl Checks for OFED
+AC_DEFUN([LN_CONFIG_OFED_SPEC],
+[
+	AC_MSG_CHECKING([if OFED has ib_dma_map_single])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
+	],[
+		ib_dma_map_single(NULL, NULL, 0, 0);
+		return 0;
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_IB_DMA_MAP, 1,
+			  [ib_dma_map_single defined])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if ib_create_cq wants comp_vector])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
+	],[
+		ib_create_cq(NULL, NULL, NULL, NULL, 0, 0);
+		return 0;
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_IB_COMP_VECTOR, 1,
+			  [has completion vector])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if OFED supports iWarp transport])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
+	],[
+		return RDMA_TRANSPORT_IWARP ==
+		       rdma_node_get_transport(RDMA_NODE_RNIC);
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_TRANSPORT_IWARP, 1,
+			  [has transport iWARP])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if OFED has RDMA_CM_EVENT_ADDR_CHANGE])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/rdma_cm.h>
+	],[
+		return (RDMA_CM_EVENT_ADDR_CHANGE == 0);
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_RDMA_CMEV_ADDRCHANGE, 1,
+			  [has completion vector])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if OFED has RDMA_CM_EVENT_TIMEWAIT_EXIT])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/rdma_cm.h>
+	],[
+		return (RDMA_CM_EVENT_TIMEWAIT_EXIT == 0);
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_RDMA_CMEV_TIMEWAIT_EXIT, 1,
+			  [has completion vector])
+	],[
+		AC_MSG_RESULT(no)
+	])
+])
+
 #
 # LB_DARWIN_CHECK_FUNCS
 #
@@ -4904,7 +5932,7 @@ do
 AC_MSG_CHECKING([for $1])
 AS_IF([AC_TRY_COMMAND(nm /mach | grep "[$1]" >/dev/null 2>/dev/null)],[
 	AC_MSG_RESULT([yes])
-	AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$ac_func])]) $2
+	AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2
 ],[
 	AC_MSG_RESULT([no]) $3
 ])dnl
diff --git a/autoMakefile.am b/autoMakefile.am
index 2a9976f..a6e21e4 100644
--- a/autoMakefile.am
+++ b/autoMakefile.am
@@ -40,3 +40,8 @@ checkstack-update:
 
 checkstack-clean:
 	rm -f ${CSTK} ${CSTKO}
+
+module-dist-hook:
+	if [ -d CVS -o -d .git ]; then \
+	    perl lustre/scripts/tree_status.pl > $(distdir)/tree_status; \
+	fi
diff --git a/autoMakefile.in b/autoMakefile.in
index a42b68c..d91e4f1 100644
--- a/autoMakefile.in
+++ b/autoMakefile.in
@@ -177,9 +177,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -334,6 +334,7 @@ CONFIG_CLEAN_FILES = Makefile Rules lustre.spec \
 	lustre/kernel_patches/targets/2.6-fc5.target \
 	lustre/kernel_patches/targets/2.6-patchless.target \
 	lustre/kernel_patches/targets/2.6-sles10.target \
+	lustre/kernel_patches/targets/2.6-sles11.target \
 	lustre/kernel_patches/targets/hp_pnnl-2.4.target \
 	lustre/kernel_patches/targets/rh-2.4.target \
 	lustre/kernel_patches/targets/rhel-2.4.target \
@@ -408,6 +409,8 @@ lustre/kernel_patches/targets/2.6-patchless.target: $(top_builddir)/config.statu
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 lustre/kernel_patches/targets/2.6-sles10.target: $(top_builddir)/config.status $(top_srcdir)/lustre/kernel_patches/targets/2.6-sles10.target.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
+lustre/kernel_patches/targets/2.6-sles11.target: $(top_builddir)/config.status $(top_srcdir)/lustre/kernel_patches/targets/2.6-sles11.target.in
+	cd $(top_builddir) && $(SHELL) ./config.status $@
 lustre/kernel_patches/targets/hp_pnnl-2.4.target: $(top_builddir)/config.status $(top_srcdir)/lustre/kernel_patches/targets/hp_pnnl-2.4.target.in
 	cd $(top_builddir) && $(SHELL) ./config.status $@
 lustre/kernel_patches/targets/rh-2.4.target: $(top_builddir)/config.status $(top_srcdir)/lustre/kernel_patches/targets/rh-2.4.target.in
@@ -533,7 +536,7 @@ distcleancheck_listfiles = find . -type f -print
 distdir: $(DISTFILES)
 	$(am__remove_distdir)
 	mkdir $(distdir)
-	$(mkinstalldirs) $(distdir)/. $(distdir)/./build $(distdir)/build $(distdir)/build/autoconf $(distdir)/lnet $(distdir)/lnet/klnds $(distdir)/lnet/klnds/ciblnd $(distdir)/lnet/klnds/gmlnd $(distdir)/lnet/klnds/iiblnd $(distdir)/lnet/klnds/mxlnd $(distdir)/lnet/klnds/o2iblnd $(distdir)/lnet/klnds/openiblnd $(distdir)/lnet/klnds/ptllnd $(distdir)/lnet/klnds/qswlnd $(distdir)/lnet/klnds/ralnd $(distdir)/lnet/klnds/socklnd $(distdir)/lnet/klnds/viblnd $(distdir)/lnet/libcfs $(distdir)/lnet/lnet $(distdir)/lnet/selftest $(distdir)/lnet/ulnds $(distdir)/lustre $(distdir)/lustre/include $(distdir)/lustre/kernel_patches/targets $(distdir)/lustre/llite $(distdir)/lustre/lov $(distdir)/lustre/lvfs $(distdir)/lustre/mdc $(distdir)/lustre/mds $(distdir)/lustre/mgc $(distdir)/lustre/mgs $(distdir)/lustre/obdclass $(distdir)/lustre/obdecho $(distdir)/lustre/obdfilter $(distdir)/lustre/osc $(distdir)/lustre/ost $(distdir)/lustre/ptlrpc $(distdir)/lustre/quota $(distdir)/lustre/scripts
+	$(mkinstalldirs) $(distdir)/. $(distdir)/./build $(distdir)/build $(distdir)/build/autoconf $(distdir)/lnet $(distdir)/lnet/klnds $(distdir)/lnet/klnds/ciblnd $(distdir)/lnet/klnds/gmlnd $(distdir)/lnet/klnds/iiblnd $(distdir)/lnet/klnds/mxlnd $(distdir)/lnet/klnds/o2iblnd $(distdir)/lnet/klnds/openiblnd $(distdir)/lnet/klnds/ptllnd $(distdir)/lnet/klnds/qswlnd $(distdir)/lnet/klnds/ralnd $(distdir)/lnet/klnds/socklnd $(distdir)/lnet/klnds/viblnd $(distdir)/lnet/libcfs $(distdir)/lnet/lnet $(distdir)/lnet/selftest $(distdir)/lnet/ulnds $(distdir)/lustre $(distdir)/lustre/include $(distdir)/lustre/kernel_patches/targets $(distdir)/lustre/llite $(distdir)/lustre/lov $(distdir)/lustre/lvfs $(distdir)/lustre/mdc $(distdir)/lustre/mds $(distdir)/lustre/mgc $(distdir)/lustre/mgs $(distdir)/lustre/obdclass $(distdir)/lustre/obdecho $(distdir)/lustre/obdfilter $(distdir)/lustre/osc $(distdir)/lustre/ost $(distdir)/lustre/ptlrpc $(distdir)/lustre/quota
 	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
 	list='$(DISTFILES)'; for file in $$list; do \
@@ -794,7 +797,11 @@ dist-hook:
 	find $(distdir) -name .deps -o \
 			-name CVS -o \
 			-name .svn -o \
+			-name .git -o \
 			-name .#* | xargs rm -rf
+	$(MAKE) $(AM_MAKEFLAGS) \
+	  top_distdir="$(top_distdir)" distdir="$(distdir)" \
+	  module-dist-hook
 
 rpms-real: @PACKAGE_TARNAME at .spec dist Makefile
 	rpmbuild -ta $(distdir).tar.gz
@@ -843,6 +850,11 @@ checkstack-update:
 
 checkstack-clean:
 	rm -f ${CSTK} ${CSTKO}
+
+module-dist-hook:
+	if [ -d CVS -o -d .git ]; then \
+	    perl lustre/scripts/tree_status.pl > $(distdir)/tree_status; \
+	fi
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/build/autoMakefile.am.toplevel b/build/autoMakefile.am.toplevel
index aa19a1e..5df429d 100644
--- a/build/autoMakefile.am.toplevel
+++ b/build/autoMakefile.am.toplevel
@@ -64,7 +64,11 @@ dist-hook:
 	find $(distdir) -name .deps -o \
 			-name CVS -o \
 			-name .svn -o \
+			-name .git -o \
 			-name .#* | xargs rm -rf
+	$(MAKE) $(AM_MAKEFLAGS) \
+	  top_distdir="$(top_distdir)" distdir="$(distdir)" \
+	  module-dist-hook
 
 EXTRA_DIST = @PACKAGE_TARNAME at .spec					\
 	build/Makefile build/autoMakefile.am.toplevel build/lbuild	\
diff --git a/build/autoconf/lustre-build-linux.m4 b/build/autoconf/lustre-build-linux.m4
index 71ee36c..bb92895 100644
--- a/build/autoconf/lustre-build-linux.m4
+++ b/build/autoconf/lustre-build-linux.m4
@@ -104,29 +104,18 @@ AC_MSG_CHECKING([that RedHat kernel])
 LB_LINUX_TRY_COMPILE([
 		#include <linux/version.h>
 	],[
-		#ifndef RHEL_MAJOR
+		#ifndef RHEL_RELEASE_CODE
 		#error "not redhat kernel"
 		#endif
 	],[
 		RHEL_KENEL="yes"
+		RHEL_KERNEL="yes"
 		AC_MSG_RESULT([yes])
 	],[
-		AC_MSG_RESULT([no])
+	        AC_MSG_RESULT([no])
 ])
 
-AC_MSG_CHECKING([that SuSe kernel])
-LB_LINUX_TRY_COMPILE([
-		#include <linux/version.h>
-	],[
-		#ifndef SLE_VERSION_CODE
-		#error "not sles kernel"
-		#endif
-	],[
-		SUSE_KERNEL="yes"
-		AC_MSG_RESULT([yes])
-	],[
-		AC_MSG_RESULT([no])
-])
+LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
 
 ])
 
@@ -141,7 +130,13 @@ AC_DEFUN([LB_LINUX_PATH],
 AC_ARG_WITH([linux],
 	AC_HELP_STRING([--with-linux=path],
 		       [set path to Linux source (default=/usr/src/linux)]),
-	[LINUX=$with_linux],
+	[
+		if ! [[[ $with_linux = /* ]]]; then
+			AC_MSG_ERROR([You must provide an absolute pathname to the --with-linux= option.])
+		else
+			LINUX=$with_linux
+		fi
+	],
 	[LINUX=/usr/src/linux])
 AC_MSG_RESULT([$LINUX])
 AC_SUBST(LINUX)
@@ -186,9 +181,9 @@ LB_CHECK_FILE([$LINUX_CONFIG],[],
 # at 2.6.19 # $LINUX/include/linux/config.h is removed
 # and at more old has only one line
 # include <autoconf.h>
-LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
-		$LINUX_OBJ/include/linux/version.h
-		],[],
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[],
+	[AC_MSG_ERROR([Run make config in $LINUX.])])
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
 	[AC_MSG_ERROR([Run make config in $LINUX.])])
 
 # ------------ rhconfig.h includes runtime-generated bits --
@@ -299,7 +294,7 @@ if test -e $LINUX/include/asm-um ; then
 		UML_CFLAGS='-O0'
 		AC_MSG_RESULT(yes)
     	else
-		AC_MSG_RESULT([no (asm doesn't point at asm-um)])
+		AC_MSG_RESULT([no])
 	fi
 else
 	AC_MSG_RESULT([no (asm-um missing)])
@@ -361,7 +356,7 @@ AC_DEFUN([LB_LINUX_ARCH],
          [AC_MSG_CHECKING([Linux kernel architecture])
           AS_IF([rm -f $PWD/build/arch
                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
-                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX_OBJ $ARCH_UM \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
                 [AC_MSG_RESULT([$LINUX_ARCH])],
                 [AC_MSG_ERROR([Could not determine the kernel architecture.])])
@@ -453,6 +448,72 @@ fi
 ])
 
 #
+# LB_CONFIG_OFED_BACKPORTS
+#
+# include any OFED backport headers in all compile commands
+# NOTE: this does only include the backport paths, not the OFED headers
+#       adding the OFED headers is done in the lnet portion
+AC_DEFUN([LB_CONFIG_OFED_BACKPORTS],
+[AC_MSG_CHECKING([whether to use any OFED backport headers])
+# set default
+AC_ARG_WITH([o2ib],
+	AC_HELP_STRING([--with-o2ib=path],
+	               [build o2iblnd against path]),
+	[
+		case $with_o2ib in
+		yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+			ENABLEO2IB=2
+			;;
+		no)     ENABLEO2IB=0
+			;;
+		*)      O2IBPATHS=$with_o2ib
+			ENABLEO2IB=3
+			;;
+		esac
+	],[
+		O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+		ENABLEO2IB=1
+	])
+if test $ENABLEO2IB -eq 0; then
+	AC_MSG_RESULT([no])
+else
+	o2ib_found=false
+	for O2IBPATH in $O2IBPATHS; do
+		if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+			o2ib_found=true
+			break
+		fi
+	done
+	if ! $o2ib_found; then
+		AC_MSG_RESULT([no])
+		case $ENABLEO2IB in
+			1) ;;
+			2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
+			3) AC_MSG_ERROR([bad --with-o2ib path]);;
+			*) AC_MSG_ERROR([internal error]);;
+		esac
+	else
+                if test -f $O2IBPATH/config.mk; then
+			. $O2IBPATH/config.mk
+                elif test -f $O2IBPATH/ofed_patch.mk; then
+			. $O2IBPATH/ofed_patch.mk
+		fi
+		if test -n "$BACKPORT_INCLUDES"; then
+			OFED_BACKPORT_PATH=`echo $BACKPORT_INCLUDES | sed "s#.*/src/ofa_kernel/#$O2IBPATH/#"`
+			EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
+			AC_MSG_RESULT([yes])
+		else
+			AC_MSG_RESULT([no])
+                fi
+	fi
+fi
+])
+
+
+#
 # LB_PROG_LINUX
 #
 # linux tests
@@ -462,11 +523,6 @@ AC_DEFUN([LB_PROG_LINUX],
 LB_LINUX_ARCH
 LB_LINUX_SYMVERFILE
 
-#if test $LINUX_ARCH == "powerpc64"; then
-#	AC_MSG_WARN([set compiler with -m64])
-#	CFLAGS="$CFLAGS -m64"
-#	CC="$CC -m64"
-#fi
 
 LB_LINUX_CONFIG([MODULES],[],[
 	AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
@@ -474,10 +530,6 @@ LB_LINUX_CONFIG([MODULES],[],[
 
 LB_LINUX_CONFIG([MODVERSIONS])
 
-LB_LINUX_CONFIG([PREEMPT],[
-	AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
-])
-
 LB_LINUX_CONFIG([KALLSYMS],[],[
 if test "x$ARCH_UM" = "x" ; then
 	AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
@@ -492,6 +544,10 @@ LB_LINUX_CONFIG([KMOD],[],[
 
 #LB_LINUX_CONFIG_BIG_STACK
 
+# it's ugly to be doing anything with OFED outside of the lnet module, but
+# this has to be done here so that the backports path is set before all of
+# the LN_PROG_LINUX checks are done
+LB_CONFIG_OFED_BACKPORTS
 ])
 
 #
@@ -515,7 +571,7 @@ AC_DEFUN([LB_LINUX_CONDITIONALS],
 # 2.6 based kernels - put modversion info into $LINUX/Module.modvers
 # or check
 AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
-[AC_MSG_CHECKING([if Linux was built with symbol $1 is exported])
+[AC_MSG_CHECKING([if Linux was built with symbol $1 exported])
 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -540,3 +596,18 @@ else
     $3
 fi
 ])
+
+#
+# Like AC_CHECK_HEADER but checks for a kernel-space header
+#
+m4_define([LB_CHECK_LINUX_HEADER],
+[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+AC_CACHE_CHECK([for $1], ac_Header,
+	       [LB_LINUX_COMPILE_IFELSE([LB_LANG_PROGRAM([@%:@include <$1>])],
+				  [modules],
+				  [test -s build/conftest.o],
+				  [AS_VAR_SET(ac_Header, [yes])],
+				  [AS_VAR_SET(ac_Header, [no])])])
+AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
+AS_VAR_POPDEF([ac_Header])dnl
+])
diff --git a/build/autoconf/lustre-build.m4 b/build/autoconf/lustre-build.m4
index 73707bb..f2d9b0a 100644
--- a/build/autoconf/lustre-build.m4
+++ b/build/autoconf/lustre-build.m4
@@ -45,19 +45,6 @@ AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([lb_File])dnl
 ])# LB_CHECK_FILE
 
-#
-# LB_CHECK_FILES
-#
-# LB_CHECK_FILE over multiple files
-#
-AC_DEFUN([LB_CHECK_FILES],
-[AC_FOREACH([AC_FILE_NAME], [$1],
-  [LB_CHECK_FILE(AC_FILE_NAME,
-                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
-                                    [Define to 1 if you have the
-                                     file `]AC_File['.])
-$2],
-                 [$3])])])
 
 #
 # LB_ARG_LIBS_INCLUDES
@@ -240,6 +227,10 @@ AC_SUBST(LDISKFS_DIR)
 AC_SUBST(LDISKFS_SUBDIR)
 AM_CONDITIONAL(LDISKFS_ENABLED, test x$with_ldiskfs != xno)
 
+if test x$enable_ext4 = xyes ; then
+	AC_DEFINE(HAVE_EXT4_LDISKFS, 1, [build ext4 based ldiskfs])
+fi
+
 # We have to configure even if we don't build here for make dist to work
 AC_CONFIG_SUBDIRS(ldiskfs)
 ])
@@ -273,6 +264,131 @@ AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
 	AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1, [enable extented attributes for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFS_FS_NFS4ACL, 1, [enable fs security for ldiskfs])
+
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
 ])
 
 #
@@ -408,11 +524,11 @@ if test x$dmu_osd = xyes; then
 
 		AC_SUBST(spl_src)
 
-		LB_CHECK_FILE([$SPL_DIR/modules/spl/spl-generic.c],[],[
+		LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
 			AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
 		])
 
-		LB_CHECK_FILE([$ZFS_DIR/zfs/lib/libzpool/dmu.c],[],[
+		LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
 			AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
 		])
 
@@ -560,7 +676,7 @@ AC_SUBST(ENABLE_INIT_SCRIPTS)
 #
 AC_DEFUN([LB_CONFIG_HEADERS],
 [AC_CONFIG_HEADERS([config.h])
-CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
+CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
 AC_SUBST(EXTRA_KCFLAGS)
 ])
@@ -648,7 +764,7 @@ if test $target_cpu == "powerpc64"; then
 	CC="$CC -m64"
 fi
 
-CPPFLAGS="-I\$(top_builddir)/$LIBCFS_INCLUDE_DIR -I\$(top_srcdir)/$LIBCFS_INCLUDE_DIR-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
+CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
 
 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
 AC_SUBST(LLCPPFLAGS)
@@ -746,12 +862,20 @@ LC_QUOTA
 
 LB_CONFIG_MODULES
 
+LN_CONFIG_USERSPACE
+
 LB_PATH_DMU
 LB_PATH_LIBSYSIO
 LB_PATH_SNMP
 LB_PATH_LDISKFS
 LB_PATH_LUSTREIOKIT
 
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
 LC_CONFIG_LIBLUSTRE
 LIBCFS_CONFIGURE
 LN_CONFIGURE
diff --git a/build/lbuild b/build/lbuild
index 2d008a0..01ea463 100755
--- a/build/lbuild
+++ b/build/lbuild
@@ -3,6 +3,7 @@
 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
 
 #set -x
+shopt -s extdebug
 
 TOPDIR=$PWD
 
@@ -11,8 +12,12 @@ KERNELDIR=
 LINUX=
 LUSTRE=
 RELEASE=false
-DO_SRC=0
-DOWNLOAD=1
+# XXX - some recent hacking has pretty much neutered this option.
+#       search through this file (and lbuild.old_school -- but that will
+#       be going away soon) for "-bb" and see how many places
+#       simply don't account for this option
+DO_SRC=true
+DOWNLOAD=true
 TAG=
 CANONICAL_TARGET=
 TARGET=
@@ -27,39 +32,27 @@ LUSTRE_EXTRA_VERSION=
 STAGEDIR=
 TMPDIR=${TMPDIR:-"/var/tmp"}
 TIMESTAMP=
+# XXX - i think these two parameters/arguments/variables need to be
+#       cleaned up and merged.  they effectively do the same thing
 REUSERPM=
 REUSEBUILD=
+# what does this do exactly?  does it imply no kernel build?
 NORPM=false
 LDISKFSRPM=true
 SKIPLDISKFSRPM="v1_4_* b1_4"
 SMPTYPES="smp bigsmp default ''"
-KERNCONFSMPTYPE=
 PATCHLESS=false
+XEN=false
 LINUXOBJ=
-REUSEDKERNELMASK=
 DISTRO=
 KERNELTREE=
 
 # patchless build
 KERNELRPMSBASE=
-KERNELRPM=
-KERNELSOURCERPM=
 RPMSMPTYPE=
-KERNELRPMCONFIG=
-KERNELRPMRELEASE=
-KERNELCOMPILEDIR=
 
 # from target file
-KERNEL=
 SERIES=
-CONFIG=
-VERSION=
-
-RHBUILD=0
-SUSEBUILD=0
-LINUX26=0
-SUSEBUILD=0
-
 BASE_ARCHS=
 BIGMEM_ARCHS=
 BOOT_ARCHS=
@@ -69,11 +62,16 @@ BIGSMP_ARCHS=
 PSERIES64_ARCHS=
 UP_ARCHS=
 
+# not in the target file any more
+CONFIG=
+
 DATE=$(date)
 
 USE_DATESTAMP=1
 RPMBUILD=
 
+OLD_SCHOOL=false
+
 export CC=${CC:-gcc}
 
 # Readlink is not present on some older distributions: emulate it.
@@ -88,35 +86,27 @@ readlink() {
     fi
 }
 
-cleanup()
-{
+cleanup() {
+
     true
 }
 
-error()
-{
-    [ "$1" ] && echo -e "\n${0##*/}: $1"
+error() {
+    local msg="$1"
+
+    [ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&2
+
 }
 
-fatal()
-{
+fatal() {
+
     cleanup
     error "$2"
     exit $1
-}
 
-list_targets()
-{
-    echo -n "Available targets:"
-    for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
-        target_file=${target##*/}
-        echo -n " ${target_file%%.target}"
-    done
-    echo
 }
 
-usage()
-{
+usage() {
     cat <<EOF
 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
 
@@ -133,10 +123,6 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
   --extraversion=EXTRAVERSION
     Text to use for the rpm release and kernel extraversion.
 
-  --kerneldir=KERNELDIR
-    Directory containing Linux source tarballs referenced by target
-    files.
-
   --timestamp=TIMESTAMP
     Date of building lustre in format YYYYMMDDhhmmss
 
@@ -161,11 +147,15 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
   --distro=DISTRO
     Which distro using. Autodetect by default
 
+  --kerneldir=KERNELDIR
+    Directory containing Linux source tarballs referenced by target
+    files.
+
   --kerneltree=KERNELTREE
     Directory containing dirs with Linux source tarballs referenced by target
     files. Dir names in format kernel version ('2.6.9', etc.)
 
-  --linux=LINUX
+  --linux=LINUX --with-linux=LINUX
     Directory of Linux kernel sources.  When this option is used, only
     Lustre modules and userspace are built.
 
@@ -216,10 +206,13 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
     will be built - there will be no lustre-lite-utils package.
 
   --disable-datestamp
-    Prevents the datestamp flag (-D) from being passed to cvs for 
-    checkouts. This is a workaround for a problem encountered when 
+    Prevents the datestamp flag (-D) from being passed to cvs for
+    checkouts. This is a workaround for a problem encountered when
     using lbuild with tinderbox.
 
+  --xen
+    Builds a Xen domX kernel.
+
 EOF
 
 #   list_targets
@@ -227,9 +220,25 @@ EOF
     fatal "$1" "$2"
 }
 
-check_options()
-{
-    if [ "$LUSTRE" ] ; then
+# canonicalize a relative path
+canon_path() {
+    local PATH="$1"
+
+    if [ ! -d "$PATH" ]; then
+        return 1
+    fi
+
+    pushd "$PATH" >/dev/null || return 1
+    local CANONPATH=$PWD
+    popd >/dev/null
+
+    echo "$CANONPATH"
+    return 0
+}
+
+check_options() {
+
+    if [ "$LUSTRE" ]; then
         [ -r "$LUSTRE" ] || \
             usage 1 "Could not find Lustre source tarball '$LUSTRE'."
     else
@@ -239,7 +248,7 @@ check_options()
             usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
     fi
 
-    if [ -z "$LINUX" ] ; then
+    if [ -z "$LINUX" ]; then
         [ "$KERNELDIR" -o "$KERNELTREE" ] || \
             usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree."
 
@@ -270,6 +279,9 @@ check_options()
         2.6-sles10)
             CANONICAL_TARGET="sles10-2.6"
             ;;
+        2.6-sles11)
+            CANONICAL_TARGET="sles11"
+            ;;
         hp_pnnl-2.4)
             CANONICAL_TARGET="hp-pnnl-2.4"
             ;;
@@ -299,189 +311,178 @@ check_options()
             usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
         fi
     fi
-    
-    if [ -n "$CCACHE" ]; then 
-        which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
+
+    if [ -n "$CCACHE" ]; then
         which "$DISTCC" 2>/dev/null && export DISTCC RPM_BUILD_NCPUS
-        local bindir="/cache/build/bin"
-        [ -d $bindir ] || mkdir -p $bindir
-        [ -d $bindir ] && rm ${bindir}/* > /dev/null 2>&1
-        which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/ccache
-        which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/cc
-        which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/gcc
-        [ -d $bindir ] && export PATH=$bindir:$PATH
+
+        if which "$CCACHE" 2>/dev/null; then
+            local ccache=$(which "$CCACHE")
+            local bindir="$TOPDIR/bin"
+
+            [ -d $bindir ] || mkdir -p $bindir
+            if [ -d $bindir ]; then
+                rm ${bindir}/* > /dev/null 2>&1
+                ln -s "$ccache" ${bindir}/ccache
+                ln -s "$ccache" ${bindir}/cc
+                ln -s "$ccache" ${bindir}/$CC
+                export PATH=$bindir:$PATH
+            fi
+            export CCACHE && export CC="ccache $CC"
+            # zero the cache so we can see how effective we are being with it
+            ccache -z
+        fi
     fi
 
-    [ -z "$DISTRO" ] && autodetect_distro
+    [ -z "$DISTRO" ] && DISTRO=$(autodetect_distro)
 }
 
-#autodetect used Distro
-autodetect_distro()
-{
+# autodetect used Distro
+autodetect_distro() {
+
+    local name
+    local version
+
     if [ -f /etc/SuSE-release ]; then
-        DISTRO=sles10
+        name=sles
+        version=$(grep ^VERSION /etc/SuSE-release)
+        version=${version#*= }
     elif [ -f /etc/redhat-release ]; then
-        local distroname=$(head -1 /etc/redhat-release | grep -e "CentOS\|Red")
-        if [ ! "$distroname" = "" ]; then
-            local version=$(echo "$distroname" | sed -e s/[^0-9.]*//g | sed -e s/\\..*// )
-            distroname="rhel"
-            [ "$version" = "" ] || DISTRO="${distroname}${version}"
-        fi
+        name=$(head -1 /etc/redhat-release)
+        version=$(echo "$distroname" |
+                  sed -e 's/^[^0-9.]*//g' | sed -e 's/[ \.].*//')
+    fi
+    if [ -z "$name" -o -z "$version" ]; then
+        fatal 1 "I don't know how to determine distro type/version.\n" \
+                "Either update autodetect_distro() or use the --distro argument"
     fi
-    [ "$DISTRO" = "" ] && DISTRO="sles9" #default distro
-}
 
-uniqify()
-{
-    echo $(echo "$*" | xargs -n 1 | sort -u)
+    echo ${name}${version}
+    return 0
+
 }
 
-build_tarball() {
-    local TARGET=$1
-    local SRPM=$2
-
-    if [ "$TARGET" = "rhel-2.6" -o "$TARGET" = "rhel-2.4" ]; then
-        local SPEC=""
-        if [ "$TARGET" = "rhel-2.6" ]; then
-            SPEC=kernel-2.6.spec
-            OLDCONFIG=nonint_oldconfig
-        elif [ "$TARGET" = "rhel-2.4" ]; then
-            SPEC=kernel-2.4.spec
-            OLDCONFIG=oldconfig
-        fi
+uniqify() {
+
+    echo $(echo "$*" | xargs -n 1 | sort -u)
 
-        RPMTOPDIR=$(mktemp -d $KERNELDIR/rpm_XXXXXX)
-        mkdir $RPMTOPDIR/BUILD/
-        rpm -ivh $KERNELDIR/$SRPM --define "_topdir $RPMTOPDIR" || \
-            { rm -rf $RPMTOPDIR; fatal 1 "Error installing kernel SRPM."; }
-        $RPMBUILD -bp --nodeps --target i686 $RPMTOPDIR/SPECS/$SPEC --define "_topdir $RPMTOPDIR"
-        pushd $RPMTOPDIR/BUILD/kernel-${lnxmaj}/linux-${lnxmaj} && {
-            make mrproper
-            cp configs/kernel-${lnxmaj}-i686-smp.config .config
-            if ! make $OLDCONFIG > /dev/null; then
-                fatal 1 "error trying to make $OLDCONFIG while building a tarball from SRPM."
-            fi
-            make include/linux/version.h 
-            rm -f .config
-            cd ..
-            tar cjf $KERNEL_FILE linux-${lnxmaj}
-        }
-        popd
-        rm -rf $RPMTOPDIR
-    fi
 }
 
-download_and_build_tarball() {
+download_srpm() {
     local target=$1
-    local kernel_file=$2
+    local srpm=$2
+    local force="${3:-false}"
+
+    if $force || [ ! -r "$KERNELDIR/$srpm" ] ||
+       [ ! -s "$KERNELDIR/$srpm" ]; then
+        if $DOWNLOAD; then
+            local location="http://downloads.lustre.org/public/kernels/$target/old"
+            echo "Downloading $location/$srpm..."
+            if ! wget -nv "$location/$srpm" -O "$KERNELDIR/$srpm" ||
+               [ ! -s "$KERNELDIR/$srpm" ]; then
+                rm -f $KERNELDIR/$srpm
+                fatal 1 "Could not download target $target's kernel SRPM" \
+                        "$srpm from $location."
+            fi
+        else
+            fatal 1 "$srpm not found in directory $KERNELDIR."
+        fi
+    fi
 
-    local srpm=kernel-${lnxmaj}-${lnxrel}.src.rpm
+}
 
-    echo "Downloading http://downloads.lustre.org/public/kernels/$target/old/$srpm..."
-    if ! wget -nv "http://downloads.lustre.org/public/kernels/$target/old/$srpm" \
-        -O "$KERNELDIR/$srpm" ; then
-        fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
+download_ofed() {
+    local force="${1:-false}"
+
+    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ] &&
+       ( $force || [ ! -r "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ] ||
+           [ ! -s "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ] ); then
+        if $DOWNLOAD; then
+            local location="http://downloads.lustre.org/public/OFED/"
+            echo "Downloading $location/OFED-${OFED_VERSION}.tgz..."
+            if ! wget -nv "$location/OFED-${OFED_VERSION}.tgz" \
+                -O "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ||
+               [ ! -s "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ]; then
+                rm -f $KERNELTREE/OFED-${OFED_VERSION}.tgz
+                fatal 1 "Could not download OFED-${OFED_VERSION}.tgz" \
+                        "from downloads.lustre.org."
+            fi
+        else
+            fatal 1 "OFED-${OFED_VERSION}.tgz not found in kernel" \
+                    "directory $KERNELTREE."
+        fi
     fi
-    [ -s "$KERNELDIR/$srpm" ] || {
-        rm -rf $KERNELDIR/$srpm
-        fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
-    }
 
-    build_tarball $target $srpm
 }
 
-load_target()
-{
+load_target() {
+
     EXTRA_VERSION_save="$EXTRA_VERSION"
-    for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
+    for patchesdir in "$EXTERNAL_PATCHES" \
+                      "$TOPDIR/lustre/lustre/kernel_patches"; do
         TARGET_FILE="$patchesdir/targets/$TARGET.target"
         [ -r "$TARGET_FILE" ] && break
     done
-    [ -r "$TARGET_FILE" ] || \
-        fatal 1 "Target $TARGET was not found."
+    [ -r "$TARGET_FILE" ] || fatal 1 "Target $TARGET was not found."
 
-    echo "Loading target config file $TARGET.target..."        
+    echo "Loading target config file $TARGET.target..."
 
     . "$TARGET_FILE"
 
-    [ "$KERNEL"  ] || fatal 1 "Target $TARGET did not specify a kernel."
-    [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
+    # doesn't make any sense to build OFED for xen domX's
+    if $XEN; then
+        OFED_VERSION=""
+    fi
+
+    # XXX - set_rpm_smp_type is an ugly undeterministic hack.  it needs to
+    #       go away and the target just specify the $RPMSMPTYPE
+    [ -z "$RPMSMPTYPE" ] && set_rpm_smp_type
 
-    #CC was overwriten in TARGET_FILE
-    which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
+    # CC might have been overwriten in TARGET_FILE
+    if [[ $CC != ccache\ * ]] && which "$CCACHE" 2>/dev/null; then
+        export CCACHE && export CC="ccache $CC"
+    fi
 
     if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then
         KERNELDIR="$KERNELTREE/${lnxmaj}"
         [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR"
     fi
 
-    if [ "$KERNELDIR" ] ; then
-        KERNEL_FILE="$KERNELDIR/$KERNEL"
-        if [ ! -r "$KERNEL_FILE" ] ; then
-            # see if we have an SRPM we can build a tarball for
-            KERNEL_SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm
-            if [ -r "$KERNELDIR/$KERNEL_SRPM" ] ; then
-                build_tarball $CANONICAL_TARGET $KERNEL_SRPM
-            else
-                if (( $DOWNLOAD )) ; then
-                    echo "Downloading http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL..."
-                    if ! wget -nv "http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
-                        # see if we can do it with an SRPM from the download site
-                        download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE
-                    else
-                        [ -s "$KERNELDIR/$KERNEL" ] || {
-                            rm -rf "$KERNELDIR/$KERNEL"
-                            fatal 1 "Target $TARGET's kernel $KERNEL not found in directory $KERNELDIR."
-                        }
-                    fi
-                else
-                    fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
-                fi
-            fi
-        fi
-        if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ] && \
-           [ ! -r "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ] ; then
-            if (( $DOWNLOAD )) ; then
-                local location="http://downloads.lustre.org/public/OFED/"
-                echo "Downloading $location/OFED-${OFED_VERSION}.tgz..."
-                if ! wget -nv "$location/OFED-${OFED_VERSION}.tgz" \
-                    -O "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ; then
-                    fatal 1 "Could not download OFED-${OFED_VERSION}.tgz from downloads.lustre.org."
-                fi
-            else
-                fatal 1 "OFED-${OFED_VERSION}.tgz not found in kernel directory $KERNELDIR."
-            fi
-        fi
-    fi
-
-    if [ "$SERIES" ] ; then
-        for series in $SERIES ; do
-            for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
+    # verify the series is available
+    if [ "$SERIES" ]; then
+        for series in $SERIES; do
+            for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
                 [ -r "$patchesdir/series/$series" ] && continue 2
             done
-            fatal 1 "Target $TARGET's series $SERIES could not be found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n\t$TOPDIR/lustre/lustre/kernel_patches/series."
+            fatal 1 "Target $TARGET's series $SERIES could not be" \
+                    "found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n" \
+                    "\t$TOPDIR/lustre/lustre/kernel_patches/series."
         done
     fi
 
-    if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
-        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config"
+    # set the location of the .config file
+    local XENPOSTFIX=""
+    if $XEN; then
+        XENPOSTFIX="-xen"
     fi
-    local smptype
-    for smptype in $SMPTYPES; do
-        [ "$smptype" = "''" ] && smptype=
-        if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then
-        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config"
-        KERNCONFSMPTYPE=$smptype
+
+    if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
+        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH${RPMSMPTYPE:+-}${RPMSMPTYPE}.config"
     fi
-    done
 
     local lnxrelnew=${lnxrel//-/_}
 
+    # remember the EXTRA_VERSION before we diddle it here
+    # XXX - we really should not diddle with any values read in from the
+    #       target file.  if we want to modify a value, we should create
+    #       a new variable.
+    PRISTINE_EXTRA_VERSION=$EXTRA_VERSION
+
     if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then
-        fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
+        fatal 1 "Config file for target $TARGET missing from" \
+                "$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
     fi
 
-    if [ "$EXTRA_VERSION_save" ] ; then
+    if [ "$EXTRA_VERSION_save" ]; then
         EXTRA_VERSION="$EXTRA_VERSION_save"
     elif ! $RELEASE; then
         # if there is no patch series, then this is not a lustre specific
@@ -495,22 +496,12 @@ load_target()
     fi
     # EXTRA_VERSION=${EXTRA_VERSION//-/_}
 
-    [ -z $REUSEDKERNELMASK ] && \
-        # create mask for kernel RPM/builddir which could be reused
-        if $NORPM; then
-            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.*${TARGET_ARCH}
-        elif $RELEASE; then
-            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TARGET_ARCH}
-        else
-            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TIMESTAMP}.${TARGET_ARCH}
-        fi
-        # kernel-lustre-smp-2.6.9-55.0.2.EL_lustre.1.6.1.i686.rpm 
-
     ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
 
     BUILD_ARCHS=
-    for arch in $(uniqify "$ALL_ARCHS") ; do
-        if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep -w "$arch" >/dev/null 2>/dev/null ; then
+    for arch in $(uniqify "$ALL_ARCHS"); do
+        if [ -z "$TARGET_ARCHS" ] ||
+           [[ \ $TARGET_ARCHS\  = *\ $arch\ * ]]; then
             BUILD_ARCHS="$BUILD_ARCHS $arch"
         fi
     done
@@ -518,9 +509,10 @@ load_target()
     echo "Building for: $BUILD_ARCHS"
 }
 
-tarflags()
-{
-    case "$1" in
+tarflags() {
+    local file="$1"
+
+    case "$file" in
         '')
             fatal 1 "tarflags(): File name argument missing."
             ;;
@@ -537,35 +529,36 @@ tarflags()
             fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
             ;;
     esac
+
 }
 
-untar()
-{
-    echo "Untarring ${1##*/}..."
-    tar $(tarflags "$1") "$1"
+untar() {
+    local file="$1"
+
+    echo "Untarring ${file##*/}..."
+    tar $(tarflags "$file") "$file"
+
 }
 
-unpack_ofed()
-{
-    untar "$KERNELTREE/../OFED-${OFED_VERSION}.tgz"
+unpack_ofed() {
+
+    if ! untar "$KERNELTREE/OFED-${OFED_VERSION}.tgz"; then
+        return 1
+    fi
     [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED
-    pwd
-    ls -ld OFED OFED-[0-9].[0-9]*
-    ls -l OFED OFED-[0-9].[0-9]*
+
 }
 
-unpack_lustre()
-{
-    DIRNAME="lustre-$TAG-$TIMESTAMP"
-    if [ "$LUSTRE" ] ; then
-        untar "$LUSTRE"
-        [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
-    else
-        if [ "$USE_DATESTAMP" ]; then
+unpack_lustre() {
+
+    if [ -z "$LUSTRE" ]; then
+        local DATESTAMP=""
+
+        if [ -n "$USE_DATESTAMP" ]; then
             DATESTAMP="-D '$DATE'"
-        else
-            DATESTAMP=""
-        fi            
+        fi
+
+        local DIRNAME="lustre-$TAG-$TIMESTAMP"
 
         cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
             fatal 1 "There was an error checking out toplevel Lustre from CVS."
@@ -577,201 +570,53 @@ unpack_lustre()
         ./configure --disable-{modules,utils,liblustre,tests,doc} || \
             fatal 1 "There was an error running ./configure to create makefiles."
         make dist || fatal 1 "There was an error running 'make dist'."
+        LUSTRE=$PWD/lustre-*.tar.gz
         popd > /dev/null
-        fname=$(basename $DIRNAME/lustre-*.tar.gz)
-        cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
-        LUSTRE="$PWD/$fname"
-        ln -sf "$DIRNAME" lustre
     fi
-}
 
-unpack_linux()
-{
-    untar "$KERNEL_FILE"
-    [ -d linux ] || ln -sf linux* linux
+    untar "$LUSTRE" || fatal 1 "Error unpacking Lustre tarball"
+    [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
+
 }
 
-patch_linux()
-{
-    [ "$SERIES" ] || return 0
+do_patch_linux() {
+
+    local do_patch=${1:-true}
+
     FULL_PATCH="$PWD/lustre-kernel-${TARGET}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}.patch"
     [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
-    pushd linux >/dev/null
-    for series in $SERIES ; do
+    $do_patch && pushd linux >/dev/null
+    for series in $SERIES; do
         echo -n "Applying series $series:"
-        for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
+        for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
             [ -r "$patchesdir/series/$series" ] || continue
             SERIES_FILE="$patchesdir/series/$series"
-            for patch in $(<"$SERIES_FILE") ; do
+            for patch in $(<"$SERIES_FILE"); do
                 echo -n " $patch"
                 PATCH_FILE="$patchesdir/patches/$patch"
                 [ -r "$PATCH_FILE" ] || \
                     fatal 1 "Patch $patch does not exist in Lustre tree."
-                cat "$PATCH_FILE" >> "$FULL_PATCH" || \
+                cat "$PATCH_FILE" >> "$FULL_PATCH" || {
+                    rm -f $FULL_PATCH
                     fatal 1 "Error adding patch $patch to full patch."
-                patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
+                }
+                if $do_patch; then
+                    patch -s -p1 < "$PATCH_FILE" || {
+                        rm -f $FULL_PATCH
+                        fatal 1 "Error applying patch $patch."
+                    }
+                fi
             done
             break
         done
         echo
     done
-    popd >/dev/null
+    $do_patch && popd >/dev/null
     echo "Full patch has been saved in ${FULL_PATCH##*/}."
-    echo "Replacing .config files..."
-    [ -d linux/configs ] || mkdir linux/configs || \
-        fatal 1 "Error creating configs directory."
-    rm -f linux/configs/*
-    copysuccess=0
-    for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
-        [ "$patchesdir" ] && \
-            cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
-    done
-    [ "$copysuccess" = "1" ] || \
-        fatal 1 "Error copying in kernel configs."
-}
 
-pack_linux()
-{
-    TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
-    echo "Creating patched linux tarball $TARBALL..."
-    tar zcf "$TARBALL" "$(readlink linux)" \
-        --exclude "CVS" --exclude ".cvsignore" || \
-        --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
-        fatal 1 "Error creating patched Linux tarball."
 }
 
-clean_linux()
-{
-    [ -d linux ] || return 0
-    echo "Cleaning linux..."
-    [ -L linux ] && rm -rf $(readlink linux)
-    rm -rf linux
-}
-
-prep_kernel_build()
-{
-    # make .spec file
-    ENABLE_INIT_SCRIPTS=""
-    sed \
-        -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
-        -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
-        -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
-        -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
-        -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
-        -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
-        -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
-        -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
-        -e "s^@KERNEL_EXTRA_VERSION_DELIMITER@^$EXTRA_VERSION_DELIMITER^g" \
-        -e "s^@KERNEL_TARGET_DELIMITER@^$TARGET_DELIMITER^g" \
-        -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
-        -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
-        -e "s^@KERNEL_VERSION@^$VERSION^g" \
-        -e "s^@LINUX26@^$LINUX26^g" \
-        -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
-        -e "s^@LUSTRE_TARGET@^$TARGET^g" \
-        -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
-        -e "s^@RHBUILD@^$RHBUILD^g" \
-        -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
-        -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
-        -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
-        < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
-        > lustre-kernel-2.4.spec
-    [ -d SRPMS ] || mkdir SRPMS
-    [ -d RPMS ] || mkdir RPMS
-    [ -d BUILD ] || mkdir BUILD
-    [ -d SOURCES ] || mkdir SOURCES
-    for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
-        suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} \
-        sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; do
-        cp $TOPDIR/lustre/build/$script SOURCES
-    done
-    cp "$LUSTRE" "$KERNEL_FILE" SOURCES
-    if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
-        tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
-    else
-        touch SOURCES/external-patches.tar.gz
-    fi
-}
-
-clean_lustre()
-{
-    [ -d lustre ] || return 0
-    echo "Cleaning Lustre..."
-    [ -L lustre ] && rm -rf $(readlink lustre)
-    rm -rf lustre
-}
-
-build_kernel()
-{
-    echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..."
-    targets=
-    for arch in $BUILD_ARCHS ; do
-        targets="--target $arch $targets"
-    done
-
-    local rpmbuildopt='-bb'
-#    if $NORPM; then
-#        rpmbuildopt='-bc'
-#        echo NORPM mode. Only compiling.
-#        echo "XXX: need to fix lmake - add options to do rpmbuild -bc instead of -bb"
-#    fi
-
-    $RPMBUILD $targets $rpmbuildopt lustre-kernel-2.4.spec \
-        --define "_tmppath $TMPDIR" \
-        --define "_topdir $TOPDIR" || \
-        fatal 1 "Error building rpms for $BUILD_ARCHS."
-
-    if (( $DO_SRC )) ; then
-        $RPMBUILD -bs lustre-kernel-2.4.spec \
-            --define "_tmppath $TMPDIR" \
-            --define "_topdir $TOPDIR" || \
-            fatal 1 "Error building .src.rpm."
-    fi
-
-    ( $(skeep_ldiskfs_rpm $TAG) ) && return
-
-    pushd $TOPDIR/BUILD/lustre*/ldiskfs || return 255
-    make dist
-    if [ "$?" != "0" ] ; then
-        popd
-        return 255
-    fi
-    cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
-
-    gen_lustre_version
-
-    local ldiskfs_spec=lustre-ldiskfs.spec
-    [ -f "$ldiskfs_spec" ] && sed \
-    -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
-    < $ldiskfs_spec \
-    > ../lustre-ldiskfs.spec
-
-    $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
-        --define "_tmppath /var/tmp" \
-        --define "_topdir $TOPDIR"
-    if [ "$?" != "0" ] ; then
-        popd
-        return 255
-    fi
-
-    if (( $DO_SRC )) ; then
-            $RPMBUILD -bs ../lustre-ldiskfs.spec \
-            --define "_tmppath /var/tmp" \
-            --define "_topdir $TOPDIR"
-        if [ "$?" != "0" ] ; then
-            popd
-            return 255
-        fi
-    fi
-    popd
-}
-
-build_lustre()
-{
-    [ -d SRPMS ] || mkdir SRPMS
-    [ -d RPMS ] || mkdir RPMS
-    [ -d BUILD ] || mkdir BUILD
-    [ -d SOURCES ] || mkdir SOURCES
+build_lustre() {
 
     cp "$LUSTRE" SOURCES
 
@@ -779,7 +624,7 @@ build_lustre()
 
     echo "Building Lustre RPMs for: $BUILD_ARCHS..."
     targets=
-    for arch in $BUILD_ARCHS ; do
+    for arch in $BUILD_ARCHS; do
         targets="--target $arch $targets"
     done
 
@@ -788,15 +633,20 @@ build_lustre()
         confoptions="--with-linux=${LINUX} --disable-server"
     fi
     if [ ! "$LINUXOBJ" = "" ]; then
-        confoptions="$confoptions --with-linux-obj=${LINUXOBJ}" 
+        confoptions="$confoptions --with-linux-obj=${LINUXOBJ}"
     fi
-    
+
     ./configure $confoptions ${CONFIGURE_FLAGS}
-    if [ "$?" != "0" ] ; then
+    if [ "$?" != "0" ]; then
         local saved_config="../config.log.$(date +%s)"
         cp config.log $saved_config
         chmod a+r $saved_config
         echo "Saved config.log is at $saved_config"
+        cat /proc/mounts
+        ls -l /proc/$$
+        pwd
+        echo "config.log contents:"
+        cat config.log
         popd
         return 255
     fi
@@ -804,7 +654,7 @@ build_lustre()
     gen_lustre_version
 
     # hack. Somebody move build/lustre.spec to lustre.spec for b1_6
-    local lustre_spec=
+    local lustre_spec
     [ -f lustre.spec ] && lustre_spec=lustre.spec
     [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec
 
@@ -819,7 +669,15 @@ build_lustre()
         echo NORPM mode. Only compiling.
     fi
 
+    # convert the $PATCHLESS boolean to an empty/no-empty boolean
+    # as silly as this seems, it makes the syntax of the rpmbuild command
+    # simpler and not need an eval to deal with the quotes in the quotes 
+    local is_patchless=""
+    if $PATCHLESS; then
+        is_patchless="yes"
+    fi
     $RPMBUILD $targets $rpmbuildopt ../lustre.spec \
+        ${is_patchless:+--define "lustre_name lustre-client"} \
         --define "_tmppath $TMPDIR" \
         --define "_topdir $TOPDIR" || \
         fatal 1 "Error building rpms for $BUILD_ARCHS."
@@ -829,7 +687,7 @@ build_lustre()
 
     pushd lustre/ldiskfs || return 255
     make dist
-    if [ "$?" != "0" ] ; then
+    if [ "$?" != "0" ]; then
         popd
         return 255
     fi
@@ -846,45 +704,48 @@ build_lustre()
     $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
         --define "_tmppath /var/tmp" \
         --define "_topdir $TOPDIR"
-    if [ "$?" != "0" ] ; then
+    if [ "$?" != "0" ]; then
         popd
         return 255
     fi
 
-    if (( $DO_SRC )) ; then
+    if $DO_SRC; then
             $RPMBUILD -bs ../lustre-ldiskfs.spec \
             --define "_tmppath /var/tmp" \
             --define "_topdir $TOPDIR"
-        if [ "$?" != "0" ] ; then
+        if [ "$?" != "0" ]; then
             popd
             return 255
         fi
     fi
     popd
+
 }
 
-stage()
-{
+stage() {
+
     [ "$STAGEDIR" ] || return 0
 
-    for arch in $BUILD_ARCHS ; do
+    for arch in $BUILD_ARCHS; do
         rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
         echo "${0##*/}: Copying RPMs into ${rpmdir}"
         mkdir -p "${rpmdir}"
         cp -v RPMS/${arch}/*.rpm "${rpmdir}"
-        if [ -d RPMS/noarch ] ; then
+        if [ -d RPMS/noarch ]; then
             cp -v RPMS/noarch/*.rpm "${rpmdir}"
         fi
     done
 
     cp -v "$LUSTRE" "$STAGEDIR"
+
 }
 
 #check if we need to build separate ldiskfs RPM
-skeep_ldiskfs_rpm()
-{
-        local tag=$1
+skeep_ldiskfs_rpm() {
+        local tag="$1"
+
         local skip=false
+
         if ! $LDISKFSRPM; then
             skip=true
         elif $PATCHLESS; then
@@ -894,133 +755,43 @@ skeep_ldiskfs_rpm()
                 [[ $tag == $skiptag ]] && skip=true && break
             done
         fi
-        echo $skip
-}
 
-#get date of last changed target/config/series/patches
-get_last_source_date()
-{
-    local filelist="${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} \
-        $CONFIG_FILE"
-    local TOPDIRnew=$(echo ${TOPDIR} | sed -e s/\\//\\\\\\//g)
-    filelist="$filelist $( \
-        cat ${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} | \
-        sed -e s/^/${TOPDIRnew}\\/lustre\\/lustre\\/kernel_patches\\/patches\\// 2>&1)"
-    local sourcelastdate=$( find ${filelist} -name CVS -prune -o \
-                -type f -printf "%T@\n" 2>&1 | sort | tail -1 )
-    is_integer $sourcelastdate && echo $sourcelastdate
-}
+        pushd $TOPDIR/BUILD/lustre-[1-9]* >/dev/null
+        grep -q '^SERVER_TRUE[ \t]=[ \t]#$' autoMakefile && skip=true
+        popd >/dev/null
+
+        echo $skip
 
-#check if variable is integer
-is_integer()
-{
-    local invariable=$1
-    [ "$invariable" = "" ] && return 255
-    local invariableint=$( echo $invariable | sed -e s/[^0-9]//g )
-    [ "$invariable" = "$invariableint" ] || return 255
 }
 
 #generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
-gen_lustre_version()
-{
-    local smptype=smp
-    [ "$KERNCONFSMPTYPE" = "" ] || smptype=$KERNCONFSMPTYPE
-    [ "$RPMSMPTYPE" = "" ] || smptype=$RPMSMPTYPE
+gen_lustre_version() {
 
-    LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${smptype}"
+    LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${RPMSMPTYPE}"
     LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
+
 }
 
-#store RPMs and/or BUILD dir for future reuse
-store_for_reuse()
-{
-    local rpmonly=$1
-    if [ ! "$REUSEBUILD" = "" ] && [ -d  "/$REUSEBUILD/" ] ; then
-        [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || mkdir "${REUSEBUILD}/${TIMESTAMP}"
-        [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || return 255
-    else
-        return 255
-    fi
+set_rpm_smp_type() {
 
-    local lnxrelnew=${lnxrel//-/_}
-    local EXTRA_VERSIONnew=${EXTRA_VERSION//-/_}
-    local KERNELRPMnew=$(basename "$KERNELRPM")
-    if [ ! "$rpmonly" = "rpmonly" ]; then
-	    local builddir=
-        if [ ! "$KERNELCOMPILEDIR" = "" ]; then
-            builddir="$KERNELCOMPILEDIR"
-        else
-            builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}"
-	    [ "$KERNELCOMPILEDIR" = "" ] || builddir="$KERNELCOMPILEDIR"
-            [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}.${lnxrel}"
-            [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}-${lnxrel}"
-	    if [ ! -d "$builddir" ]; then
-                pushd "BUILD/lustre-kernel-${lnxmaj}/lustre/" || return 255
-                local basebuilddir=$(ls -d linux-${lnxmaj}* | head -1)
-                [ "$basebuilddir" = "" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/${basebuilddir}"
-                popd
-	    fi
-        fi
-        [ -d "$builddir" ] || return 255
-	local dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}"
-	( $PATCHLESS ) && dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-$KERNELRPMnew" && \
-	        dstdir="${dstdir%.rpm}"
-	[ -d "$dstdir" ] && rm -rf "$dstdir"
-        mv "${builddir}" "$dstdir" || return 255
-        if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-            # move the OFED kernel-ib-devel tree as well
-            mv "${builddir%/*}/kernel-ib-devel/usr/src/ofa_kernel" "${dstdir%/*}" || return 255
-        fi
-    fi
-    #store kernel rpm
-    local kernelrpmname="kernel-lustre-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
-    [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSNnew}.${TARGET_ARCH}.rpm"
-    ( $PATCHLESS ) && [ -f "$KERNELRPM" ] && kernelrpmname="$KERNELRPMnew"
-    if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
-        echo "RPM already exist in store directory tree"
-    else
-        [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
-    fi
-    #store kernel source rpm
-    kernelrpmname="kernel-lustre-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
-    [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
-    ( $PATCHLESS ) && [ -f "$KERNELSOURCERPM" ] && kernelrpmname=$(basename "$KERNELSOURCERPM")
-    if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
-        echo "RPM already exist in store directory tree"
-    else
-	    [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
-    fi
-    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-        # store kernel-ib RPMs
-        local rpmname
-        for rpmname in "kernel-ib" "kernel-ib-devel"; do
-            rpmname="${rpmname}-${OFED_VERSION}"
-            if $PATCHLESS; then
-                rpmname="${rpmname}-${LINUXRELEASE//-/_}"
-            else
-                rpmname="${rpmname}-${lnxmaj}${EXTRA_VERSION_DELIMITER//-/_}${EXTRA_VERSIONnew}${TARGET_DELIMITER//-/_}${KERNCONFSMPTYPE}"
-            fi
-            rpmname="${rpmname}.${TARGET_ARCH}.rpm"
-            if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${rpmname}" ]; then
-                echo "RPM already exist in store directory tree"
-            else
-                [ -f "RPMS/${TARGET_ARCH}/${rpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${rpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
-            fi
-        done
-    fi
-}
+    local infact_arch="${TARGET_ARCH}"
 
-set_rpm_smp_type()
-{
-    local infact_arch=${TARGET_ARCH}
-    RPMSMPTYPE=default
+    RPMSMPTYPE=""
     [ "$infact_arch" == "i586" ] && infact_arch="i686"
+
+    local smp_type
     for smp_type in $SMP_ARCHS; do
         [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
     done
+
     for smp_type in $BIGSMP_ARCHS; do
         [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
     done
+
+    for smp_type in $DEFAULT_ARCHS; do
+        [ $infact_arch == $smp_type ] && RPMSMPTYPE=default && break
+    done
+
 }
 
 # This function takes a linux source pool and digs out the linux release
@@ -1037,243 +808,121 @@ find_linux_release() {
 
 }
 
-#unpack kernel(/source/devel) RPM
-unpack_linux_rpm()
-{
-    local prefix=$1
+# XXX this needs to be re-written as a wrapper around find_rpm
+#     or just gotten rid of.  :-)
+find_linux_rpm() {
+    local prefix="$1"
     local delimiter=${2:-"-"}
+
     local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
-    local kernelbinaryrpm=
     [ -d $pathtorpms ] || return 255
-    local rpmfile=
+
+    local kernelbinaryrpm rpmfile
     local wanted_kernel="${lnxmaj}${delimiter}${lnxrel}"
+
+    local arch ret=1
     for arch in $TARGET_ARCHS_ALL; do
+        local found_rpm="" rpm
         for rpm in ${pathtorpms}/${arch}/*.rpm; do
-            local provides=$(rpm -q --provides -p $rpm)
-            if (echo $provides | grep -q "kernel${prefix} = $wanted_kernel"); then
-                KERNELRPM=$rpm
+            if rpm -q --provides -p "$rpm" | grep -q "kernel${prefix} = $wanted_kernel"; then
+                found_rpm="$rpm"
+                ret=0
+                break
             fi
         done
-        [ -f "$KERNELRPM" ] && TARGET_ARCH="$arch" && BUILD_ARCHS="$arch" && break
+        [ -f "$found_rpm" ] && break
     done
 
-    # bleah
-    set_rpm_smp_type
+    echo "$found_rpm"
+    return $ret
 
-    [ -f "$KERNELRPM" ] || return 255
-    [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
-    pushd $TOPDIR/reused || return 255
-    RC=0
-    rpm2cpio < "$KERNELRPM" | cpio -idc > /dev/null 2>&1
-    if [ ${PIPESTATUS[0]} -eq 0 ]; then
-        # RHEL-style and SLES-style rpms
-        local paths="kernels/${lnxmaj}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${delimiter}${lnxrel}"
+}
 
-        for path in $paths; do
-            local src='usr/src'
+# unpack kernel(/source/devel) RPM
+#
+# This function and it's setting of $LINUX and $LINUXOBJ is a total hack that
+# needs to completely refactored.  It completely ingores that $BUILD_ARCHS may
+# contain a list of arches for which rpmbuild commands (including the one for
+# lustre itself)
+unpack_linux_devel_rpm() {
+    local kernelrpm="${1}"
+    # it's worth noting that neither sles10 nor rhel5 appear to use their
+    # extra_version delimiter for the dirname under /usr/src, so we could
+    # probably just get rid of this parameter
+    local delimiter=${2:-"-"}
 
-            if [ -d "$src/$path/" ]; then
-                LINUX="$(pwd)/$src/$path"
-            fi
-            # SLES has a separate -obj tree
-            if [ -d "$src/${path}-obj" ]; then
-                src="$src/${path}-obj"
-                local objects="$TARGET_ARCH/$RPMSMPTYPE"
-
-                # Novell, are you *TRYING* to make life hard for me?
-                if [ -d "$src/powerpc" ]; then
-                    objects="powerpc/$TARGET_ARCH"
-                elif [ $TARGET_ARCH == 'i686' ]; then
-                    objects="i386/$RPMSMPTYPE"
-                fi
+    [ -f "$kernelrpm" ] || return 255
+    [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused || return 255
 
-                LINUXOBJ="$(pwd)/$src/$objects"
-            fi
-        done
-        if [ -z "$LINUX" ]; then
-            RC=255
-        else
-            # dig out the release version
-            LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
-            if [ -z "$LINUXRELEASE" ]; then
-                echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
-                RC=255
-            fi
-        fi
-    else
-        RC=255
+    pushd $TOPDIR/reused || return 255
+
+    if ! rpm2cpio < "$kernelrpm" | cpio -id > /dev/null 2>&1; then
+        return 255
     fi
-    popd
-    return $RC
-}
 
-#look for kernel source RPM
-find_linux_source_rpm()
-{
-    local rpmfile=
-    local findarch=true
-    local arch=
-    local pathtorpms=
-    [ ! "$TARGET_ARCH" = "" ] && arch=$TARGET_ARCH && findarch=false
-    
-    if ! $findarch; then
-        pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
-        [ -d $pathtorpms ] || return 255
-        case "$DISTRO" in
-            rhel4)
-                rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
-            ;;
-            sles10)
-                rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
-            ;;
-            *)
-                rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
-            ;;
-        esac
-        [ -f "${pathtorpms}/${rpmfile}" ] || return 255
-        KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
-    else
-        for arch in $TARGET_ARCHS_ALL; do
-        pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
-        [ -d $pathtorpms ] || continue
-        case "$DISTRO" in
-            rhel4)
-                rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
-            ;;
-            sles10)
-                rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
-            ;;
-            *)
-                rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
-            ;;
-        esac
-        [ -f "${pathtorpms}/${rpmfile}" ] || continue
-        KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
-        TARGET_ARCH=${arch}
-        break
-        done
+    # call a distro specific hook, if available
+    if type -p unpack_linux_devel_rpm-$DISTRO; then
+        unpack_linux_devel_rpm-$DISTRO "$kernelrpm"
     fi
-    [ -f "${KERNELSOURCERPM}" ] || return 255
+
+    popd
+
+    find_linux_devel_paths $TOPDIR/reused
+
+    return 0
+
 }
 
-#unpack and make symlinks for reusing kernel RPM
-reuse_kernel_rpm()
-{
-    local pathtorpm=$1
-    local pathtokernelibrpm=$2
-    [ "$pathtorpm" = "" ] && return 255
-    [ -f "$pathtorpm" ] || return 255
-    [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
-    pushd $TOPDIR/reused || return 255
+# XXX - this rhel/sles goop needs abstracting out into the
+#       lbuild-{rhel5,sles10} method files
+find_linux_devel_paths() {
+    local path="$1"
 
-    rpm2cpio < $pathtorpm | cpio -idc
-    [ ${PIPESTATUS[0]} -eq 0 ] || return 255
+    local RC=0
 
-    if [ -n "$pathtokernelibrpm" ] && [ -f "$pathtokernelibrpm" ]; then
-        rpm2cpio < $pathtokernelibrpm | cpio -idc
-        [ ${PIPESTATUS[0]} -eq 0 -o ${PIPESTATUS[1]} -eq 0 ] || return 255
-        CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
-    fi
+    pushd $path
+    # RHEL-style and SLES-style rpms
+    # XXX - until bug 19336 cleans this up, we need to extricate the
+    #       ${lnxmin}- from the $lnxrel
+    local paths="kernels/${lnxmaj}${lnxmin}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}"
 
-    local smptype=
-    if pushd usr/src/linux-*-obj/${TARGET_ARCH}; then
-        local smptypes="$SMPTYPES"
-        [ "$RPMSMPTYPE" = "" ] || smptypes=$RPMSMPTYPE
-        ( ! $PATCHLESS ) && [ ! "$KERNCONFSMPTYPE" = "" ] && smptypes="$KERNCONFSMPTYPE"
-        local cursmptype=
-        for cursmptype in $smptypes; do
-            [ "$cursmptype" = "''" ] && continue
-            [ -d $cursmptype ] && smptype=$cursmptype
-            [ -d $smptype ] && break
-        done
-        popd
-    fi
-    if [ "${smptype}" = "" ]; then
-        popd
-        return 255 # cannot detect smp type
-    fi
-    if pushd usr/src/linux-*-obj/${TARGET_ARCH}/$smptype/include2; then
-        local base=$(readlink asm)
-        if [ ! -d "/${base}/" ]; then
-            rm -f asm
-            base=$(basename "$base")
-            if pushd ../../../../linux-*/include; then
-                local lsrc=$(pwd)
-                popd
-                [ -d "$lsrc/${base}" ] && ln -s $lsrc/${base} asm
-            fi
-        fi
-        popd
-        read a b < <(echo $(pwd)/usr/src/linux-*)
-        if [[ $a == $(pwd)/* && $b = $(pwd)/* ]]; then
-            cp -f $a/include/linux/config.h $b/${TARGET_ARCH}/$smptype/include/linux/
-            cp $b/${TARGET_ARCH}/$smptype/.config $a/
-            [ -f "$b/${TARGET_ARCH}/$smptype/.config" ] && KERNELRPMCONFIG="$b/${TARGET_ARCH}/$smptype/.config"
-            cp $b/${TARGET_ARCH}/$smptype/.kernelrelease $a/
-            [ -f "$b/${TARGET_ARCH}/$smptype/.kernelrelease" ] && KERNELRPMRELEASE="$b/${TARGET_ARCH}/$smptype/.kernelrelease"
-            LINUX=$a
-            LINUXOBJ=$b/${TARGET_ARCH}/$smptype
-#            local fname=$(basename $kernel_rpm)
-#            KERNELRPMSDIR=${kernel_rpm%$fname}
+    local path
+    for path in $paths; do
+        local src='usr/src'
+
+        if [ -d "$src/$path/" ]; then
+            LINUX="$(pwd)/$src/$path"
         fi
-    fi
-    popd
-    [ "$LINUX" = "" ] && return 255
-    [ -d "$LINUX" ] || return 255
-}
+        # SLES has a separate -obj tree
+        if [ -d "$src/${path}-obj" ]; then
+            local src="$src/${path}-obj"
+            local objects="$TARGET_ARCH/$RPMSMPTYPE"
+
+            # Novell, are you *TRYING* to make life hard for me?
+            if [ -d "$src/powerpc" ]; then
+                objects="powerpc/$TARGET_ARCH"
+            elif [ $TARGET_ARCH == 'i686' ]; then
+                objects="i386/$RPMSMPTYPE"
+            fi
 
-#build linux kernel rpm
-build_linux_rpm()
-{
-    pushd $LINUX || return 255
-    make binrpm-pkg || ( popd ; return 255 )
-    local addlnxrel=
-    [ -f ".version" ] && addlnxrel="-$(cat .version)"
-    popd
-    local arch=
-    for arch in $TARGET_ARCHS_ALL; do
-        [ -f "/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
-            KERNELRPM="/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
-            TARGET_ARCH="$arch"
-        [ -f "/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
-            KERNELRPM="/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
-            TARGET_ARCH="$arch"
+            LINUXOBJ="$(pwd)/$src/$objects"
+        fi
     done
-    [ "$KERNELRPM" = "" ] || return
-    return 255
-}
-
-#build linux kernel
-build_linux()
-{
-    local nofullmake=$1
-    local nocopykernel=$2
-    pushd $LINUX || fatal 1 "Kernel source not found"
-    [ "$nofullmake" = "nofullmake" ] || make mrproper
-    [ "$nofullmake" = "nofullmake" ] || rm -f rpm-release
-#    [ "$nocopykernel" = "copyrpmkernel" ] || rm -f localversion-*
-    [ "$nocopykernel" = "copykernel" ] && [ -f "$CONFIG_FILE" ] && cp $CONFIG_FILE .config
-    if [ "$nocopykernel" = "copyrpmkernel" ]; then
-        [ -f "$KERNELRPMCONFIG" ] && cp $KERNELRPMCONFIG .config
-        if [ -f "$KERNELRPMRELEASE" ]; then
-            cp $KERNELRPMRELEASE .
-        else
-            sed -e "s/^EXTRAVERSION\s\+=\s\+.*$/EXTRAVERSION = -${lnxrel}/" < Makefile > Makefile.new
-            [ -f "Makefile.new" ] && mv Makefile.new Makefile
+    if [ -z "$LINUX" ]; then
+        RC=255
+    else
+        # dig out the release version
+        LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
+        if [ -z "$LINUXRELEASE" ]; then
+            echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
+            RC=255
         fi
     fi
-    [ -f ".config" ] || ( popd ; echo "Cannot find .config file"; return 255 )
-    make oldconfig || ( popd ; return 255 )
-    make include/linux/version.h
-    if [ ! "$nofullmake" = "nofullmake" ]; then
-        make || ( popd ; return 255 )
-    fi
     popd
-    return
+    return $RC
 }
 
-build_kernel_ib()
-{
+build_kernel_ib() {
     # build kernel-ib{,-devel}
     # some I/B drivers are architecture dependent and kernel-ib's configure
     # does not figure it out for us ~sigh~
@@ -1296,282 +945,443 @@ build_kernel_ib()
 	      --define "KVERSION ${LINUXRELEASE}" \
 	      --define "$K_SRC ${LINUXOBJ:-${LINUX}}" \
 	      --define "LIB_MOD_DIR /lib/modules/${LINUXRELEASE}/updates" \
-	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" ${TOPDIR}/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
+	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-mlx4_en-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" ${TOPDIR}/OFED/SRPMS/ofa_kernel-*.src.rpm
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
         fatal 1 "Error building kernel-ib"
     fi
 
-    pushd "$TOPDIR" >/dev/null
-    rm -rf kernel-ib-devel
-    mkdir kernel-ib-devel
-    cd kernel-ib-devel
-    local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${LINUXRELEASE//-/_}.*.rpm)
-    rpm2cpio -itv < $rpm | cpio -id
-    CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
-    popd >/dev/null
 }
 
-#build patchless lustre
-patchless_build_sequence()
-{
-    if [ -f $LINUX/Makefile ]; then
-        # Get the correct kernel release - I'm unsure how this can ever
-        # work otherwise, unless you're using the exact same kernel version
-        # Lustre is shipped with.
+store_for_reuse() {
+        local articles="$1"
+        local module="$2"
+        local location="$3"
+        local signature="$4"
+        local use_links="$5"
 
-        local LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
-        if [ -z "$LINUXRELEASE" ]; then
-            echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
-            RC=255
+        local linkflag=""
+        if $use_links; then
+            linkflag="l"
         fi
 
-	lnxmaj=$(echo $LINUXRELEASE | cut -f1 -d-)
-	EXTRA_VERSION=$(echo $LINUXRELEASE | cut -f2 -d-)_lustre.$LUSTRE_VERSION
-        RPMSMPTYPE=" "
-        build_lustre && buildsuccess=true
-    else
-    #try to build from kernel-devel RPM (RHEL)
-    LINUX=
-    TARGET_ARCH=
-    local rpmfound=false
-    local buildsuccess=false
-    local storeforreuse=false
-    if [ "$KERNELRPMSBASE" = "" ] || [ ! -d "$KERNELRPMSBASE" ]; then
-        return 255
-    fi
-    [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
-
-    local delimiter=${EXTRA_VERSION_DELIMITER:-"-"}
-    # default to source type -source and special case below
-    local type=-source
-    case "$DISTRO" in
-        rhel*)
-            type=-devel
-            ;;
-    esac
+        location="$location"/"$signature"/"$module"
+        mkdir -p "$location"
+        # the cleanup script removes any directory that doesn't have a
+        # .lastused, so let's try to prevent that as soon as we can
+        # this solution still slightly racy with the cleanup script
+        # but the race is a lot tighter now
+        touch -t 197001010000 "$location/.lastused"
+        ## use eval/echo here to make sure shell expansions are performed
+        #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then
+        local article
+        for article in $(eval echo $articles); do
+            if ! cp -a${linkflag} "$article" "$location"; then
+                error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()"
+                # rename the cache location so that it's not cached
+                # product, but is around for analysis
+                mv "$location"{,-bad-$(date +%s)} || 
+                    error "failed to clean up a failed cache attempt" \
+                          "in \"$location\" -- manual cleanup will be" \
+                          "necessary"
+                return 1
+            fi
+        done
 
-    unpack_linux_rpm $type $delimiter && rpmfound=true
+        # flag the cache as complete (i.e. in case lbuild was previously
+        # interrupted while caching)
+        touch "$location/.lastused"
 
-    [ -d SRPMS ] || mkdir SRPMS
-    [ -d RPMS ] || mkdir RPMS
-    [ -d BUILD ] || mkdir BUILD
-    [ -d SOURCES ] || mkdir SOURCES
+        return 0
 
-    # first build kernel-ib
-    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-        $rpmfound && build_kernel_ib
-    fi
-    ( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm
-    fi
+}
 
-    if $buildsuccess; then
-        [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELRPM" ] && \
-            cp "$KERNELRPM" RPMS/${TARGET_ARCH}/
-        [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELSOURCERPM" ] && \
-            cp "$KERNELSOURCERPM" RPMS/${TARGET_ARCH}/
-        KERNELCOMPILEDIR="$LINUX"
-        if $storeforreuse; then
-            store_for_reuse || echo "Cannot store for future reuse"
+reuse() {
+    local module="$1"
+    local dest="$2"
+    local use_links="${3:-false}"
+    local signature="$4"
+
+    if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then
+        if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then
+            # the .lastused flag is populated at the end of the caching to
+            # signal that the caching was completeld.  if that flag is not
+            # there, then the cache is invalid (and should be removed in fact) 
+            mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} || 
+                fatal 1 "failed to clean up a bad cache in location" \
+                      "\"$REUSEBUILD/$signature/$module\" -- manual cleanup" \
+                      "will be necessary"
+            return 1
         fi
 
-        return
-    elif ! $rpmfound; then
-        echo "COULD NOT FIND VENDOR -devel or -source RPM for $DISTRO/$TARGET_ARCH: $lnxmaj-$lnxrel in $KERNELRPMSBASE"
-        return 255
+        # so that we know how stale this entry is
+        touch $REUSEBUILD/$signature/$module/.lastused
+
+        if $use_links; then
+            if ls $REUSEBUILD/$signature/$module/* >/dev/null 2>&1; then
+                cp -al $REUSEBUILD/$signature/$module/* $dest/
+            fi
+        else
+            # copying is pretty heavy
+            # cp -a $REUSEBUILD/$signature/$module/* $dest/
+            # do some creative symlinking instead
+            local dir
+            for dir in BUILD SRPMS SPECS; do
+                if ls $REUSEBUILD/$signature/$module/$dir/* >/dev/null 2>&1; then
+                    ln -s $REUSEBUILD/$signature/$module/$dir/* $dest/$dir
+                fi
+            done
+            # sources have to be copied by file because we need SOURCES to
+            # be a dir we can write into
+# could overrun ls's arg list here
+            #ls $REUSEBUILD/$signature/$module/SOURCES/* |
+            find $REUSEBUILD/$signature/$module/SOURCES/ -type f |
+                xargs ln -t $dest/SOURCES -s
+
+            # same for RPMS/* dirs
+# could overrun ls's arg list here
+            #ls $REUSEBUILD/$signature/$module/RPMS/$TARGET_ARCH/* |
+            local dir
+            for dir in $REUSEBUILD/$signature/$module/RPMS/*; do
+                mkdir -p $dest/RPMS/${dir##*/}
+                find $dir -type f |
+                  xargs ln -t $dest/RPMS/${dir##*/} -s
+            done
+                     
+        fi
+        return 0
     else
-        echo "Patchless build failed."
-        return 255
+        return 1
     fi
 }
 
-#check timestamp value. should bi 14-digits string
-check_timestamp()
-{
-    local invalue=$1
-    local timestampnodig=$(echo $invalue | sed -e s/[0-9]*//g)
-    [ "$timestampnodig" = "" ] || return 255
-    local timestamplength="${#invalue}"
-    [ $timestamplength -eq 14 ] || return 255
+basearch() {
+    local arch="$1"
+
+    if [[ $arch = i[3456]86 ]]; then
+        echo "i386"
+    else
+        echo "$arch"
+    fi
+
 }
 
-# get list of suitable directories with potential reused staff
-get_reuse_dir_list()
-{
-    local rpmonly=$1
-    local reusedkernelmasknew=$2
-    local buildtimestamp=
-    local dirsforreuse=
-    local sourcelastdate=$(get_last_source_date)
-    for buildtimestamp in $(ls "$REUSEBUILD/" 2>&1); do
-        [ -d "$REUSEBUILD/$buildtimestamp" ] || continue
-	check_timestamp "$buildtimestamp" || continue
-        local buildtimestampstr=$(echo $buildtimestamp | \
-            sed -e "s^\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)^\1-\2-\3 \4:\5:\6 GMT^g")
-        local buildtimestampepoch=$(date --date="$buildtimestampstr"  +%s )
-        #check for suitable date
-	    if ! $PATCHLESS; then
-            [ $buildtimestampepoch -ge $sourcelastdate ] || continue
-	    fi
-        #check for suitable version
-        if [ "$rpmonly" = "rpmonly" ]; then
-            local reusedkernelprefix="kernel-lustre-"
-            ( $PATCHLESS ) && reusedkernelprefix=
-            local rpmmask="${reusedkernelprefix}${REUSEDKERNELMASK}"
-            [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
-            [ -f $REUSEBUILD/$buildtimestamp/${rpmmask}.rpm ] && \
-                dirsforreuse="$dirsforreuse $REUSEBUILD/$buildtimestamp"
-        else
-            local rpmmask="$REUSEDKERNELMASK"
-            [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
-            pushd $REUSEBUILD/$buildtimestamp/linux-${rpmmask} > /dev/null 2>&1 || continue
-            local curdir=$(pwd)
-            dirsforreuse="$dirsforreuse $curdir"
-            popd
+#
+# in a given directory, find the first rpm matching given requirements
+#
+find_rpm() {
+    local dir="$1"
+    local match_type="$2"
+    local match="$3"
+
+    pushd "$dir" > /dev/null || \
+        fatal 1 "Unable to chdir to directory \"$dir\" in find_rpm()"
+
+    local file
+    for file in $(ls); do
+        if [ ! -f "$file" ]; then
+            continue
         fi
+        case "$match_type" in
+            provides)
+                # match is any valid ERE (i.e. given to egrep) match
+                if rpm -q --provides -p "$file" | egrep -q "$match"; then
+                    echo "$file"
+                    popd >/dev/null
+                    return 0
+                fi
+                ;;
+            *)
+                popd >/dev/null
+                fatal 1 "Unknown match type \"$match_type\" given to find_rpm()"
+                ;;
+        esac
     done
-    echo "$dirsforreuse"
+
+    popd >/dev/null
+    return 1
 }
 
-#try to reuse old RPM
-build_sequence_rpm_reuse()
-{
-    local sourcerpm=$1
-    [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
-    local dirsforreuse=
-    if ! [ "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse RPM
-        local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
-        REUSEDKERNELMASKnew="kernel-lustre-source-${REUSEDKERNELMASKnew}"
-        local dirsforreuse="$(get_reuse_dir_list rpmonly $REUSEDKERNELMASKnew)"
-        local buildsuccess=false
-        LINUXOBJ=
-        for curdir in $(echo $dirsforreuse); do
-            [ -d "$curdir" ] || continue
-            local reusedkernelprefix="kernel-lustre-"
-            local reusedkernelrpm=
-            [ -f ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
-                reusedkernelrpm=$(ls ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
-            [ -f "$reusedkernelrpm" ] || continue
-
-            local reusedkernelsourcerpm=
-            [ -f ${curdir}/${REUSEDKERNELMASKnew}.rpm ] && \
-                reusedkernelsourcerpm=$(ls ${curdir}/${REUSEDKERNELMASKnew}.rpm | head -1 )
-            [ -f "$reusedkernelsourcerpm" ] || continue
-
-            # don't need to check for kernel-ib RPM reuse here because sles9 is not supported
-            # by OFED >= 1.3.0 and this function appears to only be used for sles9
-
-            [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
-            reuse_kernel_rpm "$reusedkernelsourcerpm" "" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
-            ( $buildsuccess ) || continue
-            if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
-                [ -f "$reusedkernelrpm" ] && \
-                    cp -f  "$reusedkernelrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
- 
-                [ -f "$reusedkernelsourcerpm" ] && \
-                    cp -f  "$reusedkernelsourcerpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
-                    touch RPMS/${TARGET_ARCH}/kernel_was_reused
-            fi
-            return
-        done
+build_kernel_with_srpm() {
+
+    # need to generate the patch for this target
+    do_patch_linux false >&2	# sets global $FULL_PATCH (yeah, yuck)
+
+    # get an md5sum of the kernel patch + config for reuse check
+    # XXX really, there needs to be a signature and a CONFIG_FILE per arch
+    #     in BUILD_ARCHS
+    local REUSE_SIGNATURE=$({ echo $BUILD_GEN; cat $CONFIG_FILE $TARGET_FILE $FULL_PATCH; } | md5sum | cut -d" " -f1)
+
+    # see if we can link to the reuse pool
+    # XXX - hrm.  i'm not convinced this doesn't belong in the reuse "library"
+    local CAN_LINK_FOR_REUSE=false
+    touch $REUSEBUILD/$$
+    if cp -al $REUSEBUILD/$$ $TOPDIR/; then
+        CAN_LINK_FOR_REUSE=true
     fi
-    return 255
+    rm $REUSEBUILD/$$
+
+    # the extra version string to use for the kernel (which might be a reused
+    # kernel, remember)
+    local kernel_extra_version=""
+    if $REUSERPM && ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
+                                   "$REUSE_SIGNATURE"; then
+        # nothing cached, build from scratch
+        if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then
+            download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&2
+        fi
+
+        if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \
+                  --define "_topdir $TOPDIR" >&2; then
+            # should we clean this up or leave it for analysis?
+            #rm -rf $RPMTOPDIR
+            fatal 1 "Error installing kernel SRPM."
+        fi
+
+        # put the Lustre kernel patch into the RPM build tree
+        cp $FULL_PATCH $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
+        prepare_and_build_srpm >&2
+
+        # store the resulting kernel RPM build tree for future use
+        if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
+                             "kernel" "$REUSEBUILD" "$REUSE_SIGNATURE" \
+                             "$CAN_LINK_FOR_REUSE"; then
+            error "Failed to store kernel RPMS for reuse"
+            echo "unknown"
+            return 1
+        fi
+    fi	# build reuse
+
+    # figure out the EXTRA_VERSION of the kernel we built or are re-using
+    local KERNEL_RPM
+    if ! KERNEL_RPM=$(find_rpm "$TOPDIR/RPMS/$TARGET_ARCH/" provides "^kernel ="); then
+        fatal 1 "Failed to find a kernel RPM in $TOPDIR/RPMS/$TARGET_ARCH/"
+    fi
+    kernel_extra_version=$(rpm -q --queryformat "%{RELEASE}" -p $TOPDIR/RPMS/$TARGET_ARCH/$KERNEL_RPM)
+
+    # should now have the following RPMs
+    # $TOPDIR/RPMS/$arch/kernel-lustre-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-devel-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-headers-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-common-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+
+    echo $kernel_extra_version
+    return 0
+
 }
 
-#try to reuse old BUILD dir
-build_sequence_reuse()
-{
-    local sourcerpm=$1
-    [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
-    local dirsforreuse=
-    if [ ! "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse old kernel build directory
-        local dirsforreuse="$(get_reuse_dir_list)"
-        local buildsuccess=false
-        LINUXOBJ=
-        local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
-        for curdir in $(echo $dirsforreuse); do
-            local reusedkernelrpm=
-            local reusedkernelsourcerpm=
-            local reusedkernelibrpm=
-            [ -d "$curdir" ] || continue
-            [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" -a 
-	      ! -d "${curdir%/*}/ofa_kernel" ] && continue
-            local reusedkernelprefix="kernel-lustre-"
-            ( $PATCHLESS ) && reusedkernelprefix=
-            [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
-                reusedkernelrpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
-            reusedkernelprefix="kernel-lustre-source-"
-            [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm ] && \
-                reusedkernelsourcerpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm | head -1 ) 
-            if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-                gen_lustre_version
-                reusedkernelprefix="kernel-ib-"
-                [ -f ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm ] && \
-                    reusedkernelibrpm=$(ls ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 ) 
-                    reusedkernelibdevelrpm=$(ls ${curdir}/../${reusedkernelprefix}devel-${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 ) 
+build_with_srpm() {
+
+    if ! $PATCHLESS; then
+        local kernel_extra_version
+        if ! kernel_extra_version=$(build_kernel_with_srpm); then
+            fatal 1 "Failed to build the kernel from it's SRPM"
+        fi
+
+        for arch in $BUILD_ARCHS; do
+
+            local kernel_devel_rpm
+            if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name true) ="); then
+                fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/"
             fi
-            if ! ( $NORPM ) && ! [ -f "$reusedkernelrpm" ]; then #kernel rpm not found. Build all
-                continue
+
+            # install the -devel RPM in preparation for the lustre build
+            # note that the EXTRA_VERSION_DELIMITER is *NOT* used in the
+            # version of the directory name under /usr/src
+            if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \
+                           "$TOPDIR/RPMS/$arch/$kernel_devel_rpm" "-"; then
+                fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm"
             fi
-            if ! ( $NORPM ) && ! [ -f "$reusedkernelsourcerpm" ]; then #kernel source rpm not found. Build all
-                continue
+        done
+    else
+        # need to find and unpack the vendor's own kernel-devel for patchless
+        # client build
+        local kernelrpm
+        if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE" ${EXTRA_VERSION_DELIMITER:-"-"}); then
+            fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
+        fi
+        if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then
+            fatal 1 "Could not find the Linux tree in $kernelrpm"
+        fi
+    fi
+
+    # before lustre, build kernel-ib
+    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
+        # see if we can link to the reuse pool
+        # XXX - hrm.  i'm not convinced this doesn't belong in the reuse "library"
+        local CAN_LINK_FOR_REUSE=false
+        touch $REUSEBUILD/$$
+        if cp -al $REUSEBUILD/$$ $TOPDIR/; then
+            CAN_LINK_FOR_REUSE=true
+        fi
+        rm $REUSEBUILD/$$
+
+        local REUSE_SIGNATURE=$({ echo "$OFED_VERSION"; echo "$(find_linux_release ${LINUXOBJ:-$LINUX})"; cat "${LINUXOBJ:-${LINUX}}/include/linux/autoconf.h"; } | md5sum | cut -d" " -f1)
+        if ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
+                        "$REUSE_SIGNATURE"; then
+            # stash away the existing built articles for a moment
+            mkdir bak
+            mv {BUILD,{S,}RPMS,S{OURCE,PEC}S} bak
+            function mv_back {
+                pushd bak
+                find . | cpio -pudlm ..
+                popd
+                rm -rf bak
+            }
+            create_rpmbuild_dirs
+            # build it
+            build_kernel_ib
+            if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
+                                 "ofed" "$REUSEBUILD" "$REUSE_SIGNATURE" \
+                                 "$CAN_LINK_FOR_REUSE"; then
+                error "Failed to store OFED RPMS for reuse"
+                mv_back
+                return 1
             fi
-            if [ -n "$OFED_VERSION" ]; then
-            	if [ "$OFED_VERSION" != "inkernel" ]; then
-                if ! ( $NORPM ) && [ ! -f "$reusedkernelibrpm" -o ! -f "$reusedkernelibdevelrpm"]; then #kernel-ib{,-devel} rpm not found. Build all
-                    continue
+            # put the stuff we stashed away back
+            mv_back
+        fi
+
+        pushd "$TOPDIR" >/dev/null
+        rm -rf kernel-ib-devel
+        mkdir kernel-ib-devel
+        cd kernel-ib-devel
+        # the actual ofed RPMs don't have the -rc$n or -$date string appened that
+        # might be present on the file
+        local ofed_version=$(echo $OFED_VERSION |
+                         sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//')
+        local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${ofed_version}-${LINUXRELEASE//-/_}.*.rpm)
+        rpm2cpio -itv < $rpm | cpio -id
+        CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
+        popd >/dev/null
+    fi
+
+    # now build Lustre
+    if build_lustre; then
+        # the build worked.  resolve any symlinked files (i.e. from reuse)
+        # in RPMS/$arch to real files so that that that huge mess of
+        # complication knows as LTS can copy them yet somewhere else.
+        # is it any wonder this whole process is so damn so?  anyone ever
+        # heard of hardlinks?  it this cool new thing that allows you save
+        # tons of time and space by creating... well you can go read about
+        # them if you have not heard about them yet.
+        # can i say how much the implemenation of all of this really impedes
+        # RPM reuse?
+        pushd RPMS/$TARGET_ARCH
+            for file in *; do
+                if [ -h $file ]; then
+                    cp $file foo
+                    mv foo $file
                 fi
-                CONFIGURE_FLAGS="--with-o2ib=${curdir%/*}/ofa_kernel ${CONFIGURE_FLAGS}"
-                else
-                    CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
-		fi
-            fi
-            LINUX="$curdir"
-            build_lustre || continue
-            touch "$curdir/../"
-            buildsuccess=true
-            if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
-                [ -f "$reusedkernelrpm" ] && \
-                    cp -f  "$reusedkernelrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
-                    touch RPMS/${TARGET_ARCH}/kernel_was_reused
-                [ -f "$reusedkernelsourcerpm" ] && \
-                    cp -f  "$reusedkernelsourcerpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
-                [ -f "$reusedkernelibrpm" ] && \
-                    cp -f  "$reusedkernelibrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
-                    cp -f  "$reusedkernelibdevelrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
-            fi
-            return
-        done
+            done
+        popd
+    else
+        return 1
     fi
-    return 255
+
 }
 
+create_rpmbuild_dirs() {
 
-build_sequence()
-{
-    if (( $DO_SRC )) ; then
-        unpack_linux
-        patch_linux
-        pack_linux
-        clean_linux
-    fi
-    prep_kernel_build || return 255
-    clean_lustre || return 255
+    [ -d RPMS ] || mkdir RPMS
+    for arch in $BUILD_ARCHS; do
+        if [[ $arch = i?86 ]]; then
+            # some stupidity in the sles11 kernel spec requires an RPMS/i386
+            # even if the target arch is i686
+            [ -d RPMS/i386 ] || mkdir RPMS/i386
+        fi
+        [ -d RPMS/$arch ] || mkdir RPMS/$arch
+    done
+    [ -d BUILD ] || mkdir BUILD
+    [ -d SOURCES ] || mkdir SOURCES
+    [ -d SPECS ] || mkdir SPECS
+    [ -d SRPMS ] || mkdir SRPMS
+
+}
+
+new_list() {
+
+    echo ""
+
+}
+
+add_list() {
+    local list="$1"
+    local item="$2"
+
+    echo "$list $item"
+
+}
+
+is_list_member() {
+    local list="$1"
+    local item="$2"
+
+    [[ $list\  == *\ $item\ * ]]
+
+}
+
+#########################################################################
+# Generate a backtrace through the call stack.
+#
+# Input: None
+# Output: None
+#########################################################################
+backtrace() {
+    local strip=${1:-1}
+
+    local funcname="" sourcefile="" lineno="" n
+
+    echo "Call stack: (most recent first)"
+    for (( n = $strip ; n < ${#FUNCNAME[@]} ; ++n )) ; do
+        funcname=${FUNCNAME[$n - 1]}
+        sourcefile=$(basename ${BASH_SOURCE[$n]})
+        lineno=${BASH_LINENO[$n - 1]}
+        # Display function arguments
+        if [[ ! -z "${BASH_ARGV[@]}" ]]; then
+            local args newarg j p=0
+            for (( j = ${BASH_ARGC[$n - 1]}; j > 0; j-- )); do
+                newarg=${BASH_ARGV[$j + $p - 1]}
+                args="${args:+${args} }'${newarg}'"
+            done
+            let p+=${BASH_ARGC[$n - 1]}
+	fi
+        echo "  ${funcname} ${args:+${args} }at ${sourcefile}:${lineno}"
+    done
+
+    echo
+    echo "BEGIN BACKTRACE"
+
+    #echo ${BASH_LINENO[*]}
+    #echo ${BASH_SOURCE[*]}
+    #echo ${FUNCNAME[*]}
+    local i=$((${#FUNCNAME[@]} - 1))
+    while [ $i -ge 0 ]; do
+        local SOURCELINE="${BASH_SOURCE[$i + 1]}:${BASH_LINENO[$i]}"
+        # Can't figure out how to get function args from other frames...
+        local FUNCTION="${FUNCNAME[$i]}()"
+        echo "$SOURCELINE:$FUNCTION"
+        i=$((i - 1))
+    done
+
+    echo "END BACKTRACE"
+
+    echo $BACKTRACE
 
-    build_kernel || return 255
 }
 
 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
 
-options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux: -- "$@")
+options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux:,xen -- "$@")
 
-if [ $? != 0 ] ; then
+if [ $? != 0 ]; then
     usage 1
 fi
 
 eval set -- "$options"
-    
-while [ "$1" ] ; do
+
+while [ "$1" ]; do
     case "$1" in
         '')
             usage 1
@@ -1604,11 +1414,15 @@ while [ "$1" ] ; do
             shift 2
             ;;
         --kerneltree)
-            KERNELTREE=$2
+            if ! KERNELTREE=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --linux | --with-linux)
-            LINUX=$2
+            if ! LINUX=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --distro)
@@ -1620,7 +1434,9 @@ while [ "$1" ] ; do
             shift 2
             ;;
         --reusebuild)
-            REUSEBUILD=$2
+            if ! REUSEBUILD=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --norpm)
@@ -1636,7 +1452,9 @@ while [ "$1" ] ; do
             shift
             ;;
         --kernelrpm)
-            KERNELRPMSBASE=$2
+            if ! KERNELRPMSBASE=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --timestamp)
@@ -1648,11 +1466,11 @@ while [ "$1" ] ; do
             shift 2
             ;;
         --nodownload)
-            DOWNLOAD=0
+            DOWNLOAD=false
             shift 1
             ;;
         --nosrc)
-            DO_SRC=0
+            DO_SRC=false
             shift 1
             ;;
         --publish)
@@ -1663,7 +1481,7 @@ while [ "$1" ] ; do
             shift
             ;;
         --src)
-            DO_SRC=1
+            DO_SRC=true
             shift 1
             ;;
         --stage)
@@ -1686,12 +1504,16 @@ while [ "$1" ] ; do
             USE_DATESTAMP=
             shift
             ;;
+        --xen)
+            XEN=true
+            shift
+            ;;
         --)
             shift
             CONFIGURE_FLAGS=$@
             CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests"
             break
-            ;; 
+            ;;
         *)
             usage 1 "Unrecognized option: $1"
             ;;
@@ -1706,26 +1528,64 @@ load_target
 EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
 
 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-    unpack_ofed
+    download_ofed
+    unpack_ofed || fatal 1 "Error unpacking OFED tarball"
 fi
 
-build_success=false
-if $PATCHLESS; then
-    patchless_build_sequence && build_success=true 
-elif [ -z "$LINUX" ] ; then
-    [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
-    if ! $build_success; then
-        build_sequence_reuse && build_success=true
-        if ! $build_success; then
-            build_sequence && build_success=true
-            if $build_success; then
-                store_for_reuse || echo "Cannot store for future reuse"
+# make sure the RPM build environment is set up
+create_rpmbuild_dirs
+
+trap '[ -n "$CCACHE" ] && ccache -s' EXIT
+
+# if an unpacked kernel source tree was given on the command line
+# just build lustre with it (nothing distro kernel specific here)
+if [ -n "$LINUX" ]; then
+    build_lustre
+else
+    if [ -f "${0%/*}/lbuild-$DISTRO" ]; then
+        seen_list=$(new_list)
+        trap '(echo "Untrapped error"
+echo
+# have we seen this one
+echo "checking seen list for ${BASH_SOURCE[0]}:${BASH_LINENO[0]}"
+
+if is_list_member "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}"; then
+  echo "seen this one already"
+else
+  seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}")
+fi
+backtrace
+echo
+echo "Environment:"
+set
+) | tee >(mail -s "Untrapped error at ${BASH_SOURCE[0]##*/}:${BASH_LINENO[0]} on $HOSTNAME" brian at sun.com) >&2' ERR
+        set -E
+
+        source ${0%/*}/lbuild-$DISTRO
+
+        build_with_srpm || fatal 1 "Failed to build_with_srpm"
+    else
+        source ${0%/*}/lbuild.old_school
+
+        old_school_download_kernel
+
+        build_success=false
+        if $PATCHLESS; then
+            patchless_build_sequence && build_success=true
+        else
+            [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
+            if ! $build_success; then
+                build_sequence_reuse && build_success=true
+                if ! $build_success; then
+                    build_sequence && build_success=true
+                    if $build_success; then
+                        store_for_reuse || echo "Cannot store for future reuse"
+                    fi
+                fi
             fi
         fi
+        ( $build_success ) || fatal 1 "Cannot build lustre"
     fi
-else
-    build_lustre && build_success=true
 fi
-( $build_success ) || fatal 1 "Cannot build lustre"
 
 stage
diff --git a/build/lmake b/build/lmake
index c9b22ea..b883453 100755
--- a/build/lmake
+++ b/build/lmake
@@ -47,6 +47,7 @@ KERNEL_FILE=
 SERIES_FILE=
 CONFIG_FILE=
 RPMBUILD=
+XEN=false
 
 canon()
 {
@@ -160,6 +161,9 @@ Options:
   --unpack-kernel
     Untars and patches the kernel source.
 
+  --xen
+    Builds a Xen domX kernel.
+
   The order that commands (--build-lustre, --unpack-kernel) are
   specified on the command line is ignored; ${0##*/} will always
   execute them in the correct order (unpack, then build, then install
@@ -228,12 +232,17 @@ load_target()
 
     . "$TARGET_FILE"
 
+    # doesn't make any sense to build OFED for xen domX's
+    if $XEN; then
+        OFED_VERSION=""
+    fi
+
     [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
 # Suse 2.6 has our patches in already
 #    [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
 #    [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify the kernel version."
-    
+
     if [ "$KERNELDIR" ] ; then
 	KERNEL_FILE="$KERNELDIR/$KERNEL"
 	[ -r "$KERNELDIR/$KERNEL" ] || \
@@ -248,8 +257,13 @@ load_target()
 	done
     fi
 
+    local XENPOSTFIX=""
+    if $XEN; then
+        XENPOSTFIX="-xen"
+    fi
+
     TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS}
-    CONFIG_TARGET="$TARGET-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
+    CONFIG_TARGET="${TARGET}${XENPOSTFIX}-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
     CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
     [ -r "$CONFIG_FILE" ] ||
 	fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/lustre/kernel_patches/configs."
@@ -270,10 +284,10 @@ setup_ccache_distcc()
             unset DISTCC
         fi
     fi
-    
+
     CC=${CC:-gcc}
     if [ "$CCACHE" ]; then
-        CC="$CCACHE $CC"
+        [[ $CC != ccache\ * ]] && CC="$CCACHE $CC"
         [ "$DISTCC" ] && export CCACHE_PREFIX="$DISTCC"
     else
         [ "$DISTCC" ] && CC="$DISTCC $CC"
@@ -316,7 +330,7 @@ extract_kernel()
 	[ -L linux ] && rm -rf $(readlink linux)
 	rm -rf linux
     fi
-    untar "$KERNEL_FILE"
+    untar "$KERNEL_FILE" || fatal 1 "Error unpacking Linux tarball"
     [ -d linux ] || ln -sf linux* linux
     popd >/dev/null
 }
@@ -401,7 +415,7 @@ depend_kernel()
     if [ -n "${TARGET_CONFIG}" ]; then
 	extra_version="${extra_version}${TARGET_DELIMITER}${TARGET_CONFIG}"
     fi
-    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${extra_version}/" Makefile
+    sed -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${extra_version}/" Makefile
     echo "Making depend in $PWD..."
     $MAKE "$MAKE_CC" mrproper || fatal 1 "Error running make mrproper"
     rm -f rpm-release
@@ -484,17 +498,21 @@ build_kernel()
     (( $BUILD_KERNEL )) || return 0
     set_make
     echo "Building kernel in $PWD..."
-    case "$TARGET_ARCH" in
-	i386 | i586 | i686 | athlon | x86_64)
-	    $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
-	    ;;
-    ia64 | ppc | ppc64)
-	    $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
-	    ;;
-	*)
-	    $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
-	    ;;
-    esac
+    if $XEN; then
+        $MAKE_J "$MAKE_CC" vmlinuz || fatal 1 "Error making vmlinux."
+    else
+        case "$TARGET_ARCH" in
+	    i386 | i586 | i686 | athlon | x86_64)
+	        $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
+	        ;;
+            ia64 | ppc | ppc64)
+	        $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
+	        ;;
+	    *)
+	        $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
+	        ;;
+        esac
+    fi
     $MAKE_J "$MAKE_CC" modules || fatal 1 "Error building modules."
 
     popd >/dev/null
@@ -525,7 +543,7 @@ build_kernel_ib()
 	      --define "KVERSION ${FULL_VERSION}" \
 	      --define "$K_SRC ${PWD}/linux" \
 	      --define "LIB_MOD_DIR /lib/modules/${FULL_VERSION}" \
-	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
+	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-*.src.rpm
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
         fatal 1 "Error building kernel-ib"
@@ -535,7 +553,7 @@ build_kernel_ib()
     rm -rf kernel-ib-devel
     mkdir kernel-ib-devel
     cd kernel-ib-devel
-    local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${FULL_VERSION//-/_}.*.rpm)
+    local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-*-${FULL_VERSION//-/_}.*.rpm)
     rpm2cpio -itv < $rpm | cpio -id
     CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
     popd >/dev/null
@@ -567,6 +585,7 @@ build_lustre()
 	< lustre.spec.in \
 	> lustre.spec
     $RPMBUILD --target ${TARGET_ARCH} -bb lustre.spec \
+        ${PATCHLESS:+--define "lustre_name lustre-client"} \
         --define "_tmppath $TMPDIR" \
 	--define "_topdir $(lbuild_topdir)" || \
 	fatal 1 "Error building Lustre rpms."
@@ -592,37 +611,42 @@ install_kernel()
 	-s modules_install || \
 	fatal 1 "Error installing modules."
 
-    case "$TARGET_ARCH" in
-	i386 | i586 | i686 | athlon)
-	    cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-	    ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ;;
-	x86_64)
-	    cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-	    ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ;;
-        ppc | ppc64)
-	    cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
-	    ;;
-	ia64)
-	    gzip -cfv vmlinux > vmlinuz
-	    mkdir -p "$DESTDIR/boot/efi/redhat"
-	    install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-	    install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
-	    ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
-	    ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    ;;
-	*)
-	    cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
-	    ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-
-	    ;;
-    esac
+    if $XEN; then
+	cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+	ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+    else
+        case "$TARGET_ARCH" in
+	    i386 | i586 | i686 | athlon)
+	        cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+	        ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ;;
+	    x86_64)
+	        cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+	        ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ;;
+            ppc | ppc64)
+	        cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
+	        ;;
+	    ia64)
+	        gzip -cfv vmlinux > vmlinuz
+	        mkdir -p "$DESTDIR/boot/efi/redhat"
+	        install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+	        install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
+	        ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
+	        ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        ;;
+	    *)
+	        cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+	        ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	    	;;
+    	esac
+    fi
     if [ -e init/kerntypes.o ] ; then
 	cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}"
     fi
@@ -764,7 +788,7 @@ save_all_headers()
 
 longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:"
 longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:"
-longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel"
+longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel,xen"
 
 options=$(getopt -o hj: -l "$longopts" -- "$@")
 
@@ -847,6 +871,10 @@ while [ "$1" ] ; do
 	    UNPACK_KERNEL=1
 	    shift
 	    ;;
+        --xen)
+            XEN=true
+            shift
+            ;;
 	--)
 	    shift
 	    CONFIGURE_FLAGS=$@
diff --git a/build/lustre-kernel-2.4.spec.in b/build/lustre-kernel-2.4.spec.in
index 804e65c..292b527 100644
--- a/build/lustre-kernel-2.4.spec.in
+++ b/build/lustre-kernel-2.4.spec.in
@@ -15,6 +15,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define release @KERNEL_RELEASE@
 # /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL}
 %define kslnk linux-2.4
+%define kprovides %(bash -c "echo %{kversion}%{kextraverdelim}%{kextraver} | sed -e 's/-[^0-9]*smp$//'")
 
 # groups of related archs
 %define all_x86 i386 i686 i586 athlon
@@ -25,6 +26,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define rhbuild @RHBUILD@
 %define susebuild @SUSEBUILD@
 %define linux26 @LINUX26@
+%define lmakeopts @LMAKEOPTS@
 
 # disable build root strip policy
 %define __spec_install_post /usr/lib/rpm/brp-compress || :
@@ -42,7 +44,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define dashtargetboard %{?targetboard:-%{targetboard}}
 %define withtargetboard 0
 %{?targetboard: %{expand: %%define withtargetboard 1}}
-	
+
 # Override generic defaults with per-arch defaults (which can
 # themselves be overridden with --with/--without).  These must
 # ONLY be "0", never "1"
@@ -157,7 +159,7 @@ Group: System Environment/Kernel
 ExclusiveArch: %{all_x86} x86_64 ia64 ppc ppc64
 ExclusiveOS: Linux
 Obsoletes: kernel-modules, kernel-sparc
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 BuildConflicts: rhbuildsys(DiscFree) < 500Mb
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
@@ -229,7 +231,7 @@ options that can be passed to Linux kernel modules at load time.
 %package smp
 Summary: The Linux kernel compiled for SMP machines.
 Group: System Environment/Kernel
-Provides: module-info, kernel = %{version}
+Provides: module-info, kernel = %{kprovides}
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
 %endif
@@ -248,7 +250,7 @@ Install the kernel-smp package if your machine uses two or more CPUs.
 %package bigsmp
 Summary: The Linux kernel compiled for SMP machines.
 Group: System/Kernel
-Provides: module-info, kernel = %{version}, k_smp4G
+Provides: module-info, kernel = %{kprovides}, k_smp4G
 Obsoletes: k_smp4G
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
@@ -268,7 +270,7 @@ Install the kernel-bigsmp package if your machine uses two or more CPUs.
 %package pseries64
 Summary: Standard Kernel for 64-bit Power based SMP and LPAR Machines
 Group: System/Kernel
-Provides: module-info, kernel = %{version}, k_smp4G
+Provides: module-info, kernel = %{kprovides}, k_smp4G
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
 %endif
@@ -287,7 +289,7 @@ machines.
 %package bigmem
 Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory.
 Group: System Environment/Kernel
-Provides: module-info, kernel = %{version}
+Provides: module-info, kernel = %{kprovides}
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
 %endif
@@ -304,7 +306,7 @@ enabled for Pentium III machines with 4 Gigabyte of memory or more.
 %package BOOT
 Summary: The version of the Linux kernel used on installation boot disks.
 Group: System Environment/Kernel
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 %if %{rhbuild}
 Prereq: %{BOOT_kernel_prereq}
 Conflicts: %{kernel_conflicts}
@@ -319,7 +321,7 @@ turned off because of the size constraints.
 %package BOOTsmp
 Summary: The Linux kernel used on installation boot disks for SMP machines.
 Group: System Environment/Kernel
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 %if %{rhbuild}
 Prereq: %{BOOT_kernel_prereq}
 Conflicts: %{kernel_conflicts}
@@ -335,7 +337,7 @@ machines that have trouble coming up to life with the uniprocessor kernel.
 %package jensen
 Summary: The Linux Kernel compiled for the Alpha Jensen platform.
 Group: System Environment/Kernel
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 %if %{rhbuild}
 Prereq: %{kernel_prereq}
 Conflicts: %{kernel_conflicts}
@@ -380,11 +382,11 @@ pushd lustre >/dev/null
 if [ -s "%{SOURCE2}" ] ; then
        tar zxf "%{SOURCE2}" -C lustre/kernel_patches
 fi
-sh -x ./build/lmake \
+bash -x ./build/lmake \
 	--unpack-kernel \
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
-	--kerneldir $RPM_SOURCE_DIR
+	--kerneldir $RPM_SOURCE_DIR %{lmakeopts}
 popd >/dev/null
 
 # handle both SuSE and Red Hat's new-kernel-pkg bits
@@ -515,19 +517,19 @@ mkdir -p $RPM_BUILD_ROOT
 DependKernel()
 {
   target_config=${1:+--target-config $1}
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--depend-kernel \
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
 	${target_config} \
 	--extraversion %{kextraver} \
-	-j $RPM_BUILD_NCPUS
+	-j $RPM_BUILD_NCPUS %{lmakeopts}
 }
 
 BuildKernel()
 {
   target_config=${1:+--target-config $1}
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--build-kernel --build-lustre \
 	--install \
 	--save-headers \
@@ -537,7 +539,7 @@ BuildKernel()
 	--extraversion %{kextraver} \
 	--kerneldir $RPM_SOURCE_DIR \
 	-j $RPM_BUILD_NCPUS \
-	--destdir $RPM_BUILD_ROOT \
+	--destdir $RPM_BUILD_ROOT %{lmakeopts} \
 	-- --enable-tests \
 	@CONFIGURE_FLAGS@
 }
@@ -545,7 +547,7 @@ BuildKernel()
 BuildLustre()
 {
   target_config=${1:+--target-config $1}
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--build-lustre \
 	--install-lustre \
 	--target @LUSTRE_TARGET@ \
@@ -554,7 +556,7 @@ BuildLustre()
 	--extraversion %{kextraver} \
 	--kerneldir $RPM_SOURCE_DIR \
 	-j $RPM_BUILD_NCPUS \
-	--destdir $RPM_BUILD_ROOT \
+	--destdir $RPM_BUILD_ROOT %{lmakeopts} \
 	-- --enable-utils \
 	--disable-doc --disable-tests \
 	--disable-modules --disable-liblustre \
@@ -565,12 +567,12 @@ BuildLustre()
 
 SaveHeaders()
 {
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--save-headers \
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
 	--extraversion %{kextraver} \
-	--destdir $RPM_BUILD_ROOT
+	--destdir $RPM_BUILD_ROOT %{lmakeopts}
 }
 
 pushd lustre >/dev/null
@@ -645,7 +647,7 @@ BuildObj ()
 	    if grep -q "$oc" Makefile ; then
 	        OLDCONFIG="$oc"
 		break
-   	    fi
+	    fi
         done
 	MAKE="make -s O=$o -C ${c}"
 	if [ "$CC" ] ; then
@@ -661,7 +663,7 @@ BuildObj ()
 $(set -- 2.6.5 ; echo ${*//./ })
 EOF
 	rm -f $o/Makefile
-	ARCH=%{_target_cpu} /bin/sh scripts/mkmakefile ../../../linux-%{KVERREL} $o \
+	ARCH=%{_target_cpu} /bin/bash scripts/mkmakefile ../../../linux-%{KVERREL} $o \
 		$VERSION $PATCHLEVEL > $o/Makefile.in
 	if [ -f $o/Makefile ] ; then
 		# will exist only for 2.6.17 and newer because mkmakefile
@@ -732,7 +734,7 @@ if [ "%{buildbase}" -ne 0 ] ; then
 	    if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
 		OLDCONFIG="$oc"
 		break
-   	    fi
+	    fi
         done
 	if [ "$CC" ] ; then
 	    MAKE_CC="CC=$CC"
diff --git a/config.h.in b/config.h.in
index 8a7c9a0..659fea8 100644
--- a/config.h.in
+++ b/config.h.in
@@ -6,9 +6,21 @@
 /* disable libcfs ENTRY/EXIT */
 #undef CDEBUG_ENTRY_EXIT
 
+/* enable posix acls for ldiskfs */
+#undef CONFIG_LDISKFSDEV_FS_POSIX_ACL
+
+/* enable fs security for ldiskfs */
+#undef CONFIG_LDISKFSDEV_FS_SECURITY
+
+/* enable extented attributes for ldiskfs */
+#undef CONFIG_LDISKFSDEV_FS_XATTR
+
 /* build ldiskfs as a module */
 #undef CONFIG_LDISKFS_FS_MODULE
 
+/* enable fs security for ldiskfs */
+#undef CONFIG_LDISKFS_FS_NFS4ACL
+
 /* enable posix acls for ldiskfs */
 #undef CONFIG_LDISKFS_FS_POSIX_ACL
 
@@ -27,9 +39,24 @@
 /* Enable Cray XT3 Features */
 #undef CRAY_XT3
 
+/* name of ldiskfs debug program */
+#undef DEBUGFS
+
 /* Enable DMU OSD */
 #undef DMU_OSD
 
+/* name of ldiskfs dump program */
+#undef DUMPE2FS
+
+/* name of ldiskfs fsck program */
+#undef E2FSCK
+
+/* name of ldiskfs e2fsprogs package */
+#undef E2FSPROGS
+
+/* name of ldiskfs label program */
+#undef E2LABEL
+
 /* do data checksums */
 #undef ENABLE_CHECKSUM
 
@@ -45,6 +72,9 @@
 /* INIT_WORK use 3 args and store data inside */
 #undef HAVE_3ARGS_INIT_WORK
 
+/* vfs_symlink wants 4 args */
+#undef HAVE_4ARGS_VFS_SYMLINK
+
 /* support alder32 checksum type */
 #undef HAVE_ADLER
 
@@ -66,9 +96,15 @@
 /* Enable BGL Features */
 #undef HAVE_BGL_SUPPORT
 
+/* if kernel has bio_endio with 2 args */
+#undef HAVE_BIO_ENDIO_2ARG
+
 /* Kernel has bit_spinlock.h */
 #undef HAVE_BIT_SPINLOCK_H
 
+/* struct bio has a bi_hw_segments field */
+#undef HAVE_BI_HW_SEGMENTS
+
 /* Define to 1 if you have the <blkid/blkid.h> header file. */
 #undef HAVE_BLKID_BLKID_H
 
@@ -87,9 +123,6 @@
 /* Define to 1 if you have the <catamount/data.h> header file. */
 #undef HAVE_CATAMOUNT_DATA_H
 
-/* cond_resched found */
-#undef HAVE_COND_RESCHED
-
 /* Define to 1 if you have the `connect' function. */
 #undef HAVE_CONNECT
 
@@ -102,15 +135,18 @@
 /* cpu_online found */
 #undef HAVE_CPU_ONLINE
 
+/* Enable delayed recovery support */
+#undef HAVE_DELAYED_RECOVERY
+
 /* kernel has new dev_set_rdonly */
 #undef HAVE_DEV_SET_RDONLY
 
-/* the kernel passes struct file to direct_IO */
-#undef HAVE_DIO_FILE
-
 /* after 2.6.17 dquote use mutex instead if semaphore */
 #undef HAVE_DQUOTOFF_MUTEX
 
+/* dump_trace is exported */
+#undef HAVE_DUMP_TRACE
+
 /* Kernel has d_add_unique */
 #undef HAVE_D_ADD_UNIQUE
 
@@ -123,15 +159,27 @@
 /* Define to 1 if you have the <endian.h> header file. */
 #undef HAVE_ENDIAN_H
 
+/* inode_permission is exported by the kernel */
+#undef HAVE_EXPORT_INODE_PERMISSION
+
 /* kernel exports __iget */
 #undef HAVE_EXPORT___IGET
 
 /* Define to 1 if you have the <ext2fs/ext2fs.h> header file. */
 #undef HAVE_EXT2FS_EXT2FS_H
 
+/* build ext4 based ldiskfs */
+#undef HAVE_EXT4_LDISKFS
+
+/* kernel has .fh_to_dentry member in export_operations struct */
+#undef HAVE_FH_TO_DENTRY
+
 /* filemap_fdatawrite() found */
 #undef HAVE_FILEMAP_FDATAWRITE
 
+/* filemap_fdatawrite_range is exported by the kernel */
+#undef HAVE_FILEMAP_FDATAWRITE_RANGE
+
 /* Kernel exports filemap_populate */
 #undef HAVE_FILEMAP_POPULATE
 
@@ -144,12 +192,21 @@
 /* use fops->readv */
 #undef HAVE_FILE_READV
 
+/* kernel have file_remove_suid */
+#undef HAVE_FILE_REMOVE_SUID
+
+/* use file_update_time */
+#undef HAVE_FILE_UPDATE_TIME
+
 /* use fops->writev */
 #undef HAVE_FILE_WRITEV
 
 /* kernel has FS_RENAME_DOES_D_MOVE flag */
 #undef HAVE_FS_RENAME_DOES_D_MOVE
 
+/* fs_struct use path structure */
+#undef HAVE_FS_STRUCT_USE_PATH
+
 /* struct file_operations has flock field */
 #undef HAVE_F_OP_FLOCK
 
@@ -171,9 +228,15 @@
 /* struct inode has i_blksize field */
 #undef HAVE_INODE_BLKSIZE
 
+/* struct inode has i_private field */
+#undef HAVE_INODE_IPRIVATE
+
 /* after 2.6.15 inode have i_mutex intead of i_sem */
 #undef HAVE_INODE_I_MUTEX
 
+/* inode_operations->permission have two args */
+#undef HAVE_INODE_PERMISION_2ARGS
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -183,14 +246,23 @@
 /* invalidate_bdev has second argument */
 #undef HAVE_INVALIDATE_BDEV_2ARG
 
+/* exported invalidate_inode_pages */
+#undef HAVE_INVALIDATE_INODE_PAGES
+
+/* exported invalidate_mapping_pages */
+#undef HAVE_INVALIDATE_MAPPING_PAGES
+
 /* struct inode has i_alloc_sem */
 #undef HAVE_I_ALLOC_SEM
 
+/* kernel has .sendfile */
+#undef HAVE_KERNEL_SENDFILE
+
 /* kernel has .slice_read */
 #undef HAVE_KERNEL_SPLICE_READ
 
-/* struct kiobuf has a dovary field */
-#undef HAVE_KIOBUF_DOVARY
+/* kernel __u64 is long long type */
+#undef HAVE_KERN__U64_LONG_LONG
 
 /* kernel has struct kmem_cache */
 #undef HAVE_KMEM_CACHE
@@ -201,6 +273,9 @@
 /* kmem_cache_destroy(cachep) return int */
 #undef HAVE_KMEM_CACHE_DESTROY_INT
 
+/* enable use of ldiskfsprogs package */
+#undef HAVE_LDISKFSPROGS
+
 /* __le16 and __le32 types are defined */
 #undef HAVE_LE_TYPES
 
@@ -219,9 +294,12 @@
 /* libwrap support is requested */
 #undef HAVE_LIBWRAP
 
-/* Define to 1 if you have the <linux/exportfs.h> header file. */
+/* kernel has include/exportfs.h */
 #undef HAVE_LINUX_EXPORTFS_H
 
+/* kernel has include/mm_types.h */
+#undef HAVE_LINUX_MMTYPES_H
+
 /* linux/posix_acl_xattr.h found */
 #undef HAVE_LINUX_POSIX_ACL_XATTR_H
 
@@ -240,6 +318,9 @@
 /* Enable lru resize support */
 #undef HAVE_LRU_RESIZE_SUPPORT
 
+/* kernel have mapping_cap_writeback_dirty */
+#undef HAVE_MAPPING_CAP_WRITEBACK_DIRTY
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -270,6 +351,15 @@
 /* ib_dma_map_single defined */
 #undef HAVE_OFED_IB_DMA_MAP
 
+/* has completion vector */
+#undef HAVE_OFED_RDMA_CMEV_ADDRCHANGE
+
+/* has completion vector */
+#undef HAVE_OFED_RDMA_CMEV_TIMEWAIT_EXIT
+
+/* has transport iWARP */
+#undef HAVE_OFED_TRANSPORT_IWARP
+
 /* does kernel have PageChecked and SetPageChecked */
 #undef HAVE_PAGE_CHECKED
 
@@ -282,8 +372,11 @@
 /* page_mapped found */
 #undef HAVE_PAGE_MAPPED
 
-/* the kernel defines PDE */
-#undef HAVE_PDE
+/* percpu_counter_init has two arguments */
+#undef HAVE_PERCPU_2ND_ARG
+
+/* percpu_counter found */
+#undef HAVE_PERCPU_COUNTER
 
 /* is kernel have PG_fs_misc */
 #undef HAVE_PG_FS_MISC
@@ -291,18 +384,51 @@
 /* readlink returns ssize_t */
 #undef HAVE_POSIX_1003_READLINK
 
+/* kernel has deleted member in procfs entry struct */
+#undef HAVE_PROCFS_DELETED
+
+/* kernel has pde_users member in procfs entry struct */
+#undef HAVE_PROCFS_USERS
+
 /* have quota64 */
 #undef HAVE_QUOTA64
 
+/* kernel has include/linux/quotaio_v1.h */
+#undef HAVE_QUOTAIO_V1_H
+
+/* quota_off needs 3 paramters */
+#undef HAVE_QUOTA_OFF_3ARGS
+
+/* quota_on needs 5 paramters */
+#undef HAVE_QUOTA_ON_5ARGS
+
 /* Enable quota support */
 #undef HAVE_QUOTA_SUPPORT
 
 /* have RCU defined */
 #undef HAVE_RCU
 
+/* super_operations has a read_inode */
+#undef HAVE_READ_INODE_IN_SBOPS
+
 /* register_cache found */
 #undef HAVE_REGISTER_CACHE
 
+/* if kernel has register_shrinker */
+#undef HAVE_REGISTER_SHRINKER
+
+/* releasepage with gfp_t parameter */
+#undef HAVE_RELEASEPAGE_WITH_GFP
+
+/* mapping->tree_lock is rw_lock */
+#undef HAVE_RW_TREE_LOCK
+
+/* Kernel has a sb_any_quota_active */
+#undef HAVE_SB_ANY_QUOTA_ACTIVE
+
+/* Kernel has a sb_has_quota_active */
+#undef HAVE_SB_HAS_QUOTA_ACTIVE
+
 /* struct scatterlist has page member */
 #undef HAVE_SCATTERLIST_SETPAGE
 
@@ -312,18 +438,21 @@
 /* semaphore counter is atomic */
 #undef HAVE_SEM_COUNT_ATOMIC
 
-/* set_fs_pwd is exported */
-#undef HAVE_SET_FS_PWD
-
 /* show_task is exported */
 #undef HAVE_SHOW_TASK
 
+/* shrinker_cache found */
+#undef HAVE_SHRINKER_CACHE
+
 /* size_t is long type */
 #undef HAVE_SIZE_T_LONG
 
 /* Define to 1 if you have the `socket' function. */
 #undef HAVE_SOCKET
 
+/* sock_map_fd have second argument */
+#undef HAVE_SOCK_MAP_FD_2ARG
+
 /* spinlock_t is defined */
 #undef HAVE_SPINLOCK_T
 
@@ -351,9 +480,15 @@
 /* Define to 1 if you have the `strnlen' function. */
 #undef HAVE_STRNLEN
 
+/* in 2.6.12 synchronize_rcu preferred over synchronize_kernel */
+#undef HAVE_SYNCHRONIZE_RCU
+
 /* sysctl has CTL_UNNUMBERED */
 #undef HAVE_SYSCTL_UNNUMBERED
 
+/* kernel exports sysctl_vfs_cache_pressure */
+#undef HAVE_SYSCTL_VFS_CACHE_PRESSURE
+
 /* Define to 1 if you have the <sys/ioctl.h> header file. */
 #undef HAVE_SYS_IOCTL_H
 
@@ -378,11 +513,20 @@
 /* task p_pptr found */
 #undef HAVE_TASK_PPTR
 
+/* task_struct has rcu field */
+#undef HAVE_TASK_RCU
+
+/* print_trace_address has reliable argument */
+#undef HAVE_TRACE_ADDRESS_RELIABLE
+
 /* kernel export truncate_complete_page */
 #undef HAVE_TRUNCATE_COMPLETE_PAGE
 
-/* __u64 is long long type */
-#undef HAVE_U64_LONG_LONG
+/* kernel export truncate_inode_pages_range */
+#undef HAVE_TRUNCATE_RANGE
+
+/* kernel use trylock_page for page lock */
+#undef HAVE_TRYLOCK_PAGE
 
 /* Define umount_begin need second argument */
 #undef HAVE_UMOUNTBEGIN_VFSMOUNT
@@ -396,6 +540,12 @@
 /* unregister_blkdev return int */
 #undef HAVE_UNREGISTER_BLKDEV_RETURN_INT
 
+/* userspace __u64 is long long type */
+#undef HAVE_USER__U64_LONG_LONG
+
+/* vfs_dq_off is defined */
+#undef HAVE_VFS_DQ_OFF
+
 /* VFS intent patches are applied */
 #undef HAVE_VFS_INTENT_PATCHES
 
@@ -405,6 +555,12 @@
 /* if vfs_readdir need 64bit inode number */
 #undef HAVE_VFS_READDIR_U64_INO
 
+/* vfs_symlink need 5 parameteres */
+#undef HAVE_VFS_SYMLINK_5ARGS
+
+/* if kernel has .fault in vm_operation_struct */
+#undef HAVE_VM_OP_FAULT
+
 /* Kernel has xattr_acl */
 #undef HAVE_XATTR_ACL
 
@@ -447,6 +603,9 @@
 /* Report minimum OST free space */
 #undef MIN_DF
 
+/* name of ldiskfs mkfs program */
+#undef MKE2FS
+
 /* IOCTL Buffer Size */
 #undef OBD_MAX_IOCTL_BUFFER
 
@@ -486,6 +645,9 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 
+/* name of ldiskfs tune program */
+#undef TUNE2FS
+
 /* Enable user-level OSS */
 #undef UOSS_SUPPORT
 
@@ -494,6 +656,3 @@
 
 /* Version number of package */
 #undef VERSION
-
-/* zap_page_range with vma parameter */
-#undef ZAP_PAGE_RANGE_VMA
diff --git a/configure b/configure
index e76e319..ee0cb79 100755
--- a/configure
+++ b/configure
@@ -318,7 +318,7 @@ ac_subdirs_all="$ac_subdirs_all zfs"
 ac_subdirs_all="$ac_subdirs_all libsysio"
 ac_subdirs_all="$ac_subdirs_all ldiskfs"
 ac_subdirs_all="$ac_subdirs_all lustre-iokit"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS AC_LUSTRE_MAJOR AC_LUSTRE_MINOR AC_LUSTRE_PATCH AC_LUSTRE_FIX AC_LUSTRE_VERSION_STRING AC_LUSTRE_VER_ALLOWED_OFFSET AC_LUSTRE_LIB_VER_OFFSET_WARN AC_LUSTRE_CLI_VER_OFFSET_WARN AC_LUSTRE_CLIENT_URN AC_LUSTRE_MDS_URN AC_LUSTRE_MGS_URN AC_LUSTRE_OSS_URN LDISKFS_ENABLED_TRUE LDISKFS_ENABLED_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE lb_target_os LIBCFS_SUBDIR LIBCFS_INCLUDE_DIR INCLUDE_RULES docdir LUSTRE rootsbindir demodir pkgexampledir RANLIB ac_ct_RANLIB CPP EGREP LLCPPFLAGS LLCFLAGS EXTRA_KCFLAGS enable_uoss POSIX_OSD_ENABLED_TRUE POSIX_OSD_ENABLED_FALSE ENABLE_DOC ENABLE_INIT_SCRIPTS LINUX LINUX_OBJ LINUX_CONFIG ARCH_UM UML_CFLAGS MODULE_TARGET linux25 KMODEXT LINUXRELEASE moduledir modulefsdir modulenetdir RELEASE SYMVERFILE QSWCPPFLAGS QSWLND GMCPPFLAGS GMLIBS GMLND OPENIBCPPFLAGS OPENIBLND CIBCPPFLAGS CIBLND VIBCPPFLAGS VIBLND IIBCPPFLAGS IIBLND EXTRA_LNET_INCLUDE O2IBCPPFLAGS O2IBLND RACPPFLAGS RALND PTLLNDCPPFLAGS PTLLND MXCPPFLAGS MXLIBS MXLND BACKINGFS EXTRA_KLDFLAGS EXTRA_KLIBS kextdir plistdir macosdir DMU_SRC subdirs SPL_DIR ZFS_DIR spl_src DMU_OSD_ENABLED_TRUE DMU_OSD_ENABLED_FALSE KDMU_TRUE KDMU_FALSE SNMP_DIST_SUBDIR SNMP_SUBDIR LDISKFS_DIR LDISKFS_SUBDIR LUSTREIOKIT_SUBDIR MPI_ROOT LIBREADLINE LIBEFENCE LIBWRAP PTHREAD_LIBS ENABLE_LIBPTHREAD CAP_LIBS UPTLLND USOCKLND ZLIB NET_SNMP_CONFIG NET_SNMP_CFLAGS NET_SNMP_LIBS agentdir mibdir MODULES_TRUE MODULES_FALSE UTILS_TRUE UTILS_FALSE TESTS_TRUE TESTS_FALSE DOC_TRUE DOC_FALSE INIT_SCRIPTS_TRUE INIT_SCRIPTS_FALSE LINUX_TRUE LINUX_FALSE DARWIN_TRUE DARWIN_FALSE CRAY_XT3_TRUE CRAY_XT3_FALSE SUNOS_TRUE SUNOS_FALSE LIBSYSIO_SUBDIR SYSIO LINUX25_TRUE LINUX25_FALSE BUILD_QSWLND_TRUE BUILD_QSWLND_FALSE BUILD_GMLND_TRUE BUILD_GMLND_FALSE BUILD_MXLND_TRUE BUILD_MXLND_FALSE BUILD_O2IBLND_TRUE BUILD_O2IBLND_FALSE BUILD_OPENIBLND_TRUE BUILD_OPENIBLND_FALSE BUILD_CIBLND_TRUE BUILD_CIBLND_FALSE BUILD_IIBLND_TRUE BUILD_IIBLND_FALSE BUILD_VIBLND_TRUE BUILD_VIBLND_FALSE BUILD_RALND_TRUE BUILD_RALND_FALSE BUILD_PTLLND_TRUE BUILD_PTLLND_FALSE BUILD_UPTLLND_TRUE BUILD_UPTLLND_FALSE BUILD_USOCKLND_TRUE BUILD_USOCKLND_FALSE LIBLUSTRE_TRUE LIBLUSTRE_FALSE USE_QUILT_TRUE USE_QUILT_FALSE LIBLUSTRE_TESTS_TRUE LIBLUSTRE_TESTS_FALSE MPITESTS_TRUE MPITESTS_FALSE CLIENT_TRUE CLIENT_FALSE SERVER_TRUE SERVER_FALSE QUOTA_TRUE QUOTA_FALSE BLKID_TRUE BLKID_FALSE EXT2FS_DEVEL_TRUE EXT2FS_DEVEL_FALSE LIBPTHREAD_TRUE LIBPTHREAD_FALSE ac_configure_args MOSTLYCLEANFILES LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS AC_LUSTRE_MAJOR AC_LUSTRE_MINOR AC_LUSTRE_PATCH AC_LUSTRE_FIX AC_LUSTRE_VERSION_STRING AC_LUSTRE_VER_ALLOWED_OFFSET AC_LUSTRE_LIB_VER_OFFSET_WARN AC_LUSTRE_CLI_VER_OFFSET_WARN AC_LUSTRE_CLIENT_URN AC_LUSTRE_MDS_URN AC_LUSTRE_MGS_URN AC_LUSTRE_OSS_URN LDISKFS_ENABLED_TRUE LDISKFS_ENABLED_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE lb_target_os LIBCFS_SUBDIR LIBCFS_INCLUDE_DIR INCLUDE_RULES docdir LUSTRE rootsbindir demodir pkgexampledir RANLIB ac_ct_RANLIB CPP EGREP LLCPPFLAGS LLCFLAGS EXTRA_KCFLAGS enable_uoss POSIX_OSD_ENABLED_TRUE POSIX_OSD_ENABLED_FALSE ENABLE_DOC ENABLE_INIT_SCRIPTS LINUX LINUX_OBJ LINUX_CONFIG ARCH_UM UML_CFLAGS MODULE_TARGET linux25 KMODEXT LINUXRELEASE moduledir modulefsdir modulenetdir RELEASE SYMVERFILE QSWCPPFLAGS QSWLND GMCPPFLAGS GMLIBS GMLND OPENIBCPPFLAGS OPENIBLND CIBCPPFLAGS CIBLND VIBCPPFLAGS VIBLND IIBCPPFLAGS IIBLND EXTRA_LNET_INCLUDE O2IBCPPFLAGS O2IBLND RACPPFLAGS RALND PTLLNDCPPFLAGS PTLLND MXCPPFLAGS MXLIBS MXLND BACKINGFS EXTRA_KLDFLAGS EXTRA_KLIBS kextdir plistdir macosdir DMU_SRC subdirs SPL_DIR ZFS_DIR spl_src DMU_OSD_ENABLED_TRUE DMU_OSD_ENABLED_FALSE KDMU_TRUE KDMU_FALSE SNMP_DIST_SUBDIR SNMP_SUBDIR LDISKFS_DIR LDISKFS_SUBDIR LUSTREIOKIT_SUBDIR MPICC_WRAPPER LIBREADLINE LIBEFENCE LIBWRAP PTHREAD_LIBS ENABLE_LIBPTHREAD CAP_LIBS UPTLLND USOCKLND ZLIB NET_SNMP_CONFIG NET_SNMP_CFLAGS NET_SNMP_LIBS agentdir mibdir MODULES_TRUE MODULES_FALSE UTILS_TRUE UTILS_FALSE TESTS_TRUE TESTS_FALSE DOC_TRUE DOC_FALSE INIT_SCRIPTS_TRUE INIT_SCRIPTS_FALSE LINUX_TRUE LINUX_FALSE DARWIN_TRUE DARWIN_FALSE CRAY_XT3_TRUE CRAY_XT3_FALSE SUNOS_TRUE SUNOS_FALSE LIBSYSIO_SUBDIR SYSIO LINUX25_TRUE LINUX25_FALSE BUILD_QSWLND_TRUE BUILD_QSWLND_FALSE BUILD_GMLND_TRUE BUILD_GMLND_FALSE BUILD_MXLND_TRUE BUILD_MXLND_FALSE BUILD_O2IBLND_TRUE BUILD_O2IBLND_FALSE BUILD_OPENIBLND_TRUE BUILD_OPENIBLND_FALSE BUILD_CIBLND_TRUE BUILD_CIBLND_FALSE BUILD_IIBLND_TRUE BUILD_IIBLND_FALSE BUILD_VIBLND_TRUE BUILD_VIBLND_FALSE BUILD_RALND_TRUE BUILD_RALND_FALSE BUILD_PTLLND_TRUE BUILD_PTLLND_FALSE BUILD_UPTLLND_TRUE BUILD_UPTLLND_FALSE BUILD_USOCKLND_TRUE BUILD_USOCKLND_FALSE LIBLUSTRE_TRUE LIBLUSTRE_FALSE USE_QUILT_TRUE USE_QUILT_FALSE LIBLUSTRE_TESTS_TRUE LIBLUSTRE_TESTS_FALSE MPITESTS_TRUE MPITESTS_FALSE CLIENT_TRUE CLIENT_FALSE SERVER_TRUE SERVER_FALSE QUOTA_TRUE QUOTA_FALSE BLKID_TRUE BLKID_FALSE EXT2FS_DEVEL_TRUE EXT2FS_DEVEL_FALSE LIBPTHREAD_TRUE LIBPTHREAD_FALSE ac_configure_args MOSTLYCLEANFILES LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -886,14 +886,16 @@ Optional Features:
                           disable liblustre recovery support
   --enable-health-write   enable disk writes when doing health check
   --enable-lru-resize     enable lru resize support
-  --enable-adaptive-timeouts
-                          enable ptlrpc adaptive timeouts support
+  --disable-adaptive-timeouts
+                          disable ptlrpc adaptive timeouts support
+  --enable-delayed-recovery
+                          enable late recovery after main one
   --enable-dmu            enable the DMU backend
   --disable-liblustre     disable building of Lustre library
   --enable-liblustre-tests
                           enable liblustre tests, if --disable-tests is used
   --disable-liblustre-acl disable ACL support for liblustre
-  --enable-mpitest=yes|no|mpich directory
+  --enable-mpitests=yes|no|mpicc wrapper
                           include mpi tests
   --disable-readline      disable readline support
   --enable-efence         use efence library
@@ -919,6 +921,7 @@ Optional Packages:
   --with-kernel-source-header=path
                           Use a different kernel version header. Consult
                           build/README.kernel-source for details.
+  --with-o2ib=path        build o2iblnd against path
   --with-qsnet=path       set path to qsnet source (default=$LINUX)
   --with-gm=path-to-gm-source-tree
                           build gmlnd against path
@@ -928,7 +931,6 @@ Optional Packages:
   --with-cib=path         build ciblnd against path
   --with-vib=path         build viblnd against path
   --with-iib=path         build iiblnd against path
-  --with-o2ib=path        build o2iblnd against path
   --with-portals=path     set path to portals
   --with-mx=path          build mxlnd against path
   --with-sysio=path       set path to libsysio source (default is included
@@ -938,6 +940,7 @@ Optional Packages:
   --with-lustre-iokit=path
                           set path to lustre-iokit source (default is included
                           lustre-iokit)
+  --with-ldiskfsprogs     use alternate names for ldiskfs-enabled e2fsprogs
   --with-max-payload-mb=MBytes
                           set maximum lnet payload in MBytes
   --with-obd-buffer-size=size
@@ -1422,17 +1425,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 AC_LUSTRE_MAJOR=1
-AC_LUSTRE_MINOR=6
-AC_LUSTRE_PATCH=7
-AC_LUSTRE_FIX=2
-AC_LUSTRE_VERSION_STRING=1.6.7.2
+AC_LUSTRE_MINOR=8
+AC_LUSTRE_PATCH=1
+AC_LUSTRE_FIX=0
+AC_LUSTRE_VERSION_STRING=1.8.1
 AC_LUSTRE_VER_ALLOWED_OFFSET="OBD_OCD_VERSION(0,0,1,32)"
 AC_LUSTRE_LIB_VER_OFFSET_WARN="OBD_OCD_VERSION(0,0,1,32)"
 AC_LUSTRE_CLI_VER_OFFSET_WARN="OBD_OCD_VERSION(0,2,0,0)"
-AC_LUSTRE_CLIENT_URN="LUSTRE-167-CLT"
-AC_LUSTRE_MGS_URN="LUSTRE-167-MGS"
-AC_LUSTRE_MDS_URN="LUSTRE-167-MDS"
-AC_LUSTRE_OSS_URN="LUSTRE-167-OSS"
+AC_LUSTRE_CLIENT_URN="LUSTRE-181-CLT"
+AC_LUSTRE_MGS_URN="LUSTRE-181-MGS"
+AC_LUSTRE_MDS_URN="LUSTRE-181-MDS"
+AC_LUSTRE_OSS_URN="LUSTRE-181-OSS"
 
 
 
@@ -1460,7 +1463,7 @@ else
 fi
 
 
-if test "1.6.7.2" = "LUSTRE""_VERSION" ; then
+if test "1.8.1" = "LUSTRE""_VERSION" ; then
 	{ { echo "$as_me:$LINENO: error: This script was not built with a version number." >&5
 echo "$as_me: error: This script was not built with a version number." >&2;}
    { (exit 1); exit 1; }; }
@@ -1828,7 +1831,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='lustre'
- VERSION='1.6.7.2'
+ VERSION='1.8.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -4193,7 +4196,7 @@ echo "$as_me: WARNING: set compiler with -m64" >&2;}
 	CC="$CC -m64"
 fi
 
-CPPFLAGS="-I\$(top_builddir)/$LIBCFS_INCLUDE_DIR -I\$(top_srcdir)/$LIBCFS_INCLUDE_DIR-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
+CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
 
 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
 
@@ -4629,7 +4632,15 @@ echo $ECHO_N "checking for Linux sources... $ECHO_C" >&6
 # Check whether --with-linux or --without-linux was given.
 if test "${with_linux+set}" = set; then
   withval="$with_linux"
-  LINUX=$with_linux
+
+		if ! [[ $with_linux = /* ]]; then
+			{ { echo "$as_me:$LINENO: error: You must provide an absolute pathname to the --with-linux= option." >&5
+echo "$as_me: error: You must provide an absolute pathname to the --with-linux= option." >&2;}
+   { (exit 1); exit 1; }; }
+		else
+			LINUX=$with_linux
+		fi
+
 else
   LINUX=/usr/src/linux
 fi;
@@ -4773,17 +4784,13 @@ fi
 echo "$as_me:$LINENO: result: `eval echo '${'$as_lb_File'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_lb_File'}'`" >&6
 if test `eval echo '${'$as_lb_File'}'` = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$LINUX_OBJ/include/linux/autoconf.h" | $as_tr_cpp` 1
-_ACEOF
-
-
+  :
 else
   { { echo "$as_me:$LINENO: error: Run make config in $LINUX." >&5
 echo "$as_me: error: Run make config in $LINUX." >&2;}
    { (exit 1); exit 1; }; }
 fi
+
 as_lb_File=`echo "lb_cv_file_$LINUX_OBJ/include/linux/version.h" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $LINUX_OBJ/include/linux/version.h" >&5
 echo $ECHO_N "checking for $LINUX_OBJ/include/linux/version.h... $ECHO_C" >&6
@@ -4799,12 +4806,7 @@ fi
 echo "$as_me:$LINENO: result: `eval echo '${'$as_lb_File'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_lb_File'}'`" >&6
 if test `eval echo '${'$as_lb_File'}'` = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$LINUX_OBJ/include/linux/version.h" | $as_tr_cpp` 1
-_ACEOF
-
-
+  :
 else
   { { echo "$as_me:$LINENO: error: Run make config in $LINUX." >&5
 echo "$as_me: error: Run make config in $LINUX." >&2;}
@@ -4869,8 +4871,8 @@ if test -e $LINUX/include/asm-um ; then
 		echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
     	else
-		echo "$as_me:$LINENO: result: no (asm doesn't point at asm-um)" >&5
-echo "${ECHO_T}no (asm doesn't point at asm-um)" >&6
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 	fi
 else
 	echo "$as_me:$LINENO: result: no (asm-um missing)" >&5
@@ -5171,7 +5173,7 @@ int
 main (void)
 {
 
-		#ifndef RHEL_MAJOR
+		#ifndef RHEL_RELEASE_CODE
 		#error "not redhat kernel"
 		#endif
 
@@ -5194,6 +5196,7 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   (exit $ac_status); }; }; then
 
 		RHEL_KENEL="yes"
+		RHEL_KERNEL="yes"
 		echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
@@ -5202,14 +5205,14 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-		echo "$as_me:$LINENO: result: no" >&5
+	        echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-echo "$as_me:$LINENO: checking that SuSe kernel" >&5
-echo $ECHO_N "checking that SuSe kernel... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with CONFIG_SUSE_KERNEL" >&5
+echo $ECHO_N "checking if Linux was built with CONFIG_SUSE_KERNEL... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -5217,15 +5220,15 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-		#include <linux/version.h>
+#include <linux/autoconf.h>
 
 int
 main (void)
 {
 
-		#ifndef SLE_VERSION_CODE
-		#error "not sles kernel"
-		#endif
+#ifndef CONFIG_SUSE_KERNEL
+#error CONFIG_SUSE_KERNEL not #defined
+#endif
 
   ;
   return 0;
@@ -5245,28 +5248,30 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-		SUSE_KERNEL="yes"
-		echo "$as_me:$LINENO: result: yes" >&5
+echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
+SUSE_KERNEL="yes"
 
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-		echo "$as_me:$LINENO: result: no" >&5
+echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 
+
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
 
 
+
 echo "$as_me:$LINENO: checking Linux kernel architecture" >&5
 echo $ECHO_N "checking Linux kernel architecture... $ECHO_C" >&6
           if rm -f $PWD/build/arch
                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
-                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX_OBJ $ARCH_UM \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`; then
   echo "$as_me:$LINENO: result: $LINUX_ARCH" >&5
 echo "${ECHO_T}$LINUX_ARCH" >&6
@@ -5289,11 +5294,6 @@ echo "${ECHO_T}$SYMVERFILE" >&6
 
 
 
-#if test $LINUX_ARCH == "powerpc64"; then
-#	AC_MSG_WARN([set compiler with -m64])
-#	CFLAGS="$CFLAGS -m64"
-#	CC="$CC -m64"
-#fi
 
 echo "$as_me:$LINENO: checking if Linux was built with CONFIG_MODULES" >&5
 echo $ECHO_N "checking if Linux was built with CONFIG_MODULES... $ECHO_C" >&6
@@ -5407,64 +5407,6 @@ fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
 
-echo "$as_me:$LINENO: checking if Linux was built with CONFIG_PREEMPT" >&5
-echo $ECHO_N "checking if Linux was built with CONFIG_PREEMPT... $ECHO_C" >&6
-cat >conftest.c <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-#include <linux/autoconf.h>
-
-int
-main (void)
-{
-
-#ifndef CONFIG_PREEMPT
-#error CONFIG_PREEMPT not #defined
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-
-rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
-if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-	{ { echo "$as_me:$LINENO: error: Lustre does not support kernels with preempt enabled." >&5
-echo "$as_me: error: Lustre does not support kernels with preempt enabled." >&2;}
-   { (exit 1); exit 1; }; }
-
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-
-fi
-rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
-
-
 echo "$as_me:$LINENO: checking if Linux was built with CONFIG_KALLSYMS" >&5
 echo $ECHO_N "checking if Linux was built with CONFIG_KALLSYMS... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
@@ -5588,6 +5530,81 @@ rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.
 
 #LB_LINUX_CONFIG_BIG_STACK
 
+# it's ugly to be doing anything with OFED outside of the lnet module, but
+# this has to be done here so that the backports path is set before all of
+# the LN_PROG_LINUX checks are done
+echo "$as_me:$LINENO: checking whether to use any OFED backport headers" >&5
+echo $ECHO_N "checking whether to use any OFED backport headers... $ECHO_C" >&6
+# set default
+
+# Check whether --with-o2ib or --without-o2ib was given.
+if test "${with_o2ib+set}" = set; then
+  withval="$with_o2ib"
+
+		case $with_o2ib in
+		yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+			ENABLEO2IB=2
+			;;
+		no)     ENABLEO2IB=0
+			;;
+		*)      O2IBPATHS=$with_o2ib
+			ENABLEO2IB=3
+			;;
+		esac
+
+else
+
+		O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+		ENABLEO2IB=1
+
+fi;
+if test $ENABLEO2IB -eq 0; then
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+else
+	o2ib_found=false
+	for O2IBPATH in $O2IBPATHS; do
+		if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+			o2ib_found=true
+			break
+		fi
+	done
+	if ! $o2ib_found; then
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+		case $ENABLEO2IB in
+			1) ;;
+			2) { { echo "$as_me:$LINENO: error: kernel OpenIB gen2 headers not present" >&5
+echo "$as_me: error: kernel OpenIB gen2 headers not present" >&2;}
+   { (exit 1); exit 1; }; };;
+			3) { { echo "$as_me:$LINENO: error: bad --with-o2ib path" >&5
+echo "$as_me: error: bad --with-o2ib path" >&2;}
+   { (exit 1); exit 1; }; };;
+			*) { { echo "$as_me:$LINENO: error: internal error" >&5
+echo "$as_me: error: internal error" >&2;}
+   { (exit 1); exit 1; }; };;
+		esac
+	else
+                if test -f $O2IBPATH/config.mk; then
+			. $O2IBPATH/config.mk
+                elif test -f $O2IBPATH/ofed_patch.mk; then
+			. $O2IBPATH/ofed_patch.mk
+		fi
+		if test -n "$BACKPORT_INCLUDES"; then
+			OFED_BACKPORT_PATH=`echo $BACKPORT_INCLUDES | sed "s#.*/src/ofa_kernel/#$O2IBPATH/#"`
+			EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
+			echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+		else
+			echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+                fi
+	fi
+fi
+
 
 
 
@@ -6825,7 +6842,8 @@ echo "$as_me: error: internal error" >&2;}
 		O2IBCPPFLAGS="-I$O2IBPATH/include"
 		EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
 		EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
-		EXTRA_LNET_INCLUDE="$O2IBCPPFLAGS $EXTRA_LNET_INCLUDE"
+		EXTRA_LNET_INCLUDE="$EXTRA_LNET_INCLUDE $O2IBCPPFLAGS"
+
 		cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -6913,12 +6931,17 @@ rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.
 					break;
 				fi
 			done
-			if test -n $O2IB_SYMVER ; then
+			if test -n "$O2IB_SYMVER"; then
 				{ echo "$as_me:$LINENO: adding $O2IBPATH/Module.symvers to $PWD/$SYMVERFILE" >&5
 echo "$as_me: adding $O2IBPATH/Module.symvers to $PWD/$SYMVERFILE" >&6;}
 				# strip out the existing symbols versions first
-				egrep -v $(echo $(awk '{ print  }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
+				if test -f $PWD/$SYMVERFILE; then
+				    egrep -v $(echo $(awk '{ print  }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
+				else
+				    touch $PWD/$SYMVERFILE.old
+				fi
 				cat $PWD/$SYMVERFILE.old $O2IBPATH/$O2IB_SYMVER > $PWD/$SYMVERFILE
+				rm $PWD/$SYMVERFILE.old
 			else
 				{ { echo "$as_me:$LINENO: error: an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there" >&5
 echo "$as_me: error: an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there" >&2;}
@@ -6926,26 +6949,29 @@ echo "$as_me: error: an external source tree was specified for o2iblnd however I
 			fi
 		fi
 
-		cat >conftest.c <<_ACEOF
+
+	echo "$as_me:$LINENO: checking if OFED has ib_dma_map_single" >&5
+echo $ECHO_N "checking if OFED has ib_dma_map_single... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-			#include <linux/version.h>
-			#include <linux/pci.h>
-			#if !HAVE_GFP_T
-			typedef int gfp_t;
-			#endif
-			#include <rdma/ib_verbs.h>
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
 
 int
 main (void)
 {
 
-			ib_dma_map_single(NULL, NULL, 0, 0);
-			return 0;
+		ib_dma_map_single(NULL, NULL, 0, 0);
+		return 0;
 
   ;
   return 0;
@@ -6965,7 +6991,7 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-			echo "$as_me:$LINENO: result: yes" >&5
+		echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
 cat >>confdefs.h <<\_ACEOF
@@ -6978,32 +7004,34 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-			echo "$as_me:$LINENO: result: NO" >&5
-echo "${ECHO_T}NO" >&6
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-		cat >conftest.c <<_ACEOF
+	echo "$as_me:$LINENO: checking if ib_create_cq wants comp_vector" >&5
+echo $ECHO_N "checking if ib_create_cq wants comp_vector... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-			#include <linux/version.h>
-			#include <linux/pci.h>
-			#if !HAVE_GFP_T
-			typedef int gfp_t;
-			#endif
-			#include <rdma/ib_verbs.h>
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
 
 int
 main (void)
 {
 
-			ib_create_cq(NULL, NULL, NULL, NULL, 0, 0);
-			return 0;
+		ib_create_cq(NULL, NULL, NULL, NULL, 0, 0);
+		return 0;
 
   ;
   return 0;
@@ -7023,7 +7051,7 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-			echo "$as_me:$LINENO: result: yes" >&5
+		echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
 cat >>confdefs.h <<\_ACEOF
@@ -7036,8 +7064,186 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-			echo "$as_me:$LINENO: result: NO" >&5
-echo "${ECHO_T}NO" >&6
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+	echo "$as_me:$LINENO: checking if OFED supports iWarp transport" >&5
+echo $ECHO_N "checking if OFED supports iWarp transport... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
+
+int
+main (void)
+{
+
+		return RDMA_TRANSPORT_IWARP ==
+		       rdma_node_get_transport(RDMA_NODE_RNIC);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_OFED_TRANSPORT_IWARP 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+	echo "$as_me:$LINENO: checking if OFED has RDMA_CM_EVENT_ADDR_CHANGE" >&5
+echo $ECHO_N "checking if OFED has RDMA_CM_EVENT_ADDR_CHANGE... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/rdma_cm.h>
+
+int
+main (void)
+{
+
+		return (RDMA_CM_EVENT_ADDR_CHANGE == 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_OFED_RDMA_CMEV_ADDRCHANGE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+	echo "$as_me:$LINENO: checking if OFED has RDMA_CM_EVENT_TIMEWAIT_EXIT" >&5
+echo $ECHO_N "checking if OFED has RDMA_CM_EVENT_TIMEWAIT_EXIT... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/rdma_cm.h>
+
+int
+main (void)
+{
+
+		return (RDMA_CM_EVENT_TIMEWAIT_EXIT == 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_OFED_RDMA_CMEV_TIMEWAIT_EXIT 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
@@ -7410,8 +7616,8 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-echo "$as_me:$LINENO: checking if Linux was built with symbol show_task is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol show_task is exported... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with symbol show_task exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol show_task exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]show_task[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -7453,39 +7659,41 @@ _ACEOF
 fi
 
 
-echo "$as_me:$LINENO: checking __u64 is long long type" >&5
-echo $ECHO_N "checking __u64 is long long type... $ECHO_C" >&6
-tmp_flags="$CFLAGS"
-CFLAGS="$CFLAGS -Werror"
-cat >conftest.$ac_ext <<_ACEOF
+echo "$as_me:$LINENO: checking kernel __u64 is long long type" >&5
+echo $ECHO_N "checking kernel __u64 is long long type... $ECHO_C" >&6
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
 
 	#include <linux/types.h>
-	int main(void) {
-		unsigned long long *data1;
-		__u64 *data2;
+	#include <linux/stddef.h>
 
-		data1 = data2;
-		return 0;
-	}
+int
+main (void)
+{
+
+	unsigned long long *data1;
+	__u64 *data2 = NULL;
+
+	data1 = data2;
 
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -7496,7 +7704,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
 echo "${ECHO_T}yes" >&6
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_U64_LONG_LONG 1
+#define HAVE_KERN__U64_LONG_LONG 1
 _ACEOF
 
 
@@ -7509,8 +7717,8 @@ sed 's/^/| /' conftest.$ac_ext >&5
 echo "${ECHO_T}no" >&6
 
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-CFLAGS="$tmp_flags"
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+EXTRA_KCFLAGS="$tmp_flags"
 
 echo "$as_me:$LINENO: checking ssize_t is signed long type" >&5
 echo $ECHO_N "checking ssize_t is signed long type... $ECHO_C" >&6
@@ -7519,9 +7727,10 @@ CFLAGS="$CFLAGS -Werror"
 cat >conftest.$ac_ext <<_ACEOF
 
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		long *data1;
-		ssize_t *data2;
+		ssize_t *data2 = NULL;
 
 		data1 = data2;
 		return 0;
@@ -7578,9 +7787,10 @@ CFLAGS="$CFLAGS -Werror"
 cat >conftest.$ac_ext <<_ACEOF
 
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		unsigned long *data1;
-		size_t *data2;
+		size_t *data2 = NULL;
 
 		data1 = data2;
 		return 0;
@@ -7685,9 +7895,65 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
+echo "$as_me:$LINENO: checking if task_struct has a rcu field" >&5
+echo $ECHO_N "checking if task_struct has a rcu field... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+	#include <linux/sched.h>
+
+int
+main (void)
+{
+
+        struct task_struct tsk;
+
+        tsk.rcu.next = NULL;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TASK_RCU 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
 # 2.6.18
-echo "$as_me:$LINENO: checking if Linux was built with symbol tasklist_lock is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol tasklist_lock is exported... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with symbol tasklist_lock exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol tasklist_lock exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]tasklist_lock[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -8117,8 +8383,8 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-        echo "$as_me:$LINENO: result: NO" >&5
-echo "${ECHO_T}NO" >&6
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
@@ -8171,8 +8437,8 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-        echo "$as_me:$LINENO: result: NO" >&5
-echo "${ECHO_T}NO" >&6
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
@@ -8228,12 +8494,329 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-        echo "$as_me:$LINENO: result: NO" >&5
-echo "${ECHO_T}NO" >&6
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
+# 2.6.27
+echo "$as_me:$LINENO: checking sock_map_fd have second argument" >&5
+echo $ECHO_N "checking sock_map_fd have second argument... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+	#include <linux/net.h>
+
+int
+main (void)
+{
+
+        sock_map_fd(NULL, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SOCK_MAP_FD_2ARG 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+echo "$as_me:$LINENO: checking if Linux was built with symbol dump_trace exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol dump_trace exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]dump_trace[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(dump_trace\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+	tmp_flags="$EXTRA_KCFLAGS"
+	EXTRA_KCFLAGS="-Werror"
+	echo "$as_me:$LINENO: checking whether we can really use dump_stack" >&5
+echo $ECHO_N "checking whether we can really use dump_stack... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		struct task_struct;
+		struct pt_regs;
+		#include <asm/stacktrace.h>
+
+int
+main (void)
+{
+
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DUMP_TRACE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+	echo "$as_me:$LINENO: checking whether print_trace_address has reliable argument" >&5
+echo $ECHO_N "checking whether print_trace_address has reliable argument... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		struct task_struct;
+		struct pt_regs;
+		void print_addr(void *data, unsigned long addr, int reliable);
+		#include <asm/stacktrace.h>
+
+int
+main (void)
+{
+
+		struct stacktrace_ops ops;
+
+		ops.address = print_addr;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TRACE_ADDRESS_RELIABLE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+EXTRA_KCFLAGS="$tmp_flags"
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+	tmp_flags="$EXTRA_KCFLAGS"
+	EXTRA_KCFLAGS="-Werror"
+	echo "$as_me:$LINENO: checking whether we can really use dump_stack" >&5
+echo $ECHO_N "checking whether we can really use dump_stack... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		struct task_struct;
+		struct pt_regs;
+		#include <asm/stacktrace.h>
+
+int
+main (void)
+{
+
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DUMP_TRACE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+	echo "$as_me:$LINENO: checking whether print_trace_address has reliable argument" >&5
+echo $ECHO_N "checking whether print_trace_address has reliable argument... $ECHO_C" >&6
+	cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+		struct task_struct;
+		struct pt_regs;
+		void print_addr(void *data, unsigned long addr, int reliable);
+		#include <asm/stacktrace.h>
+
+int
+main (void)
+{
+
+		struct stacktrace_ops ops;
+
+		ops.address = print_addr;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TRACE_ADDRESS_RELIABLE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+EXTRA_KCFLAGS="$tmp_flags"
+
+fi
+
+
 
 			as_lb_File=`echo "lb_cv_file_$LINUX/include/linux/lustre_version.h" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $LINUX/include/linux/lustre_version.h" >&5
@@ -8268,6 +8851,22 @@ echo "$as_me: WARNING: disabling server build" >&2;}
 
 fi
 
+	if test x$enable_server = xyes ; then
+		if test x$RHEL_KERNEL = xyes -a x$LINUXRELEASE != x${LINUXRELEASE##2.6.9} ; then
+        		{ echo "$as_me:$LINENO: WARNING: Lustre server has been disabled with rhel4 kernel;" >&5
+echo "$as_me: WARNING: Lustre server has been disabled with rhel4 kernel;" >&2;}
+        		{ echo "$as_me:$LINENO: WARNING: disabling server build" >&5
+echo "$as_me: WARNING: disabling server build" >&2;}
+        		enable_server='no'
+		fi
+		if test x$SUSE_KERNEL = xyes -a x$LINUXRELEASE != x${LINUXRELEASE##2.6.5} ; then
+        		{ echo "$as_me:$LINENO: WARNING: Lustre server has been disabled with sles9 kernel;" >&5
+echo "$as_me: WARNING: Lustre server has been disabled with sles9 kernel;" >&2;}
+        		{ echo "$as_me:$LINENO: WARNING: disabling server build" >&5
+echo "$as_me: WARNING: disabling server build" >&2;}
+			enable_server='no'
+		fi
+	fi
 
           if test x$enable_server = xyes ; then
 
@@ -8276,7 +8875,7 @@ BACKINGFS="ldiskfs"
 if test x$with_ldiskfs = xno ; then
 	BACKINGFS="ext3"
 
-	if test x$linux25$enable_server = xyesyes ; then
+	if test x$enable_server = xyes ; then
 		{ { echo "$as_me:$LINENO: error: ldiskfs is required for 2.6-based servers." >&5
 echo "$as_me: error: ldiskfs is required for 2.6-based servers." >&2;}
    { (exit 1); exit 1; }; }
@@ -8477,6 +9076,27 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFSDEV_FS_POSIX_ACL 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFSDEV_FS_XATTR 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFSDEV_FS_SECURITY 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFS_FS_NFS4ACL 1
+_ACEOF
+
+
+
 fi #ldiskfs
 
 echo "$as_me:$LINENO: checking which backing filesystem to use" >&5
@@ -8485,6 +9105,58 @@ echo "$as_me:$LINENO: result: $BACKINGFS" >&5
 echo "${ECHO_T}$BACKINGFS" >&6
 
 
+              echo "$as_me:$LINENO: checking stack size big than 8k" >&5
+echo $ECHO_N "checking stack size big than 8k... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+	#include <linux/thread_info.h>
+
+int
+main (void)
+{
+
+        #if THREAD_SIZE < 8192
+        #error "stack size < 8192"
+        #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        { { echo "$as_me:$LINENO: error: Lustre requires that Linux is configured with at least a 8KB stack." >&5
+echo "$as_me: error: Lustre requires that Linux is configured with at least a 8KB stack." >&2;}
+   { (exit 1); exit 1; }; }
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
           fi
           echo "$as_me:$LINENO: checking whether to enable pinger support" >&5
 echo $ECHO_N "checking whether to enable pinger support... $ECHO_C" >&6
@@ -8588,7 +9260,7 @@ if test "${enable_adaptive_timeouts+set}" = set; then
   enableval="$enable_adaptive_timeouts"
 
 else
-  enable_adaptive_timeouts='no'
+  enable_adaptive_timeouts='yes'
 fi;
 echo "$as_me:$LINENO: result: $enable_adaptive_timeouts" >&5
 echo "${ECHO_T}$enable_adaptive_timeouts" >&6
@@ -8600,6 +9272,25 @@ _ACEOF
 
 fi
 
+          echo "$as_me:$LINENO: checking whether to enable delayed recovery support" >&5
+echo $ECHO_N "checking whether to enable delayed recovery support... $ECHO_C" >&6
+# Check whether --enable-delayed-recovery or --disable-delayed-recovery was given.
+if test "${enable_delayed_recovery+set}" = set; then
+  enableval="$enable_delayed_recovery"
+
+else
+  enable_delayed_recovery='no'
+fi;
+echo "$as_me:$LINENO: result: $enable_delayed_recovery" >&5
+echo "${ECHO_T}$enable_delayed_recovery" >&6
+if test x$enable_delayed_recovery == xyes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_DELAYED_RECOVERY 1
+_ACEOF
+
+fi
+
           if test x$enable_quota != xno; then
     echo "$as_me:$LINENO: checking if Linux was built with CONFIG_QUOTA" >&5
 echo $ECHO_N "checking if Linux was built with CONFIG_QUOTA... $ECHO_C" >&6
@@ -8725,8 +9416,8 @@ fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
           # RHEL4 patches
-          echo "$as_me:$LINENO: checking if Linux was built with symbol truncate_complete_page is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol truncate_complete_page is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol truncate_complete_page exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol truncate_complete_page exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]truncate_complete_page[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -8768,8 +9459,51 @@ _ACEOF
 fi
 
 
-          echo "$as_me:$LINENO: checking if Linux was built with symbol d_rehash_cond is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol d_rehash_cond is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol truncate_inode_pages_range exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol truncate_inode_pages_range exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]truncate_inode_pages_range[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in mm/truncate.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(truncate_inode_pages_range\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TRUNCATE_RANGE 1
+_ACEOF
+
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TRUNCATE_RANGE 1
+_ACEOF
+
+
+fi
+
+
+          echo "$as_me:$LINENO: checking if Linux was built with symbol d_rehash_cond exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol d_rehash_cond exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]d_rehash_cond[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -8811,8 +9545,8 @@ _ACEOF
 fi
 
 
-          echo "$as_me:$LINENO: checking if Linux was built with symbol __d_rehash is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol __d_rehash is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol __d_rehash exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol __d_rehash exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]__d_rehash[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -8854,8 +9588,8 @@ _ACEOF
 fi
 
 
-          echo "$as_me:$LINENO: checking if Linux was built with symbol d_move_locked is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol d_move_locked is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol d_move_locked exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol d_move_locked exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]d_move_locked[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -8897,8 +9631,8 @@ _ACEOF
 fi
 
 
-          echo "$as_me:$LINENO: checking if Linux was built with symbol __d_move is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol __d_move is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol __d_move exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol __d_move exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]__d_move[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -8940,8 +9674,8 @@ _ACEOF
 fi
 
 
-          echo "$as_me:$LINENO: checking if Linux was built with symbol node_to_cpumask is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol node_to_cpumask is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol node_to_cpumask exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol node_to_cpumask exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]node_to_cpumask[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -8977,8 +9711,8 @@ _ACEOF
 
 fi
  # x86_64
-          echo "$as_me:$LINENO: checking if Linux was built with symbol node_to_cpu_mask is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol node_to_cpu_mask is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol node_to_cpu_mask exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol node_to_cpu_mask exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]node_to_cpu_mask[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -9014,8 +9748,8 @@ _ACEOF
 
 fi
  # ia64
-          echo "$as_me:$LINENO: checking if Linux was built with symbol node_2_cpu_mask is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol node_2_cpu_mask is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol node_2_cpu_mask exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol node_2_cpu_mask exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]node_2_cpu_mask[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -9053,8 +9787,24 @@ fi
  # i386
 
 
-          echo "$as_me:$LINENO: checking if struct kiobuf has a dovary field" >&5
-echo $ECHO_N "checking if struct kiobuf has a dovary field... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if releasepage has a gfp_t parameter" >&5
+echo $ECHO_N "checking if releasepage has a gfp_t parameter... $ECHO_C" >&6
+RELEASEPAGE_WITH_GFP="`grep -c 'releasepage.*gfp_t' $LINUX/include/linux/fs.h`"
+if test "$RELEASEPAGE_WITH_GFP" != 0 ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RELEASEPAGE_WITH_GFP 1
+_ACEOF
+
+	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+          echo "$as_me:$LINENO: checking if kernel has mm_inline.h header" >&5
+echo $ECHO_N "checking if kernel has mm_inline.h header... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -9062,14 +9812,15 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-	#include <linux/iobuf.h>
+	#include <linux/mm_inline.h>
 
 int
 main (void)
 {
 
-	struct kiobuf iobuf;
-	iobuf.dovary = 1;
+	#ifndef page_count
+	#error mm_inline.h does not define page_count
+	#endif
 
   ;
   return 0;
@@ -9093,7 +9844,7 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
 echo "${ECHO_T}yes" >&6
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_KIOBUF_DOVARY 1
+#define HAVE_MM_INLINE 1
 _ACEOF
 
 
@@ -9108,8 +9859,8 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-          echo "$as_me:$LINENO: checking if kernel offers cond_resched" >&5
-echo $ECHO_N "checking if kernel offers cond_resched... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if struct inode has i_alloc_sem" >&5
+echo $ECHO_N "checking if struct inode has i_alloc_sem... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -9117,13 +9868,15 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-	#include <linux/sched.h>
+	#include <linux/fs.h>
+	#include <linux/version.h>
 
 int
 main (void)
 {
 
-	cond_resched();
+	struct inode i;
+	return (char *)&i.i_alloc_sem - (char *)&i;
 
   ;
   return 0;
@@ -9147,7 +9900,7 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
 echo "${ECHO_T}yes" >&6
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_COND_RESCHED 1
+#define HAVE_I_ALLOC_SEM 1
 _ACEOF
 
 
@@ -9162,56 +9915,8 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-          echo "$as_me:$LINENO: checking if zap_page_range with vma parameter" >&5
-echo $ECHO_N "checking if zap_page_range with vma parameter... $ECHO_C" >&6
-ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
-if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define ZAP_PAGE_RANGE_VMA 1
-_ACEOF
-
-	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-	echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-          echo "$as_me:$LINENO: checking if kernel defines PDE" >&5
-echo $ECHO_N "checking if kernel defines PDE... $ECHO_C" >&6
-HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
-if test "$HAVE_PDE" != 0 ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_PDE 1
-_ACEOF
-
-	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-	echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-          echo "$as_me:$LINENO: checking if kernel passes struct file to direct_IO" >&5
-echo $ECHO_N "checking if kernel passes struct file to direct_IO... $ECHO_C" >&6
-HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
-if test "$HAVE_DIO_FILE" != 0 ; then
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_DIO_FILE 1
-_ACEOF
-
-	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-else
-	echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-          echo "$as_me:$LINENO: checking if kernel has mm_inline.h header" >&5
-echo $ECHO_N "checking if kernel has mm_inline.h header... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if kernel defines cache pressure hook" >&5
+echo $ECHO_N "checking if kernel defines cache pressure hook... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -9219,15 +9924,15 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-	#include <linux/mm_inline.h>
+	#include <linux/mm.h>
 
 int
 main (void)
 {
 
-	#ifndef page_count
-	#error mm_inline.h does not define page_count
-	#endif
+	shrinker_t shrinker;
+
+	set_shrinker(1, shrinker);
 
   ;
   return 0;
@@ -9247,11 +9952,16 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+	echo "$as_me:$LINENO: result: set_shrinker" >&5
+echo "${ECHO_T}set_shrinker" >&6
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_MM_INLINE 1
+#define HAVE_SHRINKER_CACHE 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_CACHE_RETURN_INT 1
 _ACEOF
 
 
@@ -9260,30 +9970,21 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-	echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-fi
-rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
-
-          echo "$as_me:$LINENO: checking if struct inode has i_alloc_sem" >&5
-echo $ECHO_N "checking if struct inode has i_alloc_sem... $ECHO_C" >&6
-cat >conftest.c <<_ACEOF
+	cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-	#include <linux/fs.h>
-	#include <linux/version.h>
+		#include <linux/list.h>
+		#include <linux/cache_def.h>
 
 int
 main (void)
 {
 
-	struct inode i;
-	return (char *)&i.i_alloc_sem - (char *)&i;
+		struct cache_definition cache;
 
   ;
   return 0;
@@ -9303,42 +10004,33 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+		echo "$as_me:$LINENO: result: register_cache" >&5
+echo "${ECHO_T}register_cache" >&6
 
 cat >>confdefs.h <<\_ACEOF
-#define HAVE_I_ALLOC_SEM 1
+#define HAVE_REGISTER_CACHE 1
 _ACEOF
 
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-	echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-fi
-rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
-
-          echo "$as_me:$LINENO: checking if kernel defines register_cache()" >&5
-echo $ECHO_N "checking if kernel defines register_cache()... $ECHO_C" >&6
-cat >conftest.c <<_ACEOF
+		echo "$as_me:$LINENO: checking if kernel expects return from cache shrink " >&5
+echo $ECHO_N "checking if kernel expects return from cache shrink ... $ECHO_C" >&6
+		tmp_flags="$EXTRA_KCFLAGS"
+		EXTRA_KCFLAGS="-Werror"
+		cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-	#include <linux/list.h>
-	#include <linux/cache_def.h>
+			#include <linux/list.h>
+			#include <linux/cache_def.h>
 
 int
 main (void)
 {
 
-	struct cache_definition cache;
+			struct cache_definition c;
+			c.shrinker = (int (*)(int, unsigned int))1;
 
   ;
   return 0;
@@ -9358,40 +10050,40 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_REGISTER_CACHE 1
-_ACEOF
-
-	echo "$as_me:$LINENO: checking if kernel expects return from cache shrink function" >&5
-echo $ECHO_N "checking if kernel expects return from cache shrink function... $ECHO_C" >&6
-	HAVE_CACHE_RETURN_INT="`grep -c 'int.*shrink' $LINUX/include/linux/cache_def.h`"
-	if test "$HAVE_CACHE_RETURN_INT" != 0 ; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_CACHE_RETURN_INT 1
 _ACEOF
 
-		echo "$as_me:$LINENO: result: yes" >&5
+			echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
-	else
-		echo "$as_me:$LINENO: result: no" >&5
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+			echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
-	fi
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+		EXTRA_KCFLAGS="$tmp_flags"
 
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-	echo "$as_me:$LINENO: result: no" >&5
+		echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
           echo "$as_me:$LINENO: checking if kernel defines grab_cache_page_nowait_gfp()" >&5
 echo $ECHO_N "checking if kernel defines grab_cache_page_nowait_gfp()... $ECHO_C" >&6
 HAVE_GCPN_GFP="`grep -c 'grab_cache_page_nowait_gfp' $LINUX/include/linux/pagemap.h`"
@@ -10071,8 +10763,8 @@ echo "${ECHO_T}no" >&6
 fi
 
 
-          echo "$as_me:$LINENO: checking if Linux was built with symbol __iget is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol __iget is exported... $ECHO_C" >&6
+          echo "$as_me:$LINENO: checking if Linux was built with symbol __iget exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol __iget exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]__iget[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -10114,49 +10806,6 @@ _ACEOF
 fi
 
 
-          echo "$as_me:$LINENO: checking if Linux was built with symbol set_fs_pwd is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol set_fs_pwd is exported... $ECHO_C" >&6
-grep -q -E '[[:space:]]set_fs_pwd[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
-rc=$?
-if test $rc -ne 0; then
-    export=0
-    for file in fs/namespace.c; do
-    	grep -q -E "EXPORT_SYMBOL.*\(set_fs_pwd\)" "$LINUX/$file" 2>/dev/null
-    	rc=$?
-	if test $rc -eq 0; then
-		export=1
-		break;
-	fi
-    done
-    if test $export -eq 0; then
-    	echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-
-    else
-    	echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SET_FS_PWD 1
-_ACEOF
-
-
-    fi
-else
-    echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_SET_FS_PWD 1
-_ACEOF
-
-
-fi
-
-
           echo "$as_me:$LINENO: checking if kernel has MS_FLOCK_LOCK sb flag" >&5
 echo $ECHO_N "checking if kernel has MS_FLOCK_LOCK sb flag... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
@@ -10532,6 +11181,7 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
+
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -10543,7 +11193,115 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-          echo "$as_me:$LINENO: checking if kernel has 64-bit quota limits support" >&5
+          echo "$as_me:$LINENO: checking if have struct percpu_counter defined" >&5
+echo $ECHO_N "checking if have struct percpu_counter defined... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/percpu_counter.h>
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PERCPU_COUNTER 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+        echo "$as_me:$LINENO: checking if percpu_counter_inc takes the 2nd argument" >&5
+echo $ECHO_N "checking if percpu_counter_inc takes the 2nd argument... $ECHO_C" >&6
+        cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+                #include <linux/percpu_counter.h>
+
+int
+main (void)
+{
+
+                struct percpu_counter c;
+                percpu_counter_init(&c, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PERCPU_2ND_ARG 1
+_ACEOF
+
+                echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+                echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          if test x$enable_server = xyes ; then
+echo "$as_me:$LINENO: checking if kernel has 64-bit quota limits support" >&5
 echo $ECHO_N "checking if kernel has 64-bit quota limits support... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
@@ -10588,18 +11346,130 @@ _ACEOF
         echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        tmp_flags="$EXTRA_KCFLAGS"
+        EXTRA_KCFLAGS="-I $LINUX/fs"
+        cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+                #include <linux/kernel.h>
+                #include <linux/fs.h>
+                #include <quotaio_v2.h>
+                struct v2r1_disk_dqblk dqblk_r1;
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_QUOTA64 1
+_ACEOF
+
+                echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
 
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-        { echo "$as_me:$LINENO: WARNING: 4 TB (or larger) block quota limits can only be used with OSTs not larger than 4 TB." >&5
+                echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+                { echo "$as_me:$LINENO: WARNING: 4 TB (or larger) block quota limits can only be used with OSTs not larger than 4 TB." >&5
 echo "$as_me: WARNING: 4 TB (or larger) block quota limits can only be used with OSTs not larger than 4 TB." >&2;}
-        { echo "$as_me:$LINENO: WARNING: Continuing with limited quota support." >&5
+                { echo "$as_me:$LINENO: WARNING: Continuing with limited quota support." >&5
 echo "$as_me: WARNING: Continuing with limited quota support." >&2;}
-        { echo "$as_me:$LINENO: WARNING: quotacheck is needed for filesystems with recent quota versions." >&5
+                { echo "$as_me:$LINENO: WARNING: quotacheck is needed for filesystems with recent quota versions." >&5
 echo "$as_me: WARNING: quotacheck is needed for filesystems with recent quota versions." >&2;}
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+        EXTRA_KCFLAGS=$tmp_flags
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+fi
+
+          echo "$as_me:$LINENO: checking if vfs_symlink wants 4 args" >&5
+echo $ECHO_N "checking if vfs_symlink wants 4 args... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+	#include <linux/fs.h>
+
+int
+main (void)
+{
+
+	struct inode *dir;
+	struct dentry *dentry;
+	const char *oldname = NULL;
+	int mode = 0;
+
+	vfs_symlink(dir, dentry, oldname, mode);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_4ARGS_VFS_SYMLINK 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
         echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 
@@ -10670,6 +11540,155 @@ fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
 
+	  # 2.6.5 sles9
+	  echo "$as_me:$LINENO: checking if Linux was built with symbol sysctl_vfs_cache_pressure exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol sysctl_vfs_cache_pressure exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]sysctl_vfs_cache_pressure[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in fs/dcache.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(sysctl_vfs_cache_pressure\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYSCTL_VFS_CACHE_PRESSURE 1
+_ACEOF
+
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYSCTL_VFS_CACHE_PRESSURE 1
+_ACEOF
+
+
+fi
+
+
+
+          # 2.6.12
+          echo "$as_me:$LINENO: checking mapping->tree_lock is rw_lock" >&5
+echo $ECHO_N "checking mapping->tree_lock is rw_lock... $ECHO_C" >&6
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+	#include <linux/fs.h>
+
+int
+main (void)
+{
+
+	struct address_space *map = NULL;
+
+	write_lock_irq(&map->tree_lock);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RW_TREE_LOCK 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+EXTRA_KCFLAGS="$tmp_flags"
+
+          echo "$as_me:$LINENO: checking if Linux was built with symbol synchronize_rcu exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol synchronize_rcu exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]synchronize_rcu[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in kernel/rcupdate.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(synchronize_rcu\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYNCHRONIZE_RCU 1
+_ACEOF
+
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYNCHRONIZE_RCU 1
+_ACEOF
+
+
+fi
+
+
+
           # 2.6.15
           echo "$as_me:$LINENO: checking if inode has i_mutex " >&5
 echo $ECHO_N "checking if inode has i_mutex ... $ECHO_C" >&6
@@ -11134,6 +12153,189 @@ fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 EXTRA_KCFLAGS="$tmp_flags"
 
+          echo "$as_me:$LINENO: checking if inode has a i_private field" >&5
+echo $ECHO_N "checking if inode has a i_private field... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <linux/fs.h>
+
+int
+main (void)
+{
+
+	struct inode i;
+	i.i_private = NULL;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INODE_IPRIVATE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking if Linux was built with symbol filemap_fdatawrite_range exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol filemap_fdatawrite_range exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]filemap_fdatawrite_range[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in mm/filemap.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(filemap_fdatawrite_range\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FILEMAP_FDATAWRITE_RANGE 1
+_ACEOF
+
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FILEMAP_FDATAWRITE_RANGE 1
+_ACEOF
+
+
+fi
+
+
+          if test x$enable_server = xyes ; then
+                echo "$as_me:$LINENO: checking if Linux was built with symbol invalidate_mapping_pages exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol invalidate_mapping_pages exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]invalidate_mapping_pages[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in mm/truncate.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(invalidate_mapping_pages\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+    	echo "$as_me:$LINENO: checking if Linux was built with symbol invalidate_inode_pages exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol invalidate_inode_pages exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]invalidate_inode_pages[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in mm/truncate.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(invalidate_inode_pages\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+       { { echo "$as_me:$LINENO: error: no way to invalidate pages" >&5
+echo "$as_me: error: no way to invalidate pages" >&2;}
+   { (exit 1); exit 1; }; }
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INVALIDATE_INODE_PAGES 1
+_ACEOF
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INVALIDATE_INODE_PAGES 1
+_ACEOF
+
+fi
+
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INVALIDATE_MAPPING_PAGES 1
+_ACEOF
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INVALIDATE_MAPPING_PAGES 1
+_ACEOF
+
+fi
+
+
+          fi
 
           #2.6.18 + RHEL5 (fc6)
           echo "$as_me:$LINENO: checking kernel has PG_fs_misc" >&5
@@ -11202,19 +12404,24 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-        #include <linux/mm.h>
-        #include <linux/page-flags.h>
+        #include <linux/autoconf.h>
+#ifdef HAVE_LINUX_MMTYPES_H
+        #include <linux/mm_types.h>
+#endif
+	#include <linux/page-flags.h>
 
 int
 main (void)
 {
 
+ 	struct page *p;
+
+        /* before 2.6.26 this define*/
         #ifndef PageChecked
-        #error PageChecked not defined in kernel
-        #endif
-        #ifndef SetPageChecked
-        #error SetPageChecked not defined in kernel
-        #endif
+ 	/* 2.6.26 use function instead of define for it */
+ 	SetPageChecked(p);
+ 	PageChecked(p);
+ 	#endif
 
   ;
   return 0;
@@ -11375,6 +12582,60 @@ fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 EXTRA_KCFLAGS="$tmp_flags"
 
+          echo "$as_me:$LINENO: checking if file_update_time is exported" >&5
+echo $ECHO_N "checking if file_update_time is exported... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/fs.h>
+
+int
+main (void)
+{
+
+        file_update_time(NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FILE_UPDATE_TIME 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+       echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
           echo "$as_me:$LINENO: checking writev in fops" >&5
 echo $ECHO_N "checking writev in fops... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
@@ -11503,6 +12764,10 @@ int
 main (void)
 {
 
+        /* tmp workaround for broken OFED 1.4.1 at SLES10 */
+        #if defined(CONFIG_SLE_VERSION) && CONFIG_SLE_VERSION == 10 && defined(_BACKPORT_LINUX_MM_H_)
+        #error badly implementation of cancel_dirty_pages
+        #endif
         cancel_dirty_page(NULL, 0);
 
   ;
@@ -11602,7 +12867,7 @@ fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
 
-	  # 2.6.22
+          # 2.6.22
           echo "$as_me:$LINENO: checking if invalidate_bdev has second argument" >&5
 echo $ECHO_N "checking if invalidate_bdev has second argument... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
@@ -11766,6 +13031,62 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
+          echo "$as_me:$LINENO: checking if kernel has .sendfile" >&5
+echo $ECHO_N "checking if kernel has .sendfile... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/fs.h>
+
+int
+main (void)
+{
+
+        struct file_operations file;
+
+        file.sendfile = NULL;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_KERNEL_SENDFILE 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
           echo "$as_me:$LINENO: checking if kernel has .splice_read" >&5
 echo $ECHO_N "checking if kernel has .splice_read... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
@@ -11822,160 +13143,1263 @@ echo "${ECHO_T}no" >&6
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
+          as_lb_File=`echo "lb_cv_file_$LINUX/include/linux/exportfs.h" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $LINUX/include/linux/exportfs.h" >&5
+echo $ECHO_N "checking for $LINUX/include/linux/exportfs.h... $ECHO_C" >&6
+if eval "test \"\${$as_lb_File+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -r "$LINUX/include/linux/exportfs.h"; then
+  eval "$as_lb_File=yes"
+else
+  eval "$as_lb_File=no"
+fi
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_lb_File'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_lb_File'}'`" >&6
+if test `eval echo '${'$as_lb_File'}'` = yes; then
 
-tmpfl="$CFLAGS"
-CFLAGS="$CFLAGS -I$LINUX_OBJ/include"
 
-for ac_header in linux/exportfs.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LINUX_EXPORTFS_H 1
+_ACEOF
+
+
+else
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+
+
+          echo "$as_me:$LINENO: checking if kernel has .fault in vm_operation_struct" >&5
+echo $ECHO_N "checking if kernel has .fault in vm_operation_struct... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/mm.h>
+
+int
+main (void)
+{
+
+        struct vm_operations_struct op;
+
+        op.fault = NULL;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_VM_OP_FAULT 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking if kernel has register_shrinker" >&5
+echo $ECHO_N "checking if kernel has register_shrinker... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/mm.h>
+
+int
+main (void)
+{
+
+        register_shrinker(NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_REGISTER_SHRINKER 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking if kernel has pde_users member in procfs entry struct" >&5
+echo $ECHO_N "checking if kernel has pde_users member in procfs entry struct... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/proc_fs.h>
+
+int
+main (void)
+{
+
+        struct proc_dir_entry pde;
+
+        pde.pde_users   = 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PROCFS_USERS 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+
+          # 2.6.25
+          echo "$as_me:$LINENO: checking if kernel have mapping_cap_writeback_dirty" >&5
+echo $ECHO_N "checking if kernel have mapping_cap_writeback_dirty... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/backing-dev.h>
+
+int
+main (void)
+{
+
+        #ifndef mapping_cap_writeback_dirty
+        mapping_cap_writeback_dirty(NULL);
+        #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MAPPING_CAP_WRITEBACK_DIRTY 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+
+          # 2.6.24
+          as_lb_File=`echo "lb_cv_file_$LINUX/include/linux/mm_types.h" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $LINUX/include/linux/mm_types.h" >&5
+echo $ECHO_N "checking for $LINUX/include/linux/mm_types.h... $ECHO_C" >&6
+if eval "test \"\${$as_lb_File+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test -r "$LINUX/include/linux/mm_types.h"; then
+  eval "$as_lb_File=yes"
+else
+  eval "$as_lb_File=no"
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_lb_File'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_lb_File'}'`" >&6
+if test `eval echo '${'$as_lb_File'}'` = yes; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LINUX_MMTYPES_H 1
+_ACEOF
+
+
 else
-  # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+
+
+          echo "$as_me:$LINENO: checking if kernel has bio_endio with 2 args" >&5
+echo $ECHO_N "checking if kernel has bio_endio with 2 args... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_includes_default
-#include <$ac_header>
+
+        #include <linux/bio.h>
+
+int
+main (void)
+{
+
+        bio_endio(NULL, 0);
+
+  ;
+  return 0;
+}
 _ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BIO_ENDIO_2ARG 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking if kernel has .fh_to_dentry member in export_operations struct" >&5
+echo $ECHO_N "checking if kernel has .fh_to_dentry member in export_operations struct... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#ifdef HAVE_LINUX_EXPORTFS_H
+        #include <linux/exportfs.h>
+#else
+        #include <linux/fs.h>
+#endif
+
+int
+main (void)
+{
+
+        struct export_operations exp;
+
+        exp.fh_to_dentry   = NULL;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_header_compiler=yes
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FH_TO_DENTRY 1
+_ACEOF
+
+
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_header_compiler=no
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-# Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
-cat >conftest.$ac_ext <<_ACEOF
+          echo "$as_me:$LINENO: checking if kernel has deleted member in procfs entry struct" >&5
+echo $ECHO_N "checking if kernel has deleted member in procfs entry struct... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <$ac_header>
+
+	#include <linux/proc_fs.h>
+
+int
+main (void)
+{
+
+        struct proc_dir_entry pde;
+
+        pde.deleted   = NULL;
+
+  ;
+  return 0;
+}
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
   ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PROCFS_DELETED 1
+_ACEOF
+
+
 else
-  ac_cpp_err=yes
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
 fi
-if test -z "$ac_cpp_err"; then
-  ac_header_preproc=yes
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+
+          # 2.6.26
+          echo "$as_me:$LINENO: checking fs_struct use path structure" >&5
+echo $ECHO_N "checking fs_struct use path structure... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <asm/atomic.h>
+        #include <linux/spinlock.h>
+        #include <linux/fs_struct.h>
+
+int
+main (void)
+{
+
+        struct path path;
+        struct fs_struct fs;
+
+        fs.pwd = path;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FS_STRUCT_USE_PATH 1
+_ACEOF
+
+
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-  ac_header_preproc=no
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
 fi
-rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-# So?  What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
-  yes:no: )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
-echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
-    ac_header_preproc=yes
-    ;;
-  no:yes:* )
-    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
-echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
-echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
-echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
-echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
-echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
-    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
-echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    (
-      cat <<\_ASBOX
-## ------------------------------------------- ##
-## Report this to https://bugzilla.lustre.org/ ##
-## ------------------------------------------- ##
-_ASBOX
-    ) |
-      sed "s/^/$as_me: WARNING:     /" >&2
-    ;;
-esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+          LC_RCU_LIST_SAFE
+
+          # 2.6.27
+          echo "$as_me:$LINENO: checking inode_operations->permission have two args" >&5
+echo $ECHO_N "checking inode_operations->permission have two args... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/fs.h>
+
+int
+main (void)
+{
+
+        struct inode *inode;
+
+        inode->i_op->permission(NULL,0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_INODE_PERMISION_2ARGS 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking kernel have file_remove_suid" >&5
+echo $ECHO_N "checking kernel have file_remove_suid... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/fs.h>
+
+int
+main (void)
+{
+
+        file_remove_suid(NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FILE_REMOVE_SUID 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking kernel use trylock_page for page lock" >&5
+echo $ECHO_N "checking kernel use trylock_page for page lock... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/pagemap.h>
+
+int
+main (void)
+{
+
+        trylock_page(NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TRYLOCK_PAGE 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking mapping->tree_lock is rw_lock" >&5
+echo $ECHO_N "checking mapping->tree_lock is rw_lock... $ECHO_C" >&6
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+	#include <linux/fs.h>
+
+int
+main (void)
+{
+
+	struct address_space *map = NULL;
+
+	write_lock_irq(&map->tree_lock);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_RW_TREE_LOCK 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+EXTRA_KCFLAGS="$tmp_flags"
+
+          echo "$as_me:$LINENO: checking super_operations has a read_inode field" >&5
+echo $ECHO_N "checking super_operations has a read_inode field... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/fs.h>
+
+int
+main (void)
+{
+
+        struct super_operations *sop;
+        sop->read_inode(NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_READ_INODE_IN_SBOPS 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking if Linux was built with symbol inode_permission exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol inode_permission exported... $ECHO_C" >&6
+grep -q -E '[[:space:]]inode_permission[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
+rc=$?
+if test $rc -ne 0; then
+    export=0
+    for file in fs/namei.c; do
+    	grep -q -E "EXPORT_SYMBOL.*\(inode_permission\)" "$LINUX/$file" 2>/dev/null
+    	rc=$?
+	if test $rc -eq 0; then
+		export=1
+		break;
+	fi
+    done
+    if test $export -eq 0; then
+    	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+
+    else
+    	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_EXPORT_INODE_PERMISSION 1
+_ACEOF
+
+
+    fi
+else
+    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_EXPORT_INODE_PERMISSION 1
+_ACEOF
+
+
+fi
+
+
+          echo "$as_me:$LINENO: checking quota_on needs 5 parameters" >&5
+echo $ECHO_N "checking quota_on needs 5 parameters... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/quota.h>
+
+int
+main (void)
+{
+
+        struct quotactl_ops *qop;
+        qop->quota_on(NULL, 0, 0, NULL, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_QUOTA_ON_5ARGS 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking quota_off needs 3 parameters" >&5
+echo $ECHO_N "checking quota_off needs 3 parameters... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/quota.h>
+
+int
+main (void)
+{
+
+        struct quotactl_ops *qop;
+        qop->quota_off(NULL, 0, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_QUOTA_OFF_3ARGS 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking vfs_dq_off is defined" >&5
+echo $ECHO_N "checking vfs_dq_off is defined... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/quotaops.h>
+
+int
+main (void)
+{
+
+        vfs_dq_off(NULL, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_VFS_DQ_OFF 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+
+          # 2.6.27.15-2 sles11
+          echo "$as_me:$LINENO: checking struct bio has a bi_hw_segments field" >&5
+echo $ECHO_N "checking struct bio has a bi_hw_segments field... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/bio.h>
+
+int
+main (void)
+{
+
+        struct bio io;
+        io.bi_hw_segments = 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_BI_HW_SEGMENTS 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          as_lb_File=`echo "lb_cv_file_$LINUX/include/linux/quotaio_v1.h" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $LINUX/include/linux/quotaio_v1.h" >&5
+echo $ECHO_N "checking for $LINUX/include/linux/quotaio_v1.h... $ECHO_C" >&6
+if eval "test \"\${$as_lb_File+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  eval "$as_ac_Header=\$ac_header_preproc"
+  if test -r "$LINUX/include/linux/quotaio_v1.h"; then
+  eval "$as_lb_File=yes"
+else
+  eval "$as_lb_File=no"
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_lb_File'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_lb_File'}'`" >&6
+if test `eval echo '${'$as_lb_File'}'` = yes; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_QUOTAIO_V1_H 1
+_ACEOF
+
+
+else
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 
 fi
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+
+
+          echo "$as_me:$LINENO: checking vfs_symlink need 5 parameter" >&5
+echo $ECHO_N "checking vfs_symlink need 5 parameter... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/fs.h>
+
+int
+main (void)
+{
+
+        struct inode *dir = NULL;
+        struct dentry *dentry = NULL;
+        struct vfsmount *mnt = NULL;
+        const char * path = NULL;
+        vfs_symlink(dir, dentry, mnt, path, 0);
+
+  ;
+  return 0;
+}
 _ACEOF
 
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_VFS_SYMLINK_5ARGS 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
 fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-done
+          echo "$as_me:$LINENO: checking Kernel has sb_any_quota_active" >&5
+echo $ECHO_N "checking Kernel has sb_any_quota_active... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/quotaops.h>
+
+int
+main (void)
+{
+
+        sb_any_quota_active(NULL);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
 
-CFLAGS="$tmpfl"
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SB_ANY_QUOTA_ACTIVE 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
+
+          echo "$as_me:$LINENO: checking Kernel has sb_has_quota_active" >&5
+echo $ECHO_N "checking Kernel has sb_has_quota_active... $ECHO_C" >&6
+cat >conftest.c <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+        #include <linux/quotaops.h>
+
+int
+main (void)
+{
+
+        sb_has_quota_active(NULL, 0);
+
+  ;
+  return 0;
+}
+_ACEOF
+
+rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
+if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SB_HAS_QUOTA_ACTIVE 1
+_ACEOF
+
+        echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+        echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
 
 			;;
@@ -12088,6 +14512,69 @@ echo "$as_me: error: Modules are not supported on $target_os" >&2;}
 fi
 
 
+
+echo "$as_me:$LINENO: checking userspace __u64 is long long type" >&5
+echo $ECHO_N "checking userspace __u64 is long long type... $ECHO_C" >&6
+tmp_flags="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
+cat >conftest.$ac_ext <<_ACEOF
+
+	#include <linux/types.h>
+	#include <linux/stddef.h>
+	int main(void) {
+		unsigned long long *data1;
+		__u64 *data2 = NULL;
+
+		data1 = data2;
+		return 0;
+	}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+
+	echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_USER__U64_LONG_LONG 1
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="$tmp_flags"
+
+
+
 # Check whether --enable-dmu or --disable-dmu was given.
 if test "${enable_dmu+set}" = set; then
   enableval="$enable_dmu"
@@ -12170,13 +14657,13 @@ subdirs="$subdirs lustre/zfs-lustre"
 
 
 
-		as_lb_File=`echo "lb_cv_file_$SPL_DIR/modules/spl/spl-generic.c" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $SPL_DIR/modules/spl/spl-generic.c" >&5
-echo $ECHO_N "checking for $SPL_DIR/modules/spl/spl-generic.c... $ECHO_C" >&6
+		as_lb_File=`echo "lb_cv_file_$SPL_DIR/module/spl/spl-generic.c" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $SPL_DIR/module/spl/spl-generic.c" >&5
+echo $ECHO_N "checking for $SPL_DIR/module/spl/spl-generic.c... $ECHO_C" >&6
 if eval "test \"\${$as_lb_File+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -r "$SPL_DIR/modules/spl/spl-generic.c"; then
+  if test -r "$SPL_DIR/module/spl/spl-generic.c"; then
   eval "$as_lb_File=yes"
 else
   eval "$as_lb_File=no"
@@ -12195,13 +14682,13 @@ echo "$as_me: error: A complete SPL tree was not found in $SPL_DIR." >&2;}
 fi
 
 
-		as_lb_File=`echo "lb_cv_file_$ZFS_DIR/zfs/lib/libzpool/dmu.c" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ZFS_DIR/zfs/lib/libzpool/dmu.c" >&5
-echo $ECHO_N "checking for $ZFS_DIR/zfs/lib/libzpool/dmu.c... $ECHO_C" >&6
+		as_lb_File=`echo "lb_cv_file_$ZFS_DIR/module/zfs/dmu.c" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ZFS_DIR/module/zfs/dmu.c" >&5
+echo $ECHO_N "checking for $ZFS_DIR/module/zfs/dmu.c... $ECHO_C" >&6
 if eval "test \"\${$as_lb_File+set}\" = set"; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if test -r "$ZFS_DIR/zfs/lib/libzpool/dmu.c"; then
+  if test -r "$ZFS_DIR/module/zfs/dmu.c"; then
   eval "$as_lb_File=yes"
 else
   eval "$as_lb_File=no"
@@ -12460,6 +14947,14 @@ else
 fi
 
 
+if test x$enable_ext4 = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_EXT4_LDISKFS 1
+_ACEOF
+
+fi
+
 # We have to configure even if we don't build here for make dist to work
 
 
@@ -12553,6 +15048,222 @@ subdirs="$subdirs lustre-iokit"
 
 
 
+
+# Check whether --with-ldiskfsprogs or --without-ldiskfsprogs was given.
+if test "${with_ldiskfsprogs+set}" = set; then
+  withval="$with_ldiskfsprogs"
+
+else
+  withval='no'
+fi;
+
+if test x$withval = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LDISKFSPROGS 1
+_ACEOF
+
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	echo "$as_me:$LINENO: result: enabled" >&5
+echo "${ECHO_T}enabled" >&6
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	echo "$as_me:$LINENO: result: disabled" >&5
+echo "${ECHO_T}disabled" >&6
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define E2FSPROGS "$E2FSPROGS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define MKE2FS "$MKE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEBUGFS "$DEBUGFS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define TUNE2FS "$TUNE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define E2LABEL "$E2LABEL"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define DUMPE2FS "$DUMPE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define E2FSCK "$E2FSCK"
+_ACEOF
+
+
+
+
+# Check whether --with-ldiskfsprogs or --without-ldiskfsprogs was given.
+if test "${with_ldiskfsprogs+set}" = set; then
+  withval="$with_ldiskfsprogs"
+
+else
+  withval='no'
+fi;
+
+if test x$withval = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LDISKFSPROGS 1
+_ACEOF
+
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	echo "$as_me:$LINENO: result: enabled" >&5
+echo "${ECHO_T}enabled" >&6
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	echo "$as_me:$LINENO: result: disabled" >&5
+echo "${ECHO_T}disabled" >&6
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define E2FSPROGS "$E2FSPROGS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define MKE2FS "$MKE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEBUGFS "$DEBUGFS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define TUNE2FS "$TUNE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define E2LABEL "$E2LABEL"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define DUMPE2FS "$DUMPE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define E2FSCK "$E2FSCK"
+_ACEOF
+
+
+
+
+# Check whether --with-ldiskfsprogs or --without-ldiskfsprogs was given.
+if test "${with_ldiskfsprogs+set}" = set; then
+  withval="$with_ldiskfsprogs"
+
+else
+  withval='no'
+fi;
+
+if test x$withval = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LDISKFSPROGS 1
+_ACEOF
+
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	echo "$as_me:$LINENO: result: enabled" >&5
+echo "${ECHO_T}enabled" >&6
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	echo "$as_me:$LINENO: result: disabled" >&5
+echo "${ECHO_T}disabled" >&6
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define E2FSPROGS "$E2FSPROGS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define MKE2FS "$MKE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEBUGFS "$DEBUGFS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define TUNE2FS "$TUNE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define E2LABEL "$E2LABEL"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define DUMPE2FS "$DUMPE2FS"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define E2FSCK "$E2FSCK"
+_ACEOF
+
+
+
 echo "$as_me:$LINENO: checking whether to build Lustre library" >&5
 echo $ECHO_N "checking whether to build Lustre library... $ECHO_C" >&6
 # Check whether --enable-liblustre or --disable-liblustre was given.
@@ -12611,83 +15322,45 @@ if test "${enable_mpitests+set}" = set; then
 	 enable_mpitests=yes
          case $enableval in
          yes)
-		MPI_ROOT=/opt/mpich
-		LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
-		CFLAGS="$CFLAGS -I$MPI_ROOT/include"
+		MPICC_WRAPPER=mpicc
 		;;
          no)
 		enable_mpitests=no
 		;;
-	 [\\/$]* | ?:[\\/]* )
-		MPI_ROOT=$enableval
-		LDFLAGS="$LDFLAGS -L$with_mpi/lib"
-		CFLAGS="$CFLAGS -I$MPI_ROOT/include"
-                ;;
          *)
-                 { { echo "$as_me:$LINENO: error: expected absolute directory name for --enable-mpitests or yes or no" >&5
-echo "$as_me: error: expected absolute directory name for --enable-mpitests or yes or no" >&2;}
-   { (exit 1); exit 1; }; }
+		MPICC_WRAPPER=$enableval
                  ;;
 	 esac
 
 else
 
-	MPI_ROOT=/opt/mpich
-        LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
-        CFLAGS="$CFLAGS -I$MPI_ROOT/include"
+	MPICC_WRAPPER=mpicc
 	enable_mpitests=yes
 
 
 fi;
 
-
 if test x$enable_mpitests != xno; then
-	echo "$as_me:$LINENO: checking whether to mpitests can be built" >&5
-echo $ECHO_N "checking whether to mpitests can be built... $ECHO_C" >&6
-        as_ac_File=`echo "ac_cv_file_$MPI_ROOT/include/mpi.h" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $MPI_ROOT/include/mpi.h" >&5
-echo $ECHO_N "checking for $MPI_ROOT/include/mpi.h... $ECHO_C" >&6
-if eval "test \"\${$as_ac_File+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  test "$cross_compiling" = yes &&
-  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
-echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
-   { (exit 1); exit 1; }; }
-if test -r "$MPI_ROOT/include/mpi.h"; then
-  eval "$as_ac_File=yes"
-else
-  eval "$as_ac_File=no"
-fi
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_File'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_File'}'`" >&6
-if test `eval echo '${'$as_ac_File'}'` = yes; then
-  echo "$as_me:$LINENO: checking for MPI_Start in -lmpich" >&5
-echo $ECHO_N "checking for MPI_Start in -lmpich... $ECHO_C" >&6
-if test "${ac_cv_lib_mpich_MPI_Start+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lmpich  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+	echo "$as_me:$LINENO: checking whether mpitests can be built" >&5
+echo $ECHO_N "checking whether mpitests can be built... $ECHO_C" >&6
+	oldcc=$CC
+	CC=$MPICC_WRAPPER
+	cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char MPI_Start ();
+		    #include <mpi.h>
+
 int
 main ()
 {
-MPI_Start ();
+
+		    int flag;
+		    MPI_Initialized(&flag);
+
   ;
   return 0;
 }
@@ -12714,33 +15387,25 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_lib_mpich_MPI_Start=yes
+
+		    echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_mpich_MPI_Start=no
+
+		    echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+		    enable_mpitests=no
+
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_mpich_MPI_Start" >&5
-echo "${ECHO_T}$ac_cv_lib_mpich_MPI_Start" >&6
-if test $ac_cv_lib_mpich_MPI_Start = yes; then
-  enable_mpitests=yes
-else
-  enable_mpitests=no
+	CC=$oldcc
 fi
 
-else
-  enable_mpitests=no
-fi
-
-fi
-echo "$as_me:$LINENO: result: $enable_mpitests" >&5
-echo "${ECHO_T}$enable_mpitests" >&6
-
 
 { echo "$as_me:$LINENO: Enabling Lustre configure options for libsysio" >&5
 echo "$as_me: Enabling Lustre configure options for libsysio" >&6;}
@@ -13890,6 +16555,10 @@ _ACEOF
 
 
 
+if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
+        CFLAGS="$CFLAGS -Werror"
+fi
+
 # include/liblustre.h
 
 
@@ -15933,7 +18602,7 @@ fi
 
           ac_config_headers="$ac_config_headers config.h"
 
-CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
+CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
 
 
@@ -15952,7 +18621,7 @@ case $lb_target_os in
 		;;
 esac
 
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ac_config_files="$ac_config_files lustre/Makefile lustre/autoMakefile lustre/autoconf/Makefile lustre/contrib/Makefile 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-suse.target lustre/kernel_patches/targets/2.6-vanilla.target lustre/kernel_patches/targets/2.6-rhel4.target lustre/kernel_patches/targets/2.6-rhel5.target lustre/kernel_patches/targets/2.6-fc5.target lustre/kernel_patches/targets/2.6-patchless.target lustre/kernel_patches/targets/2.6-sles10.target lustre/kernel_patches/targets/hp_pnnl-2.4.target lustre/kernel_patches/targets/rh-2.4.target lustre/kernel_patches/targets/rhel-2.4.target lustre/kernel_patches/targets/suse-2.4.21-2.target lustre/kernel_patches/targets/sles-2.4.target lustre/ldlm/Makefile lustre/liblustre/Makefile lustre/liblustre/tests/Makefile lustre/llite/Makefile lustre/llite/autoMakefile lustre/lov/Makefile lustre/lov/autoMakefile lustre/lvfs/Makefile lustre/lvfs/autoMakefile lustre/mdc/Makefile lustre/mdc/autoMakefile lustre/mds/Makefile lustre/mds/autoMakefile lustre/obdclass/Makefile lustre/obdclass/autoMakefile lustre/obdclass/linux/Makefile lustre/obdecho/Makefile lustre/obdecho/autoMakefile lustre/obdfilter/Makefile lustre/obdfilter/autoMakefile lustre/osc/Makefile lustre/osc/autoMakefile lustre/ost/Makefile lustre/ost/autoMakefile lustre/mgc/Makefile lustre/mgc/autoMakefile lustre/mgs/Makefile lustre/mgs/autoMakefile lustre/ptlrpc/Makefile lustre/ptlrpc/autoMakefile lustre/quota/Makefile lustre/quota/autoMakefile lustre/scripts/Makefile lustre/scripts/version_tag.pl lustre/tests/Makefile lustre/utils/Makefile"
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ac_config_files="$ac_config_files lustre/Makefile lustre/autoMakefile lustre/autoconf/Makefile lustre/contrib/Makefile 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-suse.target lustre/kernel_patches/targets/2.6-vanilla.target lustre/kernel_patches/targets/2.6-rhel4.target lustre/kernel_patches/targets/2.6-rhel5.target lustre/kernel_patches/targets/2.6-fc5.target lustre/kernel_patches/targets/2.6-patchless.target lustre/kernel_patches/targets/2.6-sles10.target lustre/kernel_patches/targets/2.6-sles11.target lustre/kernel_patches/targets/hp_pnnl-2.4.target lustre/kernel_patches/targets/rh-2.4.target lustre/kernel_patches/targets/rhel-2.4.target lustre/kernel_patches/targets/suse-2.4.21-2.target lustre/kernel_patches/targets/sles-2.4.target lustre/ldlm/Makefile lustre/liblustre/Makefile lustre/liblustre/tests/Makefile lustre/liblustre/tests/mpi/Makefile lustre/llite/Makefile lustre/llite/autoMakefile lustre/lov/Makefile lustre/lov/autoMakefile lustre/lvfs/Makefile lustre/lvfs/autoMakefile lustre/mdc/Makefile lustre/mdc/autoMakefile lustre/mds/Makefile lustre/mds/autoMakefile lustre/obdclass/Makefile lustre/obdclass/autoMakefile lustre/obdclass/linux/Makefile lustre/obdecho/Makefile lustre/obdecho/autoMakefile lustre/obdfilter/Makefile lustre/obdfilter/autoMakefile lustre/osc/Makefile lustre/osc/autoMakefile lustre/ost/Makefile lustre/ost/autoMakefile lustre/mgc/Makefile lustre/mgc/autoMakefile lustre/mgs/Makefile lustre/mgs/autoMakefile lustre/ptlrpc/Makefile lustre/ptlrpc/autoMakefile lustre/quota/Makefile lustre/quota/autoMakefile lustre/scripts/Makefile lustre/tests/Makefile lustre/tests/mpi/Makefile lustre/utils/Makefile"
 
 case $lb_target_os in
         darwin)
@@ -16608,7 +19277,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by Lustre $as_me 1.6.7.2, which was
+This file was extended by Lustre $as_me 1.8.1, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16671,7 +19340,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-Lustre config.status 1.6.7.2
+Lustre config.status 1.8.1
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -16850,6 +19519,7 @@ do
   "lustre/kernel_patches/targets/2.6-fc5.target" ) CONFIG_FILES="$CONFIG_FILES lustre/kernel_patches/targets/2.6-fc5.target" ;;
   "lustre/kernel_patches/targets/2.6-patchless.target" ) CONFIG_FILES="$CONFIG_FILES lustre/kernel_patches/targets/2.6-patchless.target" ;;
   "lustre/kernel_patches/targets/2.6-sles10.target" ) CONFIG_FILES="$CONFIG_FILES lustre/kernel_patches/targets/2.6-sles10.target" ;;
+  "lustre/kernel_patches/targets/2.6-sles11.target" ) CONFIG_FILES="$CONFIG_FILES lustre/kernel_patches/targets/2.6-sles11.target" ;;
   "lustre/kernel_patches/targets/hp_pnnl-2.4.target" ) CONFIG_FILES="$CONFIG_FILES lustre/kernel_patches/targets/hp_pnnl-2.4.target" ;;
   "lustre/kernel_patches/targets/rh-2.4.target" ) CONFIG_FILES="$CONFIG_FILES lustre/kernel_patches/targets/rh-2.4.target" ;;
   "lustre/kernel_patches/targets/rhel-2.4.target" ) CONFIG_FILES="$CONFIG_FILES lustre/kernel_patches/targets/rhel-2.4.target" ;;
@@ -16858,6 +19528,7 @@ do
   "lustre/ldlm/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/ldlm/Makefile" ;;
   "lustre/liblustre/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/liblustre/Makefile" ;;
   "lustre/liblustre/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/liblustre/tests/Makefile" ;;
+  "lustre/liblustre/tests/mpi/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/liblustre/tests/mpi/Makefile" ;;
   "lustre/llite/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/llite/Makefile" ;;
   "lustre/llite/autoMakefile" ) CONFIG_FILES="$CONFIG_FILES lustre/llite/autoMakefile" ;;
   "lustre/lov/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/lov/Makefile" ;;
@@ -16888,8 +19559,8 @@ do
   "lustre/quota/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/quota/Makefile" ;;
   "lustre/quota/autoMakefile" ) CONFIG_FILES="$CONFIG_FILES lustre/quota/autoMakefile" ;;
   "lustre/scripts/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/scripts/Makefile" ;;
-  "lustre/scripts/version_tag.pl" ) CONFIG_FILES="$CONFIG_FILES lustre/scripts/version_tag.pl" ;;
   "lustre/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/tests/Makefile" ;;
+  "lustre/tests/mpi/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/tests/mpi/Makefile" ;;
   "lustre/utils/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/utils/Makefile" ;;
   "lustre/obdclass/darwin/Makefile" ) CONFIG_FILES="$CONFIG_FILES lustre/obdclass/darwin/Makefile" ;;
   "snmp/Makefile" ) CONFIG_FILES="$CONFIG_FILES snmp/Makefile" ;;
@@ -17120,7 +19791,7 @@ s, at SNMP_SUBDIR@,$SNMP_SUBDIR,;t t
 s, at LDISKFS_DIR@,$LDISKFS_DIR,;t t
 s, at LDISKFS_SUBDIR@,$LDISKFS_SUBDIR,;t t
 s, at LUSTREIOKIT_SUBDIR@,$LUSTREIOKIT_SUBDIR,;t t
-s, at MPI_ROOT@,$MPI_ROOT,;t t
+s, at MPICC_WRAPPER@,$MPICC_WRAPPER,;t t
 s, at LIBREADLINE@,$LIBREADLINE,;t t
 s, at LIBEFENCE@,$LIBEFENCE,;t t
 s, at LIBWRAP@,$LIBWRAP,;t t
diff --git a/ldiskfs/ChangeLog b/ldiskfs/ChangeLog
index 480c201..d275fcc 100644
--- a/ldiskfs/ChangeLog
+++ b/ldiskfs/ChangeLog
@@ -1,5 +1,36 @@
-2009-06-05 Sun Microsystems, Inc.
-        * version 3.0.7.2
+2009-07-31  Sun Microsystems, Inc.
+	* version 3.0.9
+
+Severity   : minor
+Frequency  : in recovery
+Bugzilla   : 18192
+Description: don't mix llog inodes with normal.
+Details    : allocate inodes for log in last inode group
+
+-------------------------------------------------------------------------------
+
+2009-04-20  Sun Microsystems, Inc.
+	* version 3.0.8
+
+Severity   : minor
+Bugzilla   : 16114
+Description: minor fixes and cleanups
+Details    : use EXT_UNSET_BLOCK to avoid confusion with EXT_MAX_BLOCK.
+	     Initialize 'ix' variable in extents patch to stop compiler warning.
+
+Severity   : feature
+Bugzilla   : 17942
+Description: update FIEMAP ioctl to match upstream kernel version
+Details    : the FIEMAP block-mapping ioctl had a prototype version in
+	     ldiskfs 3.0.7 but this release updates it to match the
+	     interface in the upstream kernel, with a new ioctl number.
+
+Severity   : normal
+Frequency  : only if MMP is active and detects filesystem is in use
+Bugzilla   : 18173
+Description: if MMP startup fails, an oops is triggered
+Details    : if ldiskfs mounting doesn't succeed the error handling doesn't
+	     clean up the MMP data correctly, causing an oops.
 
 -------------------------------------------------------------------------------
 
@@ -41,6 +72,14 @@ Details    : The ldiskfs code is not tested on big-endian machines, and
 	     possible to mount with the "bigendian_extents" option to
 	     force the mount.
 
+Severity   : major
+Frequency  : only with software RAID-5
+Bugzilla   : 17895
+Description: MMP block reads may fail to detect another user of the filesystem
+Details    : with software RAID it is possible that the RAID driver will
+	     cache the MMP block and not refetch it from disk.  Force the
+	     read to invalidate the RAID page cache and go directly to disk.
+
 -------------------------------------------------------------------------------
 
 2008-08-31  Sun Microsystems, Inc.
@@ -86,7 +125,7 @@ Details    : FIEMAP ioctl will allow an application to efficiently fetch the
 
 Severity   : normal
 Bugzilla   : 17490
-Description: mkfs.lustre: Unable to mount /dev/cciss/c0d1: Cannot allocate memory
+Description: mkfs.lustre: Unable to mount /dev/cciss/c0d1:Cannot allocate memory
 Details    : correctly handle device paths using a subdirectory in /dev when
 	     creating the per-device procfs directory under /proc/fs/ldiskfs.
 
diff --git a/ldiskfs/aclocal.m4 b/ldiskfs/aclocal.m4
index 8dd1fc9..cf95cdd 100644
--- a/ldiskfs/aclocal.m4
+++ b/ldiskfs/aclocal.m4
@@ -880,19 +880,6 @@ AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([lb_File])dnl
 ])# LB_CHECK_FILE
 
-#
-# LB_CHECK_FILES
-#
-# LB_CHECK_FILE over multiple files
-#
-AC_DEFUN([LB_CHECK_FILES],
-[AC_FOREACH([AC_FILE_NAME], [$1],
-  [LB_CHECK_FILE(AC_FILE_NAME,
-                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
-                                    [Define to 1 if you have the
-                                     file `]AC_File['.])
-$2],
-                 [$3])])])
 
 #
 # LB_ARG_LIBS_INCLUDES
@@ -1075,6 +1062,10 @@ AC_SUBST(LDISKFS_DIR)
 AC_SUBST(LDISKFS_SUBDIR)
 AM_CONDITIONAL(LDISKFS_ENABLED, test x$with_ldiskfs != xno)
 
+if test x$enable_ext4 = xyes ; then
+	AC_DEFINE(HAVE_EXT4_LDISKFS, 1, [build ext4 based ldiskfs])
+fi
+
 # We have to configure even if we don't build here for make dist to work
 AC_CONFIG_SUBDIRS(ldiskfs)
 ])
@@ -1108,6 +1099,131 @@ AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
 	AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1, [enable extented attributes for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFS_FS_NFS4ACL, 1, [enable fs security for ldiskfs])
+
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
 ])
 
 #
@@ -1243,11 +1359,11 @@ if test x$dmu_osd = xyes; then
 
 		AC_SUBST(spl_src)
 
-		LB_CHECK_FILE([$SPL_DIR/modules/spl/spl-generic.c],[],[
+		LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
 			AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
 		])
 
-		LB_CHECK_FILE([$ZFS_DIR/zfs/lib/libzpool/dmu.c],[],[
+		LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
 			AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
 		])
 
@@ -1395,7 +1511,7 @@ AC_SUBST(ENABLE_INIT_SCRIPTS)
 #
 AC_DEFUN([LB_CONFIG_HEADERS],
 [AC_CONFIG_HEADERS([config.h])
-CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
+CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
 AC_SUBST(EXTRA_KCFLAGS)
 ])
@@ -1483,7 +1599,7 @@ if test $target_cpu == "powerpc64"; then
 	CC="$CC -m64"
 fi
 
-CPPFLAGS="-I\$(top_builddir)/$LIBCFS_INCLUDE_DIR -I\$(top_srcdir)/$LIBCFS_INCLUDE_DIR-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
+CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
 
 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
 AC_SUBST(LLCPPFLAGS)
@@ -1581,12 +1697,20 @@ LC_QUOTA
 
 LB_CONFIG_MODULES
 
+LN_CONFIG_USERSPACE
+
 LB_PATH_DMU
 LB_PATH_LIBSYSIO
 LB_PATH_SNMP
 LB_PATH_LDISKFS
 LB_PATH_LUSTREIOKIT
 
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
 LC_CONFIG_LIBLUSTRE
 LIBCFS_CONFIGURE
 LN_CONFIGURE
@@ -1736,29 +1860,18 @@ AC_MSG_CHECKING([that RedHat kernel])
 LB_LINUX_TRY_COMPILE([
 		#include <linux/version.h>
 	],[
-		#ifndef RHEL_MAJOR
+		#ifndef RHEL_RELEASE_CODE
 		#error "not redhat kernel"
 		#endif
 	],[
 		RHEL_KENEL="yes"
+		RHEL_KERNEL="yes"
 		AC_MSG_RESULT([yes])
 	],[
-		AC_MSG_RESULT([no])
+	        AC_MSG_RESULT([no])
 ])
 
-AC_MSG_CHECKING([that SuSe kernel])
-LB_LINUX_TRY_COMPILE([
-		#include <linux/version.h>
-	],[
-		#ifndef SLE_VERSION_CODE
-		#error "not sles kernel"
-		#endif
-	],[
-		SUSE_KERNEL="yes"
-		AC_MSG_RESULT([yes])
-	],[
-		AC_MSG_RESULT([no])
-])
+LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
 
 ])
 
@@ -1773,7 +1886,13 @@ AC_DEFUN([LB_LINUX_PATH],
 AC_ARG_WITH([linux],
 	AC_HELP_STRING([--with-linux=path],
 		       [set path to Linux source (default=/usr/src/linux)]),
-	[LINUX=$with_linux],
+	[
+		if ! [[[ $with_linux = /* ]]]; then
+			AC_MSG_ERROR([You must provide an absolute pathname to the --with-linux= option.])
+		else
+			LINUX=$with_linux
+		fi
+	],
 	[LINUX=/usr/src/linux])
 AC_MSG_RESULT([$LINUX])
 AC_SUBST(LINUX)
@@ -1818,9 +1937,9 @@ LB_CHECK_FILE([$LINUX_CONFIG],[],
 # at 2.6.19 # $LINUX/include/linux/config.h is removed
 # and at more old has only one line
 # include <autoconf.h>
-LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
-		$LINUX_OBJ/include/linux/version.h
-		],[],
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[],
+	[AC_MSG_ERROR([Run make config in $LINUX.])])
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
 	[AC_MSG_ERROR([Run make config in $LINUX.])])
 
 # ------------ rhconfig.h includes runtime-generated bits --
@@ -1931,7 +2050,7 @@ if test -e $LINUX/include/asm-um ; then
 		UML_CFLAGS='-O0'
 		AC_MSG_RESULT(yes)
     	else
-		AC_MSG_RESULT([no (asm doesn't point at asm-um)])
+		AC_MSG_RESULT([no])
 	fi
 else
 	AC_MSG_RESULT([no (asm-um missing)])
@@ -1993,7 +2112,7 @@ AC_DEFUN([LB_LINUX_ARCH],
          [AC_MSG_CHECKING([Linux kernel architecture])
           AS_IF([rm -f $PWD/build/arch
                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
-                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX_OBJ $ARCH_UM \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
                 [AC_MSG_RESULT([$LINUX_ARCH])],
                 [AC_MSG_ERROR([Could not determine the kernel architecture.])])
@@ -2085,6 +2204,72 @@ fi
 ])
 
 #
+# LB_CONFIG_OFED_BACKPORTS
+#
+# include any OFED backport headers in all compile commands
+# NOTE: this does only include the backport paths, not the OFED headers
+#       adding the OFED headers is done in the lnet portion
+AC_DEFUN([LB_CONFIG_OFED_BACKPORTS],
+[AC_MSG_CHECKING([whether to use any OFED backport headers])
+# set default
+AC_ARG_WITH([o2ib],
+	AC_HELP_STRING([--with-o2ib=path],
+	               [build o2iblnd against path]),
+	[
+		case $with_o2ib in
+		yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+			ENABLEO2IB=2
+			;;
+		no)     ENABLEO2IB=0
+			;;
+		*)      O2IBPATHS=$with_o2ib
+			ENABLEO2IB=3
+			;;
+		esac
+	],[
+		O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+		ENABLEO2IB=1
+	])
+if test $ENABLEO2IB -eq 0; then
+	AC_MSG_RESULT([no])
+else
+	o2ib_found=false
+	for O2IBPATH in $O2IBPATHS; do
+		if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+			o2ib_found=true
+			break
+		fi
+	done
+	if ! $o2ib_found; then
+		AC_MSG_RESULT([no])
+		case $ENABLEO2IB in
+			1) ;;
+			2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
+			3) AC_MSG_ERROR([bad --with-o2ib path]);;
+			*) AC_MSG_ERROR([internal error]);;
+		esac
+	else
+                if test -f $O2IBPATH/config.mk; then
+			. $O2IBPATH/config.mk
+                elif test -f $O2IBPATH/ofed_patch.mk; then
+			. $O2IBPATH/ofed_patch.mk
+		fi
+		if test -n "$BACKPORT_INCLUDES"; then
+			OFED_BACKPORT_PATH=`echo $BACKPORT_INCLUDES | sed "s#.*/src/ofa_kernel/#$O2IBPATH/#"`
+			EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
+			AC_MSG_RESULT([yes])
+		else
+			AC_MSG_RESULT([no])
+                fi
+	fi
+fi
+])
+
+
+#
 # LB_PROG_LINUX
 #
 # linux tests
@@ -2094,11 +2279,6 @@ AC_DEFUN([LB_PROG_LINUX],
 LB_LINUX_ARCH
 LB_LINUX_SYMVERFILE
 
-#if test $LINUX_ARCH == "powerpc64"; then
-#	AC_MSG_WARN([set compiler with -m64])
-#	CFLAGS="$CFLAGS -m64"
-#	CC="$CC -m64"
-#fi
 
 LB_LINUX_CONFIG([MODULES],[],[
 	AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
@@ -2106,10 +2286,6 @@ LB_LINUX_CONFIG([MODULES],[],[
 
 LB_LINUX_CONFIG([MODVERSIONS])
 
-LB_LINUX_CONFIG([PREEMPT],[
-	AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
-])
-
 LB_LINUX_CONFIG([KALLSYMS],[],[
 if test "x$ARCH_UM" = "x" ; then
 	AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
@@ -2124,6 +2300,10 @@ LB_LINUX_CONFIG([KMOD],[],[
 
 #LB_LINUX_CONFIG_BIG_STACK
 
+# it's ugly to be doing anything with OFED outside of the lnet module, but
+# this has to be done here so that the backports path is set before all of
+# the LN_PROG_LINUX checks are done
+LB_CONFIG_OFED_BACKPORTS
 ])
 
 #
@@ -2147,7 +2327,7 @@ AC_DEFUN([LB_LINUX_CONDITIONALS],
 # 2.6 based kernels - put modversion info into $LINUX/Module.modvers
 # or check
 AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
-[AC_MSG_CHECKING([if Linux was built with symbol $1 is exported])
+[AC_MSG_CHECKING([if Linux was built with symbol $1 exported])
 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -2174,6 +2354,21 @@ fi
 ])
 
 #
+# Like AC_CHECK_HEADER but checks for a kernel-space header
+#
+m4_define([LB_CHECK_LINUX_HEADER],
+[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+AC_CACHE_CHECK([for $1], ac_Header,
+	       [LB_LINUX_COMPILE_IFELSE([LB_LANG_PROGRAM([@%:@include <$1>])],
+				  [modules],
+				  [test -s build/conftest.o],
+				  [AS_VAR_SET(ac_Header, [yes])],
+				  [AS_VAR_SET(ac_Header, [no])])])
+AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
+AS_VAR_POPDEF([ac_Header])dnl
+])
+
+#
 # LB_DARWIN_CHECK_FUNCS
 #
 # check for functions in the darwin kernel
@@ -2188,7 +2383,7 @@ do
 AC_MSG_CHECKING([for $1])
 AS_IF([AC_TRY_COMMAND(nm /mach | grep "[$1]" >/dev/null 2>/dev/null)],[
 	AC_MSG_RESULT([yes])
-	AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$ac_func])]) $2
+	AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$ac_func])) $2
 ],[
 	AC_MSG_RESULT([no]) $3
 ])dnl
diff --git a/ldiskfs/autoMakefile.am b/ldiskfs/autoMakefile.am
index 9e9a2cd..12759cd 100644
--- a/ldiskfs/autoMakefile.am
+++ b/ldiskfs/autoMakefile.am
@@ -5,3 +5,5 @@ DIST_SUBDIRS := ldiskfs
 include build/autoMakefile.am.toplevel
 
 EXTRA_DIST += kernel_patches
+
+module-dist-hook:
diff --git a/ldiskfs/autoMakefile.in b/ldiskfs/autoMakefile.in
index be4c576..7c63331 100644
--- a/ldiskfs/autoMakefile.in
+++ b/ldiskfs/autoMakefile.in
@@ -50,6 +50,8 @@ AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
+BACKFS = @BACKFS@
+BACKFSU = @BACKFSU@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -112,6 +114,8 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 SYMVERFILE = @SYMVERFILE@
 UML_CFLAGS = @UML_CFLAGS@
+USE_EXT4_FALSE = @USE_EXT4_FALSE@
+USE_EXT4_TRUE = @USE_EXT4_TRUE@
 USE_QUILT_FALSE = @USE_QUILT_FALSE@
 USE_QUILT_TRUE = @USE_QUILT_TRUE@
 VERSION = @VERSION@
@@ -619,7 +623,11 @@ dist-hook:
 	find $(distdir) -name .deps -o \
 			-name CVS -o \
 			-name .svn -o \
+			-name .git -o \
 			-name .#* | xargs rm -rf
+	$(MAKE) $(AM_MAKEFLAGS) \
+	  top_distdir="$(top_distdir)" distdir="$(distdir)" \
+	  module-dist-hook
 
 rpms-real: @PACKAGE_TARNAME at .spec dist Makefile
 	rpmbuild -ta $(distdir).tar.gz
@@ -642,6 +650,8 @@ srpm:
 		echo "Finished srpms in $$subdir";			\
 	done;								\
 	$(MAKE) $(AM_MAKEFLAGS) srpm-real
+
+module-dist-hook:
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/ldiskfs/build/autoMakefile.am.toplevel b/ldiskfs/build/autoMakefile.am.toplevel
index aa19a1e..5df429d 100644
--- a/ldiskfs/build/autoMakefile.am.toplevel
+++ b/ldiskfs/build/autoMakefile.am.toplevel
@@ -64,7 +64,11 @@ dist-hook:
 	find $(distdir) -name .deps -o \
 			-name CVS -o \
 			-name .svn -o \
+			-name .git -o \
 			-name .#* | xargs rm -rf
+	$(MAKE) $(AM_MAKEFLAGS) \
+	  top_distdir="$(top_distdir)" distdir="$(distdir)" \
+	  module-dist-hook
 
 EXTRA_DIST = @PACKAGE_TARNAME at .spec					\
 	build/Makefile build/autoMakefile.am.toplevel build/lbuild	\
diff --git a/ldiskfs/build/autoconf/lustre-build-linux.m4 b/ldiskfs/build/autoconf/lustre-build-linux.m4
index 71ee36c..bb92895 100644
--- a/ldiskfs/build/autoconf/lustre-build-linux.m4
+++ b/ldiskfs/build/autoconf/lustre-build-linux.m4
@@ -104,29 +104,18 @@ AC_MSG_CHECKING([that RedHat kernel])
 LB_LINUX_TRY_COMPILE([
 		#include <linux/version.h>
 	],[
-		#ifndef RHEL_MAJOR
+		#ifndef RHEL_RELEASE_CODE
 		#error "not redhat kernel"
 		#endif
 	],[
 		RHEL_KENEL="yes"
+		RHEL_KERNEL="yes"
 		AC_MSG_RESULT([yes])
 	],[
-		AC_MSG_RESULT([no])
+	        AC_MSG_RESULT([no])
 ])
 
-AC_MSG_CHECKING([that SuSe kernel])
-LB_LINUX_TRY_COMPILE([
-		#include <linux/version.h>
-	],[
-		#ifndef SLE_VERSION_CODE
-		#error "not sles kernel"
-		#endif
-	],[
-		SUSE_KERNEL="yes"
-		AC_MSG_RESULT([yes])
-	],[
-		AC_MSG_RESULT([no])
-])
+LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
 
 ])
 
@@ -141,7 +130,13 @@ AC_DEFUN([LB_LINUX_PATH],
 AC_ARG_WITH([linux],
 	AC_HELP_STRING([--with-linux=path],
 		       [set path to Linux source (default=/usr/src/linux)]),
-	[LINUX=$with_linux],
+	[
+		if ! [[[ $with_linux = /* ]]]; then
+			AC_MSG_ERROR([You must provide an absolute pathname to the --with-linux= option.])
+		else
+			LINUX=$with_linux
+		fi
+	],
 	[LINUX=/usr/src/linux])
 AC_MSG_RESULT([$LINUX])
 AC_SUBST(LINUX)
@@ -186,9 +181,9 @@ LB_CHECK_FILE([$LINUX_CONFIG],[],
 # at 2.6.19 # $LINUX/include/linux/config.h is removed
 # and at more old has only one line
 # include <autoconf.h>
-LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
-		$LINUX_OBJ/include/linux/version.h
-		],[],
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[],
+	[AC_MSG_ERROR([Run make config in $LINUX.])])
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
 	[AC_MSG_ERROR([Run make config in $LINUX.])])
 
 # ------------ rhconfig.h includes runtime-generated bits --
@@ -299,7 +294,7 @@ if test -e $LINUX/include/asm-um ; then
 		UML_CFLAGS='-O0'
 		AC_MSG_RESULT(yes)
     	else
-		AC_MSG_RESULT([no (asm doesn't point at asm-um)])
+		AC_MSG_RESULT([no])
 	fi
 else
 	AC_MSG_RESULT([no (asm-um missing)])
@@ -361,7 +356,7 @@ AC_DEFUN([LB_LINUX_ARCH],
          [AC_MSG_CHECKING([Linux kernel architecture])
           AS_IF([rm -f $PWD/build/arch
                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
-                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX_OBJ $ARCH_UM \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
                 [AC_MSG_RESULT([$LINUX_ARCH])],
                 [AC_MSG_ERROR([Could not determine the kernel architecture.])])
@@ -453,6 +448,72 @@ fi
 ])
 
 #
+# LB_CONFIG_OFED_BACKPORTS
+#
+# include any OFED backport headers in all compile commands
+# NOTE: this does only include the backport paths, not the OFED headers
+#       adding the OFED headers is done in the lnet portion
+AC_DEFUN([LB_CONFIG_OFED_BACKPORTS],
+[AC_MSG_CHECKING([whether to use any OFED backport headers])
+# set default
+AC_ARG_WITH([o2ib],
+	AC_HELP_STRING([--with-o2ib=path],
+	               [build o2iblnd against path]),
+	[
+		case $with_o2ib in
+		yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+			ENABLEO2IB=2
+			;;
+		no)     ENABLEO2IB=0
+			;;
+		*)      O2IBPATHS=$with_o2ib
+			ENABLEO2IB=3
+			;;
+		esac
+	],[
+		O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+		ENABLEO2IB=1
+	])
+if test $ENABLEO2IB -eq 0; then
+	AC_MSG_RESULT([no])
+else
+	o2ib_found=false
+	for O2IBPATH in $O2IBPATHS; do
+		if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+			o2ib_found=true
+			break
+		fi
+	done
+	if ! $o2ib_found; then
+		AC_MSG_RESULT([no])
+		case $ENABLEO2IB in
+			1) ;;
+			2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
+			3) AC_MSG_ERROR([bad --with-o2ib path]);;
+			*) AC_MSG_ERROR([internal error]);;
+		esac
+	else
+                if test -f $O2IBPATH/config.mk; then
+			. $O2IBPATH/config.mk
+                elif test -f $O2IBPATH/ofed_patch.mk; then
+			. $O2IBPATH/ofed_patch.mk
+		fi
+		if test -n "$BACKPORT_INCLUDES"; then
+			OFED_BACKPORT_PATH=`echo $BACKPORT_INCLUDES | sed "s#.*/src/ofa_kernel/#$O2IBPATH/#"`
+			EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
+			AC_MSG_RESULT([yes])
+		else
+			AC_MSG_RESULT([no])
+                fi
+	fi
+fi
+])
+
+
+#
 # LB_PROG_LINUX
 #
 # linux tests
@@ -462,11 +523,6 @@ AC_DEFUN([LB_PROG_LINUX],
 LB_LINUX_ARCH
 LB_LINUX_SYMVERFILE
 
-#if test $LINUX_ARCH == "powerpc64"; then
-#	AC_MSG_WARN([set compiler with -m64])
-#	CFLAGS="$CFLAGS -m64"
-#	CC="$CC -m64"
-#fi
 
 LB_LINUX_CONFIG([MODULES],[],[
 	AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
@@ -474,10 +530,6 @@ LB_LINUX_CONFIG([MODULES],[],[
 
 LB_LINUX_CONFIG([MODVERSIONS])
 
-LB_LINUX_CONFIG([PREEMPT],[
-	AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
-])
-
 LB_LINUX_CONFIG([KALLSYMS],[],[
 if test "x$ARCH_UM" = "x" ; then
 	AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
@@ -492,6 +544,10 @@ LB_LINUX_CONFIG([KMOD],[],[
 
 #LB_LINUX_CONFIG_BIG_STACK
 
+# it's ugly to be doing anything with OFED outside of the lnet module, but
+# this has to be done here so that the backports path is set before all of
+# the LN_PROG_LINUX checks are done
+LB_CONFIG_OFED_BACKPORTS
 ])
 
 #
@@ -515,7 +571,7 @@ AC_DEFUN([LB_LINUX_CONDITIONALS],
 # 2.6 based kernels - put modversion info into $LINUX/Module.modvers
 # or check
 AC_DEFUN([LB_CHECK_SYMBOL_EXPORT],
-[AC_MSG_CHECKING([if Linux was built with symbol $1 is exported])
+[AC_MSG_CHECKING([if Linux was built with symbol $1 exported])
 grep -q -E '[[[:space:]]]$1[[[:space:]]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -540,3 +596,18 @@ else
     $3
 fi
 ])
+
+#
+# Like AC_CHECK_HEADER but checks for a kernel-space header
+#
+m4_define([LB_CHECK_LINUX_HEADER],
+[AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
+AC_CACHE_CHECK([for $1], ac_Header,
+	       [LB_LINUX_COMPILE_IFELSE([LB_LANG_PROGRAM([@%:@include <$1>])],
+				  [modules],
+				  [test -s build/conftest.o],
+				  [AS_VAR_SET(ac_Header, [yes])],
+				  [AS_VAR_SET(ac_Header, [no])])])
+AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
+AS_VAR_POPDEF([ac_Header])dnl
+])
diff --git a/ldiskfs/build/autoconf/lustre-build.m4 b/ldiskfs/build/autoconf/lustre-build.m4
index 73707bb..f2d9b0a 100644
--- a/ldiskfs/build/autoconf/lustre-build.m4
+++ b/ldiskfs/build/autoconf/lustre-build.m4
@@ -45,19 +45,6 @@ AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([lb_File])dnl
 ])# LB_CHECK_FILE
 
-#
-# LB_CHECK_FILES
-#
-# LB_CHECK_FILE over multiple files
-#
-AC_DEFUN([LB_CHECK_FILES],
-[AC_FOREACH([AC_FILE_NAME], [$1],
-  [LB_CHECK_FILE(AC_FILE_NAME,
-                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
-                                    [Define to 1 if you have the
-                                     file `]AC_File['.])
-$2],
-                 [$3])])])
 
 #
 # LB_ARG_LIBS_INCLUDES
@@ -240,6 +227,10 @@ AC_SUBST(LDISKFS_DIR)
 AC_SUBST(LDISKFS_SUBDIR)
 AM_CONDITIONAL(LDISKFS_ENABLED, test x$with_ldiskfs != xno)
 
+if test x$enable_ext4 = xyes ; then
+	AC_DEFINE(HAVE_EXT4_LDISKFS, 1, [build ext4 based ldiskfs])
+fi
+
 # We have to configure even if we don't build here for make dist to work
 AC_CONFIG_SUBDIRS(ldiskfs)
 ])
@@ -273,6 +264,131 @@ AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
 	AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
 	AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1, [enable extented attributes for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1, [enable fs security for ldiskfs])
+	AC_DEFINE(CONFIG_LDISKFS_FS_NFS4ACL, 1, [enable fs security for ldiskfs])
+
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
+])
+
+#
+# LB_DEFINE_E2FSPROGS_NAMES
+#
+# Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
+#
+AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
+[AC_ARG_WITH([ldiskfsprogs],
+        AC_HELP_STRING([--with-ldiskfsprogs],
+                       [use alternate names for ldiskfs-enabled e2fsprogs]),
+	[],[withval='no'])
+
+if test x$withval = xyes ; then
+	AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
+	E2FSPROGS="ldiskfsprogs"
+	MKE2FS="mkfs.ldiskfs"
+	DEBUGFS="debug.ldiskfs"
+	TUNE2FS="tune.ldiskfs"
+	E2LABEL="label.ldiskfs"
+	DUMPE2FS="dump.ldiskfs"
+	E2FSCK="fsck.ldiskfs"
+	AC_MSG_RESULT([enabled])
+else
+	E2FSPROGS="e2fsprogs"
+	MKE2FS="mke2fs"
+	DEBUGFS="debugfs"
+	TUNE2FS="tune2fs"
+	E2LABEL="e2label"
+	DUMPE2FS="dumpe2fs"
+	E2FSCK="e2fsck"
+	AC_MSG_RESULT([disabled])
+fi
+	AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
+	AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
+	AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
+	AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
+	AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
+	AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
+	AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
 ])
 
 #
@@ -408,11 +524,11 @@ if test x$dmu_osd = xyes; then
 
 		AC_SUBST(spl_src)
 
-		LB_CHECK_FILE([$SPL_DIR/modules/spl/spl-generic.c],[],[
+		LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
 			AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
 		])
 
-		LB_CHECK_FILE([$ZFS_DIR/zfs/lib/libzpool/dmu.c],[],[
+		LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
 			AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
 		])
 
@@ -560,7 +676,7 @@ AC_SUBST(ENABLE_INIT_SCRIPTS)
 #
 AC_DEFUN([LB_CONFIG_HEADERS],
 [AC_CONFIG_HEADERS([config.h])
-CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
+CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
 AC_SUBST(EXTRA_KCFLAGS)
 ])
@@ -648,7 +764,7 @@ if test $target_cpu == "powerpc64"; then
 	CC="$CC -m64"
 fi
 
-CPPFLAGS="-I\$(top_builddir)/$LIBCFS_INCLUDE_DIR -I\$(top_srcdir)/$LIBCFS_INCLUDE_DIR-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
+CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
 
 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
 AC_SUBST(LLCPPFLAGS)
@@ -746,12 +862,20 @@ LC_QUOTA
 
 LB_CONFIG_MODULES
 
+LN_CONFIG_USERSPACE
+
 LB_PATH_DMU
 LB_PATH_LIBSYSIO
 LB_PATH_SNMP
 LB_PATH_LDISKFS
 LB_PATH_LUSTREIOKIT
 
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
+LB_DEFINE_E2FSPROGS_NAMES
+
 LC_CONFIG_LIBLUSTRE
 LIBCFS_CONFIGURE
 LN_CONFIGURE
diff --git a/ldiskfs/build/lbuild b/ldiskfs/build/lbuild
index 2d008a0..01ea463 100755
--- a/ldiskfs/build/lbuild
+++ b/ldiskfs/build/lbuild
@@ -3,6 +3,7 @@
 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
 
 #set -x
+shopt -s extdebug
 
 TOPDIR=$PWD
 
@@ -11,8 +12,12 @@ KERNELDIR=
 LINUX=
 LUSTRE=
 RELEASE=false
-DO_SRC=0
-DOWNLOAD=1
+# XXX - some recent hacking has pretty much neutered this option.
+#       search through this file (and lbuild.old_school -- but that will
+#       be going away soon) for "-bb" and see how many places
+#       simply don't account for this option
+DO_SRC=true
+DOWNLOAD=true
 TAG=
 CANONICAL_TARGET=
 TARGET=
@@ -27,39 +32,27 @@ LUSTRE_EXTRA_VERSION=
 STAGEDIR=
 TMPDIR=${TMPDIR:-"/var/tmp"}
 TIMESTAMP=
+# XXX - i think these two parameters/arguments/variables need to be
+#       cleaned up and merged.  they effectively do the same thing
 REUSERPM=
 REUSEBUILD=
+# what does this do exactly?  does it imply no kernel build?
 NORPM=false
 LDISKFSRPM=true
 SKIPLDISKFSRPM="v1_4_* b1_4"
 SMPTYPES="smp bigsmp default ''"
-KERNCONFSMPTYPE=
 PATCHLESS=false
+XEN=false
 LINUXOBJ=
-REUSEDKERNELMASK=
 DISTRO=
 KERNELTREE=
 
 # patchless build
 KERNELRPMSBASE=
-KERNELRPM=
-KERNELSOURCERPM=
 RPMSMPTYPE=
-KERNELRPMCONFIG=
-KERNELRPMRELEASE=
-KERNELCOMPILEDIR=
 
 # from target file
-KERNEL=
 SERIES=
-CONFIG=
-VERSION=
-
-RHBUILD=0
-SUSEBUILD=0
-LINUX26=0
-SUSEBUILD=0
-
 BASE_ARCHS=
 BIGMEM_ARCHS=
 BOOT_ARCHS=
@@ -69,11 +62,16 @@ BIGSMP_ARCHS=
 PSERIES64_ARCHS=
 UP_ARCHS=
 
+# not in the target file any more
+CONFIG=
+
 DATE=$(date)
 
 USE_DATESTAMP=1
 RPMBUILD=
 
+OLD_SCHOOL=false
+
 export CC=${CC:-gcc}
 
 # Readlink is not present on some older distributions: emulate it.
@@ -88,35 +86,27 @@ readlink() {
     fi
 }
 
-cleanup()
-{
+cleanup() {
+
     true
 }
 
-error()
-{
-    [ "$1" ] && echo -e "\n${0##*/}: $1"
+error() {
+    local msg="$1"
+
+    [ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&2
+
 }
 
-fatal()
-{
+fatal() {
+
     cleanup
     error "$2"
     exit $1
-}
 
-list_targets()
-{
-    echo -n "Available targets:"
-    for target in $TOPDIR/lustre/lustre/kernel_patches/targets/*.target ; do
-        target_file=${target##*/}
-        echo -n " ${target_file%%.target}"
-    done
-    echo
 }
 
-usage()
-{
+usage() {
     cat <<EOF
 Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
 
@@ -133,10 +123,6 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
   --extraversion=EXTRAVERSION
     Text to use for the rpm release and kernel extraversion.
 
-  --kerneldir=KERNELDIR
-    Directory containing Linux source tarballs referenced by target
-    files.
-
   --timestamp=TIMESTAMP
     Date of building lustre in format YYYYMMDDhhmmss
 
@@ -161,11 +147,15 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
   --distro=DISTRO
     Which distro using. Autodetect by default
 
+  --kerneldir=KERNELDIR
+    Directory containing Linux source tarballs referenced by target
+    files.
+
   --kerneltree=KERNELTREE
     Directory containing dirs with Linux source tarballs referenced by target
     files. Dir names in format kernel version ('2.6.9', etc.)
 
-  --linux=LINUX
+  --linux=LINUX --with-linux=LINUX
     Directory of Linux kernel sources.  When this option is used, only
     Lustre modules and userspace are built.
 
@@ -216,10 +206,13 @@ Usage: ${0##*/} [OPTION]... [-- <lustre configure options>]
     will be built - there will be no lustre-lite-utils package.
 
   --disable-datestamp
-    Prevents the datestamp flag (-D) from being passed to cvs for 
-    checkouts. This is a workaround for a problem encountered when 
+    Prevents the datestamp flag (-D) from being passed to cvs for
+    checkouts. This is a workaround for a problem encountered when
     using lbuild with tinderbox.
 
+  --xen
+    Builds a Xen domX kernel.
+
 EOF
 
 #   list_targets
@@ -227,9 +220,25 @@ EOF
     fatal "$1" "$2"
 }
 
-check_options()
-{
-    if [ "$LUSTRE" ] ; then
+# canonicalize a relative path
+canon_path() {
+    local PATH="$1"
+
+    if [ ! -d "$PATH" ]; then
+        return 1
+    fi
+
+    pushd "$PATH" >/dev/null || return 1
+    local CANONPATH=$PWD
+    popd >/dev/null
+
+    echo "$CANONPATH"
+    return 0
+}
+
+check_options() {
+
+    if [ "$LUSTRE" ]; then
         [ -r "$LUSTRE" ] || \
             usage 1 "Could not find Lustre source tarball '$LUSTRE'."
     else
@@ -239,7 +248,7 @@ check_options()
             usage 1 "A branch/tag name must be specified with --tag when not building from a tarball."
     fi
 
-    if [ -z "$LINUX" ] ; then
+    if [ -z "$LINUX" ]; then
         [ "$KERNELDIR" -o "$KERNELTREE" ] || \
             usage 1 "A kernel directory must be specified with --kerneldir or --kerneltree."
 
@@ -270,6 +279,9 @@ check_options()
         2.6-sles10)
             CANONICAL_TARGET="sles10-2.6"
             ;;
+        2.6-sles11)
+            CANONICAL_TARGET="sles11"
+            ;;
         hp_pnnl-2.4)
             CANONICAL_TARGET="hp-pnnl-2.4"
             ;;
@@ -299,189 +311,178 @@ check_options()
             usage 1 "Could not find binary for making rpms (tried rpmbuild and rpm)."
         fi
     fi
-    
-    if [ -n "$CCACHE" ]; then 
-        which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
+
+    if [ -n "$CCACHE" ]; then
         which "$DISTCC" 2>/dev/null && export DISTCC RPM_BUILD_NCPUS
-        local bindir="/cache/build/bin"
-        [ -d $bindir ] || mkdir -p $bindir
-        [ -d $bindir ] && rm ${bindir}/* > /dev/null 2>&1
-        which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/ccache
-        which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/cc
-        which "$CCACHE" 2>/dev/null && [ -d $bindir ] && ln -s `which "$CCACHE"` ${bindir}/gcc
-        [ -d $bindir ] && export PATH=$bindir:$PATH
+
+        if which "$CCACHE" 2>/dev/null; then
+            local ccache=$(which "$CCACHE")
+            local bindir="$TOPDIR/bin"
+
+            [ -d $bindir ] || mkdir -p $bindir
+            if [ -d $bindir ]; then
+                rm ${bindir}/* > /dev/null 2>&1
+                ln -s "$ccache" ${bindir}/ccache
+                ln -s "$ccache" ${bindir}/cc
+                ln -s "$ccache" ${bindir}/$CC
+                export PATH=$bindir:$PATH
+            fi
+            export CCACHE && export CC="ccache $CC"
+            # zero the cache so we can see how effective we are being with it
+            ccache -z
+        fi
     fi
 
-    [ -z "$DISTRO" ] && autodetect_distro
+    [ -z "$DISTRO" ] && DISTRO=$(autodetect_distro)
 }
 
-#autodetect used Distro
-autodetect_distro()
-{
+# autodetect used Distro
+autodetect_distro() {
+
+    local name
+    local version
+
     if [ -f /etc/SuSE-release ]; then
-        DISTRO=sles10
+        name=sles
+        version=$(grep ^VERSION /etc/SuSE-release)
+        version=${version#*= }
     elif [ -f /etc/redhat-release ]; then
-        local distroname=$(head -1 /etc/redhat-release | grep -e "CentOS\|Red")
-        if [ ! "$distroname" = "" ]; then
-            local version=$(echo "$distroname" | sed -e s/[^0-9.]*//g | sed -e s/\\..*// )
-            distroname="rhel"
-            [ "$version" = "" ] || DISTRO="${distroname}${version}"
-        fi
+        name=$(head -1 /etc/redhat-release)
+        version=$(echo "$distroname" |
+                  sed -e 's/^[^0-9.]*//g' | sed -e 's/[ \.].*//')
+    fi
+    if [ -z "$name" -o -z "$version" ]; then
+        fatal 1 "I don't know how to determine distro type/version.\n" \
+                "Either update autodetect_distro() or use the --distro argument"
     fi
-    [ "$DISTRO" = "" ] && DISTRO="sles9" #default distro
-}
 
-uniqify()
-{
-    echo $(echo "$*" | xargs -n 1 | sort -u)
+    echo ${name}${version}
+    return 0
+
 }
 
-build_tarball() {
-    local TARGET=$1
-    local SRPM=$2
-
-    if [ "$TARGET" = "rhel-2.6" -o "$TARGET" = "rhel-2.4" ]; then
-        local SPEC=""
-        if [ "$TARGET" = "rhel-2.6" ]; then
-            SPEC=kernel-2.6.spec
-            OLDCONFIG=nonint_oldconfig
-        elif [ "$TARGET" = "rhel-2.4" ]; then
-            SPEC=kernel-2.4.spec
-            OLDCONFIG=oldconfig
-        fi
+uniqify() {
+
+    echo $(echo "$*" | xargs -n 1 | sort -u)
 
-        RPMTOPDIR=$(mktemp -d $KERNELDIR/rpm_XXXXXX)
-        mkdir $RPMTOPDIR/BUILD/
-        rpm -ivh $KERNELDIR/$SRPM --define "_topdir $RPMTOPDIR" || \
-            { rm -rf $RPMTOPDIR; fatal 1 "Error installing kernel SRPM."; }
-        $RPMBUILD -bp --nodeps --target i686 $RPMTOPDIR/SPECS/$SPEC --define "_topdir $RPMTOPDIR"
-        pushd $RPMTOPDIR/BUILD/kernel-${lnxmaj}/linux-${lnxmaj} && {
-            make mrproper
-            cp configs/kernel-${lnxmaj}-i686-smp.config .config
-            if ! make $OLDCONFIG > /dev/null; then
-                fatal 1 "error trying to make $OLDCONFIG while building a tarball from SRPM."
-            fi
-            make include/linux/version.h 
-            rm -f .config
-            cd ..
-            tar cjf $KERNEL_FILE linux-${lnxmaj}
-        }
-        popd
-        rm -rf $RPMTOPDIR
-    fi
 }
 
-download_and_build_tarball() {
+download_srpm() {
     local target=$1
-    local kernel_file=$2
+    local srpm=$2
+    local force="${3:-false}"
+
+    if $force || [ ! -r "$KERNELDIR/$srpm" ] ||
+       [ ! -s "$KERNELDIR/$srpm" ]; then
+        if $DOWNLOAD; then
+            local location="http://downloads.lustre.org/public/kernels/$target/old"
+            echo "Downloading $location/$srpm..."
+            if ! wget -nv "$location/$srpm" -O "$KERNELDIR/$srpm" ||
+               [ ! -s "$KERNELDIR/$srpm" ]; then
+                rm -f $KERNELDIR/$srpm
+                fatal 1 "Could not download target $target's kernel SRPM" \
+                        "$srpm from $location."
+            fi
+        else
+            fatal 1 "$srpm not found in directory $KERNELDIR."
+        fi
+    fi
 
-    local srpm=kernel-${lnxmaj}-${lnxrel}.src.rpm
+}
 
-    echo "Downloading http://downloads.lustre.org/public/kernels/$target/old/$srpm..."
-    if ! wget -nv "http://downloads.lustre.org/public/kernels/$target/old/$srpm" \
-        -O "$KERNELDIR/$srpm" ; then
-        fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
+download_ofed() {
+    local force="${1:-false}"
+
+    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ] &&
+       ( $force || [ ! -r "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ] ||
+           [ ! -s "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ] ); then
+        if $DOWNLOAD; then
+            local location="http://downloads.lustre.org/public/OFED/"
+            echo "Downloading $location/OFED-${OFED_VERSION}.tgz..."
+            if ! wget -nv "$location/OFED-${OFED_VERSION}.tgz" \
+                -O "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ||
+               [ ! -s "$KERNELTREE/OFED-${OFED_VERSION}.tgz" ]; then
+                rm -f $KERNELTREE/OFED-${OFED_VERSION}.tgz
+                fatal 1 "Could not download OFED-${OFED_VERSION}.tgz" \
+                        "from downloads.lustre.org."
+            fi
+        else
+            fatal 1 "OFED-${OFED_VERSION}.tgz not found in kernel" \
+                    "directory $KERNELTREE."
+        fi
     fi
-    [ -s "$KERNELDIR/$srpm" ] || {
-        rm -rf $KERNELDIR/$srpm
-        fatal 1 "Could not download target $kernel_file's kernel SRPM $srpm from downloads.lustre.org."
-    }
 
-    build_tarball $target $srpm
 }
 
-load_target()
-{
+load_target() {
+
     EXTRA_VERSION_save="$EXTRA_VERSION"
-    for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
+    for patchesdir in "$EXTERNAL_PATCHES" \
+                      "$TOPDIR/lustre/lustre/kernel_patches"; do
         TARGET_FILE="$patchesdir/targets/$TARGET.target"
         [ -r "$TARGET_FILE" ] && break
     done
-    [ -r "$TARGET_FILE" ] || \
-        fatal 1 "Target $TARGET was not found."
+    [ -r "$TARGET_FILE" ] || fatal 1 "Target $TARGET was not found."
 
-    echo "Loading target config file $TARGET.target..."        
+    echo "Loading target config file $TARGET.target..."
 
     . "$TARGET_FILE"
 
-    [ "$KERNEL"  ] || fatal 1 "Target $TARGET did not specify a kernel."
-    [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify a kernel version."
+    # doesn't make any sense to build OFED for xen domX's
+    if $XEN; then
+        OFED_VERSION=""
+    fi
+
+    # XXX - set_rpm_smp_type is an ugly undeterministic hack.  it needs to
+    #       go away and the target just specify the $RPMSMPTYPE
+    [ -z "$RPMSMPTYPE" ] && set_rpm_smp_type
 
-    #CC was overwriten in TARGET_FILE
-    which "$CCACHE" 2>/dev/null && export CCACHE && export CC="ccache gcc"
+    # CC might have been overwriten in TARGET_FILE
+    if [[ $CC != ccache\ * ]] && which "$CCACHE" 2>/dev/null; then
+        export CCACHE && export CC="ccache $CC"
+    fi
 
     if [ ! "$KERNELTREE" = "" ] && [ -d "$KERNELTREE" ]; then
         KERNELDIR="$KERNELTREE/${lnxmaj}"
         [ -d "$KERNELDIR" ] || mkdir "$KERNELDIR"
     fi
 
-    if [ "$KERNELDIR" ] ; then
-        KERNEL_FILE="$KERNELDIR/$KERNEL"
-        if [ ! -r "$KERNEL_FILE" ] ; then
-            # see if we have an SRPM we can build a tarball for
-            KERNEL_SRPM=kernel-${lnxmaj}-${lnxrel}.src.rpm
-            if [ -r "$KERNELDIR/$KERNEL_SRPM" ] ; then
-                build_tarball $CANONICAL_TARGET $KERNEL_SRPM
-            else
-                if (( $DOWNLOAD )) ; then
-                    echo "Downloading http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL..."
-                    if ! wget -nv "http://downloads.lustre.org/public/kernels/$DISTRO/old/$KERNEL" -O "$KERNELDIR/$KERNEL" ; then
-                        # see if we can do it with an SRPM from the download site
-                        download_and_build_tarball $CANONICAL_TARGET $KERNEL_FILE
-                    else
-                        [ -s "$KERNELDIR/$KERNEL" ] || {
-                            rm -rf "$KERNELDIR/$KERNEL"
-                            fatal 1 "Target $TARGET's kernel $KERNEL not found in directory $KERNELDIR."
-                        }
-                    fi
-                else
-                    fatal 1 "Target $TARGET's kernel file $KERNEL not found in kernel directory $KERNELDIR."
-                fi
-            fi
-        fi
-        if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ] && \
-           [ ! -r "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ] ; then
-            if (( $DOWNLOAD )) ; then
-                local location="http://downloads.lustre.org/public/OFED/"
-                echo "Downloading $location/OFED-${OFED_VERSION}.tgz..."
-                if ! wget -nv "$location/OFED-${OFED_VERSION}.tgz" \
-                    -O "$KERNELTREE/../OFED-${OFED_VERSION}.tgz" ; then
-                    fatal 1 "Could not download OFED-${OFED_VERSION}.tgz from downloads.lustre.org."
-                fi
-            else
-                fatal 1 "OFED-${OFED_VERSION}.tgz not found in kernel directory $KERNELDIR."
-            fi
-        fi
-    fi
-
-    if [ "$SERIES" ] ; then
-        for series in $SERIES ; do
-            for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
+    # verify the series is available
+    if [ "$SERIES" ]; then
+        for series in $SERIES; do
+            for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
                 [ -r "$patchesdir/series/$series" ] && continue 2
             done
-            fatal 1 "Target $TARGET's series $SERIES could not be found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n\t$TOPDIR/lustre/lustre/kernel_patches/series."
+            fatal 1 "Target $TARGET's series $SERIES could not be" \
+                    "found.\nSearched:\n\t$EXTERNAL_PATCHES/series\n" \
+                    "\t$TOPDIR/lustre/lustre/kernel_patches/series."
         done
     fi
 
-    if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
-        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config"
+    # set the location of the .config file
+    local XENPOSTFIX=""
+    if $XEN; then
+        XENPOSTFIX="-xen"
     fi
-    local smptype
-    for smptype in $SMPTYPES; do
-        [ "$smptype" = "''" ] && smptype=
-        if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config ]; then
-        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH-${smptype}.config"
-        KERNCONFSMPTYPE=$smptype
+
+    if [ -f $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET-$TARGET_ARCH.config ]; then
+        CONFIG_FILE="$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/kernel-$lnxmaj-$TARGET$XENPOSTFIX-$TARGET_ARCH${RPMSMPTYPE:+-}${RPMSMPTYPE}.config"
     fi
-    done
 
     local lnxrelnew=${lnxrel//-/_}
 
+    # remember the EXTRA_VERSION before we diddle it here
+    # XXX - we really should not diddle with any values read in from the
+    #       target file.  if we want to modify a value, we should create
+    #       a new variable.
+    PRISTINE_EXTRA_VERSION=$EXTRA_VERSION
+
     if ! $PATCHLESS && [ ! -f "$CONFIG_FILE" ]; then
-        fatal 1 "Config file for target $TARGET missing from $TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
+        fatal 1 "Config file for target $TARGET missing from" \
+                "$TOPDIR/lustre/lustre/kernel_patches/kernel_configs/."
     fi
 
-    if [ "$EXTRA_VERSION_save" ] ; then
+    if [ "$EXTRA_VERSION_save" ]; then
         EXTRA_VERSION="$EXTRA_VERSION_save"
     elif ! $RELEASE; then
         # if there is no patch series, then this is not a lustre specific
@@ -495,22 +496,12 @@ load_target()
     fi
     # EXTRA_VERSION=${EXTRA_VERSION//-/_}
 
-    [ -z $REUSEDKERNELMASK ] && \
-        # create mask for kernel RPM/builddir which could be reused
-        if $NORPM; then
-            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.*${TARGET_ARCH}
-        elif $RELEASE; then
-            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TARGET_ARCH}
-        else
-            REUSEDKERNELMASK=${KERNCONFSMPTYPE}-${lnxmaj}-${lnxrelnew}_lustre.${LUSTRE_VERSION}.${TIMESTAMP}.${TARGET_ARCH}
-        fi
-        # kernel-lustre-smp-2.6.9-55.0.2.EL_lustre.1.6.1.i686.rpm 
-
     ALL_ARCHS="$BASE_ARCHS $BIGMEM_ARCHS $BOOT_ARCHS $JENSEN_ARCHS $SMP_ARCHS $BIGSMP_ARCHS $PSERIES64_ARCHS $UP_ARCHS"
 
     BUILD_ARCHS=
-    for arch in $(uniqify "$ALL_ARCHS") ; do
-        if [ -z "$TARGET_ARCHS" ] || echo "$TARGET_ARCHS" | grep -w "$arch" >/dev/null 2>/dev/null ; then
+    for arch in $(uniqify "$ALL_ARCHS"); do
+        if [ -z "$TARGET_ARCHS" ] ||
+           [[ \ $TARGET_ARCHS\  = *\ $arch\ * ]]; then
             BUILD_ARCHS="$BUILD_ARCHS $arch"
         fi
     done
@@ -518,9 +509,10 @@ load_target()
     echo "Building for: $BUILD_ARCHS"
 }
 
-tarflags()
-{
-    case "$1" in
+tarflags() {
+    local file="$1"
+
+    case "$file" in
         '')
             fatal 1 "tarflags(): File name argument missing."
             ;;
@@ -537,35 +529,36 @@ tarflags()
             fatal 1 "tarflags(): Unrecognized tar extension in file: $1"
             ;;
     esac
+
 }
 
-untar()
-{
-    echo "Untarring ${1##*/}..."
-    tar $(tarflags "$1") "$1"
+untar() {
+    local file="$1"
+
+    echo "Untarring ${file##*/}..."
+    tar $(tarflags "$file") "$file"
+
 }
 
-unpack_ofed()
-{
-    untar "$KERNELTREE/../OFED-${OFED_VERSION}.tgz"
+unpack_ofed() {
+
+    if ! untar "$KERNELTREE/OFED-${OFED_VERSION}.tgz"; then
+        return 1
+    fi
     [ -d OFED ] || ln -sf OFED-[0-9].[0-9]* OFED
-    pwd
-    ls -ld OFED OFED-[0-9].[0-9]*
-    ls -l OFED OFED-[0-9].[0-9]*
+
 }
 
-unpack_lustre()
-{
-    DIRNAME="lustre-$TAG-$TIMESTAMP"
-    if [ "$LUSTRE" ] ; then
-        untar "$LUSTRE"
-        [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
-    else
-        if [ "$USE_DATESTAMP" ]; then
+unpack_lustre() {
+
+    if [ -z "$LUSTRE" ]; then
+        local DATESTAMP=""
+
+        if [ -n "$USE_DATESTAMP" ]; then
             DATESTAMP="-D '$DATE'"
-        else
-            DATESTAMP=""
-        fi            
+        fi
+
+        local DIRNAME="lustre-$TAG-$TIMESTAMP"
 
         cvs -d "$CVSROOT" -qz3 co $DATESTAMP -d "$DIRNAME" lustre || \
             fatal 1 "There was an error checking out toplevel Lustre from CVS."
@@ -577,201 +570,53 @@ unpack_lustre()
         ./configure --disable-{modules,utils,liblustre,tests,doc} || \
             fatal 1 "There was an error running ./configure to create makefiles."
         make dist || fatal 1 "There was an error running 'make dist'."
+        LUSTRE=$PWD/lustre-*.tar.gz
         popd > /dev/null
-        fname=$(basename $DIRNAME/lustre-*.tar.gz)
-        cp $DIRNAME/$fname . || fatal 1 "There was an error copying lustre tarball."
-        LUSTRE="$PWD/$fname"
-        ln -sf "$DIRNAME" lustre
     fi
-}
 
-unpack_linux()
-{
-    untar "$KERNEL_FILE"
-    [ -d linux ] || ln -sf linux* linux
+    untar "$LUSTRE" || fatal 1 "Error unpacking Lustre tarball"
+    [ -d lustre ] || ln -sf lustre-[0-9].[0-9]* lustre
+
 }
 
-patch_linux()
-{
-    [ "$SERIES" ] || return 0
+do_patch_linux() {
+
+    local do_patch=${1:-true}
+
     FULL_PATCH="$PWD/lustre-kernel-${TARGET}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}.patch"
     [ -f "$FULL_PATCH" ] && rm -f "$FULL_PATCH"
-    pushd linux >/dev/null
-    for series in $SERIES ; do
+    $do_patch && pushd linux >/dev/null
+    for series in $SERIES; do
         echo -n "Applying series $series:"
-        for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches" ; do
+        for patchesdir in "$EXTERNAL_PATCHES" "$TOPDIR/lustre/lustre/kernel_patches"; do
             [ -r "$patchesdir/series/$series" ] || continue
             SERIES_FILE="$patchesdir/series/$series"
-            for patch in $(<"$SERIES_FILE") ; do
+            for patch in $(<"$SERIES_FILE"); do
                 echo -n " $patch"
                 PATCH_FILE="$patchesdir/patches/$patch"
                 [ -r "$PATCH_FILE" ] || \
                     fatal 1 "Patch $patch does not exist in Lustre tree."
-                cat "$PATCH_FILE" >> "$FULL_PATCH" || \
+                cat "$PATCH_FILE" >> "$FULL_PATCH" || {
+                    rm -f $FULL_PATCH
                     fatal 1 "Error adding patch $patch to full patch."
-                patch -s -p1 < "$PATCH_FILE" || fatal 1 "Error applying patch $patch."
+                }
+                if $do_patch; then
+                    patch -s -p1 < "$PATCH_FILE" || {
+                        rm -f $FULL_PATCH
+                        fatal 1 "Error applying patch $patch."
+                    }
+                fi
             done
             break
         done
         echo
     done
-    popd >/dev/null
+    $do_patch && popd >/dev/null
     echo "Full patch has been saved in ${FULL_PATCH##*/}."
-    echo "Replacing .config files..."
-    [ -d linux/configs ] || mkdir linux/configs || \
-        fatal 1 "Error creating configs directory."
-    rm -f linux/configs/*
-    copysuccess=0
-    for patchesdir in "$EXTERNAL_PATCHES" "lustre/lustre/kernel_patches" ; do
-        [ "$patchesdir" ] && \
-            cp -v $patchesdir/kernel_configs/kernel-${VERSION}-${TARGET}*.config linux/configs/ >/dev/null && copysuccess=1
-    done
-    [ "$copysuccess" = "1" ] || \
-        fatal 1 "Error copying in kernel configs."
-}
 
-pack_linux()
-{
-    TARBALL="$(readlink linux)-$EXTRA_VERSION.tar.gz"
-    echo "Creating patched linux tarball $TARBALL..."
-    tar zcf "$TARBALL" "$(readlink linux)" \
-        --exclude "CVS" --exclude ".cvsignore" || \
-        --exclude "*.orig" --exclude "*~" --exclude "*.rej" || \
-        fatal 1 "Error creating patched Linux tarball."
 }
 
-clean_linux()
-{
-    [ -d linux ] || return 0
-    echo "Cleaning linux..."
-    [ -L linux ] && rm -rf $(readlink linux)
-    rm -rf linux
-}
-
-prep_kernel_build()
-{
-    # make .spec file
-    ENABLE_INIT_SCRIPTS=""
-    sed \
-        -e "s^@BASE_ARCHS@^$BASE_ARCHS^g" \
-        -e "s^@BIGMEM_ARCHS@^$BIGMEM_ARCHS^g" \
-        -e "s^@BIGSMP_ARCHS@^$BIGSMP_ARCHS^g" \
-        -e "s^@BOOT_ARCHS@^$BOOT_ARCHS^g" \
-        -e "s^@CONFIGURE_FLAGS@^$CONFIGURE_FLAGS^g" \
-        -e "s^@ENABLE_INIT_SCRIPTS@^$ENABLE_INIT_SCRIPTS^g" \
-        -e "s^@JENSEN_ARCHS@^$BOOT_ARCHS^g" \
-        -e "s^@KERNEL_EXTRA_VERSION@^$EXTRA_VERSION^g" \
-        -e "s^@KERNEL_EXTRA_VERSION_DELIMITER@^$EXTRA_VERSION_DELIMITER^g" \
-        -e "s^@KERNEL_TARGET_DELIMITER@^$TARGET_DELIMITER^g" \
-        -e "s^@KERNEL_RELEASE@^${EXTRA_VERSION//-/_}^g" \
-        -e "s^@KERNEL_SOURCE@^$KERNEL^g" \
-        -e "s^@KERNEL_VERSION@^$VERSION^g" \
-        -e "s^@LINUX26@^$LINUX26^g" \
-        -e "s^@LUSTRE_SOURCE@^${LUSTRE##*/}^g" \
-        -e "s^@LUSTRE_TARGET@^$TARGET^g" \
-        -e "s^@PSERIES64_ARCHS@^$PSERIES64_ARCHS^g" \
-        -e "s^@RHBUILD@^$RHBUILD^g" \
-        -e "s^@SMP_ARCHS@^$SMP_ARCHS^g" \
-        -e "s^@SUSEBUILD@^$SUSEBUILD^g" \
-        -e "s^@UP_ARCHS@^$UP_ARCHS^g" \
-        < $TOPDIR/lustre/build/lustre-kernel-2.4.spec.in \
-        > lustre-kernel-2.4.spec
-    [ -d SRPMS ] || mkdir SRPMS
-    [ -d RPMS ] || mkdir RPMS
-    [ -d BUILD ] || mkdir BUILD
-    [ -d SOURCES ] || mkdir SOURCES
-    for script in linux-{rhconfig.h,merge-config.awk,merge-modules.awk} \
-        suse-{functions.sh,post.sh,postun.sh,trigger-script.sh.in} \
-        sles8-{pre,post,postun,update_{INITRD_MODULES,rcfile_setting}}.sh ; do
-        cp $TOPDIR/lustre/build/$script SOURCES
-    done
-    cp "$LUSTRE" "$KERNEL_FILE" SOURCES
-    if [ "$EXTERNAL_PATCHES" -a -d "$EXTERNAL_PATCHES" ] ; then
-        tar zcf SOURCES/external-patches.tar.gz -C "$EXTERNAL_PATCHES" series targets patches kernel_configs
-    else
-        touch SOURCES/external-patches.tar.gz
-    fi
-}
-
-clean_lustre()
-{
-    [ -d lustre ] || return 0
-    echo "Cleaning Lustre..."
-    [ -L lustre ] && rm -rf $(readlink lustre)
-    rm -rf lustre
-}
-
-build_kernel()
-{
-    echo "Building kernel + Lustre RPMs for: $BUILD_ARCHS..."
-    targets=
-    for arch in $BUILD_ARCHS ; do
-        targets="--target $arch $targets"
-    done
-
-    local rpmbuildopt='-bb'
-#    if $NORPM; then
-#        rpmbuildopt='-bc'
-#        echo NORPM mode. Only compiling.
-#        echo "XXX: need to fix lmake - add options to do rpmbuild -bc instead of -bb"
-#    fi
-
-    $RPMBUILD $targets $rpmbuildopt lustre-kernel-2.4.spec \
-        --define "_tmppath $TMPDIR" \
-        --define "_topdir $TOPDIR" || \
-        fatal 1 "Error building rpms for $BUILD_ARCHS."
-
-    if (( $DO_SRC )) ; then
-        $RPMBUILD -bs lustre-kernel-2.4.spec \
-            --define "_tmppath $TMPDIR" \
-            --define "_topdir $TOPDIR" || \
-            fatal 1 "Error building .src.rpm."
-    fi
-
-    ( $(skeep_ldiskfs_rpm $TAG) ) && return
-
-    pushd $TOPDIR/BUILD/lustre*/ldiskfs || return 255
-    make dist
-    if [ "$?" != "0" ] ; then
-        popd
-        return 255
-    fi
-    cp lustre-ldiskfs*.tar.gz $TOPDIR/SOURCES
-
-    gen_lustre_version
-
-    local ldiskfs_spec=lustre-ldiskfs.spec
-    [ -f "$ldiskfs_spec" ] && sed \
-    -e "s^Release: .*$^Release: $LUSTRE_EXTRA_VERSION^" \
-    < $ldiskfs_spec \
-    > ../lustre-ldiskfs.spec
-
-    $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
-        --define "_tmppath /var/tmp" \
-        --define "_topdir $TOPDIR"
-    if [ "$?" != "0" ] ; then
-        popd
-        return 255
-    fi
-
-    if (( $DO_SRC )) ; then
-            $RPMBUILD -bs ../lustre-ldiskfs.spec \
-            --define "_tmppath /var/tmp" \
-            --define "_topdir $TOPDIR"
-        if [ "$?" != "0" ] ; then
-            popd
-            return 255
-        fi
-    fi
-    popd
-}
-
-build_lustre()
-{
-    [ -d SRPMS ] || mkdir SRPMS
-    [ -d RPMS ] || mkdir RPMS
-    [ -d BUILD ] || mkdir BUILD
-    [ -d SOURCES ] || mkdir SOURCES
+build_lustre() {
 
     cp "$LUSTRE" SOURCES
 
@@ -779,7 +624,7 @@ build_lustre()
 
     echo "Building Lustre RPMs for: $BUILD_ARCHS..."
     targets=
-    for arch in $BUILD_ARCHS ; do
+    for arch in $BUILD_ARCHS; do
         targets="--target $arch $targets"
     done
 
@@ -788,15 +633,20 @@ build_lustre()
         confoptions="--with-linux=${LINUX} --disable-server"
     fi
     if [ ! "$LINUXOBJ" = "" ]; then
-        confoptions="$confoptions --with-linux-obj=${LINUXOBJ}" 
+        confoptions="$confoptions --with-linux-obj=${LINUXOBJ}"
     fi
-    
+
     ./configure $confoptions ${CONFIGURE_FLAGS}
-    if [ "$?" != "0" ] ; then
+    if [ "$?" != "0" ]; then
         local saved_config="../config.log.$(date +%s)"
         cp config.log $saved_config
         chmod a+r $saved_config
         echo "Saved config.log is at $saved_config"
+        cat /proc/mounts
+        ls -l /proc/$$
+        pwd
+        echo "config.log contents:"
+        cat config.log
         popd
         return 255
     fi
@@ -804,7 +654,7 @@ build_lustre()
     gen_lustre_version
 
     # hack. Somebody move build/lustre.spec to lustre.spec for b1_6
-    local lustre_spec=
+    local lustre_spec
     [ -f lustre.spec ] && lustre_spec=lustre.spec
     [ -f build/lustre.spec ] && lustre_spec=build/lustre.spec
 
@@ -819,7 +669,15 @@ build_lustre()
         echo NORPM mode. Only compiling.
     fi
 
+    # convert the $PATCHLESS boolean to an empty/no-empty boolean
+    # as silly as this seems, it makes the syntax of the rpmbuild command
+    # simpler and not need an eval to deal with the quotes in the quotes 
+    local is_patchless=""
+    if $PATCHLESS; then
+        is_patchless="yes"
+    fi
     $RPMBUILD $targets $rpmbuildopt ../lustre.spec \
+        ${is_patchless:+--define "lustre_name lustre-client"} \
         --define "_tmppath $TMPDIR" \
         --define "_topdir $TOPDIR" || \
         fatal 1 "Error building rpms for $BUILD_ARCHS."
@@ -829,7 +687,7 @@ build_lustre()
 
     pushd lustre/ldiskfs || return 255
     make dist
-    if [ "$?" != "0" ] ; then
+    if [ "$?" != "0" ]; then
         popd
         return 255
     fi
@@ -846,45 +704,48 @@ build_lustre()
     $RPMBUILD $targets $rpmbuildopt ../lustre-ldiskfs.spec \
         --define "_tmppath /var/tmp" \
         --define "_topdir $TOPDIR"
-    if [ "$?" != "0" ] ; then
+    if [ "$?" != "0" ]; then
         popd
         return 255
     fi
 
-    if (( $DO_SRC )) ; then
+    if $DO_SRC; then
             $RPMBUILD -bs ../lustre-ldiskfs.spec \
             --define "_tmppath /var/tmp" \
             --define "_topdir $TOPDIR"
-        if [ "$?" != "0" ] ; then
+        if [ "$?" != "0" ]; then
             popd
             return 255
         fi
     fi
     popd
+
 }
 
-stage()
-{
+stage() {
+
     [ "$STAGEDIR" ] || return 0
 
-    for arch in $BUILD_ARCHS ; do
+    for arch in $BUILD_ARCHS; do
         rpmdir="${STAGEDIR}/${CANONICAL_TARGET}-${arch}"
         echo "${0##*/}: Copying RPMs into ${rpmdir}"
         mkdir -p "${rpmdir}"
         cp -v RPMS/${arch}/*.rpm "${rpmdir}"
-        if [ -d RPMS/noarch ] ; then
+        if [ -d RPMS/noarch ]; then
             cp -v RPMS/noarch/*.rpm "${rpmdir}"
         fi
     done
 
     cp -v "$LUSTRE" "$STAGEDIR"
+
 }
 
 #check if we need to build separate ldiskfs RPM
-skeep_ldiskfs_rpm()
-{
-        local tag=$1
+skeep_ldiskfs_rpm() {
+        local tag="$1"
+
         local skip=false
+
         if ! $LDISKFSRPM; then
             skip=true
         elif $PATCHLESS; then
@@ -894,133 +755,43 @@ skeep_ldiskfs_rpm()
                 [[ $tag == $skiptag ]] && skip=true && break
             done
         fi
-        echo $skip
-}
 
-#get date of last changed target/config/series/patches
-get_last_source_date()
-{
-    local filelist="${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} \
-        $CONFIG_FILE"
-    local TOPDIRnew=$(echo ${TOPDIR} | sed -e s/\\//\\\\\\//g)
-    filelist="$filelist $( \
-        cat ${TOPDIR}/lustre/lustre/kernel_patches/series/${SERIES} | \
-        sed -e s/^/${TOPDIRnew}\\/lustre\\/lustre\\/kernel_patches\\/patches\\// 2>&1)"
-    local sourcelastdate=$( find ${filelist} -name CVS -prune -o \
-                -type f -printf "%T@\n" 2>&1 | sort | tail -1 )
-    is_integer $sourcelastdate && echo $sourcelastdate
-}
+        pushd $TOPDIR/BUILD/lustre-[1-9]* >/dev/null
+        grep -q '^SERVER_TRUE[ \t]=[ \t]#$' autoMakefile && skip=true
+        popd >/dev/null
+
+        echo $skip
 
-#check if variable is integer
-is_integer()
-{
-    local invariable=$1
-    [ "$invariable" = "" ] && return 255
-    local invariableint=$( echo $invariable | sed -e s/[^0-9]//g )
-    [ "$invariable" = "$invariableint" ] || return 255
 }
 
 #generate LUSTRE_EXTRA_VERSION from EXTRA_VERSION
-gen_lustre_version()
-{
-    local smptype=smp
-    [ "$KERNCONFSMPTYPE" = "" ] || smptype=$KERNCONFSMPTYPE
-    [ "$RPMSMPTYPE" = "" ] || smptype=$RPMSMPTYPE
+gen_lustre_version() {
 
-    LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${smptype}"
+    LUSTRE_EXTRA_VERSION="${lnxmaj}${EXTRA_VERSION_DELIMITER}${EXTRA_VERSION}${TARGET_DELIMITER}${RPMSMPTYPE}"
     LUSTRE_EXTRA_VERSION=${LUSTRE_EXTRA_VERSION//-/_}
+
 }
 
-#store RPMs and/or BUILD dir for future reuse
-store_for_reuse()
-{
-    local rpmonly=$1
-    if [ ! "$REUSEBUILD" = "" ] && [ -d  "/$REUSEBUILD/" ] ; then
-        [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || mkdir "${REUSEBUILD}/${TIMESTAMP}"
-        [ -d "${REUSEBUILD}/${TIMESTAMP}" ] || return 255
-    else
-        return 255
-    fi
+set_rpm_smp_type() {
 
-    local lnxrelnew=${lnxrel//-/_}
-    local EXTRA_VERSIONnew=${EXTRA_VERSION//-/_}
-    local KERNELRPMnew=$(basename "$KERNELRPM")
-    if [ ! "$rpmonly" = "rpmonly" ]; then
-	    local builddir=
-        if [ ! "$KERNELCOMPILEDIR" = "" ]; then
-            builddir="$KERNELCOMPILEDIR"
-        else
-            builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}"
-	    [ "$KERNELCOMPILEDIR" = "" ] || builddir="$KERNELCOMPILEDIR"
-            [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}.${lnxrel}"
-            [ -d "$builddir" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/linux-${lnxmaj}-${lnxrel}"
-	    if [ ! -d "$builddir" ]; then
-                pushd "BUILD/lustre-kernel-${lnxmaj}/lustre/" || return 255
-                local basebuilddir=$(ls -d linux-${lnxmaj}* | head -1)
-                [ "$basebuilddir" = "" ] || builddir="BUILD/lustre-kernel-${lnxmaj}/lustre/${basebuilddir}"
-                popd
-	    fi
-        fi
-        [ -d "$builddir" ] || return 255
-	local dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}"
-	( $PATCHLESS ) && dstdir="${REUSEBUILD}/${TIMESTAMP}/linux-$KERNELRPMnew" && \
-	        dstdir="${dstdir%.rpm}"
-	[ -d "$dstdir" ] && rm -rf "$dstdir"
-        mv "${builddir}" "$dstdir" || return 255
-        if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-            # move the OFED kernel-ib-devel tree as well
-            mv "${builddir%/*}/kernel-ib-devel/usr/src/ofa_kernel" "${dstdir%/*}" || return 255
-        fi
-    fi
-    #store kernel rpm
-    local kernelrpmname="kernel-lustre-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
-    [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-${KERNCONFSMPTYPE}-${lnxmaj}-${EXTRA_VERSNnew}.${TARGET_ARCH}.rpm"
-    ( $PATCHLESS ) && [ -f "$KERNELRPM" ] && kernelrpmname="$KERNELRPMnew"
-    if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
-        echo "RPM already exist in store directory tree"
-    else
-        [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
-    fi
-    #store kernel source rpm
-    kernelrpmname="kernel-lustre-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
-    [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] || kernelrpmname="kernel-source-${lnxmaj}-${EXTRA_VERSIONnew}.${TARGET_ARCH}.rpm"
-    ( $PATCHLESS ) && [ -f "$KERNELSOURCERPM" ] && kernelrpmname=$(basename "$KERNELSOURCERPM")
-    if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${kernelrpmname}" ]; then
-        echo "RPM already exist in store directory tree"
-    else
-	    [ -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${kernelrpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
-    fi
-    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-        # store kernel-ib RPMs
-        local rpmname
-        for rpmname in "kernel-ib" "kernel-ib-devel"; do
-            rpmname="${rpmname}-${OFED_VERSION}"
-            if $PATCHLESS; then
-                rpmname="${rpmname}-${LINUXRELEASE//-/_}"
-            else
-                rpmname="${rpmname}-${lnxmaj}${EXTRA_VERSION_DELIMITER//-/_}${EXTRA_VERSIONnew}${TARGET_DELIMITER//-/_}${KERNCONFSMPTYPE}"
-            fi
-            rpmname="${rpmname}.${TARGET_ARCH}.rpm"
-            if [ "$rpmonly" = "rpmonly" ] && [ -f "${REUSEBUILD}/${TIMESTAMP}/${rpmname}" ]; then
-                echo "RPM already exist in store directory tree"
-            else
-                [ -f "RPMS/${TARGET_ARCH}/${rpmname}" ] && cp -f "RPMS/${TARGET_ARCH}/${rpmname}" "${REUSEBUILD}/${TIMESTAMP}/"
-            fi
-        done
-    fi
-}
+    local infact_arch="${TARGET_ARCH}"
 
-set_rpm_smp_type()
-{
-    local infact_arch=${TARGET_ARCH}
-    RPMSMPTYPE=default
+    RPMSMPTYPE=""
     [ "$infact_arch" == "i586" ] && infact_arch="i686"
+
+    local smp_type
     for smp_type in $SMP_ARCHS; do
         [ $infact_arch == $smp_type ] && RPMSMPTYPE=smp && break
     done
+
     for smp_type in $BIGSMP_ARCHS; do
         [ $infact_arch == $smp_type ] && RPMSMPTYPE=bigsmp && break
     done
+
+    for smp_type in $DEFAULT_ARCHS; do
+        [ $infact_arch == $smp_type ] && RPMSMPTYPE=default && break
+    done
+
 }
 
 # This function takes a linux source pool and digs out the linux release
@@ -1037,243 +808,121 @@ find_linux_release() {
 
 }
 
-#unpack kernel(/source/devel) RPM
-unpack_linux_rpm()
-{
-    local prefix=$1
+# XXX this needs to be re-written as a wrapper around find_rpm
+#     or just gotten rid of.  :-)
+find_linux_rpm() {
+    local prefix="$1"
     local delimiter=${2:-"-"}
+
     local pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
-    local kernelbinaryrpm=
     [ -d $pathtorpms ] || return 255
-    local rpmfile=
+
+    local kernelbinaryrpm rpmfile
     local wanted_kernel="${lnxmaj}${delimiter}${lnxrel}"
+
+    local arch ret=1
     for arch in $TARGET_ARCHS_ALL; do
+        local found_rpm="" rpm
         for rpm in ${pathtorpms}/${arch}/*.rpm; do
-            local provides=$(rpm -q --provides -p $rpm)
-            if (echo $provides | grep -q "kernel${prefix} = $wanted_kernel"); then
-                KERNELRPM=$rpm
+            if rpm -q --provides -p "$rpm" | grep -q "kernel${prefix} = $wanted_kernel"; then
+                found_rpm="$rpm"
+                ret=0
+                break
             fi
         done
-        [ -f "$KERNELRPM" ] && TARGET_ARCH="$arch" && BUILD_ARCHS="$arch" && break
+        [ -f "$found_rpm" ] && break
     done
 
-    # bleah
-    set_rpm_smp_type
+    echo "$found_rpm"
+    return $ret
 
-    [ -f "$KERNELRPM" ] || return 255
-    [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
-    pushd $TOPDIR/reused || return 255
-    RC=0
-    rpm2cpio < "$KERNELRPM" | cpio -idc > /dev/null 2>&1
-    if [ ${PIPESTATUS[0]} -eq 0 ]; then
-        # RHEL-style and SLES-style rpms
-        local paths="kernels/${lnxmaj}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${delimiter}${lnxrel}"
+}
 
-        for path in $paths; do
-            local src='usr/src'
+# unpack kernel(/source/devel) RPM
+#
+# This function and it's setting of $LINUX and $LINUXOBJ is a total hack that
+# needs to completely refactored.  It completely ingores that $BUILD_ARCHS may
+# contain a list of arches for which rpmbuild commands (including the one for
+# lustre itself)
+unpack_linux_devel_rpm() {
+    local kernelrpm="${1}"
+    # it's worth noting that neither sles10 nor rhel5 appear to use their
+    # extra_version delimiter for the dirname under /usr/src, so we could
+    # probably just get rid of this parameter
+    local delimiter=${2:-"-"}
 
-            if [ -d "$src/$path/" ]; then
-                LINUX="$(pwd)/$src/$path"
-            fi
-            # SLES has a separate -obj tree
-            if [ -d "$src/${path}-obj" ]; then
-                src="$src/${path}-obj"
-                local objects="$TARGET_ARCH/$RPMSMPTYPE"
-
-                # Novell, are you *TRYING* to make life hard for me?
-                if [ -d "$src/powerpc" ]; then
-                    objects="powerpc/$TARGET_ARCH"
-                elif [ $TARGET_ARCH == 'i686' ]; then
-                    objects="i386/$RPMSMPTYPE"
-                fi
+    [ -f "$kernelrpm" ] || return 255
+    [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused || return 255
 
-                LINUXOBJ="$(pwd)/$src/$objects"
-            fi
-        done
-        if [ -z "$LINUX" ]; then
-            RC=255
-        else
-            # dig out the release version
-            LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
-            if [ -z "$LINUXRELEASE" ]; then
-                echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
-                RC=255
-            fi
-        fi
-    else
-        RC=255
+    pushd $TOPDIR/reused || return 255
+
+    if ! rpm2cpio < "$kernelrpm" | cpio -id > /dev/null 2>&1; then
+        return 255
     fi
-    popd
-    return $RC
-}
 
-#look for kernel source RPM
-find_linux_source_rpm()
-{
-    local rpmfile=
-    local findarch=true
-    local arch=
-    local pathtorpms=
-    [ ! "$TARGET_ARCH" = "" ] && arch=$TARGET_ARCH && findarch=false
-    
-    if ! $findarch; then
-        pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
-        [ -d $pathtorpms ] || return 255
-        case "$DISTRO" in
-            rhel4)
-                rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
-            ;;
-            sles10)
-                rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
-            ;;
-            *)
-                rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
-            ;;
-        esac
-        [ -f "${pathtorpms}/${rpmfile}" ] || return 255
-        KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
-    else
-        for arch in $TARGET_ARCHS_ALL; do
-        pathtorpms="${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}/${arch}"
-        [ -d $pathtorpms ] || continue
-        case "$DISTRO" in
-            rhel4)
-                rpmfile="kernel-${lnxmaj}-${lnxrel}.src.rpm"
-            ;;
-            sles10)
-                rpmfile="kernel-source-${lnxmaj}.${lnxrel}.${arch}.rpm"
-            ;;
-            *)
-                rpmfile="kernel-source-${lnxmaj}-${lnxrel}.${arch}.rpm"
-            ;;
-        esac
-        [ -f "${pathtorpms}/${rpmfile}" ] || continue
-        KERNELSOURCERPM="${pathtorpms}/${rpmfile}"
-        TARGET_ARCH=${arch}
-        break
-        done
+    # call a distro specific hook, if available
+    if type -p unpack_linux_devel_rpm-$DISTRO; then
+        unpack_linux_devel_rpm-$DISTRO "$kernelrpm"
     fi
-    [ -f "${KERNELSOURCERPM}" ] || return 255
+
+    popd
+
+    find_linux_devel_paths $TOPDIR/reused
+
+    return 0
+
 }
 
-#unpack and make symlinks for reusing kernel RPM
-reuse_kernel_rpm()
-{
-    local pathtorpm=$1
-    local pathtokernelibrpm=$2
-    [ "$pathtorpm" = "" ] && return 255
-    [ -f "$pathtorpm" ] || return 255
-    [ -d $TOPDIR/reused ] || mkdir $TOPDIR/reused
-    pushd $TOPDIR/reused || return 255
+# XXX - this rhel/sles goop needs abstracting out into the
+#       lbuild-{rhel5,sles10} method files
+find_linux_devel_paths() {
+    local path="$1"
 
-    rpm2cpio < $pathtorpm | cpio -idc
-    [ ${PIPESTATUS[0]} -eq 0 ] || return 255
+    local RC=0
 
-    if [ -n "$pathtokernelibrpm" ] && [ -f "$pathtokernelibrpm" ]; then
-        rpm2cpio < $pathtokernelibrpm | cpio -idc
-        [ ${PIPESTATUS[0]} -eq 0 -o ${PIPESTATUS[1]} -eq 0 ] || return 255
-        CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
-    fi
+    pushd $path
+    # RHEL-style and SLES-style rpms
+    # XXX - until bug 19336 cleans this up, we need to extricate the
+    #       ${lnxmin}- from the $lnxrel
+    local paths="kernels/${lnxmaj}${lnxmin}${delimiter}${lnxrel}-${TARGET_ARCH} linux-${lnxmaj}${lnxmin}${delimiter}${lnxrel##${lnxmin#.}-}"
 
-    local smptype=
-    if pushd usr/src/linux-*-obj/${TARGET_ARCH}; then
-        local smptypes="$SMPTYPES"
-        [ "$RPMSMPTYPE" = "" ] || smptypes=$RPMSMPTYPE
-        ( ! $PATCHLESS ) && [ ! "$KERNCONFSMPTYPE" = "" ] && smptypes="$KERNCONFSMPTYPE"
-        local cursmptype=
-        for cursmptype in $smptypes; do
-            [ "$cursmptype" = "''" ] && continue
-            [ -d $cursmptype ] && smptype=$cursmptype
-            [ -d $smptype ] && break
-        done
-        popd
-    fi
-    if [ "${smptype}" = "" ]; then
-        popd
-        return 255 # cannot detect smp type
-    fi
-    if pushd usr/src/linux-*-obj/${TARGET_ARCH}/$smptype/include2; then
-        local base=$(readlink asm)
-        if [ ! -d "/${base}/" ]; then
-            rm -f asm
-            base=$(basename "$base")
-            if pushd ../../../../linux-*/include; then
-                local lsrc=$(pwd)
-                popd
-                [ -d "$lsrc/${base}" ] && ln -s $lsrc/${base} asm
-            fi
-        fi
-        popd
-        read a b < <(echo $(pwd)/usr/src/linux-*)
-        if [[ $a == $(pwd)/* && $b = $(pwd)/* ]]; then
-            cp -f $a/include/linux/config.h $b/${TARGET_ARCH}/$smptype/include/linux/
-            cp $b/${TARGET_ARCH}/$smptype/.config $a/
-            [ -f "$b/${TARGET_ARCH}/$smptype/.config" ] && KERNELRPMCONFIG="$b/${TARGET_ARCH}/$smptype/.config"
-            cp $b/${TARGET_ARCH}/$smptype/.kernelrelease $a/
-            [ -f "$b/${TARGET_ARCH}/$smptype/.kernelrelease" ] && KERNELRPMRELEASE="$b/${TARGET_ARCH}/$smptype/.kernelrelease"
-            LINUX=$a
-            LINUXOBJ=$b/${TARGET_ARCH}/$smptype
-#            local fname=$(basename $kernel_rpm)
-#            KERNELRPMSDIR=${kernel_rpm%$fname}
+    local path
+    for path in $paths; do
+        local src='usr/src'
+
+        if [ -d "$src/$path/" ]; then
+            LINUX="$(pwd)/$src/$path"
         fi
-    fi
-    popd
-    [ "$LINUX" = "" ] && return 255
-    [ -d "$LINUX" ] || return 255
-}
+        # SLES has a separate -obj tree
+        if [ -d "$src/${path}-obj" ]; then
+            local src="$src/${path}-obj"
+            local objects="$TARGET_ARCH/$RPMSMPTYPE"
+
+            # Novell, are you *TRYING* to make life hard for me?
+            if [ -d "$src/powerpc" ]; then
+                objects="powerpc/$TARGET_ARCH"
+            elif [ $TARGET_ARCH == 'i686' ]; then
+                objects="i386/$RPMSMPTYPE"
+            fi
 
-#build linux kernel rpm
-build_linux_rpm()
-{
-    pushd $LINUX || return 255
-    make binrpm-pkg || ( popd ; return 255 )
-    local addlnxrel=
-    [ -f ".version" ] && addlnxrel="-$(cat .version)"
-    popd
-    local arch=
-    for arch in $TARGET_ARCHS_ALL; do
-        [ -f "/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
-            KERNELRPM="/usr/src/rpm/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
-            TARGET_ARCH="$arch"
-        [ -f "/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" ] && \
-            KERNELRPM="/usr/src/packages/RPMS/$arch/kernel-$lnxmaj.${lnxrel}${addlnxrel}.$arch.rpm" && \
-            TARGET_ARCH="$arch"
+            LINUXOBJ="$(pwd)/$src/$objects"
+        fi
     done
-    [ "$KERNELRPM" = "" ] || return
-    return 255
-}
-
-#build linux kernel
-build_linux()
-{
-    local nofullmake=$1
-    local nocopykernel=$2
-    pushd $LINUX || fatal 1 "Kernel source not found"
-    [ "$nofullmake" = "nofullmake" ] || make mrproper
-    [ "$nofullmake" = "nofullmake" ] || rm -f rpm-release
-#    [ "$nocopykernel" = "copyrpmkernel" ] || rm -f localversion-*
-    [ "$nocopykernel" = "copykernel" ] && [ -f "$CONFIG_FILE" ] && cp $CONFIG_FILE .config
-    if [ "$nocopykernel" = "copyrpmkernel" ]; then
-        [ -f "$KERNELRPMCONFIG" ] && cp $KERNELRPMCONFIG .config
-        if [ -f "$KERNELRPMRELEASE" ]; then
-            cp $KERNELRPMRELEASE .
-        else
-            sed -e "s/^EXTRAVERSION\s\+=\s\+.*$/EXTRAVERSION = -${lnxrel}/" < Makefile > Makefile.new
-            [ -f "Makefile.new" ] && mv Makefile.new Makefile
+    if [ -z "$LINUX" ]; then
+        RC=255
+    else
+        # dig out the release version
+        LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
+        if [ -z "$LINUXRELEASE" ]; then
+            echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
+            RC=255
         fi
     fi
-    [ -f ".config" ] || ( popd ; echo "Cannot find .config file"; return 255 )
-    make oldconfig || ( popd ; return 255 )
-    make include/linux/version.h
-    if [ ! "$nofullmake" = "nofullmake" ]; then
-        make || ( popd ; return 255 )
-    fi
     popd
-    return
+    return $RC
 }
 
-build_kernel_ib()
-{
+build_kernel_ib() {
     # build kernel-ib{,-devel}
     # some I/B drivers are architecture dependent and kernel-ib's configure
     # does not figure it out for us ~sigh~
@@ -1296,282 +945,443 @@ build_kernel_ib()
 	      --define "KVERSION ${LINUXRELEASE}" \
 	      --define "$K_SRC ${LINUXOBJ:-${LINUX}}" \
 	      --define "LIB_MOD_DIR /lib/modules/${LINUXRELEASE}/updates" \
-	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" ${TOPDIR}/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
+	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-mlx4_en-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" ${TOPDIR}/OFED/SRPMS/ofa_kernel-*.src.rpm
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
         fatal 1 "Error building kernel-ib"
     fi
 
-    pushd "$TOPDIR" >/dev/null
-    rm -rf kernel-ib-devel
-    mkdir kernel-ib-devel
-    cd kernel-ib-devel
-    local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${LINUXRELEASE//-/_}.*.rpm)
-    rpm2cpio -itv < $rpm | cpio -id
-    CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
-    popd >/dev/null
 }
 
-#build patchless lustre
-patchless_build_sequence()
-{
-    if [ -f $LINUX/Makefile ]; then
-        # Get the correct kernel release - I'm unsure how this can ever
-        # work otherwise, unless you're using the exact same kernel version
-        # Lustre is shipped with.
+store_for_reuse() {
+        local articles="$1"
+        local module="$2"
+        local location="$3"
+        local signature="$4"
+        local use_links="$5"
 
-        local LINUXRELEASE=$(find_linux_release ${LINUXOBJ:-$LINUX})
-        if [ -z "$LINUXRELEASE" ]; then
-            echo "Failed to find linux release in ${LINUXOBJ:-$LINUX}"
-            RC=255
+        local linkflag=""
+        if $use_links; then
+            linkflag="l"
         fi
 
-	lnxmaj=$(echo $LINUXRELEASE | cut -f1 -d-)
-	EXTRA_VERSION=$(echo $LINUXRELEASE | cut -f2 -d-)_lustre.$LUSTRE_VERSION
-        RPMSMPTYPE=" "
-        build_lustre && buildsuccess=true
-    else
-    #try to build from kernel-devel RPM (RHEL)
-    LINUX=
-    TARGET_ARCH=
-    local rpmfound=false
-    local buildsuccess=false
-    local storeforreuse=false
-    if [ "$KERNELRPMSBASE" = "" ] || [ ! -d "$KERNELRPMSBASE" ]; then
-        return 255
-    fi
-    [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
-
-    local delimiter=${EXTRA_VERSION_DELIMITER:-"-"}
-    # default to source type -source and special case below
-    local type=-source
-    case "$DISTRO" in
-        rhel*)
-            type=-devel
-            ;;
-    esac
+        location="$location"/"$signature"/"$module"
+        mkdir -p "$location"
+        # the cleanup script removes any directory that doesn't have a
+        # .lastused, so let's try to prevent that as soon as we can
+        # this solution still slightly racy with the cleanup script
+        # but the race is a lot tighter now
+        touch -t 197001010000 "$location/.lastused"
+        ## use eval/echo here to make sure shell expansions are performed
+        #if ! cp -a${linkflag} $(eval echo $articles) "$location"; then
+        local article
+        for article in $(eval echo $articles); do
+            if ! cp -a${linkflag} "$article" "$location"; then
+                error "Failed to copy \"$article\" to \"$location\" in store_for_reuse()"
+                # rename the cache location so that it's not cached
+                # product, but is around for analysis
+                mv "$location"{,-bad-$(date +%s)} || 
+                    error "failed to clean up a failed cache attempt" \
+                          "in \"$location\" -- manual cleanup will be" \
+                          "necessary"
+                return 1
+            fi
+        done
 
-    unpack_linux_rpm $type $delimiter && rpmfound=true
+        # flag the cache as complete (i.e. in case lbuild was previously
+        # interrupted while caching)
+        touch "$location/.lastused"
 
-    [ -d SRPMS ] || mkdir SRPMS
-    [ -d RPMS ] || mkdir RPMS
-    [ -d BUILD ] || mkdir BUILD
-    [ -d SOURCES ] || mkdir SOURCES
+        return 0
 
-    # first build kernel-ib
-    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-        $rpmfound && build_kernel_ib
-    fi
-    ( $rpmfound ) && build_lustre && buildsuccess=true && find_linux_source_rpm
-    fi
+}
 
-    if $buildsuccess; then
-        [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELRPM" ] && \
-            cp "$KERNELRPM" RPMS/${TARGET_ARCH}/
-        [ -d "RPMS/${TARGET_ARCH}" ] && [ -f "$KERNELSOURCERPM" ] && \
-            cp "$KERNELSOURCERPM" RPMS/${TARGET_ARCH}/
-        KERNELCOMPILEDIR="$LINUX"
-        if $storeforreuse; then
-            store_for_reuse || echo "Cannot store for future reuse"
+reuse() {
+    local module="$1"
+    local dest="$2"
+    local use_links="${3:-false}"
+    local signature="$4"
+
+    if [ -n "$REUSEBUILD" ] && [ -d "$REUSEBUILD/$signature/$module" ]; then
+        if [ ! -f "$REUSEBUILD/$signature/$module/.lastused" ]; then
+            # the .lastused flag is populated at the end of the caching to
+            # signal that the caching was completeld.  if that flag is not
+            # there, then the cache is invalid (and should be removed in fact) 
+            mv "$REUSEBUILD/$signature/$module"{,-bad-$(date +%s)} || 
+                fatal 1 "failed to clean up a bad cache in location" \
+                      "\"$REUSEBUILD/$signature/$module\" -- manual cleanup" \
+                      "will be necessary"
+            return 1
         fi
 
-        return
-    elif ! $rpmfound; then
-        echo "COULD NOT FIND VENDOR -devel or -source RPM for $DISTRO/$TARGET_ARCH: $lnxmaj-$lnxrel in $KERNELRPMSBASE"
-        return 255
+        # so that we know how stale this entry is
+        touch $REUSEBUILD/$signature/$module/.lastused
+
+        if $use_links; then
+            if ls $REUSEBUILD/$signature/$module/* >/dev/null 2>&1; then
+                cp -al $REUSEBUILD/$signature/$module/* $dest/
+            fi
+        else
+            # copying is pretty heavy
+            # cp -a $REUSEBUILD/$signature/$module/* $dest/
+            # do some creative symlinking instead
+            local dir
+            for dir in BUILD SRPMS SPECS; do
+                if ls $REUSEBUILD/$signature/$module/$dir/* >/dev/null 2>&1; then
+                    ln -s $REUSEBUILD/$signature/$module/$dir/* $dest/$dir
+                fi
+            done
+            # sources have to be copied by file because we need SOURCES to
+            # be a dir we can write into
+# could overrun ls's arg list here
+            #ls $REUSEBUILD/$signature/$module/SOURCES/* |
+            find $REUSEBUILD/$signature/$module/SOURCES/ -type f |
+                xargs ln -t $dest/SOURCES -s
+
+            # same for RPMS/* dirs
+# could overrun ls's arg list here
+            #ls $REUSEBUILD/$signature/$module/RPMS/$TARGET_ARCH/* |
+            local dir
+            for dir in $REUSEBUILD/$signature/$module/RPMS/*; do
+                mkdir -p $dest/RPMS/${dir##*/}
+                find $dir -type f |
+                  xargs ln -t $dest/RPMS/${dir##*/} -s
+            done
+                     
+        fi
+        return 0
     else
-        echo "Patchless build failed."
-        return 255
+        return 1
     fi
 }
 
-#check timestamp value. should bi 14-digits string
-check_timestamp()
-{
-    local invalue=$1
-    local timestampnodig=$(echo $invalue | sed -e s/[0-9]*//g)
-    [ "$timestampnodig" = "" ] || return 255
-    local timestamplength="${#invalue}"
-    [ $timestamplength -eq 14 ] || return 255
+basearch() {
+    local arch="$1"
+
+    if [[ $arch = i[3456]86 ]]; then
+        echo "i386"
+    else
+        echo "$arch"
+    fi
+
 }
 
-# get list of suitable directories with potential reused staff
-get_reuse_dir_list()
-{
-    local rpmonly=$1
-    local reusedkernelmasknew=$2
-    local buildtimestamp=
-    local dirsforreuse=
-    local sourcelastdate=$(get_last_source_date)
-    for buildtimestamp in $(ls "$REUSEBUILD/" 2>&1); do
-        [ -d "$REUSEBUILD/$buildtimestamp" ] || continue
-	check_timestamp "$buildtimestamp" || continue
-        local buildtimestampstr=$(echo $buildtimestamp | \
-            sed -e "s^\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)^\1-\2-\3 \4:\5:\6 GMT^g")
-        local buildtimestampepoch=$(date --date="$buildtimestampstr"  +%s )
-        #check for suitable date
-	    if ! $PATCHLESS; then
-            [ $buildtimestampepoch -ge $sourcelastdate ] || continue
-	    fi
-        #check for suitable version
-        if [ "$rpmonly" = "rpmonly" ]; then
-            local reusedkernelprefix="kernel-lustre-"
-            ( $PATCHLESS ) && reusedkernelprefix=
-            local rpmmask="${reusedkernelprefix}${REUSEDKERNELMASK}"
-            [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
-            [ -f $REUSEBUILD/$buildtimestamp/${rpmmask}.rpm ] && \
-                dirsforreuse="$dirsforreuse $REUSEBUILD/$buildtimestamp"
-        else
-            local rpmmask="$REUSEDKERNELMASK"
-            [ "$reusedkernelmasknew" = "" ] || rpmmask="$reusedkernelmasknew"
-            pushd $REUSEBUILD/$buildtimestamp/linux-${rpmmask} > /dev/null 2>&1 || continue
-            local curdir=$(pwd)
-            dirsforreuse="$dirsforreuse $curdir"
-            popd
+#
+# in a given directory, find the first rpm matching given requirements
+#
+find_rpm() {
+    local dir="$1"
+    local match_type="$2"
+    local match="$3"
+
+    pushd "$dir" > /dev/null || \
+        fatal 1 "Unable to chdir to directory \"$dir\" in find_rpm()"
+
+    local file
+    for file in $(ls); do
+        if [ ! -f "$file" ]; then
+            continue
         fi
+        case "$match_type" in
+            provides)
+                # match is any valid ERE (i.e. given to egrep) match
+                if rpm -q --provides -p "$file" | egrep -q "$match"; then
+                    echo "$file"
+                    popd >/dev/null
+                    return 0
+                fi
+                ;;
+            *)
+                popd >/dev/null
+                fatal 1 "Unknown match type \"$match_type\" given to find_rpm()"
+                ;;
+        esac
     done
-    echo "$dirsforreuse"
+
+    popd >/dev/null
+    return 1
 }
 
-#try to reuse old RPM
-build_sequence_rpm_reuse()
-{
-    local sourcerpm=$1
-    [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
-    local dirsforreuse=
-    if ! [ "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse RPM
-        local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
-        REUSEDKERNELMASKnew="kernel-lustre-source-${REUSEDKERNELMASKnew}"
-        local dirsforreuse="$(get_reuse_dir_list rpmonly $REUSEDKERNELMASKnew)"
-        local buildsuccess=false
-        LINUXOBJ=
-        for curdir in $(echo $dirsforreuse); do
-            [ -d "$curdir" ] || continue
-            local reusedkernelprefix="kernel-lustre-"
-            local reusedkernelrpm=
-            [ -f ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
-                reusedkernelrpm=$(ls ${curdir}/${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
-            [ -f "$reusedkernelrpm" ] || continue
-
-            local reusedkernelsourcerpm=
-            [ -f ${curdir}/${REUSEDKERNELMASKnew}.rpm ] && \
-                reusedkernelsourcerpm=$(ls ${curdir}/${REUSEDKERNELMASKnew}.rpm | head -1 )
-            [ -f "$reusedkernelsourcerpm" ] || continue
-
-            # don't need to check for kernel-ib RPM reuse here because sles9 is not supported
-            # by OFED >= 1.3.0 and this function appears to only be used for sles9
-
-            [ -d $TOPDIR/reused ] && rm -rf $TOPDIR/reused
-            reuse_kernel_rpm "$reusedkernelsourcerpm" "" && build_linux nofullmake copyrpmkernel && build_lustre && buildsuccess=true
-            ( $buildsuccess ) || continue
-            if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
-                [ -f "$reusedkernelrpm" ] && \
-                    cp -f  "$reusedkernelrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
- 
-                [ -f "$reusedkernelsourcerpm" ] && \
-                    cp -f  "$reusedkernelsourcerpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
-                    touch RPMS/${TARGET_ARCH}/kernel_was_reused
-            fi
-            return
-        done
+build_kernel_with_srpm() {
+
+    # need to generate the patch for this target
+    do_patch_linux false >&2	# sets global $FULL_PATCH (yeah, yuck)
+
+    # get an md5sum of the kernel patch + config for reuse check
+    # XXX really, there needs to be a signature and a CONFIG_FILE per arch
+    #     in BUILD_ARCHS
+    local REUSE_SIGNATURE=$({ echo $BUILD_GEN; cat $CONFIG_FILE $TARGET_FILE $FULL_PATCH; } | md5sum | cut -d" " -f1)
+
+    # see if we can link to the reuse pool
+    # XXX - hrm.  i'm not convinced this doesn't belong in the reuse "library"
+    local CAN_LINK_FOR_REUSE=false
+    touch $REUSEBUILD/$$
+    if cp -al $REUSEBUILD/$$ $TOPDIR/; then
+        CAN_LINK_FOR_REUSE=true
     fi
-    return 255
+    rm $REUSEBUILD/$$
+
+    # the extra version string to use for the kernel (which might be a reused
+    # kernel, remember)
+    local kernel_extra_version=""
+    if $REUSERPM && ! reuse kernel "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
+                                   "$REUSE_SIGNATURE"; then
+        # nothing cached, build from scratch
+        if [ ! -r "$KERNELDIR/$KERNEL_SRPM" ]; then
+            download_srpm "$CANONICAL_TARGET" "$KERNEL_SRPM" >&2
+        fi
+
+        if ! rpm -ivh $KERNELDIR/$KERNEL_SRPM \
+                  --define "_topdir $TOPDIR" >&2; then
+            # should we clean this up or leave it for analysis?
+            #rm -rf $RPMTOPDIR
+            fatal 1 "Error installing kernel SRPM."
+        fi
+
+        # put the Lustre kernel patch into the RPM build tree
+        cp $FULL_PATCH $TOPDIR/SOURCES/linux-${lnxmaj}-lustre.patch
+        prepare_and_build_srpm >&2
+
+        # store the resulting kernel RPM build tree for future use
+        if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
+                             "kernel" "$REUSEBUILD" "$REUSE_SIGNATURE" \
+                             "$CAN_LINK_FOR_REUSE"; then
+            error "Failed to store kernel RPMS for reuse"
+            echo "unknown"
+            return 1
+        fi
+    fi	# build reuse
+
+    # figure out the EXTRA_VERSION of the kernel we built or are re-using
+    local KERNEL_RPM
+    if ! KERNEL_RPM=$(find_rpm "$TOPDIR/RPMS/$TARGET_ARCH/" provides "^kernel ="); then
+        fatal 1 "Failed to find a kernel RPM in $TOPDIR/RPMS/$TARGET_ARCH/"
+    fi
+    kernel_extra_version=$(rpm -q --queryformat "%{RELEASE}" -p $TOPDIR/RPMS/$TARGET_ARCH/$KERNEL_RPM)
+
+    # should now have the following RPMs
+    # $TOPDIR/RPMS/$arch/kernel-lustre-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-devel-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-headers-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-common-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+    # $TOPDIR/RPMS/$arch/kernel-lustre-debuginfo-2.6.18-53.1.21.el5_lustre.1.6.5.1.$arch.rpm
+
+    echo $kernel_extra_version
+    return 0
+
 }
 
-#try to reuse old BUILD dir
-build_sequence_reuse()
-{
-    local sourcerpm=$1
-    [ "$REUSERPM" = "" ] && [ "$REUSEBUILD" = "" ] && return 255
-    local dirsforreuse=
-    if [ ! "$REUSEBUILD" = "" ] && [ -d "$REUSEBUILD" ]; then #try to reuse old kernel build directory
-        local dirsforreuse="$(get_reuse_dir_list)"
-        local buildsuccess=false
-        LINUXOBJ=
-        local REUSEDKERNELMASKnew=$(echo $REUSEDKERNELMASK | sed -e "s/^[^0-9]*//")
-        for curdir in $(echo $dirsforreuse); do
-            local reusedkernelrpm=
-            local reusedkernelsourcerpm=
-            local reusedkernelibrpm=
-            [ -d "$curdir" ] || continue
-            [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" -a 
-	      ! -d "${curdir%/*}/ofa_kernel" ] && continue
-            local reusedkernelprefix="kernel-lustre-"
-            ( $PATCHLESS ) && reusedkernelprefix=
-            [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm ] && \
-                reusedkernelrpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASK}.rpm | head -1 )
-            reusedkernelprefix="kernel-lustre-source-"
-            [ -f ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm ] && \
-                reusedkernelsourcerpm=$(ls ${curdir}/../${reusedkernelprefix}${REUSEDKERNELMASKnew}.rpm | head -1 ) 
-            if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-                gen_lustre_version
-                reusedkernelprefix="kernel-ib-"
-                [ -f ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm ] && \
-                    reusedkernelibrpm=$(ls ${curdir}/../${reusedkernelprefix}${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 ) 
-                    reusedkernelibdevelrpm=$(ls ${curdir}/../${reusedkernelprefix}devel-${OFED_VERSION}-${LUSTRE_EXTRA_VERSION}.${TARGET_ARCH}.rpm | head -1 ) 
+build_with_srpm() {
+
+    if ! $PATCHLESS; then
+        local kernel_extra_version
+        if ! kernel_extra_version=$(build_kernel_with_srpm); then
+            fatal 1 "Failed to build the kernel from it's SRPM"
+        fi
+
+        for arch in $BUILD_ARCHS; do
+
+            local kernel_devel_rpm
+            if ! kernel_devel_rpm=$(find_rpm "$TOPDIR/RPMS/$arch/" provides "^$(devel_kernel_name true) ="); then
+                fatal 1 "Failed to find a kernel development RPM in $TOPDIR/RPMS/$arch/"
             fi
-            if ! ( $NORPM ) && ! [ -f "$reusedkernelrpm" ]; then #kernel rpm not found. Build all
-                continue
+
+            # install the -devel RPM in preparation for the lustre build
+            # note that the EXTRA_VERSION_DELIMITER is *NOT* used in the
+            # version of the directory name under /usr/src
+            if ! lnxrel="$kernel_extra_version" unpack_linux_devel_rpm \
+                           "$TOPDIR/RPMS/$arch/$kernel_devel_rpm" "-"; then
+                fatal 1 "Could not find the Linux tree in $TOPDIR/RPMS/$arch/$kernel_devel_rpm"
             fi
-            if ! ( $NORPM ) && ! [ -f "$reusedkernelsourcerpm" ]; then #kernel source rpm not found. Build all
-                continue
+        done
+    else
+        # need to find and unpack the vendor's own kernel-devel for patchless
+        # client build
+        local kernelrpm
+        if ! kernelrpm=$(find_linux_rpm "-$DEVEL_KERNEL_TYPE" ${EXTRA_VERSION_DELIMITER:-"-"}); then
+            fatal 1 "Could not find the kernel-$DEVEL_KERNEL_TYPE RPM in ${KERNELRPMSBASE}/${lnxmaj}/${DISTRO}"
+        fi
+        if ! lnxrel="$lnxrel" unpack_linux_devel_rpm "$kernelrpm" "-"; then
+            fatal 1 "Could not find the Linux tree in $kernelrpm"
+        fi
+    fi
+
+    # before lustre, build kernel-ib
+    if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
+        # see if we can link to the reuse pool
+        # XXX - hrm.  i'm not convinced this doesn't belong in the reuse "library"
+        local CAN_LINK_FOR_REUSE=false
+        touch $REUSEBUILD/$$
+        if cp -al $REUSEBUILD/$$ $TOPDIR/; then
+            CAN_LINK_FOR_REUSE=true
+        fi
+        rm $REUSEBUILD/$$
+
+        local REUSE_SIGNATURE=$({ echo "$OFED_VERSION"; echo "$(find_linux_release ${LINUXOBJ:-$LINUX})"; cat "${LINUXOBJ:-${LINUX}}/include/linux/autoconf.h"; } | md5sum | cut -d" " -f1)
+        if ! reuse ofed "$TOPDIR" "$CAN_LINK_FOR_REUSE" \
+                        "$REUSE_SIGNATURE"; then
+            # stash away the existing built articles for a moment
+            mkdir bak
+            mv {BUILD,{S,}RPMS,S{OURCE,PEC}S} bak
+            function mv_back {
+                pushd bak
+                find . | cpio -pudlm ..
+                popd
+                rm -rf bak
+            }
+            create_rpmbuild_dirs
+            # build it
+            build_kernel_ib
+            if ! store_for_reuse "$TOPDIR/{SPECS,SOURCES,BUILD,SRPMS,RPMS}" \
+                                 "ofed" "$REUSEBUILD" "$REUSE_SIGNATURE" \
+                                 "$CAN_LINK_FOR_REUSE"; then
+                error "Failed to store OFED RPMS for reuse"
+                mv_back
+                return 1
             fi
-            if [ -n "$OFED_VERSION" ]; then
-            	if [ "$OFED_VERSION" != "inkernel" ]; then
-                if ! ( $NORPM ) && [ ! -f "$reusedkernelibrpm" -o ! -f "$reusedkernelibdevelrpm"]; then #kernel-ib{,-devel} rpm not found. Build all
-                    continue
+            # put the stuff we stashed away back
+            mv_back
+        fi
+
+        pushd "$TOPDIR" >/dev/null
+        rm -rf kernel-ib-devel
+        mkdir kernel-ib-devel
+        cd kernel-ib-devel
+        # the actual ofed RPMs don't have the -rc$n or -$date string appened that
+        # might be present on the file
+        local ofed_version=$(echo $OFED_VERSION |
+                         sed -re 's/-(20[0-9]{6,6}-[0-9]{4,4}|rc[0-9]*)$//')
+        local rpm=$(ls $TOPDIR/RPMS/*/kernel-ib-devel-${ofed_version}-${LINUXRELEASE//-/_}.*.rpm)
+        rpm2cpio -itv < $rpm | cpio -id
+        CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
+        popd >/dev/null
+    fi
+
+    # now build Lustre
+    if build_lustre; then
+        # the build worked.  resolve any symlinked files (i.e. from reuse)
+        # in RPMS/$arch to real files so that that that huge mess of
+        # complication knows as LTS can copy them yet somewhere else.
+        # is it any wonder this whole process is so damn so?  anyone ever
+        # heard of hardlinks?  it this cool new thing that allows you save
+        # tons of time and space by creating... well you can go read about
+        # them if you have not heard about them yet.
+        # can i say how much the implemenation of all of this really impedes
+        # RPM reuse?
+        pushd RPMS/$TARGET_ARCH
+            for file in *; do
+                if [ -h $file ]; then
+                    cp $file foo
+                    mv foo $file
                 fi
-                CONFIGURE_FLAGS="--with-o2ib=${curdir%/*}/ofa_kernel ${CONFIGURE_FLAGS}"
-                else
-                    CONFIGURE_FLAGS="--with-o2ib=yes ${CONFIGURE_FLAGS}"
-		fi
-            fi
-            LINUX="$curdir"
-            build_lustre || continue
-            touch "$curdir/../"
-            buildsuccess=true
-            if ( ! $NORPM ) && ( ! $PATCHLESS ) ; then
-                [ -f "$reusedkernelrpm" ] && \
-                    cp -f  "$reusedkernelrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1 && \
-                    touch RPMS/${TARGET_ARCH}/kernel_was_reused
-                [ -f "$reusedkernelsourcerpm" ] && \
-                    cp -f  "$reusedkernelsourcerpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
-                [ -f "$reusedkernelibrpm" ] && \
-                    cp -f  "$reusedkernelibrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
-                    cp -f  "$reusedkernelibdevelrpm"  RPMS/${TARGET_ARCH}/ > /dev/null 2>&1
-            fi
-            return
-        done
+            done
+        popd
+    else
+        return 1
     fi
-    return 255
+
 }
 
+create_rpmbuild_dirs() {
 
-build_sequence()
-{
-    if (( $DO_SRC )) ; then
-        unpack_linux
-        patch_linux
-        pack_linux
-        clean_linux
-    fi
-    prep_kernel_build || return 255
-    clean_lustre || return 255
+    [ -d RPMS ] || mkdir RPMS
+    for arch in $BUILD_ARCHS; do
+        if [[ $arch = i?86 ]]; then
+            # some stupidity in the sles11 kernel spec requires an RPMS/i386
+            # even if the target arch is i686
+            [ -d RPMS/i386 ] || mkdir RPMS/i386
+        fi
+        [ -d RPMS/$arch ] || mkdir RPMS/$arch
+    done
+    [ -d BUILD ] || mkdir BUILD
+    [ -d SOURCES ] || mkdir SOURCES
+    [ -d SPECS ] || mkdir SPECS
+    [ -d SRPMS ] || mkdir SRPMS
+
+}
+
+new_list() {
+
+    echo ""
+
+}
+
+add_list() {
+    local list="$1"
+    local item="$2"
+
+    echo "$list $item"
+
+}
+
+is_list_member() {
+    local list="$1"
+    local item="$2"
+
+    [[ $list\  == *\ $item\ * ]]
+
+}
+
+#########################################################################
+# Generate a backtrace through the call stack.
+#
+# Input: None
+# Output: None
+#########################################################################
+backtrace() {
+    local strip=${1:-1}
+
+    local funcname="" sourcefile="" lineno="" n
+
+    echo "Call stack: (most recent first)"
+    for (( n = $strip ; n < ${#FUNCNAME[@]} ; ++n )) ; do
+        funcname=${FUNCNAME[$n - 1]}
+        sourcefile=$(basename ${BASH_SOURCE[$n]})
+        lineno=${BASH_LINENO[$n - 1]}
+        # Display function arguments
+        if [[ ! -z "${BASH_ARGV[@]}" ]]; then
+            local args newarg j p=0
+            for (( j = ${BASH_ARGC[$n - 1]}; j > 0; j-- )); do
+                newarg=${BASH_ARGV[$j + $p - 1]}
+                args="${args:+${args} }'${newarg}'"
+            done
+            let p+=${BASH_ARGC[$n - 1]}
+	fi
+        echo "  ${funcname} ${args:+${args} }at ${sourcefile}:${lineno}"
+    done
+
+    echo
+    echo "BEGIN BACKTRACE"
+
+    #echo ${BASH_LINENO[*]}
+    #echo ${BASH_SOURCE[*]}
+    #echo ${FUNCNAME[*]}
+    local i=$((${#FUNCNAME[@]} - 1))
+    while [ $i -ge 0 ]; do
+        local SOURCELINE="${BASH_SOURCE[$i + 1]}:${BASH_LINENO[$i]}"
+        # Can't figure out how to get function args from other frames...
+        local FUNCTION="${FUNCNAME[$i]}()"
+        echo "$SOURCELINE:$FUNCTION"
+        i=$((i - 1))
+    done
+
+    echo "END BACKTRACE"
+
+    echo $BACKTRACE
 
-    build_kernel || return 255
 }
 
 [ -r ~/.lbuildrc ] && . ~/.lbuildrc
 
-options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux: -- "$@")
+options=$(getopt -o d:D:h -l kerneltree:,distro:,kernelrpm:,reusebuild:,patchless,ldiskfs,ccache,reuse:,norpm,disable-datestamp,external-patches:,timestamp:,extraversion:,kerneldir:,linux:,lustre:,nodownload,nosrc,publish,release,src,stage:,tag:,target:,target-archs:,with-linux:,xen -- "$@")
 
-if [ $? != 0 ] ; then
+if [ $? != 0 ]; then
     usage 1
 fi
 
 eval set -- "$options"
-    
-while [ "$1" ] ; do
+
+while [ "$1" ]; do
     case "$1" in
         '')
             usage 1
@@ -1604,11 +1414,15 @@ while [ "$1" ] ; do
             shift 2
             ;;
         --kerneltree)
-            KERNELTREE=$2
+            if ! KERNELTREE=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --linux | --with-linux)
-            LINUX=$2
+            if ! LINUX=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --distro)
@@ -1620,7 +1434,9 @@ while [ "$1" ] ; do
             shift 2
             ;;
         --reusebuild)
-            REUSEBUILD=$2
+            if ! REUSEBUILD=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --norpm)
@@ -1636,7 +1452,9 @@ while [ "$1" ] ; do
             shift
             ;;
         --kernelrpm)
-            KERNELRPMSBASE=$2
+            if ! KERNELRPMSBASE=$(canon_path "$2"); then
+                fatal 1 "Could not determine the canonical location of $2"
+            fi
             shift 2
             ;;
         --timestamp)
@@ -1648,11 +1466,11 @@ while [ "$1" ] ; do
             shift 2
             ;;
         --nodownload)
-            DOWNLOAD=0
+            DOWNLOAD=false
             shift 1
             ;;
         --nosrc)
-            DO_SRC=0
+            DO_SRC=false
             shift 1
             ;;
         --publish)
@@ -1663,7 +1481,7 @@ while [ "$1" ] ; do
             shift
             ;;
         --src)
-            DO_SRC=1
+            DO_SRC=true
             shift 1
             ;;
         --stage)
@@ -1686,12 +1504,16 @@ while [ "$1" ] ; do
             USE_DATESTAMP=
             shift
             ;;
+        --xen)
+            XEN=true
+            shift
+            ;;
         --)
             shift
             CONFIGURE_FLAGS=$@
             CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-liblustre --enable-liblustre-tests"
             break
-            ;; 
+            ;;
         *)
             usage 1 "Unrecognized option: $1"
             ;;
@@ -1706,26 +1528,64 @@ load_target
 EXTRA_VERSION_DELIMITER=${EXTRA_VERSION_DELIMITER:-"-"}
 
 if [ -n "$OFED_VERSION" -a "$OFED_VERSION" != "inkernel" ]; then
-    unpack_ofed
+    download_ofed
+    unpack_ofed || fatal 1 "Error unpacking OFED tarball"
 fi
 
-build_success=false
-if $PATCHLESS; then
-    patchless_build_sequence && build_success=true 
-elif [ -z "$LINUX" ] ; then
-    [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
-    if ! $build_success; then
-        build_sequence_reuse && build_success=true
-        if ! $build_success; then
-            build_sequence && build_success=true
-            if $build_success; then
-                store_for_reuse || echo "Cannot store for future reuse"
+# make sure the RPM build environment is set up
+create_rpmbuild_dirs
+
+trap '[ -n "$CCACHE" ] && ccache -s' EXIT
+
+# if an unpacked kernel source tree was given on the command line
+# just build lustre with it (nothing distro kernel specific here)
+if [ -n "$LINUX" ]; then
+    build_lustre
+else
+    if [ -f "${0%/*}/lbuild-$DISTRO" ]; then
+        seen_list=$(new_list)
+        trap '(echo "Untrapped error"
+echo
+# have we seen this one
+echo "checking seen list for ${BASH_SOURCE[0]}:${BASH_LINENO[0]}"
+
+if is_list_member "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}"; then
+  echo "seen this one already"
+else
+  seen_list=$(add_list "$seen_list" "${BASH_SOURCE[0]}:${BASH_LINENO[0]}")
+fi
+backtrace
+echo
+echo "Environment:"
+set
+) | tee >(mail -s "Untrapped error at ${BASH_SOURCE[0]##*/}:${BASH_LINENO[0]} on $HOSTNAME" brian at sun.com) >&2' ERR
+        set -E
+
+        source ${0%/*}/lbuild-$DISTRO
+
+        build_with_srpm || fatal 1 "Failed to build_with_srpm"
+    else
+        source ${0%/*}/lbuild.old_school
+
+        old_school_download_kernel
+
+        build_success=false
+        if $PATCHLESS; then
+            patchless_build_sequence && build_success=true
+        else
+            [ "$DISTRO" = "sles9" ] && build_sequence_rpm_reuse && build_success=true
+            if ! $build_success; then
+                build_sequence_reuse && build_success=true
+                if ! $build_success; then
+                    build_sequence && build_success=true
+                    if $build_success; then
+                        store_for_reuse || echo "Cannot store for future reuse"
+                    fi
+                fi
             fi
         fi
+        ( $build_success ) || fatal 1 "Cannot build lustre"
     fi
-else
-    build_lustre && build_success=true
 fi
-( $build_success ) || fatal 1 "Cannot build lustre"
 
 stage
diff --git a/ldiskfs/build/lmake b/ldiskfs/build/lmake
index c9b22ea..b883453 100755
--- a/ldiskfs/build/lmake
+++ b/ldiskfs/build/lmake
@@ -47,6 +47,7 @@ KERNEL_FILE=
 SERIES_FILE=
 CONFIG_FILE=
 RPMBUILD=
+XEN=false
 
 canon()
 {
@@ -160,6 +161,9 @@ Options:
   --unpack-kernel
     Untars and patches the kernel source.
 
+  --xen
+    Builds a Xen domX kernel.
+
   The order that commands (--build-lustre, --unpack-kernel) are
   specified on the command line is ignored; ${0##*/} will always
   execute them in the correct order (unpack, then build, then install
@@ -228,12 +232,17 @@ load_target()
 
     . "$TARGET_FILE"
 
+    # doesn't make any sense to build OFED for xen domX's
+    if $XEN; then
+        OFED_VERSION=""
+    fi
+
     [ "$KERNEL" ] || fatal 1 "Target $TARGET did not specify a kernel."
 # Suse 2.6 has our patches in already
 #    [ "$SERIES" ] || fatal 1 "Target $TARGET did not specify a patch series."
 #    [ "$CONFIG" ] || fatal 1 "Target $TARGET did not specify a kernel config."
     [ "$VERSION" ] || fatal 1 "Target $TARGET did not specify the kernel version."
-    
+
     if [ "$KERNELDIR" ] ; then
 	KERNEL_FILE="$KERNELDIR/$KERNEL"
 	[ -r "$KERNELDIR/$KERNEL" ] || \
@@ -248,8 +257,13 @@ load_target()
 	done
     fi
 
+    local XENPOSTFIX=""
+    if $XEN; then
+        XENPOSTFIX="-xen"
+    fi
+
     TARGET_ARCH=${TARGET_ARCH:-$BASE_ARCHS}
-    CONFIG_TARGET="$TARGET-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
+    CONFIG_TARGET="${TARGET}${XENPOSTFIX}-${TARGET_ARCH}${TARGET_CONFIG:+-$TARGET_CONFIG}"
     CONFIG_FILE="$TOPDIR/lustre/kernel_patches/kernel_configs/kernel-$VERSION-$CONFIG_TARGET.config"
     [ -r "$CONFIG_FILE" ] ||
 	fatal 1 "Target $TARGET's config file $CONFIG_FILE missing from $TOPDIR/lustre/kernel_patches/configs."
@@ -270,10 +284,10 @@ setup_ccache_distcc()
             unset DISTCC
         fi
     fi
-    
+
     CC=${CC:-gcc}
     if [ "$CCACHE" ]; then
-        CC="$CCACHE $CC"
+        [[ $CC != ccache\ * ]] && CC="$CCACHE $CC"
         [ "$DISTCC" ] && export CCACHE_PREFIX="$DISTCC"
     else
         [ "$DISTCC" ] && CC="$DISTCC $CC"
@@ -316,7 +330,7 @@ extract_kernel()
 	[ -L linux ] && rm -rf $(readlink linux)
 	rm -rf linux
     fi
-    untar "$KERNEL_FILE"
+    untar "$KERNEL_FILE" || fatal 1 "Error unpacking Linux tarball"
     [ -d linux ] || ln -sf linux* linux
     popd >/dev/null
 }
@@ -401,7 +415,7 @@ depend_kernel()
     if [ -n "${TARGET_CONFIG}" ]; then
 	extra_version="${extra_version}${TARGET_DELIMITER}${TARGET_CONFIG}"
     fi
-    perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${extra_version}/" Makefile
+    sed -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${extra_version}/" Makefile
     echo "Making depend in $PWD..."
     $MAKE "$MAKE_CC" mrproper || fatal 1 "Error running make mrproper"
     rm -f rpm-release
@@ -484,17 +498,21 @@ build_kernel()
     (( $BUILD_KERNEL )) || return 0
     set_make
     echo "Building kernel in $PWD..."
-    case "$TARGET_ARCH" in
-	i386 | i586 | i686 | athlon | x86_64)
-	    $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
-	    ;;
-    ia64 | ppc | ppc64)
-	    $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
-	    ;;
-	*)
-	    $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
-	    ;;
-    esac
+    if $XEN; then
+        $MAKE_J "$MAKE_CC" vmlinuz || fatal 1 "Error making vmlinux."
+    else
+        case "$TARGET_ARCH" in
+	    i386 | i586 | i686 | athlon | x86_64)
+	        $MAKE_J "$MAKE_CC" bzImage || fatal 1 "Error making bzImage."
+	        ;;
+            ia64 | ppc | ppc64)
+	        $MAKE_J "$MAKE_CC" vmlinux || fatal 1 "Error making vmlinux."
+	        ;;
+	    *)
+	        $MAKE_J "$MAKE_CC" boot || fatal 1 "Error making boot."
+	        ;;
+        esac
+    fi
     $MAKE_J "$MAKE_CC" modules || fatal 1 "Error building modules."
 
     popd >/dev/null
@@ -525,7 +543,7 @@ build_kernel_ib()
 	      --define "KVERSION ${FULL_VERSION}" \
 	      --define "$K_SRC ${PWD}/linux" \
 	      --define "LIB_MOD_DIR /lib/modules/${FULL_VERSION}" \
-	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --without-srp-target-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-${OFED_VERSION}-ofed${OFED_VERSION}.src.rpm
+	      --define "configure_options --without-quilt --with-core-mod --with-user_mad-mod --with-user_access-mod --with-addr_trans-mod --with-srp-target-mod --with-core-mod --with-mthca-mod --with-mlx4-mod --with-cxgb3-mod --with-nes-mod --with-ipoib-mod --with-sdp-mod --with-srp-mod --with-rds-mod --with-iser-mod --with-qlgc_vnic-mod --with-madeye-mod $configure_options" $(lbuild_topdir)/OFED/SRPMS/ofa_kernel-*.src.rpm
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
         fatal 1 "Error building kernel-ib"
@@ -535,7 +553,7 @@ build_kernel_ib()
     rm -rf kernel-ib-devel
     mkdir kernel-ib-devel
     cd kernel-ib-devel
-    local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-${OFED_VERSION}-${FULL_VERSION//-/_}.*.rpm)
+    local rpm=$(ls $(lbuild_topdir)/RPMS/*/kernel-ib-devel-*-${FULL_VERSION//-/_}.*.rpm)
     rpm2cpio -itv < $rpm | cpio -id
     CONFIGURE_FLAGS="--with-o2ib=$(pwd)/usr/src/ofa_kernel ${CONFIGURE_FLAGS}"
     popd >/dev/null
@@ -567,6 +585,7 @@ build_lustre()
 	< lustre.spec.in \
 	> lustre.spec
     $RPMBUILD --target ${TARGET_ARCH} -bb lustre.spec \
+        ${PATCHLESS:+--define "lustre_name lustre-client"} \
         --define "_tmppath $TMPDIR" \
 	--define "_topdir $(lbuild_topdir)" || \
 	fatal 1 "Error building Lustre rpms."
@@ -592,37 +611,42 @@ install_kernel()
 	-s modules_install || \
 	fatal 1 "Error installing modules."
 
-    case "$TARGET_ARCH" in
-	i386 | i586 | i686 | athlon)
-	    cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-	    ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ;;
-	x86_64)
-	    cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-	    ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ;;
-        ppc | ppc64)
-	    cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
-	    ;;
-	ia64)
-	    gzip -cfv vmlinux > vmlinuz
-	    mkdir -p "$DESTDIR/boot/efi/redhat"
-	    install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
-	    install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
-	    ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
-	    ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-	    ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    ;;
-	*)
-	    cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
-	    cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
-	    ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
-
-	    ;;
-    esac
+    if $XEN; then
+	cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+	ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+    else
+        case "$TARGET_ARCH" in
+	    i386 | i586 | i686 | athlon)
+	        cp arch/i386/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+	        ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ;;
+	    x86_64)
+	        cp arch/x86_64/boot/bzImage "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+	        ln -sf "../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ;;
+            ppc | ppc64)
+	        cp vmlinux "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ln -sf "$DESTDIR/boot/vmlinux-${FULL_VERSION}" "../lib/modules/${FULL_VERSION}/vmlinux" 
+	        ;;
+	    ia64)
+	        gzip -cfv vmlinux > vmlinuz
+	        mkdir -p "$DESTDIR/boot/efi/redhat"
+	        install -m 755 vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/"
+	        install -m 755 vmlinuz "$DESTDIR/boot/efi/redhat/vmlinuz-${FULL_VERSION}"
+	        ln -sf "../../../lib/modules/${FULL_VERSION}/vmlinux" "$DESTDIR/boot/efi/redhat/vmlinux-${FULL_VERSION}"
+	        ln -sf "efi/redhat/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	        ln -sf "efi/redhat/vmlinuz-${FULL_VERSION}" "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        ;;
+	    *)
+	        cp vmlinuz "$DESTDIR/boot/vmlinuz-${FULL_VERSION}"
+	        cp vmlinux "$DESTDIR/lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}"
+	        ln -sf "../lib/modules/${FULL_VERSION}/vmlinux-${FULL_VERSION}" "$DESTDIR/boot/vmlinux-${FULL_VERSION}"
+	    	;;
+    	esac
+    fi
     if [ -e init/kerntypes.o ] ; then
 	cp init/kerntypes.o "$DESTDIR/boot/Kerntypes-${FULL_VERSION}"
     fi
@@ -764,7 +788,7 @@ save_all_headers()
 
 longopts="build,build-lustre,build-kernel,depend-kernel,destdir:,extraversion:"
 longopts="$longopts,help,install,install-lustre,install-kernel,kerneldir:"
-longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel"
+longopts="$longopts,save-headers,target:,target-arch:,target-config:,unpack-kernel,xen"
 
 options=$(getopt -o hj: -l "$longopts" -- "$@")
 
@@ -847,6 +871,10 @@ while [ "$1" ] ; do
 	    UNPACK_KERNEL=1
 	    shift
 	    ;;
+        --xen)
+            XEN=true
+            shift
+            ;;
 	--)
 	    shift
 	    CONFIGURE_FLAGS=$@
diff --git a/ldiskfs/build/lustre-kernel-2.4.spec.in b/ldiskfs/build/lustre-kernel-2.4.spec.in
index 804e65c..292b527 100644
--- a/ldiskfs/build/lustre-kernel-2.4.spec.in
+++ b/ldiskfs/build/lustre-kernel-2.4.spec.in
@@ -15,6 +15,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define release @KERNEL_RELEASE@
 # /usr/src/%{kslnk} -> /usr/src/linux-%{KVERREL}
 %define kslnk linux-2.4
+%define kprovides %(bash -c "echo %{kversion}%{kextraverdelim}%{kextraver} | sed -e 's/-[^0-9]*smp$//'")
 
 # groups of related archs
 %define all_x86 i386 i686 i586 athlon
@@ -25,6 +26,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define rhbuild @RHBUILD@
 %define susebuild @SUSEBUILD@
 %define linux26 @LINUX26@
+%define lmakeopts @LMAKEOPTS@
 
 # disable build root strip policy
 %define __spec_install_post /usr/lib/rpm/brp-compress || :
@@ -42,7 +44,7 @@ Summary: The Linux kernel (the core of the Linux operating system)
 %define dashtargetboard %{?targetboard:-%{targetboard}}
 %define withtargetboard 0
 %{?targetboard: %{expand: %%define withtargetboard 1}}
-	
+
 # Override generic defaults with per-arch defaults (which can
 # themselves be overridden with --with/--without).  These must
 # ONLY be "0", never "1"
@@ -157,7 +159,7 @@ Group: System Environment/Kernel
 ExclusiveArch: %{all_x86} x86_64 ia64 ppc ppc64
 ExclusiveOS: Linux
 Obsoletes: kernel-modules, kernel-sparc
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 BuildConflicts: rhbuildsys(DiscFree) < 500Mb
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
@@ -229,7 +231,7 @@ options that can be passed to Linux kernel modules at load time.
 %package smp
 Summary: The Linux kernel compiled for SMP machines.
 Group: System Environment/Kernel
-Provides: module-info, kernel = %{version}
+Provides: module-info, kernel = %{kprovides}
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
 %endif
@@ -248,7 +250,7 @@ Install the kernel-smp package if your machine uses two or more CPUs.
 %package bigsmp
 Summary: The Linux kernel compiled for SMP machines.
 Group: System/Kernel
-Provides: module-info, kernel = %{version}, k_smp4G
+Provides: module-info, kernel = %{kprovides}, k_smp4G
 Obsoletes: k_smp4G
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
@@ -268,7 +270,7 @@ Install the kernel-bigsmp package if your machine uses two or more CPUs.
 %package pseries64
 Summary: Standard Kernel for 64-bit Power based SMP and LPAR Machines
 Group: System/Kernel
-Provides: module-info, kernel = %{version}, k_smp4G
+Provides: module-info, kernel = %{kprovides}, k_smp4G
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
 %endif
@@ -287,7 +289,7 @@ machines.
 %package bigmem
 Summary: The Linux Kernel for machines with more than 4 Gigabyte of memory.
 Group: System Environment/Kernel
-Provides: module-info, kernel = %{version}
+Provides: module-info, kernel = %{kprovides}
 %ifarch %{all_x86} ia64 x86_64
 Provides: kernel-drm = 4.1.0, kernel-drm = 4.2.0, kernel-drm = 4.3.0, kernel-drm = 4.2.99.3
 %endif
@@ -304,7 +306,7 @@ enabled for Pentium III machines with 4 Gigabyte of memory or more.
 %package BOOT
 Summary: The version of the Linux kernel used on installation boot disks.
 Group: System Environment/Kernel
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 %if %{rhbuild}
 Prereq: %{BOOT_kernel_prereq}
 Conflicts: %{kernel_conflicts}
@@ -319,7 +321,7 @@ turned off because of the size constraints.
 %package BOOTsmp
 Summary: The Linux kernel used on installation boot disks for SMP machines.
 Group: System Environment/Kernel
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 %if %{rhbuild}
 Prereq: %{BOOT_kernel_prereq}
 Conflicts: %{kernel_conflicts}
@@ -335,7 +337,7 @@ machines that have trouble coming up to life with the uniprocessor kernel.
 %package jensen
 Summary: The Linux Kernel compiled for the Alpha Jensen platform.
 Group: System Environment/Kernel
-Provides: kernel = %{version}
+Provides: kernel = %{kprovides}
 %if %{rhbuild}
 Prereq: %{kernel_prereq}
 Conflicts: %{kernel_conflicts}
@@ -380,11 +382,11 @@ pushd lustre >/dev/null
 if [ -s "%{SOURCE2}" ] ; then
        tar zxf "%{SOURCE2}" -C lustre/kernel_patches
 fi
-sh -x ./build/lmake \
+bash -x ./build/lmake \
 	--unpack-kernel \
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
-	--kerneldir $RPM_SOURCE_DIR
+	--kerneldir $RPM_SOURCE_DIR %{lmakeopts}
 popd >/dev/null
 
 # handle both SuSE and Red Hat's new-kernel-pkg bits
@@ -515,19 +517,19 @@ mkdir -p $RPM_BUILD_ROOT
 DependKernel()
 {
   target_config=${1:+--target-config $1}
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--depend-kernel \
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
 	${target_config} \
 	--extraversion %{kextraver} \
-	-j $RPM_BUILD_NCPUS
+	-j $RPM_BUILD_NCPUS %{lmakeopts}
 }
 
 BuildKernel()
 {
   target_config=${1:+--target-config $1}
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--build-kernel --build-lustre \
 	--install \
 	--save-headers \
@@ -537,7 +539,7 @@ BuildKernel()
 	--extraversion %{kextraver} \
 	--kerneldir $RPM_SOURCE_DIR \
 	-j $RPM_BUILD_NCPUS \
-	--destdir $RPM_BUILD_ROOT \
+	--destdir $RPM_BUILD_ROOT %{lmakeopts} \
 	-- --enable-tests \
 	@CONFIGURE_FLAGS@
 }
@@ -545,7 +547,7 @@ BuildKernel()
 BuildLustre()
 {
   target_config=${1:+--target-config $1}
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--build-lustre \
 	--install-lustre \
 	--target @LUSTRE_TARGET@ \
@@ -554,7 +556,7 @@ BuildLustre()
 	--extraversion %{kextraver} \
 	--kerneldir $RPM_SOURCE_DIR \
 	-j $RPM_BUILD_NCPUS \
-	--destdir $RPM_BUILD_ROOT \
+	--destdir $RPM_BUILD_ROOT %{lmakeopts} \
 	-- --enable-utils \
 	--disable-doc --disable-tests \
 	--disable-modules --disable-liblustre \
@@ -565,12 +567,12 @@ BuildLustre()
 
 SaveHeaders()
 {
-  sh -x ./build/lmake \
+  bash -x ./build/lmake \
 	--save-headers \
 	--target @LUSTRE_TARGET@ \
 	--target-arch %{_target_cpu} \
 	--extraversion %{kextraver} \
-	--destdir $RPM_BUILD_ROOT
+	--destdir $RPM_BUILD_ROOT %{lmakeopts}
 }
 
 pushd lustre >/dev/null
@@ -645,7 +647,7 @@ BuildObj ()
 	    if grep -q "$oc" Makefile ; then
 	        OLDCONFIG="$oc"
 		break
-   	    fi
+	    fi
         done
 	MAKE="make -s O=$o -C ${c}"
 	if [ "$CC" ] ; then
@@ -661,7 +663,7 @@ BuildObj ()
 $(set -- 2.6.5 ; echo ${*//./ })
 EOF
 	rm -f $o/Makefile
-	ARCH=%{_target_cpu} /bin/sh scripts/mkmakefile ../../../linux-%{KVERREL} $o \
+	ARCH=%{_target_cpu} /bin/bash scripts/mkmakefile ../../../linux-%{KVERREL} $o \
 		$VERSION $PATCHLEVEL > $o/Makefile.in
 	if [ -f $o/Makefile ] ; then
 		# will exist only for 2.6.17 and newer because mkmakefile
@@ -732,7 +734,7 @@ if [ "%{buildbase}" -ne 0 ] ; then
 	    if grep -q "$oc" $RPM_BUILD_ROOT/usr/src/linux-%{KVERREL}/Makefile ; then
 		OLDCONFIG="$oc"
 		break
-   	    fi
+	    fi
         done
 	if [ "$CC" ] ; then
 	    MAKE_CC="CC=$CC"
diff --git a/ldiskfs/config.h.in b/ldiskfs/config.h.in
index f5cffd8..1052e32 100644
--- a/ldiskfs/config.h.in
+++ b/ldiskfs/config.h.in
@@ -1,8 +1,20 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* enable posix acls for ldiskfs */
+#undef CONFIG_LDISKFSDEV_FS_POSIX_ACL
+
+/* enable fs security for ldiskfs */
+#undef CONFIG_LDISKFSDEV_FS_SECURITY
+
+/* enable extented attributes for ldiskfs */
+#undef CONFIG_LDISKFSDEV_FS_XATTR
+
 /* build ldiskfs as a module */
 #undef CONFIG_LDISKFS_FS_MODULE
 
+/* enable fs security for ldiskfs */
+#undef CONFIG_LDISKFS_FS_NFS4ACL
+
 /* enable posix acls for ldiskfs */
 #undef CONFIG_LDISKFS_FS_POSIX_ACL
 
@@ -18,6 +30,9 @@
 /* d_rehash_cond is exported by the kernel */
 #undef HAVE_D_REHASH_COND
 
+/* ldiskfs based on ext4 */
+#undef HAVE_EXT4_LDISKFS
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
diff --git a/ldiskfs/configure b/ldiskfs/configure
index 9b228e0..07c8b48 100755
--- a/ldiskfs/configure
+++ b/ldiskfs/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59 for Lustre ldiskfs 3.0.7.1.
+# Generated by GNU Autoconf 2.59 for Lustre ldiskfs 3.0.9.
 #
 # Report bugs to <https://bugzilla.lustre.org/>.
 #
@@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='Lustre ldiskfs'
 PACKAGE_TARNAME='lustre-ldiskfs'
-PACKAGE_VERSION='3.0.7.1'
-PACKAGE_STRING='Lustre ldiskfs 3.0.7.1'
+PACKAGE_VERSION='3.0.9'
+PACKAGE_STRING='Lustre ldiskfs 3.0.9'
 PACKAGE_BUGREPORT='https://bugzilla.lustre.org/'
 
 ac_unique_file="lustre-ldiskfs.spec.in"
@@ -311,7 +311,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE lb_target_os INCLUDE_RULES RANLIB ac_ct_RANLIB CPP EGREP LLCPPFLAGS LLCFLAGS EXTRA_KCFLAGS LINUX LINUX_OBJ LINUX_CONFIG ARCH_UM UML_CFLAGS MODULE_TARGET linux25 KMODEXT LINUXRELEASE moduledir modulefsdir modulenetdir RELEASE SYMVERFILE MODPOST MODPOST_ARGS MODULES_TRUE MODULES_FALSE LINUX_TRUE LINUX_FALSE DARWIN_TRUE DARWIN_FALSE LINUX25_TRUE LINUX25_FALSE LDISKFSDIR PATCH QUILT USE_QUILT_TRUE USE_QUILT_FALSE LDISKFS_SERIES ac_configure_args MOSTLYCLEANFILES LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE am__leading_dot CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE lb_target_os INCLUDE_RULES RANLIB ac_ct_RANLIB CPP EGREP LLCPPFLAGS LLCFLAGS EXTRA_KCFLAGS LINUX LINUX_OBJ LINUX_CONFIG ARCH_UM UML_CFLAGS MODULE_TARGET linux25 KMODEXT LINUXRELEASE moduledir modulefsdir modulenetdir RELEASE SYMVERFILE MODPOST MODPOST_ARGS MODULES_TRUE MODULES_FALSE LINUX_TRUE LINUX_FALSE DARWIN_TRUE DARWIN_FALSE LINUX25_TRUE LINUX25_FALSE LDISKFSDIR PATCH QUILT USE_QUILT_TRUE USE_QUILT_FALSE BACKFS BACKFSU USE_EXT4_TRUE USE_EXT4_FALSE LDISKFS_SERIES ac_configure_args MOSTLYCLEANFILES LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -780,7 +780,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Lustre ldiskfs 3.0.7.1 to adapt to many kinds of systems.
+\`configure' configures Lustre ldiskfs 3.0.9 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -847,7 +847,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Lustre ldiskfs 3.0.7.1:";;
+     short | recursive ) echo "Configuration of Lustre ldiskfs 3.0.9:";;
    esac
   cat <<\_ACEOF
 
@@ -858,6 +858,7 @@ Optional Features:
   --enable-dependency-tracking  Do not reject slow dependency extractors
   --disable-modules       disable building of Lustre kernel modules
   --disable-quilt         disable use of quilt for ldiskfs
+  --enable-ext4           enable building of ldiskfs based on ext4
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -869,6 +870,7 @@ Optional Packages:
   --with-kernel-source-header=path
                           Use a different kernel version header. Consult
                           build/README.kernel-source for details.
+  --with-o2ib=path        build o2iblnd against path
 
 Some influential environment variables:
   CC          C compiler command
@@ -978,7 +980,7 @@ fi
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
-Lustre ldiskfs configure 3.0.7.1
+Lustre ldiskfs configure 3.0.9
 generated by GNU Autoconf 2.59
 
 Copyright (C) 2003 Free Software Foundation, Inc.
@@ -992,7 +994,7 @@ cat >&5 <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Lustre ldiskfs $as_me 3.0.7.1, which was
+It was created by Lustre ldiskfs $as_me 3.0.9, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   $ $0 $@
@@ -1690,7 +1692,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='lustre-ldiskfs'
- VERSION='3.0.7.1'
+ VERSION='3.0.9'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3964,7 +3966,7 @@ echo "$as_me: WARNING: set compiler with -m64" >&2;}
 	CC="$CC -m64"
 fi
 
-CPPFLAGS="-I\$(top_builddir)/$LIBCFS_INCLUDE_DIR -I\$(top_srcdir)/$LIBCFS_INCLUDE_DIR-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
+CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
 
 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
 
@@ -3987,6 +3989,7 @@ EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include
 
 
 
+
 echo "$as_me:$LINENO: checking whether to build kernel modules" >&5
 echo $ECHO_N "checking whether to build kernel modules... $ECHO_C" >&6
 # Check whether --enable-modules or --disable-modules was given.
@@ -4014,7 +4017,15 @@ echo $ECHO_N "checking for Linux sources... $ECHO_C" >&6
 # Check whether --with-linux or --without-linux was given.
 if test "${with_linux+set}" = set; then
   withval="$with_linux"
-  LINUX=$with_linux
+
+		if ! [[ $with_linux = /* ]]; then
+			{ { echo "$as_me:$LINENO: error: You must provide an absolute pathname to the --with-linux= option." >&5
+echo "$as_me: error: You must provide an absolute pathname to the --with-linux= option." >&2;}
+   { (exit 1); exit 1; }; }
+		else
+			LINUX=$with_linux
+		fi
+
 else
   LINUX=/usr/src/linux
 fi;
@@ -4158,17 +4169,13 @@ fi
 echo "$as_me:$LINENO: result: `eval echo '${'$as_lb_File'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_lb_File'}'`" >&6
 if test `eval echo '${'$as_lb_File'}'` = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$LINUX_OBJ/include/linux/autoconf.h" | $as_tr_cpp` 1
-_ACEOF
-
-
+  :
 else
   { { echo "$as_me:$LINENO: error: Run make config in $LINUX." >&5
 echo "$as_me: error: Run make config in $LINUX." >&2;}
    { (exit 1); exit 1; }; }
 fi
+
 as_lb_File=`echo "lb_cv_file_$LINUX_OBJ/include/linux/version.h" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $LINUX_OBJ/include/linux/version.h" >&5
 echo $ECHO_N "checking for $LINUX_OBJ/include/linux/version.h... $ECHO_C" >&6
@@ -4184,12 +4191,7 @@ fi
 echo "$as_me:$LINENO: result: `eval echo '${'$as_lb_File'}'`" >&5
 echo "${ECHO_T}`eval echo '${'$as_lb_File'}'`" >&6
 if test `eval echo '${'$as_lb_File'}'` = yes; then
-
-cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$LINUX_OBJ/include/linux/version.h" | $as_tr_cpp` 1
-_ACEOF
-
-
+  :
 else
   { { echo "$as_me:$LINENO: error: Run make config in $LINUX." >&5
 echo "$as_me: error: Run make config in $LINUX." >&2;}
@@ -4254,8 +4256,8 @@ if test -e $LINUX/include/asm-um ; then
 		echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
     	else
-		echo "$as_me:$LINENO: result: no (asm doesn't point at asm-um)" >&5
-echo "${ECHO_T}no (asm doesn't point at asm-um)" >&6
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
 	fi
 else
 	echo "$as_me:$LINENO: result: no (asm-um missing)" >&5
@@ -4556,7 +4558,7 @@ int
 main (void)
 {
 
-		#ifndef RHEL_MAJOR
+		#ifndef RHEL_RELEASE_CODE
 		#error "not redhat kernel"
 		#endif
 
@@ -4579,6 +4581,7 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   (exit $ac_status); }; }; then
 
 		RHEL_KENEL="yes"
+		RHEL_KERNEL="yes"
 		echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
 
@@ -4587,14 +4590,14 @@ else
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-		echo "$as_me:$LINENO: result: no" >&5
+	        echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
-echo "$as_me:$LINENO: checking that SuSe kernel" >&5
-echo $ECHO_N "checking that SuSe kernel... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with CONFIG_SUSE_KERNEL" >&5
+echo $ECHO_N "checking if Linux was built with CONFIG_SUSE_KERNEL... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -4602,15 +4605,15 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-		#include <linux/version.h>
+#include <linux/autoconf.h>
 
 int
 main (void)
 {
 
-		#ifndef SLE_VERSION_CODE
-		#error "not sles kernel"
-		#endif
+#ifndef CONFIG_SUSE_KERNEL
+#error CONFIG_SUSE_KERNEL not #defined
+#endif
 
   ;
   return 0;
@@ -4630,28 +4633,30 @@ if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
 
-		SUSE_KERNEL="yes"
-		echo "$as_me:$LINENO: result: yes" >&5
+echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6
+SUSE_KERNEL="yes"
 
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 
-		echo "$as_me:$LINENO: result: no" >&5
+echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 
+
 fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
 
 
+
 echo "$as_me:$LINENO: checking Linux kernel architecture" >&5
 echo $ECHO_N "checking Linux kernel architecture... $ECHO_C" >&6
           if rm -f $PWD/build/arch
                  make -s --no-print-directory echoarch -f $PWD/build/Makefile \
-                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX_OBJ $ARCH_UM \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`; then
   echo "$as_me:$LINENO: result: $LINUX_ARCH" >&5
 echo "${ECHO_T}$LINUX_ARCH" >&6
@@ -4674,11 +4679,6 @@ echo "${ECHO_T}$SYMVERFILE" >&6
 
 
 
-#if test $LINUX_ARCH == "powerpc64"; then
-#	AC_MSG_WARN([set compiler with -m64])
-#	CFLAGS="$CFLAGS -m64"
-#	CC="$CC -m64"
-#fi
 
 echo "$as_me:$LINENO: checking if Linux was built with CONFIG_MODULES" >&5
 echo $ECHO_N "checking if Linux was built with CONFIG_MODULES... $ECHO_C" >&6
@@ -4792,64 +4792,6 @@ fi
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
 
 
-echo "$as_me:$LINENO: checking if Linux was built with CONFIG_PREEMPT" >&5
-echo $ECHO_N "checking if Linux was built with CONFIG_PREEMPT... $ECHO_C" >&6
-cat >conftest.c <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-#include <linux/autoconf.h>
-
-int
-main (void)
-{
-
-#ifndef CONFIG_PREEMPT
-#error CONFIG_PREEMPT not #defined
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-
-rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
-if { ac_try='cp conftest.c build && make -d modules ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_LNET_INCLUDE -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-	{ { echo "$as_me:$LINENO: error: Lustre does not support kernels with preempt enabled." >&5
-echo "$as_me: error: Lustre does not support kernels with preempt enabled." >&2;}
-   { (exit 1); exit 1; }; }
-
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-
-
-fi
-rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko build/conftest.c conftest.c
-
-
 echo "$as_me:$LINENO: checking if Linux was built with CONFIG_KALLSYMS" >&5
 echo $ECHO_N "checking if Linux was built with CONFIG_KALLSYMS... $ECHO_C" >&6
 cat >conftest.c <<_ACEOF
@@ -4973,6 +4915,81 @@ rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.
 
 #LB_LINUX_CONFIG_BIG_STACK
 
+# it's ugly to be doing anything with OFED outside of the lnet module, but
+# this has to be done here so that the backports path is set before all of
+# the LN_PROG_LINUX checks are done
+echo "$as_me:$LINENO: checking whether to use any OFED backport headers" >&5
+echo $ECHO_N "checking whether to use any OFED backport headers... $ECHO_C" >&6
+# set default
+
+# Check whether --with-o2ib or --without-o2ib was given.
+if test "${with_o2ib+set}" = set; then
+  withval="$with_o2ib"
+
+		case $with_o2ib in
+		yes)    O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+			ENABLEO2IB=2
+			;;
+		no)     ENABLEO2IB=0
+			;;
+		*)      O2IBPATHS=$with_o2ib
+			ENABLEO2IB=3
+			;;
+		esac
+
+else
+
+		O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
+		ENABLEO2IB=1
+
+fi;
+if test $ENABLEO2IB -eq 0; then
+	echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+else
+	o2ib_found=false
+	for O2IBPATH in $O2IBPATHS; do
+		if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
+			   -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+			o2ib_found=true
+			break
+		fi
+	done
+	if ! $o2ib_found; then
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+		case $ENABLEO2IB in
+			1) ;;
+			2) { { echo "$as_me:$LINENO: error: kernel OpenIB gen2 headers not present" >&5
+echo "$as_me: error: kernel OpenIB gen2 headers not present" >&2;}
+   { (exit 1); exit 1; }; };;
+			3) { { echo "$as_me:$LINENO: error: bad --with-o2ib path" >&5
+echo "$as_me: error: bad --with-o2ib path" >&2;}
+   { (exit 1); exit 1; }; };;
+			*) { { echo "$as_me:$LINENO: error: internal error" >&5
+echo "$as_me: error: internal error" >&2;}
+   { (exit 1); exit 1; }; };;
+		esac
+	else
+                if test -f $O2IBPATH/config.mk; then
+			. $O2IBPATH/config.mk
+                elif test -f $O2IBPATH/ofed_patch.mk; then
+			. $O2IBPATH/ofed_patch.mk
+		fi
+		if test -n "$BACKPORT_INCLUDES"; then
+			OFED_BACKPORT_PATH=`echo $BACKPORT_INCLUDES | sed "s#.*/src/ofa_kernel/#$O2IBPATH/#"`
+			EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
+			echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+		else
+			echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+                fi
+	fi
+fi
+
 
 if test x$linux25 = xyes ; then
 
@@ -5053,7 +5070,7 @@ fi
 
           ac_config_headers="$ac_config_headers config.h"
 
-CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
+CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
 
 
@@ -5240,6 +5257,78 @@ cat >>confdefs.h <<\_ACEOF
 _ACEOF
 
 
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFSDEV_FS_POSIX_ACL 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFSDEV_FS_XATTR 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFSDEV_FS_SECURITY 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_LDISKFS_FS_NFS4ACL 1
+_ACEOF
+
+
+
+
+echo "$as_me:$LINENO: checking whether to build ldiskfs based on ext4" >&5
+echo $ECHO_N "checking whether to build ldiskfs based on ext4... $ECHO_C" >&6
+if test x$RHEL_KERNEL = xyes; then
+	# Check whether --enable-ext4 or --disable-ext4 was given.
+if test "${enable_ext4+set}" = set; then
+  enableval="$enable_ext4"
+
+else
+  enable_ext4='no'
+fi;
+else
+	case $LINUXRELEASE in
+	# ext4 was in 2.6.22-2.6.26 but not stable enough to use
+	2.6.206*) enable_ext4='no' ;;
+	*) if test -f $LINUX/fs/ext4/ext4.h ; then
+enable_ext4='yes'
+else
+enable_ext4='no'
+fi
+ ;;
+	esac
+fi
+echo "$as_me:$LINENO: result: $enable_ext4" >&5
+echo "${ECHO_T}$enable_ext4" >&6
+
+if test x$enable_ext4 = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_EXT4_LDISKFS 1
+_ACEOF
+
+	BACKFS=ext4
+else
+	BACKFS=ext3
+fi
+
+
+BACKFSU=${BACKFS/ext/EXT}
+ # We need a Upper string
+
+
+
+if test x$enable_ext4 = xyes; then
+  USE_EXT4_TRUE=
+  USE_EXT4_FALSE='#'
+else
+  USE_EXT4_TRUE='#'
+  USE_EXT4_FALSE=
+fi
+
 
 echo "$as_me:$LINENO: checking which ldiskfs series to use" >&5
 echo $ECHO_N "checking which ldiskfs series to use... $ECHO_C" >&6
@@ -5253,12 +5342,17 @@ case $LINUXRELEASE in
 2.6.16*) LDISKFS_SERIES="2.6-sles10.series";;
 2.6.18*)
 	if test x$RHEL_KENEL = xyes; then
-		LDISKFS_SERIES="2.6-rhel5.series"
+                if test x$enable_ext4 = xyes; then
+		        LDISKFS_SERIES="2.6-rhel5-ext4.series"
+                else
+		        LDISKFS_SERIES="2.6-rhel5.series"
+                fi
 	else
 		LDISKFS_SERIES="2.6.18-vanilla.series"
 	fi
 	;;
 2.6.22*) LDISKFS_SERIES="2.6.22-vanilla.series";;
+2.6.27*) LDISKFS_SERIES="2.6-sles11.series";;
 *) { echo "$as_me:$LINENO: WARNING: Unknown kernel version $LINUXRELEASE, fix ldiskfs/configure.ac" >&5
 echo "$as_me: WARNING: Unknown kernel version $LINUXRELEASE, fix ldiskfs/configure.ac" >&2;}
 esac
@@ -5268,8 +5362,8 @@ echo "${ECHO_T}$LDISKFS_SERIES" >&6
 
 
 
-echo "$as_me:$LINENO: checking if Linux was built with symbol d_rehash_cond is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol d_rehash_cond is exported... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with symbol d_rehash_cond exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol d_rehash_cond exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]d_rehash_cond[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -5306,8 +5400,8 @@ _ACEOF
 fi
 
 
-echo "$as_me:$LINENO: checking if Linux was built with symbol __d_rehash is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol __d_rehash is exported... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with symbol __d_rehash exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol __d_rehash exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]__d_rehash[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -5344,8 +5438,8 @@ _ACEOF
 fi
 
 
-echo "$as_me:$LINENO: checking if Linux was built with symbol d_move_locked is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol d_move_locked is exported... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with symbol d_move_locked exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol d_move_locked exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]d_move_locked[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -5382,8 +5476,8 @@ _ACEOF
 fi
 
 
-echo "$as_me:$LINENO: checking if Linux was built with symbol __d_move is exported" >&5
-echo $ECHO_N "checking if Linux was built with symbol __d_move is exported... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking if Linux was built with symbol __d_move exported" >&5
+echo $ECHO_N "checking if Linux was built with symbol __d_move exported... $ECHO_C" >&6
 grep -q -E '[[:space:]]__d_move[[:space:]]' $LINUX/$SYMVERFILE 2>/dev/null
 rc=$?
 if test $rc -ne 0; then
@@ -5570,6 +5664,13 @@ echo "$as_me: error: conditional \"USE_QUILT\" was never defined.
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${USE_EXT4_TRUE}" && test -z "${USE_EXT4_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"USE_EXT4\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"USE_EXT4\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
@@ -5841,7 +5942,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by Lustre ldiskfs $as_me 3.0.7.1, which was
+This file was extended by Lustre ldiskfs $as_me 3.0.9, which was
 generated by GNU Autoconf 2.59.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5904,7 +6005,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-Lustre ldiskfs config.status 3.0.7.1
+Lustre ldiskfs config.status 3.0.9
 configured by $0, generated by GNU Autoconf 2.59,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -6192,6 +6293,10 @@ s, at PATCH@,$PATCH,;t t
 s, at QUILT@,$QUILT,;t t
 s, at USE_QUILT_TRUE@,$USE_QUILT_TRUE,;t t
 s, at USE_QUILT_FALSE@,$USE_QUILT_FALSE,;t t
+s, at BACKFS@,$BACKFS,;t t
+s, at BACKFSU@,$BACKFSU,;t t
+s, at USE_EXT4_TRUE@,$USE_EXT4_TRUE,;t t
+s, at USE_EXT4_FALSE@,$USE_EXT4_FALSE,;t t
 s, at LDISKFS_SERIES@,$LDISKFS_SERIES,;t t
 s, at ac_configure_args@,$ac_configure_args,;t t
 s, at MOSTLYCLEANFILES@,$MOSTLYCLEANFILES,;t t
diff --git a/ldiskfs/configure.ac b/ldiskfs/configure.ac
index 759ecda..405b8e3 100644
--- a/ldiskfs/configure.ac
+++ b/ldiskfs/configure.ac
@@ -1,6 +1,6 @@
 # Process this file with autoconf to produce a configure script.
 
-AC_INIT([Lustre ldiskfs], 3.0.7.1, [https://bugzilla.lustre.org/])
+AC_INIT([Lustre ldiskfs], 3.0.9, [https://bugzilla.lustre.org/])
 AC_CONFIG_SRCDIR([lustre-ldiskfs.spec.in])
 
 # Don't look for install-sh, etc. in ..
@@ -33,6 +33,13 @@ $2
 esac
 ])
 
+AC_DEFUN([LC_KERNEL_WITH_EXT4],
+[if test -f $LINUX/fs/ext4/ext4.h ; then
+$1
+else
+$2
+fi
+])
 
 AC_MSG_CHECKING([whether to build kernel modules])
 AC_ARG_ENABLE([modules],
@@ -83,6 +90,35 @@ AM_CONDITIONAL(USE_QUILT, test x$QUILT != xno)
 
 LB_DEFINE_LDISKFS_OPTIONS
 
+AC_MSG_CHECKING([whether to build ldiskfs based on ext4])
+if test x$RHEL_KERNEL = xyes; then
+	AC_ARG_ENABLE([ext4],
+		AC_HELP_STRING([--enable-ext4],
+			     [enable building of ldiskfs based on ext4]),
+			     [], [enable_ext4='no'])
+else
+	case $LINUXRELEASE in
+	# ext4 was in 2.6.22-2.6.26 but not stable enough to use
+	2.6.2[06]*) enable_ext4='no' ;;
+	*) LC_KERNEL_WITH_EXT4([enable_ext4='yes'],
+			       [enable_ext4='no']) ;;
+	esac
+fi
+AC_MSG_RESULT([$enable_ext4])
+
+if test x$enable_ext4 = xyes ; then
+	AC_DEFINE(HAVE_EXT4_LDISKFS, 1, [ldiskfs based on ext4])
+	BACKFS=ext4
+else
+	BACKFS=ext3
+fi
+
+AC_SUBST(BACKFS)
+BACKFSU=${BACKFS/ext/EXT}
+AC_SUBST(BACKFSU) # We need a Upper string
+
+AM_CONDITIONAL(USE_EXT4, test x$enable_ext4 = xyes)
+
 AC_MSG_CHECKING([which ldiskfs series to use])
 case $LINUXRELEASE in
 2.6.5*) LDISKFS_SERIES="2.6-suse.series" ;;
@@ -94,12 +130,17 @@ case $LINUXRELEASE in
 2.6.16*) LDISKFS_SERIES="2.6-sles10.series";;
 2.6.18*)
 	if test x$RHEL_KENEL = xyes; then
-		LDISKFS_SERIES="2.6-rhel5.series"
+                if test x$enable_ext4 = xyes; then
+		        LDISKFS_SERIES="2.6-rhel5-ext4.series"
+                else
+		        LDISKFS_SERIES="2.6-rhel5.series"
+                fi
 	else
 		LDISKFS_SERIES="2.6.18-vanilla.series"
 	fi
 	;;
 2.6.22*) LDISKFS_SERIES="2.6.22-vanilla.series";;
+2.6.27*) LDISKFS_SERIES="2.6-sles11.series";;
 *) AC_MSG_WARN([Unknown kernel version $LINUXRELEASE, fix ldiskfs/configure.ac])
 esac
 AC_MSG_RESULT([$LDISKFS_SERIES])
diff --git a/ldiskfs/kernel_patches/patches/alloc-policy-2.6-rhlel5.diff b/ldiskfs/kernel_patches/patches/alloc-policy-2.6-rhlel5.diff
new file mode 100644
index 0000000..800574b
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/alloc-policy-2.6-rhlel5.diff
@@ -0,0 +1,99 @@
+diff -Nrpu /tmp/linux-stage/fs/ext3/ialloc.c linux-stage/fs/ext3/ialloc.c
+--- /tmp/linux-stage/fs/ext3/ialloc.c	2009-05-09 06:44:02.000000000 +0400
++++ linux-stage/fs/ext3/ialloc.c	2009-05-09 06:45:33.000000000 +0400
+@@ -822,6 +822,36 @@ fail_drop:
+ 	return ERR_PTR(err);
+ }
+ 
++unsigned long ext3_find_reverse(struct super_block *sb)
++{
++	struct ext3_group_desc *desc;
++	struct buffer_head *bitmap_bh = NULL;
++	int group;
++	unsigned long ino, offset;
++
++	for (offset = (EXT3_INODES_PER_GROUP(sb) >> 1); offset >= 0;
++	     offset >>= 1) {
++		for (group = EXT3_SB(sb)->s_groups_count - 1; group >= 0;
++		     --group) {
++			desc = ext3_get_group_desc(sb, group, NULL);
++			if (desc->bg_free_inodes_count == 0)
++				continue;
++
++			bitmap_bh = read_inode_bitmap(sb, group);
++			if (!bitmap_bh)
++				continue;
++
++			ino = ext3_find_next_zero_bit((unsigned long *)
++					bitmap_bh->b_data,
++					EXT3_INODES_PER_GROUP(sb), offset);
++			if (ino < EXT3_INODES_PER_GROUP(sb))
++				return(group * EXT3_INODES_PER_GROUP(sb) +
++				       ino + 1);
++		}
++	}
++	return 0;
++}
++
+ /* Verify that we are loading a valid orphan from disk */
+ struct inode *ext3_orphan_get(struct super_block *sb, unsigned long ino)
+ {
+diff -Nrpu /tmp/linux-stage/fs/ext3/namei.c linux-stage/fs/ext3/namei.c
+--- /tmp/linux-stage/fs/ext3/namei.c	2009-05-09 06:44:02.000000000 +0400
++++ linux-stage/fs/ext3/namei.c	2009-05-09 06:45:33.000000000 +0400
+@@ -145,14 +145,25 @@ struct dx_map_entry
+ 	u32 offs;
+ };
+ 
++/*
++ * dentry_param used by ext3_new_inode_wantedi()
++ */
+ #define LVFS_DENTRY_PARAM_MAGIC		20070216UL
+ struct lvfs_dentry_params
+ {
+-	unsigned long   p_inum;
+-	void            *p_ptr;	
+-	u32		magic;
++	unsigned long   ldp_inum;
++	long		ldp_flags;
++	u32		ldp_magic;
+ };
+ 
++/* Only use the least 3 bits of ldp_flags for goal policy */
++typedef enum {
++	DP_GOAL_POLICY       = 0,
++	DP_LASTGROUP_REVERSE = 1,
++} dp_policy_t;
++
++#define LDP_FLAGS_RANGE 0x07
++
+ #ifdef CONFIG_EXT3_INDEX
+ static inline unsigned dx_get_block (struct dx_entry *entry);
+ static void dx_set_block (struct dx_entry *entry, unsigned value);
+@@ -1718,8 +1727,13 @@ static struct inode * ext3_new_inode_wan
+ 	if (dentry->d_fsdata != NULL) {
+ 		struct lvfs_dentry_params *param = dentry->d_fsdata;
+ 
+-		if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
+-			inum = param->p_inum;
++		if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC) {
++			if ((dp_policy_t)(param->ldp_flags & LDP_FLAGS_RANGE) ==
++			    DP_LASTGROUP_REVERSE)
++				inum = ext3_find_reverse(dir->i_sb);
++                        else /* DP_GOAL_POLICY */
++				inum = param->ldp_inum;
++                }
+ 	}
+ 	return ext3_new_inode(handle, dir, mode, inum);
+ }
+diff -Nrpu /tmp/linux-stage/include/linux/ext3_fs.h linux-stage/include/linux/ext3_fs.h
+--- /tmp/linux-stage/include/linux/ext3_fs.h	2009-05-09 06:44:02.000000000 +0400
++++ linux-stage/include/linux/ext3_fs.h	2009-05-09 06:45:33.000000000 +0400
+@@ -973,6 +973,7 @@ extern int ext3fs_dirhash(const char *na
+ /* ialloc.c */
+ extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
+ 				      unsigned long);
++extern unsigned long ext3_find_reverse(struct super_block *);
+ extern void ext3_free_inode (handle_t *, struct inode *);
+ extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
+ extern unsigned long ext3_count_free_inodes (struct super_block *);
diff --git a/ldiskfs/kernel_patches/patches/export-ext4-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/export-ext4-2.6-rhel5.patch
new file mode 100644
index 0000000..9f33c4f
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/export-ext4-2.6-rhel5.patch
@@ -0,0 +1,69 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/super.c
++++ linux-2.6.18-128.1.6/fs/ext4/super.c
+@@ -185,6 +185,8 @@ void ext4_journal_abort_handle(const cha
+ 	jbd2_journal_abort_handle(handle);
+ }
+ 
++EXPORT_SYMBOL(ext4_journal_abort_handle);
++
+ /* Deal with the reporting of failure conditions on a filesystem such as
+  * inconsistencies detected or read IO failures.
+  *
+@@ -2459,6 +2461,8 @@ out_fail:
+ 	return ret;
+ }
+ 
++EXPORT_SYMBOL(ext4_force_commit);
++
+ /*
+  * Setup any per-fs journal parameters now.  We'll do this both on
+  * initial mount, once the journal has been initialised but before we've
+@@ -3502,6 +3506,12 @@ int ext4_map_inode_page(struct inode *in
+ 			unsigned long *blocks, int *created, int create);
+ EXPORT_SYMBOL(ext4_map_inode_page);
+ 
++EXPORT_SYMBOL(ext4_xattr_get);
++EXPORT_SYMBOL(ext4_xattr_set_handle);
++EXPORT_SYMBOL(ext4_bread);
++EXPORT_SYMBOL(ext4_journal_start_sb);
++EXPORT_SYMBOL(__ext4_journal_stop);
++
+ MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
+ MODULE_DESCRIPTION("Fourth Extended Filesystem with extents");
+ MODULE_LICENSE("GPL");
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4.h
+@@ -1024,6 +1024,8 @@ extern unsigned long ext4_count_free_ino
+ extern unsigned long ext4_count_dirs (struct super_block *);
+ extern void ext4_check_inodes_bitmap (struct super_block *);
+ extern unsigned long ext4_count_free (struct buffer_head *, unsigned);
++extern struct buffer_head *ext4_read_inode_bitmap(struct super_block *sb,
++						  ext4_group_t block_group);
+ 
+ /* mballoc.c */
+ extern long ext4_mb_stats;
+Index: linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ialloc.c
++++ linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+@@ -96,7 +96,7 @@ unsigned ext4_init_inode_bitmap(struct s
+  *
+  * Return buffer_head of bitmap on success or NULL.
+  */
+-static struct buffer_head *
++struct buffer_head *
+ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
+ {
+ 	struct ext4_group_desc *desc;
+@@ -137,6 +137,7 @@ ext4_read_inode_bitmap(struct super_bloc
+ 	}
+ 	return bh;
+ }
++EXPORT_SYMBOL(ext4_read_inode_bitmap);
+ 
+ /*
+  * NOTE! When we get the inode, we're the only people
diff --git a/ldiskfs/kernel_patches/patches/export-ext4-2.6-sles11.patch b/ldiskfs/kernel_patches/patches/export-ext4-2.6-sles11.patch
new file mode 100644
index 0000000..0d151fc
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/export-ext4-2.6-sles11.patch
@@ -0,0 +1,69 @@
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -185,6 +185,8 @@ void ext4_journal_abort_handle(const cha
+ 	jbd2_journal_abort_handle(handle);
+ }
+ 
++EXPORT_SYMBOL(ext4_journal_abort_handle);
++
+ /* Deal with the reporting of failure conditions on a filesystem such as
+  * inconsistencies detected or read IO failures.
+  *
+@@ -2459,6 +2461,8 @@ out_fail:
+ 	return ret;
+ }
+ 
++EXPORT_SYMBOL(ext4_force_commit);
++
+ /*
+  * Setup any per-fs journal parameters now.  We'll do this both on
+  * initial mount, once the journal has been initialised but before we've
+@@ -3502,6 +3506,12 @@ int ext4_map_inode_page(struct inode *in
+ 			unsigned long *blocks, int *created, int create);
+ EXPORT_SYMBOL(ext4_map_inode_page);
+ 
++EXPORT_SYMBOL(ext4_xattr_get);
++EXPORT_SYMBOL(ext4_xattr_set_handle);
++EXPORT_SYMBOL(ext4_bread);
++EXPORT_SYMBOL(ext4_journal_start_sb);
++EXPORT_SYMBOL(__ext4_journal_stop);
++
+ MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
+ MODULE_DESCRIPTION("Fourth Extended Filesystem with extents");
+ MODULE_LICENSE("GPL");
+Index: linux-stage/fs/ext4/ext4.h
+===================================================================
+--- linux-stage.orig/fs/ext4/ext4.h
++++ linux-stage/fs/ext4/ext4.h
+@@ -1097,6 +1097,8 @@ extern struct inode * ext4_orphan_get(st
+ extern unsigned long ext4_count_free_inodes(struct super_block *);
+ extern unsigned long ext4_count_dirs(struct super_block *);
+ extern void ext4_check_inodes_bitmap(struct super_block *);
++extern struct buffer_head *ext4_read_inode_bitmap(struct super_block *sb,
++                                                  ext4_group_t block_group);
+ 
+ /* mballoc.c */
+ extern long ext4_mb_stats;
+Index: linux-stage/fs/ext4/ialloc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/ialloc.c
++++ linux-stage/fs/ext4/ialloc.c
+@@ -96,7 +96,7 @@ unsigned ext4_init_inode_bitmap(struct s
+  *
+  * Return buffer_head of bitmap on success or NULL.
+  */
+-static struct buffer_head *
++struct buffer_head *
+ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
+ {
+ 	struct ext4_group_desc *desc;
+@@ -159,6 +159,7 @@ ext4_read_inode_bitmap(struct super_bloc
+ 	}
+ 	return bh;
+ }
++EXPORT_SYMBOL(ext4_read_inode_bitmap);
+ 
+ /*
+  * NOTE! When we get the inode, we're the only people
diff --git a/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-rhel4.patch
index 3aced41..bf3ba6c 100644
--- a/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-rhel4.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-rhel4.patch
@@ -627,12 +627,12 @@ Index: linux-2.6.9-67.0.20/fs/ext3/xattr.c
 +	if (value) {
 +		int offs = min_offs - value_len;
 +		/* use last to create new entry */
-+		memset(last, 0, esize);
 +		last->e_name_len = strlen(name);
 +		last->e_name_index = name_index;
 +		last->e_value_offs = cpu_to_le16(offs);
 +		last->e_value_size = cpu_to_le32(value_len);
 +		last->e_hash = last->e_value_block = 0;
++		memset(last->e_name, 0, esize);
 +		memcpy(last->e_name, name, last->e_name_len);
 +		if (start + offs + value_len > end)
 +			printk("ALERT at %s:%d: 0x%p + %d + %zd > 0x%p\n",
diff --git a/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch b/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch
index dcd87ed..18efe81 100644
--- a/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-ea-in-inode-2.6-suse.patch
@@ -617,12 +617,12 @@ Index: linux-2.6.5-7.311/fs/ext3/xattr.c
 +	if (value) {
 +		int offs = min_offs - value_len;
 +		/* use last to create new entry */
-+		memset(last, 0, esize);
 +		last->e_name_len = strlen(name);
 +		last->e_name_index = name_index;
 +		last->e_value_offs = cpu_to_le16(offs);
 +		last->e_value_size = cpu_to_le32(value_len);
 +		last->e_hash = last->e_value_block = 0;
++		memset(last->e_name, 0, esize);
 +		memcpy(last->e_name, name, last->e_name_len);
 +		if (start + offs + value_len > end)
 +			printk("ALERT at %s:%d: 0x%p + %d + %zd > 0x%p\n",
diff --git a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.16-sles10.patch b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.16-sles10.patch
index f1f94f2..bbccd36 100644
--- a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.16-sles10.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.16-sles10.patch
@@ -970,7 +970,7 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/extents.c
 +}
 +
 +/*
-+ * returns first allocated block from next leaf or EXT_MAX_BLOCK
++ * returns first allocated block from next leaf or EXT_UNSET_BLOCK
 + */
 +static unsigned ext3_ext_next_leaf_block(struct ext3_extents_tree *tree,
 +					 struct ext3_ext_path *path)
@@ -982,7 +982,7 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/extents.c
 +
 +	/* zero-tree has no leaf blocks at all */
 +	if (depth == 0)
-+		return EXT_MAX_BLOCK;
++		return EXT_UNSET_BLOCK;
 +
 +	/* go to index block */
 +	depth--;
@@ -994,7 +994,7 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/extents.c
 +		depth--;        
 +	}
 +
-+	return EXT_MAX_BLOCK;
++	return EXT_UNSET_BLOCK;
 +}
 +
 +/*
@@ -1112,7 +1112,7 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/extents.c
 +	/* probably next leaf has space for us? */
 +	fex = EXT_LAST_EXTENT(eh);
 +	next = ext3_ext_next_leaf_block(tree, path);
-+	if (newext->ee_block > fex->ee_block && next != EXT_MAX_BLOCK) {
++	if (newext->ee_block > fex->ee_block && next != EXT_UNSET_BLOCK) {
 +		ext_debug(tree, "next leaf block - %d\n", next);
 +		EXT_ASSERT(!npath);
 +		npath = ext3_ext_find_extent(tree, next, NULL);
@@ -1577,8 +1577,8 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/extents.c
 +		path[depth].p_ext = ex;
 +	
 +		a = ex->ee_block > start ? ex->ee_block : start;
-+		b = ex->ee_block + ex->ee_len - 1 < end ?
-+			ex->ee_block + ex->ee_len - 1 : end;
++		b = (unsigned long long)ex->ee_block + ex->ee_len - 1 <
++			end ? ex->ee_block + ex->ee_len - 1 : end;
 +		
 +		ext_debug(tree, "  border %u:%u\n", a, b);
 +
@@ -2547,7 +2547,7 @@ Index: linux-2.6.16.54-0.2.5/include/linux/ext3_extents.h
 ===================================================================
 --- /dev/null
 +++ linux-2.6.16.54-0.2.5/include/linux/ext3_extents.h
-@@ -0,0 +1,262 @@
+@@ -0,0 +1,263 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.
 + * Written by Alex Tomas <alex at clusterfs.com>
@@ -2728,6 +2728,7 @@ Index: linux-2.6.16.54-0.2.5/include/linux/ext3_extents.h
 +
 +
 +#define EXT_MAX_BLOCK	0xffffffff
++#define EXT_UNSET_BLOCK 1
 +
 +
 +#define EXT_FIRST_EXTENT(__hdr__) \
diff --git a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.18-vanilla.patch b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.18-vanilla.patch
index d51dbb5..27cfe46 100644
--- a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.18-vanilla.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.18-vanilla.patch
@@ -18,7 +18,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +++ linux-2.6.18.8/fs/ext3/extents.c	2007-07-17 11:08:59.000000000 +0200
 @@ -0,0 +1,2276 @@
 +/*
-+ * Copyright 2008 Sun Microsystems, Inc.
++ * Copyright 2008, Sun Microsystems, Inc.
 + * Written by Alex Tomas <alex at clusterfs.com>
 + *
 + * Architecture independence:
@@ -1037,7 +1037,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +{
 +	struct buffer_head *bh = NULL;
 +	struct ext3_extent_header *eh;
-+	struct ext3_extent_idx *ix;
++	struct ext3_extent_idx *ix = NULL;
 +	struct ext3_extent *ex;
 +	unsigned long block;
 +	int depth;
@@ -1162,7 +1162,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +}
 +
 +/*
-+ * returns first allocated block from next leaf or EXT_MAX_BLOCK
++ * returns first allocated block from next leaf or EXT_UNSET_BLOCK
 + */
 +static unsigned ext3_ext_next_leaf_block(struct inode *inode,
 +					 struct ext3_ext_path *path)
@@ -1174,7 +1174,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +
 +	/* zero-tree has no leaf blocks at all */
 +	if (depth == 0)
-+		return EXT_MAX_BLOCK;
++		return EXT_UNSET_BLOCK;
 +
 +	/* go to index block */
 +	depth--;
@@ -1186,7 +1186,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +		depth--;
 +	}
 +
-+	return EXT_MAX_BLOCK;
++	return EXT_UNSET_BLOCK;
 +}
 +
 +/*
@@ -1309,7 +1309,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +	fex = EXT_LAST_EXTENT(eh);
 +	next = ext3_ext_next_leaf_block(inode, path);
 +	if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
-+	    && next != EXT_MAX_BLOCK) {
++	    && next != EXT_UNSET_BLOCK) {
 +		ext_debug(inode, "next leaf block - %d\n", next);
 +		BUG_ON(npath != NULL);
 +		npath = ext3_ext_find_extent(inode, next, NULL);
@@ -1773,8 +1773,8 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +		path[depth].p_ext = ex;
 +
 +		a = ex_ee_block > start ? ex_ee_block : start;
-+		b = ex_ee_block + ex_ee_len - 1 < EXT_MAX_BLOCK ?
-+			ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
++		b = (unsigned long long)ex_ee_block + ex_ee_len - 1 < 
++		     EXT_MAX_BLOCK ? ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
 +
 +		ext_debug(inode, "  border %u:%u\n", a, b);
 +
@@ -2337,20 +2337,20 @@ Index: linux-2.6.18.8/fs/ext3/inode.c
  	depth = ext3_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
  
 @@ -984,12 +983,10 @@ static int ext3_get_block(struct inode *
+		started = 1;
+	}
  
- get_block:
- 	if (ret == 0) {
--		ret = ext3_get_blocks_handle(handle, inode, iblock,
-+		ret = ext3_get_blocks_wrap(handle, inode, iblock,
+-	ret = ext3_get_blocks_handle(handle, inode, iblock,
++	ret = ext3_get_blocks_wrap(handle, inode, iblock,
  					max_blocks, bh_result, create, 0);
--		if (ret > 0) {
--			bh_result->b_size = (ret << inode->i_blkbits);
-+		if (ret > 0)
- 			ret = 0;
--		}
- 	}
- 	return ret;
- }
+-	if (ret > 0) {
+-		bh_result->b_size = (ret << inode->i_blkbits);
++	if (ret > 0)
+ 		ret = 0;
+-	}
+	if (started)
+		ext3_journal_stop(handle);
+ out:
 @@ -1008,7 +1005,7 @@ struct buffer_head *ext3_getblk(handle_t
  	dummy.b_state = 0;
  	dummy.b_blocknr = -1000;
@@ -2488,7 +2488,7 @@ Index: linux-2.6.18.8/include/linux/ext3_extents.h
 ===================================================================
 --- /dev/null	1970-01-01 00:00:00.000000000 +0000
 +++ linux-2.6.18.8/include/linux/ext3_extents.h	2007-07-17 09:18:14.000000000 +0200
-@@ -0,0 +1,231 @@
+@@ -0,0 +1,232 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.
 + * Written by Alex Tomas <alex at clusterfs.com>
@@ -2642,6 +2642,7 @@ Index: linux-2.6.18.8/include/linux/ext3_extents.h
 +
 +
 +#define EXT_MAX_BLOCK	0xffffffff
++#define EXT_UNSET_BLOCK 1
 +
 +#define EXT_FLAGS_CLR_UNKNOWN	0x7  /* Flags cleared on modification */
 +#define EXT_HDR_GEN_BITS	24
diff --git a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.22-vanilla.patch b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.22-vanilla.patch
index c7f9164..f0358a6 100644
--- a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.22-vanilla.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.22-vanilla.patch
@@ -1037,7 +1037,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +{
 +	struct buffer_head *bh = NULL;
 +	struct ext3_extent_header *eh;
-+	struct ext3_extent_idx *ix;
++	struct ext3_extent_idx *ix = NULL;
 +	struct ext3_extent *ex;
 +	unsigned long block;
 +	int depth;
@@ -1162,7 +1162,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +}
 +
 +/*
-+ * returns first allocated block from next leaf or EXT_MAX_BLOCK
++ * returns first allocated block from next leaf or EXT_UNSET_BLOCK
 + */
 +static unsigned ext3_ext_next_leaf_block(struct inode *inode,
 +					 struct ext3_ext_path *path)
@@ -1174,7 +1174,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +
 +	/* zero-tree has no leaf blocks at all */
 +	if (depth == 0)
-+		return EXT_MAX_BLOCK;
++		return EXT_UNSET_BLOCK;
 +
 +	/* go to index block */
 +	depth--;
@@ -1186,7 +1186,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +		depth--;
 +	}
 +
-+	return EXT_MAX_BLOCK;
++	return EXT_UNSET_BLOCK;
 +}
 +
 +/*
@@ -1309,7 +1309,7 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +	fex = EXT_LAST_EXTENT(eh);
 +	next = ext3_ext_next_leaf_block(inode, path);
 +	if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
-+	    && next != EXT_MAX_BLOCK) {
++	    && next != EXT_UNSET_BLOCK) {
 +		ext_debug(inode, "next leaf block - %d\n", next);
 +		BUG_ON(npath != NULL);
 +		npath = ext3_ext_find_extent(inode, next, NULL);
@@ -1773,8 +1773,8 @@ Index: linux-2.6.18.8/fs/ext3/extents.c
 +		path[depth].p_ext = ex;
 +
 +		a = ex_ee_block > start ? ex_ee_block : start;
-+		b = ex_ee_block + ex_ee_len - 1 < EXT_MAX_BLOCK ?
-+			ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
++		b = (unsigned long long)ex_ee_block + ex_ee_len - 1 < 
++		     EXT_MAX_BLOCK ? ex_ee_block + ex_ee_len - 1 : EXT_MAX_BLOCK;
 +
 +		ext_debug(inode, "  border %u:%u\n", a, b);
 +
@@ -2489,7 +2489,7 @@ Index: linux-2.6.18.8/include/linux/ext3_extents.h
 ===================================================================
 --- /dev/null	1970-01-01 00:00:00.000000000 +0000
 +++ linux-2.6.18.8/include/linux/ext3_extents.h	2007-07-17 09:18:14.000000000 +0200
-@@ -0,0 +1,231 @@
+@@ -0,0 +1,232 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.
 + * Written by Alex Tomas <alex at clusterfs.com>
@@ -2643,6 +2643,7 @@ Index: linux-2.6.18.8/include/linux/ext3_extents.h
 +
 +
 +#define EXT_MAX_BLOCK	0xffffffff
++#define EXT_UNSET_BLOCK 1
 +
 +#define EXT_FLAGS_CLR_UNKNOWN	0x7  /* Flags cleared on modification */
 +#define EXT_HDR_GEN_BITS	24
diff --git a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.5.patch b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.5.patch
index 4bef709..de538f0 100644
--- a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.5.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.5.patch
@@ -2402,7 +2402,7 @@ Index: linux-2.6.5-7.311/fs/ext3/super.c
 ===================================================================
 --- linux-2.6.5-7.311.orig/fs/ext3/super.c
 +++ linux-2.6.5-7.311/fs/ext3/super.c
-@@ -390,6 +390,7 @@ void ext3_put_super (struct super_block 
+@@ -389,6 +389,7 @@ void ext3_put_super (struct super_block 
  	struct ext3_super_block *es = sbi->s_es;
  	int i;
  
@@ -2410,7 +2410,7 @@ Index: linux-2.6.5-7.311/fs/ext3/super.c
  	ext3_xattr_put_super(sb);
  	journal_destroy(sbi->s_journal);
  	if (!(sb->s_flags & MS_RDONLY)) {
-@@ -451,6 +452,8 @@ static struct inode *ext3_alloc_inode(st
+@@ -450,6 +451,8 @@ static struct inode *ext3_alloc_inode(st
  #endif
  	ei->i_rsv_window.rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
  	ei->vfs_inode.i_version = 1;
@@ -2419,7 +2419,7 @@ Index: linux-2.6.5-7.311/fs/ext3/super.c
  	return &ei->vfs_inode;
  }
  
-@@ -615,6 +618,7 @@ enum {
+@@ -584,6 +587,7 @@ enum {
  	Opt_ignore, Opt_barrier,
  	Opt_err,
  	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
@@ -2427,7 +2427,7 @@ Index: linux-2.6.5-7.311/fs/ext3/super.c
  };
  
  static match_table_t tokens = {
-@@ -658,6 +662,9 @@ static match_table_t tokens = {
+@@ -627,6 +631,9 @@ static match_table_t tokens = {
  	{Opt_iopen, "iopen"},
  	{Opt_noiopen, "noiopen"},
  	{Opt_iopen_nopriv, "iopen_nopriv"},
@@ -2437,7 +2437,7 @@ Index: linux-2.6.5-7.311/fs/ext3/super.c
  	{Opt_barrier, "barrier=%u"},
  	{Opt_err, NULL}
  };
-@@ -874,6 +881,15 @@ static int parse_options (char * options
+@@ -843,6 +850,15 @@ static int parse_options (char * options
  			break;
  		case Opt_ignore:
  			break;
@@ -2453,7 +2453,7 @@ Index: linux-2.6.5-7.311/fs/ext3/super.c
  		default:
  			printk (KERN_ERR
  				"EXT3-fs: Unrecognized mount option \"%s\" "
-@@ -1528,6 +1544,8 @@ static int ext3_fill_super (struct super
+@@ -1495,6 +1511,8 @@ static int ext3_fill_super (struct super
  	percpu_counter_mod(&sbi->s_dirs_counter,
  		ext3_count_dirs(sb));
  
diff --git a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.9-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.9-rhel4.patch
index d565468..655d665 100644
--- a/ldiskfs/kernel_patches/patches/ext3-extents-2.6.9-rhel4.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-extents-2.6.9-rhel4.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.9-67.0.15/fs/ext3/extents.c
+Index: linux-2.6.9-67.0.20/fs/ext3/extents.c
 ===================================================================
 --- /dev/null
-+++ linux-2.6.9-67.0.15/fs/ext3/extents.c
++++ linux-2.6.9-67.0.20/fs/ext3/extents.c
 @@ -0,0 +1,2265 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.
@@ -2260,7 +2260,7 @@ Index: linux-2.6.9-67.0.15/fs/ext3/extents.c
 +	ext3_init_tree_desc(&tree, inode);
 +	return ext3_ext_calc_metadata_amount(&tree, blocks);
 +}
-+
++	
 +EXPORT_SYMBOL(ext3_init_tree_desc);
 +EXPORT_SYMBOL(ext3_mark_inode_dirty);
 +EXPORT_SYMBOL(ext3_ext_invalidate_cache);
@@ -2268,10 +2268,10 @@ Index: linux-2.6.9-67.0.15/fs/ext3/extents.c
 +EXPORT_SYMBOL(ext3_ext_walk_space);
 +EXPORT_SYMBOL(ext3_ext_find_goal);
 +EXPORT_SYMBOL(ext3_ext_calc_credits_for_insert);
-Index: linux-2.6.9-67.0.15/fs/ext3/ialloc.c
+Index: linux-2.6.9-67.0.20/fs/ext3/ialloc.c
 ===================================================================
---- linux-2.6.9-67.0.15.orig/fs/ext3/ialloc.c
-+++ linux-2.6.9-67.0.15/fs/ext3/ialloc.c
+--- linux-2.6.9-67.0.20.orig/fs/ext3/ialloc.c
++++ linux-2.6.9-67.0.20/fs/ext3/ialloc.c
 @@ -602,7 +602,7 @@ got:
  	ei->i_dir_start_lookup = 0;
  	ei->i_disksize = 0;
@@ -2300,10 +2300,10 @@ Index: linux-2.6.9-67.0.15/fs/ext3/ialloc.c
  	err = ext3_mark_inode_dirty(handle, inode);
  	if (err) {
  		ext3_std_error(sb, err);
-Index: linux-2.6.9-67.0.15/fs/ext3/inode.c
+Index: linux-2.6.9-67.0.20/fs/ext3/inode.c
 ===================================================================
---- linux-2.6.9-67.0.15.orig/fs/ext3/inode.c
-+++ linux-2.6.9-67.0.15/fs/ext3/inode.c
+--- linux-2.6.9-67.0.20.orig/fs/ext3/inode.c
++++ linux-2.6.9-67.0.20/fs/ext3/inode.c
 @@ -797,6 +797,17 @@ changed:
  	goto reread;
  }
@@ -2334,14 +2334,14 @@ Index: linux-2.6.9-67.0.15/fs/ext3/inode.c
  }
  
 @@ -852,7 +863,7 @@ ext3_direct_io_get_blocks(struct inode *
-		started = 1;
-	}
  
--	ret = ext3_get_block_handle(handle, inode, iblock,
-+	ret = ext3_get_block_wrap(handle, inode, iblock,
-				    bh_result, create, 0);
-
-	if (!ret)
+ get_block:
+ 	if (ret == 0)
+-		ret = ext3_get_block_handle(handle, inode, iblock,
++		ret = ext3_get_block_wrap(handle, inode, iblock,
+ 					bh_result, create, 0);
+ 	bh_result->b_size = (1 << inode->i_blkbits);
+ 	return ret;
 @@ -872,7 +883,7 @@ struct buffer_head *ext3_getblk(handle_t
  	dummy.b_state = 0;
  	dummy.b_blocknr = -1000;
@@ -2380,10 +2380,10 @@ Index: linux-2.6.9-67.0.15/fs/ext3/inode.c
  	if (ext3_should_journal_data(inode))
  		ret = 3 * (bpp + indirects) + 2;
  	else
-Index: linux-2.6.9-67.0.15/fs/ext3/Makefile
+Index: linux-2.6.9-67.0.20/fs/ext3/Makefile
 ===================================================================
---- linux-2.6.9-67.0.15.orig/fs/ext3/Makefile
-+++ linux-2.6.9-67.0.15/fs/ext3/Makefile
+--- linux-2.6.9-67.0.20.orig/fs/ext3/Makefile
++++ linux-2.6.9-67.0.20/fs/ext3/Makefile
 @@ -5,7 +5,8 @@
  obj-$(CONFIG_EXT3_FS) += ext3.o
  
@@ -2394,10 +2394,10 @@ Index: linux-2.6.9-67.0.15/fs/ext3/Makefile
  
  ext3-$(CONFIG_EXT3_FS_XATTR)	 += xattr.o xattr_user.o xattr_trusted.o
  ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
-Index: linux-2.6.9-67.0.15/fs/ext3/super.c
+Index: linux-2.6.9-67.0.20/fs/ext3/super.c
 ===================================================================
---- linux-2.6.9-67.0.15.orig/fs/ext3/super.c
-+++ linux-2.6.9-67.0.15/fs/ext3/super.c
+--- linux-2.6.9-67.0.20.orig/fs/ext3/super.c
++++ linux-2.6.9-67.0.20/fs/ext3/super.c
 @@ -394,6 +394,7 @@ void ext3_put_super (struct super_block 
  	struct ext3_super_block *es = sbi->s_es;
  	int i;
@@ -2415,7 +2415,7 @@ Index: linux-2.6.9-67.0.15/fs/ext3/super.c
  	return &ei->vfs_inode;
  }
  
-@@ -642,6 +645,7 @@ enum {
+@@ -635,6 +638,7 @@ enum {
  	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0,
  	Opt_ignore, Opt_barrier, Opt_err, Opt_resize,
  	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
@@ -2423,7 +2423,7 @@ Index: linux-2.6.9-67.0.15/fs/ext3/super.c
  };
  
  static match_table_t tokens = {
-@@ -691,6 +695,9 @@ static match_table_t tokens = {
+@@ -684,6 +688,9 @@ static match_table_t tokens = {
  	{Opt_iopen, "iopen"},
  	{Opt_noiopen, "noiopen"},
  	{Opt_iopen_nopriv, "iopen_nopriv"},
@@ -2433,7 +2433,7 @@ Index: linux-2.6.9-67.0.15/fs/ext3/super.c
  	{Opt_barrier, "barrier=%u"},
  	{Opt_err, NULL},
  	{Opt_resize, "resize"},
-@@ -999,6 +1006,15 @@ clear_qf_name:
+@@ -988,6 +995,15 @@ clear_qf_name:
  			match_int(&args[0], &option);
  			*n_blocks_count = option;
  			break;
@@ -2449,7 +2449,7 @@ Index: linux-2.6.9-67.0.15/fs/ext3/super.c
  		default:
  			printk (KERN_ERR
  				"EXT3-fs: Unrecognized mount option \"%s\" "
-@@ -1693,6 +1709,8 @@ static int ext3_fill_super (struct super
+@@ -1682,6 +1698,8 @@ static int ext3_fill_super (struct super
  	percpu_counter_mod(&sbi->s_dirs_counter,
  		ext3_count_dirs(sb));
  
@@ -2458,10 +2458,10 @@ Index: linux-2.6.9-67.0.15/fs/ext3/super.c
  	return 0;
  
  failed_mount3:
-Index: linux-2.6.9-67.0.15/include/linux/ext3_fs.h
+Index: linux-2.6.9-67.0.20/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.9-67.0.15.orig/include/linux/ext3_fs.h
-+++ linux-2.6.9-67.0.15/include/linux/ext3_fs.h
+--- linux-2.6.9-67.0.20.orig/include/linux/ext3_fs.h
++++ linux-2.6.9-67.0.20/include/linux/ext3_fs.h
 @@ -185,9 +185,10 @@ struct ext3_group_desc
  #define EXT3_NOTAIL_FL			0x00008000 /* file tail should not be merged */
  #define EXT3_DIRSYNC_FL			0x00010000 /* dirsync behaviour (directories only) */
@@ -2523,10 +2523,10 @@ Index: linux-2.6.9-67.0.15/include/linux/ext3_fs.h
  
  #endif	/* __KERNEL__ */
  
-Index: linux-2.6.9-67.0.15/include/linux/ext3_extents.h
+Index: linux-2.6.9-67.0.20/include/linux/ext3_extents.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.9-67.0.15/include/linux/ext3_extents.h
++++ linux-2.6.9-67.0.20/include/linux/ext3_extents.h
 @@ -0,0 +1,262 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.
@@ -2790,10 +2790,10 @@ Index: linux-2.6.9-67.0.15/include/linux/ext3_extents.h
 +		tree->cex->ec_type = EXT3_EXT_CACHE_NO;
 +}
 +#endif /* _LINUX_EXT3_EXTENTS */
-Index: linux-2.6.9-67.0.15/include/linux/ext3_fs_i.h
+Index: linux-2.6.9-67.0.20/include/linux/ext3_fs_i.h
 ===================================================================
---- linux-2.6.9-67.0.15.orig/include/linux/ext3_fs_i.h
-+++ linux-2.6.9-67.0.15/include/linux/ext3_fs_i.h
+--- linux-2.6.9-67.0.20.orig/include/linux/ext3_fs_i.h
++++ linux-2.6.9-67.0.20/include/linux/ext3_fs_i.h
 @@ -128,6 +128,8 @@ struct ext3_inode_info {
  	 */
  	struct semaphore truncate_sem;
diff --git a/ldiskfs/kernel_patches/patches/ext3-extents-multiblock-directio-2.6-sles10.patch b/ldiskfs/kernel_patches/patches/ext3-extents-multiblock-directio-2.6-sles10.patch
deleted file mode 100644
index 726a473..0000000
--- a/ldiskfs/kernel_patches/patches/ext3-extents-multiblock-directio-2.6-sles10.patch
+++ /dev/null
@@ -1,149 +0,0 @@
---- linux-2.6.9-full/include/linux/ext3_fs.h	2007-03-23 15:57:00.000000000 +0300
-+++ linux-2.6.9-full/include/linux/ext3_fs.h	2007-02-16 17:16:23.000000000 +0300
-@@ -850,7 +850,7 @@ extern struct inode_operations ext3_fast
- 
- /* extents.c */
- extern int ext3_ext_writepage_trans_blocks(struct inode *, int);
--extern int ext3_ext_get_block(handle_t *, struct inode *, long,
-+extern int ext3_ext_get_block(handle_t *, struct inode *, long, int,
- 			      struct buffer_head *, int, int);
- extern void ext3_ext_truncate(struct inode *, struct page *);
- extern void ext3_ext_init(struct super_block *);
-
---- linux-2.6.9-full/fs/ext3/extents.c	2007-03-23 15:57:00.000000000 +0300
-+++ linux-2.6.9-full/fs/ext3/extents.c	2007-02-22 17:45:05.000000000 +0300
-@@ -2031,7 +2168,8 @@ void ext3_init_tree_desc(struct ext3_ext
- }
- 
- int ext3_ext_get_block(handle_t *handle, struct inode *inode,
--		       long iblock, struct buffer_head *bh_result,
-+		       long iblock, int max_blocks, 
-+		       struct buffer_head *bh_result,
- 		       int create, int extend_disksize)
- {
- 	struct ext3_ext_path *path = NULL;
-@@ -2039,6 +2177,11 @@ int ext3_ext_get_block(handle_t *handle,
- 	struct ext3_extent *ex;
- 	int goal, newblock, err = 0, depth;
- 	struct ext3_extents_tree tree;
-+	unsigned long next;
-+	int allocated = 0;
-+
-+	/* until we have multiblock allocation */
-+	max_blocks = 1;
- 
- 	clear_buffer_new(bh_result);
- 	ext3_init_tree_desc(&tree, inode);
-@@ -2058,6 +2201,9 @@ int ext3_ext_get_block(handle_t *handle,
- 		} else if (goal == EXT3_EXT_CACHE_EXTENT) {
- 			/* block is already allocated */
- 			newblock = iblock - newex.ee_block + newex.ee_start;
-+			/* number of remaining blocks in the extent */
-+			EXT_ASSERT(iblock >= newex.ee_block);
-+			allocated = newex.ee_len - (iblock - newex.ee_block);
- 			goto out;
- 		} else {
- 			EXT_ASSERT(0);
-@@ -2085,6 +2231,8 @@ int ext3_ext_get_block(handle_t *handle,
- 		/* if found exent covers block, simple return it */
- 		if (iblock >= ex->ee_block && iblock < ex->ee_block + ex->ee_len) {
- 			newblock = iblock - ex->ee_block + ex->ee_start;
-+			/* number of remaining blocks in the extent */
-+			allocated = ex->ee_len - (iblock - ex->ee_block);
- 			ext_debug(&tree, "%d fit into %d:%d -> %d\n",
- 				  (int) iblock, ex->ee_block, ex->ee_len,
- 				  newblock);
-@@ -2105,6 +2253,15 @@ int ext3_ext_get_block(handle_t *handle,
- 		goto out2;
- 	}
- 
-+	/* find next allocated block so that we know how many
-+	 * blocks we can allocate without ovelapping next extent */
-+	EXT_ASSERT(iblock >= ex->ee_block + ex->ee_len);
-+	next = ext3_ext_next_allocated_block(path);
-+	EXT_ASSERT(next > iblock);
-+	allocated = next - iblock;
-+	if (allocated > max_blocks)
-+		allocated = max_blocks;
-+
- 	/* allocate new block */
- 	goal = ext3_ext_find_goal(inode, path, iblock);
- 	newblock = ext3_new_block(handle, inode, goal, &err);
-@@ -2119,8 +2276,11 @@ int ext3_ext_get_block(handle_t *handle,
- 	newex.ee_start_hi = 0;
- 	newex.ee_len = 1;
- 	err = ext3_ext_insert_extent(handle, &tree, path, &newex);
--	if (err)
-+	if (err) {
-+		/* free data blocks we just allocated */
-+		ext3_free_blocks(handle, inode, newex.ee_start, newex.ee_len);
- 		goto out2;
-+	}
- 	
- 	if (extend_disksize && inode->i_size > EXT3_I(inode)->i_disksize)
- 		EXT3_I(inode)->i_disksize = inode->i_size;
-@@ -2132,8 +2292,11 @@ int ext3_ext_get_block(handle_t *handle,
- 	ext3_ext_put_in_cache(&tree, newex.ee_block, newex.ee_len,
- 			      newex.ee_start, EXT3_EXT_CACHE_EXTENT);
- out:
-+	if (allocated > max_blocks)
-+		allocated = max_blocks;
- 	ext3_ext_show_leaf(&tree, path);
- 	map_bh(bh_result, inode->i_sb, newblock);
-+	bh_result->b_size = (allocated << inode->i_blkbits);
- out2:
- 	if (path) {
- 		ext3_ext_drop_refs(path);
---- linux-2.6.9-full/fs/ext3/inode.c	2007-03-23 15:57:00.000000000 +0300
-+++ linux-2.6.9-full/fs/ext3/inode.c	2007-02-16 17:17:03.000000000 +0300
-@@ -798,13 +798,17 @@ changed:
- 
- static inline int
- ext3_get_block_wrap(handle_t *handle, struct inode *inode, long block,
--		    struct buffer_head *bh, int create, int extend_disksize)
-+			int max_blocks, struct buffer_head *bh, int create,
-+			int extend_disksize)
- {
-+	int ret;
- 	if (EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL)
--		return ext3_ext_get_block(handle, inode, block, bh, create,
--					  extend_disksize);
--	return ext3_get_block_handle(handle, inode, block, bh, create,
-+		return ext3_ext_get_block(handle, inode, block, max_blocks,
-+					bh, create, extend_disksize);
-+	ret = ext3_get_block_handle(handle, inode, block, bh, create,
- 				     extend_disksize);
-+	bh->b_size = (1 << inode->i_blkbits);
-+	return ret;
- }
- 
- static int ext3_get_block(struct inode *inode, sector_t iblock,
-@@ -817,7 +821,7 @@ static int ext3_get_block(struct inode *
- 		handle = ext3_journal_current_handle();
- 		J_ASSERT(handle != 0);
- 	}
--	ret = ext3_get_block_wrap(handle, inode, iblock,
-+	ret = ext3_get_block_wrap(handle, inode, iblock, 1,
- 				  bh_result, create, 1);
- 	return ret;
- }
-@@ -862,9 +866,8 @@ ext3_direct_io_get_blocks(struct inode *
- 
- get_block:
- 	if (ret == 0)
--		ret = ext3_get_block_wrap(handle, inode, iblock,
-+		ret = ext3_get_block_wrap(handle, inode, iblock, max_blocks,
- 					bh_result, create, 0);
--	bh_result->b_size = (1 << inode->i_blkbits);
- 	return ret;
- }
- 
-@@ -882,7 +885,7 @@ struct buffer_head *ext3_getblk(handle_t
- 	dummy.b_state = 0;
- 	dummy.b_blocknr = -1000;
- 	buffer_trace_init(&dummy.b_history);
--	*errp = ext3_get_block_wrap(handle, inode, block, &dummy, create, 1);
-+	*errp = ext3_get_block_wrap(handle, inode, block, 1, &dummy, create, 1);
- 	if (!*errp && buffer_mapped(&dummy)) {
- 		struct buffer_head *bh;
- 		bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
diff --git a/ldiskfs/kernel_patches/patches/ext3-extents-multiblock-directio-2.6.9-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-extents-multiblock-directio-2.6.9-rhel4.patch
index 9344462..726a473 100644
--- a/ldiskfs/kernel_patches/patches/ext3-extents-multiblock-directio-2.6.9-rhel4.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-extents-multiblock-directio-2.6.9-rhel4.patch
@@ -127,19 +127,17 @@
  				  bh_result, create, 1);
  	return ret;
  }
-@@ -862,11 +866,8 @@ ext3_direct_io_get_blocks(struct inode *
-		started = 1;
-	}
-
--	ret = ext3_get_block_wrap(handle, inode, iblock,
-+	ret = ext3_get_block_wrap(handle, inode, iblock, max_blocks,
-				    bh_result, create, 0);
--
--	if (!ret)
--		bh_result->b_size = (1 << inode->i_blkbits);
-
-	if (started)
-		ext3_journal_stop(handle);
+@@ -862,9 +866,8 @@ ext3_direct_io_get_blocks(struct inode *
+ 
+ get_block:
+ 	if (ret == 0)
+-		ret = ext3_get_block_wrap(handle, inode, iblock,
++		ret = ext3_get_block_wrap(handle, inode, iblock, max_blocks,
+ 					bh_result, create, 0);
+-	bh_result->b_size = (1 << inode->i_blkbits);
+ 	return ret;
+ }
+ 
 @@ -882,7 +885,7 @@ struct buffer_head *ext3_getblk(handle_t
  	dummy.b_state = 0;
  	dummy.b_blocknr = -1000;
diff --git a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel4.patch
deleted file mode 100644
index 8f170f3..0000000
--- a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel4.patch
+++ /dev/null
@@ -1,488 +0,0 @@
-A large part of this code is from the generic VFS code in fs/ioctl.c in the
-upstream kernel.
-
-Index: linux-2.6.9-67.0.22/fs/ext3/ioctl.c
-===================================================================
---- linux-2.6.9-67.0.22.orig/fs/ext3/ioctl.c
-+++ linux-2.6.9-67.0.22/fs/ext3/ioctl.c
-@@ -14,7 +14,159 @@
- #include <linux/time.h>
- #include <asm/uaccess.h>
- #include <linux/namei.h>
-+#include "fiemap.h"
- 
-+/* So that the fiemap access checks can't overflow on 32 bit machines. */
-+#define FIEMAP_MAX_EXTENTS     (UINT_MAX / sizeof(struct fiemap_extent))
-+
-+/**
-+ * fiemap_fill_next_extent - Fiemap helper function
-+ * @fieinfo:   Fiemap context passed into ->fiemap
-+ * @logical:   Extent logical start offset, in bytes
-+ * @phys:      Extent physical start offset, in bytes
-+ * @len:	Extent length, in bytes
-+ * @flags:     FIEMAP_EXTENT flags that describe this extent
-+ * @lun:	LUN on which this extent resides
-+ *
-+ * Called from file system ->fiemap callback. Will populate extent
-+ * info as passed in via arguments and copy to user memory. On
-+ * success, extent count on fieinfo is incremented.
-+ *
-+ * Returns 0 on success, -errno on error, 1 if this was the last
-+ * extent that will fit in user array.
-+ */
-+#define SET_UNKNOWN_FLAGS      (FIEMAP_EXTENT_DELALLOC)
-+#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_COMPRESSED	\
-+				|FIEMAP_EXTENT_DATA_ENCRYPTED	\
-+				|FIEMAP_EXTENT_NET)
-+#define SET_NOT_ALIGNED_FLAGS  (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE)
-+int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
-+			    u64 phys, u64 len, u32 flags, dev_t dev)
-+{
-+	struct fiemap_extent extent = { 0 };
-+	struct fiemap_extent *dest = fieinfo->fi_extents_start;
-+
-+	/* only count the extents */
-+	if (fieinfo->fi_extents_max == 0) {
-+		 fieinfo->fi_extents_mapped++;
-+		 return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
-+	}
-+
-+	if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max)
-+		 return 1;
-+
-+	if (flags & SET_UNKNOWN_FLAGS)
-+		 flags |= FIEMAP_EXTENT_UNKNOWN;
-+	if (flags & SET_NO_DIRECT_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NO_DIRECT;
-+	if (flags & SET_NOT_ALIGNED_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NOT_ALIGNED;
-+
-+	extent.fe_logical = logical;
-+	extent.fe_physical = phys;
-+	extent.fe_length = len;
-+	extent.fe_flags = flags;
-+	extent.fe_device = new_encode_dev(dev);
-+
-+	dest += fieinfo->fi_extents_mapped;
-+	if (copy_to_user(dest, &extent, sizeof(extent)))
-+		 return -EFAULT;
-+
-+	fieinfo->fi_extents_mapped++;
-+	if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max)
-+		 return 1;
-+
-+	return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
-+}
-+
-+static int fiemap_check_ranges(struct super_block *sb,
-+			       u64 start, u64 len, u64 *new_len)
-+{
-+	*new_len = len;
-+
-+	if (len == 0)
-+		return -EINVAL;
-+
-+	if (start > sb->s_maxbytes)
-+		return -EFBIG;
-+
-+	/*
-+	 * Shrink request scope to what the fs can actually handle.
-+	 */
-+	if ((len > sb->s_maxbytes) ||
-+	    (sb->s_maxbytes - len) < start)
-+		*new_len = sb->s_maxbytes - start;
-+
-+	return 0;
-+}
-+
-+/*
-+ * fiemap_check_flags - check validity of requested flags for fiemap
-+ * @fieinfo:   Fiemap context passed into ->fiemap
-+ * @fs_flags:  Set of fiemap flags that the file system understands
-+ *
-+ * Called from file system ->fiemap callback. This will compute the
-+ * intersection of valid fiemap flags and those that the fs supports. That
-+ * value is then compared against the user supplied flags. In case of bad user
-+ * flags, the invalid values will be written into the fieinfo structure, and
-+ * -EBADR is returned, which tells ioctl_fiemap() to return those values to
-+ * userspace. For this reason, a return code of -EBADR should be preserved.
-+ *
-+ * Returns 0 on success, -EBADR on bad flags.
-+*/
-+int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags)
-+{
-+	u32 incompat_flags;
-+
-+	incompat_flags = fieinfo->fi_flags & ~(FIEMAP_FLAGS_COMPAT & fs_flags);
-+	if (incompat_flags) {
-+		fieinfo->fi_flags = incompat_flags;
-+		return -EBADR;
-+	}
-+
-+	return 0;
-+}
-+
-+int ioctl_fiemap(struct inode *inode, struct file *filp, unsigned long arg)
-+{
-+	struct fiemap fiemap;
-+	u64 len;
-+	struct fiemap_extent_info fieinfo = {0, };
-+	struct super_block *sb = inode->i_sb;
-+	int error = 0;
-+
-+	if (copy_from_user(&fiemap, (struct fiemap __user *) arg,
-+			     sizeof(struct fiemap)))
-+		 return -EFAULT;
-+
-+	if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS)
-+		 return -EINVAL;
-+
-+	error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length,
-+				    &len);
-+	if (error)
-+		return error;
-+
-+	fieinfo.fi_flags = fiemap.fm_flags;
-+	fieinfo.fi_extents_max = fiemap.fm_extent_count;
-+	fieinfo.fi_extents_start = (struct fiemap_extent *)(arg + sizeof(fiemap));
-+
-+	if (fiemap.fm_extent_count != 0 &&
-+	    !access_ok(VERIFY_WRITE, (void *)arg,
-+		       offsetof(typeof(fiemap), fm_extents[fiemap.fm_extent_count])))
-+		       return -EFAULT;
-+
-+	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
-+		ext3_sync_file(filp, filp->f_dentry, 1);
-+
-+	error = ext3_fiemap(inode, &fieinfo, fiemap.fm_start, len);
-+	fiemap.fm_flags = fieinfo.fi_flags;
-+	fiemap.fm_mapped_extents = fieinfo.fi_extents_mapped;
-+	if (copy_to_user((char *)arg, &fiemap, sizeof(fiemap)))
-+		error = -EFAULT;
-+
-+	return error;
-+}
- 
- int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
- 		unsigned long arg)
-@@ -244,7 +396,9 @@ flags_err:
- 
- 		return err;
- 	}
--
-+	case EXT3_IOC_FIEMAP: {
-+		return ioctl_fiemap(inode, filp, arg);
-+	}
- 
- 	default:
- 		return -ENOTTY;
-Index: linux-2.6.9-67.0.22/include/linux/ext3_fs.h
-===================================================================
---- linux-2.6.9-67.0.22.orig/include/linux/ext3_fs.h
-+++ linux-2.6.9-67.0.22/include/linux/ext3_fs.h
-@@ -259,15 +259,19 @@ struct ext3_new_group_data {
- #define	EXT3_IOC_SETFLAGS		_IOW('f', 2, long)
- #define	EXT3_IOC_GETVERSION		_IOR('f', 3, long)
- #define	EXT3_IOC_SETVERSION		_IOW('f', 4, long)
-+#define EXT3_IOC_GETRSVSZ		_IOR('f', 5, long)
-+#define EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
- #define EXT3_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
- #define EXT3_IOC_GROUP_ADD		_IOW('f', 8,struct ext3_new_group_input)
-+#define EXT3_IOC_FIEMAP			_IOWR('f', 10, struct fiemap)
- #define	EXT3_IOC_GETVERSION_OLD		_IOR('v', 1, long)
- #define	EXT3_IOC_SETVERSION_OLD		_IOW('v', 2, long)
- #ifdef CONFIG_JBD_DEBUG
- #define EXT3_IOC_WAIT_FOR_READONLY	_IOR('f', 99, long)
- #endif
--#define EXT3_IOC_GETRSVSZ		_IOR('f', 5, long)
--#define EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
-+
-+/* FIEMAP flags supported by ext3 */
-+#define EXT3_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC)
- 
- /*
-  * Structure of an inode on the disk
-@@ -969,6 +973,9 @@ extern void ext3_set_aops(struct inode *
- /* ioctl.c */
- extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
- 		       unsigned long);
-+struct fiemap_extent_info;
-+extern int ext3_fiemap(struct inode *, struct fiemap_extent_info *, __u64,
-+		       __u64);
- 
- /* namei.c */
- extern int ext3_orphan_add(handle_t *, struct inode *);
-Index: linux-2.6.9-67.0.22/include/linux/ext3_extents.h
-===================================================================
---- linux-2.6.9-67.0.22.orig/include/linux/ext3_extents.h
-+++ linux-2.6.9-67.0.22/include/linux/ext3_extents.h
-@@ -170,7 +170,10 @@ struct ext3_extents_helpers {
-  */
- typedef int (*ext_prepare_callback)(struct ext3_extents_tree *,
- 				    struct ext3_ext_path *,
--				    struct ext3_ext_cache *);
-+				    struct ext3_ext_cache *,
-+				    struct ext3_extent *);
-+
-+#define HAVE_EXT_PREPARE_CB_EXTENT
- 
- #define EXT_CONTINUE	0
- #define EXT_BREAK	1
-@@ -179,6 +182,25 @@ typedef int (*ext_prepare_callback)(stru
- 
- #define EXT_MAX_BLOCK	0xffffffff
- 
-+/*
-+ * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
-+ * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
-+ * MSB of ee_len field in the extent datastructure to signify if this
-+ * particular extent is an initialized extent or an uninitialized (i.e.
-+ * preallocated).
-+ * EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
-+ * uninitialized extent.
-+ * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
-+ * uninitialized one. In other words, if MSB of ee_len is set, it is an
-+ * uninitialized extent with only one special scenario when ee_len = 0x8000.
-+ * In this case we can not have an uninitialized extent of zero length and
-+ * thus we make it as a special case of initialized extent with 0x8000 length.
-+ * This way we get better extent-to-group alignment for initialized extents.
-+ * Hence, the maximum number of blocks we can have in an *initialized*
-+ * extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
-+ */
-+#define	EXT_INIT_MAX_LEN	(1UL << 15)
-+#define	EXT_UNINIT_MAX_LEN	(EXT_INIT_MAX_LEN - 1)
- 
- #define EXT_FIRST_EXTENT(__hdr__) \
- 	((struct ext3_extent *) (((char *) (__hdr__)) +		\
-@@ -244,6 +266,12 @@ struct ext3_extent_tree_stats {
- 	int leaf_num;
- };
- 
-+static inline int ext3_ext_is_uninitialized(struct ext3_extent *ext)
-+{
-+	/* Extent with ee_len of 0x8000 is treated as an initialized extent */
-+	return (le16_to_cpu(ext->ee_len) > EXT_INIT_MAX_LEN);
-+}
-+
- extern int ext3_ext_search_left(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
- extern int ext3_ext_search_right(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
- extern void ext3_init_tree_desc(struct ext3_extents_tree *, struct inode *);
-Index: linux-2.6.9-67.0.22/fs/ext3/extents.c
-===================================================================
---- linux-2.6.9-67.0.22.orig/fs/ext3/extents.c
-+++ linux-2.6.9-67.0.22/fs/ext3/extents.c
-@@ -41,6 +41,7 @@
- #include <linux/string.h>
- #include <linux/slab.h>
- #include <linux/ext3_extents.h>
-+#include "fiemap.h"
- #include <asm/uaccess.h>
- 
- 
-@@ -1489,7 +1490,7 @@ int ext3_ext_walk_space(struct ext3_exte
- 
- 		EXT_ASSERT(cbex.ec_len > 0);
- 		EXT_ASSERT(path[depth].p_hdr);
--		err = func(tree, path, &cbex);
-+		err = func(tree, path, &cbex, ex);
- 		ext3_ext_drop_refs(path);
- 
- 		if (err < 0)
-@@ -2504,6 +2505,108 @@ int ext3_ext_calc_blockmap_metadata(stru
- 	return ext3_ext_calc_metadata_amount(&tree, blocks);
- }
- 
-+/*
-+ * Callback function called for each extent to gather FIEMAP information.
-+ */
-+int ext3_ext_fiemap_cb(struct ext3_extents_tree *tree,
-+		       struct ext3_ext_path *path, struct ext3_ext_cache *newex,
-+		       struct ext3_extent *ex)
-+{
-+	struct fiemap_extent_info *fieinfo = (struct fiemap_extent_info *)tree->private;
-+	struct inode *inode = tree->inode;
-+	unsigned long blksize_bits = inode->i_sb->s_blocksize_bits;
-+	__u64   logical;
-+	__u64   physical;
-+	__u64   length;
-+	__u32   flags = 0;
-+	int     error;
-+
-+	logical =  (__u64)newex->ec_block << blksize_bits;
-+
-+	if (newex->ec_type == EXT3_EXT_CACHE_GAP) {
-+		pgoff_t offset;
-+		struct page *page;
-+		struct buffer_head *bh = NULL;
-+
-+		offset = logical >> PAGE_SHIFT;
-+		page = find_get_page(inode->i_mapping, offset);
-+		if (!page || !page_has_buffers(page))
-+			return EXT_CONTINUE;
-+
-+		bh = page_buffers(page);
-+
-+		if (!bh)
-+			return EXT_CONTINUE;
-+
-+		if (buffer_delay(bh)) {
-+			flags |= FIEMAP_EXTENT_DELALLOC;
-+			page_cache_release(page);
-+		} else {
-+			page_cache_release(page);
-+			return EXT_CONTINUE;
-+		}
-+	}
-+
-+	physical = (__u64)newex->ec_start << blksize_bits;
-+	length =   (__u64)newex->ec_len << blksize_bits;
-+
-+	if (ex && ext3_ext_is_uninitialized(ex))
-+		flags |= FIEMAP_EXTENT_UNWRITTEN;
-+
-+	/*
-+	 * If this extent reaches EXT_MAX_BLOCK, it must be last.
-+	 *
-+	 * Or if ext3_ext_next_allocated_block is EXT_MAX_BLOCK,
-+	 * this indicates no more allocated blocks.
-+	 *
-+	 * XXX this might miss a single-block extent at EXT_MAX_BLOCK
-+	 */
-+	if (logical + length - 1 == EXT_MAX_BLOCK ||
-+	    ext3_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
-+		flags |= FIEMAP_EXTENT_LAST;
-+
-+	error = fiemap_fill_next_extent(fieinfo, logical, physical,
-+					length, flags, inode->i_sb->s_dev);
-+	if (error < 0)
-+		return error;
-+	if (error == 1)
-+		return EXT_BREAK;
-+
-+	return EXT_CONTINUE;
-+}
-+
-+int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
-+		__u64 start, __u64 len)
-+{
-+	struct ext3_extents_tree tree;
-+	unsigned long start_blk;
-+	unsigned long len_blks;
-+	int error = 0;
-+
-+	if (!(EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL))
-+		return -EOPNOTSUPP;
-+
-+	if (fiemap_check_flags(fieinfo, EXT3_FIEMAP_FLAGS_COMPAT))
-+		return -EBADR;
-+
-+	start_blk = start >> inode->i_sb->s_blocksize_bits;
-+	len_blks = (len + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
-+
-+	ext3_init_tree_desc(&tree, inode);
-+	tree.private = fieinfo;
-+
-+	/*
-+	  * Walk the extent tree gathering extent information.
-+	  * ext3_ext_fiemap_cb will push extents back to user.
-+	  */
-+	down(&EXT3_I(inode)->truncate_sem);
-+	error = ext3_ext_walk_space(&tree, start_blk, len_blks,
-+				    ext3_ext_fiemap_cb);
-+	up(&EXT3_I(inode)->truncate_sem);
-+
-+	return error;
-+}
-+
- EXPORT_SYMBOL(ext3_init_tree_desc);
- EXPORT_SYMBOL(ext3_mark_inode_dirty);
- EXPORT_SYMBOL(ext3_ext_invalidate_cache);
-Index: linux-2.6.9-67.0.22/fs/ext3/fiemap.h
-===================================================================
---- /dev/null
-+++ linux-2.6.9-67.0.22/fs/ext3/fiemap.h
-@@ -0,0 +1,84 @@
-+/*
-+ * FIEMAP ioctl infrastructure.
-+ *
-+ * Copyright 2008 Sun Microsystems, Inc.
-+ *
-+ * Author: Kalpak Shah <kalpak.shah at sun.com>
-+ *	    Andreas Dilger <adilger at sun.com>
-+ */
-+
-+#ifndef _LINUX_EXT3_FIEMAP_H
-+#define _LINUX_EXT3_FIEMAP_H
-+
-+struct fiemap_extent {
-+	__u64 fe_logical;  /* logical offset in bytes for the start of
-+			    * the extent from the beginning of the file */
-+	__u64 fe_physical; /* physical offset in bytes for the start
-+			    * of the extent from the beginning of the disk */
-+	__u64 fe_length;   /* length in bytes for this extent */
-+	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
-+	__u32 fe_device;   /* device number for this extent */
-+};
-+
-+struct fiemap {
-+	__u64 fm_start;	 /* logical offset (inclusive) at
-+				 * which to start mapping (in) */
-+	__u64 fm_length;	/* logical length of mapping which
-+				 * userspace wants (in) */
-+	__u32 fm_flags;	 /* FIEMAP_FLAG_* flags for request (in/out) */
-+	__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
-+	__u32 fm_extent_count;  /* size of fm_extents array (in) */
-+	__u32 fm_reserved;
-+	struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
-+};
-+
-+/*
-+ * FIEMAP helper definition.
-+ */
-+struct fiemap_extent_info {
-+	unsigned int    fi_flags;		/* Flags as passed from user */
-+	unsigned int    fi_extents_mapped;	/* Number of mapped extents */
-+	unsigned int    fi_extents_max;		/* Size of fiemap_extent array*/
-+	struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent array */
-+};
-+
-+int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
-+int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
-+			    u64 phys, u64 len, u32 flags, u32 lun);
-+
-+#define	FIEMAP_MAX_OFFSET	(~0ULL)
-+
-+#define	FIEMAP_FLAG_SYNC	0x00000001 /* sync file data before map */
-+#define	FIEMAP_FLAG_XATTR	0x00000002 /* map extended attribute tree */
-+
-+/* ldiskfs only supports FLAG_SYNC flag currently */
-+#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
-+
-+
-+#define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */
-+#define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */
-+#define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending.
-+						   * Sets EXTENT_UNKNOWN. */
-+#define FIEMAP_EXTENT_NO_DIRECT		0x00000008 /* Data mapping undefined */
-+#define FIEMAP_EXTENT_SECONDARY		0x00000010 /* Data copied offline. May
-+						   * set EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_NET		0x00000020 /* Data stored remotely.
-+						   * Sets EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_DATA_COMPRESSED	0x00000040 /* Data is compressed by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
-+						   * block aligned. */
-+#define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
-+#define FIEMAP_EXTENT_DATA_TAIL		0x00000400 /* Multiple files in block.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
-+#define FIEMAP_EXTENT_UNWRITTEN		0x00000800 /* Space allocated, but
-+						   * no data (i.e. zero). */
-+#define FIEMAP_EXTENT_MERGED		0x00001000 /* File does not natively
-+						   * support extents. Result
-+						   * merged for efficiency. */
-+
-+#endif /* _LINUX_EXT3_FIEMAP_H */
-+
diff --git a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch
index c8b84e5..d4c0e28 100644
--- a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-rhel5.patch
@@ -1,11 +1,11 @@
 A large part of this code is from the generic VFS code in fs/ioctl.c in the
 upstream kernel.
 
-Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
+Index: linux-2.6.18-92.1.22/fs/ext3/ioctl.c
 ===================================================================
---- linux-2.6.18-53.1.14.orig/fs/ext3/ioctl.c
-+++ linux-2.6.18-53.1.14/fs/ext3/ioctl.c
-@@ -15,7 +15,159 @@
+--- linux-2.6.18-92.1.22.orig/fs/ext3/ioctl.c
++++ linux-2.6.18-92.1.22/fs/ext3/ioctl.c
+@@ -15,7 +15,161 @@
  #include <linux/time.h>
  #include <asm/uaccess.h>
  #include <linux/namei.h>
@@ -19,9 +19,9 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
 + * @fieinfo:   Fiemap context passed into ->fiemap
 + * @logical:   Extent logical start offset, in bytes
 + * @phys:      Extent physical start offset, in bytes
-+ * @len:	Extent length, in bytes
++ * @len:       Extent length, in bytes
 + * @flags:     FIEMAP_EXTENT flags that describe this extent
-+ * @lun:	LUN on which this extent resides
++ * @lun:       LUN on which this extent resides
 + *
 + * Called from file system ->fiemap callback. Will populate extent
 + * info as passed in via arguments and copy to user memory. On
@@ -31,9 +31,9 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
 + * extent that will fit in user array.
 + */
 +#define SET_UNKNOWN_FLAGS      (FIEMAP_EXTENT_DELALLOC)
-+#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_COMPRESSED	\
-+				|FIEMAP_EXTENT_DATA_ENCRYPTED	\
++#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_ENCRYPTED	\
 +				|FIEMAP_EXTENT_NET)
++#define SET_NO_UNMOUNTED_IO_FLAGS       (FIEMAP_EXTENT_DATA_ENCRYPTED)
 +#define SET_NOT_ALIGNED_FLAGS  (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE)
 +int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
 +			    u64 phys, u64 len, u32 flags, dev_t dev)
@@ -43,19 +43,21 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
 +
 +	/* only count the extents */
 +	if (fieinfo->fi_extents_max == 0) {
-+		 fieinfo->fi_extents_mapped++;
-+		 return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
++		fieinfo->fi_extents_mapped++;
++		return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
 +	}
 +
 +	if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max)
-+		 return 1;
++		return 1;
 +
 +	if (flags & SET_UNKNOWN_FLAGS)
-+		 flags |= FIEMAP_EXTENT_UNKNOWN;
++		flags |= FIEMAP_EXTENT_UNKNOWN;
 +	if (flags & SET_NO_DIRECT_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NO_DIRECT;
++		flags |= FIEMAP_EXTENT_NO_DIRECT;
 +	if (flags & SET_NOT_ALIGNED_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++		flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++	if (flags & SET_NO_UNMOUNTED_IO_FLAGS)
++		flags |= FIEMAP_EXTENT_ENCODED;
 +
 +	extent.fe_logical = logical;
 +	extent.fe_physical = phys;
@@ -65,11 +67,11 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
 +
 +	dest += fieinfo->fi_extents_mapped;
 +	if (copy_to_user(dest, &extent, sizeof(extent)))
-+		 return -EFAULT;
++		return -EFAULT;
 +
 +	fieinfo->fi_extents_mapped++;
 +	if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max)
-+		 return 1;
++		return 1;
 +
 +	return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
 +}
@@ -131,11 +133,11 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
 +	int error = 0;
 +
 +	if (copy_from_user(&fiemap, (struct fiemap __user *) arg,
-+			     sizeof(struct fiemap)))
++			   sizeof(struct fiemap)))
 +		 return -EFAULT;
 +
 +	if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS)
-+		 return -EINVAL;
++		return -EINVAL;
 +
 +	error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length,
 +				    &len);
@@ -149,7 +151,7 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
 +	if (fiemap.fm_extent_count != 0 &&
 +	    !access_ok(VERIFY_WRITE, (void *)arg,
 +		       offsetof(typeof(fiemap), fm_extents[fiemap.fm_extent_count])))
-+		       return -EFAULT;
++		return -EFAULT;
 +
 +	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
 +		filemap_write_and_wait(inode->i_mapping);
@@ -165,7 +167,7 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
  
  int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
  		unsigned long arg)
-@@ -272,7 +424,9 @@ flags_err:
+@@ -272,7 +426,9 @@ flags_err:
  
  		return err;
  	}
@@ -176,11 +178,11 @@ Index: linux-2.6.18-53.1.14/fs/ext3/ioctl.c
  
  	default:
  		return -ENOTTY;
-Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h
+Index: linux-2.6.18-92.1.22/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.18-53.1.14.orig/include/linux/ext3_fs.h
-+++ linux-2.6.18-53.1.14/include/linux/ext3_fs.h
-@@ -257,15 +257,19 @@ struct ext3_new_group_data {
+--- linux-2.6.18-92.1.22.orig/include/linux/ext3_fs.h
++++ linux-2.6.18-92.1.22/include/linux/ext3_fs.h
+@@ -258,15 +258,19 @@ struct ext3_new_group_data {
  #define	EXT3_IOC_SETFLAGS		_IOW('f', 2, long)
  #define	EXT3_IOC_GETVERSION		_IOR('f', 3, long)
  #define	EXT3_IOC_SETVERSION		_IOW('f', 4, long)
@@ -188,7 +190,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h
 +#define EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
  #define EXT3_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
  #define EXT3_IOC_GROUP_ADD		_IOW('f', 8,struct ext3_new_group_input)
-+#define EXT3_IOC_FIEMAP			_IOWR('f', 10, struct fiemap)
++#define EXT3_IOC_FIEMAP			_IOWR('f', 11, struct fiemap)
  #define	EXT3_IOC_GETVERSION_OLD		_IOR('v', 1, long)
  #define	EXT3_IOC_SETVERSION_OLD		_IOW('v', 2, long)
  #ifdef CONFIG_JBD_DEBUG
@@ -202,7 +204,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h
  
  /*
   *  Mount options
-@@ -1040,6 +1044,9 @@ extern int ext3_block_truncate_page(hand
+@@ -1041,6 +1045,9 @@ extern int ext3_block_truncate_page(hand
  /* ioctl.c */
  extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
  		       unsigned long);
@@ -212,7 +214,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h
  
  /* namei.c */
  extern int ext3_orphan_add(handle_t *, struct inode *);
-@@ -1117,7 +1124,6 @@ ext3_get_blocks_wrap(handle_t *handle, s
+@@ -1118,7 +1125,6 @@ ext3_get_blocks_wrap(handle_t *handle, s
  	return ret;
  }
  
@@ -220,10 +222,10 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h
  #endif	/* __KERNEL__ */
  
  /* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
-Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h
+Index: linux-2.6.18-92.1.22/include/linux/ext3_extents.h
 ===================================================================
---- linux-2.6.18-53.1.14.orig/include/linux/ext3_extents.h
-+++ linux-2.6.18-53.1.14/include/linux/ext3_extents.h
+--- linux-2.6.18-92.1.22.orig/include/linux/ext3_extents.h
++++ linux-2.6.18-92.1.22/include/linux/ext3_extents.h
 @@ -142,8 +142,10 @@ struct ext3_ext_path {
   * callback must return valid extent (passed or newly created)
   */
@@ -237,9 +239,9 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h
  
  #define EXT_CONTINUE	0
  #define EXT_BREAK	1
-@@ -152,6 +154,26 @@ typedef int (*ext_prepare_callback)(stru
- 
+@@ -153,6 +155,26 @@ typedef int (*ext_prepare_callback)(stru
  #define EXT_MAX_BLOCK	0xffffffff
+ #define EXT_UNSET_BLOCK 1
  
 +/*
 + * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
@@ -264,7 +266,7 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h
  #define EXT_FLAGS_CLR_UNKNOWN	0x7  /* Flags cleared on modification */
  #define EXT_HDR_GEN_BITS	24
  #define EXT_HDR_GEN_MASK	((1 << EXT_HDR_GEN_BITS) - 1)
-@@ -219,6 +241,12 @@ ext3_ext_invalidate_cache(struct inode *
+@@ -220,6 +242,12 @@ ext3_ext_invalidate_cache(struct inode *
  	EXT3_I(inode)->i_cached_extent.ec_type = EXT3_EXT_CACHE_NO;
  }
  
@@ -277,10 +279,10 @@ Index: linux-2.6.18-53.1.14/include/linux/ext3_extents.h
  extern int ext3_ext_search_left(struct inode *, struct ext3_ext_path *, unsigned long *, unsigned long *);
  extern int ext3_ext_search_right(struct inode *, struct ext3_ext_path *, unsigned long *, unsigned long *);
  extern int ext3_extent_tree_init(handle_t *, struct inode *);
-Index: linux-2.6.18-53.1.14/fs/ext3/extents.c
+Index: linux-2.6.18-92.1.22/fs/ext3/extents.c
 ===================================================================
---- linux-2.6.18-53.1.14.orig/fs/ext3/extents.c
-+++ linux-2.6.18-53.1.14/fs/ext3/extents.c
+--- linux-2.6.18-92.1.22.orig/fs/ext3/extents.c
++++ linux-2.6.18-92.1.22/fs/ext3/extents.c
 @@ -41,6 +41,7 @@
  #include <linux/string.h>
  #include <linux/slab.h>
@@ -402,11 +404,11 @@ Index: linux-2.6.18-53.1.14/fs/ext3/extents.c
  EXPORT_SYMBOL(ext3_mark_inode_dirty);
  EXPORT_SYMBOL(ext3_ext_invalidate_cache);
  EXPORT_SYMBOL(ext3_ext_insert_extent);
-Index: linux-2.6.18-53.1.14/fs/ext3/fiemap.h
+Index: linux-2.6.18-92.1.22/fs/ext3/fiemap.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.18-53.1.14/fs/ext3/fiemap.h
-@@ -0,0 +1,84 @@
++++ linux-2.6.18-92.1.22/fs/ext3/fiemap.h
+@@ -0,0 +1,85 @@
 +/*
 + * FIEMAP ioctl infrastructure.
 + *
@@ -425,8 +427,10 @@ Index: linux-2.6.18-53.1.14/fs/ext3/fiemap.h
 +	__u64 fe_physical; /* physical offset in bytes for the start
 +			    * of the extent from the beginning of the disk */
 +	__u64 fe_length;   /* length in bytes for this extent */
++	__u64 fe_reserved64[2];
 +	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
 +	__u32 fe_device;   /* device number for this extent */
++	__u32 fe_reserved[2];
 +};
 +
 +struct fiemap {
@@ -463,32 +467,30 @@ Index: linux-2.6.18-53.1.14/fs/ext3/fiemap.h
 +/* ldiskfs only supports FLAG_SYNC flag currently */
 +#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
 +
-+
 +#define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */
 +#define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */
 +#define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending.
-+						   * Sets EXTENT_UNKNOWN. */
-+#define FIEMAP_EXTENT_NO_DIRECT		0x00000008 /* Data mapping undefined */
-+#define FIEMAP_EXTENT_SECONDARY		0x00000010 /* Data copied offline. May
-+						   * set EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_NET		0x00000020 /* Data stored remotely.
-+						   * Sets EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_DATA_COMPRESSED	0x00000040 /* Data is compressed by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
++						    * Sets EXTENT_UNKNOWN. */
++#define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
++						    * while fs is unmounted */
 +#define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
++						    * Sets EXTENT_NO_DIRECT. */
 +#define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
-+						   * block aligned. */
++						    * block aligned. */
 +#define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
++						    * Sets EXTENT_NOT_ALIGNED.*/
 +#define FIEMAP_EXTENT_DATA_TAIL		0x00000400 /* Multiple files in block.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
++						    * Sets EXTENT_NOT_ALIGNED.*/
 +#define FIEMAP_EXTENT_UNWRITTEN		0x00000800 /* Space allocated, but
-+						   * no data (i.e. zero). */
++						    * no data (i.e. zero). */
 +#define FIEMAP_EXTENT_MERGED		0x00001000 /* File does not natively
-+						   * support extents. Result
-+						   * merged for efficiency. */
++						    * support extents. Result
++						    * merged for efficiency. */
++
++/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
++#define FIEMAP_EXTENT_NO_DIRECT		0x40000000 /* Data mapping undefined */
++#define FIEMAP_EXTENT_NET		0x80000000 /* Data stored remotely.
++						    * Sets NO_DIRECT flag */
 +
 +#endif /* _LINUX_EXT3_FIEMAP_H */
 +
-
diff --git a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-sles10.patch b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-sles10.patch
index c1c8dc7..ce5e4d0 100644
--- a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-sles10.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6-sles10.patch
@@ -1,11 +1,11 @@
 A large part of this code is from the generic VFS code in fs/ioctl.c in the
 upstream kernel.
 
-Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
+Index: linux-2.6.9-67.0.22/fs/ext3/ioctl.c
 ===================================================================
---- linux-2.6.16.60-0.23.orig/fs/ext3/ioctl.c
-+++ linux-2.6.16.60-0.23/fs/ext3/ioctl.c
-@@ -15,7 +15,159 @@
+--- linux-2.6.9-67.0.22.orig/fs/ext3/ioctl.c
++++ linux-2.6.9-67.0.22/fs/ext3/ioctl.c
+@@ -14,7 +14,161 @@
  #include <linux/time.h>
  #include <asm/uaccess.h>
  #include <linux/namei.h>
@@ -19,9 +19,9 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
 + * @fieinfo:   Fiemap context passed into ->fiemap
 + * @logical:   Extent logical start offset, in bytes
 + * @phys:      Extent physical start offset, in bytes
-+ * @len:	Extent length, in bytes
++ * @len:       Extent length, in bytes
 + * @flags:     FIEMAP_EXTENT flags that describe this extent
-+ * @lun:	LUN on which this extent resides
++ * @lun:       LUN on which this extent resides
 + *
 + * Called from file system ->fiemap callback. Will populate extent
 + * info as passed in via arguments and copy to user memory. On
@@ -31,9 +31,9 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
 + * extent that will fit in user array.
 + */
 +#define SET_UNKNOWN_FLAGS      (FIEMAP_EXTENT_DELALLOC)
-+#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_COMPRESSED	\
-+				|FIEMAP_EXTENT_DATA_ENCRYPTED	\
++#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_ENCRYPTED	\
 +				|FIEMAP_EXTENT_NET)
++#define SET_NO_UNMOUNTED_IO_FLAGS       (FIEMAP_EXTENT_DATA_ENCRYPTED)
 +#define SET_NOT_ALIGNED_FLAGS  (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE)
 +int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
 +			    u64 phys, u64 len, u32 flags, dev_t dev)
@@ -43,19 +43,21 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
 +
 +	/* only count the extents */
 +	if (fieinfo->fi_extents_max == 0) {
-+		 fieinfo->fi_extents_mapped++;
-+		 return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
++		fieinfo->fi_extents_mapped++;
++		return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
 +	}
 +
 +	if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max)
-+		 return 1;
++		return 1;
 +
 +	if (flags & SET_UNKNOWN_FLAGS)
-+		 flags |= FIEMAP_EXTENT_UNKNOWN;
++		flags |= FIEMAP_EXTENT_UNKNOWN;
 +	if (flags & SET_NO_DIRECT_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NO_DIRECT;
++		flags |= FIEMAP_EXTENT_NO_DIRECT;
 +	if (flags & SET_NOT_ALIGNED_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++		flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++	if (flags & SET_NO_UNMOUNTED_IO_FLAGS)
++		flags |= FIEMAP_EXTENT_ENCODED;
 +
 +	extent.fe_logical = logical;
 +	extent.fe_physical = phys;
@@ -65,11 +67,11 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
 +
 +	dest += fieinfo->fi_extents_mapped;
 +	if (copy_to_user(dest, &extent, sizeof(extent)))
-+		 return -EFAULT;
++		return -EFAULT;
 +
 +	fieinfo->fi_extents_mapped++;
 +	if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max)
-+		 return 1;
++		return 1;
 +
 +	return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
 +}
@@ -131,11 +133,11 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
 +	int error = 0;
 +
 +	if (copy_from_user(&fiemap, (struct fiemap __user *) arg,
-+			     sizeof(struct fiemap)))
++			   sizeof(struct fiemap)))
 +		 return -EFAULT;
 +
 +	if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS)
-+		 return -EINVAL;
++		return -EINVAL;
 +
 +	error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length,
 +				    &len);
@@ -149,7 +151,7 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
 +	if (fiemap.fm_extent_count != 0 &&
 +	    !access_ok(VERIFY_WRITE, (void *)arg,
 +		       offsetof(typeof(fiemap), fm_extents[fiemap.fm_extent_count])))
-+		       return -EFAULT;
++		return -EFAULT;
 +
 +	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
 +		filemap_write_and_wait(inode->i_mapping);
@@ -165,7 +167,7 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
  
  int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
  		unsigned long arg)
-@@ -262,7 +414,9 @@ flags_err:
+@@ -244,7 +398,9 @@ flags_err:
  
  		return err;
  	}
@@ -176,10 +178,10 @@ Index: linux-2.6.16.60-0.23/fs/ext3/ioctl.c
  
  	default:
  		return -ENOTTY;
-Index: linux-2.6.16.60-0.23/include/linux/ext3_fs.h
+Index: linux-2.6.9-67.0.22/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.16.60-0.23.orig/include/linux/ext3_fs.h
-+++ linux-2.6.16.60-0.23/include/linux/ext3_fs.h
+--- linux-2.6.9-67.0.22.orig/include/linux/ext3_fs.h
++++ linux-2.6.9-67.0.22/include/linux/ext3_fs.h
 @@ -260,15 +260,19 @@ struct ext3_new_group_data {
  #define	EXT3_IOC_SETFLAGS		_IOW('f', 2, long)
  #define	EXT3_IOC_GETVERSION		_IOR('f', 3, long)
@@ -188,7 +190,7 @@ Index: linux-2.6.16.60-0.23/include/linux/ext3_fs.h
 +#define EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
  #define EXT3_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
  #define EXT3_IOC_GROUP_ADD		_IOW('f', 8,struct ext3_new_group_input)
-+#define EXT3_IOC_FIEMAP			_IOWR('f', 10, struct fiemap)
++#define EXT3_IOC_FIEMAP			_IOWR('f', 11, struct fiemap)
  #define	EXT3_IOC_GETVERSION_OLD		_IOR('v', 1, long)
  #define	EXT3_IOC_SETVERSION_OLD		_IOW('v', 2, long)
  #ifdef CONFIG_JBD_DEBUG
@@ -201,8 +203,8 @@ Index: linux-2.6.16.60-0.23/include/linux/ext3_fs.h
 +#define EXT3_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC)
  
  /*
-  *  Mount options
-@@ -996,6 +1000,9 @@ extern int ext3_writepage_trans_blocks(s
+  * Structure of an inode on the disk
+@@ -963,6 +967,9 @@ extern void ext3_set_aops(struct inode *
  /* ioctl.c */
  extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
  		       unsigned long);
@@ -212,10 +214,10 @@ Index: linux-2.6.16.60-0.23/include/linux/ext3_fs.h
  
  /* namei.c */
  extern int ext3_orphan_add(handle_t *, struct inode *);
-Index: linux-2.6.16.60-0.23/include/linux/ext3_extents.h
+Index: linux-2.6.9-67.0.22/include/linux/ext3_extents.h
 ===================================================================
---- linux-2.6.16.60-0.23.orig/include/linux/ext3_extents.h
-+++ linux-2.6.16.60-0.23/include/linux/ext3_extents.h
+--- linux-2.6.9-67.0.22.orig/include/linux/ext3_extents.h
++++ linux-2.6.9-67.0.22/include/linux/ext3_extents.h
 @@ -170,7 +170,10 @@ struct ext3_extents_helpers {
   */
  typedef int (*ext_prepare_callback)(struct ext3_extents_tree *,
@@ -254,7 +256,7 @@ Index: linux-2.6.16.60-0.23/include/linux/ext3_extents.h
  
  #define EXT_FIRST_EXTENT(__hdr__) \
  	((struct ext3_extent *) (((char *) (__hdr__)) +		\
-@@ -242,6 +264,12 @@ struct ext3_extent_tree_stats {
+@@ -244,6 +266,12 @@ struct ext3_extent_tree_stats {
  	int leaf_num;
  };
  
@@ -267,10 +269,10 @@ Index: linux-2.6.16.60-0.23/include/linux/ext3_extents.h
  extern int ext3_ext_search_left(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
  extern int ext3_ext_search_right(struct ext3_extents_tree *, struct ext3_ext_path *, unsigned long *, unsigned long *);
  extern void ext3_init_tree_desc(struct ext3_extents_tree *, struct inode *);
-Index: linux-2.6.16.60-0.23/fs/ext3/extents.c
+Index: linux-2.6.9-67.0.22/fs/ext3/extents.c
 ===================================================================
---- linux-2.6.16.60-0.23.orig/fs/ext3/extents.c
-+++ linux-2.6.16.60-0.23/fs/ext3/extents.c
+--- linux-2.6.9-67.0.22.orig/fs/ext3/extents.c
++++ linux-2.6.9-67.0.22/fs/ext3/extents.c
 @@ -41,6 +41,7 @@
  #include <linux/string.h>
  #include <linux/slab.h>
@@ -279,7 +281,7 @@ Index: linux-2.6.16.60-0.23/fs/ext3/extents.c
  #include <asm/uaccess.h>
  
  
-@@ -1488,7 +1489,7 @@ int ext3_ext_walk_space(struct ext3_exte
+@@ -1489,7 +1490,7 @@ int ext3_ext_walk_space(struct ext3_exte
  
  		EXT_ASSERT(cbex.ec_len > 0);
  		EXT_ASSERT(path[depth].p_hdr);
@@ -288,7 +290,7 @@ Index: linux-2.6.16.60-0.23/fs/ext3/extents.c
  		ext3_ext_drop_refs(path);
  
  		if (err < 0)
-@@ -2502,7 +2503,109 @@ int ext3_ext_calc_blockmap_metadata(stru
+@@ -2503,7 +2504,109 @@ int ext3_ext_calc_blockmap_metadata(stru
  	ext3_init_tree_desc(&tree, inode);
  	return ext3_ext_calc_metadata_amount(&tree, blocks);
  }
@@ -399,11 +401,11 @@ Index: linux-2.6.16.60-0.23/fs/ext3/extents.c
  EXPORT_SYMBOL(ext3_init_tree_desc);
  EXPORT_SYMBOL(ext3_mark_inode_dirty);
  EXPORT_SYMBOL(ext3_ext_invalidate_cache);
-Index: linux-2.6.16.60-0.23/fs/ext3/fiemap.h
+Index: linux-2.6.9-67.0.22/fs/ext3/fiemap.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.16.60-0.23/fs/ext3/fiemap.h
-@@ -0,0 +1,84 @@
++++ linux-2.6.9-67.0.22/fs/ext3/fiemap.h
+@@ -0,0 +1,85 @@
 +/*
 + * FIEMAP ioctl infrastructure.
 + *
@@ -422,8 +424,10 @@ Index: linux-2.6.16.60-0.23/fs/ext3/fiemap.h
 +	__u64 fe_physical; /* physical offset in bytes for the start
 +			    * of the extent from the beginning of the disk */
 +	__u64 fe_length;   /* length in bytes for this extent */
++	__u64 fe_reserved64[2];
 +	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
 +	__u32 fe_device;   /* device number for this extent */
++	__u32 fe_reserved[2];
 +};
 +
 +struct fiemap {
@@ -460,31 +464,30 @@ Index: linux-2.6.16.60-0.23/fs/ext3/fiemap.h
 +/* ldiskfs only supports FLAG_SYNC flag currently */
 +#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
 +
-+
 +#define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */
 +#define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */
 +#define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending.
-+						   * Sets EXTENT_UNKNOWN. */
-+#define FIEMAP_EXTENT_NO_DIRECT		0x00000008 /* Data mapping undefined */
-+#define FIEMAP_EXTENT_SECONDARY		0x00000010 /* Data copied offline. May
-+						   * set EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_NET		0x00000020 /* Data stored remotely.
-+						   * Sets EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_DATA_COMPRESSED	0x00000040 /* Data is compressed by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
++						    * Sets EXTENT_UNKNOWN. */
++#define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
++						    * while fs is unmounted */
 +#define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
++						    * Sets EXTENT_NO_DIRECT. */
 +#define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
-+						   * block aligned. */
++						    * block aligned. */
 +#define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
++						    * Sets EXTENT_NOT_ALIGNED.*/
 +#define FIEMAP_EXTENT_DATA_TAIL		0x00000400 /* Multiple files in block.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
++						    * Sets EXTENT_NOT_ALIGNED.*/
 +#define FIEMAP_EXTENT_UNWRITTEN		0x00000800 /* Space allocated, but
-+						   * no data (i.e. zero). */
++						    * no data (i.e. zero). */
 +#define FIEMAP_EXTENT_MERGED		0x00001000 /* File does not natively
-+						   * support extents. Result
-+						   * merged for efficiency. */
++						    * support extents. Result
++						    * merged for efficiency. */
++
++/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
++#define FIEMAP_EXTENT_NO_DIRECT		0x40000000 /* Data mapping undefined */
++#define FIEMAP_EXTENT_NET		0x80000000 /* Data stored remotely.
++						    * Sets NO_DIRECT flag */
 +
 +#endif /* _LINUX_EXT3_FIEMAP_H */
 +
diff --git a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6.18-vanilla.patch b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6.18-vanilla.patch
new file mode 100644
index 0000000..2920823
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6.18-vanilla.patch
@@ -0,0 +1,341 @@
+Index: linux-2.6.18/fs/ext3/ioctl.c
+===================================================================
+--- linux-2.6.18.orig/fs/ext3/ioctl.c
++++ linux-2.6.18/fs/ext3/ioctl.c
+@@ -15,7 +15,7 @@
+ #include <linux/time.h>
+ #include <asm/uaccess.h>
+ #include <linux/namei.h>
+-
++#include "fiemap.h"
+ 
+ int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
+ 		unsigned long arg)
+@@ -272,6 +272,9 @@ flags_err:
+ 
+ 		return err;
+ 	}
++	case EXT3_IOC_FIEMAP: {
++		return ext3_fiemap(inode, filp, cmd, arg);
++	}
+ 
+ 
+ 	default:
+Index: linux-2.6.18/include/linux/ext3_fs.h
+===================================================================
+--- linux-2.6.18.orig/include/linux/ext3_fs.h
++++ linux-2.6.18/include/linux/ext3_fs.h
+@@ -249,7 +249,6 @@ struct ext3_new_group_data {
+ 	__u32 free_blocks_count;
+ };
+ 
+-
+ /*
+  * ioctl commands
+  */
+@@ -257,15 +256,16 @@ struct ext3_new_group_data {
+ #define	EXT3_IOC_SETFLAGS		_IOW('f', 2, long)
+ #define	EXT3_IOC_GETVERSION		_IOR('f', 3, long)
+ #define	EXT3_IOC_SETVERSION		_IOW('f', 4, long)
+-#define EXT3_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
++#define	EXT3_IOC_GETRSVSZ		_IOR('f', 5, long)
++#define	EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
++#define	EXT3_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
+ #define EXT3_IOC_GROUP_ADD		_IOW('f', 8,struct ext3_new_group_input)
++#define	EXT3_IOC_FIEMAP			_IOWR('f', 10, struct fiemap)
+ #define	EXT3_IOC_GETVERSION_OLD		_IOR('v', 1, long)
+ #define	EXT3_IOC_SETVERSION_OLD		_IOW('v', 2, long)
+ #ifdef CONFIG_JBD_DEBUG
+ #define EXT3_IOC_WAIT_FOR_READONLY	_IOR('f', 99, long)
+ #endif
+-#define EXT3_IOC_GETRSVSZ		_IOR('f', 5, long)
+-#define EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
+ 
+ /*
+  *  Mount options
+@@ -1117,6 +1117,8 @@ ext3_get_blocks_wrap(handle_t *handle, s
+ 		bh->b_size = (ret << inode->i_blkbits);
+ 	return ret;
+ }
++extern int ext3_fiemap(struct inode *, struct file *, unsigned int,
++		       unsigned long);
+ 
+ 
+ #endif	/* __KERNEL__ */
+Index: linux-2.6.18/include/linux/ext3_extents.h
+===================================================================
+--- linux-2.6.18.orig/include/linux/ext3_extents.h
++++ linux-2.6.18/include/linux/ext3_extents.h
+@@ -142,8 +142,9 @@ struct ext3_ext_path {
+  * callback must return valid extent (passed or newly created)
+  */
+ typedef int (*ext_prepare_callback)(struct inode *, struct ext3_ext_path *,
+-					struct ext3_ext_cache *,
+-					void *);
++				    struct ext3_ext_cache *,
++				    struct ext3_extent *, void *);
++#define HAVE_EXT_PREPARE_CB_EXTENT
+ 
+ #define EXT_CONTINUE	0
+ #define EXT_BREAK	1
+@@ -152,6 +152,26 @@ typedef int (*ext_prepare_callback)(stru
+ 
+ #define EXT_MAX_BLOCK	0xffffffff
+ 
++/*
++ * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
++ * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
++ * MSB of ee_len field in the extent datastructure to signify if this
++ * particular extent is an initialized extent or an uninitialized (i.e.
++ * preallocated).
++ * EXT_UNINIT_MAX_LEN is the maximum number of blocks we can have in an
++ * uninitialized extent.
++ * If ee_len is <= 0x8000, it is an initialized extent. Otherwise, it is an
++ * uninitialized one. In other words, if MSB of ee_len is set, it is an
++ * uninitialized extent with only one special scenario when ee_len = 0x8000.
++ * In this case we can not have an uninitialized extent of zero length and
++ * thus we make it as a special case of initialized extent with 0x8000 length.
++ * This way we get better extent-to-group alignment for initialized extents.
++ * Hence, the maximum number of blocks we can have in an *initialized*
++ * extent is 2^15 (32768) and in an *uninitialized* extent is 2^15-1 (32767).
++ */
++#define EXT_INIT_MAX_LEN	(1UL << 15)
++#define EXT_UNINIT_MAX_LEN	(EXT_INIT_MAX_LEN - 1)
++
+ #define EXT_FLAGS_CLR_UNKNOWN	0x7  /* Flags cleared on modification */
+ #define EXT_HDR_GEN_BITS	24
+ #define EXT_HDR_GEN_MASK	((1 << EXT_HDR_GEN_BITS) - 1)
+@@ -219,6 +239,13 @@ ext3_ext_invalidate_cache(struct inode *
+ 	EXT3_I(inode)->i_cached_extent.ec_type = EXT3_EXT_CACHE_NO;
+ }
+ 
++static inline int ext3_ext_is_uninitialized(struct ext3_extent *ext)
++{
++	/* Extent with ee_len of 0x8000 is treated as an initialized extent */
++	return (le16_to_cpu(ext->ee_len) > EXT_INIT_MAX_LEN);
++}
++
++
+ extern int ext3_ext_search_left(struct inode *, struct ext3_ext_path *, unsigned long *, unsigned long *);
+ extern int ext3_ext_search_right(struct inode *, struct ext3_ext_path *, unsigned long *, unsigned long *);
+ extern int ext3_extent_tree_init(handle_t *, struct inode *);
+Index: linux-2.6.18/fs/ext3/extents.c
+===================================================================
+--- linux-2.6.18.orig/fs/ext3/extents.c
++++ linux-2.6.18/fs/ext3/extents.c
+@@ -42,7 +42,7 @@
+ #include <linux/slab.h>
+ #include <linux/ext3_extents.h>
+ #include <asm/uaccess.h>
+-
++#include "fiemap.h"
+ 
+ static handle_t *ext3_ext_journal_restart(handle_t *handle, int needed)
+ {
+@@ -1477,7 +1477,7 @@ int ext3_ext_walk_space(struct inode *in
+ 		}
+ 
+ 		BUG_ON(cbex.ec_len == 0);
+-		err = func(inode, path, &cbex, cbdata);
++		err = func(inode, path, &cbex, ex, cbdata);
+ 		ext3_ext_drop_refs(path);
+ 
+ 		if (err < 0)
+@@ -2289,6 +2289,143 @@ int ext3_ext_writepage_trans_blocks(stru
+ 	return needed;
+ }
+ 
++struct fiemap_internal {
++	struct fiemap		*fiemap_s;
++	struct fiemap_extent    fm_extent;
++	size_t			tot_mapping_len;
++	char			*cur_ext_ptr;
++	int			current_extent;
++	int			err;
++};
++
++/*
++ * Callback function called for each extent to gather fiemap information.
++ */
++int ext3_ext_fiemap_cb(struct inode *inode, struct ext3_ext_path *path,
++		       struct ext3_ext_cache *newex, struct ext3_extent *ex,
++		       void *data)
++{
++	struct fiemap_internal *fiemap_i = data;
++	struct fiemap *fiemap_s = fiemap_i->fiemap_s;
++	struct fiemap_extent *fm_extent = &fiemap_i->fm_extent;
++	int current_extent = fiemap_i->current_extent;
++	unsigned long blksize_bits = inode->i_sb->s_blocksize_bits;
++
++	/*
++	 * ext3_ext_walk_space returns a hole for extents that have not been
++	 * allocated yet.
++	 */
++	if (((u64)(newex->ec_block + newex->ec_len) << blksize_bits >=
++	     inode->i_size) && !ext3_ext_is_uninitialized(ex) &&
++	    newex->ec_type == EXT3_EXT_CACHE_GAP)
++		return EXT_BREAK;
++
++	/*
++	 * We only need to return number of extents.
++	 */
++	if (fiemap_s->fm_flags & FIEMAP_FLAG_NUM_EXTENTS)
++		goto count_extents;
++
++	if (current_extent >= fiemap_s->fm_extent_count)
++		return EXT_BREAK;
++
++	memset(fm_extent, 0, sizeof(*fm_extent));
++	fm_extent->fe_offset = (__u64)newex->ec_start << blksize_bits;
++	fm_extent->fe_length = (__u64)newex->ec_len << blksize_bits;
++	fiemap_i->tot_mapping_len += fm_extent->fe_length;
++
++	if (newex->ec_type == EXT3_EXT_CACHE_GAP)
++		fm_extent->fe_flags |= FIEMAP_EXTENT_HOLE;
++
++	if (ext3_ext_is_uninitialized(ex))
++		fm_extent->fe_flags |= (FIEMAP_EXTENT_DELALLOC |
++					FIEMAP_EXTENT_UNMAPPED);
++
++	/*
++	 * Mark this fiemap_extent as FIEMAP_EXTENT_EOF if it's past the end
++	 * of file.
++	 */
++	if ((u64)(newex->ec_block + newex->ec_len) << blksize_bits >=
++								inode->i_size)
++		fm_extent->fe_flags |= FIEMAP_EXTENT_EOF;
++
++	if (!copy_to_user(fiemap_i->cur_ext_ptr, fm_extent,
++			  sizeof(struct fiemap_extent))) {
++		fiemap_i->cur_ext_ptr += sizeof(struct fiemap_extent);
++	} else {
++		fiemap_i->err = -EFAULT;
++		return EXT_BREAK;
++	}
++
++count_extents:
++	fiemap_i->current_extent++;
++
++	/*
++	 * Stop if we are beyond requested mapping size but return complete last
++	 * extent.
++	 */
++	if ((u64)(newex->ec_block + newex->ec_len) << blksize_bits >=
++	    fiemap_s->fm_length)
++		return EXT_BREAK;
++
++	return EXT_CONTINUE;
++}
++
++int ext3_fiemap(struct inode *inode, struct file *filp, unsigned int cmd,
++		unsigned long arg)
++{
++	struct fiemap *fiemap_s;
++	struct fiemap_internal fiemap_i;
++	struct fiemap_extent *last_extent;
++	ext3_fsblk_t start_blk;
++	int err = 0;
++
++	if (!(EXT3_I(inode)->i_flags & EXT3_EXTENTS_FL))
++		return -EOPNOTSUPP;
++
++	fiemap_s = kmalloc(sizeof(*fiemap_s), GFP_KERNEL);
++	if (fiemap_s == NULL)
++		return -ENOMEM;
++	if (copy_from_user(fiemap_s, (struct fiemap __user *)arg,
++			   sizeof(*fiemap_s)))
++		return -EFAULT;
++
++	if (fiemap_s->fm_flags & FIEMAP_FLAG_INCOMPAT)
++		return -EOPNOTSUPP;
++
++	if (fiemap_s->fm_flags & FIEMAP_FLAG_SYNC)
++		ext3_sync_file(filp, filp->f_dentry, 1);
++
++	start_blk = (fiemap_s->fm_start + inode->i_sb->s_blocksize - 1) >>
++						inode->i_sb->s_blocksize_bits;
++	fiemap_i.fiemap_s = fiemap_s;
++	fiemap_i.tot_mapping_len = 0;
++	fiemap_i.cur_ext_ptr = (char *)(arg + sizeof(*fiemap_s));
++	fiemap_i.current_extent = 0;
++	fiemap_i.err = 0;
++
++	/*
++	 * Walk the extent tree gathering extent information
++	 */
++	mutex_lock(&EXT3_I(inode)->truncate_mutex);
++	err = ext3_ext_walk_space(inode, start_blk , EXT_MAX_BLOCK - start_blk,
++				  ext3_ext_fiemap_cb, &fiemap_i);
++	mutex_unlock(&EXT3_I(inode)->truncate_mutex);
++	if (err)
++		return err;
++
++	fiemap_s->fm_extent_count = fiemap_i.current_extent;
++	fiemap_s->fm_length = fiemap_i.tot_mapping_len;
++	if (fiemap_i.current_extent != 0 &&
++	    !(fiemap_s->fm_flags & FIEMAP_FLAG_NUM_EXTENTS)) {
++		last_extent = &fiemap_i.fm_extent;
++		last_extent->fe_flags |= FIEMAP_EXTENT_LAST;
++	}
++	err = copy_to_user((void *)arg, fiemap_s, sizeof(*fiemap_s));
++
++	return err;
++}
++
+ EXPORT_SYMBOL(ext3_mark_inode_dirty);
+ EXPORT_SYMBOL(ext3_ext_invalidate_cache);
+ EXPORT_SYMBOL(ext3_ext_insert_extent);
+Index: linux-2.6.18/fs/ext3/fiemap.h
+===================================================================
+--- /dev/null
++++ linux-2.6.18/fs/ext3/fiemap.h
+@@ -0,0 +1,49 @@
++/*
++ * linux/fs/ext3/fiemap.h
++ *
++ * Copyright 2008 Sun Microsystems, Inc.
++ *
++ * Author: Kalpak Shah <kalpak at clusterfs.com>
++ */
++
++#ifndef _LINUX_EXT3_FIEMAP_H
++#define _LINUX_EXT3_FIEMAP_H
++
++struct fiemap_extent {
++	__u64	fe_offset; /* offset in bytes for the start of the extent */
++	__u64	fe_length; /* length in bytes for the extent */
++	__u32	fe_flags;  /* returned FIEMAP_EXTENT_* flags for the extent */
++	__u32	fe_lun;	   /* logical device number for extent (starting at 0)*/
++};
++
++/*
++ * fiemap is not ext3-specific and should be moved into fs.h eventually.
++ */
++
++struct fiemap {
++	__u64	fm_start;	 /* logical starting byte offset (in/out) */
++	__u64	fm_length;	 /* logical length of map (in/out) */
++	__u32	fm_flags;	 /* FIEMAP_FLAG_* flags for request (in/out) */
++	__u32	fm_extent_count; /* number of extents in fm_extents (in/out) */
++	__u64	fm_unused;
++	struct fiemap_extent	fm_extents[0];
++};
++
++#define	FIEMAP_FLAG_SYNC	0x00000001 /* sync file data before map */
++#define	FIEMAP_FLAG_HSM_READ	0x00000002 /* get data from HSM before map */
++#define	FIEMAP_FLAG_NUM_EXTENTS	0x00000004 /* return only number of extents */
++#define	FIEMAP_FLAG_INCOMPAT	0xff000000 /* error for unknown flags in here */
++
++#define	FIEMAP_EXTENT_HOLE	0x00000001 /* has no data or space allocation */
++#define	FIEMAP_EXTENT_UNWRITTEN	0x00000002 /* space allocated, but no data */
++#define	FIEMAP_EXTENT_UNMAPPED	0x00000004 /* has data but no space allocation*/
++#define	FIEMAP_EXTENT_ERROR	0x00000008 /* mapping error, errno in fe_start*/
++#define	FIEMAP_EXTENT_NO_DIRECT	0x00000010 /* cannot access data directly */
++#define	FIEMAP_EXTENT_LAST	0x00000020 /* last extent in the file */
++#define	FIEMAP_EXTENT_DELALLOC	0x00000040 /* has data but not yet written,
++					    * must have EXTENT_UNKNOWN set */
++#define	FIEMAP_EXTENT_SECONDARY	0x00000080 /* data (also) in secondary storage,
++					    * not in primary if EXTENT_UNKNOWN*/
++#define	FIEMAP_EXTENT_EOF	0x00000100 /* if fm_start+fm_len is beyond EOF*/
++
++#endif /* _LINUX_EXT3_FIEMAP_H */
diff --git a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6.22-vanilla.patch b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6.22-vanilla.patch
index 62905c2..80897e8 100644
--- a/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6.22-vanilla.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-fiemap-2.6.22-vanilla.patch
@@ -5,7 +5,7 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
 ===================================================================
 --- linux-2.6.22.14.orig/fs/ext3/ioctl.c
 +++ linux-2.6.22.14/fs/ext3/ioctl.c
-@@ -17,6 +17,159 @@
+@@ -17,6 +17,161 @@
  #include <linux/smp_lock.h>
  #include <asm/uaccess.h>
  #include <linux/namei.h>
@@ -19,9 +19,9 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
 + * @fieinfo:   Fiemap context passed into ->fiemap
 + * @logical:   Extent logical start offset, in bytes
 + * @phys:      Extent physical start offset, in bytes
-+ * @len:	Extent length, in bytes
++ * @len:       Extent length, in bytes
 + * @flags:     FIEMAP_EXTENT flags that describe this extent
-+ * @lun:	LUN on which this extent resides
++ * @lun:       LUN on which this extent resides
 + *
 + * Called from file system ->fiemap callback. Will populate extent
 + * info as passed in via arguments and copy to user memory. On
@@ -31,9 +31,9 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
 + * extent that will fit in user array.
 + */
 +#define SET_UNKNOWN_FLAGS      (FIEMAP_EXTENT_DELALLOC)
-+#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_COMPRESSED	\
-+				|FIEMAP_EXTENT_DATA_ENCRYPTED	\
++#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_ENCRYPTED	\
 +				|FIEMAP_EXTENT_NET)
++#define SET_NO_UNMOUNTED_IO_FLAGS       (FIEMAP_EXTENT_DATA_ENCRYPTED)
 +#define SET_NOT_ALIGNED_FLAGS  (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE)
 +int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
 +			    u64 phys, u64 len, u32 flags, dev_t dev)
@@ -43,19 +43,21 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
 +
 +	/* only count the extents */
 +	if (fieinfo->fi_extents_max == 0) {
-+		 fieinfo->fi_extents_mapped++;
-+		 return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
++		fieinfo->fi_extents_mapped++;
++		return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
 +	}
 +
 +	if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max)
-+		 return 1;
++		return 1;
 +
 +	if (flags & SET_UNKNOWN_FLAGS)
-+		 flags |= FIEMAP_EXTENT_UNKNOWN;
++		flags |= FIEMAP_EXTENT_UNKNOWN;
 +	if (flags & SET_NO_DIRECT_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NO_DIRECT;
++		flags |= FIEMAP_EXTENT_NO_DIRECT;
 +	if (flags & SET_NOT_ALIGNED_FLAGS)
-+		 flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++		flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++	if (flags & SET_NO_UNMOUNTED_IO_FLAGS)
++		flags |= FIEMAP_EXTENT_ENCODED;
 +
 +	extent.fe_logical = logical;
 +	extent.fe_physical = phys;
@@ -65,11 +67,11 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
 +
 +	dest += fieinfo->fi_extents_mapped;
 +	if (copy_to_user(dest, &extent, sizeof(extent)))
-+		 return -EFAULT;
++		return -EFAULT;
 +
 +	fieinfo->fi_extents_mapped++;
 +	if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max)
-+		 return 1;
++		return 1;
 +
 +	return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
 +}
@@ -131,11 +133,11 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
 +	int error = 0;
 +
 +	if (copy_from_user(&fiemap, (struct fiemap __user *) arg,
-+			     sizeof(struct fiemap)))
++			   sizeof(struct fiemap)))
 +		 return -EFAULT;
 +
 +	if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS)
-+		 return -EINVAL;
++		return -EINVAL;
 +
 +	error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length,
 +				    &len);
@@ -149,7 +151,7 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
 +	if (fiemap.fm_extent_count != 0 &&
 +	    !access_ok(VERIFY_WRITE, (void *)arg,
 +		       offsetof(typeof(fiemap), fm_extents[fiemap.fm_extent_count])))
-+		       return -EFAULT;
++		return -EFAULT;
 +
 +	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
 +		filemap_write_and_wait(inode->i_mapping);
@@ -165,7 +167,7 @@ Index: linux-2.6.22.14/fs/ext3/ioctl.c
  
  int ext3_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
  		unsigned long arg)
-@@ -274,7 +427,9 @@ flags_err:
+@@ -274,7 +429,9 @@ flags_err:
  
  		return err;
  	}
@@ -180,7 +182,7 @@ Index: linux-2.6.22.14/include/linux/ext3_fs.h
 ===================================================================
 --- linux-2.6.22.14.orig/include/linux/ext3_fs.h
 +++ linux-2.6.22.14/include/linux/ext3_fs.h
-@@ -254,15 +254,16 @@ struct ext3_new_group_data {
+@@ -255,15 +255,16 @@ struct ext3_new_group_data {
  #define	EXT3_IOC_SETFLAGS		FS_IOC_SETFLAGS
  #define	EXT3_IOC_GETVERSION		_IOR('f', 3, long)
  #define	EXT3_IOC_SETVERSION		_IOW('f', 4, long)
@@ -188,7 +190,7 @@ Index: linux-2.6.22.14/include/linux/ext3_fs.h
 +#define EXT3_IOC_SETRSVSZ		_IOW('f', 6, long)
  #define EXT3_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
  #define EXT3_IOC_GROUP_ADD		_IOW('f', 8,struct ext3_new_group_input)
-+#define	EXT3_IOC_FIEMAP			_IOWR('f', 10, struct fiemap)
++#define	EXT3_IOC_FIEMAP			_IOWR('f', 11, struct fiemap)
  #define	EXT3_IOC_GETVERSION_OLD		FS_IOC_GETVERSION
  #define	EXT3_IOC_SETVERSION_OLD		FS_IOC_SETVERSION
  #ifdef CONFIG_JBD_DEBUG
@@ -199,27 +201,26 @@ Index: linux-2.6.22.14/include/linux/ext3_fs.h
  
  /*
   * ioctl commands in 32 bit emulation
-@@ -281,6 +282,9 @@ struct ext3_new_group_data {
+@@ -281,6 +282,8 @@ struct ext3_new_group_data {
+ #define EXT3_IOC32_GETVERSION_OLD	FS_IOC32_GETVERSION
  #define EXT3_IOC32_SETVERSION_OLD	FS_IOC32_SETVERSION
  
- 
 +/* FIEMAP flags supported by ext3 */
 +#define	EXT3_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC)
-+
+ 
  /*
   *  Mount options
-  */
-@@ -1056,6 +1060,9 @@ extern int ext3_block_truncate_page(hand
+@@ -1057,6 +1060,9 @@ extern int ext3_block_truncate_page(hand
  extern int ext3_ioctl (struct inode *, struct file *, unsigned int,
  		       unsigned long);
  extern long ext3_compat_ioctl (struct file *, unsigned int, unsigned long);
 +struct fiemap_extent_info;
 +extern int ext3_fiemap(struct inode *, struct fiemap_extent_info *, __u64,
-+		       __u64);
++			__u64);
  
  /* namei.c */
  extern int ext3_orphan_add(handle_t *, struct inode *);
-@@ -1133,7 +1140,6 @@ ext3_get_blocks_wrap(handle_t *handle, s
+@@ -1134,7 +1140,6 @@ ext3_get_blocks_wrap(handle_t *handle, s
  	return ret;
  }
  
@@ -413,7 +414,7 @@ Index: linux-2.6.22.14/fs/ext3/fiemap.h
 ===================================================================
 --- /dev/null
 +++ linux-2.6.22.14/fs/ext3/fiemap.h
-@@ -0,0 +1,84 @@
+@@ -0,0 +1,85 @@
 +/*
 + * FIEMAP ioctl infrastructure.
 + *
@@ -432,8 +433,10 @@ Index: linux-2.6.22.14/fs/ext3/fiemap.h
 +	__u64 fe_physical; /* physical offset in bytes for the start
 +			    * of the extent from the beginning of the disk */
 +	__u64 fe_length;   /* length in bytes for this extent */
++	__u64 fe_reserved64[2];
 +	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
 +	__u32 fe_device;   /* device number for this extent */
++	__u32 fe_reserved[2];
 +};
 +
 +struct fiemap {
@@ -470,31 +473,30 @@ Index: linux-2.6.22.14/fs/ext3/fiemap.h
 +/* ldiskfs only supports FLAG_SYNC flag currently */
 +#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
 +
-+
 +#define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */
 +#define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */
 +#define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending.
-+						   * Sets EXTENT_UNKNOWN. */
-+#define FIEMAP_EXTENT_NO_DIRECT		0x00000008 /* Data mapping undefined */
-+#define FIEMAP_EXTENT_SECONDARY		0x00000010 /* Data copied offline. May
-+						   * set EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_NET		0x00000020 /* Data stored remotely.
-+						   * Sets EXTENT_NO_DIRECT. */
-+#define FIEMAP_EXTENT_DATA_COMPRESSED	0x00000040 /* Data is compressed by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
++						    * Sets EXTENT_UNKNOWN. */
++#define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
++						    * while fs is unmounted */
 +#define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
-+						   * Sets EXTENT_NO_DIRECT. */
++						    * Sets EXTENT_NO_DIRECT. */
 +#define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
-+						   * block aligned. */
++						    * block aligned. */
 +#define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
++						    * Sets EXTENT_NOT_ALIGNED.*/
 +#define FIEMAP_EXTENT_DATA_TAIL		0x00000400 /* Multiple files in block.
-+						   * Sets EXTENT_NOT_ALIGNED.*/
++						    * Sets EXTENT_NOT_ALIGNED.*/
 +#define FIEMAP_EXTENT_UNWRITTEN		0x00000800 /* Space allocated, but
-+						   * no data (i.e. zero). */
++						    * no data (i.e. zero). */
 +#define FIEMAP_EXTENT_MERGED		0x00001000 /* File does not natively
-+						   * support extents. Result
-+						   * merged for efficiency. */
++						    * support extents. Result
++						    * merged for efficiency. */
++
++/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
++#define FIEMAP_EXTENT_NO_DIRECT		0x40000000 /* Data mapping undefined */
++#define FIEMAP_EXTENT_NET		0x80000000 /* Data stored remotely.
++						    * Sets NO_DIRECT flag */
 +
 +#endif /* _LINUX_EXT3_FIEMAP_H */
 +
diff --git a/ldiskfs/kernel_patches/patches/ext3-fiemap-fix-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-fiemap-fix-rhel4.patch
new file mode 100644
index 0000000..f9bb660
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext3-fiemap-fix-rhel4.patch
@@ -0,0 +1,13 @@
+Index: linux-2.6.9-67.0.22/fs/ext3/ioctl.c
+===================================================================
+--- linux-2.6.9-67.0.22.orig/fs/ext3/ioctl.c
++++ linux-2.6.9-67.0.22/fs/ext3/ioctl.c
+@@ -157,7 +157,7 @@ int ioctl_fiemap(struct inode *inode, st
+ 		       return -EFAULT;
+ 
+ 	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
+-		filemap_write_and_wait(inode->i_mapping);
++		ext3_sync_file(filp, filp->f_dentry, 1);
+ 
+ 	error = ext3_fiemap(inode, &fieinfo, fiemap.fm_start, len);
+ 	fiemap.fm_flags = fieinfo.fi_flags;
diff --git a/ldiskfs/kernel_patches/patches/ext3-force_over_8tb-rhel5.patch b/ldiskfs/kernel_patches/patches/ext3-force_over_8tb-rhel5.patch
new file mode 100644
index 0000000..c46c472
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext3-force_over_8tb-rhel5.patch
@@ -0,0 +1,58 @@
+Index: linux-2.6.18-128.1.6/fs/ext3/super.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext3/super.c
++++ linux-2.6.18-128.1.6/fs/ext3/super.c
+@@ -51,6 +51,8 @@
+ #define EXT3_DEFAULT_MAX_DIR_SIZE		0
+ #define EXT3_MAX_DIR_SIZE_NAME		"max_dir_size"
+ 
++static int force_over_8tb;
++
+ static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
+ 			     unsigned long journal_devnum);
+ static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
+@@ -715,7 +717,7 @@ enum {
+ 	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
+ 	Opt_grpquota,
+ 	Opt_extents, Opt_noextents, Opt_bigendian_extents, Opt_extdebug,
+-	Opt_mballoc, Opt_nomballoc, Opt_stripe,
++	Opt_mballoc, Opt_nomballoc, Opt_stripe, Opt_force_over_8tb,
+ };
+ 
+ static match_table_t tokens = {
+@@ -779,6 +781,7 @@ static match_table_t tokens = {
+ 	{Opt_mballoc, "mballoc"},
+ 	{Opt_nomballoc, "nomballoc"},
+ 	{Opt_stripe, "stripe=%u"},
++	{Opt_force_over_8tb, "force_over_8tb"},
+ 	{Opt_err, NULL},
+ 	{Opt_resize, "resize"},
+ };
+@@ -1157,6 +1160,9 @@ clear_qf_name:
+ 				return 0;
+ 			sbi->s_stripe = option;
+ 			break;
++		case Opt_force_over_8tb:
++			force_over_8tb = 1;
++			break;
+ 		default:
+ 			printk (KERN_ERR
+ 				"EXT3-fs: Unrecognized mount option \"%s\" "
+@@ -2248,6 +2254,17 @@ static int ext3_fill_super (struct super
+ 		goto failed_mount;
+ 	}
+ 
++	if (le32_to_cpu(es->s_blocks_count) >
++	    ((0x80000000000ULL >> sb->s_blocksize_bits) - 1)) {
++		if (force_over_8tb == 0) {
++			printk(KERN_ERR "EXT3-fs does not support filesystems "
++			       "greater than 8TB and can cause data corruption."
++			       "Use \"force_over_8tb\" mount option to override."
++			       "\n");
++			goto failed_mount;
++		}
++	}
++
+ 	if (EXT3_BLOCKS_PER_GROUP(sb) == 0)
+ 		goto cantfind_ext3;
+ 	sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
diff --git a/ldiskfs/kernel_patches/patches/ext3-force_over_8tb-sles10.patch b/ldiskfs/kernel_patches/patches/ext3-force_over_8tb-sles10.patch
new file mode 100644
index 0000000..ff5e907
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext3-force_over_8tb-sles10.patch
@@ -0,0 +1,58 @@
+Index: linux-2.6.16.60-0.37/fs/ext3/super.c
+===================================================================
+--- linux-2.6.16.60-0.37.orig/fs/ext3/super.c
++++ linux-2.6.16.60-0.37/fs/ext3/super.c
+@@ -52,6 +52,8 @@
+ #define EXT3_DEFAULT_MAX_DIR_SIZE		0
+ #define EXT3_MAX_DIR_SIZE_NAME		"max_dir_size"
+ 
++static int force_over_8tb;
++
+ static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
+ 			     unsigned long journal_devnum);
+ static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
+@@ -708,7 +710,7 @@ enum {
+ 	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
+ 	Opt_extents, Opt_noextents, Opt_bigendian_extents, Opt_extdebug,
+ 	Opt_mballoc, Opt_nomballoc, Opt_stripe,
+-	Opt_grpquota
++	Opt_grpquota, Opt_force_over_8tb
+ };
+ 
+ static match_table_t tokens = {
+@@ -771,6 +773,7 @@ static match_table_t tokens = {
+ 	{Opt_mballoc, "mballoc"},
+ 	{Opt_nomballoc, "nomballoc"},
+ 	{Opt_stripe, "stripe=%u"},
++	{Opt_force_over_8tb, "force_over_8tb"},
+ 	{Opt_err, NULL},
+ 	{Opt_resize, "resize"},
+ };
+@@ -1145,6 +1148,9 @@ clear_qf_name:
+ 				return 0;
+ 			sbi->s_stripe = option;
+ 			break;
++		case Opt_force_over_8tb:
++			force_over_8tb = 1;
++			break;
+ 		default:
+ 			printk (KERN_ERR
+ 				"EXT3-fs: Unrecognized mount option \"%s\" "
+@@ -2231,6 +2237,17 @@ static int ext3_fill_super (struct super
+ 		goto failed_mount;
+ 	}
+ 
++	if (le32_to_cpu(es->s_blocks_count) >
++	    ((0x80000000000ULL >> sb->s_blocksize_bits) - 1)) {
++		if (force_over_8tb == 0) {
++			printk(KERN_ERR "EXT3-fs does not support filesystems "
++			       "greater than 8TB and can cause data corruption."
++			       "Use \"force_over_8tb\" mount option to override."
++			       "\n");
++			goto failed_mount;
++		}
++	}
++
+ 	if (EXT3_BLOCKS_PER_GROUP(sb) == 0)
+ 		goto cantfind_ext3;
+ 	sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) -
diff --git a/ldiskfs/kernel_patches/patches/ext3-max-dir-size.patch b/ldiskfs/kernel_patches/patches/ext3-max-dir-size.patch
index d55c600..97f69cc 100644
--- a/ldiskfs/kernel_patches/patches/ext3-max-dir-size.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-max-dir-size.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.22.19/fs/ext3/ialloc.c
+Index: linux-2.6.18-92.1.17/fs/ext3/ialloc.c
 ===================================================================
---- linux-2.6.22.19.orig/fs/ext3/ialloc.c
-+++ linux-2.6.22.19/fs/ext3/ialloc.c
+--- linux-2.6.18-92.1.17.orig/fs/ext3/ialloc.c
++++ linux-2.6.18-92.1.17/fs/ext3/ialloc.c
 @@ -521,12 +521,15 @@ struct inode *ext3_new_inode(handle_t *h
  		return ERR_PTR(-EPERM);
  
@@ -19,10 +19,10 @@ Index: linux-2.6.22.19/fs/ext3/ialloc.c
  	es = sbi->s_es;
  	if (goal) {
  		group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
-Index: linux-2.6.22.19/fs/ext3/super.c
+Index: linux-2.6.18-92.1.17/fs/ext3/super.c
 ===================================================================
---- linux-2.6.22.19.orig/fs/ext3/super.c
-+++ linux-2.6.22.19/fs/ext3/super.c
+--- linux-2.6.18-92.1.17.orig/fs/ext3/super.c
++++ linux-2.6.18-92.1.17/fs/ext3/super.c
 @@ -45,6 +45,12 @@
  #include "namei.h"
  #include "group.h"
@@ -36,7 +36,7 @@ Index: linux-2.6.22.19/fs/ext3/super.c
  static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
  			     unsigned long journal_devnum);
  static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
-@@ -440,6 +446,7 @@ static void ext3_put_super (struct super
+@@ -439,6 +445,7 @@ static void ext3_put_super (struct super
  	}
  	if (sbi->s_mmp_tsk)
  		kthread_stop(sbi->s_mmp_tsk);
@@ -44,7 +44,7 @@ Index: linux-2.6.22.19/fs/ext3/super.c
  	if (sbi->s_dev_proc) {
  		remove_proc_entry(sbi->s_dev_proc->name, proc_root_ext3);
  		sbi->s_dev_proc = NULL;
-@@ -1849,6 +1856,45 @@ failed:
+@@ -1854,6 +1861,45 @@ failed:
  	return 1;
  }
  
@@ -90,15 +90,15 @@ Index: linux-2.6.22.19/fs/ext3/super.c
  
  static int ext3_fill_super (struct super_block *sb, void *data, int silent)
  {
-@@ -1870,6 +1916,7 @@ static int ext3_fill_super (struct super
+@@ -1875,6 +1921,7 @@ static int ext3_fill_super (struct super
  	int i;
  	int needs_recovery;
  	__le32 features;
 +	struct proc_dir_entry *proc;
  
- 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ 	sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
  	if (!sbi)
-@@ -1897,6 +1944,23 @@ static int ext3_fill_super (struct super
+@@ -1903,6 +1950,23 @@ static int ext3_fill_super (struct super
  
  	unlock_kernel();
  
@@ -130,10 +130,10 @@ Index: linux-2.6.22.19/fs/ext3/super.c
  	if (sbi->s_dev_proc) {
  		remove_proc_entry(sbi->s_dev_proc->name, proc_root_ext3);
  		sbi->s_dev_proc = NULL;
-Index: linux-2.6.22.19/include/linux/ext3_fs_sb.h
+Index: linux-2.6.18-92.1.17/include/linux/ext3_fs_sb.h
 ===================================================================
---- linux-2.6.22.19.orig/include/linux/ext3_fs_sb.h
-+++ linux-2.6.22.19/include/linux/ext3_fs_sb.h
+--- linux-2.6.18-92.1.17.orig/include/linux/ext3_fs_sb.h
++++ linux-2.6.18-92.1.17/include/linux/ext3_fs_sb.h
 @@ -132,6 +132,8 @@ struct ext3_sb_info {
  	unsigned long s_mb_last_group;
  	unsigned long s_mb_last_start;
diff --git a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch
index 3f6480c..d08cdaf 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6-fc5.patch
@@ -1,8 +1,8 @@
-Index: linux-2.6.15/include/linux/ext3_fs.h
+Index: linux-2.6.16.i686/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.15.orig/include/linux/ext3_fs.h
-+++ linux-2.6.15/include/linux/ext3_fs.h
-@@ -57,6 +57,14 @@ struct statfs;
+--- linux-2.6.16.i686.orig/include/linux/ext3_fs.h	2006-05-30 22:55:32.000000000 +0800
++++ linux-2.6.16.i686/include/linux/ext3_fs.h	2006-05-30 23:02:59.000000000 +0800
+@@ -57,6 +57,14 @@
  #define ext3_debug(f, a...)	do {} while (0)
  #endif
  
@@ -17,7 +17,7 @@ Index: linux-2.6.15/include/linux/ext3_fs.h
  /*
   * Special inodes numbers
   */
-@@ -383,6 +391,7 @@ struct ext3_inode {
+@@ -383,6 +391,7 @@
  #define EXT3_MOUNT_IOPEN_NOPRIV		0x800000/* Make iopen world-readable */
  #define EXT3_MOUNT_EXTENTS		0x1000000/* Extents support */
  #define EXT3_MOUNT_EXTDEBUG		0x2000000/* Extents debug */
@@ -25,7 +25,7 @@ Index: linux-2.6.15/include/linux/ext3_fs.h
  
  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
  #ifndef clear_opt
-@@ -405,6 +414,14 @@ struct ext3_inode {
+@@ -404,6 +413,14 @@
  #define ext3_find_first_zero_bit	ext2_find_first_zero_bit
  #define ext3_find_next_zero_bit		ext2_find_next_zero_bit
  
@@ -40,7 +40,7 @@ Index: linux-2.6.15/include/linux/ext3_fs.h
  /*
   * Maximal mount counts between two filesystem checks
   */
-@@ -744,7 +761,9 @@ extern int ext3_bg_has_super(struct supe
+@@ -744,7 +753,9 @@
  extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group);
  extern int ext3_new_block (handle_t *, struct inode *, unsigned long, int *);
  extern void ext3_free_blocks (handle_t *, struct inode *, unsigned long,
@@ -51,7 +51,7 @@ Index: linux-2.6.15/include/linux/ext3_fs.h
  extern void ext3_free_blocks_sb (handle_t *, struct super_block *,
  				 unsigned long, unsigned long, int *);
  extern unsigned long ext3_count_free_blocks (struct super_block *);
-@@ -866,6 +885,17 @@ extern void ext3_extents_initialize_bloc
+@@ -865,6 +874,17 @@
  extern int ext3_ext_ioctl(struct inode *inode, struct file *filp,
  			  unsigned int cmd, unsigned long arg);
  
@@ -69,10 +69,10 @@ Index: linux-2.6.15/include/linux/ext3_fs.h
  #endif	/* __KERNEL__ */
  
  /* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
-Index: linux-2.6.15/include/linux/ext3_fs_sb.h
+Index: linux-2.6.16.i686/include/linux/ext3_fs_sb.h
 ===================================================================
---- linux-2.6.15.orig/include/linux/ext3_fs_sb.h
-+++ linux-2.6.15/include/linux/ext3_fs_sb.h
+--- linux-2.6.16.i686.orig/include/linux/ext3_fs_sb.h	2006-03-20 13:53:29.000000000 +0800
++++ linux-2.6.16.i686/include/linux/ext3_fs_sb.h	2006-05-30 23:02:59.000000000 +0800
 @@ -21,8 +21,14 @@
  #include <linux/wait.h>
  #include <linux/blockgroup_lock.h>
@@ -88,7 +88,7 @@ Index: linux-2.6.15/include/linux/ext3_fs_sb.h
  
  /*
   * third extended-fs super-block data in memory
-@@ -78,6 +84,43 @@ struct ext3_sb_info {
+@@ -78,6 +84,43 @@
  	char *s_qf_names[MAXQUOTAS];		/* Names of quota files with journalled quota */
  	int s_jquota_fmt;			/* Format of quota to use */
  #endif
@@ -126,17 +126,17 @@ Index: linux-2.6.15/include/linux/ext3_fs_sb.h
 +	unsigned long s_mb_buddies_generated;
 +	unsigned long long s_mb_generation_time;
  };
- 
++
 +#define EXT3_GROUP_INFO(sb, group)					   \
 +	EXT3_SB(sb)->s_group_info[(group) >> EXT3_DESC_PER_BLOCK_BITS(sb)] \
 +				 [(group) & (EXT3_DESC_PER_BLOCK(sb) - 1)]
-+
+ 
  #endif	/* _LINUX_EXT3_FS_SB */
-Index: linux-2.6.15/fs/ext3/super.c
+Index: linux-2.6.16.i686/fs/ext3/super.c
 ===================================================================
---- linux-2.6.15.orig/fs/ext3/super.c
-+++ linux-2.6.15/fs/ext3/super.c
-@@ -391,6 +391,7 @@ static void ext3_put_super (struct super
+--- linux-2.6.16.i686.orig/fs/ext3/super.c	2006-05-30 22:55:32.000000000 +0800
++++ linux-2.6.16.i686/fs/ext3/super.c	2006-05-30 23:02:59.000000000 +0800
+@@ -392,6 +392,7 @@
  	struct ext3_super_block *es = sbi->s_es;
  	int i;
  
@@ -144,7 +144,7 @@ Index: linux-2.6.15/fs/ext3/super.c
  	ext3_ext_release(sb);
  	ext3_xattr_put_super(sb);
  	journal_destroy(sbi->s_journal);
-@@ -640,6 +641,7 @@ enum {
+@@ -640,6 +641,7 @@
  	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
  	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
  	Opt_extents, Opt_noextents, Opt_extdebug,
@@ -152,7 +152,7 @@ Index: linux-2.6.15/fs/ext3/super.c
  	Opt_grpquota
  };
  
-@@ -693,6 +695,9 @@ static match_table_t tokens = {
+@@ -694,6 +695,9 @@
  	{Opt_extents, "extents"},
  	{Opt_noextents, "noextents"},
  	{Opt_extdebug, "extdebug"},
@@ -162,7 +162,7 @@ Index: linux-2.6.15/fs/ext3/super.c
  	{Opt_barrier, "barrier=%u"},
  	{Opt_err, NULL},
  	{Opt_resize, "resize"},
-@@ -1032,6 +1037,19 @@ clear_qf_name:
+@@ -1041,6 +1043,19 @@
  		case Opt_extdebug:
  			set_opt (sbi->s_mount_opt, EXTDEBUG);
  			break;
@@ -182,7 +182,7 @@ Index: linux-2.6.15/fs/ext3/super.c
  		default:
  			printk (KERN_ERR
  				"EXT3-fs: Unrecognized mount option \"%s\" "
-@@ -1755,6 +1773,7 @@ static int ext3_fill_super (struct super
+@@ -1766,6 +1771,7 @@
  		ext3_count_dirs(sb));
  
  	ext3_ext_init(sb);
@@ -190,7 +190,7 @@ Index: linux-2.6.15/fs/ext3/super.c
  	lock_kernel();
  	return 0;
  
-@@ -2669,7 +2688,13 @@ static struct file_system_type ext3_fs_t
+@@ -2699,7 +2705,13 @@
  
  static int __init init_ext3_fs(void)
  {
@@ -205,19 +205,19 @@ Index: linux-2.6.15/fs/ext3/super.c
  	if (err)
  		return err;
  	err = init_inodecache();
-@@ -2691,6 +2716,7 @@ static void __exit exit_ext3_fs(void)
+@@ -2721,6 +2733,7 @@
  	unregister_filesystem(&ext3_fs_type);
  	destroy_inodecache();
  	exit_ext3_xattr();
 +	exit_ext3_proc();
  }
  
- int ext3_map_inode_page(struct inode *inode, struct page *page,
-Index: linux-2.6.15/fs/ext3/extents.c
+ int ext3_prep_san_write(struct inode *inode, long *blocks,
+Index: linux-2.6.16.i686/fs/ext3/extents.c
 ===================================================================
---- linux-2.6.15.orig/fs/ext3/extents.c
-+++ linux-2.6.15/fs/ext3/extents.c
-@@ -779,7 +779,7 @@ cleanup:
+--- linux-2.6.16.i686.orig/fs/ext3/extents.c	2006-05-30 22:55:32.000000000 +0800
++++ linux-2.6.16.i686/fs/ext3/extents.c	2006-05-30 23:02:59.000000000 +0800
+@@ -771,7 +771,7 @@
  		for (i = 0; i < depth; i++) {
  			if (!ablocks[i])
  				continue;
@@ -226,7 +226,7 @@ Index: linux-2.6.15/fs/ext3/extents.c
  		}
  	}
  	kfree(ablocks);
-@@ -1438,7 +1438,7 @@ int ext3_ext_rm_idx(handle_t *handle, st
+@@ -1428,7 +1428,7 @@
  		  path->p_idx->ei_leaf);
  	bh = sb_find_get_block(tree->inode->i_sb, path->p_idx->ei_leaf);
  	ext3_forget(handle, 1, tree->inode, bh, path->p_idx->ei_leaf);
@@ -235,7 +235,7 @@ Index: linux-2.6.15/fs/ext3/extents.c
  	return err;
  }
  
-@@ -1923,10 +1923,12 @@ ext3_remove_blocks(struct ext3_extents_t
+@@ -1913,10 +1913,12 @@
  	int needed = ext3_remove_blocks_credits(tree, ex, from, to);
  	handle_t *handle = ext3_journal_start(tree->inode, needed);
  	struct buffer_head *bh;
@@ -249,7 +249,7 @@ Index: linux-2.6.15/fs/ext3/extents.c
  	if (from >= ex->ee_block && to == ex->ee_block + ex->ee_len - 1) {
  		/* tail removal */
  		unsigned long num, start;
-@@ -1938,7 +1940,7 @@ ext3_remove_blocks(struct ext3_extents_t
+@@ -1928,7 +1930,7 @@
  			bh = sb_find_get_block(tree->inode->i_sb, start + i);
  			ext3_forget(handle, 0, tree->inode, bh, start + i);
  		}
@@ -258,11 +258,11 @@ Index: linux-2.6.15/fs/ext3/extents.c
  	} else if (from == ex->ee_block && to <= ex->ee_block + ex->ee_len - 1) {
  		printk("strange request: removal %lu-%lu from %u:%u\n",
  		       from, to, ex->ee_block, ex->ee_len);
-Index: linux-2.6.15/fs/ext3/inode.c
+Index: linux-2.6.16.i686/fs/ext3/inode.c
 ===================================================================
---- linux-2.6.15.orig/fs/ext3/inode.c
-+++ linux-2.6.15/fs/ext3/inode.c
-@@ -568,7 +568,7 @@ static int ext3_alloc_branch(handle_t *h
+--- linux-2.6.16.i686.orig/fs/ext3/inode.c	2006-05-30 22:55:32.000000000 +0800
++++ linux-2.6.16.i686/fs/ext3/inode.c	2006-05-30 23:02:59.000000000 +0800
+@@ -568,7 +568,7 @@
  		ext3_journal_forget(handle, branch[i].bh);
  	}
  	for (i = 0; i < keys; i++)
@@ -271,7 +271,7 @@ Index: linux-2.6.15/fs/ext3/inode.c
  	return err;
  }
  
-@@ -1861,7 +1861,7 @@ ext3_clear_blocks(handle_t *handle, stru
+@@ -1862,7 +1862,7 @@
  		}
  	}
  
@@ -280,7 +280,7 @@ Index: linux-2.6.15/fs/ext3/inode.c
  }
  
  /**
-@@ -2034,7 +2034,7 @@ static void ext3_free_branches(handle_t 
+@@ -2035,7 +2035,7 @@
  				ext3_journal_test_restart(handle, inode);
  			}
  
@@ -289,11 +289,11 @@ Index: linux-2.6.15/fs/ext3/inode.c
  
  			if (parent_bh) {
  				/*
-Index: linux-2.6.15/fs/ext3/balloc.c
+Index: linux-2.6.16.i686/fs/ext3/balloc.c
 ===================================================================
---- linux-2.6.15.orig/fs/ext3/balloc.c
-+++ linux-2.6.15/fs/ext3/balloc.c
-@@ -81,7 +81,7 @@ struct ext3_group_desc * ext3_get_group_
+--- linux-2.6.16.i686.orig/fs/ext3/balloc.c	2006-03-20 13:53:29.000000000 +0800
++++ linux-2.6.16.i686/fs/ext3/balloc.c	2006-05-30 23:02:59.000000000 +0800
+@@ -80,7 +80,7 @@
   *
   * Return buffer_head on success or NULL in case of failure.
   */
@@ -302,7 +302,7 @@ Index: linux-2.6.15/fs/ext3/balloc.c
  read_block_bitmap(struct super_block *sb, unsigned int block_group)
  {
  	struct ext3_group_desc * desc;
-@@ -492,24 +492,6 @@ error_return:
+@@ -491,24 +491,6 @@
  	return;
  }
  
@@ -327,7 +327,7 @@ Index: linux-2.6.15/fs/ext3/balloc.c
  /*
   * For ext3 allocations, we must not reuse any blocks which are
   * allocated in the bitmap buffer's "last committed data" copy.  This
-@@ -1155,7 +1137,7 @@ int ext3_should_retry_alloc(struct super
+@@ -1154,7 +1136,7 @@
   * bitmap, and then for any free bit if that fails.
   * This function also updates quota and i_blocks field.
   */
@@ -336,11 +336,11 @@ Index: linux-2.6.15/fs/ext3/balloc.c
  			unsigned long goal, int *errp)
  {
  	struct buffer_head *bitmap_bh = NULL;
-Index: linux-2.6.15/fs/ext3/xattr.c
+Index: linux-2.6.16.i686/fs/ext3/xattr.c
 ===================================================================
---- linux-2.6.15.orig/fs/ext3/xattr.c
-+++ linux-2.6.15/fs/ext3/xattr.c
-@@ -484,7 +484,7 @@ ext3_xattr_release_block(handle_t *handl
+--- linux-2.6.16.i686.orig/fs/ext3/xattr.c	2006-03-20 13:53:29.000000000 +0800
++++ linux-2.6.16.i686/fs/ext3/xattr.c	2006-05-30 23:02:59.000000000 +0800
+@@ -484,7 +484,7 @@
  		ea_bdebug(bh, "refcount now=0; freeing");
  		if (ce)
  			mb_cache_entry_free(ce);
@@ -349,7 +349,7 @@ Index: linux-2.6.15/fs/ext3/xattr.c
  		get_bh(bh);
  		ext3_forget(handle, 1, inode, bh, bh->b_blocknr);
  	} else {
-@@ -804,7 +804,7 @@ inserted:
+@@ -804,7 +804,7 @@
  			new_bh = sb_getblk(sb, block);
  			if (!new_bh) {
  getblk_failed:
@@ -358,11 +358,11 @@ Index: linux-2.6.15/fs/ext3/xattr.c
  				error = -EIO;
  				goto cleanup;
  			}
-Index: linux-2.6.15/fs/ext3/mballoc.c
+Index: linux-2.6.16.i686/fs/ext3/mballoc.c
 ===================================================================
---- /dev/null
-+++ linux-2.6.15/fs/ext3/mballoc.c
-@@ -0,0 +1,2728 @@
+--- linux-2.6.16.i686.orig/fs/ext3/mballoc.c	2006-05-31 04:14:15.752410384 +0800
++++ linux-2.6.16.i686/fs/ext3/mballoc.c	2006-05-30 23:03:38.000000000 +0800
+@@ -0,0 +1,2726 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.
 + * Written by Alex Tomas <alex at clusterfs.com>
@@ -3089,13 +3089,11 @@ Index: linux-2.6.15/fs/ext3/mballoc.c
 +	remove_proc_entry(EXT3_MB_ORDER2_REQ, proc_root_ext3);
 +	remove_proc_entry(EXT3_ROOT, proc_root_fs);
 +}
-+
-+EXPORT_SYMBOL(ext3_free_blocks);
-Index: linux-2.6.15/fs/ext3/Makefile
+Index: linux-2.6.16.i686/fs/ext3/Makefile
 ===================================================================
---- linux-2.6.15.orig/fs/ext3/Makefile
-+++ linux-2.6.15/fs/ext3/Makefile
-@@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o
+--- linux-2.6.16.i686.orig/fs/ext3/Makefile	2006-05-30 22:55:32.000000000 +0800
++++ linux-2.6.16.i686/fs/ext3/Makefile	2006-05-30 23:02:59.000000000 +0800
+@@ -6,7 +6,7 @@
  
  ext3-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
  	   ioctl.o namei.o super.o symlink.o hash.o resize.o \
diff --git a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch
index 766cf96..317663d 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mballoc2-2.6.9-rhel4.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.10/include/linux/ext3_fs.h
+Index: linux-2.6.9-full/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.10.orig/include/linux/ext3_fs.h
-+++ linux-2.6.10/include/linux/ext3_fs.h
+--- linux-2.6.9-full.orig/include/linux/ext3_fs.h	2006-06-01 14:58:46.000000000 +0400
++++ linux-2.6.9-full/include/linux/ext3_fs.h	2006-10-24 12:54:31.000000000 +0400
 @@ -57,6 +57,14 @@ struct statfs;
  #define ext3_debug(f, a...)	do {} while (0)
  #endif
@@ -17,7 +17,7 @@ Index: linux-2.6.10/include/linux/ext3_fs.h
  /*
   * Special inodes numbers
   */
-@@ -362,6 +370,7 @@ struct ext3_inode {
+@@ -365,6 +373,7 @@ struct ext3_inode {
  #define EXT3_MOUNT_IOPEN_NOPRIV		0x100000/* Make iopen world-readable */
  #define EXT3_MOUNT_EXTENTS		0x200000/* Extents support */
  #define EXT3_MOUNT_EXTDEBUG		0x400000/* Extents debug */
@@ -25,7 +25,7 @@ Index: linux-2.6.10/include/linux/ext3_fs.h
  
  /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
  #ifndef clear_opt
-@@ -384,6 +393,14 @@ struct ext3_inode {
+@@ -387,6 +396,14 @@ struct ext3_inode {
  #define ext3_find_first_zero_bit	ext2_find_first_zero_bit
  #define ext3_find_next_zero_bit		ext2_find_next_zero_bit
  
@@ -40,7 +40,7 @@ Index: linux-2.6.10/include/linux/ext3_fs.h
  /*
   * Maximal mount counts between two filesystem checks
   */
-@@ -723,7 +740,8 @@ extern int ext3_bg_has_super(struct supe
+@@ -726,7 +743,8 @@ extern int ext3_bg_has_super(struct supe
  extern unsigned long ext3_bg_num_gdb(struct super_block *sb, int group);
  extern int ext3_new_block (handle_t *, struct inode *, unsigned long, int *);
  extern void ext3_free_blocks (handle_t *, struct inode *, unsigned long,
@@ -50,9 +50,9 @@ Index: linux-2.6.10/include/linux/ext3_fs.h
  extern void ext3_free_blocks_sb (handle_t *, struct super_block *,
  				 unsigned long, unsigned long, int *);
  extern unsigned long ext3_count_free_blocks (struct super_block *);
-@@ -854,6 +872,17 @@ extern void ext3_ext_init(struct super_b
- extern void ext3_ext_release(struct super_block *);
- extern void ext3_extents_initialize_blockmap(handle_t *, struct inode *);
+@@ -857,6 +874,17 @@ extern void ext3_extents_initialize_bloc
+ extern int ext3_ext_ioctl(struct inode *inode, struct file *filp,
+ 			  unsigned int cmd, unsigned long arg);
  
 +/* mballoc.c */
 +extern long ext3_mb_stats;
@@ -68,10 +68,10 @@ Index: linux-2.6.10/include/linux/ext3_fs.h
  #endif	/* __KERNEL__ */
  
  /* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
-Index: linux-2.6.10/include/linux/ext3_fs_sb.h
+Index: linux-2.6.9-full/include/linux/ext3_fs_sb.h
 ===================================================================
---- linux-2.6.10.orig/include/linux/ext3_fs_sb.h
-+++ linux-2.6.10/include/linux/ext3_fs_sb.h
+--- linux-2.6.9-full.orig/include/linux/ext3_fs_sb.h	2006-05-18 23:57:04.000000000 +0400
++++ linux-2.6.9-full/include/linux/ext3_fs_sb.h	2006-10-24 12:54:31.000000000 +0400
 @@ -23,9 +23,15 @@
  #define EXT_INCLUDE
  #include <linux/blockgroup_lock.h>
@@ -132,10 +132,10 @@ Index: linux-2.6.10/include/linux/ext3_fs_sb.h
 +				 [(group) & (EXT3_DESC_PER_BLOCK(sb) - 1)]
 +
  #endif	/* _LINUX_EXT3_FS_SB */
-Index: linux-2.6.10/fs/ext3/super.c
+Index: linux-2.6.9-full/fs/ext3/super.c
 ===================================================================
---- linux-2.6.10.orig/fs/ext3/super.c
-+++ linux-2.6.10/fs/ext3/super.c
+--- linux-2.6.9-full.orig/fs/ext3/super.c	2006-06-01 14:58:46.000000000 +0400
++++ linux-2.6.9-full/fs/ext3/super.c	2006-10-24 12:54:31.000000000 +0400
 @@ -394,6 +394,7 @@ void ext3_put_super (struct super_block 
  	struct ext3_super_block *es = sbi->s_es;
  	int i;
@@ -182,7 +182,7 @@ Index: linux-2.6.10/fs/ext3/super.c
  		default:
  			printk (KERN_ERR
  				"EXT3-fs: Unrecognized mount option \"%s\" "
-@@ -1647,6 +1665,7 @@ static int ext3_fill_super (struct super
+@@ -1651,6 +1669,7 @@ static int ext3_fill_super (struct super
  		ext3_count_dirs(sb));
  
  	ext3_ext_init(sb);
@@ -212,12 +212,12 @@ Index: linux-2.6.10/fs/ext3/super.c
 +	exit_ext3_proc();
  }
  
- int ext3_map_inode_page(struct inode *inode, struct page *page,
-Index: linux-2.6.10/fs/ext3/extents.c
+ int ext3_prep_san_write(struct inode *inode, long *blocks,
+Index: linux-2.6.9-full/fs/ext3/extents.c
 ===================================================================
---- linux-2.6.10.orig/fs/ext3/extents.c
-+++ linux-2.6.10/fs/ext3/extents.c
-@@ -780,7 +780,7 @@ cleanup:
+--- linux-2.6.9-full.orig/fs/ext3/extents.c	2006-06-01 14:58:46.000000000 +0400
++++ linux-2.6.9-full/fs/ext3/extents.c	2006-10-24 12:54:31.000000000 +0400
+@@ -777,7 +777,7 @@ cleanup:
  		for (i = 0; i < depth; i++) {
  			if (!ablocks[i])
  				continue;
@@ -226,7 +226,7 @@ Index: linux-2.6.10/fs/ext3/extents.c
  		}
  	}
  	kfree(ablocks);
-@@ -1439,7 +1439,7 @@ int ext3_ext_rm_idx(handle_t *handle, st
+@@ -1434,7 +1434,7 @@ int ext3_ext_rm_idx(handle_t *handle, st
  		  path->p_idx->ei_leaf);
  	bh = sb_find_get_block(tree->inode->i_sb, path->p_idx->ei_leaf);
  	ext3_forget(handle, 1, tree->inode, bh, path->p_idx->ei_leaf);
@@ -235,7 +235,7 @@ Index: linux-2.6.10/fs/ext3/extents.c
  	return err;
  }
  
-@@ -1924,10 +1924,12 @@ ext3_remove_blocks(struct ext3_extents_t
+@@ -1919,10 +1919,12 @@ ext3_remove_blocks(struct ext3_extents_t
  	int needed = ext3_remove_blocks_credits(tree, ex, from, to);
  	handle_t *handle = ext3_journal_start(tree->inode, needed);
  	struct buffer_head *bh;
@@ -249,7 +249,7 @@ Index: linux-2.6.10/fs/ext3/extents.c
  	if (from >= ex->ee_block && to == ex->ee_block + ex->ee_len - 1) {
  		/* tail removal */
  		unsigned long num, start;
-@@ -1939,7 +1941,7 @@ ext3_remove_blocks(struct ext3_extents_t
+@@ -1934,7 +1936,7 @@ ext3_remove_blocks(struct ext3_extents_t
  			bh = sb_find_get_block(tree->inode->i_sb, start + i);
  			ext3_forget(handle, 0, tree->inode, bh, start + i);
  		}
@@ -258,10 +258,10 @@ Index: linux-2.6.10/fs/ext3/extents.c
  	} else if (from == ex->ee_block && to <= ex->ee_block + ex->ee_len - 1) {
  		printk("strange request: removal %lu-%lu from %u:%u\n",
  		       from, to, ex->ee_block, ex->ee_len);
-Index: linux-2.6.10/fs/ext3/inode.c
+Index: linux-2.6.9-full/fs/ext3/inode.c
 ===================================================================
---- linux-2.6.10.orig/fs/ext3/inode.c
-+++ linux-2.6.10/fs/ext3/inode.c
+--- linux-2.6.9-full.orig/fs/ext3/inode.c	2006-06-01 14:58:46.000000000 +0400
++++ linux-2.6.9-full/fs/ext3/inode.c	2006-10-24 12:54:31.000000000 +0400
 @@ -572,7 +572,7 @@ static int ext3_alloc_branch(handle_t *h
  		ext3_journal_forget(handle, branch[i].bh);
  	}
@@ -280,7 +280,7 @@ Index: linux-2.6.10/fs/ext3/inode.c
  	return err;
  }
  
-@@ -1833,7 +1833,7 @@ ext3_clear_blocks(handle_t *handle, stru
+@@ -1831,7 +1831,7 @@ ext3_clear_blocks(handle_t *handle, stru
  		}
  	}
  
@@ -289,7 +289,7 @@ Index: linux-2.6.10/fs/ext3/inode.c
  }
  
  /**
-@@ -2006,7 +2006,7 @@ static void ext3_free_branches(handle_t 
+@@ -2004,7 +2004,7 @@ static void ext3_free_branches(handle_t 
  				ext3_journal_test_restart(handle, inode);
  			}
  
@@ -298,10 +298,10 @@ Index: linux-2.6.10/fs/ext3/inode.c
  
  			if (parent_bh) {
  				/*
-Index: linux-2.6.10/fs/ext3/balloc.c
+Index: linux-2.6.9-full/fs/ext3/balloc.c
 ===================================================================
---- linux-2.6.10.orig/fs/ext3/balloc.c
-+++ linux-2.6.10/fs/ext3/balloc.c
+--- linux-2.6.9-full.orig/fs/ext3/balloc.c	2006-03-10 18:20:03.000000000 +0300
++++ linux-2.6.9-full/fs/ext3/balloc.c	2006-10-24 12:54:31.000000000 +0400
 @@ -79,7 +79,7 @@ struct ext3_group_desc * ext3_get_group_
   *
   * Return buffer_head on success or NULL in case of failure.
@@ -311,7 +311,7 @@ Index: linux-2.6.10/fs/ext3/balloc.c
  read_block_bitmap(struct super_block *sb, unsigned int block_group)
  {
  	struct ext3_group_desc * desc;
-@@ -449,24 +449,6 @@ error_return:
+@@ -451,24 +451,6 @@ error_return:
  	return;
  }
  
@@ -336,7 +336,7 @@ Index: linux-2.6.10/fs/ext3/balloc.c
  /*
   * For ext3 allocations, we must not reuse any blocks which are
   * allocated in the bitmap buffer's "last committed data" copy.  This
-@@ -1129,7 +1111,7 @@ int ext3_should_retry_alloc(struct super
+@@ -1131,7 +1113,7 @@ int ext3_should_retry_alloc(struct super
   * bitmap, and then for any free bit if that fails.
   * This function also updates quota and i_blocks field.
   */
@@ -345,11 +345,11 @@ Index: linux-2.6.10/fs/ext3/balloc.c
  			unsigned long goal, int *errp)
  {
  	struct buffer_head *bitmap_bh = NULL;
-Index: linux-2.6.10/fs/ext3/xattr.c
+Index: linux-2.6.9-full/fs/ext3/xattr.c
 ===================================================================
---- linux-2.6.10.orig/fs/ext3/xattr.c
-+++ linux-2.6.10/fs/ext3/xattr.c
-@@ -1287,7 +1287,7 @@ ext3_xattr_set_handle2(handle_t *handle,
+--- linux-2.6.9-full.orig/fs/ext3/xattr.c	2006-05-18 23:57:04.000000000 +0400
++++ linux-2.6.9-full/fs/ext3/xattr.c	2006-10-24 12:54:31.000000000 +0400
+@@ -1281,7 +1281,7 @@ ext3_xattr_set_handle2(handle_t *handle,
  			new_bh = sb_getblk(sb, block);
  			if (!new_bh) {
  getblk_failed:
@@ -358,7 +358,7 @@ Index: linux-2.6.10/fs/ext3/xattr.c
  				error = -EIO;
  				goto cleanup;
  			}
-@@ -1334,7 +1334,7 @@ getblk_failed:
+@@ -1328,7 +1328,7 @@ getblk_failed:
  			if (ce)
  				mb_cache_entry_free(ce);
  			ea_bdebug(old_bh, "freeing");
@@ -367,7 +367,7 @@ Index: linux-2.6.10/fs/ext3/xattr.c
  
  			/* ext3_forget() calls bforget() for us, but we
  			   let our caller release old_bh, so we need to
-@@ -1433,7 +1433,7 @@ ext3_xattr_delete_inode(handle_t *handle
+@@ -1427,7 +1427,7 @@ ext3_xattr_delete_inode(handle_t *handle
  	if (HDR(bh)->h_refcount == cpu_to_le32(1)) {
  		if (ce)
  			mb_cache_entry_free(ce);
@@ -376,11 +376,11 @@ Index: linux-2.6.10/fs/ext3/xattr.c
  		get_bh(bh);
  		ext3_forget(handle, 1, inode, bh, EXT3_I(inode)->i_file_acl);
  	} else {
-Index: linux-2.6.10/fs/ext3/mballoc.c
+Index: linux-2.6.9-full/fs/ext3/mballoc.c
 ===================================================================
---- /dev/null
-+++ linux-2.6.10/fs/ext3/mballoc.c
-@@ -0,0 +1,2728 @@
+--- linux-2.6.9-full.orig/fs/ext3/mballoc.c	2006-10-23 18:07:54.821533176 +0400
++++ linux-2.6.9-full/fs/ext3/mballoc.c	2006-10-24 13:00:56.000000000 +0400
+@@ -0,0 +1,2726 @@
 +/*
 + * Copyright 2008 Sun Microsystems, Inc.
 + * Written by Alex Tomas <alex at clusterfs.com>
@@ -3107,12 +3107,10 @@ Index: linux-2.6.10/fs/ext3/mballoc.c
 +	remove_proc_entry(EXT3_MB_ORDER2_REQ, proc_root_ext3);
 +	remove_proc_entry(EXT3_ROOT, proc_root_fs);
 +}
-+
-+EXPORT_SYMBOL(ext3_free_blocks);
-Index: linux-2.6.10/fs/ext3/Makefile
+Index: linux-2.6.9-full/fs/ext3/Makefile
 ===================================================================
---- linux-2.6.10.orig/fs/ext3/Makefile
-+++ linux-2.6.10/fs/ext3/Makefile
+--- linux-2.6.9-full.orig/fs/ext3/Makefile	2006-06-01 14:58:46.000000000 +0400
++++ linux-2.6.9-full/fs/ext3/Makefile	2006-10-24 12:54:31.000000000 +0400
 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o
  
  ext3-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
diff --git a/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch b/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch
index e6a7187..197e8cc 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mballoc3-core.patch
@@ -4714,6 +4714,8 @@ Index: linux-2.6.22.19/fs/ext3/mballoc.c
 +	if (err)
 +		goto error_return;
 +
++	ext3_lock_group(sb, block_group);
++	spin_lock(sb_bgl_lock(sbi, block_group));
 +#ifdef AGGRESSIVE_CHECK
 +	{
 +		int i;
@@ -4721,8 +4723,6 @@ Index: linux-2.6.22.19/fs/ext3/mballoc.c
 +			BUG_ON(!mb_test_bit(bit + i, bitmap_bh->b_data));
 +	}
 +#endif
-+	ext3_lock_group(sb, block_group);
-+	spin_lock(sb_bgl_lock(sbi, block_group));
 +	mb_clear_bits(NULL, bitmap_bh->b_data, bit, count);
 +	gdp->bg_free_blocks_count =
 +		cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) + count);
diff --git a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-rhel4.patch b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-rhel4.patch
index abc43d6..6a5d68a 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-rhel4.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-rhel4.patch
@@ -358,20 +358,20 @@ Index: linux-2.6.9-67.0.22/fs/ext3/super.c
 +	if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_MMP) &&
 +	    !(sb->s_flags & MS_RDONLY))
 +		if (ext3_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
-+			goto failed_mount3;
++			goto failed_mount2;
 +
  	/*
  	 * The first inode we look at is the journal inode.  Don't try
  	 * root first: it may be modified in the journal!
-@@ -1888,6 +2221,8 @@ static int ext3_fill_super (struct super
- 	return 0;
- 
+@@ -1890,6 +2223,8 @@ static int ext3_fill_super (struct super
  failed_mount3:
-+	if (sbi->s_mmp_tsk)
-+		kthread_stop(sbi->s_mmp_tsk);
  	journal_destroy(sbi->s_journal);
  failed_mount2:
++	if (sbi->s_mmp_tsk)
++		kthread_stop(sbi->s_mmp_tsk);
  	for (i = 0; i < db_count; i++)
+ 		brelse(sbi->s_group_desc[i]);
+ 	kfree(sbi->s_group_desc);
 @@ -2415,6 +2750,11 @@ int ext3_remount (struct super_block * s
  				return ret;
  			if (!ext3_setup_super (sb, es, 0))
diff --git a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-sles10.patch b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-sles10.patch
index 27820d4..f441b91 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-sles10.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6-sles10.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.16.60-0.31/fs/ext3/super.c
+Index: linux-2.6.16.60-0.37/fs/ext3/super.c
 ===================================================================
---- linux-2.6.16.60-0.31.orig/fs/ext3/super.c
-+++ linux-2.6.16.60-0.31/fs/ext3/super.c
+--- linux-2.6.16.60-0.37.orig/fs/ext3/super.c
++++ linux-2.6.16.60-0.37/fs/ext3/super.c
 @@ -36,6 +36,8 @@
  #include <linux/namei.h>
  #include <linux/quotaops.h>
@@ -357,20 +357,20 @@ Index: linux-2.6.16.60-0.31/fs/ext3/super.c
 +	if (EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_MMP) &&
 +	    !(sb->s_flags & MS_RDONLY))
 +		if (ext3_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
-+			goto failed_mount3;
++			goto failed_mount2;
 +
  	/*
  	 * The first inode we look at is the journal inode.  Don't try
  	 * root first: it may be modified in the journal!
-@@ -1991,6 +2323,8 @@ cantfind_ext3:
- 	goto failed_mount;
- 
+@@ -1993,6 +2325,8 @@ cantfind_ext3:
  failed_mount3:
-+	if (sbi->s_mmp_tsk)
-+		kthread_stop(sbi->s_mmp_tsk);
  	journal_destroy(sbi->s_journal);
  failed_mount2:
++	if (sbi->s_mmp_tsk)
++		kthread_stop(sbi->s_mmp_tsk);
  	for (i = 0; i < db_count; i++)
+ 		brelse(sbi->s_group_desc[i]);
+ 	kfree(sbi->s_group_desc);
 @@ -2463,7 +2797,7 @@ static int ext3_remount (struct super_bl
  	unsigned long n_blocks_count = 0;
  	unsigned long old_sb_flags;
@@ -380,22 +380,24 @@ Index: linux-2.6.16.60-0.31/fs/ext3/super.c
  #ifdef CONFIG_QUOTA
  	int i;
  #endif
-@@ -2547,6 +2881,11 @@ static int ext3_remount (struct super_bl
+@@ -2547,6 +2881,13 @@ static int ext3_remount (struct super_bl
  			}
  			if (!ext3_setup_super (sb, es, 0))
  				sb->s_flags &= ~MS_RDONLY;
 +			if (EXT3_HAS_INCOMPAT_FEATURE(sb,
 +						    EXT3_FEATURE_INCOMPAT_MMP))
 +				if (ext3_multi_mount_protect(sb,
-+						le64_to_cpu(es->s_mmp_block)))
++						le64_to_cpu(es->s_mmp_block))) {
++					err = -EROFS;
 +					goto restore_opts;
++				}
  		}
  	}
  #ifdef CONFIG_QUOTA
-Index: linux-2.6.16.60-0.31/include/linux/ext3_fs.h
+Index: linux-2.6.16.60-0.37/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.16.60-0.31.orig/include/linux/ext3_fs.h
-+++ linux-2.6.16.60-0.31/include/linux/ext3_fs.h
+--- linux-2.6.16.60-0.37.orig/include/linux/ext3_fs.h
++++ linux-2.6.16.60-0.37/include/linux/ext3_fs.h
 @@ -597,13 +597,17 @@ struct ext3_super_block {
  	__le32	s_first_meta_bg;	/* First metablock block group */
  	__le32	s_mkfs_time;		/* When the filesystem was created */
@@ -473,10 +475,10 @@ Index: linux-2.6.16.60-0.31/include/linux/ext3_fs.h
   * Function prototypes
   */
  
-Index: linux-2.6.16.60-0.31/include/linux/ext3_fs_sb.h
+Index: linux-2.6.16.60-0.37/include/linux/ext3_fs_sb.h
 ===================================================================
---- linux-2.6.16.60-0.31.orig/include/linux/ext3_fs_sb.h
-+++ linux-2.6.16.60-0.31/include/linux/ext3_fs_sb.h
+--- linux-2.6.16.60-0.37.orig/include/linux/ext3_fs_sb.h
++++ linux-2.6.16.60-0.37/include/linux/ext3_fs_sb.h
 @@ -147,6 +147,7 @@ struct ext3_sb_info {
  	/* locality groups */
  	struct ext3_locality_group *s_locality_groups;
diff --git a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.18-vanilla.patch b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.18-vanilla.patch
index 93db818..c5875a6 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.18-vanilla.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.18-vanilla.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.18-92.1.17/fs/ext3/super.c
+Index: linux-2.6.18-128.1.6/fs/ext3/super.c
 ===================================================================
---- linux-2.6.18-92.1.17.orig/fs/ext3/super.c
-+++ linux-2.6.18-92.1.17/fs/ext3/super.c
+--- linux-2.6.18-128.1.6.orig/fs/ext3/super.c
++++ linux-2.6.18-128.1.6/fs/ext3/super.c
 @@ -35,6 +35,8 @@
  #include <linux/namei.h>
  #include <linux/quotaops.h>
@@ -11,7 +11,7 @@ Index: linux-2.6.18-92.1.17/fs/ext3/super.c
  
  #include <asm/uaccess.h>
  
-@@ -435,6 +437,8 @@ static void ext3_put_super (struct super
+@@ -440,6 +442,8 @@ static void ext3_put_super (struct super
  		invalidate_bdev(sbi->journal_bdev, 0);
  		ext3_blkdev_remove(sbi);
  	}
@@ -20,7 +20,7 @@ Index: linux-2.6.18-92.1.17/fs/ext3/super.c
  	if (sbi->s_dev_proc) {
  		remove_proc_entry(sbi->s_dev_proc->name, proc_root_ext3);
  		sbi->s_dev_proc = NULL;
-@@ -1543,6 +1547,329 @@ static ext3_fsblk_t descriptor_loc(struc
+@@ -1548,6 +1552,329 @@ static ext3_fsblk_t descriptor_loc(struc
  	return (has_super + ext3_group_first_block_no(sb, bg));
  }
  
@@ -350,7 +350,7 @@ Index: linux-2.6.18-92.1.17/fs/ext3/super.c
  
  static int ext3_fill_super (struct super_block *sb, void *data, int silent)
  {
-@@ -1875,6 +2202,11 @@ static int ext3_fill_super (struct super
+@@ -1880,6 +2207,11 @@ static int ext3_fill_super (struct super
  			  EXT3_HAS_INCOMPAT_FEATURE(sb,
  				    EXT3_FEATURE_INCOMPAT_RECOVER));
  
@@ -362,7 +362,7 @@ Index: linux-2.6.18-92.1.17/fs/ext3/super.c
  	/*
  	 * The first inode we look at is the journal inode.  Don't try
  	 * root first: it may be modified in the journal!
-@@ -2007,6 +2339,8 @@ cantfind_ext3:
+@@ -2012,6 +2344,8 @@ cantfind_ext3:
  failed_mount4:
  	journal_destroy(sbi->s_journal);
  failed_mount3:
@@ -371,7 +371,7 @@ Index: linux-2.6.18-92.1.17/fs/ext3/super.c
  	percpu_counter_destroy(&sbi->s_freeblocks_counter);
  	percpu_counter_destroy(&sbi->s_freeinodes_counter);
  	percpu_counter_destroy(&sbi->s_dirs_counter);
-@@ -2482,7 +2816,7 @@ static int ext3_remount (struct super_bl
+@@ -2497,7 +2831,7 @@ static int ext3_remount (struct super_bl
  	ext3_fsblk_t n_blocks_count = 0;
  	unsigned long old_sb_flags;
  	struct ext3_mount_options old_opts;
@@ -380,22 +380,24 @@ Index: linux-2.6.18-92.1.17/fs/ext3/super.c
  #ifdef CONFIG_QUOTA
  	int i;
  #endif
-@@ -2580,6 +2914,11 @@ static int ext3_remount (struct super_bl
+@@ -2595,6 +2929,13 @@ static int ext3_remount (struct super_bl
  			}
  			if (!ext3_setup_super (sb, es, 0))
  				sb->s_flags &= ~MS_RDONLY;
 +			if (EXT3_HAS_INCOMPAT_FEATURE(sb,
 +						    EXT3_FEATURE_INCOMPAT_MMP))
 +				if (ext3_multi_mount_protect(sb,
-+						le64_to_cpu(es->s_mmp_block)))
++						le64_to_cpu(es->s_mmp_block))) {
++					err = -EROFS;
 +					goto restore_opts;
++				}
  		}
  	}
  #ifdef CONFIG_QUOTA
-Index: linux-2.6.18-92.1.17/include/linux/ext3_fs.h
+Index: linux-2.6.18-128.1.6/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.18-92.1.17.orig/include/linux/ext3_fs.h
-+++ linux-2.6.18-92.1.17/include/linux/ext3_fs.h
+--- linux-2.6.18-128.1.6.orig/include/linux/ext3_fs.h
++++ linux-2.6.18-128.1.6/include/linux/ext3_fs.h
 @@ -594,13 +594,17 @@ struct ext3_super_block {
  	__le32	s_first_meta_bg;	/* First metablock block group */
  	__le32	s_mkfs_time;		/* When the filesystem was created */
@@ -473,10 +475,10 @@ Index: linux-2.6.18-92.1.17/include/linux/ext3_fs.h
   * Function prototypes
   */
  
-Index: linux-2.6.18-92.1.17/include/linux/ext3_fs_sb.h
+Index: linux-2.6.18-128.1.6/include/linux/ext3_fs_sb.h
 ===================================================================
---- linux-2.6.18-92.1.17.orig/include/linux/ext3_fs_sb.h
-+++ linux-2.6.18-92.1.17/include/linux/ext3_fs_sb.h
+--- linux-2.6.18-128.1.6.orig/include/linux/ext3_fs_sb.h
++++ linux-2.6.18-128.1.6/include/linux/ext3_fs_sb.h
 @@ -158,6 +158,7 @@ struct ext3_sb_info {
  	/* locality groups */
  	struct ext3_locality_group *s_locality_groups;
diff --git a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.22-vanilla.patch b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.22-vanilla.patch
index 0a15100..b6df0f2 100644
--- a/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.22-vanilla.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-mmp-2.6.22-vanilla.patch
@@ -380,15 +380,17 @@ Index: linux-2.6.22.14/fs/ext3/super.c
  #ifdef CONFIG_QUOTA
  	int i;
  #endif
-@@ -2580,6 +2914,11 @@ static int ext3_remount (struct super_bl
+@@ -2580,6 +2914,13 @@ static int ext3_remount (struct super_bl
  				goto restore_opts;
  			if (!ext3_setup_super (sb, es, 0))
  				sb->s_flags &= ~MS_RDONLY;
 +			if (EXT3_HAS_INCOMPAT_FEATURE(sb,
 +						    EXT3_FEATURE_INCOMPAT_MMP))
 +				if (ext3_multi_mount_protect(sb,
-+						le64_to_cpu(es->s_mmp_block)))
++						le64_to_cpu(es->s_mmp_block))) {
++					err = -EROFS;
 +					goto restore_opts;
++				}
  		}
  	}
  #ifdef CONFIG_QUOTA
diff --git a/ldiskfs/kernel_patches/patches/ext3-nlinks-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext3-nlinks-2.6-rhel5.patch
new file mode 100644
index 0000000..e2dac7b
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext3-nlinks-2.6-rhel5.patch
@@ -0,0 +1,158 @@
+Index: linux-2.6.18-53.1.14/fs/ext3/namei.c
+===================================================================
+--- linux-2.6.18-53.1.14/fs/ext3/namei.c	2008-12-02 13:21:14.000000000 +0530
++++ linux-2.6.18-53.1.14_new/fs/ext3/namei.c	2008-12-02 15:11:09.000000000 +0530
+@@ -1656,11 +1656,17 @@ static int ext3_delete_entry (handle_t *
+ static inline void ext3_inc_count(handle_t *handle, struct inode *inode)
+ {
+ 	inode->i_nlink++;
++	if (is_dx(inode) && inode->i_nlink > 1) {
++		/* limit is 16-bit i_links_count */
++		if (inode->i_nlink >= EXT3_LINK_MAX || inode->i_nlink == 2)
++			inode->i_nlink = 1;
++	}
+ }
+ 
+ static inline void ext3_dec_count(handle_t *handle, struct inode *inode)
+ {
+-	inode->i_nlink--;
++	if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2)
++		drop_nlink(inode);
+ }
+ 
+ static int ext3_add_nondir(handle_t *handle,
+@@ -1759,7 +1770,7 @@ static int ext3_mkdir(struct inode * dir
+ 	struct ext3_dir_entry_2 * de;
+ 	int err, retries = 0;
+ 
+-	if (dir->i_nlink >= EXT3_LINK_MAX)
++	if (EXT3_DIR_LINK_MAX(dir))
+ 		return -EMLINK;
+ 
+ retry:
+@@ -1782,7 +1793,7 @@ retry:
+ 	inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
+ 	dir_block = ext3_bread (handle, inode, 0, 1, &err);
+ 	if (!dir_block) {
+-		inode->i_nlink--; /* is this nlink == 0? */
++		drop_nlink(inode); /* is this nlink == 0? */
+ 		ext3_mark_inode_dirty(handle, inode);
+ 		iput (inode);
+ 		goto out_stop;
+@@ -1814,7 +1825,7 @@ retry:
+ 		iput (inode);
+ 		goto out_stop;
+ 	}
+-	dir->i_nlink++;
++	ext3_inc_count(handle, dir);
+ 	ext3_update_dx_flag(dir);
+ 	ext3_mark_inode_dirty(handle, dir);
+ 	d_instantiate(dentry, inode);
+@@ -2079,10 +2090,10 @@ static int ext3_rmdir (struct inode * di
+ 	retval = ext3_delete_entry(handle, dir, de, bh);
+ 	if (retval)
+ 		goto end_rmdir;
+-	if (inode->i_nlink != 2)
+-		ext3_warning (inode->i_sb, "ext3_rmdir",
+-			      "empty directory has nlink!=2 (%d)",
+-			      inode->i_nlink);
++	if (!EXT3_DIR_LINK_EMPTY(inode))
++		ext3_warning(inode->i_sb, "ext3_rmdir",
++			     "empty directory has too many links (%d)",
++			     inode->i_nlink);
+ 	inode->i_version++;
+ 	inode->i_nlink = 0;
+ 	/* There's no need to set i_disksize: the fact that i_nlink is
+@@ -2092,7 +2103,7 @@ static int ext3_rmdir (struct inode * di
+ 	ext3_orphan_add(handle, inode);
+ 	inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
+ 	ext3_mark_inode_dirty(handle, inode);
+-	dir->i_nlink--;
++	ext3_dec_count(handle, dir);
+ 	ext3_update_dx_flag(dir);
+ 	ext3_mark_inode_dirty(handle, dir);
+ 
+@@ -2143,7 +2154,7 @@ static int ext3_unlink(struct inode * di
+ 	dir->i_ctime = dir->i_mtime = CURRENT_TIME_SEC;
+ 	ext3_update_dx_flag(dir);
+ 	ext3_mark_inode_dirty(handle, dir);
+-	inode->i_nlink--;
++	ext3_dec_count(handle, inode);
+ 	if (!inode->i_nlink)
+ 		ext3_orphan_add(handle, inode);
+ 	inode->i_ctime = dir->i_ctime;
+@@ -2219,7 +2230,7 @@ static int ext3_link (struct dentry * ol
+ 	struct inode *inode = old_dentry->d_inode;
+ 	int err, retries = 0;
+ 
+-	if (inode->i_nlink >= EXT3_LINK_MAX)
++	if (EXT3_DIR_LINK_MAX(inode))
+ 		return -EMLINK;
+ 	/*
+ 	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
+@@ -2313,8 +2324,8 @@ static int ext3_rename (struct inode * o
+ 		if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino)
+ 			goto end_rename;
+ 		retval = -EMLINK;
+-		if (!new_inode && new_dir!=old_dir &&
+-				new_dir->i_nlink >= EXT3_LINK_MAX)
++		if (!new_inode && new_dir != old_dir &&
++		    EXT3_DIR_LINK_MAX(new_dir))
+ 			goto end_rename;
+ 	}
+ 	if (!new_bh) {
+@@ -2371,7 +2382,7 @@ static int ext3_rename (struct inode * o
+ 	}
+ 
+ 	if (new_inode) {
+-		new_inode->i_nlink--;
++		ext3_dec_count(handle, new_inode);
+ 		new_inode->i_ctime = CURRENT_TIME_SEC;
+ 	}
+ 	old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME_SEC;
+@@ -2382,11 +2393,13 @@ static int ext3_rename (struct inode * o
+ 		PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino);
+ 		BUFFER_TRACE(dir_bh, "call ext3_journal_dirty_metadata");
+ 		ext3_journal_dirty_metadata(handle, dir_bh);
+-		old_dir->i_nlink--;
++		ext3_dec_count(handle, old_dir);
+ 		if (new_inode) {
+-			new_inode->i_nlink--;
++			/* checked empty_dir above, can't have another parent,
++			 * ext3_dec_count() won't work for many-linked dirs */
++			new_inode->i_nlink = 0;
+ 		} else {
+-			new_dir->i_nlink++;
++			ext3_inc_count(handle, new_dir);
+ 			ext3_update_dx_flag(new_dir);
+ 			ext3_mark_inode_dirty(handle, new_dir);
+ 		}
+Index: linux-2.6.18-53.1.14/include/linux/ext3_fs.h
+===================================================================
+--- linux-2.6.18-53.1.14/include/linux/ext3_fs.h	2008-12-02 13:21:23.000000000 +0530
++++ linux-2.6.18-53.1.14_new/include/linux/ext3_fs.h	2008-12-02 13:22:04.000000000 +0530
+@@ -74,7 +74,7 @@
+ /*
+  * Maximal count of links to a file
+  */
+-#define EXT3_LINK_MAX		32000
++#define EXT3_LINK_MAX		65000
+ 
+ /*
+  * Macro-instructions used to manage several block sizes
+@@ -563,6 +563,7 @@ static inline int ext3_valid_inum(struct
+ #define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER	0x0001
+ #define EXT3_FEATURE_RO_COMPAT_LARGE_FILE	0x0002
+ #define EXT3_FEATURE_RO_COMPAT_BTREE_DIR	0x0004
++#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK	0x0020
+ 
+ #define EXT3_FEATURE_INCOMPAT_COMPRESSION	0x0001
+ #define EXT3_FEATURE_INCOMPAT_FILETYPE		0x0002
+@@ -576,6 +577,7 @@ static inline int ext3_valid_inum(struct
+ 					 EXT3_FEATURE_INCOMPAT_META_BG)
+ #define EXT3_FEATURE_RO_COMPAT_SUPP	(EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+ 					 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
++					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
+ 					 EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
+ 
+ /*
diff --git a/ldiskfs/kernel_patches/patches/ext3-uninit-2.6-sles10.patch b/ldiskfs/kernel_patches/patches/ext3-uninit-2.6-sles10.patch
index 49406ed..d001841 100644
--- a/ldiskfs/kernel_patches/patches/ext3-uninit-2.6-sles10.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-uninit-2.6-sles10.patch
@@ -6,10 +6,10 @@ group descriptor to avoid reading or scanning them at e2fsck time.
 A checksum of each group descriptor is used to ensure that corruption in
 the group descriptor's bit flags does not cause incorrect operation.
 
-Index: linux-2.6.16.54-0.2.5/include/linux/ext3_fs.h
+Index: linux-2.6.16.60-0.27/include/linux/ext3_fs.h
 ===================================================================
---- linux-2.6.16.54-0.2.5.orig/include/linux/ext3_fs.h
-+++ linux-2.6.16.54-0.2.5/include/linux/ext3_fs.h
+--- linux-2.6.16.60-0.27.orig/include/linux/ext3_fs.h
++++ linux-2.6.16.60-0.27/include/linux/ext3_fs.h
 @@ -153,16 +153,22 @@ struct ext3_allocation_request {
   */
  struct ext3_group_desc
@@ -37,7 +37,7 @@ Index: linux-2.6.16.54-0.2.5/include/linux/ext3_fs.h
  /*
   * Macro-instructions used to manage group descriptors
   */
-@@ -607,6 +613,7 @@ static inline int ext3_valid_inum(struct
+@@ -604,6 +610,7 @@ static inline int ext3_valid_inum(struct
  #define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER	0x0001
  #define EXT3_FEATURE_RO_COMPAT_LARGE_FILE	0x0002
  #define EXT3_FEATURE_RO_COMPAT_BTREE_DIR	0x0004
@@ -45,7 +45,7 @@ Index: linux-2.6.16.54-0.2.5/include/linux/ext3_fs.h
  #define EXT4_FEATURE_RO_COMPAT_DIR_NLINK	0x0020
  
  #define EXT3_FEATURE_INCOMPAT_COMPRESSION	0x0001
-@@ -623,6 +630,7 @@ static inline int ext3_valid_inum(struct
+@@ -620,6 +627,7 @@ static inline int ext3_valid_inum(struct
  					 EXT3_FEATURE_INCOMPAT_EXTENTS)
  #define EXT3_FEATURE_RO_COMPAT_SUPP	(EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
  					 EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
@@ -53,10 +53,10 @@ Index: linux-2.6.16.54-0.2.5/include/linux/ext3_fs.h
  					 EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
  					 EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
  
-Index: linux-2.6.16.54-0.2.5/fs/ext3/resize.c
+Index: linux-2.6.16.60-0.27/fs/ext3/resize.c
 ===================================================================
---- linux-2.6.16.54-0.2.5.orig/fs/ext3/resize.c
-+++ linux-2.6.16.54-0.2.5/fs/ext3/resize.c
+--- linux-2.6.16.60-0.27.orig/fs/ext3/resize.c
++++ linux-2.6.16.60-0.27/fs/ext3/resize.c
 @@ -19,6 +19,7 @@
  #include <linux/errno.h>
  #include <linux/slab.h>
@@ -65,11 +65,10 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/resize.c
  
  #define outside(b, first, last)	((b) < (first) || (b) >= (last))
  #define inside(b, first, last)	((b) >= (first) && (b) < (last))
-@@ -133,25 +134,6 @@ static struct buffer_head *bclean(handle
- 	return bh;
+@@ -134,25 +135,6 @@ static struct buffer_head *bclean(handle
  }
  
--/*
+ /*
 - * To avoid calling the atomic setbit hundreds or thousands of times, we only
 - * need to use it within a single byte (to ensure we get endianness right).
 - * We can use memset for the rest of the bitmap as there are no other users.
@@ -88,10 +87,11 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/resize.c
 -		memset(bitmap + (i >> 3), 0xff, (end_bit - i) >> 3);
 -}
 -
- /*
+-/*
   * If we have fewer than thresh credits, extend by EXT3_MAX_TRANS_DATA.
   * If that fails, restart the transaction & regain write access for the
-@@ -818,6 +800,7 @@ int ext3_group_add(struct super_block *s
+  * buffer head which is used for block_bitmap modifications.
+@@ -865,6 +847,7 @@ int ext3_group_add(struct super_block *s
  	gdp->bg_inode_table = cpu_to_le32(input->inode_table);
  	gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
  	gdp->bg_free_inodes_count = cpu_to_le16(EXT3_INODES_PER_GROUP(sb));
@@ -99,10 +99,10 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/resize.c
  
  	/*
  	 * Make the new blocks and inodes valid next.  We do this before
-Index: linux-2.6.16.54-0.2.5/fs/ext3/super.c
+Index: linux-2.6.16.60-0.27/fs/ext3/super.c
 ===================================================================
---- linux-2.6.16.54-0.2.5.orig/fs/ext3/super.c
-+++ linux-2.6.16.54-0.2.5/fs/ext3/super.c
+--- linux-2.6.16.60-0.27.orig/fs/ext3/super.c
++++ linux-2.6.16.60-0.27/fs/ext3/super.c
 @@ -42,6 +42,7 @@
  #include "xattr.h"
  #include "acl.h"
@@ -216,15 +216,15 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/super.c
  		block += EXT3_BLOCKS_PER_GROUP(sb);
  		gdp++;
  	}
-Index: linux-2.6.16.54-0.2.5/fs/ext3/group.h
+Index: linux-2.6.16.60-0.27/fs/ext3/group.h
 ===================================================================
 --- /dev/null
-+++ linux-2.6.16.54-0.2.5/fs/ext3/group.h
++++ linux-2.6.16.60-0.27/fs/ext3/group.h
 @@ -0,0 +1,30 @@
 +/*
 + *  linux/fs/ext3/group.h
 + *
-+ * Copyright 2008 Sun Microsystems, Inc.
++ * Copyright 2008 Sun Microsystems, Inc
 + *
 + * Author: Andreas Dilger <adilger at clusterfs.com>
 + */
@@ -251,10 +251,10 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/group.h
 +				       struct ext3_group_desc *desc);
 +extern void mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
 +#endif /* _LINUX_EXT3_GROUP_H */
-Index: linux-2.6.16.54-0.2.5/fs/ext3/ialloc.c
+Index: linux-2.6.16.60-0.27/fs/ext3/ialloc.c
 ===================================================================
---- linux-2.6.16.54-0.2.5.orig/fs/ext3/ialloc.c
-+++ linux-2.6.16.54-0.2.5/fs/ext3/ialloc.c
+--- linux-2.6.16.60-0.27.orig/fs/ext3/ialloc.c
++++ linux-2.6.16.60-0.27/fs/ext3/ialloc.c
 @@ -28,6 +28,7 @@
  
  #include "xattr.h"
@@ -450,10 +450,10 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/ialloc.c
  	/* This is the optimal IO size (for stat), not the fs block size */
  	inode->i_blksize = PAGE_SIZE;
  	inode->i_blocks = 0;
-Index: linux-2.6.16.54-0.2.5/fs/ext3/mballoc.c
+Index: linux-2.6.16.60-0.27/fs/ext3/mballoc.c
 ===================================================================
---- linux-2.6.16.54-0.2.5.orig/fs/ext3/mballoc.c
-+++ linux-2.6.16.54-0.2.5/fs/ext3/mballoc.c
+--- linux-2.6.16.60-0.27.orig/fs/ext3/mballoc.c
++++ linux-2.6.16.60-0.27/fs/ext3/mballoc.c
 @@ -36,6 +36,8 @@
  #include <linux/seq_file.h>
  #include <linux/version.h>
@@ -560,10 +560,10 @@ Index: linux-2.6.16.54-0.2.5/fs/ext3/mballoc.c
  	spin_unlock(sb_bgl_lock(sbi, block_group));
  	percpu_counter_mod(&sbi->s_freeblocks_counter, count);
  
-Index: linux-2.6.16.54-0.2.5/fs/ext3/balloc.c
+Index: linux-2.6.16.60-0.27/fs/ext3/balloc.c
 ===================================================================
---- linux-2.6.16.54-0.2.5.orig/fs/ext3/balloc.c
-+++ linux-2.6.16.54-0.2.5/fs/ext3/balloc.c
+--- linux-2.6.16.60-0.27.orig/fs/ext3/balloc.c
++++ linux-2.6.16.60-0.27/fs/ext3/balloc.c
 @@ -21,6 +21,7 @@
  #include <linux/quotaops.h>
  #include <linux/buffer_head.h>
diff --git a/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.18.patch b/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.18.patch
index e184d14..88dc179 100644
--- a/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.18.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.18.patch
@@ -88,9 +88,9 @@ Index: linux-2.6.18-53.1.14/fs/ext3/resize.c
 -}
 -
 -/*
-  * Set up the block and inode bitmaps, and the inode table for the new group.
-  * This doesn't need to be part of the main transaction, since we are only
-  * changing blocks outside the actual filesystem.  We still do journaling to
+  * If we have fewer than thresh credits, extend by EXT3_MAX_TRANS_DATA.
+  * If that fails, restart the transaction & regain write access for the
+  * buffer head which is used for block_bitmap modifications.
 @@ -834,6 +816,7 @@ int ext3_group_add(struct super_block *s
  	gdp->bg_inode_table = cpu_to_le32(input->inode_table);
  	gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
diff --git a/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.9.patch b/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.9.patch
index ed196a9..eb9a75d 100644
--- a/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.9.patch
+++ b/ldiskfs/kernel_patches/patches/ext3-uninit-2.6.9.patch
@@ -88,9 +88,9 @@ Index: linux-2.6.9-67.0.15/fs/ext3/resize.c
 -}
 -
 -/*
-  * If we have fewer than thresh credits, extend by EXT3_MAX_TRANS_DATA.
-  * If that fails, restart the transaction & regain write access for the
-  * buffer head which is used for block_bitmap modifications.
+  * Set up the block and inode bitmaps, and the inode table for the new group.
+  * This doesn't need to be part of the main transaction, since we are only
+  * changing blocks outside the actual filesystem.  We still do journaling to
 @@ -807,6 +789,7 @@ int ext3_group_add(struct super_block *s
  	gdp->bg_inode_table = cpu_to_le32(input->inode_table);
  	gdp->bg_free_blocks_count = cpu_to_le16(input->free_blocks_count);
@@ -680,7 +680,7 @@ Index: linux-2.6.9-67.0.15/fs/ext3/balloc.c
 @@ -429,6 +519,7 @@ do_more:
  	gdp->bg_free_blocks_count =
  		cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) +
-			group_freed);
+ 			*pdquot_freed_blocks);
 +	gdp->bg_checksum = ext3_group_desc_csum(sbi, block_group, gdp);
  	spin_unlock(sb_bgl_lock(sbi, block_group));
  	percpu_counter_mod(&sbi->s_freeblocks_counter, count);
diff --git a/ldiskfs/kernel_patches/patches/ext4-alloc-policy-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-alloc-policy-2.6-rhel5.patch
new file mode 100644
index 0000000..a1b8375
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-alloc-policy-2.6-rhel5.patch
@@ -0,0 +1,101 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ialloc.c
++++ linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+@@ -946,6 +946,36 @@ fail_drop:
+ 	return ERR_PTR(err);
+ }
+ 
++unsigned long ext4_find_reverse(struct super_block *sb)
++{
++	struct ext4_group_desc *desc;
++	struct buffer_head *bitmap_bh = NULL;
++	int group;
++	unsigned long ino, offset;
++
++	for (offset = (EXT4_INODES_PER_GROUP(sb) >> 1); offset >= 0;
++	     offset >>= 1) {
++		for (group = EXT4_SB(sb)->s_groups_count - 1; group >= 0;
++		     --group) {
++			desc = ext4_get_group_desc(sb, group, NULL);
++			if (desc->bg_free_inodes_count == 0)
++				continue;
++
++			bitmap_bh = ext4_read_inode_bitmap(sb, group);
++			if (!bitmap_bh)
++				continue;
++
++			ino = ext4_find_next_zero_bit((unsigned long *)
++					bitmap_bh->b_data,
++					EXT4_INODES_PER_GROUP(sb), offset);
++			if (ino < EXT4_INODES_PER_GROUP(sb))
++				return (group * EXT4_INODES_PER_GROUP(sb) +
++				       ino + 1);
++		}
++	}
++	return 0;
++}
++
+ /* Verify that we are loading a valid orphan from disk */
+ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
+ {
+Index: linux-2.6.18-128.1.6/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/namei.c
++++ linux-2.6.18-128.1.6/fs/ext4/namei.c
+@@ -151,14 +151,24 @@ struct dx_map_entry
+ 	u16 size;
+ };
+ 
++/*
++ * dentry_param used by ext4_new_inode_wantedi()
++ */
+ #define LVFS_DENTRY_PARAM_MAGIC		20070216UL
+ struct lvfs_dentry_params
+ {
+-	unsigned long   p_inum;
+-	void	    *p_ptr;
+-	u32	     magic;
++	unsigned long   ldp_inum;
++	long		ldp_flags;
++	u32		ldp_magic;
+ };
+ 
++/* Only use the least 3 bits of ldp_flags for goal policy */
++typedef enum {
++	DP_GOAL_POLICY       = 0,
++	DP_LASTGROUP_REVERSE = 1,
++} dp_policy_t;
++
++
+ static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
+ static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
+ static inline unsigned dx_get_hash (struct dx_entry *entry);
+@@ -1762,8 +1772,13 @@ static struct inode * ext4_new_inode_wan
+ 	if (dentry->d_fsdata != NULL) {
+ 		struct lvfs_dentry_params *param = dentry->d_fsdata;
+ 
+-		if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
+-			inum = param->p_inum;
++		if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC) {
++			if ((dp_policy_t)(param->ldp_flags & 0x7) ==
++			    DP_LASTGROUP_REVERSE)
++				inum = ext4_find_reverse(dir->i_sb);
++                        else /* DP_GOAL_POLICY */
++				inum = param->ldp_inum;
++                }
+ 	}
+ 	return ext4_new_inode(handle, dir, mode, inum);
+ }
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4.h
+@@ -1071,6 +1071,7 @@ extern int ext4fs_dirhash(const char *na
+ /* ialloc.c */
+ extern struct inode * ext4_new_inode (handle_t *, struct inode *, int,
+ 				      unsigned long);
++extern unsigned long ext4_find_reverse(struct super_block *);
+ extern void ext4_free_inode (handle_t *, struct inode *);
+ extern struct inode * ext4_orphan_get (struct super_block *, unsigned long);
+ extern unsigned long ext4_count_free_inodes (struct super_block *);
diff --git a/ldiskfs/kernel_patches/patches/ext4-alloc-policy-2.6-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-alloc-policy-2.6-sles11.patch
new file mode 100644
index 0000000..a39fb88
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-alloc-policy-2.6-sles11.patch
@@ -0,0 +1,101 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ialloc.c
++++ linux-2.6.27.21-0.1/fs/ext4/ialloc.c
+@@ -1005,6 +1005,36 @@ fail_drop:
+ 	return ERR_PTR(err);
+ }
+ 
++unsigned long ext4_find_reverse(struct super_block *sb)
++{
++	struct ext4_group_desc *desc;
++	struct buffer_head *bitmap_bh = NULL;
++	int group;
++	unsigned long ino, offset;
++
++	for (offset = (EXT4_INODES_PER_GROUP(sb) >> 1); offset >= 0;
++	     offset >>= 1) {
++		for (group = EXT4_SB(sb)->s_groups_count - 1; group >= 0;
++		     --group) {
++			desc = ext4_get_group_desc(sb, group, NULL);
++			if (ext4_free_inodes_count(sb, desc) == 0)
++				continue;
++
++			bitmap_bh = ext4_read_inode_bitmap(sb, group);
++			if (!bitmap_bh)
++				continue;
++
++			ino = ext4_find_next_zero_bit((unsigned long *)
++					bitmap_bh->b_data,
++					EXT4_INODES_PER_GROUP(sb), offset);
++			if (ino < EXT4_INODES_PER_GROUP(sb))
++				return (group * EXT4_INODES_PER_GROUP(sb) +
++				       ino + 1);
++		}
++	}
++	return 0;
++}
++
+ /* Verify that we are loading a valid orphan from disk */
+ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
+ {
+Index: linux-2.6.27.21-0.1/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/namei.c
++++ linux-2.6.27.21-0.1/fs/ext4/namei.c
+@@ -151,14 +151,24 @@ struct dx_map_entry
+ 	u16 size;
+ };
+ 
++/*
++ * dentry_param used by ext4_new_inode_wantedi()
++ */
+ #define LVFS_DENTRY_PARAM_MAGIC		20070216UL
+ struct lvfs_dentry_params
+ {
+-	unsigned long   p_inum;
+-	void	    *p_ptr;
+-	u32	     magic;
++	unsigned long   ldp_inum;
++	long		ldp_flags;
++	u32		ldp_magic;
+ };
+ 
++/* Only use the least 3 bits of ldp_flags for goal policy */
++typedef enum {
++	DP_GOAL_POLICY       = 0,
++	DP_LASTGROUP_REVERSE = 1,
++} dp_policy_t;
++
++
+ static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
+ static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
+ static inline unsigned dx_get_hash(struct dx_entry *entry);
+@@ -1770,8 +1780,13 @@ static struct inode * ext4_new_inode_wan
+ 	if (dentry->d_fsdata != NULL) {
+ 		struct lvfs_dentry_params *param = dentry->d_fsdata;
+ 
+-		if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
+-			inum = param->p_inum;
++		if (param->ldp_magic == LVFS_DENTRY_PARAM_MAGIC) {
++			if ((dp_policy_t)(param->ldp_flags & 0x7) ==
++			    DP_LASTGROUP_REVERSE)
++				inum = ext4_find_reverse(dir->i_sb);
++                        else /* DP_GOAL_POLICY */
++				inum = param->ldp_inum;
++                }
+ 	}
+ 	return ext4_new_inode(handle, dir, mode, inum);
+ }
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4.h
+@@ -1089,6 +1089,7 @@ extern int ext4fs_dirhash(const char *na
+ /* ialloc.c */
+ extern struct inode * ext4_new_inode(handle_t *, struct inode *, int,
+ 				     unsigned long);
++extern unsigned long ext4_find_reverse(struct super_block *);
+ extern void ext4_free_inode(handle_t *, struct inode *);
+ extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
+ extern unsigned long ext4_count_free_inodes(struct super_block *);
diff --git a/ldiskfs/kernel_patches/patches/ext4-big-endian-check-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-big-endian-check-2.6-rhel5.patch
new file mode 100644
index 0000000..0ec5670
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-big-endian-check-2.6-rhel5.patch
@@ -0,0 +1,56 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/super.c
++++ linux-2.6.18-128.1.6/fs/ext4/super.c
+@@ -70,6 +70,8 @@ struct page *ext4_zero_page;
+ 
+ struct proc_dir_entry *proc_root_ext4;
+ 
++static int bigendian_extents;
++
+ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
+ 			       struct ext4_group_desc *bg)
+ {
+@@ -1222,7 +1224,7 @@ enum {
+ 	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
+ 	Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
+ 	Opt_mballoc, Opt_nomballoc, Opt_stripe,
+-	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
++	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv, Opt_bigendian_extents,
+ };
+ 
+ static match_table_t tokens = {
+@@ -1284,6 +1286,7 @@ static match_table_t tokens = {
+ 	{Opt_nomballoc, "nomballoc"},
+ 	{Opt_stripe, "stripe=%u"},
+ 	{Opt_resize, "resize"},
++	{Opt_bigendian_extents, "bigendian_extents"},
+ 	{Opt_err, NULL},
+ };
+ 
+@@ -1682,6 +1685,9 @@ clear_qf_name:
+ 				return 0;
+ 			sbi->s_stripe = option;
+ 			break;
++		case Opt_bigendian_extents:
++			bigendian_extents = 1;
++			break;
+ 		default:
+ 			printk(KERN_ERR
+ 			       "EXT4-fs: Unrecognized mount option \"%s\" "
+@@ -2561,6 +2567,15 @@ static int ext4_fill_super(struct super_
+ 		goto failed_mount;
+ 	}
+ 
++#ifdef __BIG_ENDIAN
++	if (bigendian_extents == 0) {
++		printk(KERN_ERR "EXT4-fs: extents feature is not guaranteed to "
++		       "work on big-endian systems. Use \"bigendian_extents\" "
++		       "mount option to override.\n");
++		goto failed_mount;
++	}
++#endif
++
+ 	bgl_lock_init(&sbi->s_blockgroup_lock);
+ 
+ 	sbi->s_last_alloc_group = -1;
diff --git a/ldiskfs/kernel_patches/patches/ext4-big-endian-check-2.6-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-big-endian-check-2.6-sles11.patch
new file mode 100644
index 0000000..27bfee8
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-big-endian-check-2.6-sles11.patch
@@ -0,0 +1,56 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -74,6 +74,8 @@ static void ext4_write_super_lockfs(stru
+ 
+ struct proc_dir_entry *proc_root_ext4;
+ 
++static int bigendian_extents;
++
+ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
+ 			       struct ext4_group_desc *bg)
+ {
+@@ -1291,7 +1293,7 @@ enum {
+ 	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
+ 	Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
+ 	Opt_stripe, Opt_delalloc, Opt_nodelalloc,
+-	Opt_inode_readahead_blks,
++	Opt_inode_readahead_blks, Opt_bigendian_extents,
+ 	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
+ };
+ 
+@@ -1353,6 +1355,7 @@ static const match_table_t tokens = {
+ 	{Opt_delalloc, "delalloc"},
+ 	{Opt_nodelalloc, "nodelalloc"},
+ 	{Opt_inode_readahead_blks, "inode_readahead_blks=%u"},
++	{Opt_bigendian_extents, "bigendian_extents"},
+ 	{Opt_err, NULL},
+ };
+ 
+@@ -1768,6 +1771,9 @@ set_qf_format:
+ 				return 0;
+ 			sbi->s_inode_readahead_blks = option;
+ 			break;
++		case Opt_bigendian_extents:
++			bigendian_extents = 1;
++			break;
+ 		default:
+ 			printk(KERN_ERR
+ 			       "EXT4-fs: Unrecognized mount option \"%s\" "
+@@ -2673,6 +2679,15 @@ static int ext4_fill_super(struct super_
+ 				 &sbi->s_inode_readahead_blks);
+ #endif
+ 
++#ifdef __BIG_ENDIAN
++	if (bigendian_extents == 0) {
++		printk(KERN_ERR "EXT4-fs: extents feature is not guaranteed to "
++		       "work on big-endian systems. Use \"bigendian_extents\" "
++		       "mount option to override.\n");
++		goto failed_mount;
++	}
++#endif
++
+ 	bgl_lock_init(&sbi->s_blockgroup_lock);
+ 
+ 	sbi->s_last_alloc_group = -1;
diff --git a/ldiskfs/kernel_patches/patches/ext4-claim_inode-free_inode-race.patch b/ldiskfs/kernel_patches/patches/ext4-claim_inode-free_inode-race.patch
new file mode 100644
index 0000000..c742b38
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-claim_inode-free_inode-race.patch
@@ -0,0 +1,28 @@
+Index: linux-stage/fs/ext4/ialloc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/ialloc.c
++++ linux-stage/fs/ext4/ialloc.c
+@@ -189,7 +189,7 @@ void ext4_free_inode(handle_t *handle, s
+ 	struct ext4_group_desc *gdp;
+ 	struct ext4_super_block *es;
+ 	struct ext4_sb_info *sbi;
+-	int fatal = 0, err, count;
++	int fatal = 0, err, count, cleared;
+ 	ext4_group_t flex_group;
+ 
+ 	if (atomic_read(&inode->i_count) > 1) {
+@@ -243,9 +243,12 @@ void ext4_free_inode(handle_t *handle, s
+ 	if (fatal)
+ 		goto error_return;
+ 
++	ext4_lock_group(sb, block_group);
++	cleared = ext4_clear_bit(bit, bitmap_bh->b_data);
++	ext4_unlock_group(sb, block_group);
++
+ 	/* Ok, now we can actually update the inode bitmaps.. */
+-	if (!ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
+-		                   bit, bitmap_bh->b_data))
++	if (!cleared)
+ 		ext4_error(sb, "ext4_free_inode",
+ 			   "bit already cleared for inode %lu", ino);
+ 	else {
diff --git a/ldiskfs/kernel_patches/patches/ext4-convert-group-lock-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-convert-group-lock-rhel5.patch
new file mode 100644
index 0000000..370b2e7
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-convert-group-lock-rhel5.patch
@@ -0,0 +1,595 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/balloc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/balloc.c
++++ linux-2.6.18-128.1.6/fs/ext4/balloc.c
+@@ -321,15 +321,15 @@ ext4_read_block_bitmap(struct super_bloc
+ 	if (bh_uptodate_or_lock(bh))
+ 		return bh;
+ 
+-	spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_lock_group(sb, block_group);
+ 	if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 		ext4_init_block_bitmap(sb, bh, block_group, desc);
+ 		set_buffer_uptodate(bh);
+ 		unlock_buffer(bh);
+-		spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++		ext4_unlock_group(sb, block_group);
+ 		return bh;
+ 	}
+-	spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_unlock_group(sb, block_group);
+ 	if (bh_submit_read(bh) < 0) {
+ 		put_bh(bh);
+ 		ext4_error(sb, __func__,
+@@ -778,8 +778,9 @@ do_more:
+ 		BUFFER_TRACE(bitmap_bh, "set in b_committed_data");
+ 		J_ASSERT_BH(bitmap_bh,
+ 				bh2jh(bitmap_bh)->b_committed_data != NULL);
+-		ext4_set_bit_atomic(sb_bgl_lock(sbi, block_group), bit + i,
+-				bh2jh(bitmap_bh)->b_committed_data);
++		ext4_set_bit_atomic(ext4_group_lock_ptr(sb, block_group),
++		                    bit + i,
++				    bh2jh(bitmap_bh)->b_committed_data);
+ 
+ 		/*
+ 		 * We clear the bit in the bitmap after setting the committed
+@@ -787,7 +788,7 @@ do_more:
+ 		 * the allocator uses.
+ 		 */
+ 		BUFFER_TRACE(bitmap_bh, "clear bit");
+-		if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
++		if (!ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
+ 						bit + i, bitmap_bh->b_data)) {
+ 			jbd_unlock_bh_state(bitmap_bh);
+ 			ext4_error(sb, __func__,
+@@ -801,17 +802,17 @@ do_more:
+ 	}
+ 	jbd_unlock_bh_state(bitmap_bh);
+ 
+-	spin_lock(sb_bgl_lock(sbi, block_group));
++	ext4_lock_group(sb, block_group);
+ 	le16_add_cpu(&desc->bg_free_blocks_count, group_freed);
+ 	desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc);
+-	spin_unlock(sb_bgl_lock(sbi, block_group));
++	ext4_unlock_group(sb, block_group);
+ 	percpu_counter_add(&sbi->s_freeblocks_counter, count);
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, block_group);
+ 		sbi->s_flex_groups[flex_group].free_blocks += count;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, block_group);
+ 	}
+ 
+ 	/* We dirtied the bitmap block */
+@@ -1104,7 +1105,7 @@ repeat:
+ 	}
+ 	start = grp_goal;
+ 
+-	if (!claim_block(sb_bgl_lock(EXT4_SB(sb), group),
++	if (!claim_block(ext4_group_lock_ptr(sb, group),
+ 		grp_goal, bitmap_bh)) {
+ 		/*
+ 		 * The block was allocated by another thread, or it was
+@@ -1120,7 +1121,7 @@ repeat:
+ 	grp_goal++;
+ 	while (num < *count && grp_goal < end
+ 		&& ext4_test_allocatable(grp_goal, bitmap_bh)
+-		&& claim_block(sb_bgl_lock(EXT4_SB(sb), group),
++		&& claim_block(ext4_group_lock_ptr(sb, group),
+ 				grp_goal, bitmap_bh)) {
+ 		num++;
+ 		grp_goal++;
+@@ -1872,7 +1873,7 @@ allocated:
+ 		}
+ 	}
+ 	jbd_lock_bh_state(bitmap_bh);
+-	spin_lock(sb_bgl_lock(sbi, group_no));
++	ext4_lock_group(sb, group_no);
+ 	if (buffer_jbd(bitmap_bh) && bh2jh(bitmap_bh)->b_committed_data) {
+ 		int i;
+ 
+@@ -1885,7 +1886,7 @@ allocated:
+ 		}
+ 	}
+ 	ext4_debug("found bit %d\n", grp_alloc_blk);
+-	spin_unlock(sb_bgl_lock(sbi, group_no));
++	ext4_unlock_group(sb, group_no);
+ 	jbd_unlock_bh_state(bitmap_bh);
+ #endif
+ 
+@@ -1902,19 +1903,19 @@ allocated:
+ 	 * list of some description.  We don't know in advance whether
+ 	 * the caller wants to use it as metadata or data.
+ 	 */
+-	spin_lock(sb_bgl_lock(sbi, group_no));
++	ext4_lock_group(sb, group_no);
+ 	if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))
+ 		gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
+ 	le16_add_cpu(&gdp->bg_free_blocks_count, -num);
+ 	gdp->bg_checksum = ext4_group_desc_csum(sbi, group_no, gdp);
+-	spin_unlock(sb_bgl_lock(sbi, group_no));
++	ext4_unlock_group(sb, group_no);
+ 	percpu_counter_sub(&sbi->s_freeblocks_counter, num);
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ext4_group_t flex_group = ext4_flex_group(sbi, group_no);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_blocks -= num;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 
+ 	BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
+Index: linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ialloc.c
++++ linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+@@ -118,15 +118,15 @@ ext4_read_inode_bitmap(struct super_bloc
+ 	if (bh_uptodate_or_lock(bh))
+ 		return bh;
+ 
+-	spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_lock_group(sb, block_group);
+ 	if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
+ 		ext4_init_inode_bitmap(sb, bh, block_group, desc);
+ 		set_buffer_uptodate(bh);
+ 		unlock_buffer(bh);
+-		spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++		ext4_unlock_group(sb, block_group);
+ 		return bh;
+ 	}
+-	spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_unlock_group(sb, block_group);
+ 	if (bh_submit_read(bh) < 0) {
+ 		put_bh(bh);
+ 		ext4_error(sb, __func__,
+@@ -221,8 +221,8 @@ void ext4_free_inode (handle_t *handle, 
+ 		goto error_return;
+ 
+ 	/* Ok, now we can actually update the inode bitmaps.. */
+-	if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
+-					bit, bitmap_bh->b_data))
++	if (!ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
++				   bit, bitmap_bh->b_data))
+ 		ext4_error (sb, "ext4_free_inode",
+ 			      "bit already cleared for inode %lu", ino);
+ 	else {
+@@ -233,22 +233,22 @@ void ext4_free_inode (handle_t *handle, 
+ 		if (fatal) goto error_return;
+ 
+ 		if (gdp) {
+-			spin_lock(sb_bgl_lock(sbi, block_group));
++			ext4_lock_group(sb, block_group);
+ 			le16_add_cpu(&gdp->bg_free_inodes_count, 1);
+ 			if (is_directory)
+ 				le16_add_cpu(&gdp->bg_used_dirs_count, -1);
+ 			gdp->bg_checksum = ext4_group_desc_csum(sbi,
+ 							block_group, gdp);
+-			spin_unlock(sb_bgl_lock(sbi, block_group));
++			ext4_unlock_group(sb, block_group);
+ 			percpu_counter_inc(&sbi->s_freeinodes_counter);
+ 			if (is_directory)
+ 				percpu_counter_dec(&sbi->s_dirs_counter);
+ 
+ 			if (sbi->s_log_groups_per_flex) {
+ 				flex_group = ext4_flex_group(sbi, block_group);
+-				spin_lock(sb_bgl_lock(sbi, flex_group));
++				ext4_lock_group(sb, flex_group);
+ 				sbi->s_flex_groups[flex_group].free_inodes++;
+-				spin_unlock(sb_bgl_lock(sbi, flex_group));
++				ext4_unlock_group(sb, flex_group);
+ 			}
+ 		}
+ 		BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
+@@ -630,7 +630,7 @@ struct inode *ext4_new_inode(handle_t *h
+ 		if (err)
+ 			goto fail;
+ 
+-		if (ext4_set_bit_atomic(sb_bgl_lock(sbi, group),
++		if (ext4_set_bit_atomic(ext4_group_lock_ptr(sb, group),
+ 					ino, bitmap_bh->b_data)) {
+ 			printk(KERN_ERR "goal inode %lu unavailable\n", goal);
+ 			/* Oh well, we tried. */
+@@ -691,7 +691,7 @@ repeat_in_this_group:
+ 			if (err)
+ 				goto fail;
+ 
+-			if (!ext4_set_bit_atomic(sb_bgl_lock(sbi, group),
++			if (!ext4_set_bit_atomic(ext4_group_lock_ptr(sb, group),
+ 						ino, bitmap_bh->b_data)) {
+ 				/* we won it */
+ 				BUFFER_TRACE(bitmap_bh,
+@@ -751,14 +751,14 @@ got:
+ 		}
+ 
+ 		free = 0;
+-		spin_lock(sb_bgl_lock(sbi, group));
++		ext4_lock_group(sb, group);
+ 		/* recheck and clear flag under lock if we still need to */
+ 		if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 			gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
+ 			free = ext4_free_blocks_after_init(sb, group, gdp);
+ 			gdp->bg_free_blocks_count = cpu_to_le16(free);
+ 		}
+-		spin_unlock(sb_bgl_lock(sbi, group));
++		ext4_unlock_group(sb, group);
+ 
+ 		/* Don't need to dirty bitmap block if we didn't change it */
+ 		if (free) {
+@@ -771,7 +771,7 @@ got:
+ 			goto fail;
+ 	}
+ 
+-	spin_lock(sb_bgl_lock(sbi, group));
++	ext4_lock_group(sb, group);
+ 	/* If we didn't allocate from within the initialized part of the inode
+ 	 * table then we need to initialize up to this inode. */
+ 	if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
+@@ -807,7 +807,7 @@ got:
+ 		le16_add_cpu(&gdp->bg_used_dirs_count, 1);
+ 	}
+ 	gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
+-	spin_unlock(sb_bgl_lock(sbi, group));
++	ext4_unlock_group(sb, group);
+ 	BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
+ 	err = ext4_journal_dirty_metadata(handle, bh2);
+ 	if (err) goto fail;
+@@ -819,9 +819,9 @@ got:
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		flex_group = ext4_flex_group(sbi, group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_inodes--;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 
+ 	inode->i_uid = current->fsuid;
+Index: linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/mballoc.c
++++ linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+@@ -361,24 +361,12 @@ static inline void mb_set_bit(int bit, v
+ 	ext4_set_bit(bit, addr);
+ }
+ 
+-static inline void mb_set_bit_atomic(spinlock_t *lock, int bit, void *addr)
+-{
+-	addr = mb_correct_addr_and_bit(&bit, addr);
+-	ext4_set_bit_atomic(lock, bit, addr);
+-}
+-
+ static inline void mb_clear_bit(int bit, void *addr)
+ {
+ 	addr = mb_correct_addr_and_bit(&bit, addr);
+ 	ext4_clear_bit(bit, addr);
+ }
+ 
+-static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr)
+-{
+-	addr = mb_correct_addr_and_bit(&bit, addr);
+-	ext4_clear_bit_atomic(lock, bit, addr);
+-}
+-
+ static inline int mb_find_next_zero_bit(void *addr, int max, int start)
+ {
+ 	int fix = 0, ret, tmpmax;
+@@ -789,16 +777,16 @@ static int ext4_mb_init_cache(struct pag
+ 		if (bh_uptodate_or_lock(bh[i]))
+ 			continue;
+ 
+-		spin_lock(sb_bgl_lock(EXT4_SB(sb), first_group + i));
++		ext4_lock_group(sb, first_group + i);
+ 		if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 			ext4_init_block_bitmap(sb, bh[i],
+ 						first_group + i, desc);
+ 			set_buffer_uptodate(bh[i]);
+ 			unlock_buffer(bh[i]);
+-			spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i));
++			ext4_unlock_group(sb, first_group + i);
+ 			continue;
+ 		}
+-		spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i));
++		ext4_unlock_group(sb, first_group + i);
+ 		get_bh(bh[i]);
+ 		bh[i]->b_end_io = end_buffer_read_sync;
+ 		submit_bh(READ, bh[i]);
+@@ -1021,7 +1009,7 @@ static int mb_find_order_for_block(struc
+ 	return 0;
+ }
+ 
+-static void mb_clear_bits(spinlock_t *lock, void *bm, int cur, int len)
++static void mb_clear_bits(void *bm, int cur, int len)
+ {
+ 	__u32 *addr;
+ 
+@@ -1034,12 +1022,12 @@ static void mb_clear_bits(spinlock_t *lo
+ 			cur += 32;
+ 			continue;
+ 		}
+-		mb_clear_bit_atomic(lock, cur, bm);
++		mb_clear_bit(cur, bm);
+ 		cur++;
+ 	}
+ }
+ 
+-static void mb_set_bits(spinlock_t *lock, void *bm, int cur, int len)
++static void mb_set_bits(void *bm, int cur, int len)
+ {
+ 	__u32 *addr;
+ 
+@@ -1052,7 +1040,7 @@ static void mb_set_bits(spinlock_t *lock
+ 			cur += 32;
+ 			continue;
+ 		}
+-		mb_set_bit_atomic(lock, cur, bm);
++		mb_set_bit(cur, bm);
+ 		cur++;
+ 	}
+ }
+@@ -1268,8 +1256,7 @@ static int mb_mark_used(struct ext4_budd
+ 		e4b->bd_info->bb_counters[ord]++;
+ 	}
+ 
+-	mb_set_bits(sb_bgl_lock(EXT4_SB(e4b->bd_sb), ex->fe_group),
+-			EXT4_MB_BITMAP(e4b), ex->fe_start, len0);
++	mb_set_bits(EXT4_MB_BITMAP(e4b), ex->fe_start, len0);
+ 	mb_check_buddy(e4b);
+ 
+ 	return ret;
+@@ -2651,7 +2638,7 @@ int ext4_mb_init(struct super_block *sb,
+ 	return 0;
+ }
+ 
+-/* need to called with ext4 group lock (ext4_lock_group) */
++/* need to called with the ext4 group lock held */
+ static void ext4_mb_cleanup_pa(struct ext4_group_info *grp)
+ {
+ 	struct ext4_prealloc_space *pa;
+@@ -3130,14 +3117,17 @@ ext4_mb_mark_diskspace_used(struct ext4_
+ 		 * Fix the bitmap and repeat the block allocation
+ 		 * We leak some of the blocks here.
+ 		 */
+-		mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group),
+-				bitmap_bh->b_data, ac->ac_b_ex.fe_start,
+-				ac->ac_b_ex.fe_len);
++		ext4_lock_group(sb, ac->ac_b_ex.fe_group);
++		mb_set_bits(bitmap_bh->b_data, ac->ac_b_ex.fe_start,
++			    ac->ac_b_ex.fe_len);
++		ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
+ 		err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+ 		if (!err)
+ 			err = -EAGAIN;
+ 		goto out_err;
+ 	}
++
++	ext4_lock_group(sb, ac->ac_b_ex.fe_group);
+ #ifdef AGGRESSIVE_CHECK
+ 	{
+ 		int i;
+@@ -3147,10 +3137,8 @@ ext4_mb_mark_diskspace_used(struct ext4_
+ 		}
+ 	}
+ #endif
+-	mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group), bitmap_bh->b_data,
+-				ac->ac_b_ex.fe_start, ac->ac_b_ex.fe_len);
++	mb_set_bits(bitmap_bh->b_data, ac->ac_b_ex.fe_start,ac->ac_b_ex.fe_len);
+ 
+-	spin_lock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group));
+ 	if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 		gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
+ 		gdp->bg_free_blocks_count =
+@@ -3160,15 +3148,16 @@ ext4_mb_mark_diskspace_used(struct ext4_
+ 	}
+ 	le16_add_cpu(&gdp->bg_free_blocks_count, -ac->ac_b_ex.fe_len);
+ 	gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp);
+-	spin_unlock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group));
++
++	ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
+ 	percpu_counter_sub(&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len);
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ext4_group_t flex_group = ext4_flex_group(sbi,
+ 							  ac->ac_b_ex.fe_group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_blocks -= ac->ac_b_ex.fe_len;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 
+ 	err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+@@ -3600,7 +3589,7 @@ int ext4_mb_check_ondisk_bitmap(struct s
+ /*
+  * the function goes through all preallocation in this group and marks them
+  * used in in-core bitmap. buddy must be generated from this bitmap
+- * Need to be called with ext4 group lock (ext4_lock_group)
++ * Need to be called with ext4 group lock held.
+  */
+ static int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+ 					ext4_group_t group)
+@@ -3646,8 +3635,7 @@ static int ext4_mb_generate_from_pa(stru
+ 			continue;
+ 		}
+ 		BUG_ON(groupnr != group);
+-		mb_set_bits(sb_bgl_lock(EXT4_SB(sb), group),
+-						bitmap, start, len);
++		mb_set_bits(bitmap, start, len);
+ 		preallocated += len;
+ 		count++;
+ 	}
+@@ -4901,6 +4889,13 @@ do_more:
+ 	if (err)
+ 		goto error_return;
+ 
++	if (ac) {
++		ac->ac_b_ex.fe_group = block_group;
++		ac->ac_b_ex.fe_start = bit;
++		ac->ac_b_ex.fe_len = count;
++		ext4_mb_store_history(ac);
++	}
++
+ 	err = ext4_mb_load_buddy(sb, block_group, &e4b);
+ 	if (err)
+ 		goto error_return;
+@@ -4912,42 +4907,31 @@ do_more:
+ 			BUG_ON(!mb_test_bit(bit + i, bitmap_bh->b_data));
+ 	}
+ #endif
+-	mb_clear_bits(sb_bgl_lock(sbi, block_group), bitmap_bh->b_data,
+-			bit, count);
+-
++	ext4_lock_group(sb, block_group);
++	mb_clear_bits(bitmap_bh->b_data, bit, count);
+ 	/* We dirtied the bitmap block */
+ 	BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
+ 	err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+ 
+-	if (ac) {
+-		ac->ac_b_ex.fe_group = block_group;
+-		ac->ac_b_ex.fe_start = bit;
+-		ac->ac_b_ex.fe_len = count;
+-		ext4_mb_store_history(ac);
+-	}
+-
+ 	if (metadata) {
+ 		/* blocks being freed are metadata. these blocks shouldn't
+ 		 * be used until this transaction is committed */
+ 		ext4_mb_free_metadata(handle, &e4b, block_group, bit, count);
+ 	} else {
+-		ext4_lock_group(sb, block_group);
+ 		mb_free_blocks(inode, &e4b, bit, count);
+ 		ext4_mb_return_to_preallocation(inode, &e4b, block, count);
+-		ext4_unlock_group(sb, block_group);
+ 	}
+ 
+-	spin_lock(sb_bgl_lock(sbi, block_group));
+ 	le16_add_cpu(&gdp->bg_free_blocks_count, count);
+ 	gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp);
+-	spin_unlock(sb_bgl_lock(sbi, block_group));
++	ext4_unlock_group(sb, block_group);
+ 	percpu_counter_add(&sbi->s_freeblocks_counter, count);
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_blocks += count;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 
+ 	ext4_mb_release_desc(&e4b);
+Index: linux-2.6.18-128.1.6/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/super.c
++++ linux-2.6.18-128.1.6/fs/ext4/super.c
+@@ -1934,16 +1934,18 @@ static int ext4_check_descriptors(struct
+ 			       "(block %llu)!", i, inode_table);
+ 			return 0;
+ 		}
+-		spin_lock(sb_bgl_lock(sbi, i));
++		ext4_lock_group(sb, i);
+ 		if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
+ 			printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
+ 			       "Checksum for group %lu failed (%u!=%u)\n",
+ 			       i, le16_to_cpu(ext4_group_desc_csum(sbi, i,
+ 			       gdp)), le16_to_cpu(gdp->bg_checksum));
+-			if (!(sb->s_flags & MS_RDONLY))
++			if (!(sb->s_flags & MS_RDONLY)) {
++				ext4_unlock_group(sb, i);
+ 				return 0;
++			}
+ 		}
+-		spin_unlock(sb_bgl_lock(sbi, i));
++		ext4_unlock_group(sb, i);
+ 		if (!flexbg_flag)
+ 			first_block += EXT4_BLOCKS_PER_GROUP(sb);
+ 	}
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4.h
+@@ -1303,6 +1303,33 @@ extern int ext4_get_blocks_wrap(handle_t
+ 			sector_t block, unsigned long max_blocks,
+ 			struct buffer_head *bh, int create,
+ 			int extend_disksize);
++
++static inline spinlock_t *ext4_group_lock_ptr(struct super_block *sb,
++					      ext4_group_t group)
++{
++	struct blockgroup_lock *bgl = &EXT4_SB(sb)->s_blockgroup_lock;
++	return &bgl->locks[group & (NR_BG_LOCKS-1)].lock;
++}
++
++static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group)
++{
++	spin_lock(ext4_group_lock_ptr(sb, group));
++}
++
++static inline void ext4_unlock_group(struct super_block *sb,
++					ext4_group_t group)
++{
++	spin_unlock(ext4_group_lock_ptr(sb, group));
++}
++
++static inline int ext4_is_group_locked(struct super_block *sb,
++					ext4_group_t group)
++{
++	return spin_is_locked(ext4_group_lock_ptr(sb, group));
++}
++
++
++
+ #endif	/* __KERNEL__ */
+ 
+ #endif	/* _EXT4_H */
+Index: linux-2.6.18-128.1.6/fs/ext4/mballoc.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/mballoc.h
++++ linux-2.6.18-128.1.6/fs/ext4/mballoc.h
+@@ -126,7 +126,6 @@ struct ext4_group_info {
+ };
+ 
+ #define EXT4_GROUP_INFO_NEED_INIT_BIT	0
+-#define EXT4_GROUP_INFO_LOCKED_BIT	1
+ 
+ #define EXT4_MB_GRP_NEED_INIT(grp)	\
+ 	(test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
+@@ -272,31 +271,6 @@ static void ext4_mb_put_pa(struct ext4_a
+ static int ext4_mb_init_per_dev_proc(struct super_block *sb);
+ static int ext4_mb_destroy_per_dev_proc(struct super_block *sb);
+ 
+-
+-static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group)
+-{
+-	struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
+-
+-	bit_spin_lock(EXT4_GROUP_INFO_LOCKED_BIT, &(grinfo->bb_state));
+-}
+-
+-static inline void ext4_unlock_group(struct super_block *sb,
+-					ext4_group_t group)
+-{
+-	struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
+-
+-	bit_spin_unlock(EXT4_GROUP_INFO_LOCKED_BIT, &(grinfo->bb_state));
+-}
+-
+-static inline int ext4_is_group_locked(struct super_block *sb,
+-					ext4_group_t group)
+-{
+-	struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
+-
+-	return bit_spin_is_locked(EXT4_GROUP_INFO_LOCKED_BIT,
+-						&(grinfo->bb_state));
+-}
+-
+ static ext4_fsblk_t ext4_grp_offs_to_block(struct super_block *sb,
+ 					struct ext4_free_extent *fex)
+ {
diff --git a/ldiskfs/kernel_patches/patches/ext4-convert-group-lock-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-convert-group-lock-sles11.patch
new file mode 100644
index 0000000..b7d08bf
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-convert-group-lock-sles11.patch
@@ -0,0 +1,509 @@
+Index: linux-stage/fs/ext4/balloc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/balloc.c
++++ linux-stage/fs/ext4/balloc.c
+@@ -329,16 +329,16 @@ ext4_read_block_bitmap(struct super_bloc
+ 		unlock_buffer(bh);
+ 		return bh;
+ 	}
+-	spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_lock_group(sb, block_group);
+ 	if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 		ext4_init_block_bitmap(sb, bh, block_group, desc);
+ 		set_bitmap_uptodate(bh);
+ 		set_buffer_uptodate(bh);
+-		spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++		ext4_unlock_group(sb, block_group);
+ 		unlock_buffer(bh);
+ 		return bh;
+ 	}
+-	spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_unlock_group(sb, block_group);
+ 	if (buffer_uptodate(bh)) {
+ 		/*
+ 		 * if not uninit if bh is uptodate,
+@@ -454,7 +454,7 @@ void ext4_add_groupblocks(handle_t *hand
+ 	down_write(&grp->alloc_sem);
+ 	for (i = 0, blocks_freed = 0; i < count; i++) {
+ 		BUFFER_TRACE(bitmap_bh, "clear bit");
+-		if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
++		if (!ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
+ 						bit + i, bitmap_bh->b_data)) {
+ 			ext4_error(sb, __func__,
+ 				   "bit already cleared for block %llu",
+@@ -464,18 +464,18 @@ void ext4_add_groupblocks(handle_t *hand
+ 			blocks_freed++;
+ 		}
+ 	}
+-	spin_lock(sb_bgl_lock(sbi, block_group));
++	ext4_lock_group(sb, block_group);
+ 	blk_free_count = blocks_freed + ext4_free_blks_count(sb, desc);
+ 	ext4_free_blks_set(sb, desc, blk_free_count);
+ 	desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc);
+-	spin_unlock(sb_bgl_lock(sbi, block_group));
++	ext4_unlock_group(sb, block_group);
+ 	percpu_counter_add(&sbi->s_freeblocks_counter, blocks_freed);
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_blocks += blocks_freed;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 	/*
+ 	 * request to reload the buddy with the
+Index: linux-stage/fs/ext4/ext4.h
+===================================================================
+--- linux-stage.orig/fs/ext4/ext4.h
++++ linux-stage/fs/ext4/ext4.h
+@@ -1342,33 +1342,32 @@ struct ext4_group_info {
+ };
+ 
+ #define EXT4_GROUP_INFO_NEED_INIT_BIT	0
+-#define EXT4_GROUP_INFO_LOCKED_BIT	1
+ 
+ #define EXT4_MB_GRP_NEED_INIT(grp)	\
+ 	(test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
+ 
+-static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group)
++static inline spinlock_t *ext4_group_lock_ptr(struct super_block *sb,
++					      ext4_group_t group)
+ {
+-	struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
++	struct blockgroup_lock *bgl = &EXT4_SB(sb)->s_blockgroup_lock;
++	return &bgl->locks[group & (NR_BG_LOCKS-1)].lock;
++}
+ 
+-	bit_spin_lock(EXT4_GROUP_INFO_LOCKED_BIT, &(grinfo->bb_state));
++static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group)
++{
++	spin_lock(ext4_group_lock_ptr(sb, group));
+ }
+ 
+ static inline void ext4_unlock_group(struct super_block *sb,
+ 					ext4_group_t group)
+ {
+-	struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
+-
+-	bit_spin_unlock(EXT4_GROUP_INFO_LOCKED_BIT, &(grinfo->bb_state));
++	spin_unlock(ext4_group_lock_ptr(sb, group));
+ }
+ 
+ static inline int ext4_is_group_locked(struct super_block *sb,
+ 					ext4_group_t group)
+ {
+-	struct ext4_group_info *grinfo = ext4_get_group_info(sb, group);
+-
+-	return bit_spin_is_locked(EXT4_GROUP_INFO_LOCKED_BIT,
+-						&(grinfo->bb_state));
++	return spin_is_locked(ext4_group_lock_ptr(sb, group));
+ }
+ 
+ /*
+Index: linux-stage/fs/ext4/ialloc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/ialloc.c
++++ linux-stage/fs/ext4/ialloc.c
+@@ -123,16 +123,16 @@ ext4_read_inode_bitmap(struct super_bloc
+ 		unlock_buffer(bh);
+ 		return bh;
+ 	}
+-	spin_lock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_lock_group(sb, block_group);
+ 	if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) {
+ 		ext4_init_inode_bitmap(sb, bh, block_group, desc);
+ 		set_bitmap_uptodate(bh);
+ 		set_buffer_uptodate(bh);
+-		spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++		ext4_unlock_group(sb, block_group);
+ 		unlock_buffer(bh);
+ 		return bh;
+ 	}
+-	spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group));
++	ext4_unlock_group(sb, block_group);
+ 	if (buffer_uptodate(bh)) {
+ 		/*
+ 		 * if not uninit if bh is uptodate,
+@@ -244,8 +244,8 @@ void ext4_free_inode(handle_t *handle, s
+ 		goto error_return;
+ 
+ 	/* Ok, now we can actually update the inode bitmaps.. */
+-	if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group),
+-					bit, bitmap_bh->b_data))
++	if (!ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
++		                   bit, bitmap_bh->b_data))
+ 		ext4_error(sb, "ext4_free_inode",
+ 			   "bit already cleared for inode %lu", ino);
+ 	else {
+@@ -256,7 +256,7 @@ void ext4_free_inode(handle_t *handle, s
+ 		if (fatal) goto error_return;
+ 
+ 		if (gdp) {
+-			spin_lock(sb_bgl_lock(sbi, block_group));
++			ext4_lock_group(sb, block_group);
+ 			count = ext4_free_inodes_count(sb, gdp) + 1;
+ 			ext4_free_inodes_set(sb, gdp, count);
+ 			if (is_directory) {
+@@ -265,16 +265,16 @@ void ext4_free_inode(handle_t *handle, s
+ 			}
+ 			gdp->bg_checksum = ext4_group_desc_csum(sbi,
+ 							block_group, gdp);
+-			spin_unlock(sb_bgl_lock(sbi, block_group));
++			ext4_unlock_group(sb, block_group);
+ 			percpu_counter_inc(&sbi->s_freeinodes_counter);
+ 			if (is_directory)
+ 				percpu_counter_dec(&sbi->s_dirs_counter);
+ 
+ 			if (sbi->s_log_groups_per_flex) {
+ 				flex_group = ext4_flex_group(sbi, block_group);
+-				spin_lock(sb_bgl_lock(sbi, flex_group));
++				ext4_lock_group(sb, flex_group);
+ 				sbi->s_flex_groups[flex_group].free_inodes++;
+-				spin_unlock(sb_bgl_lock(sbi, flex_group));
++				ext4_unlock_group(sb, flex_group);
+ 			}
+ 		}
+ 		BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
+@@ -595,10 +595,10 @@ static int find_group_other(struct super
+ 
+ /*
+  * claim the inode from the inode bitmap. If the group
+- * is uninit we need to take the groups's sb_bgl_lock
++ * is uninit we need to take the groups's ext4_group_lock
+  * and clear the uninit flag. The inode bitmap update
+  * and group desc uninit flag clear should be done
+- * after holding sb_bgl_lock so that ext4_read_inode_bitmap
++ * after holding ext4_group_lock so that ext4_read_inode_bitmap
+  * doesn't race with the ext4_claim_inode
+  */
+ static int ext4_claim_inode(struct super_block *sb,
+@@ -609,7 +609,7 @@ static int ext4_claim_inode(struct super
+ 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+ 	struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL);
+ 
+-	spin_lock(sb_bgl_lock(sbi, group));
++	ext4_lock_group(sb, group);
+ 	if (ext4_set_bit(ino, inode_bitmap_bh->b_data)) {
+ 		/* not a free inode */
+ 		retval = 1;
+@@ -618,7 +618,7 @@ static int ext4_claim_inode(struct super
+ 	ino++;
+ 	if ((group == 0 && ino < EXT4_FIRST_INO(sb)) ||
+ 			ino > EXT4_INODES_PER_GROUP(sb)) {
+-		spin_unlock(sb_bgl_lock(sbi, group));
++		ext4_unlock_group(sb, group);
+ 		ext4_error(sb, __func__,
+ 			   "reserved inode or inode > inodes count - "
+ 			   "block_group = %u, inode=%lu", group,
+@@ -662,7 +662,7 @@ static int ext4_claim_inode(struct super
+ 	}
+ 	gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp);
+ err_ret:
+-	spin_unlock(sb_bgl_lock(sbi, group));
++	ext4_unlock_group(sb, group);
+ 	return retval;
+ }
+ 
+@@ -854,7 +854,7 @@ got:
+ 		}
+ 
+ 		free = 0;
+-		spin_lock(sb_bgl_lock(sbi, group));
++		ext4_lock_group(sb, group);
+ 		/* recheck and clear flag under lock if we still need to */
+ 		if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 			free = ext4_free_blocks_after_init(sb, group, gdp);
+@@ -863,7 +863,7 @@ got:
+ 			gdp->bg_checksum = ext4_group_desc_csum(sbi, group,
+ 								gdp);
+ 		}
+-		spin_unlock(sb_bgl_lock(sbi, group));
++		ext4_unlock_group(sb, group);
+ 
+ 		/* Don't need to dirty bitmap block if we didn't change it */
+ 		if (free) {
+@@ -888,9 +888,9 @@ got:
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		flex_group = ext4_flex_group(sbi, group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_inodes--;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 
+ 	inode->i_uid = current_fsuid();
+Index: linux-stage/fs/ext4/mballoc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/mballoc.c
++++ linux-stage/fs/ext4/mballoc.c
+@@ -375,24 +375,12 @@ static inline void mb_set_bit(int bit, v
+ 	ext4_set_bit(bit, addr);
+ }
+ 
+-static inline void mb_set_bit_atomic(spinlock_t *lock, int bit, void *addr)
+-{
+-	addr = mb_correct_addr_and_bit(&bit, addr);
+-	ext4_set_bit_atomic(lock, bit, addr);
+-}
+-
+ static inline void mb_clear_bit(int bit, void *addr)
+ {
+ 	addr = mb_correct_addr_and_bit(&bit, addr);
+ 	ext4_clear_bit(bit, addr);
+ }
+ 
+-static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr)
+-{
+-	addr = mb_correct_addr_and_bit(&bit, addr);
+-	ext4_clear_bit_atomic(lock, bit, addr);
+-}
+-
+ static inline int mb_find_next_zero_bit(void *addr, int max, int start)
+ {
+ 	int fix = 0, ret, tmpmax;
+@@ -805,17 +793,17 @@ static int ext4_mb_init_cache(struct pag
+ 			unlock_buffer(bh[i]);
+ 			continue;
+ 		}
+-		spin_lock(sb_bgl_lock(EXT4_SB(sb), first_group + i));
++		ext4_lock_group(sb, first_group + i);
+ 		if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 			ext4_init_block_bitmap(sb, bh[i],
+ 						first_group + i, desc);
+ 			set_bitmap_uptodate(bh[i]);
+ 			set_buffer_uptodate(bh[i]);
+-			spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i));
++			ext4_unlock_group(sb, first_group + i);
+ 			unlock_buffer(bh[i]);
+ 			continue;
+ 		}
+-		spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i));
++		ext4_unlock_group(sb, first_group + i);
+ 		if (buffer_uptodate(bh[i])) {
+ 			/*
+ 			 * if not uninit if bh is uptodate,
+@@ -1087,7 +1075,7 @@ static int mb_find_order_for_block(struc
+ 	return 0;
+ }
+ 
+-static void mb_clear_bits(spinlock_t *lock, void *bm, int cur, int len)
++static void mb_clear_bits(void *bm, int cur, int len)
+ {
+ 	__u32 *addr;
+ 
+@@ -1100,15 +1088,12 @@ static void mb_clear_bits(spinlock_t *lo
+ 			cur += 32;
+ 			continue;
+ 		}
+-		if (lock)
+-			mb_clear_bit_atomic(lock, cur, bm);
+-		else
+-			mb_clear_bit(cur, bm);
++		mb_clear_bit(cur, bm);
+ 		cur++;
+ 	}
+ }
+ 
+-static void mb_set_bits(spinlock_t *lock, void *bm, int cur, int len)
++static void mb_set_bits(void *bm, int cur, int len)
+ {
+ 	__u32 *addr;
+ 
+@@ -1121,10 +1106,7 @@ static void mb_set_bits(spinlock_t *lock
+ 			cur += 32;
+ 			continue;
+ 		}
+-		if (lock)
+-			mb_set_bit_atomic(lock, cur, bm);
+-		else
+-			mb_set_bit(cur, bm);
++		mb_set_bit(cur, bm);
+ 		cur++;
+ 	}
+ }
+@@ -1339,8 +1321,7 @@ static int mb_mark_used(struct ext4_budd
+ 		e4b->bd_info->bb_counters[ord]++;
+ 	}
+ 
+-	mb_set_bits(sb_bgl_lock(EXT4_SB(e4b->bd_sb), ex->fe_group),
+-			EXT4_MB_BITMAP(e4b), ex->fe_start, len0);
++	mb_set_bits(EXT4_MB_BITMAP(e4b), ex->fe_start, len0);
+ 	mb_check_buddy(e4b);
+ 
+ 	return ret;
+@@ -2841,7 +2822,7 @@ int ext4_mb_init(struct super_block *sb,
+ 	return 0;
+ }
+ 
+-/* need to called with ext4 group lock (ext4_lock_group) */
++/* need to called with the ext4 group lock held */
+ static void ext4_mb_cleanup_pa(struct ext4_group_info *grp)
+ {
+ 	struct ext4_prealloc_space *pa;
+@@ -3240,14 +3221,17 @@ ext4_mb_mark_diskspace_used(struct ext4_
+ 		 * Fix the bitmap and repeat the block allocation
+ 		 * We leak some of the blocks here.
+ 		 */
+-		mb_set_bits(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group),
+-				bitmap_bh->b_data, ac->ac_b_ex.fe_start,
+-				ac->ac_b_ex.fe_len);
++		ext4_lock_group(sb, ac->ac_b_ex.fe_group);
++		mb_set_bits(bitmap_bh->b_data, ac->ac_b_ex.fe_start,
++			    ac->ac_b_ex.fe_len);
++		ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
+ 		err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+ 		if (!err)
+ 			err = -EAGAIN;
+ 		goto out_err;
+ 	}
++
++	ext4_lock_group(sb, ac->ac_b_ex.fe_group);
+ #ifdef AGGRESSIVE_CHECK
+ 	{
+ 		int i;
+@@ -3257,9 +3241,7 @@ ext4_mb_mark_diskspace_used(struct ext4_
+ 		}
+ 	}
+ #endif
+-	spin_lock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group));
+-	mb_set_bits(NULL, bitmap_bh->b_data,
+-				ac->ac_b_ex.fe_start, ac->ac_b_ex.fe_len);
++	mb_set_bits(bitmap_bh->b_data, ac->ac_b_ex.fe_start,ac->ac_b_ex.fe_len);
+ 	if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
+ 		gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT);
+ 		ext4_free_blks_set(sb, gdp,
+@@ -3269,7 +3251,8 @@ ext4_mb_mark_diskspace_used(struct ext4_
+ 	len = ext4_free_blks_count(sb, gdp) - ac->ac_b_ex.fe_len;
+ 	ext4_free_blks_set(sb, gdp, len);
+ 	gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp);
+-	spin_unlock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group));
++
++	ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
+ 	percpu_counter_sub(&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len);
+ 	/*
+ 	 * Now reduce the dirty block count also. Should not go negative
+@@ -3284,9 +3267,9 @@ ext4_mb_mark_diskspace_used(struct ext4_
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ext4_group_t flex_group = ext4_flex_group(sbi,
+ 							  ac->ac_b_ex.fe_group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_blocks -= ac->ac_b_ex.fe_len;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 
+ 	err = ext4_journal_dirty_metadata(handle, bitmap_bh);
+@@ -3686,7 +3669,7 @@ ext4_mb_use_preallocated(struct ext4_all
+  * the function goes through all block freed in the group
+  * but not yet committed and marks them used in in-core bitmap.
+  * buddy must be generated from this bitmap
+- * Need to be called with ext4 group lock (ext4_lock_group)
++ * Need to be called with the ext4 group lock held
+  */
+ static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap,
+ 						ext4_group_t group)
+@@ -3700,9 +3683,7 @@ static void ext4_mb_generate_from_freeli
+ 
+ 	while (n) {
+ 		entry = rb_entry(n, struct ext4_free_data, node);
+-		mb_set_bits(sb_bgl_lock(EXT4_SB(sb), group),
+-				bitmap, entry->start_blk,
+-				entry->count);
++		mb_set_bits(bitmap, entry->start_blk, entry->count);
+ 		n = rb_next(n);
+ 	}
+ 	return;
+@@ -3744,7 +3725,7 @@ int ext4_mb_check_ondisk_bitmap(struct s
+ /*
+  * the function goes through all preallocation in this group and marks them
+  * used in in-core bitmap. buddy must be generated from this bitmap
+- * Need to be called with ext4 group lock (ext4_lock_group)
++ * Need to be called with ext4 group lock held.
+  */
+ static int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+ 					ext4_group_t group)
+@@ -3790,8 +3771,7 @@ static int ext4_mb_generate_from_pa(stru
+ 			continue;
+ 		}
+ 		BUG_ON(groupnr != group);
+-		mb_set_bits(sb_bgl_lock(EXT4_SB(sb), group),
+-						bitmap, start, len);
++		mb_set_bits(bitmap, start, len);
+ 		preallocated += len;
+ 		count++;
+ 	}
+@@ -5124,36 +5104,32 @@ do_more:
+ 		new_entry->group  = block_group;
+ 		new_entry->count = count;
+ 		new_entry->t_tid = handle->h_transaction->t_tid;
++
+ 		ext4_lock_group(sb, block_group);
+-		mb_clear_bits(sb_bgl_lock(sbi, block_group), bitmap_bh->b_data,
+-				bit, count);
++		mb_clear_bits(bitmap_bh->b_data, bit, count);
+ 		ext4_mb_free_metadata(handle, &e4b, new_entry);
+-		ext4_unlock_group(sb, block_group);
+ 	} else {
+-		ext4_lock_group(sb, block_group);
+ 		/* need to update group_info->bb_free and bitmap
+ 		 * with group lock held. generate_buddy look at
+ 		 * them with group lock_held
+ 		 */
+-		mb_clear_bits(sb_bgl_lock(sbi, block_group), bitmap_bh->b_data,
+-				bit, count);
++		ext4_lock_group(sb, block_group);
++		mb_clear_bits(bitmap_bh->b_data, bit, count);
+ 		mb_free_blocks(inode, &e4b, bit, count);
+ 		ext4_mb_return_to_preallocation(inode, &e4b, block, count);
+-		ext4_unlock_group(sb, block_group);
+ 	}
+ 
+-	spin_lock(sb_bgl_lock(sbi, block_group));
+ 	ret = ext4_free_blks_count(sb, gdp) + count;
+ 	ext4_free_blks_set(sb, gdp, ret);
+ 	gdp->bg_checksum = ext4_group_desc_csum(sbi, block_group, gdp);
+-	spin_unlock(sb_bgl_lock(sbi, block_group));
++	ext4_unlock_group(sb, block_group);
+ 	percpu_counter_add(&sbi->s_freeblocks_counter, count);
+ 
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
+-		spin_lock(sb_bgl_lock(sbi, flex_group));
++		ext4_lock_group(sb, flex_group);
+ 		sbi->s_flex_groups[flex_group].free_blocks += count;
+-		spin_unlock(sb_bgl_lock(sbi, flex_group));
++		ext4_unlock_group(sb, flex_group);
+ 	}
+ 
+ 	ext4_mb_release_desc(&e4b);
+Index: linux-stage/fs/ext4/super.c
+===================================================================
+--- linux-stage.orig/fs/ext4/super.c
++++ linux-stage/fs/ext4/super.c
+@@ -2020,18 +2020,18 @@ static int ext4_check_descriptors(struct
+ 			       "(block %llu)!\n", i, inode_table);
+ 			return 0;
+ 		}
+-		spin_lock(sb_bgl_lock(sbi, i));
++		ext4_lock_group(sb, i);
+ 		if (!ext4_group_desc_csum_verify(sbi, i, gdp)) {
+ 			printk(KERN_ERR "EXT4-fs: ext4_check_descriptors: "
+ 			       "Checksum for group %u failed (%u!=%u)\n",
+ 			       i, le16_to_cpu(ext4_group_desc_csum(sbi, i,
+ 			       gdp)), le16_to_cpu(gdp->bg_checksum));
+ 			if (!(sb->s_flags & MS_RDONLY)) {
+-				spin_unlock(sb_bgl_lock(sbi, i));
++				ext4_unlock_group(sb, i);
+ 				return 0;
+ 			}
+ 		}
+-		spin_unlock(sb_bgl_lock(sbi, i));
++		ext4_unlock_group(sb, i);
+ 		if (!flexbg_flag)
+ 			first_block += EXT4_BLOCKS_PER_GROUP(sb);
+ 	}
diff --git a/ldiskfs/kernel_patches/patches/ext4-disable-delalloc-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-disable-delalloc-sles11.patch
new file mode 100644
index 0000000..c62b953
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-disable-delalloc-sles11.patch
@@ -0,0 +1,21 @@
+Disable the DELALLOC feature because it is not robust in ext4 versions < 2.6.31.
+
+--
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c	2009-06-15 05:36:44.000000000 -0400
++++ linux-2.6.27.21-0.1/fs/ext4/super.c	2009-06-15 05:40:38.000000000 -0400
+@@ -2462,13 +2462,6 @@ static int ext4_fill_super(struct super_
+ 			"extents feature not enabled on this filesystem, "
+ 			"use tune2fs.\n");
+ 
+-	/*
+-	 * enable delayed allocation by default
+-	 * Use -o nodelalloc to turn it off
+-	 */
+-	set_opt(sbi->s_mount_opt, DELALLOC);
+-
+-
+ 	if (!parse_options((char *) data, sb, &journal_inum, &journal_devnum,
+ 			   NULL, 0))
+ 		goto failed_mount;
diff --git a/ldiskfs/kernel_patches/patches/ext4-ext_generation-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-ext_generation-sles11.patch
new file mode 100644
index 0000000..742d0ab
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-ext_generation-sles11.patch
@@ -0,0 +1,48 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_extents.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h
+@@ -203,6 +203,11 @@ static inline unsigned short ext_depth(s
+ 	return le16_to_cpu(ext_inode_hdr(inode)->eh_depth);
+ }
+ 
++static inline void ext4_ext_tree_changed(struct inode *inode)
++{
++        EXT4_I(inode)->i_ext_generation++;
++}
++
+ static inline void
+ ext4_ext_invalidate_cache(struct inode *inode)
+ {
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_i.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_i.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_i.h
+@@ -114,6 +114,7 @@ struct ext4_inode_info {
+ 	struct inode vfs_inode;
+ 	struct jbd2_inode jinode;
+ 
++        unsigned long i_ext_generation;
+ 	struct ext4_ext_cache i_cached_extent;
+ 	/*
+ 	 * File creation time. Its function is same as that of
+Index: linux-2.6.27.21-0.1/fs/ext4/extents.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/extents.c
++++ linux-2.6.27.21-0.1/fs/ext4/extents.c
+@@ -1618,6 +1618,7 @@ cleanup:
+ 		ext4_ext_drop_refs(npath);
+ 		kfree(npath);
+ 	}
++	ext4_ext_tree_changed(inode);
+ 	ext4_ext_invalidate_cache(inode);
+ 	return err;
+ }
+@@ -2278,6 +2279,7 @@ static int ext4_ext_remove_space(struct 
+ 		}
+ 	}
+ out:
++	ext4_ext_tree_changed(inode);
+ 	ext4_ext_drop_refs(path);
+ 	kfree(path);
+ 	ext4_journal_stop(handle);
diff --git a/ldiskfs/kernel_patches/patches/ext4-fiemap-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-fiemap-2.6-rhel5.patch
new file mode 100644
index 0000000..b2f80d5
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-fiemap-2.6-rhel5.patch
@@ -0,0 +1,566 @@
+A large part of this code is from the generic VFS code in fs/ioctl.c in the
+upstream kernel.
+
+Index: linux-2.6.18.i386/fs/ext4/ioctl.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ioctl.c
++++ linux-2.6.18.i386/fs/ext4/ioctl.c
+@@ -17,6 +17,162 @@
+ #include "ext4_jbd2.h"
+ #include "ext4.h"
+ 
++#include "fiemap.h"
++
++/* So that the fiemap access checks can't overflow on 32 bit machines. */
++#define FIEMAP_MAX_EXTENTS     (UINT_MAX / sizeof(struct fiemap_extent))
++
++/**
++ * fiemap_fill_next_extent - Fiemap helper function
++ * @fieinfo:   Fiemap context passed into ->fiemap
++ * @logical:   Extent logical start offset, in bytes
++ * @phys:      Extent physical start offset, in bytes
++ * @len:       Extent length, in bytes
++ * @flags:     FIEMAP_EXTENT flags that describe this extent
++ * @lun:       LUN on which this extent resides
++ *
++ * Called from file system ->fiemap callback. Will populate extent
++ * info as passed in via arguments and copy to user memory. On
++ * success, extent count on fieinfo is incremented.
++ *
++ * Returns 0 on success, -errno on error, 1 if this was the last
++ * extent that will fit in user array.
++ */
++#define SET_UNKNOWN_FLAGS      (FIEMAP_EXTENT_DELALLOC)
++#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_ENCRYPTED	\
++				|FIEMAP_EXTENT_NET)
++#define SET_NO_UNMOUNTED_IO_FLAGS       (FIEMAP_EXTENT_DATA_ENCRYPTED)
++#define SET_NOT_ALIGNED_FLAGS  (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE)
++int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
++			    u64 phys, u64 len, u32 flags, dev_t dev)
++{
++	struct fiemap_extent extent = { 0 };
++	struct fiemap_extent *dest = fieinfo->fi_extents_start;
++
++	/* only count the extents */
++	if (fieinfo->fi_extents_max == 0) {
++		fieinfo->fi_extents_mapped++;
++		return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
++	}
++
++	if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max)
++		return 1;
++
++	if (flags & SET_UNKNOWN_FLAGS)
++		flags |= FIEMAP_EXTENT_UNKNOWN;
++	if (flags & SET_NO_DIRECT_FLAGS)
++		flags |= FIEMAP_EXTENT_NO_DIRECT;
++	if (flags & SET_NOT_ALIGNED_FLAGS)
++		flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++	if (flags & SET_NO_UNMOUNTED_IO_FLAGS)
++		flags |= FIEMAP_EXTENT_ENCODED;
++
++	extent.fe_logical = logical;
++	extent.fe_physical = phys;
++	extent.fe_length = len;
++	extent.fe_flags = flags;
++	extent.fe_device = new_encode_dev(dev);
++
++	dest += fieinfo->fi_extents_mapped;
++	if (copy_to_user(dest, &extent, sizeof(extent)))
++		return -EFAULT;
++
++	fieinfo->fi_extents_mapped++;
++	if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max)
++		return 1;
++
++	return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
++}
++
++static int fiemap_check_ranges(struct super_block *sb,
++			       u64 start, u64 len, u64 *new_len)
++{
++	*new_len = len;
++
++	if (len == 0)
++		return -EINVAL;
++
++	if (start > sb->s_maxbytes)
++		return -EFBIG;
++
++	/*
++	 * Shrink request scope to what the fs can actually handle.
++	 */
++	if ((len > sb->s_maxbytes) ||
++	    (sb->s_maxbytes - len) < start)
++		*new_len = sb->s_maxbytes - start;
++
++	return 0;
++}
++
++/*
++ * fiemap_check_flags - check validity of requested flags for fiemap
++ * @fieinfo:   Fiemap context passed into ->fiemap
++ * @fs_flags:  Set of fiemap flags that the file system understands
++ *
++ * Called from file system ->fiemap callback. This will compute the
++ * intersection of valid fiemap flags and those that the fs supports. That
++ * value is then compared against the user supplied flags. In case of bad user
++ * flags, the invalid values will be written into the fieinfo structure, and
++ * -EBADR is returned, which tells ioctl_fiemap() to return those values to
++ * userspace. For this reason, a return code of -EBADR should be preserved.
++ *
++ * Returns 0 on success, -EBADR on bad flags.
++ */
++int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags)
++{
++	u32 incompat_flags;
++
++	incompat_flags = fieinfo->fi_flags & ~(FIEMAP_FLAGS_COMPAT & fs_flags);
++	if (incompat_flags) {
++		fieinfo->fi_flags = incompat_flags;
++		return -EBADR;
++	}
++
++	return 0;
++}
++
++int ioctl_fiemap(struct inode *inode, struct file *filp, unsigned long arg)
++{
++	struct fiemap fiemap;
++	u64 len;
++	struct fiemap_extent_info fieinfo = {0, };
++	struct super_block *sb = inode->i_sb;
++	int error = 0;
++
++	if (copy_from_user(&fiemap, (struct fiemap __user *) arg,
++			   sizeof(struct fiemap)))
++		 return -EFAULT;
++
++	if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS)
++		return -EINVAL;
++
++	error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length,
++				    &len);
++	if (error)
++		return error;
++
++	fieinfo.fi_flags = fiemap.fm_flags;
++	fieinfo.fi_extents_max = fiemap.fm_extent_count;
++	fieinfo.fi_extents_start = (struct fiemap_extent *)(arg + sizeof(fiemap));
++
++	if (fiemap.fm_extent_count != 0 &&
++	    !access_ok(VERIFY_WRITE, (void *)arg,
++		       offsetof(typeof(fiemap), fm_extents[fiemap.fm_extent_count])))
++		return -EFAULT;
++
++	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
++		filemap_write_and_wait(inode->i_mapping);
++
++	error = ext4_fiemap(inode, &fieinfo, fiemap.fm_start, len);
++	fiemap.fm_flags = fieinfo.fi_flags;
++	fiemap.fm_mapped_extents = fieinfo.fi_extents_mapped;
++	if (copy_to_user((char *)arg, &fiemap, sizeof(fiemap)))
++		error = -EFAULT;
++
++	return error;
++}
++
+ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ 	struct inode *inode = filp->f_dentry->d_inode;
+@@ -257,6 +413,10 @@ flags_err:
+ 	case EXT4_IOC_MIGRATE:
+ 		return ext4_ext_migrate(inode, filp, cmd, arg);
+ 
++	case EXT4_IOC_FIEMAP: {
++		return ioctl_fiemap(inode, filp, arg);
++	}
++
+ 	default:
+ 		return -ENOTTY;
+ 	}
+Index: linux-2.6.18.i386/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4.h
++++ linux-2.6.18.i386/fs/ext4/ext4.h
+@@ -300,6 +300,7 @@ struct ext4_new_group_data {
+ #define EXT4_IOC_GETRSVSZ		_IOR('f', 5, long)
+ #define EXT4_IOC_SETRSVSZ		_IOW('f', 6, long)
+ #define EXT4_IOC_MIGRATE		_IO('f', 7)
++#define EXT4_IOC_FIEMAP			_IOWR('f', 11, struct fiemap)
+ 
+ /*
+  * ioctl commands in 32 bit emulation
+@@ -317,6 +318,8 @@ struct ext4_new_group_data {
+ #define EXT4_IOC32_GETVERSION_OLD	FS_IOC32_GETVERSION
+ #define EXT4_IOC32_SETVERSION_OLD	FS_IOC32_SETVERSION
+ 
++/* FIEMAP flags supported by ext4 */
++#define EXT4_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC)
+ 
+ /*
+  *  Mount options
+@@ -1115,6 +1118,9 @@ extern int ext4_page_mkwrite(struct vm_a
+ /* ioctl.c */
+ extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
+ extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
++struct fiemap_extent_info;
++extern int ext4_fiemap(struct inode *, struct fiemap_extent_info *, __u64,
++		       __u64);
+ 
+ /* migrate.c */
+ extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
+Index: linux-2.6.18.i386/fs/ext4/ext4_extents.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4_extents.h
++++ linux-2.6.18.i386/fs/ext4/ext4_extents.h
+@@ -128,6 +128,22 @@ struct ext4_ext_path {
+ #define EXT_MAX_BLOCK	0xffffffff
+ 
+ /*
++ * to be called by ext4_ext_walk_space()
++ * negative retcode - error
++ * positive retcode - signal for ext4_ext_walk_space(), see below
++ * callback must return valid extent (passed or newly created)
++ */
++typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
++				    struct ext4_ext_cache *,
++				    struct ext4_extent *, void *);
++
++#define HAVE_EXT_PREPARE_CB_EXTENT
++
++#define EXT_CONTINUE   0
++#define EXT_BREAK      1
++#define EXT_REPEAT     2
++
++/*
+  * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
+  * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
+  * MSB of ee_len field in the extent datastructure to signify if this
+@@ -223,6 +239,8 @@ extern int ext4_ext_try_to_merge(struct 
+ 				 struct ext4_extent *);
+ extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *);
+ extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
++extern int ext4_ext_walk_space(struct inode *, ext4_lblk_t, ext4_lblk_t,
++			       ext_prepare_callback, void *);
+ extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
+ 							struct ext4_ext_path *);
+ extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
+Index: linux-2.6.18.i386/fs/ext4/extents.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/extents.c
++++ linux-2.6.18.i386/fs/ext4/extents.c
+@@ -44,7 +44,7 @@
+ #include <asm/uaccess.h>
+ #include "ext4_jbd2.h"
+ #include "ext4_extents.h"
+-
++#include "fiemap.h"
+ 
+ /*
+  * ext_pblock:
+@@ -1597,6 +1597,113 @@ cleanup:
+ 	return err;
+ }
+ 
++int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block,
++			ext4_lblk_t num, ext_prepare_callback func,
++			void *cbdata)
++{
++	struct ext4_ext_path *path = NULL;
++	struct ext4_ext_cache cbex;
++	struct ext4_extent *ex;
++	ext4_lblk_t next, start = 0, end = 0;
++	ext4_lblk_t last = block + num;
++	int depth, exists, err = 0;
++
++	BUG_ON(func == NULL);
++	BUG_ON(inode == NULL);
++
++	while (block < last && block != EXT_MAX_BLOCK) {
++		num = last - block;
++		/* find extent for this block */
++		path = ext4_ext_find_extent(inode, block, path);
++		if (IS_ERR(path)) {
++			err = PTR_ERR(path);
++			path = NULL;
++			break;
++		}
++
++		depth = ext_depth(inode);
++		BUG_ON(path[depth].p_hdr == NULL);
++		ex = path[depth].p_ext;
++		next = ext4_ext_next_allocated_block(path);
++
++		exists = 0;
++		if (!ex) {
++			/* there is no extent yet, so try to allocate
++			 * all requested space */
++			start = block;
++			end = block + num;
++		} else if (le32_to_cpu(ex->ee_block) > block) {
++			/* need to allocate space before found extent */
++			start = block;
++			end = le32_to_cpu(ex->ee_block);
++			if (block + num < end)
++				end = block + num;
++		} else if (block >= le32_to_cpu(ex->ee_block)
++					+ ext4_ext_get_actual_len(ex)) {
++			/* need to allocate space after found extent */
++			start = block;
++			end = block + num;
++			if (end >= next)
++				end = next;
++		} else if (block >= le32_to_cpu(ex->ee_block)) {
++			/*
++			 * some part of requested space is covered
++			 * by found extent
++			 */
++			start = block;
++			end = le32_to_cpu(ex->ee_block)
++				+ ext4_ext_get_actual_len(ex);
++			if (block + num < end)
++				end = block + num;
++			exists = 1;
++		} else {
++			BUG();
++		}
++		BUG_ON(end <= start);
++
++		if (!exists) {
++			cbex.ec_block = start;
++			cbex.ec_len = end - start;
++			cbex.ec_start = 0;
++			cbex.ec_type = EXT4_EXT_CACHE_GAP;
++		} else {
++			cbex.ec_block = le32_to_cpu(ex->ee_block);
++			cbex.ec_len = ext4_ext_get_actual_len(ex);
++			cbex.ec_start = ext_pblock(ex);
++			cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
++		}
++
++		BUG_ON(cbex.ec_len == 0);
++		err = func(inode, path, &cbex, ex, cbdata);
++		ext4_ext_drop_refs(path);
++
++		if (err < 0)
++			break;
++
++		if (err == EXT_REPEAT)
++			continue;
++		else if (err == EXT_BREAK) {
++			err = 0;
++			break;
++		}
++
++		if (ext_depth(inode) != depth) {
++			/* depth was changed. we have to realloc path */
++			kfree(path);
++			path = NULL;
++		}
++
++		block = cbex.ec_block + cbex.ec_len;
++	}
++
++	if (path) {
++		ext4_ext_drop_refs(path);
++		kfree(path);
++	}
++
++	return err;
++}
++
+ static void
+ ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
+ 			__u32 len, ext4_fsblk_t start, int type)
+@@ -2953,3 +3060,100 @@ retry:
+ 	return ret > 0 ? ret2 : ret;
+ }
+ #endif
++
++/*
++ * Callback function called for each extent to gather FIEMAP information.
++ */
++int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
++		       struct ext4_ext_cache *newex, struct ext4_extent *ex,
++		       void *data)
++{
++	struct fiemap_extent_info *fieinfo = data;
++	unsigned long blksize_bits = inode->i_sb->s_blocksize_bits;
++	__u64   logical;
++	__u64   physical;
++	__u64   length;
++	__u32   flags = 0;
++	int     error;
++
++	logical =  (__u64)newex->ec_block << blksize_bits;
++
++	if (newex->ec_type == EXT4_EXT_CACHE_GAP) {
++		pgoff_t offset;
++		struct page *page;
++		struct buffer_head *bh = NULL;
++
++		offset = logical >> PAGE_SHIFT;
++		page = find_get_page(inode->i_mapping, offset);
++		if (!page || !page_has_buffers(page))
++			return EXT_CONTINUE;
++
++		bh = page_buffers(page);
++
++		if (!bh)
++			return EXT_CONTINUE;
++
++		if (buffer_delay(bh)) {
++			flags |= FIEMAP_EXTENT_DELALLOC;
++			page_cache_release(page);
++		} else {
++			page_cache_release(page);
++			return EXT_CONTINUE;
++		}
++	}
++
++	physical = (__u64)newex->ec_start << blksize_bits;
++	length =   (__u64)newex->ec_len << blksize_bits;
++
++	if (ex && ext4_ext_is_uninitialized(ex))
++		flags |= FIEMAP_EXTENT_UNWRITTEN;
++
++	/*
++	 * If this extent reaches EXT_MAX_BLOCK, it must be last.
++	 *
++	 * Or if ext4_ext_next_allocated_block is EXT_MAX_BLOCK,
++	 * this indicates no more allocated blocks.
++	 *
++	 * XXX this might miss a single-block extent at EXT_MAX_BLOCK
++	 */
++	if (logical + length - 1 == EXT_MAX_BLOCK ||
++	    ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
++		flags |= FIEMAP_EXTENT_LAST;
++
++	error = fiemap_fill_next_extent(fieinfo, logical, physical,
++					length, flags, inode->i_sb->s_dev);
++	if (error < 0)
++		return error;
++	if (error == 1)
++		return EXT_BREAK;
++
++	return EXT_CONTINUE;
++}
++
++int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
++		__u64 start, __u64 len)
++{
++	ext4_fsblk_t start_blk;
++	ext4_fsblk_t len_blks;
++	int error = 0;
++
++	if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))
++		return -EOPNOTSUPP;
++
++	if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS_COMPAT))
++		return -EBADR;
++
++	start_blk = start >> inode->i_sb->s_blocksize_bits;
++	len_blks = (len + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
++
++	/*
++	  * Walk the extent tree gathering extent information.
++	  * ext4_ext_fiemap_cb will push extents back to user.
++	  */
++	down_write(&EXT4_I(inode)->i_data_sem);
++	error = ext4_ext_walk_space(inode, start_blk, len_blks,
++				  ext4_ext_fiemap_cb, fieinfo);
++	up_write(&EXT4_I(inode)->i_data_sem);
++
++	return error;
++}
+Index: linux-2.6.18.i386/fs/ext4/fiemap.h
+===================================================================
+--- /dev/null
++++ linux-2.6.18.i386/fs/ext4/fiemap.h
+@@ -0,0 +1,85 @@
++/*
++ * FIEMAP ioctl infrastructure.
++ *
++ * Copyright 2008 Sun Microsystems, Inc
++ *
++ * Author: Kalpak Shah <kalpak.shah at sun.com>
++ *	 Andreas Dilger <adilger at sun.com>
++ */
++
++#ifndef _LINUX_EXT4_FIEMAP_H
++#define _LINUX_EXT4_FIEMAP_H
++
++struct fiemap_extent {
++	__u64 fe_logical;  /* logical offset in bytes for the start of
++			    * the extent from the beginning of the file */
++	__u64 fe_physical; /* physical offset in bytes for the start
++			    * of the extent from the beginning of the disk */
++	__u64 fe_length;   /* length in bytes for this extent */
++	__u64 fe_reserved64[2];
++	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
++	__u32 fe_device;   /* device number for this extent */
++	__u32 fe_reserved[2];
++};
++
++struct fiemap {
++	__u64 fm_start;	 /* logical offset (inclusive) at
++				 * which to start mapping (in) */
++	__u64 fm_length;	/* logical length of mapping which
++				 * userspace wants (in) */
++	__u32 fm_flags;	 /* FIEMAP_FLAG_* flags for request (in/out) */
++	__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
++	__u32 fm_extent_count;  /* size of fm_extents array (in) */
++	__u32 fm_reserved;
++	struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
++};
++
++/*
++ * FIEMAP helper definition.
++ */
++struct fiemap_extent_info {
++	unsigned int    fi_flags;		/* Flags as passed from user */
++	unsigned int    fi_extents_mapped;	/* Number of mapped extents */
++	unsigned int    fi_extents_max;		/* Size of fiemap_extent array*/
++	struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent array */
++};
++
++int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
++int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
++			    u64 phys, u64 len, u32 flags, u32 lun);
++
++#define	FIEMAP_MAX_OFFSET	(~0ULL)
++
++#define	FIEMAP_FLAG_SYNC	0x00000001 /* sync file data before map */
++#define	FIEMAP_FLAG_XATTR	0x00000002 /* map extended attribute tree */
++
++/* ldiskfs only supports FLAG_SYNC flag currently */
++#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
++
++#define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */
++#define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */
++#define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending.
++						    * Sets EXTENT_UNKNOWN. */
++#define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
++						    * while fs is unmounted */
++#define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
++						    * Sets EXTENT_NO_DIRECT. */
++#define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
++						    * block aligned. */
++#define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
++						    * Sets EXTENT_NOT_ALIGNED.*/
++#define FIEMAP_EXTENT_DATA_TAIL		0x00000400 /* Multiple files in block.
++						    * Sets EXTENT_NOT_ALIGNED.*/
++#define FIEMAP_EXTENT_UNWRITTEN		0x00000800 /* Space allocated, but
++						    * no data (i.e. zero). */
++#define FIEMAP_EXTENT_MERGED		0x00001000 /* File does not natively
++						    * support extents. Result
++						    * merged for efficiency. */
++
++/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
++#define FIEMAP_EXTENT_NO_DIRECT		0x40000000 /* Data mapping undefined */
++#define FIEMAP_EXTENT_NET		0x80000000 /* Data stored remotely.
++						    * Sets NO_DIRECT flag */
++
++#endif /* _LINUX_EXT4_FIEMAP_H */
++
diff --git a/ldiskfs/kernel_patches/patches/ext4-fiemap-2.6-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-fiemap-2.6-sles11.patch
new file mode 100644
index 0000000..149019a
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-fiemap-2.6-sles11.patch
@@ -0,0 +1,568 @@
+A large part of this code is from the generic VFS code in fs/ioctl.c in the
+upstream kernel.
+
+Index: linux-2.6.27.21-0.1/fs/ext4/ioctl.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ioctl.c
++++ linux-2.6.27.21-0.1/fs/ext4/ioctl.c
+@@ -18,6 +18,162 @@
+ #include "ext4_jbd2.h"
+ #include "ext4.h"
+ 
++#include "fiemap.h"
++
++/* So that the fiemap access checks can't overflow on 32 bit machines. */
++#define FIEMAP_MAX_EXTENTS     (UINT_MAX / sizeof(struct fiemap_extent))
++
++/**
++ * fiemap_fill_next_extent - Fiemap helper function
++ * @fieinfo:   Fiemap context passed into ->fiemap
++ * @logical:   Extent logical start offset, in bytes
++ * @phys:      Extent physical start offset, in bytes
++ * @len:       Extent length, in bytes
++ * @flags:     FIEMAP_EXTENT flags that describe this extent
++ * @lun:       LUN on which this extent resides
++ *
++ * Called from file system ->fiemap callback. Will populate extent
++ * info as passed in via arguments and copy to user memory. On
++ * success, extent count on fieinfo is incremented.
++ *
++ * Returns 0 on success, -errno on error, 1 if this was the last
++ * extent that will fit in user array.
++ */
++#define SET_UNKNOWN_FLAGS      (FIEMAP_EXTENT_DELALLOC)
++#define SET_NO_DIRECT_FLAGS    (FIEMAP_EXTENT_DATA_ENCRYPTED	\
++				|FIEMAP_EXTENT_NET)
++#define SET_NO_UNMOUNTED_IO_FLAGS       (FIEMAP_EXTENT_DATA_ENCRYPTED)
++#define SET_NOT_ALIGNED_FLAGS  (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE)
++int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
++			    u64 phys, u64 len, u32 flags, dev_t dev)
++{
++	struct fiemap_extent extent = { 0 };
++	struct fiemap_extent *dest = fieinfo->fi_extents_start;
++
++	/* only count the extents */
++	if (fieinfo->fi_extents_max == 0) {
++		fieinfo->fi_extents_mapped++;
++		return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
++	}
++
++	if (fieinfo->fi_extents_mapped >= fieinfo->fi_extents_max)
++		return 1;
++
++	if (flags & SET_UNKNOWN_FLAGS)
++		flags |= FIEMAP_EXTENT_UNKNOWN;
++	if (flags & SET_NO_DIRECT_FLAGS)
++		flags |= FIEMAP_EXTENT_NO_DIRECT;
++	if (flags & SET_NOT_ALIGNED_FLAGS)
++		flags |= FIEMAP_EXTENT_NOT_ALIGNED;
++	if (flags & SET_NO_UNMOUNTED_IO_FLAGS)
++		flags |= FIEMAP_EXTENT_ENCODED;
++
++	extent.fe_logical = logical;
++	extent.fe_physical = phys;
++	extent.fe_length = len;
++	extent.fe_flags = flags;
++	extent.fe_device = new_encode_dev(dev);
++
++	dest += fieinfo->fi_extents_mapped;
++	if (copy_to_user(dest, &extent, sizeof(extent)))
++		return -EFAULT;
++
++	fieinfo->fi_extents_mapped++;
++	if (fieinfo->fi_extents_mapped == fieinfo->fi_extents_max)
++		return 1;
++
++	return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
++}
++
++static int fiemap_check_ranges(struct super_block *sb,
++			       u64 start, u64 len, u64 *new_len)
++{
++	*new_len = len;
++
++	if (len == 0)
++		return -EINVAL;
++
++	if (start > sb->s_maxbytes)
++		return -EFBIG;
++
++	/*
++	 * Shrink request scope to what the fs can actually handle.
++	 */
++	if ((len > sb->s_maxbytes) ||
++	    (sb->s_maxbytes - len) < start)
++		*new_len = sb->s_maxbytes - start;
++
++	return 0;
++}
++
++/*
++ * fiemap_check_flags - check validity of requested flags for fiemap
++ * @fieinfo:   Fiemap context passed into ->fiemap
++ * @fs_flags:  Set of fiemap flags that the file system understands
++ *
++ * Called from file system ->fiemap callback. This will compute the
++ * intersection of valid fiemap flags and those that the fs supports. That
++ * value is then compared against the user supplied flags. In case of bad user
++ * flags, the invalid values will be written into the fieinfo structure, and
++ * -EBADR is returned, which tells ioctl_fiemap() to return those values to
++ * userspace. For this reason, a return code of -EBADR should be preserved.
++ *
++ * Returns 0 on success, -EBADR on bad flags.
++ */
++int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags)
++{
++	u32 incompat_flags;
++
++	incompat_flags = fieinfo->fi_flags & ~(FIEMAP_FLAGS_COMPAT & fs_flags);
++	if (incompat_flags) {
++		fieinfo->fi_flags = incompat_flags;
++		return -EBADR;
++	}
++
++	return 0;
++}
++
++int ioctl_fiemap(struct inode *inode, struct file *filp, unsigned long arg)
++{
++	struct fiemap fiemap;
++	u64 len;
++	struct fiemap_extent_info fieinfo = {0, };
++	struct super_block *sb = inode->i_sb;
++	int error = 0;
++
++	if (copy_from_user(&fiemap, (struct fiemap __user *) arg,
++			   sizeof(struct fiemap)))
++		 return -EFAULT;
++
++	if (fiemap.fm_extent_count > FIEMAP_MAX_EXTENTS)
++		return -EINVAL;
++
++	error = fiemap_check_ranges(sb, fiemap.fm_start, fiemap.fm_length,
++				    &len);
++	if (error)
++		return error;
++
++	fieinfo.fi_flags = fiemap.fm_flags;
++	fieinfo.fi_extents_max = fiemap.fm_extent_count;
++	fieinfo.fi_extents_start = (struct fiemap_extent *)(arg + sizeof(fiemap));
++
++	if (fiemap.fm_extent_count != 0 &&
++	    !access_ok(VERIFY_WRITE, (void *)arg,
++		       offsetof(typeof(fiemap), fm_extents[fiemap.fm_extent_count])))
++		return -EFAULT;
++
++	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
++		filemap_write_and_wait(inode->i_mapping);
++
++	error = ext4_fiemap(inode, &fieinfo, fiemap.fm_start, len);
++	fiemap.fm_flags = fieinfo.fi_flags;
++	fiemap.fm_mapped_extents = fieinfo.fi_extents_mapped;
++	if (copy_to_user((char *)arg, &fiemap, sizeof(fiemap)))
++		error = -EFAULT;
++
++	return error;
++}
++
+ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+ {
+ 	struct inode *inode = filp->f_dentry->d_inode;
+@@ -263,6 +419,10 @@ setversion_out:
+ 		return err;
+ 	}
+ 
++	case EXT4_IOC_FIEMAP: {
++		return ioctl_fiemap(inode, filp, arg);
++	}
++
+ 	default:
+ 		return -ENOTTY;
+ 	}
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4.h
+@@ -302,7 +302,8 @@ struct ext4_new_group_data {
+ #define EXT4_IOC_GROUP_EXTEND		_IOW('f', 7, unsigned long)
+ #define EXT4_IOC_GROUP_ADD		_IOW('f', 8, struct ext4_new_group_input)
+ #define EXT4_IOC_MIGRATE		_IO('f', 9)
+- /* note ioctl 11 reserved for filesystem-independent FIEMAP ioctl */
++#define EXT4_IOC_FIEMAP			_IOWR('f', 11, struct fiemap)
++
+ 
+ /*
+  * ioctl commands in 32 bit emulation
+@@ -320,6 +321,8 @@ struct ext4_new_group_data {
+ #define EXT4_IOC32_GETVERSION_OLD	FS_IOC32_GETVERSION
+ #define EXT4_IOC32_SETVERSION_OLD	FS_IOC32_SETVERSION
+ 
++/* FIEMAP flags supported by ext4 */
++#define EXT4_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC)
+ 
+ /*
+  *  Mount options
+@@ -1130,6 +1133,9 @@ extern int ext4_page_mkwrite(struct vm_a
+ /* ioctl.c */
+ extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
+ extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
++struct fiemap_extent_info;
++extern int ext4_fiemap(struct inode *, struct fiemap_extent_info *, __u64,
++		       __u64);
+ 
+ /* migrate.c */
+ extern int ext4_ext_migrate(struct inode *);
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_extents.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h
+@@ -128,6 +128,22 @@ struct ext4_ext_path {
+ #define EXT_MAX_BLOCK	0xffffffff
+ 
+ /*
++ * to be called by ext4_ext_walk_space()
++ * negative retcode - error
++ * positive retcode - signal for ext4_ext_walk_space(), see below
++ * callback must return valid extent (passed or newly created)
++ */
++typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
++				    struct ext4_ext_cache *,
++				    struct ext4_extent *, void *);
++
++#define HAVE_EXT_PREPARE_CB_EXTENT
++
++#define EXT_CONTINUE   0
++#define EXT_BREAK      1
++#define EXT_REPEAT     2
++
++/*
+  * EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an
+  * initialized extent. This is 2^15 and not (2^16 - 1), since we use the
+  * MSB of ee_len field in the extent datastructure to signify if this
+@@ -219,6 +235,8 @@ extern int ext4_ext_try_to_merge(struct 
+ 				 struct ext4_extent *);
+ extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *);
+ extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
++extern int ext4_ext_walk_space(struct inode *, ext4_lblk_t, ext4_lblk_t,
++			       ext_prepare_callback, void *);
+ extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
+ 							struct ext4_ext_path *);
+ extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
+Index: linux-2.6.27.21-0.1/fs/ext4/extents.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/extents.c
++++ linux-2.6.27.21-0.1/fs/ext4/extents.c
+@@ -42,7 +42,7 @@
+ #include <asm/uaccess.h>
+ #include "ext4_jbd2.h"
+ #include "ext4_extents.h"
+-
++#include "fiemap.h"
+ 
+ /*
+  * ext_pblock:
+@@ -1622,6 +1622,113 @@ cleanup:
+ 	return err;
+ }
+ 
++int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block,
++			ext4_lblk_t num, ext_prepare_callback func,
++			void *cbdata)
++{
++	struct ext4_ext_path *path = NULL;
++	struct ext4_ext_cache cbex;
++	struct ext4_extent *ex;
++	ext4_lblk_t next, start = 0, end = 0;
++	ext4_lblk_t last = block + num;
++	int depth, exists, err = 0;
++
++	BUG_ON(func == NULL);
++	BUG_ON(inode == NULL);
++
++	while (block < last && block != EXT_MAX_BLOCK) {
++		num = last - block;
++		/* find extent for this block */
++		path = ext4_ext_find_extent(inode, block, path);
++		if (IS_ERR(path)) {
++			err = PTR_ERR(path);
++			path = NULL;
++			break;
++		}
++
++		depth = ext_depth(inode);
++		BUG_ON(path[depth].p_hdr == NULL);
++		ex = path[depth].p_ext;
++		next = ext4_ext_next_allocated_block(path);
++
++		exists = 0;
++		if (!ex) {
++			/* there is no extent yet, so try to allocate
++			 * all requested space */
++			start = block;
++			end = block + num;
++		} else if (le32_to_cpu(ex->ee_block) > block) {
++			/* need to allocate space before found extent */
++			start = block;
++			end = le32_to_cpu(ex->ee_block);
++			if (block + num < end)
++				end = block + num;
++		} else if (block >= le32_to_cpu(ex->ee_block)
++					+ ext4_ext_get_actual_len(ex)) {
++			/* need to allocate space after found extent */
++			start = block;
++			end = block + num;
++			if (end >= next)
++				end = next;
++		} else if (block >= le32_to_cpu(ex->ee_block)) {
++			/*
++			 * some part of requested space is covered
++			 * by found extent
++			 */
++			start = block;
++			end = le32_to_cpu(ex->ee_block)
++				+ ext4_ext_get_actual_len(ex);
++			if (block + num < end)
++				end = block + num;
++			exists = 1;
++		} else {
++			BUG();
++		}
++		BUG_ON(end <= start);
++
++		if (!exists) {
++			cbex.ec_block = start;
++			cbex.ec_len = end - start;
++			cbex.ec_start = 0;
++			cbex.ec_type = EXT4_EXT_CACHE_GAP;
++		} else {
++			cbex.ec_block = le32_to_cpu(ex->ee_block);
++			cbex.ec_len = ext4_ext_get_actual_len(ex);
++			cbex.ec_start = ext_pblock(ex);
++			cbex.ec_type = EXT4_EXT_CACHE_EXTENT;
++		}
++
++		BUG_ON(cbex.ec_len == 0);
++		err = func(inode, path, &cbex, ex, cbdata);
++		ext4_ext_drop_refs(path);
++
++		if (err < 0)
++			break;
++
++		if (err == EXT_REPEAT)
++			continue;
++		else if (err == EXT_BREAK) {
++			err = 0;
++			break;
++		}
++
++		if (ext_depth(inode) != depth) {
++			/* depth was changed. we have to realloc path */
++			kfree(path);
++			path = NULL;
++		}
++
++		block = cbex.ec_block + cbex.ec_len;
++	}
++
++	if (path) {
++		ext4_ext_drop_refs(path);
++		kfree(path);
++	}
++
++	return err;
++}
++
+ static void
+ ext4_ext_put_in_cache(struct inode *inode, ext4_lblk_t block,
+ 			__u32 len, ext4_fsblk_t start, int type)
+@@ -2966,3 +3073,100 @@ retry:
+ 	mutex_unlock(&inode->i_mutex);
+ 	return ret > 0 ? ret2 : ret;
+ }
++
++/*
++ * Callback function called for each extent to gather FIEMAP information.
++ */
++int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
++		       struct ext4_ext_cache *newex, struct ext4_extent *ex,
++		       void *data)
++{
++	struct fiemap_extent_info *fieinfo = data;
++	unsigned long blksize_bits = inode->i_sb->s_blocksize_bits;
++	__u64   logical;
++	__u64   physical;
++	__u64   length;
++	__u32   flags = 0;
++	int     error;
++
++	logical =  (__u64)newex->ec_block << blksize_bits;
++
++	if (newex->ec_type == EXT4_EXT_CACHE_GAP) {
++		pgoff_t offset;
++		struct page *page;
++		struct buffer_head *bh = NULL;
++
++		offset = logical >> PAGE_SHIFT;
++		page = find_get_page(inode->i_mapping, offset);
++		if (!page || !page_has_buffers(page))
++			return EXT_CONTINUE;
++
++		bh = page_buffers(page);
++
++		if (!bh)
++			return EXT_CONTINUE;
++
++		if (buffer_delay(bh)) {
++			flags |= FIEMAP_EXTENT_DELALLOC;
++			page_cache_release(page);
++		} else {
++			page_cache_release(page);
++			return EXT_CONTINUE;
++		}
++	}
++
++	physical = (__u64)newex->ec_start << blksize_bits;
++	length =   (__u64)newex->ec_len << blksize_bits;
++
++	if (ex && ext4_ext_is_uninitialized(ex))
++		flags |= FIEMAP_EXTENT_UNWRITTEN;
++
++	/*
++	 * If this extent reaches EXT_MAX_BLOCK, it must be last.
++	 *
++	 * Or if ext4_ext_next_allocated_block is EXT_MAX_BLOCK,
++	 * this indicates no more allocated blocks.
++	 *
++	 * XXX this might miss a single-block extent at EXT_MAX_BLOCK
++	 */
++	if (logical + length - 1 == EXT_MAX_BLOCK ||
++	    ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
++		flags |= FIEMAP_EXTENT_LAST;
++
++	error = fiemap_fill_next_extent(fieinfo, logical, physical,
++					length, flags, inode->i_sb->s_dev);
++	if (error < 0)
++		return error;
++	if (error == 1)
++		return EXT_BREAK;
++
++	return EXT_CONTINUE;
++}
++
++int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
++		__u64 start, __u64 len)
++{
++	ext4_fsblk_t start_blk;
++	ext4_fsblk_t len_blks;
++	int error = 0;
++
++	if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))
++		return -EOPNOTSUPP;
++
++	if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS_COMPAT))
++		return -EBADR;
++
++	start_blk = start >> inode->i_sb->s_blocksize_bits;
++	len_blks = (len + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
++
++	/*
++	 * Walk the extent tree gathering extent information.
++	 * ext4_ext_fiemap_cb will push extents back to user.
++	 */
++	down_write(&EXT4_I(inode)->i_data_sem);
++	error = ext4_ext_walk_space(inode, start_blk, len_blks,
++				  ext4_ext_fiemap_cb, fieinfo);
++	up_write(&EXT4_I(inode)->i_data_sem);
++
++	return error;
++}
+Index: linux-2.6.27.21-0.1/fs/ext4/fiemap.h
+===================================================================
+--- /dev/null
++++ linux-2.6.27.21-0.1/fs/ext4/fiemap.h
+@@ -0,0 +1,85 @@
++/*
++ * FIEMAP ioctl infrastructure.
++ *
++ * Copyright 2008 Sun Microsystems, Inc
++ *
++ * Author: Kalpak Shah <kalpak.shah at sun.com>
++ *	 Andreas Dilger <adilger at sun.com>
++ */
++
++#ifndef _LINUX_EXT4_FIEMAP_H
++#define _LINUX_EXT4_FIEMAP_H
++
++struct fiemap_extent {
++	__u64 fe_logical;  /* logical offset in bytes for the start of
++			    * the extent from the beginning of the file */
++	__u64 fe_physical; /* physical offset in bytes for the start
++			    * of the extent from the beginning of the disk */
++	__u64 fe_length;   /* length in bytes for this extent */
++	__u64 fe_reserved64[2];
++	__u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
++	__u32 fe_device;   /* device number for this extent */
++	__u32 fe_reserved[2];
++};
++
++struct fiemap {
++	__u64 fm_start;	 /* logical offset (inclusive) at
++				 * which to start mapping (in) */
++	__u64 fm_length;	/* logical length of mapping which
++				 * userspace wants (in) */
++	__u32 fm_flags;	 /* FIEMAP_FLAG_* flags for request (in/out) */
++	__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
++	__u32 fm_extent_count;  /* size of fm_extents array (in) */
++	__u32 fm_reserved;
++	struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
++};
++
++/*
++ * FIEMAP helper definition.
++ */
++struct fiemap_extent_info {
++	unsigned int    fi_flags;		/* Flags as passed from user */
++	unsigned int    fi_extents_mapped;	/* Number of mapped extents */
++	unsigned int    fi_extents_max;		/* Size of fiemap_extent array*/
++	struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent array */
++};
++
++int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
++int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
++			    u64 phys, u64 len, u32 flags, u32 lun);
++
++#define	FIEMAP_MAX_OFFSET	(~0ULL)
++
++#define	FIEMAP_FLAG_SYNC	0x00000001 /* sync file data before map */
++#define	FIEMAP_FLAG_XATTR	0x00000002 /* map extended attribute tree */
++
++/* ldiskfs only supports FLAG_SYNC flag currently */
++#define FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR)
++
++#define FIEMAP_EXTENT_LAST		0x00000001 /* Last extent in file. */
++#define FIEMAP_EXTENT_UNKNOWN		0x00000002 /* Data location unknown. */
++#define FIEMAP_EXTENT_DELALLOC		0x00000004 /* Location still pending.
++						    * Sets EXTENT_UNKNOWN. */
++#define FIEMAP_EXTENT_ENCODED		0x00000008 /* Data can not be read
++						    * while fs is unmounted */
++#define FIEMAP_EXTENT_DATA_ENCRYPTED	0x00000080 /* Data is encrypted by fs.
++						    * Sets EXTENT_NO_DIRECT. */
++#define FIEMAP_EXTENT_NOT_ALIGNED	0x00000100 /* Extent offsets may not be
++						    * block aligned. */
++#define FIEMAP_EXTENT_DATA_INLINE	0x00000200 /* Data mixed with metadata.
++						    * Sets EXTENT_NOT_ALIGNED.*/
++#define FIEMAP_EXTENT_DATA_TAIL		0x00000400 /* Multiple files in block.
++						    * Sets EXTENT_NOT_ALIGNED.*/
++#define FIEMAP_EXTENT_UNWRITTEN		0x00000800 /* Space allocated, but
++						    * no data (i.e. zero). */
++#define FIEMAP_EXTENT_MERGED		0x00001000 /* File does not natively
++						    * support extents. Result
++						    * merged for efficiency. */
++
++/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
++#define FIEMAP_EXTENT_NO_DIRECT		0x40000000 /* Data mapping undefined */
++#define FIEMAP_EXTENT_NET		0x80000000 /* Data stored remotely.
++						    * Sets NO_DIRECT flag */
++
++#endif /* _LINUX_EXT4_FIEMAP_H */
++
diff --git a/ldiskfs/kernel_patches/patches/ext4-filterdata-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-filterdata-rhel5.patch
new file mode 100644
index 0000000..25ea28a
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-filterdata-rhel5.patch
@@ -0,0 +1,25 @@
+Index: linux-2.6.18.i386/fs/ext4/ext4_i.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4_i.h
++++ linux-2.6.18.i386/fs/ext4/ext4_i.h
+@@ -162,6 +162,8 @@ struct ext4_inode_info {
+ 	/* mballoc */
+ 	struct list_head i_prealloc_list;
+ 	spinlock_t i_prealloc_lock;
++
++	void *i_filterdata;
+ };
+ 
+ #endif	/* _EXT4_I */
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -574,6 +574,7 @@ static struct inode *ext4_alloc_inode(st
+ 	memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache));
+ 	INIT_LIST_HEAD(&ei->i_prealloc_list);
+ 	spin_lock_init(&ei->i_prealloc_lock);
++	ei->i_filterdata = NULL;
+ 	return &ei->vfs_inode;
+ }
+ 
diff --git a/ldiskfs/kernel_patches/patches/ext4-filterdata-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-filterdata-sles11.patch
new file mode 100644
index 0000000..ea83bcd
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-filterdata-sles11.patch
@@ -0,0 +1,25 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_i.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_i.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_i.h
+@@ -135,6 +135,8 @@ struct ext4_inode_info {
+ 	__u16 i_extra_isize;
+ 
+ 	spinlock_t i_block_reservation_lock;
++
++	void *i_filterdata;
+ };
+ 
+ #endif	/* _EXT4_I */
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -624,6 +624,7 @@ static struct inode *ext4_alloc_inode(st
+ 	memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache));
+ 	INIT_LIST_HEAD(&ei->i_prealloc_list);
+ 	spin_lock_init(&ei->i_prealloc_lock);
++	ei->i_filterdata = NULL;
+ 	jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode);
+ 	ei->i_reserved_data_blocks = 0;
+ 	ei->i_reserved_meta_blocks = 0;
diff --git a/ldiskfs/kernel_patches/patches/ext4-force_over_8tb-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-force_over_8tb-rhel5.patch
new file mode 100644
index 0000000..6529fbc
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-force_over_8tb-rhel5.patch
@@ -0,0 +1,57 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/super.c
++++ linux-2.6.18-128.1.6/fs/ext4/super.c
+@@ -47,6 +47,8 @@
+ #include "namei.h"
+ #include "group.h"
+ 
++static int force_over_8tb;
++
+ static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
+ 			     unsigned long journal_devnum);
+ static int ext4_create_journal(struct super_block *, struct ext4_super_block *,
+@@ -1227,6 +1229,7 @@ enum {
+ 	Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
+ 	Opt_mballoc, Opt_nomballoc, Opt_stripe,
+ 	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv, Opt_bigendian_extents,
++	Opt_force_over_8tb,
+ };
+ 
+ static match_table_t tokens = {
+@@ -1289,6 +1292,7 @@ static match_table_t tokens = {
+ 	{Opt_stripe, "stripe=%u"},
+ 	{Opt_resize, "resize"},
+ 	{Opt_bigendian_extents, "bigendian_extents"},
++	{Opt_force_over_8tb, "force_over_8tb"},
+ 	{Opt_err, NULL},
+ };
+ 
+@@ -1690,6 +1694,9 @@ clear_qf_name:
+ 		case Opt_bigendian_extents:
+ 			bigendian_extents = 1;
+ 			break;
++		case Opt_force_over_8tb:
++			force_over_8tb = 1;
++			break;
+ 		default:
+ 			printk(KERN_ERR
+ 			       "EXT4-fs: Unrecognized mount option \"%s\" "
+@@ -2534,6 +2541,17 @@ static int ext4_fill_super(struct super_
+ 		goto failed_mount;
+ 	}
+ 
++	if (ext4_blocks_count(es) >
++	    ((0x80000000000ULL >> sb->s_blocksize_bits) - 1)) {
++		if (force_over_8tb == 0) {
++			printk(KERN_ERR "EXT4-fs does not support filesystems "
++			       "greater than 8TB and can cause data corruption."
++			       "Use \"force_over_8tb\" mount option to override."
++			       "\n");
++			goto failed_mount;
++		}
++	}
++
+ 	if (EXT4_BLOCKS_PER_GROUP(sb) == 0)
+ 		goto cantfind_ext4;
+ 
diff --git a/ldiskfs/kernel_patches/patches/ext4-force_over_8tb-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-force_over_8tb-sles11.patch
new file mode 100644
index 0000000..1e15050
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-force_over_8tb-sles11.patch
@@ -0,0 +1,58 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -52,6 +52,8 @@
+ 
+ struct proc_dir_entry *ext4_proc_root;
+ 
++static int force_over_8tb;
++
+ static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
+ 			     unsigned long journal_devnum);
+ static int ext4_create_journal(struct super_block *, struct ext4_super_block *,
+@@ -1295,7 +1297,7 @@ enum {
+ 	Opt_stripe, Opt_delalloc, Opt_nodelalloc,
+ 	Opt_inode_readahead_blks, Opt_bigendian_extents,
+ 	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
+-	Opt_mballoc
++	Opt_mballoc, Opt_force_over_8tb
+ };
+ 
+ static match_table_t tokens = {
+@@ -1358,6 +1360,7 @@ static match_table_t tokens = {
+ 	{Opt_inode_readahead_blks, "inode_readahead_blks=%u"},
+ 	{Opt_bigendian_extents, "bigendian_extents"},
+ 	{Opt_mballoc, "mballoc"},
++	{Opt_force_over_8tb, "force_over_8tb"},
+ 	{Opt_err, NULL},
+ };
+ 
+@@ -1778,6 +1781,9 @@ set_qf_format:
+ 			break;
+ 		case Opt_mballoc:
+ 			break;
++		case Opt_force_over_8tb:
++			force_over_8tb = 1;
++			break;
+ 		default:
+ 			printk(KERN_ERR
+ 			       "EXT4-fs: Unrecognized mount option \"%s\" "
+@@ -2639,6 +2645,17 @@ static int ext4_fill_super(struct super_
+ 		goto failed_mount;
+ 	}
+ 
++	if (ext4_blocks_count(es) >
++	    ((0x80000000000ULL >> sb->s_blocksize_bits) - 1)) {
++		if (force_over_8tb == 0) {
++			printk(KERN_ERR "EXT4-fs does not support filesystems "
++			       "greater than 8TB and can cause data corruption."
++			       "Use \"force_over_8tb\" mount option to override."
++			       "\n");
++			goto failed_mount;
++		}
++	}
++
+ 	if (EXT4_BLOCKS_PER_GROUP(sb) == 0)
+ 		goto cantfind_ext4;
+ 
diff --git a/ldiskfs/kernel_patches/patches/ext4-ialloc-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-ialloc-2.6-rhel5.patch
new file mode 100644
index 0000000..7361a24
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-ialloc-2.6-rhel5.patch
@@ -0,0 +1,129 @@
+Index: linux-2.6.18.i386/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ialloc.c
++++ linux-2.6.18.i386/fs/ext4/ialloc.c
+@@ -509,12 +509,16 @@ fallback:
+ }
+ 
+ static int find_group_other(struct super_block *sb, struct inode *parent,
+-				ext4_group_t *group)
++			    ext4_group_t *group, int mode)
+ {
++	struct ext4_sb_info *sbi = EXT4_SB(sb);
+ 	ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
+-	ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
++	ext4_group_t ngroups = sbi->s_groups_count;
+ 	struct ext4_group_desc *desc;
+ 	ext4_group_t i;
++	int best_group = -1;
++	ext4_fsblk_t avefreeb, freeb;
++	int best_group_freeb = 0;
+ 
+ 	/*
+ 	 * Try to place the inode in its parent directory
+@@ -522,8 +526,10 @@ static int find_group_other(struct super
+ 	*group = parent_group;
+ 	desc = ext4_get_group_desc(sb, *group, NULL);
+ 	if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
+-			le16_to_cpu(desc->bg_free_blocks_count))
++	    (!S_ISREG(mode) || le16_to_cpu(desc->bg_free_blocks_count)))
+ 		return 0;
++	avefreeb = ext4_free_blocks_count(sbi->s_es);
++	do_div(avefreeb, ngroups);
+ 
+ 	/*
+ 	 * We're going to place this inode in a different blockgroup from its
+@@ -537,33 +543,49 @@ static int find_group_other(struct super
+ 	*group = (*group + parent->i_ino) % ngroups;
+ 
+ 	/*
+-	 * Use a quadratic hash to find a group with a free inode and some free
+-	 * blocks.
++	 * Use a quadratic hash to find a group with a free inode and
++	 * average number of free blocks.
+ 	 */
+ 	for (i = 1; i < ngroups; i <<= 1) {
+ 		*group += i;
+ 		if (*group >= ngroups)
+ 			*group -= ngroups;
+ 		desc = ext4_get_group_desc(sb, *group, NULL);
+-		if (desc && le16_to_cpu(desc->bg_free_inodes_count) &&
+-				le16_to_cpu(desc->bg_free_blocks_count))
++		if (!desc || !desc->bg_free_inodes_count)
++			continue;
++		if (!S_ISREG(mode))
++			return 0;
++		if (le16_to_cpu(desc->bg_free_blocks_count) >= avefreeb)
+ 			return 0;
+ 	}
+ 
+ 	/*
+-	 * That failed: try linear search for a free inode, even if that group
+-	 * has no free blocks.
++	 * That failed: start from last group used to allocate inode
++	 * try linear search for a free inode and prefereably
++	 * free blocks.
+ 	 */
+-	*group = parent_group;
++	*group = sbi->s_last_alloc_group;
++	if (*group == -1)
++		*group = parent_group;
++
+ 	for (i = 0; i < ngroups; i++) {
+ 		if (++*group >= ngroups)
+ 			*group = 0;
+ 		desc = ext4_get_group_desc(sb, *group, NULL);
+-		if (desc && le16_to_cpu(desc->bg_free_inodes_count))
+-			return 0;
++		if (!desc || !desc->bg_free_inodes_count)
++			continue;
++		freeb = le16_to_cpu(desc->bg_free_blocks_count);
++		if (freeb > best_group_freeb) {
++			best_group_freeb = freeb;
++			best_group = *group;
++			if (freeb >= avefreeb || !S_ISREG(mode))
++				break;
++		}
+ 	}
+ 
+-	return -1;
++	sbi->s_last_alloc_group = best_group;
++	*group = best_group;
++	return 0;
+ }
+ 
+ /*
+@@ -656,7 +678,7 @@ continue_allocation:
+ 		else
+ 			ret2 = find_group_orlov(sb, dir, &group);
+ 	} else
+-		ret2 = find_group_other(sb, dir, &group);
++		ret2 = find_group_other(sb, dir, &group, mode);
+ 
+ got_group:
+ 	err = -ENOSPC;
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -2190,6 +2190,7 @@ static int ext4_fill_super(struct super_
+ 
+ 	bgl_lock_init(&sbi->s_blockgroup_lock);
+ 
++	sbi->s_last_alloc_group = -1;
+ 	for (i = 0; i < db_count; i++) {
+ 		block = descriptor_loc(sb, logical_sb_block, i);
+ 		sbi->s_group_desc[i] = sb_bread(sb, block);
+Index: linux-2.6.18.i386/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4_sb.h
++++ linux-2.6.18.i386/fs/ext4/ext4_sb.h
+@@ -60,6 +60,8 @@ struct ext4_sb_info {
+ 	struct percpu_counter s_freeinodes_counter;
+ 	struct percpu_counter s_dirs_counter;
+ 	struct blockgroup_lock s_blockgroup_lock;
++	/* Last group used to allocate inode */
++	int s_last_alloc_group;
+ 
+ 	/* root of the per fs reservation window tree */
+ 	spinlock_t s_rsv_window_lock;
diff --git a/ldiskfs/kernel_patches/patches/ext4-ialloc-2.6-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-ialloc-2.6-sles11.patch
new file mode 100644
index 0000000..1423331
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-ialloc-2.6-sles11.patch
@@ -0,0 +1,129 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ialloc.c
++++ linux-2.6.27.21-0.1/fs/ext4/ialloc.c
+@@ -535,12 +535,16 @@ fallback:
+ }
+ 
+ static int find_group_other(struct super_block *sb, struct inode *parent,
+-				ext4_group_t *group)
++			    ext4_group_t *group, int mode)
+ {
++	struct ext4_sb_info *sbi = EXT4_SB(sb);
+ 	ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
+-	ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
++	ext4_group_t ngroups = sbi->s_groups_count;
+ 	struct ext4_group_desc *desc;
+ 	ext4_group_t i;
++	int best_group = -1;
++	ext4_fsblk_t avefreeb, freeb;
++	int best_group_freeb = 0;
+ 
+ 	/*
+ 	 * Try to place the inode in its parent directory
+@@ -548,8 +552,10 @@ static int find_group_other(struct super
+ 	*group = parent_group;
+ 	desc = ext4_get_group_desc(sb, *group, NULL);
+ 	if (desc && ext4_free_inodes_count(sb, desc) &&
+-			ext4_free_blks_count(sb, desc))
++	    (!S_ISREG(mode) || ext4_free_blks_count(sb, desc)))
+ 		return 0;
++	avefreeb = ext4_free_blocks_count(sbi->s_es);
++	do_div(avefreeb, ngroups);
+ 
+ 	/*
+ 	 * We're going to place this inode in a different blockgroup from its
+@@ -563,33 +569,49 @@ static int find_group_other(struct super
+ 	*group = (*group + parent->i_ino) % ngroups;
+ 
+ 	/*
+-	 * Use a quadratic hash to find a group with a free inode and some free
+-	 * blocks.
++	 * Use a quadratic hash to find a group with a free inode and
++	 * average number of free blocks.
+ 	 */
+ 	for (i = 1; i < ngroups; i <<= 1) {
+ 		*group += i;
+ 		if (*group >= ngroups)
+ 			*group -= ngroups;
+ 		desc = ext4_get_group_desc(sb, *group, NULL);
+-		if (desc && ext4_free_inodes_count(sb, desc) &&
+-				ext4_free_blks_count(sb, desc))
++		if (!desc || ext4_free_inodes_count(sb, desc))
++			continue;
++		if (!S_ISREG(mode))
++			return 0;
++		if (ext4_free_blks_count(sb, desc) >= avefreeb)
+ 			return 0;
+ 	}
+ 
+ 	/*
+-	 * That failed: try linear search for a free inode, even if that group
+-	 * has no free blocks.
++	 * That failed: start from last group used to allocate inode
++	 * try linear search for a free inode and prefereably
++	 * free blocks.
+ 	 */
+-	*group = parent_group;
++	*group = sbi->s_last_alloc_group;
++	if (*group == -1)
++		*group = parent_group;
++
+ 	for (i = 0; i < ngroups; i++) {
+ 		if (++*group >= ngroups)
+ 			*group = 0;
+ 		desc = ext4_get_group_desc(sb, *group, NULL);
+-		if (desc && ext4_free_inodes_count(sb, desc))
+-			return 0;
++		if (!desc || ext4_free_inodes_count(sb, desc))
++			continue;
++		freeb = ext4_free_blks_count(sb, desc);
++		if (freeb > best_group_freeb) {
++			best_group_freeb = freeb;
++			best_group = *group;
++			if (freeb >= avefreeb || !S_ISREG(mode))
++				break;
++		}
+ 	}
+ 
+-	return -1;
++	sbi->s_last_alloc_group = best_group;
++	*group = best_group;
++	return 0;
+ }
+ 
+ /*
+@@ -755,7 +777,7 @@ continue_allocation:
+ 		else
+ 			ret2 = find_group_orlov(sb, dir, &group);
+ 	} else
+-		ret2 = find_group_other(sb, dir, &group);
++		ret2 = find_group_other(sb, dir, &group, mode);
+ 
+ got_group:
+ 	err = -ENOSPC;
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -2300,6 +2300,7 @@ static int ext4_fill_super(struct super_
+ 
+ 	bgl_lock_init(&sbi->s_blockgroup_lock);
+ 
++	sbi->s_last_alloc_group = -1;
+ 	for (i = 0; i < db_count; i++) {
+ 		block = descriptor_loc(sb, logical_sb_block, i);
+ 		sbi->s_group_desc[i] = sb_bread(sb, block);
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_sb.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h
+@@ -64,6 +64,8 @@ struct ext4_sb_info {
+ 	struct percpu_counter s_dirtyblocks_counter;
+ 	struct blockgroup_lock s_blockgroup_lock;
+ 	struct proc_dir_entry *s_proc;
++	/* Last group used to allocate inode */
++	ext4_group_t s_last_alloc_group;
+ 
+ 	/* root of the per fs reservation window tree */
+ 	spinlock_t s_rsv_window_lock;
diff --git a/ldiskfs/kernel_patches/patches/ext4-include-fixes-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-include-fixes-2.6-rhel5.patch
new file mode 100644
index 0000000..0009eaa
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-include-fixes-2.6-rhel5.patch
@@ -0,0 +1,20 @@
+Index: linux-2.6.18.i386/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4.h
++++ linux-2.6.18.i386/fs/ext4/ext4.h
+@@ -541,12 +541,13 @@ do {									       \
+ #define EXT4_MOUNT_IOPEN		0x8000000 /* Allow access via iopen */
+ #define EXT4_MOUNT_IOPEN_NOPRIV		0x10000000 /* Make iopen world-readable */
+ /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
+-#ifndef _LINUX_EXT2_FS_H
++#ifndef clear_opt
+ #define clear_opt(o, opt)		o &= ~EXT4_MOUNT_##opt
+ #define set_opt(o, opt)			o |= EXT4_MOUNT_##opt
+ #define test_opt(sb, opt)		(EXT4_SB(sb)->s_mount_opt & \
+ 					 EXT4_MOUNT_##opt)
+-#else
++#endif
++#ifndef EXT2_MOUNT_NOLOAD
+ #define EXT2_MOUNT_NOLOAD		EXT4_MOUNT_NOLOAD
+ #define EXT2_MOUNT_ABORT		EXT4_MOUNT_ABORT
+ #define EXT2_MOUNT_DATA_FLAGS		EXT4_MOUNT_DATA_FLAGS
diff --git a/ldiskfs/kernel_patches/patches/ext4-include-fixes-2.6-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-include-fixes-2.6-sles11.patch
new file mode 100644
index 0000000..0009eaa
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-include-fixes-2.6-sles11.patch
@@ -0,0 +1,20 @@
+Index: linux-2.6.18.i386/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4.h
++++ linux-2.6.18.i386/fs/ext4/ext4.h
+@@ -541,12 +541,13 @@ do {									       \
+ #define EXT4_MOUNT_IOPEN		0x8000000 /* Allow access via iopen */
+ #define EXT4_MOUNT_IOPEN_NOPRIV		0x10000000 /* Make iopen world-readable */
+ /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
+-#ifndef _LINUX_EXT2_FS_H
++#ifndef clear_opt
+ #define clear_opt(o, opt)		o &= ~EXT4_MOUNT_##opt
+ #define set_opt(o, opt)			o |= EXT4_MOUNT_##opt
+ #define test_opt(sb, opt)		(EXT4_SB(sb)->s_mount_opt & \
+ 					 EXT4_MOUNT_##opt)
+-#else
++#endif
++#ifndef EXT2_MOUNT_NOLOAD
+ #define EXT2_MOUNT_NOLOAD		EXT4_MOUNT_NOLOAD
+ #define EXT2_MOUNT_ABORT		EXT4_MOUNT_ABORT
+ #define EXT2_MOUNT_DATA_FLAGS		EXT4_MOUNT_DATA_FLAGS
diff --git a/ldiskfs/kernel_patches/patches/ext4-inode-version-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-inode-version-rhel5.patch
new file mode 100644
index 0000000..d8a31ad
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-inode-version-rhel5.patch
@@ -0,0 +1,105 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/inode.c
++++ linux-2.6.18-128.1.6/fs/ext4/inode.c
+@@ -2850,11 +2850,11 @@ struct inode *ext4_iget(struct super_blo
+ 	EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
+ 	EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
+ 
+-	inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
++	ei->i_fs_version = le32_to_cpu(raw_inode->i_disk_version);
+ 	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
+ 		if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
+-			inode->i_version |=
+-			(__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
++			ei->i_fs_version |= (__u64)(le32_to_cpu(raw_inode->i_version_hi))
++									 << 32;
+ 	}
+ 
+ 	if (S_ISREG(inode->i_mode)) {
+@@ -3043,16 +3043,11 @@ static int ext4_do_update_inode(handle_t
+ 	} else for (block = 0; block < EXT4_N_BLOCKS; block++)
+ 		raw_inode->i_block[block] = ei->i_data[block];
+ 
+-	raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
++	raw_inode->i_disk_version = cpu_to_le32(ei->i_fs_version);
+ 	if (ei->i_extra_isize) {
+ 		if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
+-			/* in RHEL5 i_version is an unsigned long */
+-#if BITS_PER_LONG == 64
+-			raw_inode->i_version_hi =
+-			cpu_to_le32(inode->i_version >> 32);
+-#else
+-			raw_inode->i_version_hi = 0;
+-#endif
++			raw_inode->i_version_hi = cpu_to_le32(ei->i_fs_version
++							      >> 32);
+ 		raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
+ 	}
+ 
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4_i.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4_i.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4_i.h
+@@ -21,6 +21,8 @@
+ #include <linux/seqlock.h>
+ #include <linux/mutex.h>
+ 
++#define HAVE_DISK_INODE_VERSION
++
+ /* data type for block offset of block group */
+ typedef int ext4_grpblk_t;
+ 
+@@ -164,6 +166,8 @@ struct ext4_inode_info {
+ 	spinlock_t i_prealloc_lock;
+ 
+ 	void *i_filterdata;
++
++	__u64 i_fs_version;
+ };
+ 
+ #endif	/* _EXT4_I */
+Index: linux-2.6.18-128.1.6/fs/ext4/xattr.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/xattr.c
++++ linux-2.6.18-128.1.6/fs/ext4/xattr.c
+@@ -959,13 +959,18 @@ ext4_xattr_set_handle(handle_t *handle, 
+ 	struct ext4_xattr_block_find bs = {
+ 		.s = { .not_found = -ENODATA, },
+ 	};
++	unsigned long no_expand;
+ 	int error;
+ 
+ 	if (!name)
+ 		return -EINVAL;
+ 	if (strlen(name) > 255)
+ 		return -ERANGE;
++
+ 	down_write(&EXT4_I(inode)->xattr_sem);
++	no_expand = EXT4_I(inode)->i_state & EXT4_STATE_NO_EXPAND;
++	EXT4_I(inode)->i_state |= EXT4_STATE_NO_EXPAND;
++
+ 	error = ext4_get_inode_loc(inode, &is.iloc);
+ 	if (error)
+ 		goto cleanup;
+@@ -1042,6 +1047,8 @@ ext4_xattr_set_handle(handle_t *handle, 
+ cleanup:
+ 	brelse(is.iloc.bh);
+ 	brelse(bs.bh);
++	if (no_expand == 0)
++		EXT4_I(inode)->i_state &= ~EXT4_STATE_NO_EXPAND;
+ 	up_write(&EXT4_I(inode)->xattr_sem);
+ 	return error;
+ }
+Index: linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ialloc.c
++++ linux-2.6.18-128.1.6/fs/ext4/ialloc.c
+@@ -878,6 +878,7 @@ got:
+ 	ei->i_dtime = 0;
+ 	ei->i_block_alloc_info = NULL;
+ 	ei->i_block_group = group;
++	ei->i_fs_version = 0;
+ 
+ 	ext4_set_inode_flags(inode);
+ 	if (IS_DIRSYNC(inode))
diff --git a/ldiskfs/kernel_patches/patches/ext4-lock-cached_extent.patch b/ldiskfs/kernel_patches/patches/ext4-lock-cached_extent.patch
new file mode 100644
index 0000000..1751057
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-lock-cached_extent.patch
@@ -0,0 +1,53 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/extents.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/extents.c	2009-06-19 15:50:57.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/extents.c	2009-06-19 15:56:32.000000000 +0530
+@@ -1736,11 +1736,13 @@
+ {
+ 	struct ext4_ext_cache *cex;
+ 	BUG_ON(len == 0);
++	spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
+ 	cex = &EXT4_I(inode)->i_cached_extent;
+ 	cex->ec_type = type;
+ 	cex->ec_block = block;
+ 	cex->ec_len = len;
+ 	cex->ec_start = start;
++	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+ }
+ 
+ /*
+@@ -1797,12 +1799,17 @@
+ 			struct ext4_extent *ex)
+ {
+ 	struct ext4_ext_cache *cex;
++	int ret = EXT4_EXT_CACHE_NO;
+ 
++	/*
++	 * We borrow i_block_reservation_lock to protect i_cached_extent
++	 */
++	spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
+ 	cex = &EXT4_I(inode)->i_cached_extent;
+ 
+ 	/* has cache valid data? */
+ 	if (cex->ec_type == EXT4_EXT_CACHE_NO)
+-		return EXT4_EXT_CACHE_NO;
++		goto errout;
+ 
+ 	BUG_ON(cex->ec_type != EXT4_EXT_CACHE_GAP &&
+ 			cex->ec_type != EXT4_EXT_CACHE_EXTENT);
+@@ -1813,11 +1820,12 @@
+ 		ext_debug("%u cached by %u:%u:%llu\n",
+ 				block,
+ 				cex->ec_block, cex->ec_len, cex->ec_start);
+-		return cex->ec_type;
++		ret = cex->ec_type;
+ 	}
+ 
+-	/* not in cache */
+-	return EXT4_EXT_CACHE_NO;
++errout:
++	spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
++	return ret;
+ }
+ 
+ /*
diff --git a/ldiskfs/kernel_patches/patches/ext4-lookup-dotdot-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-lookup-dotdot-rhel5.patch
new file mode 100644
index 0000000..af019fa
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-lookup-dotdot-rhel5.patch
@@ -0,0 +1,63 @@
+Index: linux-2.6.18.i386/fs/ext4/iopen.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/iopen.c
++++ linux-2.6.18.i386/fs/ext4/iopen.c
+@@ -91,9 +91,12 @@ static struct dentry *iopen_lookup(struc
+ 		assert(!(alternate->d_flags & DCACHE_DISCONNECTED));
+ 	}
+ 
+-	if (!list_empty(&inode->i_dentry)) {
+-		alternate = list_entry(inode->i_dentry.next,
+-				       struct dentry, d_alias);
++	list_for_each(lp, &inode->i_dentry) {
++		alternate = list_entry(lp, struct dentry, d_alias);
++		/* ignore dentries created for ".." to preserve
++		 * proper dcache hierarchy -- bug 10458 */
++		if (alternate->d_flags & DCACHE_NFSFS_RENAMED)
++			continue;
+ 		dget_locked(alternate);
+ 		spin_lock(&alternate->d_lock);
+ 		alternate->d_flags |= DCACHE_REFERENCED;
+Index: linux-2.6.18.i386/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/namei.c
++++ linux-2.6.18.i386/fs/ext4/namei.c
+@@ -1067,6 +1067,38 @@ static struct dentry *ext4_lookup(struct
+ 			return ERR_CAST(inode);
+ 	}
+ 
++	/* ".." shouldn't go into dcache to preserve dcache hierarchy
++	 * otherwise we'll get parent being a child of actual child.
++	 * see bug 10458 for details -bzzz */
++	if (inode && (dentry->d_name.name[0] == '.' && (dentry->d_name.len == 1 ||
++		(dentry->d_name.len == 2 && dentry->d_name.name[1] == '.')))) {
++		struct dentry *tmp, *goal = NULL;
++		struct list_head *lp;
++
++		/* first, look for an existing dentry - any one is good */
++		spin_lock(&dcache_lock);
++		list_for_each(lp, &inode->i_dentry) {
++			tmp = list_entry(lp, struct dentry, d_alias);
++			goal = tmp;
++			dget_locked(goal);
++			break;
++		}
++		if (goal == NULL) {
++			/* there is no alias, we need to make current dentry:
++			 *  a) inaccessible for __d_lookup()
++			 *  b) inaccessible for iopen */
++			J_ASSERT(list_empty(&dentry->d_alias));
++			dentry->d_flags |= DCACHE_NFSFS_RENAMED;
++			/* this is d_instantiate() ... */
++			list_add(&dentry->d_alias, &inode->i_dentry);
++			dentry->d_inode = inode;
++		}
++		spin_unlock(&dcache_lock);
++		if (goal)
++			iput(inode);
++		return goal;
++	}
++
+ 	return iopen_connect_dentry(dentry, inode, 1);
+ }
+ 
diff --git a/ldiskfs/kernel_patches/patches/ext4-lookup-dotdot-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-lookup-dotdot-sles11.patch
new file mode 100644
index 0000000..af019fa
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-lookup-dotdot-sles11.patch
@@ -0,0 +1,63 @@
+Index: linux-2.6.18.i386/fs/ext4/iopen.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/iopen.c
++++ linux-2.6.18.i386/fs/ext4/iopen.c
+@@ -91,9 +91,12 @@ static struct dentry *iopen_lookup(struc
+ 		assert(!(alternate->d_flags & DCACHE_DISCONNECTED));
+ 	}
+ 
+-	if (!list_empty(&inode->i_dentry)) {
+-		alternate = list_entry(inode->i_dentry.next,
+-				       struct dentry, d_alias);
++	list_for_each(lp, &inode->i_dentry) {
++		alternate = list_entry(lp, struct dentry, d_alias);
++		/* ignore dentries created for ".." to preserve
++		 * proper dcache hierarchy -- bug 10458 */
++		if (alternate->d_flags & DCACHE_NFSFS_RENAMED)
++			continue;
+ 		dget_locked(alternate);
+ 		spin_lock(&alternate->d_lock);
+ 		alternate->d_flags |= DCACHE_REFERENCED;
+Index: linux-2.6.18.i386/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/namei.c
++++ linux-2.6.18.i386/fs/ext4/namei.c
+@@ -1067,6 +1067,38 @@ static struct dentry *ext4_lookup(struct
+ 			return ERR_CAST(inode);
+ 	}
+ 
++	/* ".." shouldn't go into dcache to preserve dcache hierarchy
++	 * otherwise we'll get parent being a child of actual child.
++	 * see bug 10458 for details -bzzz */
++	if (inode && (dentry->d_name.name[0] == '.' && (dentry->d_name.len == 1 ||
++		(dentry->d_name.len == 2 && dentry->d_name.name[1] == '.')))) {
++		struct dentry *tmp, *goal = NULL;
++		struct list_head *lp;
++
++		/* first, look for an existing dentry - any one is good */
++		spin_lock(&dcache_lock);
++		list_for_each(lp, &inode->i_dentry) {
++			tmp = list_entry(lp, struct dentry, d_alias);
++			goal = tmp;
++			dget_locked(goal);
++			break;
++		}
++		if (goal == NULL) {
++			/* there is no alias, we need to make current dentry:
++			 *  a) inaccessible for __d_lookup()
++			 *  b) inaccessible for iopen */
++			J_ASSERT(list_empty(&dentry->d_alias));
++			dentry->d_flags |= DCACHE_NFSFS_RENAMED;
++			/* this is d_instantiate() ... */
++			list_add(&dentry->d_alias, &inode->i_dentry);
++			dentry->d_inode = inode;
++		}
++		spin_unlock(&dcache_lock);
++		if (goal)
++			iput(inode);
++		return goal;
++	}
++
+ 	return iopen_connect_dentry(dentry, inode, 1);
+ }
+ 
diff --git a/ldiskfs/kernel_patches/patches/ext4-lustre-i_version.patch b/ldiskfs/kernel_patches/patches/ext4-lustre-i_version.patch
new file mode 100644
index 0000000..c78c2e0
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-lustre-i_version.patch
@@ -0,0 +1,66 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_i.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_i.h	2009-06-15 06:23:34.000000000 -0400
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_i.h	2009-06-15 17:09:59.000000000 -0400
+@@ -36,6 +36,8 @@ typedef unsigned int ext4_group_t;
+ #define rsv_start rsv_window._rsv_start
+ #define rsv_end rsv_window._rsv_end
+ 
++#define USE_I_FS_VERSION
++
+ /*
+  * storage for cached extent
+  */
+@@ -138,6 +140,8 @@ struct ext4_inode_info {
+ 	spinlock_t i_block_reservation_lock;
+ 
+ 	void *i_filterdata;
++
++	__u64 i_fs_version;
+ };
+ 
+ #endif	/* _EXT4_I */
+Index: linux-2.6.27.21-0.1/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ialloc.c	2009-06-15 06:23:34.000000000 -0400
++++ linux-2.6.27.21-0.1/fs/ext4/ialloc.c	2009-06-15 16:59:35.000000000 -0400
+@@ -888,6 +888,7 @@ got:
+ 	ei->i_file_acl = 0;
+ 	ei->i_dtime = 0;
+ 	ei->i_block_group = group;
++	ei->i_fs_version = 0;
+ 
+ 	ext4_set_inode_flags(inode);
+ 	if (IS_DIRSYNC(inode))
+Index: linux-2.6.27.21-0.1/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/inode.c	2009-06-15 06:23:34.000000000 -0400
++++ linux-2.6.27.21-0.1/fs/ext4/inode.c	2009-06-15 17:01:11.000000000 -0400
+@@ -4201,10 +4201,10 @@ struct inode *ext4_iget(struct super_blo
+ 	EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
+ 	EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
+ 
+-	inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
++	ei->i_fs_version = le32_to_cpu(raw_inode->i_disk_version);
+ 	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
+ 		if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
+-			inode->i_version |=
++			ei->i_fs_version |=
+ 			(__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
+ 	}
+ 
+@@ -4383,11 +4383,11 @@ static int ext4_do_update_inode(handle_t
+ 	} else for (block = 0; block < EXT4_N_BLOCKS; block++)
+ 		raw_inode->i_block[block] = ei->i_data[block];
+ 
+-	raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
++	raw_inode->i_disk_version = cpu_to_le32(ei->i_fs_version);
+ 	if (ei->i_extra_isize) {
+ 		if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
+ 			raw_inode->i_version_hi =
+-			cpu_to_le32(inode->i_version >> 32);
++			cpu_to_le32(ei->i_fs_version >> 32);
+ 		raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
+ 	}
+ 
+
diff --git a/ldiskfs/kernel_patches/patches/ext4-map_inode_page-2.6.18-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-map_inode_page-2.6.18-rhel5.patch
new file mode 100644
index 0000000..4ed87f0
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-map_inode_page-2.6.18-rhel5.patch
@@ -0,0 +1,86 @@
+Index: linux-2.6.18.i386/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/inode.c
++++ linux-2.6.18.i386/fs/ext4/inode.c
+@@ -3666,3 +3666,66 @@ out_unlock:
+ 	unlock_page(page);
+ 	return ret;
+ }
++
++int ext4_map_inode_page(struct inode *inode, struct page *page,
++			unsigned long *blocks, int *created, int create)
++{
++	unsigned int blocksize, blocks_per_page;
++	unsigned long iblock;
++	struct buffer_head dummy;
++	void *handle;
++	int i, rc = 0, failed = 0, needed_blocks;
++
++	blocksize = inode->i_sb->s_blocksize;
++	blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
++	iblock = page->index * blocks_per_page;
++
++	for (i = 0; i < blocks_per_page; i++, iblock++) {
++		blocks[i] = ext4_bmap(inode->i_mapping, iblock);
++		if (blocks[i] == 0) {
++			failed++;
++			if (created)
++				created[i] = -1;
++		} else if (created) {
++			created[i] = 0;
++		}
++	}
++
++	if (failed == 0 || create == 0)
++		return 0;
++
++	needed_blocks = ext4_writepage_trans_blocks(inode);
++	handle = ext4_journal_start(inode, needed_blocks);
++	if (IS_ERR(handle))
++		return PTR_ERR(handle);
++
++	iblock = page->index * blocks_per_page;
++	for (i = 0; i < blocks_per_page; i++, iblock++) {
++		if (blocks[i] != 0)
++			continue;
++
++		rc = ext4_get_blocks_handle(handle, inode, iblock, 1, &dummy, 1, 1);
++		if (rc < 0) {
++			printk(KERN_INFO "ext4_map_inode_page: error reading "
++					"block %ld\n", iblock);
++			goto out;
++		} else {
++			if (rc > 1)
++				WARN_ON(1);
++			rc = 0;
++		}
++		/* Unmap any metadata buffers from the block mapping, to avoid
++		 * data corruption due to direct-write from Lustre being
++		 * clobbered by a later flush of the blockdev metadata buffer.*/
++		if (buffer_new(&dummy))
++			unmap_underlying_metadata(dummy.b_bdev,
++					dummy.b_blocknr);
++		blocks[i] = dummy.b_blocknr;
++		if (created)
++			created[i] = 1;
++	}
++
++out:
++	ext4_journal_stop(handle);
++	return rc;
++}
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -3498,6 +3498,10 @@ static void __exit exit_ext4_fs(void)
+ 	__free_page(ext4_zero_page);
+ }
+ 
++int ext4_map_inode_page(struct inode *inode, struct page *page,
++			unsigned long *blocks, int *created, int create);
++EXPORT_SYMBOL(ext4_map_inode_page);
++
+ MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
+ MODULE_DESCRIPTION("Fourth Extended Filesystem with extents");
+ MODULE_LICENSE("GPL");
diff --git a/ldiskfs/kernel_patches/patches/ext4-map_inode_page-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-map_inode_page-sles11.patch
new file mode 100644
index 0000000..4ed87f0
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-map_inode_page-sles11.patch
@@ -0,0 +1,86 @@
+Index: linux-2.6.18.i386/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/inode.c
++++ linux-2.6.18.i386/fs/ext4/inode.c
+@@ -3666,3 +3666,66 @@ out_unlock:
+ 	unlock_page(page);
+ 	return ret;
+ }
++
++int ext4_map_inode_page(struct inode *inode, struct page *page,
++			unsigned long *blocks, int *created, int create)
++{
++	unsigned int blocksize, blocks_per_page;
++	unsigned long iblock;
++	struct buffer_head dummy;
++	void *handle;
++	int i, rc = 0, failed = 0, needed_blocks;
++
++	blocksize = inode->i_sb->s_blocksize;
++	blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits;
++	iblock = page->index * blocks_per_page;
++
++	for (i = 0; i < blocks_per_page; i++, iblock++) {
++		blocks[i] = ext4_bmap(inode->i_mapping, iblock);
++		if (blocks[i] == 0) {
++			failed++;
++			if (created)
++				created[i] = -1;
++		} else if (created) {
++			created[i] = 0;
++		}
++	}
++
++	if (failed == 0 || create == 0)
++		return 0;
++
++	needed_blocks = ext4_writepage_trans_blocks(inode);
++	handle = ext4_journal_start(inode, needed_blocks);
++	if (IS_ERR(handle))
++		return PTR_ERR(handle);
++
++	iblock = page->index * blocks_per_page;
++	for (i = 0; i < blocks_per_page; i++, iblock++) {
++		if (blocks[i] != 0)
++			continue;
++
++		rc = ext4_get_blocks_handle(handle, inode, iblock, 1, &dummy, 1, 1);
++		if (rc < 0) {
++			printk(KERN_INFO "ext4_map_inode_page: error reading "
++					"block %ld\n", iblock);
++			goto out;
++		} else {
++			if (rc > 1)
++				WARN_ON(1);
++			rc = 0;
++		}
++		/* Unmap any metadata buffers from the block mapping, to avoid
++		 * data corruption due to direct-write from Lustre being
++		 * clobbered by a later flush of the blockdev metadata buffer.*/
++		if (buffer_new(&dummy))
++			unmap_underlying_metadata(dummy.b_bdev,
++					dummy.b_blocknr);
++		blocks[i] = dummy.b_blocknr;
++		if (created)
++			created[i] = 1;
++	}
++
++out:
++	ext4_journal_stop(handle);
++	return rc;
++}
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -3498,6 +3498,10 @@ static void __exit exit_ext4_fs(void)
+ 	__free_page(ext4_zero_page);
+ }
+ 
++int ext4_map_inode_page(struct inode *inode, struct page *page,
++			unsigned long *blocks, int *created, int create);
++EXPORT_SYMBOL(ext4_map_inode_page);
++
+ MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
+ MODULE_DESCRIPTION("Fourth Extended Filesystem with extents");
+ MODULE_LICENSE("GPL");
diff --git a/ldiskfs/kernel_patches/patches/ext4-max-dir-size-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-max-dir-size-rhel5.patch
new file mode 100644
index 0000000..295d0d1
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-max-dir-size-rhel5.patch
@@ -0,0 +1,203 @@
+Index: linux-2.6.18.i386/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ialloc.c
++++ linux-2.6.18.i386/fs/ext4/ialloc.c
+@@ -622,12 +622,15 @@ struct inode *ext4_new_inode(handle_t *h
+ 		return ERR_PTR(-EPERM);
+ 
+ 	sb = dir->i_sb;
++	sbi = EXT4_SB(sb);
++	if (sbi->s_max_dir_size > 0 && i_size_read(dir) >= sbi->s_max_dir_size)
++		return ERR_PTR(-EFBIG);
++
+ 	inode = new_inode(sb);
+ 	if (!inode)
+ 		return ERR_PTR(-ENOMEM);
+ 	ei = EXT4_I(inode);
+ 
+-	sbi = EXT4_SB(sb);
+ 	es = sbi->s_es;
+ 
+ 	if (goal) {
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -38,6 +38,7 @@
+ #include <asm/uaccess.h>
+ #include <linux/kthread.h>
+ #include <linux/utsname.h>
++#include <linux/proc_fs.h>
+ 
+ #include "ext4.h"
+ #include "ext4_jbd2.h"
+@@ -67,6 +68,8 @@ static void ext4_write_super_lockfs(stru
+ 
+ struct page *ext4_zero_page;
+ 
++struct proc_dir_entry *proc_root_ext4;
++
+ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
+ 			       struct ext4_group_desc *bg)
+ {
+@@ -551,6 +554,9 @@ static void ext4_put_super(struct super_
+ 	}
+ 	if (sbi->s_mmp_tsk)
+ 		kthread_stop(sbi->s_mmp_tsk);
++
++	remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_mb_proc);
++
+ 	sb->s_fs_info = NULL;
+ 	kfree(sbi);
+ 	return;
+@@ -2185,6 +2191,46 @@ static unsigned long ext4_get_stripe_siz
+ 	return 0;
+ }
+ 
++static int ext4_max_dir_size_read(char *page, char **start, off_t off,
++                                  int count, int *eof, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	int len;
++
++	*eof = 1;
++	if (off != 0)
++		return 0;
++
++	len = sprintf(page, "%lu\n", sbi->s_max_dir_size);
++	*start = page;
++	return len;
++}
++
++static int ext4_max_dir_size_write(struct file *file, const char *buffer,
++                                   unsigned long count, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	char str[32];
++	unsigned long value;
++	char *end;
++
++	if (count >= sizeof(str)) {
++		printk(KERN_ERR "EXT4-fs: %s string too long, max %u bytes\n",
++		       EXT4_MAX_DIR_SIZE_NAME, (int)sizeof(str));
++		return -EOVERFLOW;
++	}
++
++	if (copy_from_user(str, buffer, count))
++		return -EFAULT;
++
++	value = simple_strtol(str, &end, 0);
++	if (value < 0)
++		return -ERANGE;
++
++	sbi->s_max_dir_size = value;
++	return count;
++}
++
+ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
+ 				__releases(kernel_lock)
+ 				__acquires(kernel_lock)
+@@ -2208,6 +2254,7 @@ static int ext4_fill_super(struct super_
+ 	int needs_recovery;
+ 	__le32 features;
+ 	__u64 blocks_count;
++	struct proc_dir_entry *proc;
+ 
+ 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+ 	if (!sbi)
+@@ -2743,6 +2790,22 @@ static int ext4_fill_super(struct super_
+ 	ext4_ext_init(sb);
+ 	ext4_mb_init(sb, needs_recovery);
+ 
++	sbi->s_max_dir_size = EXT4_DEFAULT_MAX_DIR_SIZE;
++	proc = create_proc_entry(EXT4_MAX_DIR_SIZE_NAME,
++				 S_IFREG | S_IRUGO | S_IWUSR, sbi->s_mb_proc);
++	if (proc == NULL) {
++		printk(KERN_ERR "EXT4-fs: unable to create %s\n",
++		       EXT4_MAX_DIR_SIZE_NAME);
++		remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_mb_proc);
++		remove_proc_entry(sbi->s_mb_proc->name, proc_root_ext4);
++		sbi->s_mb_proc = NULL;
++		ret = -ENOMEM;
++		goto failed_mount4;
++	}
++	proc->data = sbi;
++	proc->read_proc = ext4_max_dir_size_read;
++	proc->write_proc = ext4_max_dir_size_write;
++
+ 	lock_kernel();
+ 	return 0;
+ 
+@@ -3082,7 +3145,6 @@ static void ext4_commit_super(struct sup
+ 		sync_dirty_buffer(sbh);
+ }
+ 
+-
+ /*
+  * Have we just finished recovery?  If so, and if we are mounting (or
+  * remounting) the filesystem readonly, then we will end up with a
+Index: linux-2.6.18.i386/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4_sb.h
++++ linux-2.6.18.i386/fs/ext4/ext4_sb.h
+@@ -117,6 +117,7 @@ struct ext4_sb_info {
+ 	/* where last allocation was done - for stream allocation */
+ 	unsigned long s_mb_last_group;
+ 	unsigned long s_mb_last_start;
++	unsigned long s_max_dir_size;
+ 
+ 	/* history to debug policy */
+ 	struct ext4_mb_history *s_mb_history;
+Index: linux-2.6.18.i386/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4.h
++++ linux-2.6.18.i386/fs/ext4/ext4.h
+@@ -992,6 +992,14 @@ struct mmp_struct {
+  */
+ #define EXT4_MMP_MIN_CHECK_INTERVAL	5
+ 
++extern struct proc_dir_entry *proc_root_ext4;
++
++/*
++ * max directory size tunable
++ */
++#define EXT4_DEFAULT_MAX_DIR_SIZE	0
++#define EXT4_MAX_DIR_SIZE_NAME		"max_dir_size"
++
+ /*
+  * Function prototypes
+  */
+Index: linux-2.6.18.i386/fs/ext4/mballoc.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/mballoc.h
++++ linux-2.6.18.i386/fs/ext4/mballoc.h
+@@ -257,7 +257,6 @@ static void ext4_mb_store_history(struct
+ 
+ #define in_range(b, first, len)	((b) >= (first) && (b) <= (first) + (len) - 1)
+ 
+-static struct proc_dir_entry *proc_root_ext4;
+ struct buffer_head *read_block_bitmap(struct super_block *, ext4_group_t);
+ 
+ static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+Index: linux-2.6.18.i386/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/mballoc.c
++++ linux-2.6.18.i386/fs/ext4/mballoc.c
+@@ -2821,6 +2821,7 @@ err_out:
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(devname, proc_root_ext4);
+ 	sbi->s_mb_proc = NULL;
+ 
+@@ -2842,7 +2843,9 @@ static int ext4_mb_destroy_per_dev_proc(
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(devname, proc_root_ext4);
++	sbi->s_mb_proc = NULL;
+ 
+ 	return 0;
+ }
diff --git a/ldiskfs/kernel_patches/patches/ext4-max-dir-size-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-max-dir-size-sles11.patch
new file mode 100644
index 0000000..4b0db60
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-max-dir-size-sles11.patch
@@ -0,0 +1,195 @@
+Index: linux-stage/fs/ext4/ialloc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/ialloc.c
++++ linux-stage/fs/ext4/ialloc.c
+@@ -700,12 +700,15 @@ struct inode *ext4_new_inode(handle_t *h
+ 		return ERR_PTR(-EPERM);
+ 
+ 	sb = dir->i_sb;
++	sbi = EXT4_SB(sb);
++	if (sbi->s_max_dir_size > 0 && i_size_read(dir) >= sbi->s_max_dir_size)
++		return ERR_PTR(-EFBIG);
++
+ 	inode = new_inode(sb);
+ 	if (!inode)
+ 		return ERR_PTR(-ENOMEM);
+ 	ei = EXT4_I(inode);
+ 
+-	sbi = EXT4_SB(sb);
+ 	es = sbi->s_es;
+ 
+ 	if (goal) {
+Index: linux-stage/fs/ext4/super.c
+===================================================================
+--- linux-stage.orig/fs/ext4/super.c
++++ linux-stage/fs/ext4/super.c
+@@ -41,6 +41,7 @@
+ #include <asm/uaccess.h>
+ #include <linux/kthread.h>
+ #include <linux/utsname.h>
++#include <linux/proc_fs.h>
+ 
+ #include "ext4.h"
+ #include "ext4_jbd2.h"
+@@ -71,6 +72,8 @@ static void ext4_write_super(struct supe
+ static void ext4_write_super_lockfs(struct super_block *sb);
+ 
+ 
++struct proc_dir_entry *proc_root_ext4;
++
+ ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
+ 			       struct ext4_group_desc *bg)
+ {
+@@ -564,6 +567,7 @@ static void ext4_put_super(struct super_
+ 	}
+ 	if (sbi->s_proc) {
+ 		remove_proc_entry("inode_readahead_blks", sbi->s_proc);
++		remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
+ 		remove_proc_entry(sb->s_id, ext4_proc_root);
+ 	}
+ 
+@@ -602,6 +606,7 @@ static void ext4_put_super(struct super_
+ 	}
+ 	if (sbi->s_mmp_tsk)
+ 		kthread_stop(sbi->s_mmp_tsk);
++
+ 	sb->s_fs_info = NULL;
+ 	kfree(sbi);
+ 	return;
+@@ -2287,6 +2292,46 @@ static unsigned long ext4_get_stripe_siz
+ 	return 0;
+ }
+ 
++static int ext4_max_dir_size_read(char *page, char **start, off_t off,
++                                  int count, int *eof, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	int len;
++
++	*eof = 1;
++	if (off != 0)
++		return 0;
++
++	len = sprintf(page, "%lu\n", sbi->s_max_dir_size);
++	*start = page;
++	return len;
++}
++
++static int ext4_max_dir_size_write(struct file *file, const char *buffer,
++                                   unsigned long count, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	char str[32];
++	unsigned long value;
++	char *end;
++
++	if (count >= sizeof(str)) {
++		printk(KERN_ERR "EXT4-fs: %s string too long, max %u bytes\n",
++		       EXT4_MAX_DIR_SIZE_NAME, (int)sizeof(str));
++		return -EOVERFLOW;
++	}
++
++	if (copy_from_user(str, buffer, count))
++		return -EFAULT;
++
++	value = simple_strtol(str, &end, 0);
++	if (value < 0)
++		return -ERANGE;
++
++	sbi->s_max_dir_size = value;
++	return count;
++}
++
+ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
+ 				__releases(kernel_lock)
+ 				__acquires(kernel_lock)
+@@ -2311,6 +2356,7 @@ static int ext4_fill_super(struct super_
+ 	int needs_recovery, has_huge_files;
+ 	int features;
+ 	__u64 blocks_count;
++	struct proc_dir_entry *proc;
+ 	int err;
+ 
+ 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
+@@ -2880,6 +2926,22 @@ static int ext4_fill_super(struct super_
+ 	       test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered":
+ 	       "writeback");
+ 
++	sbi->s_max_dir_size = EXT4_DEFAULT_MAX_DIR_SIZE;
++	proc = create_proc_entry(EXT4_MAX_DIR_SIZE_NAME,
++				 S_IFREG | S_IRUGO | S_IWUSR, sbi->s_proc);
++	if (proc == NULL) {
++		printk(KERN_ERR "EXT4-fs: unable to create %s\n",
++		       EXT4_MAX_DIR_SIZE_NAME);
++		remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
++		remove_proc_entry(sbi->s_proc->name, proc_root_ext4);
++		sbi->s_proc = NULL;
++		ret = -ENOMEM;
++		goto failed_mount4;
++	}
++	proc->data = sbi;
++	proc->read_proc = ext4_max_dir_size_read;
++	proc->write_proc = ext4_max_dir_size_write;
++
+ 	lock_kernel();
+ 	return 0;
+ 
+@@ -3253,7 +3315,6 @@ static void ext4_commit_super(struct sup
+ 	}
+ }
+ 
+-
+ /*
+  * Have we just finished recovery?  If so, and if we are mounting (or
+  * remounting) the filesystem readonly, then we will end up with a
+Index: linux-stage/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-stage.orig/fs/ext4/ext4_sb.h
++++ linux-stage/fs/ext4/ext4_sb.h
+@@ -118,6 +118,7 @@ struct ext4_sb_info {
+ 	/* where last allocation was done - for stream allocation */
+ 	unsigned long s_mb_last_group;
+ 	unsigned long s_mb_last_start;
++	unsigned long s_max_dir_size;
+ 
+ 	/* history to debug policy */
+ 	struct ext4_mb_history *s_mb_history;
+Index: linux-stage/fs/ext4/ext4.h
+===================================================================
+--- linux-stage.orig/fs/ext4/ext4.h
++++ linux-stage/fs/ext4/ext4.h
+@@ -1017,6 +1017,14 @@ struct mmp_struct {
+  */
+ #define EXT4_MMP_MIN_CHECK_INTERVAL	5
+ 
++extern struct proc_dir_entry *proc_root_ext4;
++
++/*
++ * max directory size tunable
++ */
++#define EXT4_DEFAULT_MAX_DIR_SIZE	0
++#define EXT4_MAX_DIR_SIZE_NAME		"max_dir_size"
++
+ /*
+  * Function prototypes
+  */
+Index: linux-stage/fs/ext4/mballoc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/mballoc.c
++++ linux-stage/fs/ext4/mballoc.c
+@@ -2943,6 +2943,7 @@ err_out:
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc);
++	remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
+ 	return -ENOMEM;
+ #else
+ 	return 0;
+@@ -2963,6 +2964,7 @@ static int ext4_mb_destroy_per_dev_proc(
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_STATS_NAME, sbi->s_proc);
++	remove_proc_entry(EXT4_MAX_DIR_SIZE_NAME, sbi->s_proc);
+ #endif
+ 	return 0;
+ }
diff --git a/ldiskfs/kernel_patches/patches/ext4-mballoc-extra-checks-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-mballoc-extra-checks-rhel5.patch
new file mode 100644
index 0000000..7a77781
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-mballoc-extra-checks-rhel5.patch
@@ -0,0 +1,331 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/mballoc.c
++++ linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+@@ -660,7 +660,7 @@ static void ext4_mb_mark_free_simple(str
+ 	}
+ }
+ 
+-static void ext4_mb_generate_buddy(struct super_block *sb,
++static int ext4_mb_generate_buddy(struct super_block *sb,
+ 				void *buddy, void *bitmap, ext4_group_t group)
+ {
+ 	struct ext4_group_info *grp = ext4_get_group_info(sb, group);
+@@ -692,14 +692,14 @@ static void ext4_mb_generate_buddy(struc
+ 	grp->bb_fragments = fragments;
+ 
+ 	if (free != grp->bb_free) {
+-		ext4_error(sb, __func__,
+-			"EXT4-fs: group %lu: %u blocks in bitmap, %u in gd\n",
+-			group, free, grp->bb_free);
+-		/*
+-		 * If we intent to continue, we consider group descritor
+-		 * corrupt and update bb_free using bitmap value
+-		 */
+-		grp->bb_free = free;
++		struct ext4_group_desc *gdp;
++		gdp = ext4_get_group_desc (sb, group, NULL);
++		ext4_error(sb, __FUNCTION__,
++			"group %lu: %u blocks in bitmap, %u in bb, "
++			"%u in gd, %lu pa's\n", group, free, grp->bb_free,
++			le16_to_cpu(gdp->bg_free_blocks_count),
++			grp->bb_prealloc_nr);
++		return -EIO;
+ 	}
+ 
+ 	clear_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &(grp->bb_state));
+@@ -709,6 +709,8 @@ static void ext4_mb_generate_buddy(struc
+ 	EXT4_SB(sb)->s_mb_buddies_generated++;
+ 	EXT4_SB(sb)->s_mb_generation_time += period;
+ 	spin_unlock(&EXT4_SB(sb)->s_bal_lock);
++
++	return 0;
+ }
+ 
+ /* The buddy information is attached the buddy cache inode
+@@ -814,7 +816,7 @@ static int ext4_mb_init_cache(struct pag
+ 
+ 	err = 0;
+ 	first_block = page->index * blocks_per_page;
+-	for (i = 0; i < blocks_per_page; i++) {
++	for (i = 0; i < blocks_per_page && err == 0; i++) {
+ 		int group;
+ 		struct ext4_group_info *grinfo;
+ 
+@@ -848,7 +850,7 @@ static int ext4_mb_init_cache(struct pag
+ 			/*
+ 			 * incore got set to the group block bitmap below
+ 			 */
+-			ext4_mb_generate_buddy(sb, data, incore, group);
++			err = ext4_mb_generate_buddy(sb, data, incore, group);
+ 			incore = NULL;
+ 		} else {
+ 			/* this is block of bitmap */
+@@ -861,7 +863,7 @@ static int ext4_mb_init_cache(struct pag
+ 			memcpy(data, bitmap, blocksize);
+ 
+ 			/* mark all preallocated blks used in in-core bitmap */
+-			ext4_mb_generate_from_pa(sb, data, group);
++			err = ext4_mb_generate_from_pa(sb, data, group);
+ 			ext4_unlock_group(sb, group);
+ 
+ 			/* set incore so that the buddy information can be
+@@ -870,6 +872,7 @@ static int ext4_mb_init_cache(struct pag
+ 			incore = data;
+ 		}
+ 	}
++	if (likely(err == 0))
+ 	SetPageUptodate(page);
+ 
+ out:
+@@ -1964,7 +1967,10 @@ static int ext4_mb_seq_history_show(stru
+ 			hs->result.fe_start, hs->result.fe_len);
+ 		seq_printf(seq, "%-5u %-8u %-23s free\n",
+ 				hs->pid, hs->ino, buf2);
++	} else {
++		seq_printf(seq, "unknown op %d\n", hs->op);
+ 	}
++
+ 	return 0;
+ }
+ 
+@@ -2092,9 +2098,11 @@ static void *ext4_mb_seq_groups_next(str
+ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
+ {
+ 	struct super_block *sb = seq->private;
++	struct ext4_group_desc *gdp;
+ 	long group = (long) v;
+ 	int i;
+ 	int err;
++	int free = 0;
+ 	struct ext4_buddy e4b;
+ 	struct sg {
+ 		struct ext4_group_info info;
+@@ -2103,10 +2111,10 @@ static int ext4_mb_seq_groups_show(struc
+ 
+ 	group--;
+ 	if (group == 0)
+-		seq_printf(seq, "#%-5s: %-5s %-5s %-5s "
++		seq_printf(seq, "#%-5s: %-5s %-5s %-5s %-5s %-5s"
+ 				"[ %-5s %-5s %-5s %-5s %-5s %-5s %-5s "
+ 				  "%-5s %-5s %-5s %-5s %-5s %-5s %-5s ]\n",
+-			   "group", "free", "frags", "first",
++			   "group", "free", "frags", "first", "first", "pa",
+ 			   "2^0", "2^1", "2^2", "2^3", "2^4", "2^5", "2^6",
+ 			   "2^7", "2^8", "2^9", "2^10", "2^11", "2^12", "2^13");
+ 
+@@ -2117,13 +2125,20 @@ static int ext4_mb_seq_groups_show(struc
+ 		seq_printf(seq, "#%-5lu: I/O error\n", group);
+ 		return 0;
+ 	}
++
++	gdp = ext4_get_group_desc(sb, group, NULL);
++	if (gdp != NULL)
++		free = le16_to_cpu(gdp->bg_free_blocks_count);
++
+ 	ext4_lock_group(sb, group);
+ 	memcpy(&sg, ext4_get_group_info(sb, group), i);
+ 	ext4_unlock_group(sb, group);
+ 	ext4_mb_release_desc(&e4b);
+ 
+-	seq_printf(seq, "#%-5lu: %-5u %-5u %-5u [", group, sg.info.bb_free,
+-			sg.info.bb_fragments, sg.info.bb_first_free);
++	seq_printf(seq, "#%-5lu: %-5u %-5u %-5u %-5u %-5lu [", group,
++			sg.info.bb_free, free,
++			sg.info.bb_fragments, sg.info.bb_first_free,
++			sg.info.bb_prealloc_nr);
+ 	for (i = 0; i <= 13; i++)
+ 		seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ?
+ 				sg.info.bb_counters[i] : 0);
+@@ -2226,6 +2241,7 @@ ext4_mb_store_history(struct ext4_alloca
+ 	h.tail = ac->ac_tail;
+ 	h.buddy = ac->ac_buddy;
+ 	h.merged = 0;
++	h.cr = ac->ac_criteria;
+ 	if (ac->ac_op == EXT4_MB_HISTORY_ALLOC) {
+ 		if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
+ 				ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
+@@ -3539,22 +3555,67 @@ ext4_mb_use_preallocated(struct ext4_all
+ }
+ 
+ /*
++ * check free blocks in bitmap match free block in group descriptor
++ * do this before taking preallocated blocks into account to be able
++ * to detect on-disk corruptions. The group lock should be hold by the
++ * caller.
++ */
++int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap,
++				struct ext4_group_desc *gdp, int group)
++{
++	unsigned short max = EXT4_BLOCKS_PER_GROUP(sb);
++	unsigned short i, first, free = 0;
++
++	i = mb_find_next_zero_bit(bitmap, max, 0);
++
++	while (i < max) {
++		first = i;
++		i = mb_find_next_bit(bitmap, max, i);
++		if (i > max)
++			i = max;
++		free += i - first;
++		if (i < max)
++			i = mb_find_next_zero_bit(bitmap, max, i);
++	}
++
++	if (free != le16_to_cpu(gdp->bg_free_blocks_count)) {
++		ext4_error(sb, __FUNCTION__, "on-disk bitmap for group %d"
++			"corrupted: %u blocks free in bitmap, %u - in gd\n",
++			group, free, le16_to_cpu(gdp->bg_free_blocks_count));
++		return -EIO;
++	}
++	return 0;
++}
++
++/*
+  * the function goes through all preallocation in this group and marks them
+  * used in in-core bitmap. buddy must be generated from this bitmap
+  * Need to be called with ext4 group lock (ext4_lock_group)
+  */
+-static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
++static int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+ 					ext4_group_t group)
+ {
+ 	struct ext4_group_info *grp = ext4_get_group_info(sb, group);
+ 	struct ext4_prealloc_space *pa;
++	struct ext4_group_desc *gdp;
+ 	struct list_head *cur;
+ 	ext4_group_t groupnr;
+ 	ext4_grpblk_t start;
+ 	int preallocated = 0;
+ 	int count = 0;
++	int skip = 0;
++	int err;
+ 	int len;
+ 
++	gdp = ext4_get_group_desc (sb, group, NULL);
++	if (gdp == NULL)
++		return -EIO;
++
++	/* before applying preallocations, check bitmap consistency */
++	err = ext4_mb_check_ondisk_bitmap(sb, bitmap, gdp, group);
++	if (err)
++		return err;
++
+ 	/* all form of preallocation discards first load group,
+ 	 * so the only competing code is preallocation use.
+ 	 * we don't need any locking here
+@@ -3570,15 +3631,24 @@ static void ext4_mb_generate_from_pa(str
+ 					     &groupnr, &start);
+ 		len = pa->pa_len;
+ 		spin_unlock(&pa->pa_lock);
+-		if (unlikely(len == 0))
++		if (unlikely(len == 0)) {
++			skip++;
+ 			continue;
++		}
+ 		BUG_ON(groupnr != group);
+ 		mb_set_bits(sb_bgl_lock(EXT4_SB(sb), group),
+ 						bitmap, start, len);
+ 		preallocated += len;
+ 		count++;
+ 	}
++	if (count + skip != grp->bb_prealloc_nr) {
++		ext4_error(sb, __FUNCTION__, "lost preallocations: "
++			   "count %d, bb_prealloc_nr %lu, skip %d\n",
++			   count, grp->bb_prealloc_nr, skip);
++		return -EIO;
++	}
+ 	mb_debug("prellocated %u for group %lu\n", preallocated, group);
++	return 0;
+ }
+ 
+ static void ext4_mb_pa_callback(struct rcu_head *head)
+@@ -3629,6 +3699,7 @@ static void ext4_mb_put_pa(struct ext4_a
+ 	 */
+ 	ext4_lock_group(sb, grp);
+ 	list_del(&pa->pa_group_list);
++	ext4_get_group_info(sb, grp)->bb_prealloc_nr--;
+ 	ext4_unlock_group(sb, grp);
+ 
+ 	spin_lock(pa->pa_obj_lock);
+@@ -3717,6 +3788,7 @@ ext4_mb_new_inode_pa(struct ext4_allocat
+ 
+ 	ext4_lock_group(sb, ac->ac_b_ex.fe_group);
+ 	list_add(&pa->pa_group_list, &grp->bb_prealloc_list);
++	grp->bb_prealloc_nr++;
+ 	ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
+ 
+ 	spin_lock(pa->pa_obj_lock);
+@@ -3776,6 +3848,7 @@ ext4_mb_new_group_pa(struct ext4_allocat
+ 
+ 	ext4_lock_group(sb, ac->ac_b_ex.fe_group);
+ 	list_add(&pa->pa_group_list, &grp->bb_prealloc_list);
++	grp->bb_prealloc_nr++;
+ 	ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
+ 
+ 	/*
+@@ -3828,6 +3901,7 @@ ext4_mb_release_inode_pa(struct ext4_bud
+ 		ac->ac_sb = sb;
+ 		ac->ac_inode = pa->pa_inode;
+ 		ac->ac_op = EXT4_MB_HISTORY_DISCARD;
++		ac->ac_o_ex.fe_len = 1;
+ 	}
+ 
+ 	while (bit < end) {
+@@ -3972,6 +4046,8 @@ repeat:
+ 
+ 		spin_unlock(&pa->pa_lock);
+ 
++		BUG_ON(grp->bb_prealloc_nr == 0);
++		grp->bb_prealloc_nr--;
+ 		list_del(&pa->pa_group_list);
+ 		list_add(&pa->u.pa_tmp_list, &list);
+ 	}
+@@ -4107,7 +4183,7 @@ repeat:
+ 		if (err) {
+ 			ext4_error(sb, __func__, "Error in loading buddy "
+ 					"information for %lu\n", group);
+-			continue;
++			return;
+ 		}
+ 
+ 		bitmap_bh = ext4_read_block_bitmap(sb, group);
+@@ -4119,6 +4195,8 @@ repeat:
+ 		}
+ 
+ 		ext4_lock_group(sb, group);
++		BUG_ON(e4b.bd_info->bb_prealloc_nr == 0);
++		e4b.bd_info->bb_prealloc_nr--;
+ 		list_del(&pa->pa_group_list);
+ 		ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa, ac);
+ 		ext4_unlock_group(sb, group);
+Index: linux-2.6.18-128.1.6/fs/ext4/mballoc.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/mballoc.h
++++ linux-2.6.18-128.1.6/fs/ext4/mballoc.h
+@@ -119,6 +119,7 @@ struct ext4_group_info {
+ 	unsigned short	bb_free;
+ 	unsigned short	bb_fragments;
+ 	struct		list_head bb_prealloc_list;
++	unsigned long   bb_prealloc_nr;
+ #ifdef DOUBLE_CHECK
+ 	void		*bb_bitmap;
+ #endif
+@@ -228,7 +229,7 @@ struct ext4_mb_history {
+ 	__u16 tail;	/* what tail broke some buddy */
+ 	__u16 buddy;	/* buddy the tail ^^^ broke */
+ 	__u16 flags;
+-	__u8 cr:3;	/* which phase the result extent was found at */
++	__u8 cr:8;	/* which phase the result extent was found at */
+ 	__u8 op:4;
+ 	__u8 merged:1;
+ };
+@@ -259,7 +260,7 @@ static void ext4_mb_store_history(struct
+ 
+ struct buffer_head *read_block_bitmap(struct super_block *, ext4_group_t);
+ 
+-static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
++static int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+ 					ext4_group_t group);
+ static void ext4_mb_poll_new_transaction(struct super_block *, handle_t *);
+ static void ext4_mb_free_committed_blocks(struct super_block *);
diff --git a/ldiskfs/kernel_patches/patches/ext4-mballoc-extra-checks-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-mballoc-extra-checks-sles11.patch
new file mode 100644
index 0000000..6fc1683
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-mballoc-extra-checks-sles11.patch
@@ -0,0 +1,271 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/mballoc.c
++++ linux-2.6.27.21-0.1/fs/ext4/mballoc.c
+@@ -333,7 +333,7 @@
+ static struct kmem_cache *ext4_pspace_cachep;
+ static struct kmem_cache *ext4_ac_cachep;
+ static struct kmem_cache *ext4_free_ext_cachep;
+-static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
++static int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+ 					ext4_group_t group);
+ static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap,
+ 						ext4_group_t group);
+@@ -672,7 +672,7 @@ static void ext4_mb_mark_free_simple(str
+ 	}
+ }
+ 
+-static void ext4_mb_generate_buddy(struct super_block *sb,
++static int ext4_mb_generate_buddy(struct super_block *sb,
+ 				void *buddy, void *bitmap, ext4_group_t group)
+ {
+ 	struct ext4_group_info *grp = ext4_get_group_info(sb, group);
+@@ -704,14 +704,13 @@ static void ext4_mb_generate_buddy(struc
+ 	grp->bb_fragments = fragments;
+ 
+ 	if (free != grp->bb_free) {
+-		ext4_grp_locked_error(sb, group,  __func__,
+-			"EXT4-fs: group %u: %u blocks in bitmap, %u in gd\n",
+-			group, free, grp->bb_free);
+-		/*
+-		 * If we intent to continue, we consider group descritor
+-		 * corrupt and update bb_free using bitmap value
+-		 */
+-		grp->bb_free = free;
++		struct ext4_group_desc *gdp;
++		gdp = ext4_get_group_desc (sb, group, NULL);
++		ext4_grp_locked_error(sb, group, __func__,
++			"group %u: %u blocks in bitmap, %u in bb, "
++			"%u in gd\n", group, free, grp->bb_free,
++			ext4_free_blks_count(sb, gdp));
++		return -EIO;
+ 	}
+ 
+ 	clear_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &(grp->bb_state));
+@@ -721,6 +720,8 @@ static void ext4_mb_generate_buddy(struc
+ 	EXT4_SB(sb)->s_mb_buddies_generated++;
+ 	EXT4_SB(sb)->s_mb_generation_time += period;
+ 	spin_unlock(&EXT4_SB(sb)->s_bal_lock);
++
++	return 0;
+ }
+ 
+ /* The buddy information is attached the buddy cache inode
+@@ -850,7 +851,7 @@ static int ext4_mb_init_cache(struct pag
+ 	first_block = page->index * blocks_per_page;
+ 	/* init the page  */
+ 	memset(page_address(page), 0xff, PAGE_CACHE_SIZE);
+-	for (i = 0; i < blocks_per_page; i++) {
++	for (i = 0; i < blocks_per_page && err == 0; i++) {
+ 		int group;
+ 		struct ext4_group_info *grinfo;
+ 
+@@ -884,7 +885,7 @@ static int ext4_mb_init_cache(struct pag
+ 			 * incore got set to the group block bitmap below
+ 			 */
+ 			ext4_lock_group(sb, group);
+-			ext4_mb_generate_buddy(sb, data, incore, group);
++			err = ext4_mb_generate_buddy(sb, data, incore, group);
+ 			ext4_unlock_group(sb, group);
+ 			incore = NULL;
+ 		} else {
+@@ -898,7 +899,7 @@ static int ext4_mb_init_cache(struct pag
+ 			memcpy(data, bitmap, blocksize);
+ 
+ 			/* mark all preallocated blks used in in-core bitmap */
+-			ext4_mb_generate_from_pa(sb, data, group);
++			err = ext4_mb_generate_from_pa(sb, data, group);
+ 			ext4_mb_generate_from_freelist(sb, data, group);
+ 			ext4_unlock_group(sb, group);
+ 
+@@ -908,6 +909,7 @@ static int ext4_mb_init_cache(struct pag
+ 			incore = data;
+ 		}
+ 	}
++	if (likely(err == 0))
+ 	SetPageUptodate(page);
+ 
+ out:
+@@ -2217,7 +2219,10 @@ static int ext4_mb_seq_history_show(stru
+ 			hs->result.fe_start, hs->result.fe_len);
+ 		seq_printf(seq, "%-5u %-8u %-23s free\n",
+ 				hs->pid, hs->ino, buf2);
++	} else {
++		seq_printf(seq, "unknown op %d\n", hs->op);
+ 	}
++
+ 	return 0;
+ }
+ 
+@@ -2345,9 +2350,11 @@ static void *ext4_mb_seq_groups_next(str
+ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
+ {
+ 	struct super_block *sb = seq->private;
++	struct ext4_group_desc *gdp;
+ 	ext4_group_t group = (ext4_group_t) ((unsigned long) v);
+ 	int i;
+ 	int err;
++	unsigned free = 0;
+ 	struct ext4_buddy e4b;
+ 	struct sg {
+ 		struct ext4_group_info info;
+@@ -2356,10 +2363,10 @@ static int ext4_mb_seq_groups_show(struc
+ 
+ 	group--;
+ 	if (group == 0)
+-		seq_printf(seq, "#%-5s: %-5s %-5s %-5s "
++		seq_printf(seq, "#%-5s: %-5s %-5s %-5s %-5s %-5s"
+ 				"[ %-5s %-5s %-5s %-5s %-5s %-5s %-5s "
+ 				  "%-5s %-5s %-5s %-5s %-5s %-5s %-5s ]\n",
+-			   "group", "free", "frags", "first",
++			   "group", "free", "frags", "first", "first", "pa",
+ 			   "2^0", "2^1", "2^2", "2^3", "2^4", "2^5", "2^6",
+ 			   "2^7", "2^8", "2^9", "2^10", "2^11", "2^12", "2^13");
+ 
+@@ -2371,12 +2378,18 @@ static int ext4_mb_seq_groups_show(struc
+ 		seq_printf(seq, "#%-5u: I/O error\n", group);
+ 		return 0;
+ 	}
++
++	gdp = ext4_get_group_desc(sb, group, NULL);
++	if (gdp != NULL)
++		free = ext4_free_blks_count(sb, gdp);
++
+ 	ext4_lock_group(sb, group);
+ 	memcpy(&sg, ext4_get_group_info(sb, group), i);
+ 	ext4_unlock_group(sb, group);
+ 	ext4_mb_release_desc(&e4b);
+ 
+-	seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free,
++	seq_printf(seq, "#%-5u: %-5u %-5u %-5u %-5u [", group,
++			sg.info.bb_free, free,
+ 			sg.info.bb_fragments, sg.info.bb_first_free);
+ 	for (i = 0; i <= 13; i++)
+ 		seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ?
+@@ -2474,6 +2487,7 @@ ext4_mb_store_history(struct ext4_alloca
+ 	h.tail = ac->ac_tail;
+ 	h.buddy = ac->ac_buddy;
+ 	h.merged = 0;
++	h.cr = ac->ac_criteria;
+ 	if (ac->ac_op == EXT4_MB_HISTORY_ALLOC) {
+ 		if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
+ 				ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
+@@ -3695,22 +3709,67 @@ static void ext4_mb_generate_from_freeli
+ }
+ 
+ /*
++ * check free blocks in bitmap match free block in group descriptor
++ * do this before taking preallocated blocks into account to be able
++ * to detect on-disk corruptions. The group lock should be hold by the
++ * caller.
++ */
++int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap,
++				struct ext4_group_desc *gdp, int group)
++{
++	unsigned short max = EXT4_BLOCKS_PER_GROUP(sb);
++	unsigned short i, first, free = 0;
++
++	i = mb_find_next_zero_bit(bitmap, max, 0);
++
++	while (i < max) {
++		first = i;
++		i = mb_find_next_bit(bitmap, max, i);
++		if (i > max)
++			i = max;
++		free += i - first;
++		if (i < max)
++			i = mb_find_next_zero_bit(bitmap, max, i);
++	}
++
++	if (free != ext4_free_blks_count(sb, gdp)) {
++		ext4_error(sb, __FUNCTION__, "on-disk bitmap for group %d"
++			"corrupted: %u blocks free in bitmap, %u - in gd\n",
++			group, free, ext4_free_blks_count(sb, gdp));
++		return -EIO;
++	}
++	return 0;
++}
++
++/*
+  * the function goes through all preallocation in this group and marks them
+  * used in in-core bitmap. buddy must be generated from this bitmap
+  * Need to be called with ext4 group lock (ext4_lock_group)
+  */
+-static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
++static int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
+ 					ext4_group_t group)
+ {
+ 	struct ext4_group_info *grp = ext4_get_group_info(sb, group);
+ 	struct ext4_prealloc_space *pa;
++	struct ext4_group_desc *gdp;
+ 	struct list_head *cur;
+ 	ext4_group_t groupnr;
+ 	ext4_grpblk_t start;
+ 	int preallocated = 0;
+ 	int count = 0;
++	int skip = 0;
++	int err;
+ 	int len;
+ 
++	gdp = ext4_get_group_desc (sb, group, NULL);
++	if (gdp == NULL)
++		return -EIO;
++
++	/* before applying preallocations, check bitmap consistency */
++	err = ext4_mb_check_ondisk_bitmap(sb, bitmap, gdp, group);
++	if (err)
++		return err;
++
+ 	/* all form of preallocation discards first load group,
+ 	 * so the only competing code is preallocation use.
+ 	 * we don't need any locking here
+@@ -3720,8 +3778,10 @@ static void ext4_mb_generate_from_pa(str
+ 					     &groupnr, &start);
+ 		len = pa->pa_len;
+ 		spin_unlock(&pa->pa_lock);
+-		if (unlikely(len == 0))
++		if (unlikely(len == 0)) {
++			skip++;
+ 			continue;
++		}
+ 		BUG_ON(groupnr != group);
+ 		mb_set_bits(sb_bgl_lock(EXT4_SB(sb), group),
+ 						bitmap, start, len);
+@@ -3729,6 +3789,7 @@ static void ext4_mb_generate_from_pa(str
+ 		count++;
+ 	}
+ 	mb_debug("prellocated %u for group %u\n", preallocated, group);
++	return 0;
+ }
+ 
+ static void ext4_mb_pa_callback(struct rcu_head *head)
+@@ -3978,6 +4039,7 @@ ext4_mb_release_inode_pa(struct ext4_bud
+ 		ac->ac_sb = sb;
+ 		ac->ac_inode = pa->pa_inode;
+ 		ac->ac_op = EXT4_MB_HISTORY_DISCARD;
++		ac->ac_o_ex.fe_len = 1;
+ 	}
+ 
+ 	while (bit < end) {
+@@ -4260,7 +4322,7 @@ repeat:
+ 			__release(e4b->alloc_semp);
+ 			ext4_error(sb, __func__, "Error in loading buddy "
+ 					"information for %u\n", group);
+-			continue;
++			return;
+ 		}
+ 
+ 		bitmap_bh = ext4_read_block_bitmap(sb, group);
+Index: linux-2.6.27.21-0.1/fs/ext4/mballoc.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/mballoc.h
++++ linux-2.6.27.21-0.1/fs/ext4/mballoc.h
+@@ -219,7 +219,7 @@ struct ext4_mb_history {
+ 	__u16 tail;	/* what tail broke some buddy */
+ 	__u16 buddy;	/* buddy the tail ^^^ broke */
+ 	__u16 flags;
+-	__u8 cr:3;	/* which phase the result extent was found at */
++	__u8 cr:8;	/* which phase the result extent was found at */
+ 	__u8 op:4;
+ 	__u8 merged:1;
+ };
diff --git a/ldiskfs/kernel_patches/patches/ext4-mballoc-handle-dev-paths-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-mballoc-handle-dev-paths-rhel5.patch
new file mode 100644
index 0000000..17a5fbd
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-mballoc-handle-dev-paths-rhel5.patch
@@ -0,0 +1,59 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/mballoc.c	2009-05-29 16:32:19.000000000 +0530
++++ linux-2.6.18-128.1.6/fs/ext4/mballoc.c	2009-05-29 16:34:16.000000000 +0530
+@@ -2949,14 +2949,20 @@
+ 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+ 	struct proc_dir_entry *proc;
+ 	struct proc_dir_entry *proc_entry;
+-	char devname[64];
++	char devname[BDEVNAME_SIZE], *p;
+ 
+ 	if (proc_root_ext4 == NULL) {
+ 		sbi->s_mb_proc = NULL;
+ 		return -EINVAL;
+ 	}
+ 	bdevname(sb->s_bdev, devname);
++	p = devname;
++	while ((p = strchr(p, '/')))
++		*p = '!';
++
+ 	sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4);
++	if (!sbi->s_mb_proc)
++		goto err_create_dir;
+ 
+ 	MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats);
+ 	MB_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, max_to_scan);
+@@ -2980,7 +2986,6 @@
+ 	return 0;
+ 
+ err_out:
+-	printk(KERN_ERR "EXT4-fs: Unable to create %s\n", devname);
+ 	remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_LARGE_REQ, sbi->s_mb_proc);
+@@ -2993,18 +2998,23 @@
+ 	remove_proc_entry(devname, proc_root_ext4);
+ 	sbi->s_mb_proc = NULL;
+ 
++err_create_dir:
++	printk(KERN_ERR "EXT4-fs: Unable to create %s\n", devname);
+ 	return -ENOMEM;
+ }
+ 
+ static int ext4_mb_destroy_per_dev_proc(struct super_block *sb)
+ {
+ 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+-	char devname[64];
++	char devname[BDEVNAME_SIZE], *p;
+ 
+ 	if (sbi->s_mb_proc == NULL)
+ 		return -EINVAL;
+ 
+ 	bdevname(sb->s_bdev, devname);
++	p = devname;
++	while ((p = strchr(p, '/')))
++		*p = '!';
+ 	remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_LARGE_REQ, sbi->s_mb_proc);
diff --git a/ldiskfs/kernel_patches/patches/ext4-misc-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-misc-rhel5.patch
new file mode 100644
index 0000000..f8e77c7
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-misc-rhel5.patch
@@ -0,0 +1,271 @@
+Index: linux-2.6.18.i386/fs/ext4/ext4_jbd2.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4_jbd2.h
++++ linux-2.6.18.i386/fs/ext4/ext4_jbd2.h
+@@ -35,6 +35,9 @@
+ 	(EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)	\
+ 		|| test_opt(sb, EXTENTS) ? 27U : 8U)
+ 
++/* Indicate that EXT4_SINGLEDATA_TRANS_BLOCKS takes the sb as argument */
++#define EXT4_SINGLEDATA_TRANS_BLOCKS_HAS_SB
++
+ /* Extended attribute operations touch at most two data buffers,
+  * two bitmap buffers, and two group summaries, in addition to the inode
+  * and the superblock, which are already accounted for. */
+Index: linux-2.6.18.i386/fs/ext4/extents.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/extents.c
++++ linux-2.6.18.i386/fs/ext4/extents.c
+@@ -50,7 +50,7 @@
+  * ext_pblock:
+  * combine low and high parts of physical block number into ext4_fsblk_t
+  */
+-static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
++ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
+ {
+ 	ext4_fsblk_t block;
+ 
+@@ -60,6 +60,17 @@ static ext4_fsblk_t ext_pblock(struct ex
+ }
+ 
+ /*
++ * ext4_ext_store_pblock:
++ * stores a large physical block number into an extent struct,
++ * breaking it into parts
++ */
++void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
++{
++	ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
++	ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
++}
++
++/*
+  * idx_pblock:
+  * combine low and high parts of a leaf physical block number into ext4_fsblk_t
+  */
+@@ -73,17 +84,6 @@ ext4_fsblk_t idx_pblock(struct ext4_exte
+ }
+ 
+ /*
+- * ext4_ext_store_pblock:
+- * stores a large physical block number into an extent struct,
+- * breaking it into parts
+- */
+-void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
+-{
+-	ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
+-	ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
+-}
+-
+-/*
+  * ext4_idx_store_pblock:
+  * stores a large physical block number into an index struct,
+  * breaking it into parts
+@@ -1826,6 +1826,56 @@ static int ext4_ext_rm_idx(handle_t *han
+ }
+ 
+ /*
++ * This routine returns max. credits extent tree can consume.
++ * It should be OK for low-performance paths like ->writepage()
++ * To allow many writing process to fit a single transaction,
++ * caller should calculate credits under truncate_mutex and
++ * pass actual path.
++ */
++int ext4_ext_calc_credits_for_insert(struct inode *inode,
++				    struct ext4_ext_path *path)
++{
++	int depth, needed;
++
++	if (path) {
++		/* probably there is space in leaf? */
++		depth = ext_depth(inode);
++		if (le16_to_cpu(path[depth].p_hdr->eh_entries)
++				< le16_to_cpu(path[depth].p_hdr->eh_max))
++			return 1;
++	}
++
++	/*
++	 * given 32bit logical block (4294967296 blocks), max. tree
++	 * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
++	 * let's also add one more level for imbalance.
++	 */
++	depth = 5;
++
++	/* allocation of new data block(s) */
++	needed = 2;
++
++	/*
++	 * tree can be full, so it'd need to grow in depth:
++	 * we need one credit to modify old root, credits for
++	 * new root will be added in split accounting
++	 */
++	needed += 1;
++
++	/*
++	 * Index split can happen, we'd need:
++	 *    allocate intermediate indexes (bitmap + group)
++	 *  + change two blocks at each level, but root (already included)
++	 */
++	needed += (depth * 2) + (depth * 2);
++
++	/* any allocation modifies superblock */
++	needed += 1;
++
++	return needed;
++}
++
++/*
+  * ext4_ext_calc_credits_for_single_extent:
+  * This routine returns max. credits that needed to insert an extent
+  * to the extent tree.
+@@ -3157,3 +3207,14 @@ int ext4_fiemap(struct inode *inode, str
+ 
+ 	return error;
+ }
++
++EXPORT_SYMBOL(ext4_ext_store_pblock);
++EXPORT_SYMBOL(ext4_ext_search_right);
++EXPORT_SYMBOL(ext4_ext_search_left);
++EXPORT_SYMBOL(ext_pblock);
++EXPORT_SYMBOL(ext4_ext_insert_extent);
++EXPORT_SYMBOL(ext4_mb_new_blocks);
++EXPORT_SYMBOL(ext4_ext_walk_space);
++EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
++EXPORT_SYMBOL(ext4_mark_inode_dirty);
++
+Index: linux-2.6.18.i386/fs/ext4/ext4_extents.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4_extents.h
++++ linux-2.6.18.i386/fs/ext4/ext4_extents.h
+@@ -59,6 +59,11 @@
+  */
+ #define EXT_STATS_
+ 
++/*
++ * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
++ * are now accounted in ext4_ext_calc_credits_for_insert()
++ */
++#define EXT4_ALLOC_NEEDED 0
+ 
+ /*
+  * ext4_inode has i_block array (60 bytes total).
+@@ -124,6 +129,7 @@ struct ext4_ext_path {
+ #define EXT4_EXT_CACHE_GAP	1
+ #define EXT4_EXT_CACHE_EXTENT	2
+ 
++#define EXT4_EXT_HAS_NO_TREE  /* ext4_extents_tree struct is not used*/
+ 
+ #define EXT_MAX_BLOCK	0xffffffff
+ 
+@@ -228,9 +234,13 @@ static inline int ext4_ext_get_actual_le
+ 		(le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
+ }
+ 
++extern ext4_fsblk_t ext_pblock(struct ext4_extent *ex);
++extern void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb);
+ extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
+ extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
+ extern int ext4_extent_tree_init(handle_t *, struct inode *);
++extern int ext4_ext_calc_credits_for_insert(struct inode *,
++					    struct ext4_ext_path *);
+ extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
+ 						   int num,
+ 						   struct ext4_ext_path *path);
+Index: linux-2.6.18.i386/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/mballoc.c
++++ linux-2.6.18.i386/fs/ext4/mballoc.c
+@@ -4965,3 +4965,7 @@ error_return:
+ 		kmem_cache_free(ext4_ac_cachep, ac);
+ 	return;
+ }
++
++EXPORT_SYMBOL(ext4_free_blocks);
++EXPORT_SYMBOL(ext4_mb_discard_inode_preallocations);
++
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -91,6 +91,7 @@ ext4_fsblk_t ext4_inode_bitmap(struct su
+ 		(EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
+ 		(ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
+ }
++EXPORT_SYMBOL(ext4_inode_bitmap);
+ 
+ ext4_fsblk_t ext4_inode_table(struct super_block *sb,
+ 			      struct ext4_group_desc *bg)
+@@ -513,7 +514,8 @@ static void ext4_put_super(struct super_
+ 	struct ext4_super_block *es = sbi->s_es;
+ 	int i;
+ 
+-	ext4_mb_release(sb);
++	if (test_opt(sb, MBALLOC))
++		ext4_mb_release(sb);
+ 	ext4_ext_release(sb);
+ 	ext4_xattr_put_super(sb);
+ 	jbd2_journal_destroy(sbi->s_journal);
+@@ -2373,16 +2375,6 @@ static int ext4_fill_super(struct super_
+ 		       "running e2fsck is recommended\n");
+ 
+ 	/*
+-	 * Since ext4 is still considered development code, we require
+-	 * that the TEST_FILESYS flag in s->flags be set.
+-	 */
+-	if (!(le32_to_cpu(es->s_flags) & EXT2_FLAGS_TEST_FILESYS)) {
+-		printk(KERN_WARNING "EXT4-fs: %s: not marked "
+-		       "OK to use with test code.\n", sb->s_id);
+-		goto failed_mount;
+-	}
+-
+-	/*
+ 	 * Check feature flags regardless of the revision level, since we
+ 	 * previously didn't change the revision level when setting the flags,
+ 	 * so there is a chance incompat flags are set on a rev 0 filesystem.
+@@ -3835,9 +3827,9 @@ static int ext4_get_sb(struct file_syste
+ 	return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super, mnt);
+ }
+ 
+-static struct file_system_type ext4dev_fs_type = {
++static struct file_system_type ext4_fs_type = {
+ 	.owner		= THIS_MODULE,
+-	.name		= "ext4dev",
++	.name		= "ext4",
+ 	.get_sb		= ext4_get_sb,
+ 	.kill_sb	= kill_block_super,
+ #ifdef HAVE_FALLOCATE
+@@ -3867,7 +3859,7 @@ static int __init init_ext4_fs(void)
+ 	err = init_inodecache();
+ 	if (err)
+ 		goto out1;
+-	err = register_filesystem(&ext4dev_fs_type);
++	err = register_filesystem(&ext4_fs_type);
+ 	if (err)
+ 		goto out;
+ 	return 0;
+@@ -3884,7 +3876,7 @@ out3:
+ 
+ static void __exit exit_ext4_fs(void)
+ {
+-	unregister_filesystem(&ext4dev_fs_type);
++	unregister_filesystem(&ext4_fs_type);
+ 	destroy_inodecache();
+ 	exit_ext4_xattr();
+ 	exit_ext4_mballoc();
+Index: linux-2.6.18.i386/fs/ext4/ext4_jbd2.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4_jbd2.c
++++ linux-2.6.18.i386/fs/ext4/ext4_jbd2.c
+@@ -21,6 +21,7 @@ int __ext4_journal_get_write_access(cons
+ 		ext4_journal_abort_handle(where, __func__, bh, handle, err);
+ 	return err;
+ }
++EXPORT_SYMBOL(__ext4_journal_get_write_access);
+ 
+ int __ext4_journal_forget(const char *where, handle_t *handle,
+ 				struct buffer_head *bh)
+@@ -57,3 +58,4 @@ int __ext4_journal_dirty_metadata(const 
+ 		ext4_journal_abort_handle(where, __func__, bh, handle, err);
+ 	return err;
+ }
++EXPORT_SYMBOL(__ext4_journal_dirty_metadata);
diff --git a/ldiskfs/kernel_patches/patches/ext4-misc-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-misc-sles11.patch
new file mode 100644
index 0000000..9899574
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-misc-sles11.patch
@@ -0,0 +1,306 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_jbd2.h	2009-06-02 18:39:19.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.h	2009-06-04 17:01:43.000000000 +0530
+@@ -35,6 +35,9 @@
+ 	(EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)	\
+ 		|| test_opt(sb, EXTENTS) ? 27U : 8U)
+ 
++/* Indicate that EXT4_SINGLEDATA_TRANS_BLOCKS takes the sb as argument */
++#define EXT4_SINGLEDATA_TRANS_BLOCKS_HAS_SB
++
+ /* Extended attribute operations touch at most two data buffers,
+  * two bitmap buffers, and two group summaries, in addition to the inode
+  * and the superblock, which are already accounted for. */
+Index: linux-2.6.27.21-0.1/fs/ext4/extents.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/extents.c	2009-06-04 17:01:43.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/extents.c	2009-06-04 17:01:48.000000000 +0530
+@@ -48,7 +48,7 @@
+  * ext_pblock:
+  * combine low and high parts of physical block number into ext4_fsblk_t
+  */
+-static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
++ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
+ {
+ 	ext4_fsblk_t block;
+ 
+@@ -58,6 +58,17 @@
+ }
+ 
+ /*
++ * ext4_ext_store_pblock:
++ * stores a large physical block number into an extent struct,
++ * breaking it into parts
++ */
++void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
++{
++	ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
++	ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
++}
++
++/*
+  * idx_pblock:
+  * combine low and high parts of a leaf physical block number into ext4_fsblk_t
+  */
+@@ -71,17 +82,6 @@
+ }
+ 
+ /*
+- * ext4_ext_store_pblock:
+- * stores a large physical block number into an extent struct,
+- * breaking it into parts
+- */
+-void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
+-{
+-	ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
+-	ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
+-}
+-
+-/*
+  * ext4_idx_store_pblock:
+  * stores a large physical block number into an index struct,
+  * breaking it into parts
+@@ -1851,6 +1851,56 @@
+ }
+ 
+ /*
++ * This routine returns max. credits extent tree can consume.
++ * It should be OK for low-performance paths like ->writepage()
++ * To allow many writing process to fit a single transaction,
++ * caller should calculate credits under truncate_mutex and
++ * pass actual path.
++ */
++int ext4_ext_calc_credits_for_insert(struct inode *inode,
++				    struct ext4_ext_path *path)
++{
++	int depth, needed;
++
++	if (path) {
++		/* probably there is space in leaf? */
++		depth = ext_depth(inode);
++		if (le16_to_cpu(path[depth].p_hdr->eh_entries)
++				< le16_to_cpu(path[depth].p_hdr->eh_max))
++			return 1;
++	}
++
++	/*
++	 * given 32bit logical block (4294967296 blocks), max. tree
++	 * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
++	 * let's also add one more level for imbalance.
++	 */
++	depth = 5;
++
++	/* allocation of new data block(s) */
++	needed = 2;
++
++	/*
++	 * tree can be full, so it'd need to grow in depth:
++	 * we need one credit to modify old root, credits for
++	 * new root will be added in split accounting
++	 */
++	needed += 1;
++
++	/*
++	 * Index split can happen, we'd need:
++	 *    allocate intermediate indexes (bitmap + group)
++	 *  + change two blocks at each level, but root (already included)
++	 */
++	needed += (depth * 2) + (depth * 2);
++
++	/* any allocation modifies superblock */
++	needed += 1;
++
++	return needed;
++}
++
++/*
+  * ext4_ext_calc_credits_for_single_extent:
+  * This routine returns max. credits that needed to insert an extent
+  * to the extent tree.
+@@ -3170,3 +3220,14 @@
+ 
+ 	return error;
+ }
++
++EXPORT_SYMBOL(ext4_ext_store_pblock);
++EXPORT_SYMBOL(ext4_ext_search_right);
++EXPORT_SYMBOL(ext4_ext_search_left);
++EXPORT_SYMBOL(ext_pblock);
++EXPORT_SYMBOL(ext4_ext_insert_extent);
++EXPORT_SYMBOL(ext4_mb_new_blocks);
++EXPORT_SYMBOL(ext4_ext_walk_space);
++EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
++EXPORT_SYMBOL(ext4_mark_inode_dirty);
++
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_extents.h	2009-06-04 17:01:43.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_extents.h	2009-06-04 17:01:48.000000000 +0530
+@@ -59,6 +59,11 @@
+  */
+ #define EXT_STATS_
+ 
++/*
++ * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
++ * are now accounted in ext4_ext_calc_credits_for_insert()
++ */
++#define EXT4_ALLOC_NEEDED 0
+ 
+ /*
+  * ext4_inode has i_block array (60 bytes total).
+@@ -124,6 +129,7 @@
+ #define EXT4_EXT_CACHE_GAP	1
+ #define EXT4_EXT_CACHE_EXTENT	2
+ 
++#define EXT4_EXT_HAS_NO_TREE  /* ext4_extents_tree struct is not used*/
+ 
+ #define EXT_MAX_BLOCK	0xffffffff
+ 
+@@ -223,10 +229,14 @@
+ 		(le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
+ }
+ 
++extern ext4_fsblk_t ext_pblock(struct ext4_extent *ex);
++extern void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb);
+ extern int ext4_ext_calc_metadata_amount(struct inode *inode, int blocks);
+ extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
+ extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
+ extern int ext4_extent_tree_init(handle_t *, struct inode *);
++extern int ext4_ext_calc_credits_for_insert(struct inode *,
++					    struct ext4_ext_path *);
+ extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
+ 						   int num,
+ 						   struct ext4_ext_path *path);
+Index: linux-2.6.27.21-0.1/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/mballoc.c	2009-06-04 17:01:43.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/mballoc.c	2009-06-04 17:01:43.000000000 +0530
+@@ -4354,6 +4354,13 @@
+ 		kmem_cache_free(ext4_ac_cachep, ac);
+ }
+ 
++/* For backward compatibility, since Lustre uses this symbol */
++void ext4_mb_discard_inode_preallocations(struct inode *inode)
++{
++	ext4_discard_preallocations(inode);
++}
++EXPORT_SYMBOL(ext4_mb_discard_inode_preallocations);
++
+ /*
+  * finds all preallocated spaces and return blocks being freed to them
+  * if preallocated space becomes full (no block is used from the space)
+@@ -5176,3 +5183,6 @@
+ 		kmem_cache_free(ext4_ac_cachep, ac);
+ 	return;
+ }
++
++EXPORT_SYMBOL(ext4_free_blocks);
++
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c	2009-06-04 17:01:43.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/super.c	2009-06-04 17:01:46.000000000 +0530
+@@ -91,6 +91,7 @@
+ 		(EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ?
+ 		(ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
+ }
++EXPORT_SYMBOL(ext4_inode_bitmap);
+ 
+ ext4_fsblk_t ext4_inode_table(struct super_block *sb,
+ 			      struct ext4_group_desc *bg)
+@@ -1295,6 +1296,7 @@
+ 	Opt_stripe, Opt_delalloc, Opt_nodelalloc,
+ 	Opt_inode_readahead_blks, Opt_bigendian_extents,
+ 	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
++	Opt_mballoc
+ };
+ 
+ static const match_table_t tokens = {
+@@ -1356,6 +1358,7 @@
+ 	{Opt_nodelalloc, "nodelalloc"},
+ 	{Opt_inode_readahead_blks, "inode_readahead_blks=%u"},
+ 	{Opt_bigendian_extents, "bigendian_extents"},
++	{Opt_mballoc, "mballoc"},
+ 	{Opt_err, NULL},
+ };
+ 
+@@ -1774,6 +1777,8 @@
+ 		case Opt_bigendian_extents:
+ 			bigendian_extents = 1;
+ 			break;
++		case Opt_mballoc:
++			break;
+ 		default:
+ 			printk(KERN_ERR
+ 			       "EXT4-fs: Unrecognized mount option \"%s\" "
+@@ -4094,7 +4099,7 @@
+ 	.kill_sb	= kill_block_super,
+ 	.fs_flags	= FS_REQUIRES_DEV,
+ };
+-MODULE_ALIAS("ext4dev");
++MODULE_ALIAS("ext4");
+ 
+ static int __init init_ext4_fs(void)
+ {
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_jbd2.c	2009-06-02 18:39:19.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_jbd2.c	2009-06-04 17:01:43.000000000 +0530
+@@ -21,6 +21,7 @@
+ 		ext4_journal_abort_handle(where, __func__, bh, handle, err);
+ 	return err;
+ }
++EXPORT_SYMBOL(__ext4_journal_get_write_access);
+ 
+ int __ext4_journal_forget(const char *where, handle_t *handle,
+ 				struct buffer_head *bh)
+@@ -57,3 +58,4 @@
+ 		ext4_journal_abort_handle(where, __func__, bh, handle, err);
+ 	return err;
+ }
++EXPORT_SYMBOL(__ext4_journal_dirty_metadata);
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4.h	2009-06-04 17:01:43.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/ext4.h	2009-06-04 17:02:07.000000000 +0530
+@@ -26,6 +26,9 @@
+  * The fourth extended filesystem constants/structures
+  */
+ 
++/* Has been moved to linux/magic.h but we need it for Lustre */
++#define EXT4_SUPER_MAGIC	0xEF53
++
+ /*
+  * Define EXT4FS_DEBUG to produce debug messages
+  */
+@@ -400,6 +403,8 @@
+ 	__le32  i_version_hi;	/* high 32 bits for 64-bit version */
+ };
+ 
++/* SLES11 kernel already has 64-bit inode->i_version field */
++#define HAVE_DISK_INODE_VERSION
+ 
+ #define EXT4_EPOCH_BITS 2
+ #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
+@@ -1115,6 +1120,8 @@
+ extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
+ extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
+ 						ext4_group_t, int);
++extern void ext4_mb_discard_inode_preallocations(struct inode *);
++
+ /* inode.c */
+ int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
+ 		struct buffer_head *bh, ext4_fsblk_t blocknr);
+Index: linux-2.6.27.21-0.1/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/inode.c	2009-06-04 17:01:43.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/inode.c	2009-06-04 17:01:43.000000000 +0530
+@@ -4240,6 +4240,7 @@
+ 	iget_failed(inode);
+ 	return ERR_PTR(ret);
+ }
++EXPORT_SYMBOL(ext4_iget);
+ 
+ static int ext4_inode_blocks_set(handle_t *handle,
+ 				struct ext4_inode *raw_inode,
diff --git a/ldiskfs/kernel_patches/patches/ext4-mmp-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-mmp-rhel5.patch
new file mode 100644
index 0000000..d01d046
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-mmp-rhel5.patch
@@ -0,0 +1,479 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/super.c
++++ linux-2.6.18-128.1.6/fs/ext4/super.c
+@@ -36,6 +36,8 @@
+ #include <linux/log2.h>
+ #include <linux/crc16.h>
+ #include <asm/uaccess.h>
++#include <linux/kthread.h>
++#include <linux/utsname.h>
+ 
+ #include "ext4.h"
+ #include "ext4_jbd2.h"
+@@ -547,6 +549,8 @@ static void ext4_put_super(struct super_
+ 		invalidate_bdev(sbi->journal_bdev, 0);
+ 		ext4_blkdev_remove(sbi);
+ 	}
++	if (sbi->s_mmp_tsk)
++		kthread_stop(sbi->s_mmp_tsk);
+ 	sb->s_fs_info = NULL;
+ 	kfree(sbi);
+ 	return;
+@@ -766,6 +770,328 @@ static int ext4_show_options(struct seq_
+ 	return 0;
+ }
+ 
++/*
++ * Write the MMP block using WRITE_SYNC to try to get the block on-disk
++ * faster.
++ */
++static int write_mmp_block(struct buffer_head *bh)
++{
++	mark_buffer_dirty(bh);
++	lock_buffer(bh);
++	bh->b_end_io = end_buffer_write_sync;
++	get_bh(bh);
++	submit_bh(WRITE_SYNC, bh);
++	wait_on_buffer(bh);
++	if (unlikely(!buffer_uptodate(bh)))
++		return 1;
++
++	return 0;
++}
++
++/*
++ * Read the MMP block. It _must_ be read from disk and hence we clear the
++ * uptodate flag on the buffer.
++ */
++static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
++			  unsigned long mmp_block)
++{
++	struct mmp_struct *mmp;
++
++	if (*bh)
++		clear_buffer_uptodate(*bh);
++
++#if 0
++	brelse(*bh);
++
++	*bh = sb_bread(sb, mmp_block);
++#else
++	if (!*bh)
++		*bh = sb_getblk(sb, mmp_block);
++	if (*bh) {
++		get_bh(*bh);
++		lock_buffer(*bh);
++		(*bh)->b_end_io = end_buffer_read_sync;
++		submit_bh(READ_SYNC, *bh);
++		wait_on_buffer(*bh);
++		if (!buffer_uptodate(*bh)) {
++			brelse(*bh);
++			*bh = NULL;
++		}
++	}
++#endif
++	if (!*bh) {
++		ext4_warning(sb, __FUNCTION__,
++			     "Error while reading MMP block %lu", mmp_block);
++		return -EIO;
++	}
++
++	mmp = (struct mmp_struct *)((*bh)->b_data);
++	if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC)
++		return -EINVAL;
++
++	return 0;
++}
++
++/*
++ * Dump as much information as possible to help the admin.
++ */
++static void dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
++			 const char *function, const char *msg)
++{
++	ext4_warning(sb, function, msg);
++	ext4_warning(sb, function, "MMP failure info: last update time: %llu, "
++		     "last update node: %s, last update device: %s\n",
++		     le64_to_cpu(mmp->mmp_time), mmp->mmp_nodename,
++		     mmp->mmp_bdevname);
++}
++
++/*
++ * kmmpd will update the MMP sequence every s_mmp_update_interval seconds
++ */
++static int kmmpd(void *data)
++{
++	struct super_block *sb = (struct super_block *) data;
++	struct ext4_super_block *es = EXT4_SB(sb)->s_es;
++	struct buffer_head *bh = NULL;
++	struct mmp_struct *mmp;
++	unsigned long mmp_block;
++	u32 seq = 0;
++	unsigned long failed_writes = 0;
++	int mmp_update_interval = le16_to_cpu(es->s_mmp_update_interval);
++	unsigned mmp_check_interval;
++	unsigned long last_update_time;
++	unsigned long diff;
++	int retval;
++
++	mmp_block = le64_to_cpu(es->s_mmp_block);
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++
++	mmp = (struct mmp_struct *)(bh->b_data);
++	mmp->mmp_time = cpu_to_le64(get_seconds());
++	/*
++	 * Start with the higher mmp_check_interval and reduce it if
++	 * the MMP block is being updated on time.
++	 */
++	mmp_check_interval = max(5 * mmp_update_interval,
++				 EXT4_MMP_MIN_CHECK_INTERVAL);
++	mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval);
++	bdevname(bh->b_bdev, mmp->mmp_bdevname);
++
++	down_read(&uts_sem);
++	memcpy(mmp->mmp_nodename, system_utsname.nodename,
++	       sizeof(mmp->mmp_nodename));
++	up_read(&uts_sem);
++
++	while (!kthread_should_stop()) {
++		if (++seq > EXT4_MMP_SEQ_MAX)
++			seq = 1;
++
++		mmp->mmp_seq = cpu_to_le32(seq);
++		mmp->mmp_time = cpu_to_le64(get_seconds());
++		last_update_time = jiffies;
++
++		retval = write_mmp_block(bh);
++		/*
++		 * Don't spew too many error messages. Print one every
++		 * (s_mmp_update_interval * 60) seconds.
++		 */
++		if (retval && (failed_writes % 60) == 0) {
++			ext4_error(sb, __FUNCTION__,
++				   "Error writing to MMP block");
++			failed_writes++;
++		}
++
++		if (!(le32_to_cpu(es->s_feature_incompat) &
++		    EXT4_FEATURE_INCOMPAT_MMP)) {
++			ext4_warning(sb, __FUNCTION__, "kmmpd being stopped "
++				     "since MMP feature has been disabled.");
++			EXT4_SB(sb)->s_mmp_tsk = 0;
++			goto failed;
++		}
++
++		if (sb->s_flags & MS_RDONLY) {
++			ext4_warning(sb, __FUNCTION__, "kmmpd being stopped "
++				     "since filesystem has been remounted as "
++				     "readonly.");
++			EXT4_SB(sb)->s_mmp_tsk = 0;
++			goto failed;
++		}
++
++		diff = jiffies - last_update_time;
++		if (diff < mmp_update_interval * HZ)
++			schedule_timeout_interruptible(EXT4_MMP_UPDATE_INTERVAL*
++						       HZ - diff);
++
++		/*
++		 * We need to make sure that more than mmp_check_interval
++		 * seconds have not passed since writing. If that has happened
++		 * we need to check if the MMP block is as we left it.
++		 */
++		diff = jiffies - last_update_time;
++		if (diff > mmp_check_interval * HZ) {
++			struct buffer_head *bh_check = NULL;
++			struct mmp_struct *mmp_check;
++
++			retval = read_mmp_block(sb, &bh_check, mmp_block);
++			if (retval) {
++				EXT4_SB(sb)->s_mmp_tsk = 0;
++				goto failed;
++			}
++
++			mmp_check = (struct mmp_struct *)(bh_check->b_data);
++			if (mmp->mmp_time != mmp_check->mmp_time ||
++			    memcmp(mmp->mmp_nodename, mmp_check->mmp_nodename,
++				   sizeof(mmp->mmp_nodename)))
++				dump_mmp_msg(sb, mmp_check, __FUNCTION__,
++					     "Error while updating MMP info. "
++					     "The filesystem seems to have "
++					     "been multiply mounted.");
++
++			put_bh(bh_check);
++		}
++
++		/*
++		 * Adjust the mmp_check_interval depending on how much time
++		 * it took for the MMP block to be written.
++		 */
++		mmp_check_interval = max(5 * diff / HZ,
++				 (unsigned long) EXT4_MMP_MIN_CHECK_INTERVAL);
++		mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval);
++	}
++
++	/*
++	 * Unmount seems to be clean.
++	 */
++	mmp->mmp_seq = cpu_to_le32(EXT4_MMP_SEQ_CLEAN);
++	mmp->mmp_time = cpu_to_le64(get_seconds());
++
++	retval = write_mmp_block(bh);
++
++failed:
++	brelse(bh);
++	return retval;
++}
++
++/*
++ * Get a random new sequence number but make sure it is not greater than
++ * EXT4_MMP_SEQ_MAX.
++ */
++static unsigned int mmp_new_seq(void)
++{
++	u32 new_seq;
++
++	do {
++		get_random_bytes(&new_seq, sizeof(u32));
++	} while (new_seq > EXT4_MMP_SEQ_MAX);
++
++	return new_seq;
++}
++
++/*
++ * Protect the filesystem from being mounted more than once.
++ */
++static int ext4_multi_mount_protect(struct super_block *sb,
++				    unsigned long mmp_block)
++{
++	struct ext4_super_block *es = EXT4_SB(sb)->s_es;
++	struct buffer_head *bh = NULL;
++	struct mmp_struct *mmp = NULL;
++	u32 seq;
++	unsigned int mmp_check_interval = le16_to_cpu(es->s_mmp_update_interval);
++	int retval;
++
++	if (mmp_block < le32_to_cpu(es->s_first_data_block) ||
++	    mmp_block >= ext4_blocks_count(es)) {
++		ext4_warning(sb, __FUNCTION__,
++			     "Invalid MMP block in superblock");
++		goto failed;
++	}
++
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++
++	mmp = (struct mmp_struct *)(bh->b_data);
++
++	if (mmp_check_interval < EXT4_MMP_MIN_CHECK_INTERVAL)
++		mmp_check_interval = EXT4_MMP_MIN_CHECK_INTERVAL;
++
++	/*
++	 * If check_interval in MMP block is larger, use that instead of
++	 * update_interval from the superblock.
++	 */
++	if (mmp->mmp_check_interval > mmp_check_interval)
++		mmp_check_interval = mmp->mmp_check_interval;
++
++	seq = le32_to_cpu(mmp->mmp_seq);
++	if (seq == EXT4_MMP_SEQ_CLEAN)
++		goto skip;
++
++	if (seq == EXT4_MMP_SEQ_FSCK) {
++		dump_mmp_msg(sb, mmp, __FUNCTION__,
++			     "fsck is running on the filesystem");
++		goto failed;
++	}
++
++	schedule_timeout_uninterruptible(HZ * (2 * mmp_check_interval + 1));
++
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++	mmp = (struct mmp_struct *)(bh->b_data);
++	if (seq != le32_to_cpu(mmp->mmp_seq)) {
++		dump_mmp_msg(sb, mmp, __FUNCTION__,
++			     "Device is already active on another node.");
++		goto failed;
++	}
++
++skip:
++	/*
++	 * write a new random sequence number.
++	 */
++	mmp->mmp_seq = seq = cpu_to_le32(mmp_new_seq());
++
++	retval = write_mmp_block(bh);
++	if (retval)
++		goto failed;
++
++	/*
++	 * wait for MMP interval and check mmp_seq.
++	 */
++	schedule_timeout_uninterruptible(HZ * (2 * mmp_check_interval + 1));
++
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++	mmp = (struct mmp_struct *)(bh->b_data);
++	if (seq != le32_to_cpu(mmp->mmp_seq)) {
++		dump_mmp_msg(sb, mmp, __FUNCTION__,
++			     "Device is already active on another node.");
++		goto failed;
++	}
++
++	/*
++	 * Start a kernel thread to update the MMP block periodically.
++	 */
++	EXT4_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, sb, "kmmpd-%02x:%02x",
++					     MAJOR(sb->s_dev),
++					     MINOR(sb->s_dev));
++	if (IS_ERR(EXT4_SB(sb)->s_mmp_tsk)) {
++		EXT4_SB(sb)->s_mmp_tsk = 0;
++		ext4_warning(sb, __FUNCTION__, "Unable to create kmmpd thread "
++			     "for %s.", sb->s_id);
++		goto failed;
++	}
++
++	brelse(bh);
++	return 0;
++
++failed:
++	brelse(bh);
++	return 1;
++}
+ 
+ static struct dentry *ext4_get_dentry(struct super_block *sb, void *vobjp)
+ {
+@@ -775,7 +1101,6 @@ static struct dentry *ext4_get_dentry(st
+ 	struct inode *inode;
+ 	struct dentry *result;
+ 
+-
+ 	if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
+ 		return ERR_PTR(-ESTALE);
+ 	if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))
+@@ -2258,6 +2583,11 @@ static int ext4_fill_super(struct super_
+ 			  EXT4_HAS_INCOMPAT_FEATURE(sb,
+ 				    EXT4_FEATURE_INCOMPAT_RECOVER));
+ 
++	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) &&
++	    !(sb->s_flags & MS_RDONLY))
++		if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
++			goto failed_mount3;
++
+ 	/*
+ 	 * The first inode we look at is the journal inode.  Don't try
+ 	 * root first: it may be modified in the journal!
+@@ -2445,6 +2775,8 @@ failed_mount3:
+ 	percpu_counter_destroy(&sbi->s_freeblocks_counter);
+ 	percpu_counter_destroy(&sbi->s_freeinodes_counter);
+ 	percpu_counter_destroy(&sbi->s_dirs_counter);
++	if (sbi->s_mmp_tsk)
++		kthread_stop(sbi->s_mmp_tsk);
+ failed_mount2:
+ 	for (i = 0; i < db_count; i++)
+ 		brelse(sbi->s_group_desc[i]);
+@@ -2918,7 +3250,7 @@ static int ext4_remount(struct super_blo
+ 	unsigned long old_sb_flags;
+ 	struct ext4_mount_options old_opts;
+ 	ext4_group_t g;
+-	int err;
++	int err = 0;
+ #ifdef CONFIG_QUOTA
+ 	int i;
+ #endif
+@@ -3042,6 +3374,13 @@ static int ext4_remount(struct super_blo
+ 				goto restore_opts;
+ 			if (!ext4_setup_super(sb, es, 0))
+ 				sb->s_flags &= ~MS_RDONLY;
++			if (EXT4_HAS_INCOMPAT_FEATURE(sb,
++						    EXT4_FEATURE_INCOMPAT_MMP))
++				if (ext4_multi_mount_protect(sb,
++						le64_to_cpu(es->s_mmp_block))) {
++					err = -EROFS;
++					goto restore_opts;
++				}
+ 		}
+ 	}
+ #ifdef CONFIG_QUOTA
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4.h
+@@ -658,7 +658,7 @@ struct ext4_super_block {
+ 	__le16	s_want_extra_isize; 	/* New inodes should reserve # bytes */
+ 	__le32	s_flags;		/* Miscellaneous flags */
+ 	__le16  s_raid_stride;		/* RAID stride */
+-	__le16  s_mmp_interval;         /* # seconds to wait in MMP checking */
++	__le16  s_mmp_update_interval;  /* # seconds to wait in MMP checking */
+ 	__le64  s_mmp_block;            /* Block for multi-mount protection */
+ 	__le32  s_raid_stripe_width;    /* blocks on all data disks (N*stride)*/
+ 	__u8	s_log_groups_per_flex;  /* FLEX_BG group size */
+@@ -775,7 +775,8 @@ static inline int ext4_valid_inum(struct
+ 					 EXT4_FEATURE_INCOMPAT_META_BG| \
+ 					 EXT4_FEATURE_INCOMPAT_EXTENTS| \
+ 					 EXT4_FEATURE_INCOMPAT_64BIT| \
+-					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
++					 EXT4_FEATURE_INCOMPAT_FLEX_BG| \
++					 EXT4_FEATURE_INCOMPAT_MMP)
+ #define EXT4_FEATURE_RO_COMPAT_SUPP	(EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+ 					 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
+ 					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
+@@ -956,6 +957,39 @@ void ext4_get_group_no_and_offset(struct
+ 			unsigned long *blockgrpp, ext4_grpblk_t *offsetp);
+ 
+ /*
++ * This structure will be used for multiple mount protection. It will be
++ * written into the block number saved in the s_mmp_block field in the
++ * superblock. Programs that check MMP should assume that if
++ * SEQ_FSCK (or any unknown code above SEQ_MAX) is present then it is NOT safe
++ * to use the filesystem, regardless of how old the timestamp is.
++ */
++#define EXT4_MMP_MAGIC     0x004D4D50U /* ASCII for MMP */
++#define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */
++#define EXT4_MMP_SEQ_FSCK  0xE24D4D50U /* mmp_seq value when being fscked */
++#define EXT4_MMP_SEQ_MAX   0xE24D4D4FU /* maximum valid mmp_seq value */
++
++struct mmp_struct {
++	__le32	mmp_magic;
++	__le32	mmp_seq;
++	__le64	mmp_time;
++	char	mmp_nodename[64];
++	char	mmp_bdevname[32];
++	__le16	mmp_check_interval;
++	__le16	mmp_pad1;
++	__le32	mmp_pad2[227];
++};
++
++/*
++ * Default interval in seconds to update the MMP sequence number.
++ */
++#define EXT4_MMP_UPDATE_INTERVAL   1
++
++/*
++ * Minimum interval for MMP checking in seconds.
++ */
++#define EXT4_MMP_MIN_CHECK_INTERVAL	5
++
++/*
+  * Function prototypes
+  */
+ 
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4_sb.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4_sb.h
+@@ -148,6 +148,8 @@ struct ext4_sb_info {
+ 
+ 	unsigned int s_log_groups_per_flex;
+ 	struct flex_groups *s_flex_groups;
++
++	struct task_struct *s_mmp_tsk;  /* Kernel thread for multiple mount protection */
+ };
+ 
+ #endif	/* _EXT4_SB */
diff --git a/ldiskfs/kernel_patches/patches/ext4-mmp-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-mmp-sles11.patch
new file mode 100644
index 0000000..827cbae
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-mmp-sles11.patch
@@ -0,0 +1,481 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -39,6 +39,8 @@
+ #include <linux/log2.h>
+ #include <linux/crc16.h>
+ #include <asm/uaccess.h>
++#include <linux/kthread.h>
++#include <linux/utsname.h>
+ 
+ #include "ext4.h"
+ #include "ext4_jbd2.h"
+@@ -598,6 +600,8 @@ static void ext4_put_super(struct super_
+ 		invalidate_bdev(sbi->journal_bdev);
+ 		ext4_blkdev_remove(sbi);
+ 	}
++	if (sbi->s_mmp_tsk)
++		kthread_stop(sbi->s_mmp_tsk);
+ 	sb->s_fs_info = NULL;
+ 	kfree(sbi);
+ 	return;
+@@ -806,7 +810,6 @@ static int ext4_show_options(struct seq_
+ 	if (!test_opt(sb, DELALLOC))
+ 		seq_puts(seq, ",nodelalloc");
+ 
+-
+ 	if (sbi->s_stripe)
+ 		seq_printf(seq, ",stripe=%lu", sbi->s_stripe);
+ 	/*
+@@ -829,6 +832,330 @@ static int ext4_show_options(struct seq_
+ }
+ 
+ 
++
++/*
++ * Write the MMP block using WRITE_SYNC to try to get the block on-disk
++ * faster.
++ */
++static int write_mmp_block(struct buffer_head *bh)
++{
++	mark_buffer_dirty(bh);
++	lock_buffer(bh);
++	bh->b_end_io = end_buffer_write_sync;
++	get_bh(bh);
++	submit_bh(WRITE_SYNC, bh);
++	wait_on_buffer(bh);
++	if (unlikely(!buffer_uptodate(bh)))
++		return 1;
++
++	return 0;
++}
++
++/*
++ * Read the MMP block. It _must_ be read from disk and hence we clear the
++ * uptodate flag on the buffer.
++ */
++static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
++			  unsigned long mmp_block)
++{
++	struct mmp_struct *mmp;
++
++	if (*bh)
++		clear_buffer_uptodate(*bh);
++
++#if 0
++	brelse(*bh);
++
++	*bh = sb_bread(sb, mmp_block);
++#else
++	if (!*bh)
++		*bh = sb_getblk(sb, mmp_block);
++	if (*bh) {
++		get_bh(*bh);
++		lock_buffer(*bh);
++		(*bh)->b_end_io = end_buffer_read_sync;
++		submit_bh(READ_SYNC, *bh);
++		wait_on_buffer(*bh);
++		if (!buffer_uptodate(*bh)) {
++			brelse(*bh);
++			*bh = NULL;
++		}
++	}
++#endif
++	if (!*bh) {
++		ext4_warning(sb, __FUNCTION__,
++			     "Error while reading MMP block %lu", mmp_block);
++		return -EIO;
++	}
++
++	mmp = (struct mmp_struct *)((*bh)->b_data);
++	if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC)
++		return -EINVAL;
++
++	return 0;
++}
++
++/*
++ * Dump as much information as possible to help the admin.
++ */
++static void dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
++			 const char *function, const char *msg)
++{
++	ext4_warning(sb, function, msg);
++	ext4_warning(sb, function, "MMP failure info: last update time: %llu, "
++		     "last update node: %s, last update device: %s\n",
++		     le64_to_cpu(mmp->mmp_time), mmp->mmp_nodename,
++		     mmp->mmp_bdevname);
++}
++
++/*
++ * kmmpd will update the MMP sequence every s_mmp_update_interval seconds
++ */
++static int kmmpd(void *data)
++{
++	struct super_block *sb = (struct super_block *) data;
++	struct ext4_super_block *es = EXT4_SB(sb)->s_es;
++	struct buffer_head *bh = NULL;
++	struct mmp_struct *mmp;
++	unsigned long mmp_block;
++	u32 seq = 0;
++	unsigned long failed_writes = 0;
++	int mmp_update_interval = le16_to_cpu(es->s_mmp_update_interval);
++	unsigned mmp_check_interval;
++	unsigned long last_update_time;
++	unsigned long diff;
++	int retval;
++
++	mmp_block = le64_to_cpu(es->s_mmp_block);
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++
++	mmp = (struct mmp_struct *)(bh->b_data);
++	mmp->mmp_time = cpu_to_le64(get_seconds());
++	/*
++	 * Start with the higher mmp_check_interval and reduce it if
++	 * the MMP block is being updated on time.
++	 */
++	mmp_check_interval = max(5 * mmp_update_interval,
++				 EXT4_MMP_MIN_CHECK_INTERVAL);
++	mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval);
++	bdevname(bh->b_bdev, mmp->mmp_bdevname);
++
++	down_read(&uts_sem);
++	memcpy(mmp->mmp_nodename, init_utsname()->sysname,
++	       sizeof(mmp->mmp_nodename));
++	up_read(&uts_sem);
++
++	while (!kthread_should_stop()) {
++		if (++seq > EXT4_MMP_SEQ_MAX)
++			seq = 1;
++
++		mmp->mmp_seq = cpu_to_le32(seq);
++		mmp->mmp_time = cpu_to_le64(get_seconds());
++		last_update_time = jiffies;
++
++		retval = write_mmp_block(bh);
++		/*
++		 * Don't spew too many error messages. Print one every
++		 * (s_mmp_update_interval * 60) seconds.
++		 */
++		if (retval && (failed_writes % 60) == 0) {
++			ext4_error(sb, __FUNCTION__,
++				   "Error writing to MMP block");
++			failed_writes++;
++		}
++
++		if (!(le32_to_cpu(es->s_feature_incompat) &
++		    EXT4_FEATURE_INCOMPAT_MMP)) {
++			ext4_warning(sb, __FUNCTION__, "kmmpd being stopped "
++				     "since MMP feature has been disabled.");
++			EXT4_SB(sb)->s_mmp_tsk = 0;
++			goto failed;
++		}
++
++		if (sb->s_flags & MS_RDONLY) {
++			ext4_warning(sb, __FUNCTION__, "kmmpd being stopped "
++				     "since filesystem has been remounted as "
++				     "readonly.");
++			EXT4_SB(sb)->s_mmp_tsk = 0;
++			goto failed;
++		}
++
++		diff = jiffies - last_update_time;
++		if (diff < mmp_update_interval * HZ)
++			schedule_timeout_interruptible(EXT4_MMP_UPDATE_INTERVAL*
++						       HZ - diff);
++
++		/*
++		 * We need to make sure that more than mmp_check_interval
++		 * seconds have not passed since writing. If that has happened
++		 * we need to check if the MMP block is as we left it.
++		 */
++		diff = jiffies - last_update_time;
++		if (diff > mmp_check_interval * HZ) {
++			struct buffer_head *bh_check = NULL;
++			struct mmp_struct *mmp_check;
++
++			retval = read_mmp_block(sb, &bh_check, mmp_block);
++			if (retval) {
++				EXT4_SB(sb)->s_mmp_tsk = 0;
++				goto failed;
++			}
++
++			mmp_check = (struct mmp_struct *)(bh_check->b_data);
++			if (mmp->mmp_time != mmp_check->mmp_time ||
++			    memcmp(mmp->mmp_nodename, mmp_check->mmp_nodename,
++				   sizeof(mmp->mmp_nodename)))
++				dump_mmp_msg(sb, mmp_check, __FUNCTION__,
++					     "Error while updating MMP info. "
++					     "The filesystem seems to have "
++					     "been multiply mounted.");
++
++			put_bh(bh_check);
++		}
++
++		/*
++		 * Adjust the mmp_check_interval depending on how much time
++		 * it took for the MMP block to be written.
++		 */
++		mmp_check_interval = max(5 * diff / HZ,
++				 (unsigned long) EXT4_MMP_MIN_CHECK_INTERVAL);
++		mmp->mmp_check_interval = cpu_to_le16(mmp_check_interval);
++	}
++
++	/*
++	 * Unmount seems to be clean.
++	 */
++	mmp->mmp_seq = cpu_to_le32(EXT4_MMP_SEQ_CLEAN);
++	mmp->mmp_time = cpu_to_le64(get_seconds());
++
++	retval = write_mmp_block(bh);
++
++failed:
++	brelse(bh);
++	return retval;
++}
++
++/*
++ * Get a random new sequence number but make sure it is not greater than
++ * EXT4_MMP_SEQ_MAX.
++ */
++static unsigned int mmp_new_seq(void)
++{
++	u32 new_seq;
++
++	do {
++		get_random_bytes(&new_seq, sizeof(u32));
++	} while (new_seq > EXT4_MMP_SEQ_MAX);
++
++	return new_seq;
++}
++
++/*
++ * Protect the filesystem from being mounted more than once.
++ */
++static int ext4_multi_mount_protect(struct super_block *sb,
++				    unsigned long mmp_block)
++{
++	struct ext4_super_block *es = EXT4_SB(sb)->s_es;
++	struct buffer_head *bh = NULL;
++	struct mmp_struct *mmp = NULL;
++	u32 seq;
++	unsigned int mmp_check_interval = le16_to_cpu(es->s_mmp_update_interval);
++	int retval;
++
++	if (mmp_block < le32_to_cpu(es->s_first_data_block) ||
++	    mmp_block >= ext4_blocks_count(es)) {
++		ext4_warning(sb, __FUNCTION__,
++			     "Invalid MMP block in superblock");
++		goto failed;
++	}
++
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++
++	mmp = (struct mmp_struct *)(bh->b_data);
++
++	if (mmp_check_interval < EXT4_MMP_MIN_CHECK_INTERVAL)
++		mmp_check_interval = EXT4_MMP_MIN_CHECK_INTERVAL;
++
++	/*
++	 * If check_interval in MMP block is larger, use that instead of
++	 * update_interval from the superblock.
++	 */
++	if (mmp->mmp_check_interval > mmp_check_interval)
++		mmp_check_interval = mmp->mmp_check_interval;
++
++	seq = le32_to_cpu(mmp->mmp_seq);
++	if (seq == EXT4_MMP_SEQ_CLEAN)
++		goto skip;
++
++	if (seq == EXT4_MMP_SEQ_FSCK) {
++		dump_mmp_msg(sb, mmp, __FUNCTION__,
++			     "fsck is running on the filesystem");
++		goto failed;
++	}
++
++	schedule_timeout_uninterruptible(HZ * (2 * mmp_check_interval + 1));
++
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++	mmp = (struct mmp_struct *)(bh->b_data);
++	if (seq != le32_to_cpu(mmp->mmp_seq)) {
++		dump_mmp_msg(sb, mmp, __FUNCTION__,
++			     "Device is already active on another node.");
++		goto failed;
++	}
++
++skip:
++	/*
++	 * write a new random sequence number.
++	 */
++	mmp->mmp_seq = seq = cpu_to_le32(mmp_new_seq());
++
++	retval = write_mmp_block(bh);
++	if (retval)
++		goto failed;
++
++	/*
++	 * wait for MMP interval and check mmp_seq.
++	 */
++	schedule_timeout_uninterruptible(HZ * (2 * mmp_check_interval + 1));
++
++	retval = read_mmp_block(sb, &bh, mmp_block);
++	if (retval)
++		goto failed;
++	mmp = (struct mmp_struct *)(bh->b_data);
++	if (seq != le32_to_cpu(mmp->mmp_seq)) {
++		dump_mmp_msg(sb, mmp, __FUNCTION__,
++			     "Device is already active on another node.");
++		goto failed;
++	}
++
++	/*
++	 * Start a kernel thread to update the MMP block periodically.
++	 */
++	EXT4_SB(sb)->s_mmp_tsk = kthread_run(kmmpd, sb, "kmmpd-%02x:%02x",
++					     MAJOR(sb->s_dev),
++					     MINOR(sb->s_dev));
++	if (IS_ERR(EXT4_SB(sb)->s_mmp_tsk)) {
++		EXT4_SB(sb)->s_mmp_tsk = 0;
++		ext4_warning(sb, __FUNCTION__, "Unable to create kmmpd thread "
++			     "for %s.", sb->s_id);
++		goto failed;
++	}
++
++	brelse(bh);
++	return 0;
++
++failed:
++	brelse(bh);
++	return 1;
++}
++
+ static struct inode *ext4_nfs_get_inode(struct super_block *sb,
+ 		u64 ino, u32 generation)
+ {
+@@ -2366,6 +2693,11 @@ static int ext4_fill_super(struct super_
+ 			  EXT4_HAS_INCOMPAT_FEATURE(sb,
+ 				    EXT4_FEATURE_INCOMPAT_RECOVER));
+ 
++	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_MMP) &&
++	    !(sb->s_flags & MS_RDONLY))
++		if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block)))
++			goto failed_mount3;
++
+ 	/*
+ 	 * The first inode we look at is the journal inode.  Don't try
+ 	 * root first: it may be modified in the journal!
+@@ -2566,6 +2898,8 @@ failed_mount3:
+ 	percpu_counter_destroy(&sbi->s_freeinodes_counter);
+ 	percpu_counter_destroy(&sbi->s_dirs_counter);
+ 	percpu_counter_destroy(&sbi->s_dirtyblocks_counter);
++	if (sbi->s_mmp_tsk)
++		kthread_stop(sbi->s_mmp_tsk);
+ failed_mount2:
+ 	for (i = 0; i < db_count; i++)
+ 		brelse(sbi->s_group_desc[i]);
+@@ -3080,7 +3414,7 @@ static int ext4_remount(struct super_blo
+ 	unsigned long old_sb_flags;
+ 	struct ext4_mount_options old_opts;
+ 	ext4_group_t g;
+-	int err;
++	int err = 0;
+ #ifdef CONFIG_QUOTA
+ 	int i;
+ #endif
+@@ -3205,6 +3539,13 @@ static int ext4_remount(struct super_blo
+ 				goto restore_opts;
+ 			if (!ext4_setup_super(sb, es, 0))
+ 				sb->s_flags &= ~MS_RDONLY;
++			if (EXT4_HAS_INCOMPAT_FEATURE(sb,
++						    EXT4_FEATURE_INCOMPAT_MMP))
++				if (ext4_multi_mount_protect(sb,
++						le64_to_cpu(es->s_mmp_block))) {
++					err = -EROFS;
++					goto restore_opts;
++				}
+ 		}
+ 	}
+ #ifdef CONFIG_QUOTA
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4.h
+@@ -660,7 +660,7 @@ struct ext4_super_block {
+ 	__le16	s_want_extra_isize; 	/* New inodes should reserve # bytes */
+ 	__le32	s_flags;		/* Miscellaneous flags */
+ 	__le16  s_raid_stride;		/* RAID stride */
+-	__le16  s_mmp_interval;         /* # seconds to wait in MMP checking */
++	__le16  s_mmp_update_interval;  /* # seconds to wait in MMP checking */
+ 	__le64  s_mmp_block;            /* Block for multi-mount protection */
+ 	__le32  s_raid_stripe_width;    /* blocks on all data disks (N*stride)*/
+ 	__u8	s_log_groups_per_flex;  /* FLEX_BG group size */
+@@ -777,7 +777,8 @@ static inline int ext4_valid_inum(struct
+ 					 EXT4_FEATURE_INCOMPAT_META_BG| \
+ 					 EXT4_FEATURE_INCOMPAT_EXTENTS| \
+ 					 EXT4_FEATURE_INCOMPAT_64BIT| \
+-					 EXT4_FEATURE_INCOMPAT_FLEX_BG)
++					 EXT4_FEATURE_INCOMPAT_FLEX_BG| \
++					 EXT4_FEATURE_INCOMPAT_MMP)
+ #define EXT4_FEATURE_RO_COMPAT_SUPP	(EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \
+ 					 EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \
+ 					 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
+@@ -981,6 +982,39 @@ do {									\
+ #endif
+ 
+ /*
++ * This structure will be used for multiple mount protection. It will be
++ * written into the block number saved in the s_mmp_block field in the
++ * superblock. Programs that check MMP should assume that if
++ * SEQ_FSCK (or any unknown code above SEQ_MAX) is present then it is NOT safe
++ * to use the filesystem, regardless of how old the timestamp is.
++ */
++#define EXT4_MMP_MAGIC     0x004D4D50U /* ASCII for MMP */
++#define EXT4_MMP_SEQ_CLEAN 0xFF4D4D50U /* mmp_seq value for clean unmount */
++#define EXT4_MMP_SEQ_FSCK  0xE24D4D50U /* mmp_seq value when being fscked */
++#define EXT4_MMP_SEQ_MAX   0xE24D4D4FU /* maximum valid mmp_seq value */
++
++struct mmp_struct {
++	__le32	mmp_magic;
++	__le32	mmp_seq;
++	__le64	mmp_time;
++	char	mmp_nodename[64];
++	char	mmp_bdevname[32];
++	__le16	mmp_check_interval;
++	__le16	mmp_pad1;
++	__le32	mmp_pad2[227];
++};
++
++/*
++ * Default interval in seconds to update the MMP sequence number.
++ */
++#define EXT4_MMP_UPDATE_INTERVAL   1
++
++/*
++ * Minimum interval for MMP checking in seconds.
++ */
++#define EXT4_MMP_MIN_CHECK_INTERVAL	5
++
++/*
+  * Function prototypes
+  */
+ 
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_sb.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h
+@@ -150,6 +150,8 @@ struct ext4_sb_info {
+ 
+ 	unsigned int s_log_groups_per_flex;
+ 	struct flex_groups *s_flex_groups;
++
++	struct task_struct *s_mmp_tsk;  /* Kernel thread for multiple mount protection */
+ };
+ 
+ #endif	/* _EXT4_SB */
diff --git a/ldiskfs/kernel_patches/patches/ext4-pa_lock-typo.patch b/ldiskfs/kernel_patches/patches/ext4-pa_lock-typo.patch
new file mode 100644
index 0000000..6c10882
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-pa_lock-typo.patch
@@ -0,0 +1,13 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/mballoc.c
++++ linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+@@ -4507,7 +4507,7 @@ static void ext4_mb_add_n_trim(struct ex
+ 						pa_inode_list) {
+ 		spin_lock(&tmp_pa->pa_lock);
+ 		if (tmp_pa->pa_deleted) {
+-			spin_unlock(&pa->pa_lock);
++			spin_unlock(&tmp_pa->pa_lock);
+ 			continue;
+ 		}
+ 		if (!added && pa->pa_free < tmp_pa->pa_free) {
diff --git a/ldiskfs/kernel_patches/patches/ext4-prealloc-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-prealloc-rhel5.patch
new file mode 100644
index 0000000..34d0472
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-prealloc-rhel5.patch
@@ -0,0 +1,405 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4_sb.h	2009-05-28 17:16:51.000000000 +0530
++++ linux-2.6.18-128.1.6/fs/ext4/ext4_sb.h	2009-05-28 17:16:52.000000000 +0530
+@@ -108,11 +108,14 @@
+ 
+ 	/* tunables */
+ 	unsigned long s_stripe;
+-	unsigned long s_mb_stream_request;
++	unsigned long s_mb_small_req;
++	unsigned long s_mb_large_req;
+ 	unsigned long s_mb_max_to_scan;
+ 	unsigned long s_mb_min_to_scan;
+ 	unsigned long s_mb_stats;
+ 	unsigned long s_mb_order2_reqs;
++	unsigned long *s_mb_prealloc_table;
++	unsigned long s_mb_prealloc_table_size;
+ 	unsigned long s_mb_group_prealloc;
+ 	/* where last allocation was done - for stream allocation */
+ 	unsigned long s_mb_last_group;
+Index: linux-2.6.18-128.1.6/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/mballoc.c	2009-05-28 17:16:51.000000000 +0530
++++ linux-2.6.18-128.1.6/fs/ext4/mballoc.c	2009-05-28 17:19:57.000000000 +0530
+@@ -1744,7 +1744,7 @@
+ 	if (size < isize)
+ 		size = isize;
+ 
+-	if (size < sbi->s_mb_stream_request &&
++	if ((ac->ac_g_ex.fe_len < sbi->s_mb_large_req) &&
+ 			(ac->ac_flags & EXT4_MB_HINT_DATA)) {
+ 		/* TBD: may be hot point */
+ 		spin_lock(&sbi->s_md_lock);
+@@ -2484,6 +2484,26 @@
+ 	return -ENOMEM;
+ }
+ 
++static void ext4_mb_prealloc_table_add(struct ext4_sb_info *sbi, int value)
++{
++	int i;
++
++	if (value > (sbi->s_blocks_per_group - 1 - 1 - sbi->s_itb_per_group))
++		return;
++
++	for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) {
++		if (sbi->s_mb_prealloc_table[i] == 0) {
++			sbi->s_mb_prealloc_table[i] = value;
++			return;
++		}
++
++		/* they should add values in order */
++		if (value <= sbi->s_mb_prealloc_table[i])
++			return;
++	}
++}
++
++
+ int ext4_mb_init(struct super_block *sb, int needs_recovery)
+ {
+ 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+@@ -2542,15 +2562,59 @@
+ 	sbi->s_mb_max_to_scan = MB_DEFAULT_MAX_TO_SCAN;
+ 	sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN;
+ 	sbi->s_mb_stats = MB_DEFAULT_STATS;
+-	sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD;
+ 	sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
+ 	sbi->s_mb_history_filter = EXT4_MB_HISTORY_DEFAULT;
+-	sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;
++
++	if (sbi->s_stripe == 0) {
++		sbi->s_mb_prealloc_table_size = 8;
++		i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long);
++		sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS);
++		if (sbi->s_mb_prealloc_table == NULL) {
++				clear_opt(sbi->s_mount_opt, MBALLOC);
++				kfree(sbi->s_mb_offsets);
++				kfree(sbi->s_mb_maxs);
++				return -ENOMEM;
++		}
++		memset(sbi->s_mb_prealloc_table, 0, i);
++
++		ext4_mb_prealloc_table_add(sbi, 4);
++		ext4_mb_prealloc_table_add(sbi, 8);
++		ext4_mb_prealloc_table_add(sbi, 16);
++		ext4_mb_prealloc_table_add(sbi, 32);
++		ext4_mb_prealloc_table_add(sbi, 64);
++		ext4_mb_prealloc_table_add(sbi, 128);
++		ext4_mb_prealloc_table_add(sbi, 256);
++		ext4_mb_prealloc_table_add(sbi, 512);
++
++		sbi->s_mb_small_req = 256;
++		sbi->s_mb_large_req = 1024;
++		sbi->s_mb_group_prealloc = 512;
++	} else {
++		sbi->s_mb_prealloc_table_size = 3;
++		i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long);
++		sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS);
++		if (sbi->s_mb_prealloc_table == NULL) {
++			clear_opt(sbi->s_mount_opt, MBALLOC);
++			kfree(sbi->s_mb_offsets);
++			kfree(sbi->s_mb_maxs);
++			return -ENOMEM;
++		}
++		memset(sbi->s_mb_prealloc_table, 0, i);
++
++		ext4_mb_prealloc_table_add(sbi, sbi->s_stripe);
++		ext4_mb_prealloc_table_add(sbi, sbi->s_stripe * 2);
++		ext4_mb_prealloc_table_add(sbi, sbi->s_stripe * 4);
++
++		sbi->s_mb_small_req = sbi->s_stripe;
++		sbi->s_mb_large_req = sbi->s_stripe * 8;
++		sbi->s_mb_group_prealloc = sbi->s_stripe * 4;
++	}
+ 
+ 	i = sizeof(struct ext4_locality_group) * num_possible_cpus();
+ 	sbi->s_locality_groups = kmalloc(i, GFP_KERNEL);
+ 	if (sbi->s_locality_groups == NULL) {
+ 		clear_opt(sbi->s_mount_opt, MBALLOC);
++		kfree(sbi->s_mb_prealloc_table);
+ 		kfree(sbi->s_mb_offsets);
+ 		kfree(sbi->s_mb_maxs);
+ 		return -ENOMEM;
+@@ -2725,10 +2789,82 @@
+ #define EXT4_MB_MAX_TO_SCAN_NAME	"max_to_scan"
+ #define EXT4_MB_MIN_TO_SCAN_NAME	"min_to_scan"
+ #define EXT4_MB_ORDER2_REQ		"order2_req"
+-#define EXT4_MB_STREAM_REQ		"stream_req"
++#define EXT4_MB_SMALL_REQ          	"small_req"
++#define EXT4_MB_LARGE_REQ            	"large_req"
++#define EXT4_MB_PREALLOC_TABLE          "prealloc_table"
+ #define EXT4_MB_GROUP_PREALLOC		"group_prealloc"
+ 
++static int ext4_mb_prealloc_table_proc_read(char *page, char **start, off_t off,
++					    int count, int *eof, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	int len = 0;
++	int i;
++
++	*eof = 1;
++	if (off != 0)
++		return 0;
++
++	for (i = 0; i < sbi->s_mb_prealloc_table_size; i++)
++		len += sprintf(page + len, "%ld ",
++			       sbi->s_mb_prealloc_table[i]);
++	len += sprintf(page + len, "\n");
++
++	*start = page;
++	return len;
++}
++
++static int ext4_mb_prealloc_table_proc_write(struct file *file,
++					     const char __user *buf,
++					     unsigned long cnt, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	unsigned long value;
++	unsigned long prev = 0;
++	char str[128];
++	char *cur;
++	char *end;
++	unsigned long *new_table;
++	int num = 0;
++	int i = 0;
++
++	if (cnt >= sizeof(str))
++		return -EINVAL;
++	if (copy_from_user(str, buf, cnt))
++		return -EFAULT;
++
++	num = 0;
++	cur = str;
++	end = str + cnt;
++	while (cur < end) {
++		while ((cur < end) && (*cur == ' ')) cur++;
++		value = simple_strtol(cur, &cur, 0);
++		if (value == 0)
++			break;
++		if (value <= prev)
++			return -EINVAL;
++		prev = value;
++		num++;
++	}
+ 
++	new_table = kmalloc(num * sizeof(*new_table), GFP_KERNEL);
++	if (new_table == NULL)
++		return -ENOMEM;
++	kfree(sbi->s_mb_prealloc_table);
++	memset(new_table, 0, num * sizeof(*new_table));
++	sbi->s_mb_prealloc_table = new_table;
++	sbi->s_mb_prealloc_table_size = num;
++	cur = str;
++	end = str + cnt;
++	while (cur < end && i < num) {
++	while ((cur < end) && (*cur == ' ')) cur++;
++		value = simple_strtol(cur, &cur, 0);
++		ext4_mb_prealloc_table_add(sbi, value);
++		i++;
++	}
++
++	return cnt;
++}
+ 
+ #define MB_PROC_FOPS(name)					\
+ static int ext4_mb_##name##_proc_show(struct seq_file *m, void *v)	\
+@@ -2774,7 +2910,8 @@
+ MB_PROC_FOPS(max_to_scan);
+ MB_PROC_FOPS(min_to_scan);
+ MB_PROC_FOPS(order2_reqs);
+-MB_PROC_FOPS(stream_request);
++MB_PROC_FOPS(small_req);
++MB_PROC_FOPS(large_req);
+ MB_PROC_FOPS(group_prealloc);
+ 
+ #define	MB_PROC_HANDLER(name, var)					\
+@@ -2795,6 +2932,7 @@
+ 	mode_t mode = S_IFREG | S_IRUGO | S_IWUSR;
+ 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+ 	struct proc_dir_entry *proc;
++	struct proc_dir_entry *proc_entry;
+ 	char devname[64];
+ 
+ 	if (proc_root_ext4 == NULL) {
+@@ -2808,15 +2946,29 @@
+ 	MB_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, max_to_scan);
+ 	MB_PROC_HANDLER(EXT4_MB_MIN_TO_SCAN_NAME, min_to_scan);
+ 	MB_PROC_HANDLER(EXT4_MB_ORDER2_REQ, order2_reqs);
+-	MB_PROC_HANDLER(EXT4_MB_STREAM_REQ, stream_request);
++	MB_PROC_HANDLER(EXT4_MB_SMALL_REQ, small_req);
++	MB_PROC_HANDLER(EXT4_MB_LARGE_REQ, large_req);
+ 	MB_PROC_HANDLER(EXT4_MB_GROUP_PREALLOC, group_prealloc);
+ 
++	proc_entry = create_proc_entry(EXT4_MB_PREALLOC_TABLE, S_IFREG |
++				       S_IRUGO | S_IWUSR, sbi->s_mb_proc);
++	if (proc_entry == NULL) {
++		printk(KERN_ERR "EXT4-fs: unable to create %s\n",
++		       EXT4_MB_PREALLOC_TABLE);
++		goto err_out;
++	}
++	proc_entry->data = sbi;
++	proc_entry->read_proc = ext4_mb_prealloc_table_proc_read;
++	proc_entry->write_proc = ext4_mb_prealloc_table_proc_write;
++
+ 	return 0;
+ 
+ err_out:
+ 	printk(KERN_ERR "EXT4-fs: Unable to create %s\n", devname);
+ 	remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
+-	remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MB_LARGE_REQ, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MB_SMALL_REQ, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_mb_proc);
+@@ -2838,7 +2990,9 @@
+ 
+ 	bdevname(sb->s_bdev, devname);
+ 	remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
+-	remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MB_LARGE_REQ, sbi->s_mb_proc);
++	remove_proc_entry(EXT4_MB_SMALL_REQ, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_mb_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_mb_proc);
+@@ -3032,11 +3186,12 @@
+ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
+ 				struct ext4_allocation_request *ar)
+ {
+-	int bsbits, max;
++	int bsbits, i, wind;
+ 	ext4_lblk_t end;
+-	loff_t size, orig_size, start_off;
++	loff_t size, orig_size;
+ 	ext4_lblk_t start, orig_start;
+ 	struct ext4_inode_info *ei = EXT4_I(ac->ac_inode);
++	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
+ 	struct ext4_prealloc_space *pa;
+ 
+ 	/* do normalize only data requests, metadata requests
+@@ -3066,49 +3221,35 @@
+ 	size = size << bsbits;
+ 	if (size < i_size_read(ac->ac_inode))
+ 		size = i_size_read(ac->ac_inode);
++	size = (size + ac->ac_sb->s_blocksize - 1) >> bsbits;
+ 
+-	/* max size of free chunks */
+-	max = 2 << bsbits;
++	start = wind = 0;
+ 
+-#define NRL_CHECK_SIZE(req, size, max, chunk_size)	\
+-		(req <= (size) || max <= (chunk_size))
++	/* let's choose preallocation window depending on file size */
++	for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) {
++		if (size <= sbi->s_mb_prealloc_table[i]) {
++			wind = sbi->s_mb_prealloc_table[i];
++			break;
++		}
++	}
++	size = wind;
+ 
+-	/* first, try to predict filesize */
+-	/* XXX: should this table be tunable? */
+-	start_off = 0;
+-	if (size <= 16 * 1024) {
+-		size = 16 * 1024;
+-	} else if (size <= 32 * 1024) {
+-		size = 32 * 1024;
+-	} else if (size <= 64 * 1024) {
+-		size = 64 * 1024;
+-	} else if (size <= 128 * 1024) {
+-		size = 128 * 1024;
+-	} else if (size <= 256 * 1024) {
+-		size = 256 * 1024;
+-	} else if (size <= 512 * 1024) {
+-		size = 512 * 1024;
+-	} else if (size <= 1024 * 1024) {
+-		size = 1024 * 1024;
+-	} else if (NRL_CHECK_SIZE(size, 4 * 1024 * 1024, max, 2 * 1024)) {
+-		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
+-						(21 - bsbits)) << 21;
+-		size = 2 * 1024 * 1024;
+-	} else if (NRL_CHECK_SIZE(size, 8 * 1024 * 1024, max, 4 * 1024)) {
+-		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
+-							(22 - bsbits)) << 22;
+-		size = 4 * 1024 * 1024;
+-	} else if (NRL_CHECK_SIZE(ac->ac_o_ex.fe_len,
+-					(8<<20)>>bsbits, max, 8 * 1024)) {
+-		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
+-							(23 - bsbits)) << 23;
+-		size = 8 * 1024 * 1024;
+-	} else {
+-		start_off = (loff_t)ac->ac_o_ex.fe_logical << bsbits;
+-		size	  = ac->ac_o_ex.fe_len << bsbits;
++	if (wind == 0) {
++		__u64 tstart, tend;
++		/* file is quite large, we now preallocate with
++		 * the biggest configured window with regart to
++		 * logical offset */
++		wind = sbi->s_mb_prealloc_table[i - 1];
++		tstart = ac->ac_o_ex.fe_logical;
++		do_div(tstart, wind);
++		start = tstart * wind;
++		tend = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len - 1;
++		do_div(tend, wind);
++		tend = tend * wind + wind;
++		size = tend - start;
+ 	}
+-	orig_size = size = size >> bsbits;
+-	orig_start = start = start_off >> bsbits;
++	orig_size = size;
++	orig_start = start;
+ 
+ 	/* don't cover already allocated blocks in selected range */
+ 	if (ar->pleft && start <= ar->lleft) {
+@@ -3185,7 +3326,6 @@
+ 	}
+ 	BUG_ON(start + size <= ac->ac_o_ex.fe_logical &&
+ 			start > ac->ac_o_ex.fe_logical);
+-	BUG_ON(size <= 0 || size >= EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
+ 
+ 	/* now prepare goal request */
+ 
+@@ -4077,22 +4217,32 @@
+ {
+ 	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
+ 	int bsbits = ac->ac_sb->s_blocksize_bits;
+-	loff_t size, isize;
++	loff_t size;
+ 
+ 	if (!(ac->ac_flags & EXT4_MB_HINT_DATA))
+ 		return;
+ 
+-	size = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len;
+-	isize = i_size_read(ac->ac_inode) >> bsbits;
+-	size = max(size, isize);
+-
+-	/* don't use group allocation for large files */
+-	if (size >= sbi->s_mb_stream_request)
++	if (ac->ac_o_ex.fe_len >= sbi->s_mb_small_req)
+ 		return;
+ 
+ 	if (unlikely(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY))
+ 		return;
+ 
++	/* request is so large that we don't care about
++	 * streaming - it overweights any possible seek */
++	if (ac->ac_o_ex.fe_len >= sbi->s_mb_large_req)
++		return;
++
++	size = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len;
++	size = size << bsbits;
++	if (size < i_size_read(ac->ac_inode))
++		size = i_size_read(ac->ac_inode);
++	size = (size + ac->ac_sb->s_blocksize - 1) >> bsbits;
++
++	/* don't use group allocation for large files */
++	if (size >= sbi->s_mb_large_req)
++		return;
++
+ 	BUG_ON(ac->ac_lg != NULL);
+ 	/*
+ 	 * locality group prealloc space are per cpu. The reason for having
diff --git a/ldiskfs/kernel_patches/patches/ext4-prealloc-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-prealloc-sles11.patch
new file mode 100644
index 0000000..029a91a
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-prealloc-sles11.patch
@@ -0,0 +1,413 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4_sb.h	2009-05-28 11:13:24.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/ext4_sb.h	2009-05-28 11:16:48.000000000 +0530
+@@ -109,11 +109,14 @@
+ 
+ 	/* tunables */
+ 	unsigned long s_stripe;
+-	unsigned int s_mb_stream_request;
++	unsigned long s_mb_small_req;
++	unsigned long s_mb_large_req;
+ 	unsigned int s_mb_max_to_scan;
+ 	unsigned int s_mb_min_to_scan;
+ 	unsigned int s_mb_stats;
+ 	unsigned int s_mb_order2_reqs;
++	unsigned long *s_mb_prealloc_table;
++	unsigned long s_mb_prealloc_table_size;
+ 	unsigned int s_mb_group_prealloc;
+ 	/* where last allocation was done - for stream allocation */
+ 	unsigned long s_mb_last_group;
+Index: linux-2.6.27.21-0.1/fs/ext4/mballoc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/mballoc.c	2009-05-28 11:12:43.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/mballoc.c	2009-05-28 11:18:09.000000000 +0530
+@@ -1996,7 +1996,7 @@
+ 	if (size < isize)
+ 		size = isize;
+ 
+-	if (size < sbi->s_mb_stream_request &&
++	if ((ac->ac_g_ex.fe_len < sbi->s_mb_large_req) &&
+ 			(ac->ac_flags & EXT4_MB_HINT_DATA)) {
+ 		/* TBD: may be hot point */
+ 		spin_lock(&sbi->s_md_lock);
+@@ -2686,6 +2686,26 @@
+ 	return -ENOMEM;
+ }
+ 
++static void ext4_mb_prealloc_table_add(struct ext4_sb_info *sbi, int value)
++{
++	int i;
++
++	if (value > (sbi->s_blocks_per_group - 1 - 1 - sbi->s_itb_per_group))
++		return;
++
++	for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) {
++		if (sbi->s_mb_prealloc_table[i] == 0) {
++			sbi->s_mb_prealloc_table[i] = value;
++			return;
++		}
++
++		/* they should add values in order */
++		if (value <= sbi->s_mb_prealloc_table[i])
++			return;
++	}
++}
++
++
+ int ext4_mb_init(struct super_block *sb, int needs_recovery)
+ {
+ 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+@@ -2738,13 +2758,55 @@
+ 	sbi->s_mb_max_to_scan = MB_DEFAULT_MAX_TO_SCAN;
+ 	sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN;
+ 	sbi->s_mb_stats = MB_DEFAULT_STATS;
+-	sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD;
+ 	sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
+ 	sbi->s_mb_history_filter = EXT4_MB_HISTORY_DEFAULT;
+-	sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;
++
++	if (sbi->s_stripe == 0) {
++		sbi->s_mb_prealloc_table_size = 8;
++		i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long);
++		sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS);
++		if (sbi->s_mb_prealloc_table == NULL) {
++			kfree(sbi->s_mb_offsets);
++			kfree(sbi->s_mb_maxs);
++			return -ENOMEM;
++		}
++		memset(sbi->s_mb_prealloc_table, 0, i);
++
++		ext4_mb_prealloc_table_add(sbi, 4);
++		ext4_mb_prealloc_table_add(sbi, 8);
++		ext4_mb_prealloc_table_add(sbi, 16);
++		ext4_mb_prealloc_table_add(sbi, 32);
++		ext4_mb_prealloc_table_add(sbi, 64);
++		ext4_mb_prealloc_table_add(sbi, 128);
++		ext4_mb_prealloc_table_add(sbi, 256);
++		ext4_mb_prealloc_table_add(sbi, 512);
++
++		sbi->s_mb_small_req = 256;
++		sbi->s_mb_large_req = 1024;
++		sbi->s_mb_group_prealloc = 512;
++	} else {
++		sbi->s_mb_prealloc_table_size = 3;
++		i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long);
++		sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS);
++		if (sbi->s_mb_prealloc_table == NULL) {
++			kfree(sbi->s_mb_offsets);
++			kfree(sbi->s_mb_maxs);
++			return -ENOMEM;
++		}
++		memset(sbi->s_mb_prealloc_table, 0, i);
++
++		ext4_mb_prealloc_table_add(sbi, sbi->s_stripe);
++		ext4_mb_prealloc_table_add(sbi, sbi->s_stripe * 2);
++		ext4_mb_prealloc_table_add(sbi, sbi->s_stripe * 4);
++
++		sbi->s_mb_small_req = sbi->s_stripe;
++		sbi->s_mb_large_req = sbi->s_stripe * 8;
++		sbi->s_mb_group_prealloc = sbi->s_stripe * 4;
++	}
+ 
+ 	sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
+ 	if (sbi->s_locality_groups == NULL) {
++		kfree(sbi->s_mb_prealloc_table);
+ 		kfree(sbi->s_mb_offsets);
+ 		kfree(sbi->s_mb_maxs);
+ 		return -ENOMEM;
+@@ -2915,15 +2977,90 @@
+ #define EXT4_MB_MAX_TO_SCAN_NAME	"max_to_scan"
+ #define EXT4_MB_MIN_TO_SCAN_NAME	"min_to_scan"
+ #define EXT4_MB_ORDER2_REQ		"order2_req"
+-#define EXT4_MB_STREAM_REQ		"stream_req"
++#define EXT4_MB_SMALL_REQ		"small_req"
++#define EXT4_MB_LARGE_REQ		"large_req"
++#define EXT4_MB_PREALLOC_TABLE		"prealloc_table"
+ #define EXT4_MB_GROUP_PREALLOC		"group_prealloc"
+ 
++static int ext4_mb_prealloc_table_proc_read(char *page, char **start, off_t off,
++					    int count, int *eof, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	int len = 0;
++	int i;
++
++	*eof = 1;
++	if (off != 0)
++		return 0;
++
++	for (i = 0; i < sbi->s_mb_prealloc_table_size; i++)
++		len += sprintf(page + len, "%ld ",
++			       sbi->s_mb_prealloc_table[i]);
++	len += sprintf(page + len, "\n");
++
++	*start = page;
++	return len;
++}
++
++static int ext4_mb_prealloc_table_proc_write(struct file *file,
++					     const char __user *buf,
++					     unsigned long cnt, void *data)
++{
++	struct ext4_sb_info *sbi = data;
++	unsigned long value;
++	unsigned long prev = 0;
++	char str[128];
++	char *cur;
++	char *end;
++	unsigned long *new_table;
++	int num = 0;
++	int i = 0;
++
++	if (cnt >= sizeof(str))
++		return -EINVAL;
++	if (copy_from_user(str, buf, cnt))
++		return -EFAULT;
++
++	num = 0;
++	cur = str;
++	end = str + cnt;
++	while (cur < end) {
++		while ((cur < end) && (*cur == ' ')) cur++;
++		value = simple_strtol(cur, &cur, 0);
++		if (value == 0)
++			break;
++		if (value <= prev)
++			return -EINVAL;
++		prev = value;
++		num++;
++	}
++
++	new_table = kmalloc(num * sizeof(*new_table), GFP_KERNEL);
++	if (new_table == NULL)
++		return -ENOMEM;
++	kfree(sbi->s_mb_prealloc_table);
++	memset(new_table, 0, num * sizeof(*new_table));
++	sbi->s_mb_prealloc_table = new_table;
++	sbi->s_mb_prealloc_table_size = num;
++	cur = str;
++	end = str + cnt;
++	while (cur < end && i < num) {
++	while ((cur < end) && (*cur == ' ')) cur++;
++		value = simple_strtol(cur, &cur, 0);
++		ext4_mb_prealloc_table_add(sbi, value);
++		i++;
++	}
++
++	return cnt;
++}
++
+ static int ext4_mb_init_per_dev_proc(struct super_block *sb)
+ {
+ #ifdef CONFIG_PROC_FS
+ 	mode_t mode = S_IFREG | S_IRUGO | S_IWUSR;
+ 	struct ext4_sb_info *sbi = EXT4_SB(sb);
+ 	struct proc_dir_entry *proc;
++	struct proc_dir_entry *proc_entry;
+ 
+ 	if (sbi->s_proc == NULL)
+ 		return -EINVAL;
+@@ -2932,13 +3069,28 @@
+ 	EXT4_PROC_HANDLER(EXT4_MB_MAX_TO_SCAN_NAME, mb_max_to_scan);
+ 	EXT4_PROC_HANDLER(EXT4_MB_MIN_TO_SCAN_NAME, mb_min_to_scan);
+ 	EXT4_PROC_HANDLER(EXT4_MB_ORDER2_REQ, mb_order2_reqs);
+-	EXT4_PROC_HANDLER(EXT4_MB_STREAM_REQ, mb_stream_request);
++	EXT4_PROC_HANDLER(EXT4_MB_SMALL_REQ, mb_small_req);
++	EXT4_PROC_HANDLER(EXT4_MB_LARGE_REQ, mb_large_req);
+ 	EXT4_PROC_HANDLER(EXT4_MB_GROUP_PREALLOC, mb_group_prealloc);
++
++	proc_entry = create_proc_entry(EXT4_MB_PREALLOC_TABLE, S_IFREG |
++ 				       S_IRUGO | S_IWUSR, sbi->s_proc);
++	if (proc_entry == NULL) {
++		printk(KERN_ERR "EXT4-fs: unable to create %s\n",
++		       EXT4_MB_PREALLOC_TABLE);
++		goto err_out;
++	}
++	proc_entry->data = sbi;
++	proc_entry->read_proc = ext4_mb_prealloc_table_proc_read;
++	proc_entry->write_proc = ext4_mb_prealloc_table_proc_write;
++
+ 	return 0;
+ 
+ err_out:
+ 	remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_proc);
+-	remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_proc);
++	remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_proc);
++	remove_proc_entry(EXT4_MB_LARGE_REQ, sbi->s_proc);
++	remove_proc_entry(EXT4_MB_SMALL_REQ, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc);
+@@ -2959,7 +3111,9 @@
+ 		return -EINVAL;
+ 
+ 	remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_proc);
+-	remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_proc);
++	remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_proc);
++	remove_proc_entry(EXT4_MB_LARGE_REQ, sbi->s_proc);
++	remove_proc_entry(EXT4_MB_SMALL_REQ, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_MIN_TO_SCAN_NAME, sbi->s_proc);
+ 	remove_proc_entry(EXT4_MB_MAX_TO_SCAN_NAME, sbi->s_proc);
+@@ -3162,11 +3316,12 @@
+ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
+ 				struct ext4_allocation_request *ar)
+ {
+-	int bsbits, max;
++	int bsbits, i, wind;
+ 	ext4_lblk_t end;
+-	loff_t size, orig_size, start_off;
++	loff_t size, orig_size;
+ 	ext4_lblk_t start, orig_start;
+ 	struct ext4_inode_info *ei = EXT4_I(ac->ac_inode);
++	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
+ 	struct ext4_prealloc_space *pa;
+ 
+ 	/* do normalize only data requests, metadata requests
+@@ -3196,49 +3351,35 @@
+ 	size = size << bsbits;
+ 	if (size < i_size_read(ac->ac_inode))
+ 		size = i_size_read(ac->ac_inode);
++	size = (size + ac->ac_sb->s_blocksize - 1) >> bsbits;
+ 
+-	/* max size of free chunks */
+-	max = 2 << bsbits;
++	start = wind = 0;
+ 
+-#define NRL_CHECK_SIZE(req, size, max, chunk_size)	\
+-		(req <= (size) || max <= (chunk_size))
++	/* let's choose preallocation window depending on file size */
++	for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) {
++		if (size <= sbi->s_mb_prealloc_table[i]) {
++			wind = sbi->s_mb_prealloc_table[i];
++			break;
++		}
++	}
++	size = wind;
+ 
+-	/* first, try to predict filesize */
+-	/* XXX: should this table be tunable? */
+-	start_off = 0;
+-	if (size <= 16 * 1024) {
+-		size = 16 * 1024;
+-	} else if (size <= 32 * 1024) {
+-		size = 32 * 1024;
+-	} else if (size <= 64 * 1024) {
+-		size = 64 * 1024;
+-	} else if (size <= 128 * 1024) {
+-		size = 128 * 1024;
+-	} else if (size <= 256 * 1024) {
+-		size = 256 * 1024;
+-	} else if (size <= 512 * 1024) {
+-		size = 512 * 1024;
+-	} else if (size <= 1024 * 1024) {
+-		size = 1024 * 1024;
+-	} else if (NRL_CHECK_SIZE(size, 4 * 1024 * 1024, max, 2 * 1024)) {
+-		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
+-						(21 - bsbits)) << 21;
+-		size = 2 * 1024 * 1024;
+-	} else if (NRL_CHECK_SIZE(size, 8 * 1024 * 1024, max, 4 * 1024)) {
+-		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
+-							(22 - bsbits)) << 22;
+-		size = 4 * 1024 * 1024;
+-	} else if (NRL_CHECK_SIZE(ac->ac_o_ex.fe_len,
+-					(8<<20)>>bsbits, max, 8 * 1024)) {
+-		start_off = ((loff_t)ac->ac_o_ex.fe_logical >>
+-							(23 - bsbits)) << 23;
+-		size = 8 * 1024 * 1024;
+-	} else {
+-		start_off = (loff_t)ac->ac_o_ex.fe_logical << bsbits;
+-		size	  = ac->ac_o_ex.fe_len << bsbits;
++	if (wind == 0) {
++		__u64 tstart, tend;
++		/* file is quite large, we now preallocate with
++		 * the biggest configured window with regart to
++		 * logical offset */
++		wind = sbi->s_mb_prealloc_table[i - 1];
++		tstart = ac->ac_o_ex.fe_logical;
++		do_div(tstart, wind);
++		start = tstart * wind;
++		tend = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len - 1;
++		do_div(tend, wind);
++		tend = tend * wind + wind;
++		size = tend - start;
+ 	}
+-	orig_size = size = size >> bsbits;
+-	orig_start = start = start_off >> bsbits;
++	orig_size = size;
++	orig_start = start;
+ 
+ 	/* don't cover already allocated blocks in selected range */
+ 	if (ar->pleft && start <= ar->lleft) {
+@@ -3315,7 +3456,6 @@
+ 	}
+ 	BUG_ON(start + size <= ac->ac_o_ex.fe_logical &&
+ 			start > ac->ac_o_ex.fe_logical);
+-	BUG_ON(size <= 0 || size >= EXT4_BLOCKS_PER_GROUP(ac->ac_sb));
+ 
+ 	/* now prepare goal request */
+ 
+@@ -4236,22 +4376,32 @@
+ {
+ 	struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
+ 	int bsbits = ac->ac_sb->s_blocksize_bits;
+-	loff_t size, isize;
++	loff_t size;
+ 
+ 	if (!(ac->ac_flags & EXT4_MB_HINT_DATA))
+ 		return;
+ 
+-	size = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len;
+-	isize = i_size_read(ac->ac_inode) >> bsbits;
+-	size = max(size, isize);
+-
+-	/* don't use group allocation for large files */
+-	if (size >= sbi->s_mb_stream_request)
++	if (ac->ac_o_ex.fe_len >= sbi->s_mb_small_req)
+ 		return;
+ 
+ 	if (unlikely(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY))
+ 		return;
+ 
++	/* request is so large that we don't care about
++	 * streaming - it overweights any possible seek */
++	if (ac->ac_o_ex.fe_len >= sbi->s_mb_large_req)
++		return;
++
++	size = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len;
++	size = size << bsbits;
++	if (size < i_size_read(ac->ac_inode))
++		size = i_size_read(ac->ac_inode);
++	size = (size + ac->ac_sb->s_blocksize - 1) >> bsbits;
++
++	/* don't use group allocation for large files */
++	if (size >= sbi->s_mb_large_req)
++		return;
++
+ 	BUG_ON(ac->ac_lg != NULL);
+ 	/*
+ 	 * locality group prealloc space are per cpu. The reason for having
+Index: linux-2.6.27.21-0.1/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/inode.c	2009-05-28 11:12:42.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/inode.c	2009-05-28 11:16:48.000000000 +0530
+@@ -2442,14 +2442,14 @@
+ 		return -EROFS;
+ 
+ 	/*
+-	 * Make sure nr_to_write is >= sbi->s_mb_stream_request
++	 * Make sure nr_to_write is >= sbi->s_mb_small_req
+ 	 * This make sure small files blocks are allocated in
+ 	 * single attempt. This ensure that small files
+ 	 * get less fragmented.
+ 	 */
+-	if (wbc->nr_to_write < sbi->s_mb_stream_request) {
+-		nr_to_writebump = sbi->s_mb_stream_request - wbc->nr_to_write;
+-		wbc->nr_to_write = sbi->s_mb_stream_request;
++	if (wbc->nr_to_write < sbi->s_mb_small_req) {
++		nr_to_writebump = sbi->s_mb_small_req - wbc->nr_to_write;
++		wbc->nr_to_write = sbi->s_mb_small_req;
+ 	}
+ 	if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
+ 		range_whole = 1;
diff --git a/ldiskfs/kernel_patches/patches/ext4-print-inum-in-htree-warning-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-print-inum-in-htree-warning-rhel5.patch
new file mode 100644
index 0000000..1cc10a8
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-print-inum-in-htree-warning-rhel5.patch
@@ -0,0 +1,15 @@
+Index: linux-2.6.18.i386/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/namei.c
++++ linux-2.6.18.i386/fs/ext4/namei.c
+@@ -374,8 +374,8 @@ dx_probe(struct dentry *dentry, struct i
+ 	    root->info.hash_version != DX_HASH_HALF_MD4 &&
+ 	    root->info.hash_version != DX_HASH_LEGACY) {
+ 		ext4_warning(dir->i_sb, __func__,
+-			     "Unrecognised inode hash code %d",
+-			     root->info.hash_version);
++			     "Unrecognised inode hash code %d for directory "
++			     "#%lu", root->info.hash_version, dir->i_ino);
+ 		brelse(bh);
+ 		*err = ERR_BAD_DX_DIR;
+ 		goto fail;
diff --git a/ldiskfs/kernel_patches/patches/ext4-print-inum-in-htree-warning-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-print-inum-in-htree-warning-sles11.patch
new file mode 100644
index 0000000..1cc10a8
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-print-inum-in-htree-warning-sles11.patch
@@ -0,0 +1,15 @@
+Index: linux-2.6.18.i386/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/namei.c
++++ linux-2.6.18.i386/fs/ext4/namei.c
+@@ -374,8 +374,8 @@ dx_probe(struct dentry *dentry, struct i
+ 	    root->info.hash_version != DX_HASH_HALF_MD4 &&
+ 	    root->info.hash_version != DX_HASH_LEGACY) {
+ 		ext4_warning(dir->i_sb, __func__,
+-			     "Unrecognised inode hash code %d",
+-			     root->info.hash_version);
++			     "Unrecognised inode hash code %d for directory "
++			     "#%lu", root->info.hash_version, dir->i_ino);
+ 		brelse(bh);
+ 		*err = ERR_BAD_DX_DIR;
+ 		goto fail;
diff --git a/ldiskfs/kernel_patches/patches/ext4-remove-cond_resched-calls-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-remove-cond_resched-calls-rhel5.patch
new file mode 100644
index 0000000..bab03d1
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-remove-cond_resched-calls-rhel5.patch
@@ -0,0 +1,29 @@
+Index: linux-2.6.18.i386/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ialloc.c
++++ linux-2.6.18.i386/fs/ext4/ialloc.c
+@@ -1057,7 +1057,6 @@ unsigned long ext4_count_free_inodes (st
+ 		if (!gdp)
+ 			continue;
+ 		desc_count += le16_to_cpu(gdp->bg_free_inodes_count);
+-		cond_resched();
+ 	}
+ 	return desc_count;
+ #endif
+Index: linux-2.6.18.i386/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/super.c
++++ linux-2.6.18.i386/fs/ext4/super.c
+@@ -3100,11 +3100,9 @@ static int ext4_statfs(struct dentry *de
+ 		 * block group descriptors.  If the sparse superblocks
+ 		 * feature is turned on, then not all groups have this.
+ 		 */
+-		for (i = 0; i < ngroups; i++) {
++		for (i = 0; i < ngroups; i++)
+ 			overhead += ext4_bg_has_super(sb, i) +
+ 				ext4_bg_num_gdb(sb, i);
+-			cond_resched();
+-		}
+ 
+ 		/*
+ 		 * Every block group has an inode bitmap, a block
diff --git a/ldiskfs/kernel_patches/patches/ext4-remove-cond_resched-calls-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-remove-cond_resched-calls-sles11.patch
new file mode 100644
index 0000000..db2e1ba
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-remove-cond_resched-calls-sles11.patch
@@ -0,0 +1,29 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ialloc.c
++++ linux-2.6.27.21-0.1/fs/ext4/ialloc.c
+@@ -1120,7 +1120,6 @@ unsigned long ext4_count_free_inodes(str
+ 		if (!gdp)
+ 			continue;
+ 		desc_count += ext4_free_inodes_count(sb, gdp);
+-		cond_resched();
+ 	}
+ 	return desc_count;
+ #endif
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -3263,11 +3263,9 @@ static int ext4_statfs(struct dentry *de
+ 		 * block group descriptors.  If the sparse superblocks
+ 		 * feature is turned on, then not all groups have this.
+ 		 */
+-		for (i = 0; i < ngroups; i++) {
++		for (i = 0; i < ngroups; i++)
+ 			overhead += ext4_bg_has_super(sb, i) +
+ 				ext4_bg_num_gdb(sb, i);
+-			cond_resched();
+-		}
+ 
+ 		/*
+ 		 * Every block group has an inode bitmap, a block
diff --git a/ldiskfs/kernel_patches/patches/ext4-remove-ioctl-filp-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-remove-ioctl-filp-sles11.patch
new file mode 100644
index 0000000..8fbc0b7
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-remove-ioctl-filp-sles11.patch
@@ -0,0 +1,111 @@
+temp patch until we find workaround. WIll not affect Lustre functionality
+
+Index: linux-2.6.27.21-0.1/fs/ext4/ioctl.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ioctl.c
++++ linux-2.6.27.21-0.1/fs/ext4/ioctl.c
+@@ -200,9 +200,9 @@ long ext4_ioctl(struct file *filp, unsig
+ 		if (get_user(flags, (int __user *) arg))
+ 			return -EFAULT;
+ 
+-		err = mnt_want_write(filp->f_path.mnt);
++/*		err = mnt_want_write(filp->f_path.mnt);
+ 		if (err)
+-			return err;
++			return err;*/
+ 
+ 		if (!S_ISDIR(inode->i_mode))
+ 			flags &= ~EXT4_DIRSYNC_FL;
+@@ -281,7 +281,7 @@ flags_err:
+ 			err = ext4_ext_migrate(inode);
+ flags_out:
+ 		mutex_unlock(&inode->i_mutex);
+-		mnt_drop_write(filp->f_path.mnt);
++//		mnt_drop_write(filp->f_path.mnt);
+ 		return err;
+ 	}
+ 	case EXT4_IOC_GETVERSION:
+@@ -297,9 +297,9 @@ flags_out:
+ 		if (!is_owner_or_cap(inode))
+ 			return -EPERM;
+ 
+-		err = mnt_want_write(filp->f_path.mnt);
++/*		err = mnt_want_write(filp->f_path.mnt);
+ 		if (err)
+-			return err;
++			return err;*/
+ 		if (get_user(generation, (int __user *) arg)) {
+ 			err = -EFAULT;
+ 			goto setversion_out;
+@@ -318,7 +318,7 @@ flags_out:
+ 		}
+ 		ext4_journal_stop(handle);
+ setversion_out:
+-		mnt_drop_write(filp->f_path.mnt);
++//		mnt_drop_write(filp->f_path.mnt);
+ 		return err;
+ 	}
+ #ifdef CONFIG_JBD2_DEBUG
+@@ -356,9 +356,9 @@ setversion_out:
+ 		if (get_user(n_blocks_count, (__u32 __user *)arg))
+ 			return -EFAULT;
+ 
+-		err = mnt_want_write(filp->f_path.mnt);
++/*		err = mnt_want_write(filp->f_path.mnt);
+ 		if (err)
+-			return err;
++			return err;*/
+ 
+ 		err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count);
+ 		jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
+@@ -366,7 +366,7 @@ setversion_out:
+ 		jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
+ 		if (err == 0)
+ 			err = err2;
+-		mnt_drop_write(filp->f_path.mnt);
++//		mnt_drop_write(filp->f_path.mnt);
+ 
+ 		return err;
+ 	}
+@@ -382,9 +382,9 @@ setversion_out:
+ 				sizeof(input)))
+ 			return -EFAULT;
+ 
+-		err = mnt_want_write(filp->f_path.mnt);
++/*		err = mnt_want_write(filp->f_path.mnt);
+ 		if (err)
+-			return err;
++			return err;*/
+ 
+ 		err = ext4_group_add(sb, &input);
+ 		jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
+@@ -392,7 +392,7 @@ setversion_out:
+ 		jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
+ 		if (err == 0)
+ 			err = err2;
+-		mnt_drop_write(filp->f_path.mnt);
++//		mnt_drop_write(filp->f_path.mnt);
+ 
+ 		return err;
+ 	}
+@@ -403,9 +403,9 @@ setversion_out:
+ 		if (!is_owner_or_cap(inode))
+ 			return -EACCES;
+ 
+-		err = mnt_want_write(filp->f_path.mnt);
++/*		err = mnt_want_write(filp->f_path.mnt);
+ 		if (err)
+-			return err;
++			return err;*/
+ 		/*
+ 		 * inode_mutex prevent write and truncate on the file.
+ 		 * Read still goes through. We take i_data_sem in
+@@ -415,7 +415,7 @@ setversion_out:
+ 		mutex_lock(&(inode->i_mutex));
+ 		err = ext4_ext_migrate(inode);
+ 		mutex_unlock(&(inode->i_mutex));
+-		mnt_drop_write(filp->f_path.mnt);
++//		mnt_drop_write(filp->f_path.mnt);
+ 		return err;
+ 	}
+ 
diff --git a/ldiskfs/kernel_patches/patches/ext4-super-warning.patch b/ldiskfs/kernel_patches/patches/ext4-super-warning.patch
new file mode 100644
index 0000000..b82d3bc
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-super-warning.patch
@@ -0,0 +1,14 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -1299,7 +1299,7 @@ enum {
+ 	Opt_mballoc
+ };
+ 
+-static const match_table_t tokens = {
++static match_table_t tokens = {
+ 	{Opt_bsd_df, "bsddf"},
+ 	{Opt_minix_df, "minixdf"},
+ 	{Opt_grpid, "grpid"},
+
diff --git a/ldiskfs/kernel_patches/patches/ext4-unlink-race-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-unlink-race-rhel5.patch
new file mode 100644
index 0000000..f75ae84
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-unlink-race-rhel5.patch
@@ -0,0 +1,15 @@
+Index: linux-2.6.18.i386/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/namei.c
++++ linux-2.6.18.i386/fs/ext4/namei.c
+@@ -2299,8 +2299,8 @@ static int ext4_link (struct dentry * ol
+ 	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
+ 	 * otherwise has the potential to corrupt the orphan inode list.
+ 	 */
+-	if (inode->i_nlink == 0)
+-		return -ENOENT;
++	//if (inode->i_nlink == 0)
++	//	return -ENOENT;
+ 
+ retry:
+ 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
diff --git a/ldiskfs/kernel_patches/patches/ext4-unlink-race-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-unlink-race-sles11.patch
new file mode 100644
index 0000000..f75ae84
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-unlink-race-sles11.patch
@@ -0,0 +1,15 @@
+Index: linux-2.6.18.i386/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/namei.c
++++ linux-2.6.18.i386/fs/ext4/namei.c
+@@ -2299,8 +2299,8 @@ static int ext4_link (struct dentry * ol
+ 	 * Return -ENOENT if we've raced with unlink and i_nlink is 0.  Doing
+ 	 * otherwise has the potential to corrupt the orphan inode list.
+ 	 */
+-	if (inode->i_nlink == 0)
+-		return -ENOENT;
++	//if (inode->i_nlink == 0)
++	//	return -ENOENT;
+ 
+ retry:
+ 	handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
diff --git a/ldiskfs/kernel_patches/patches/ext4-wantedi-2.6-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-wantedi-2.6-rhel5.patch
new file mode 100644
index 0000000..e0c6f8d
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-wantedi-2.6-rhel5.patch
@@ -0,0 +1,169 @@
+Index: linux-2.6.18.i386/fs/ext4/ialloc.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ialloc.c
++++ linux-2.6.18.i386/fs/ext4/ialloc.c
+@@ -576,7 +576,8 @@ static int find_group_other(struct super
+  * For other inodes, search forward from the parent directory's block
+  * group to find a free inode.
+  */
+-struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
++struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode,
++			     unsigned long goal)
+ {
+ 	struct super_block *sb;
+ 	struct buffer_head *bitmap_bh = NULL;
+@@ -607,6 +608,43 @@ struct inode *ext4_new_inode(handle_t *h
+ 	sbi = EXT4_SB(sb);
+ 	es = sbi->s_es;
+ 
++	if (goal) {
++		group = (goal - 1) / EXT4_INODES_PER_GROUP(sb);
++		ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb);
++		err = -EIO;
++
++		gdp = ext4_get_group_desc(sb, group, &bh2);
++		if (!gdp)
++			goto fail;
++
++		bitmap_bh = ext4_read_inode_bitmap(sb, group);
++		if (!bitmap_bh)
++			goto fail;
++
++		BUFFER_TRACE(bh, "get_write_access");
++		err = ext4_journal_get_write_access(handle, bitmap_bh);
++		if (err)
++			goto fail;
++
++		if (ext4_set_bit_atomic(sb_bgl_lock(sbi, group),
++					ino, bitmap_bh->b_data)) {
++			printk(KERN_ERR "goal inode %lu unavailable\n", goal);
++			/* Oh well, we tried. */
++			goto continue_allocation;
++		}
++
++		BUFFER_TRACE(bh, "call ext4_journal_dirty_metadata");
++		err = ext4_journal_dirty_metadata(handle, bitmap_bh);
++		if (err)
++			goto fail;
++
++		/* We've shortcircuited the allocation system successfully,
++		 * now finish filling in the inode.
++		 */
++		goto got;
++	}
++
++continue_allocation:
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ret2 = find_group_flex(sb, dir, &group);
+ 		goto got_group;
+Index: linux-2.6.18.i386/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/namei.c
++++ linux-2.6.18.i386/fs/ext4/namei.c
+@@ -104,6 +104,7 @@ struct dx_entry
+ 	__le32 block;
+ };
+ 
++
+ /*
+  * dx_root_info is laid out so that if it should somehow get overlaid by a
+  * dirent the two low bits of the hash version will be zero.  Therefore, the
+@@ -149,6 +150,14 @@ struct dx_map_entry
+ 	u16 size;
+ };
+ 
++#define LVFS_DENTRY_PARAM_MAGIC		20070216UL
++struct lvfs_dentry_params
++{
++	unsigned long   p_inum;
++	void	    *p_ptr;
++	u32	     magic;
++};
++
+ static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
+ static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
+ static inline unsigned dx_get_hash (struct dx_entry *entry);
+@@ -1708,6 +1717,20 @@ static int ext4_add_nondir(handle_t *han
+ 	return err;
+ }
+ 
++static struct inode * ext4_new_inode_wantedi(handle_t *handle, struct inode *dir,
++						int mode, struct dentry *dentry)
++{
++	unsigned long inum = 0;
++
++	if (dentry->d_fsdata != NULL) {
++		struct lvfs_dentry_params *param = dentry->d_fsdata;
++
++		if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
++			inum = param->p_inum;
++	}
++	return ext4_new_inode(handle, dir, mode, inum);
++}
++
+ /*
+  * By the time this is called, we already have created
+  * the directory cache entry for the new file, but it
+@@ -1733,7 +1756,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode (handle, dir, mode);
++	inode = ext4_new_inode_wantedi (handle, dir, mode, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (!IS_ERR(inode)) {
+ 		inode->i_op = &ext4_file_inode_operations;
+@@ -1767,7 +1790,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode (handle, dir, mode);
++	inode = ext4_new_inode_wantedi (handle, dir, mode, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (!IS_ERR(inode)) {
+ 		init_special_inode(inode, inode->i_mode, rdev);
+@@ -1803,7 +1826,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode (handle, dir, S_IFDIR | mode);
++	inode = ext4_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (IS_ERR(inode))
+ 		goto out_stop;
+@@ -2203,7 +2226,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
++	inode = ext4_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (IS_ERR(inode))
+ 		goto out_stop;
+Index: linux-2.6.18.i386/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4.h
++++ linux-2.6.18.i386/fs/ext4/ext4.h
+@@ -1013,7 +1013,8 @@ extern int ext4fs_dirhash(const char *na
+ 			  dx_hash_info *hinfo);
+ 
+ /* ialloc.c */
+-extern struct inode * ext4_new_inode (handle_t *, struct inode *, int);
++extern struct inode * ext4_new_inode (handle_t *, struct inode *, int,
++				      unsigned long);
+ extern void ext4_free_inode (handle_t *, struct inode *);
+ extern struct inode * ext4_orphan_get (struct super_block *, unsigned long);
+ extern unsigned long ext4_count_free_inodes (struct super_block *);
+Index: linux-2.6.18.i386/fs/ext4/migrate.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/migrate.c
++++ linux-2.6.18.i386/fs/ext4/migrate.c
+@@ -485,7 +485,7 @@ int ext4_ext_migrate(struct inode *inode
+ 	}
+ 	tmp_inode = ext4_new_inode(handle,
+ 				inode->i_sb->s_root->d_inode,
+-				S_IFREG);
++				S_IFREG, 0);
+ 	if (IS_ERR(tmp_inode)) {
+ 		retval = -ENOMEM;
+ 		ext4_journal_stop(handle);
diff --git a/ldiskfs/kernel_patches/patches/ext4-wantedi-2.6-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-wantedi-2.6-sles11.patch
new file mode 100644
index 0000000..77097ec
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-wantedi-2.6-sles11.patch
@@ -0,0 +1,177 @@
+Index: linux-stage/fs/ext4/ialloc.c
+===================================================================
+--- linux-stage.orig/fs/ext4/ialloc.c
++++ linux-stage/fs/ext4/ialloc.c
+@@ -675,7 +675,8 @@ err_ret:
+  * For other inodes, search forward from the parent directory's block
+  * group to find a free inode.
+  */
+-struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode)
++struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode,
++			     unsigned long goal)
+ {
+ 	struct super_block *sb;
+ 	struct buffer_head *inode_bitmap_bh = NULL;
+@@ -706,6 +707,51 @@ struct inode *ext4_new_inode(handle_t *h
+ 	sbi = EXT4_SB(sb);
+ 	es = sbi->s_es;
+ 
++	if (goal) {
++		group = (goal - 1) / EXT4_INODES_PER_GROUP(sb);
++		ino = (goal - 1) % EXT4_INODES_PER_GROUP(sb);
++		err = -EIO;
++
++		gdp = ext4_get_group_desc(sb, group, &group_desc_bh);
++		if (!gdp)
++			goto fail;
++
++		inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
++		if (!inode_bitmap_bh)
++			goto fail;
++
++		BUFFER_TRACE(bh, "get_write_access");
++		err = ext4_journal_get_write_access(handle, inode_bitmap_bh);
++		if (err)
++			goto fail;
++
++		BUFFER_TRACE(group_desc_bh, "get_write_access");
++		err = ext4_journal_get_write_access(handle, group_desc_bh);
++		if (err)
++			goto fail;
++
++		err = ext4_claim_inode(sb, inode_bitmap_bh, ino, group, mode);
++		if (err) {
++			printk(KERN_ERR "goal inode %lu unavailable\n", goal);
++			/* Oh well, we tried. */
++			jbd2_journal_release_buffer(handle, inode_bitmap_bh);
++			jbd2_journal_release_buffer(handle, group_desc_bh);
++			goto continue_allocation;
++		}
++
++		/* we won it */
++		BUFFER_TRACE(inode_bitmap_bh,
++			     "call ext4_journal_dirty_metadata");
++		err = ext4_journal_dirty_metadata(handle, inode_bitmap_bh);
++		if (err)
++			goto fail;
++
++		/* zero bit is inode number 1*/
++		ino++;
++		goto got;
++	}
++
++continue_allocation:
+ 	if (sbi->s_log_groups_per_flex) {
+ 		ret2 = find_group_flex(sb, dir, &group);
+ 		goto got_group;
+Index: linux-stage/fs/ext4/namei.c
+===================================================================
+--- linux-stage.orig/fs/ext4/namei.c
++++ linux-stage/fs/ext4/namei.c
+@@ -104,6 +104,7 @@ struct dx_entry
+ 	__le32 block;
+ };
+ 
++
+ /*
+  * dx_root_info is laid out so that if it should somehow get overlaid by a
+  * dirent the two low bits of the hash version will be zero.  Therefore, the
+@@ -149,6 +150,14 @@ struct dx_map_entry
+ 	u16 size;
+ };
+ 
++#define LVFS_DENTRY_PARAM_MAGIC		20070216UL
++struct lvfs_dentry_params
++{
++	unsigned long   p_inum;
++	void	    *p_ptr;
++	u32	     magic;
++};
++
+ static inline ext4_lblk_t dx_get_block(struct dx_entry *entry);
+ static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value);
+ static inline unsigned dx_get_hash(struct dx_entry *entry);
+@@ -1716,6 +1725,20 @@ static int ext4_add_nondir(handle_t *han
+ 	return err;
+ }
+ 
++static struct inode * ext4_new_inode_wantedi(handle_t *handle, struct inode *dir,
++						int mode, struct dentry *dentry)
++{
++	unsigned long inum = 0;
++
++	if (dentry->d_fsdata != NULL) {
++		struct lvfs_dentry_params *param = dentry->d_fsdata;
++
++		if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
++			inum = param->p_inum;
++	}
++	return ext4_new_inode(handle, dir, mode, inum);
++}
++
+ /*
+  * By the time this is called, we already have created
+  * the directory cache entry for the new file, but it
+@@ -1741,7 +1764,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode (handle, dir, mode);
++	inode = ext4_new_inode_wantedi(handle, dir, mode, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (!IS_ERR(inode)) {
+ 		inode->i_op = &ext4_file_inode_operations;
+@@ -1775,7 +1798,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode(handle, dir, mode);
++	inode = ext4_new_inode_wantedi(handle, dir, mode, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (!IS_ERR(inode)) {
+ 		init_special_inode(inode, inode->i_mode, rdev);
+@@ -1811,7 +1834,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode(handle, dir, S_IFDIR | mode);
++	inode = ext4_new_inode_wantedi(handle, dir, S_IFDIR | mode, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (IS_ERR(inode))
+ 		goto out_stop;
+@@ -2211,7 +2234,7 @@ retry:
+ 	if (IS_DIRSYNC(dir))
+ 		handle->h_sync = 1;
+ 
+-	inode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO);
++	inode = ext4_new_inode_wantedi(handle, dir, S_IFLNK|S_IRWXUGO, dentry);
+ 	err = PTR_ERR(inode);
+ 	if (IS_ERR(inode))
+ 		goto out_stop;
+Index: linux-stage/fs/ext4/ext4.h
+===================================================================
+--- linux-stage.orig/fs/ext4/ext4.h
++++ linux-stage/fs/ext4/ext4.h
+@@ -1032,7 +1032,8 @@ extern int ext4fs_dirhash(const char *na
+ 			  dx_hash_info *hinfo);
+ 
+ /* ialloc.c */
+-extern struct inode * ext4_new_inode(handle_t *, struct inode *, int);
++extern struct inode * ext4_new_inode(handle_t *, struct inode *, int,
++				     unsigned long);
+ extern void ext4_free_inode(handle_t *, struct inode *);
+ extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
+ extern unsigned long ext4_count_free_inodes(struct super_block *);
+Index: linux-stage/fs/ext4/migrate.c
+===================================================================
+--- linux-stage.orig/fs/ext4/migrate.c
++++ linux-stage/fs/ext4/migrate.c
+@@ -484,7 +484,7 @@ int ext4_ext_migrate(struct inode *inode
+ 	}
+ 	tmp_inode = ext4_new_inode(handle,
+ 				inode->i_sb->s_root->d_inode,
+-				S_IFREG);
++				S_IFREG, 0);
+ 	if (IS_ERR(tmp_inode)) {
+ 		retval = -ENOMEM;
+ 		ext4_journal_stop(handle);
diff --git a/ldiskfs/kernel_patches/patches/ext4-xattr-no-update-ctime-rhel5.patch b/ldiskfs/kernel_patches/patches/ext4-xattr-no-update-ctime-rhel5.patch
new file mode 100644
index 0000000..66de9df
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-xattr-no-update-ctime-rhel5.patch
@@ -0,0 +1,32 @@
+Index: linux-2.6.18.i386/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4.h
++++ linux-2.6.18.i386/fs/ext4/ext4.h
+@@ -995,6 +995,13 @@ struct mmp_struct {
+ extern struct proc_dir_entry *proc_root_ext4;
+ 
+ /*
++ * Indicates that ctime should not be updated in ext4_xattr_set_handle()
++ */
++#ifndef XATTR_NO_CTIME
++#define XATTR_NO_CTIME 0x80
++#endif
++
++/*
+  * Function prototypes
+  */
+ 
+Index: linux-2.6.18.i386/fs/ext4/xattr.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/xattr.c
++++ linux-2.6.18.i386/fs/ext4/xattr.c
+@@ -1026,7 +1026,8 @@ ext4_xattr_set_handle(handle_t *handle, 
+ 	}
+ 	if (!error) {
+ 		ext4_xattr_update_super_block(handle, inode->i_sb);
+-		inode->i_ctime = ext4_current_time(inode);
++		if (!(flags & XATTR_NO_CTIME))
++			inode->i_ctime = ext4_current_time(inode);
+ 		if (!value)
+ 			EXT4_I(inode)->i_state &= ~EXT4_STATE_NO_EXPAND;
+ 		error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);
diff --git a/ldiskfs/kernel_patches/patches/ext4-xattr-no-update-ctime-sles11.patch b/ldiskfs/kernel_patches/patches/ext4-xattr-no-update-ctime-sles11.patch
new file mode 100644
index 0000000..66de9df
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/ext4-xattr-no-update-ctime-sles11.patch
@@ -0,0 +1,32 @@
+Index: linux-2.6.18.i386/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/ext4.h
++++ linux-2.6.18.i386/fs/ext4/ext4.h
+@@ -995,6 +995,13 @@ struct mmp_struct {
+ extern struct proc_dir_entry *proc_root_ext4;
+ 
+ /*
++ * Indicates that ctime should not be updated in ext4_xattr_set_handle()
++ */
++#ifndef XATTR_NO_CTIME
++#define XATTR_NO_CTIME 0x80
++#endif
++
++/*
+  * Function prototypes
+  */
+ 
+Index: linux-2.6.18.i386/fs/ext4/xattr.c
+===================================================================
+--- linux-2.6.18.i386.orig/fs/ext4/xattr.c
++++ linux-2.6.18.i386/fs/ext4/xattr.c
+@@ -1026,7 +1026,8 @@ ext4_xattr_set_handle(handle_t *handle, 
+ 	}
+ 	if (!error) {
+ 		ext4_xattr_update_super_block(handle, inode->i_sb);
+-		inode->i_ctime = ext4_current_time(inode);
++		if (!(flags & XATTR_NO_CTIME))
++			inode->i_ctime = ext4_current_time(inode);
+ 		if (!value)
+ 			EXT4_I(inode)->i_state &= ~EXT4_STATE_NO_EXPAND;
+ 		error = ext4_mark_iloc_dirty(handle, inode, &is.iloc);
diff --git a/ldiskfs/kernel_patches/patches/iopen-2.6.18-rhel5-ext4.patch b/ldiskfs/kernel_patches/patches/iopen-2.6.18-rhel5-ext4.patch
new file mode 100644
index 0000000..d7b94fa
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/iopen-2.6.18-rhel5-ext4.patch
@@ -0,0 +1,512 @@
+Index: linux-2.6.18-128.1.6/fs/ext4/iopen.c
+===================================================================
+--- /dev/null
++++ linux-2.6.18-128.1.6/fs/ext4/iopen.c
+@@ -0,0 +1,295 @@
++/*
++ * linux/fs/ext4/iopen.c
++ *
++ * Special support for open by inode number
++ *
++ * Copyright (C) 2001 by Theodore Ts'o (tytso at alum.mit.edu).
++ *
++ * This file may be redistributed under the terms of the GNU General
++ * Public License.
++ *
++ *
++ * Invariants:
++ *   - there is only ever a single DCACHE_NFSD_DISCONNECTED dentry alias
++ *     for an inode at one time.
++ *   - there are never both connected and DCACHE_NFSD_DISCONNECTED dentry
++ *     aliases on an inode at the same time.
++ *
++ * If we have any connected dentry aliases for an inode, use one of those
++ * in iopen_lookup().  Otherwise, we instantiate a single NFSD_DISCONNECTED
++ * dentry for this inode, which thereafter will be found by the dcache
++ * when looking up this inode number in __iopen__, so we don't return here
++ * until it is gone.
++ *
++ * If we get an inode via a regular name lookup, then we "rename" the
++ * NFSD_DISCONNECTED dentry to the proper name and parent.  This ensures
++ * existing users of the disconnected dentry will continue to use the same
++ * dentry as the connected users, and there will never be both kinds of
++ * dentry aliases at one time.
++ */
++
++#include <linux/sched.h>
++#include <linux/fs.h>
++#include <linux/smp_lock.h>
++#include <linux/dcache.h>
++#include <linux/security.h>
++#include "iopen.h"
++#include "ext4.h"
++#include "ext4_jbd2.h"
++
++#ifndef assert
++#define assert(test) J_ASSERT(test)
++#endif
++
++#define IOPEN_NAME_LEN	32
++
++/*
++ * This implements looking up an inode by number.
++ */
++static struct dentry *iopen_lookup(struct inode * dir, struct dentry *dentry,
++				   struct nameidata *nd)
++{
++	struct inode *inode;
++	unsigned long ino;
++	struct list_head *lp;
++	struct dentry *alternate;
++	char buf[IOPEN_NAME_LEN];
++
++	if (dentry->d_name.len >= IOPEN_NAME_LEN)
++		return ERR_PTR(-ENAMETOOLONG);
++
++	memcpy(buf, dentry->d_name.name, dentry->d_name.len);
++	buf[dentry->d_name.len] = 0;
++
++	if (strcmp(buf, ".") == 0)
++		ino = dir->i_ino;
++	else if (strcmp(buf, "..") == 0)
++		ino = EXT4_ROOT_INO;
++	else
++		ino = simple_strtoul(buf, 0, 0);
++
++	if ((ino != EXT4_ROOT_INO &&
++	     ino < EXT4_FIRST_INO(dir->i_sb)) ||
++	    ino > le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count))
++		return ERR_PTR(-ENOENT);
++
++	inode = ext4_iget(dir->i_sb, ino);
++	if (IS_ERR(inode)) {
++		 /* Newer kernels return -ESTALE for inodes that are not in use,
++		  * but older kernels return a negative dentry. This can only
++		  * happen when doing a lookup in the __iopen__ dir, because the
++		  * "entry" will always be found even if inode is unallocated.
++		  * Handle this here instead of fixing the callers. b=19114 */
++		if (PTR_ERR(inode) == -ESTALE)
++			return (ERR_PTR(-ENOENT));
++		return ERR_CAST(inode);
++	}
++
++	assert(list_empty(&dentry->d_alias));		/* d_instantiate */
++	assert(d_unhashed(dentry));			/* d_rehash */
++
++	/* preferrably return a connected dentry */
++	spin_lock(&dcache_lock);
++	list_for_each(lp, &inode->i_dentry) {
++		alternate = list_entry(lp, struct dentry, d_alias);
++		assert(!(alternate->d_flags & DCACHE_DISCONNECTED));
++	}
++
++	if (!list_empty(&inode->i_dentry)) {
++		alternate = list_entry(inode->i_dentry.next,
++				       struct dentry, d_alias);
++		dget_locked(alternate);
++		spin_lock(&alternate->d_lock);
++		alternate->d_flags |= DCACHE_REFERENCED;
++		spin_unlock(&alternate->d_lock);
++		iput(inode);
++		spin_unlock(&dcache_lock);
++		return alternate;
++	}
++	dentry->d_flags |= DCACHE_DISCONNECTED;
++
++	/* d_add(), but don't drop dcache_lock before adding dentry to inode */
++	list_add(&dentry->d_alias, &inode->i_dentry);	/* d_instantiate */
++	dentry->d_inode = inode;
++
++	d_rehash_cond(dentry, 0);
++	spin_unlock(&dcache_lock);
++
++	return NULL;
++}
++
++/* This function is spliced into ext4_lookup and does the move of a
++ * disconnected dentry (if it exists) to a connected dentry.
++ */
++struct dentry *iopen_connect_dentry(struct dentry *dentry, struct inode *inode,
++				    int rehash)
++{
++	struct dentry *tmp, *goal = NULL;
++	struct list_head *lp;
++
++	/* verify this dentry is really new */
++	assert(dentry->d_inode == NULL);
++	assert(list_empty(&dentry->d_alias));		/* d_instantiate */
++	if (rehash)
++		assert(d_unhashed(dentry));		/* d_rehash */
++	assert(list_empty(&dentry->d_subdirs));
++
++	spin_lock(&dcache_lock);
++	if (!inode)
++		goto do_rehash;
++
++	if (!test_opt(inode->i_sb, IOPEN))
++		goto do_instantiate;
++
++	/* preferrably return a connected dentry */
++	list_for_each(lp, &inode->i_dentry) {
++		tmp = list_entry(lp, struct dentry, d_alias);
++		if (tmp->d_flags & DCACHE_DISCONNECTED) {
++			assert(tmp->d_alias.next == &inode->i_dentry);
++			assert(tmp->d_alias.prev == &inode->i_dentry);
++			goal = tmp;
++			dget_locked(goal);
++			break;
++		}
++	}
++
++	if (!goal)
++		goto do_instantiate;
++
++	/* Move the goal to the de hash queue */
++	goal->d_flags &= ~DCACHE_DISCONNECTED;
++	security_d_instantiate(goal, inode);
++	__d_drop(dentry);
++	d_rehash_cond(dentry, 0);
++	d_move_locked(goal, dentry);
++	spin_unlock(&dcache_lock);
++	iput(inode);
++
++	return goal;
++
++	/* d_add(), but don't drop dcache_lock before adding dentry to inode */
++do_instantiate:
++	list_add(&dentry->d_alias, &inode->i_dentry);	/* d_instantiate */
++	dentry->d_inode = inode;
++do_rehash:
++	if (rehash)
++		d_rehash_cond(dentry, 0);
++	spin_unlock(&dcache_lock);
++
++	return NULL;
++}
++
++/*
++ * Similar as d_instantiate() except that it drops the disconnected
++ * dentry if any.
++ */
++void iopen_d_instantiate(struct dentry *dentry, struct inode * inode)
++{
++	struct dentry *dis_dentry;
++
++	/* verify this dentry is really new */
++	assert(dentry->d_inode == NULL);
++	assert(list_empty(&dentry->d_alias));
++
++	spin_lock(&dcache_lock);
++	if (!inode || !test_opt(inode->i_sb, IOPEN) ||
++	    list_empty(&inode->i_dentry))
++		goto do_instantiate;
++
++	/* a disconnected dentry has been added in our back,
++	 * we have to drop this dentry, see bug 16362/15713*/
++	dis_dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias);
++	spin_lock(&dis_dentry->d_lock);
++	assert(dis_dentry->d_alias.next == &inode->i_dentry);
++	assert(dis_dentry->d_alias.prev == &inode->i_dentry);
++	assert(dis_dentry->d_flags & DCACHE_DISCONNECTED);
++	__d_drop(dis_dentry);
++	list_del_init(&dis_dentry->d_alias);
++	spin_unlock(&dis_dentry->d_lock);
++
++do_instantiate:
++	if (inode)
++		list_add(&dentry->d_alias, &inode->i_dentry);
++	dentry->d_inode = inode;
++	spin_unlock(&dcache_lock);
++	security_d_instantiate(dentry, inode);
++}
++
++/*
++ * These are the special structures for the iopen pseudo directory.
++ */
++
++static struct inode_operations iopen_inode_operations = {
++	lookup:		iopen_lookup,		/* BKL held */
++};
++
++static struct file_operations iopen_file_operations = {
++	read:		generic_read_dir,
++};
++
++static int match_dentry(struct dentry *dentry, const char *name)
++{
++	int	len;
++
++	len = strlen(name);
++	if (dentry->d_name.len != len)
++		return 0;
++	if (strncmp(dentry->d_name.name, name, len))
++		return 0;
++	return 1;
++}
++
++/*
++ * This function is spliced into ext4_lookup and returns 1 the file
++ * name is __iopen__ and dentry has been filled in appropriately.
++ */
++int ext4_check_for_iopen(struct inode *dir, struct dentry *dentry)
++{
++	struct inode *inode;
++
++	if (dir->i_ino != EXT4_ROOT_INO ||
++	    !test_opt(dir->i_sb, IOPEN) ||
++	    !match_dentry(dentry, "__iopen__"))
++		return 0;
++
++	inode = ext4_iget(dir->i_sb, EXT4_BAD_INO);
++	if (IS_ERR(inode))
++		return 0;
++
++	d_add(dentry, inode);
++	return 1;
++}
++
++/*
++ * This function is spliced into read_inode; it returns 1 if inode
++ * number is the one for /__iopen__, in which case the inode is filled
++ * in appropriately.  Otherwise, this fuction returns 0.
++ */
++int ext4_iopen_get_inode(struct inode *inode)
++{
++	if (inode->i_ino != EXT4_BAD_INO)
++		return 0;
++
++	inode->i_mode = S_IFDIR | S_IRUSR | S_IXUSR;
++	if (test_opt(inode->i_sb, IOPEN_NOPRIV))
++		inode->i_mode |= 0777;
++	inode->i_uid = 0;
++	inode->i_gid = 0;
++	inode->i_nlink = 1;
++	inode->i_size = 4096;
++	inode->i_atime = inode->i_ctime = inode->i_mtime =  ext4_current_time(inode);
++	EXT4_I(inode)->i_dtime = 0;
++	EXT4_I(inode)->i_file_acl = 0;
++	inode->i_blocks = 0;
++	inode->i_version = 1;
++	inode->i_generation = 0;
++
++	inode->i_op = &iopen_inode_operations;
++	inode->i_fop = &iopen_file_operations;
++	inode->i_mapping->a_ops = 0;
++
++	if (inode->i_state & I_NEW)
++		unlock_new_inode(inode);
++
++	return 1;
++}
+Index: linux-2.6.18-128.1.6/fs/ext4/iopen.h
+===================================================================
+--- /dev/null
++++ linux-2.6.18-128.1.6/fs/ext4/iopen.h
+@@ -0,0 +1,16 @@
++/*
++ * iopen.h
++ *
++ * Special support for opening files by inode number.
++ *
++ * Copyright (C) 2001 by Theodore Ts'o (tytso at alum.mit.edu).
++ *
++ * This file may be redistributed under the terms of the GNU General
++ * Public License.
++ */
++
++extern int ext4_check_for_iopen(struct inode *dir, struct dentry *dentry);
++extern int ext4_iopen_get_inode(struct inode *inode);
++extern struct dentry *iopen_connect_dentry(struct dentry *dentry,
++					   struct inode *inode, int rehash);
++extern void iopen_d_instantiate(struct dentry *dentry, struct inode * inode);
+Index: linux-2.6.18-128.1.6/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/inode.c
++++ linux-2.6.18-128.1.6/fs/ext4/inode.c
+@@ -37,6 +37,7 @@
+ #include <linux/bio.h>
+ #include "ext4_jbd2.h"
+ #include "xattr.h"
++#include "iopen.h"
+ #include "acl.h"
+ 
+ /*
+@@ -2764,6 +2765,8 @@ struct inode *ext4_iget(struct super_blo
+ 	ei->i_default_acl = EXT4_ACL_NOT_CACHED;
+ #endif
+ 	ei->i_block_alloc_info = NULL;
++	if (ext4_iopen_get_inode(inode))
++		return inode;
+ 
+ 	ret = __ext4_get_inode_loc(inode, &iloc, 0);
+ 	if (ret < 0)
+Index: linux-2.6.18-128.1.6/fs/ext4/super.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/super.c
++++ linux-2.6.18-128.1.6/fs/ext4/super.c
+@@ -888,6 +888,7 @@ enum {
+ 	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
+ 	Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
+ 	Opt_mballoc, Opt_nomballoc, Opt_stripe,
++	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
+ };
+ 
+ static match_table_t tokens = {
+@@ -938,6 +939,9 @@ static match_table_t tokens = {
+ 	{Opt_noquota, "noquota"},
+ 	{Opt_quota, "quota"},
+ 	{Opt_usrquota, "usrquota"},
++	{Opt_iopen, "iopen"},
++	{Opt_noiopen, "noiopen"},
++	{Opt_iopen_nopriv, "iopen_nopriv"},
+ 	{Opt_barrier, "barrier=%u"},
+ 	{Opt_extents, "extents"},
+ 	{Opt_noextents, "noextents"},
+@@ -1270,6 +1274,18 @@ clear_qf_name:
+ 			else
+ 				clear_opt(sbi->s_mount_opt, BARRIER);
+ 			break;
++		case Opt_iopen:
++			set_opt (sbi->s_mount_opt, IOPEN);
++			clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV);
++			break;
++		case Opt_noiopen:
++			clear_opt (sbi->s_mount_opt, IOPEN);
++			clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV);
++			break;
++		case Opt_iopen_nopriv:
++			set_opt (sbi->s_mount_opt, IOPEN);
++			set_opt (sbi->s_mount_opt, IOPEN_NOPRIV);
++			break;
+ 		case Opt_ignore:
+ 			break;
+ 		case Opt_resize:
+Index: linux-2.6.18-128.1.6/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/namei.c
++++ linux-2.6.18-128.1.6/fs/ext4/namei.c
+@@ -39,6 +39,7 @@
+ 
+ #include "namei.h"
+ #include "xattr.h"
++#include "iopen.h"
+ #include "acl.h"
+ 
+ /*
+@@ -1048,6 +1049,9 @@ static struct dentry *ext4_lookup(struct
+ 	if (dentry->d_name.len > EXT4_NAME_LEN)
+ 		return ERR_PTR(-ENAMETOOLONG);
+ 
++	if (ext4_check_for_iopen(dir, dentry))
++		return NULL;
++
+ 	bh = ext4_find_entry(dentry, &de);
+ 	inode = NULL;
+ 	if (bh) {
+@@ -1062,7 +1066,8 @@ static struct dentry *ext4_lookup(struct
+ 		if (IS_ERR(inode))
+ 			return ERR_CAST(inode);
+ 	}
+-	return d_splice_alias(inode, dentry);
++
++	return iopen_connect_dentry(dentry, inode, 1);
+ }
+ 
+ 
+@@ -1709,7 +1714,7 @@ static int ext4_add_nondir(handle_t *han
+ 	int err = ext4_add_entry(handle, dentry, inode);
+ 	if (!err) {
+ 		ext4_mark_inode_dirty(handle, inode);
+-		d_instantiate(dentry, inode);
++		iopen_d_instantiate(dentry, inode);
+ 		return 0;
+ 	}
+ 	drop_nlink(inode);
+@@ -1868,7 +1873,7 @@ out_clear_inode:
+ 	ext4_inc_count(handle, dir);
+ 	ext4_update_dx_flag(dir);
+ 	ext4_mark_inode_dirty(handle, dir);
+-	d_instantiate(dentry, inode);
++	iopen_d_instantiate(dentry, inode);
+ out_stop:
+ 	ext4_journal_stop(handle);
+ 	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+@@ -2134,10 +2139,6 @@ static int ext4_rmdir (struct inode * di
+ 			      inode->i_nlink);
+ 	inode->i_version++;
+ 	clear_nlink(inode);
+-	/* There's no need to set i_disksize: the fact that i_nlink is
+-	 * zero will ensure that the right thing happens during any
+-	 * recovery. */
+-	inode->i_size = 0;
+ 	ext4_orphan_add(handle, inode);
+ 	inode->i_ctime = dir->i_ctime = dir->i_mtime = ext4_current_time(inode);
+ 	ext4_mark_inode_dirty(handle, inode);
+@@ -2263,6 +2264,23 @@ out_stop:
+ 	return err;
+ }
+ 
++/* Like ext4_add_nondir() except for call to iopen_connect_dentry */
++static int ext4_add_link(handle_t *handle, struct dentry *dentry,
++			 struct inode *inode)
++{
++	int err = ext4_add_entry(handle, dentry, inode);
++	if (!err) {
++		err = ext4_mark_inode_dirty(handle, inode);
++		if (err == 0) {
++			dput(iopen_connect_dentry(dentry, inode, 0));
++			return 0;
++		}
++	}
++	ext4_dec_count(handle, inode);
++	iput(inode);
++	return err;
++}
++
+ static int ext4_link (struct dentry * old_dentry,
+ 		struct inode * dir, struct dentry *dentry)
+ {
+@@ -2293,7 +2311,8 @@ retry:
+ 	ext4_inc_count(handle, inode);
+ 	atomic_inc(&inode->i_count);
+ 
+-	err = ext4_add_nondir(handle, dentry, inode);
++	err = ext4_add_link(handle, dentry, inode);
++	ext4_orphan_del(handle, inode);
+ 	ext4_journal_stop(handle);
+ 	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+ 		goto retry;
+Index: linux-2.6.18-128.1.6/fs/ext4/Makefile
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/Makefile
++++ linux-2.6.18-128.1.6/fs/ext4/Makefile
+@@ -4,7 +4,7 @@
+ 
+ obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
+ 
+-ext4dev-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
++ext4dev-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
+ 		   ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
+ 		   ext4_jbd2.o migrate.o mballoc.o
+ 
+Index: linux-2.6.18-128.1.6/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/ext4/ext4.h
++++ linux-2.6.18-128.1.6/fs/ext4/ext4.h
+@@ -18,6 +18,7 @@
+ 
+ #include <linux/types.h>
+ #include <linux/blkdev.h>
++#include <linux/jbd2.h>
+ #include "ext4_i.h"
+ 
+ #define EXT4_SUPER_MAGIC	0xEF53
+@@ -537,6 +538,8 @@ do {									       \
+ #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT	0x1000000 /* Journal Async Commit */
+ #define EXT4_MOUNT_I_VERSION            0x2000000 /* i_version support */
+ #define EXT4_MOUNT_MBALLOC		0x4000000 /* Buddy allocation support */
++#define EXT4_MOUNT_IOPEN		0x8000000 /* Allow access via iopen */
++#define EXT4_MOUNT_IOPEN_NOPRIV		0x10000000 /* Make iopen world-readable */
+ /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
+ #ifndef _LINUX_EXT2_FS_H
+ #define clear_opt(o, opt)		o &= ~EXT4_MOUNT_##opt
diff --git a/ldiskfs/kernel_patches/patches/iopen-sles11.patch b/ldiskfs/kernel_patches/patches/iopen-sles11.patch
new file mode 100644
index 0000000..9fa64dc
--- /dev/null
+++ b/ldiskfs/kernel_patches/patches/iopen-sles11.patch
@@ -0,0 +1,507 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/iopen.c
+===================================================================
+--- /dev/null
++++ linux-2.6.27.21-0.1/fs/ext4/iopen.c
+@@ -0,0 +1,295 @@
++/*
++ * linux/fs/ext4/iopen.c
++ *
++ * Special support for open by inode number
++ *
++ * Copyright (C) 2001 by Theodore Ts'o (tytso at alum.mit.edu).
++ *
++ * This file may be redistributed under the terms of the GNU General
++ * Public License.
++ *
++ *
++ * Invariants:
++ *   - there is only ever a single DCACHE_NFSD_DISCONNECTED dentry alias
++ *     for an inode at one time.
++ *   - there are never both connected and DCACHE_NFSD_DISCONNECTED dentry
++ *     aliases on an inode at the same time.
++ *
++ * If we have any connected dentry aliases for an inode, use one of those
++ * in iopen_lookup().  Otherwise, we instantiate a single NFSD_DISCONNECTED
++ * dentry for this inode, which thereafter will be found by the dcache
++ * when looking up this inode number in __iopen__, so we don't return here
++ * until it is gone.
++ *
++ * If we get an inode via a regular name lookup, then we "rename" the
++ * NFSD_DISCONNECTED dentry to the proper name and parent.  This ensures
++ * existing users of the disconnected dentry will continue to use the same
++ * dentry as the connected users, and there will never be both kinds of
++ * dentry aliases at one time.
++ */
++
++#include <linux/sched.h>
++#include <linux/fs.h>
++#include <linux/smp_lock.h>
++#include <linux/dcache.h>
++#include <linux/security.h>
++#include "iopen.h"
++#include "ext4.h"
++#include "ext4_jbd2.h"
++
++#ifndef assert
++#define assert(test) J_ASSERT(test)
++#endif
++
++#define IOPEN_NAME_LEN	32
++
++/*
++ * This implements looking up an inode by number.
++ */
++static struct dentry *iopen_lookup(struct inode * dir, struct dentry *dentry,
++				   struct nameidata *nd)
++{
++	struct inode *inode;
++	unsigned long ino;
++	struct list_head *lp;
++	struct dentry *alternate;
++	char buf[IOPEN_NAME_LEN];
++
++	if (dentry->d_name.len >= IOPEN_NAME_LEN)
++		return ERR_PTR(-ENAMETOOLONG);
++
++	memcpy(buf, dentry->d_name.name, dentry->d_name.len);
++	buf[dentry->d_name.len] = 0;
++
++	if (strcmp(buf, ".") == 0)
++		ino = dir->i_ino;
++	else if (strcmp(buf, "..") == 0)
++		ino = EXT4_ROOT_INO;
++	else
++		ino = simple_strtoul(buf, 0, 0);
++
++	if ((ino != EXT4_ROOT_INO &&
++	     ino < EXT4_FIRST_INO(dir->i_sb)) ||
++	    ino > le32_to_cpu(EXT4_SB(dir->i_sb)->s_es->s_inodes_count))
++		return ERR_PTR(-ENOENT);
++
++	inode = ext4_iget(dir->i_sb, ino);
++	if (IS_ERR(inode)) {
++		 /* Newer kernels return -ESTALE for inodes that are not in use,
++		  * but older kernels return a negative dentry. This can only
++		  * happen when doing a lookup in the __iopen__ dir, because the
++		  * "entry" will always be found even if inode is unallocated.
++		  * Handle this here instead of fixing the callers. b=19114 */
++		if (PTR_ERR(inode) == -ESTALE)
++			return (ERR_PTR(-ENOENT));
++		return ERR_CAST(inode);
++	}
++
++	assert(list_empty(&dentry->d_alias));		/* d_instantiate */
++	assert(d_unhashed(dentry));			/* d_rehash */
++
++	/* preferrably return a connected dentry */
++	spin_lock(&dcache_lock);
++	list_for_each(lp, &inode->i_dentry) {
++		alternate = list_entry(lp, struct dentry, d_alias);
++		assert(!(alternate->d_flags & DCACHE_DISCONNECTED));
++	}
++
++	if (!list_empty(&inode->i_dentry)) {
++		alternate = list_entry(inode->i_dentry.next,
++				       struct dentry, d_alias);
++		dget_locked(alternate);
++		spin_lock(&alternate->d_lock);
++		alternate->d_flags |= DCACHE_REFERENCED;
++		spin_unlock(&alternate->d_lock);
++		iput(inode);
++		spin_unlock(&dcache_lock);
++		return alternate;
++	}
++	dentry->d_flags |= DCACHE_DISCONNECTED;
++
++	/* d_add(), but don't drop dcache_lock before adding dentry to inode */
++	list_add(&dentry->d_alias, &inode->i_dentry);	/* d_instantiate */
++	dentry->d_inode = inode;
++
++	d_rehash_cond(dentry, 0);
++	spin_unlock(&dcache_lock);
++
++	return NULL;
++}
++
++/* This function is spliced into ext4_lookup and does the move of a
++ * disconnected dentry (if it exists) to a connected dentry.
++ */
++struct dentry *iopen_connect_dentry(struct dentry *dentry, struct inode *inode,
++				    int rehash)
++{
++	struct dentry *tmp, *goal = NULL;
++	struct list_head *lp;
++
++	/* verify this dentry is really new */
++	assert(dentry->d_inode == NULL);
++	assert(list_empty(&dentry->d_alias));		/* d_instantiate */
++	if (rehash)
++		assert(d_unhashed(dentry));		/* d_rehash */
++	assert(list_empty(&dentry->d_subdirs));
++
++	spin_lock(&dcache_lock);
++	if (!inode)
++		goto do_rehash;
++
++	if (!test_opt(inode->i_sb, IOPEN))
++		goto do_instantiate;
++
++	/* preferrably return a connected dentry */
++	list_for_each(lp, &inode->i_dentry) {
++		tmp = list_entry(lp, struct dentry, d_alias);
++		if (tmp->d_flags & DCACHE_DISCONNECTED) {
++			assert(tmp->d_alias.next == &inode->i_dentry);
++			assert(tmp->d_alias.prev == &inode->i_dentry);
++			goal = tmp;
++			dget_locked(goal);
++			break;
++		}
++	}
++
++	if (!goal)
++		goto do_instantiate;
++
++	/* Move the goal to the de hash queue */
++	goal->d_flags &= ~DCACHE_DISCONNECTED;
++	security_d_instantiate(goal, inode);
++	__d_drop(dentry);
++	d_rehash_cond(dentry, 0);
++	d_move_locked(goal, dentry);
++	spin_unlock(&dcache_lock);
++	iput(inode);
++
++	return goal;
++
++	/* d_add(), but don't drop dcache_lock before adding dentry to inode */
++do_instantiate:
++	list_add(&dentry->d_alias, &inode->i_dentry);	/* d_instantiate */
++	dentry->d_inode = inode;
++do_rehash:
++	if (rehash)
++		d_rehash_cond(dentry, 0);
++	spin_unlock(&dcache_lock);
++
++	return NULL;
++}
++
++/*
++ * Similar as d_instantiate() except that it drops the disconnected
++ * dentry if any.
++ */
++void iopen_d_instantiate(struct dentry *dentry, struct inode * inode)
++{
++	struct dentry *dis_dentry;
++
++	/* verify this dentry is really new */
++	assert(dentry->d_inode == NULL);
++	assert(list_empty(&dentry->d_alias));
++
++	spin_lock(&dcache_lock);
++	if (!inode || !test_opt(inode->i_sb, IOPEN) ||
++	    list_empty(&inode->i_dentry))
++		goto do_instantiate;
++
++	/* a disconnected dentry has been added in our back,
++	 * we have to drop this dentry, see bug 16362/15713*/
++	dis_dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias);
++	spin_lock(&dis_dentry->d_lock);
++	assert(dis_dentry->d_alias.next == &inode->i_dentry);
++	assert(dis_dentry->d_alias.prev == &inode->i_dentry);
++	assert(dis_dentry->d_flags & DCACHE_DISCONNECTED);
++	__d_drop(dis_dentry);
++	list_del_init(&dis_dentry->d_alias);
++	spin_unlock(&dis_dentry->d_lock);
++
++do_instantiate:
++	if (inode)
++		list_add(&dentry->d_alias, &inode->i_dentry);
++	dentry->d_inode = inode;
++	spin_unlock(&dcache_lock);
++	security_d_instantiate(dentry, inode);
++}
++
++/*
++ * These are the special structures for the iopen pseudo directory.
++ */
++
++static struct inode_operations iopen_inode_operations = {
++	lookup:		iopen_lookup,		/* BKL held */
++};
++
++static struct file_operations iopen_file_operations = {
++	read:		generic_read_dir,
++};
++
++static int match_dentry(struct dentry *dentry, const char *name)
++{
++	int	len;
++
++	len = strlen(name);
++	if (dentry->d_name.len != len)
++		return 0;
++	if (strncmp(dentry->d_name.name, name, len))
++		return 0;
++	return 1;
++}
++
++/*
++ * This function is spliced into ext4_lookup and returns 1 the file
++ * name is __iopen__ and dentry has been filled in appropriately.
++ */
++int ext4_check_for_iopen(struct inode *dir, struct dentry *dentry)
++{
++	struct inode *inode;
++
++	if (dir->i_ino != EXT4_ROOT_INO ||
++	    !test_opt(dir->i_sb, IOPEN) ||
++	    !match_dentry(dentry, "__iopen__"))
++		return 0;
++
++	inode = ext4_iget(dir->i_sb, EXT4_BAD_INO);
++	if (IS_ERR(inode))
++		return 0;
++
++	d_add(dentry, inode);
++	return 1;
++}
++
++/*
++ * This function is spliced into read_inode; it returns 1 if inode
++ * number is the one for /__iopen__, in which case the inode is filled
++ * in appropriately.  Otherwise, this fuction returns 0.
++ */
++int ext4_iopen_get_inode(struct inode *inode)
++{
++	if (inode->i_ino != EXT4_BAD_INO)
++		return 0;
++
++	inode->i_mode = S_IFDIR | S_IRUSR | S_IXUSR;
++	if (test_opt(inode->i_sb, IOPEN_NOPRIV))
++		inode->i_mode |= 0777;
++	inode->i_uid = 0;
++	inode->i_gid = 0;
++	inode->i_nlink = 1;
++	inode->i_size = 4096;
++	inode->i_atime = inode->i_ctime = inode->i_mtime =  ext4_current_time(inode);
++	EXT4_I(inode)->i_dtime = 0;
++	EXT4_I(inode)->i_file_acl = 0;
++	inode->i_blocks = 0;
++	inode->i_version = 1;
++	inode->i_generation = 0;
++
++	inode->i_op = &iopen_inode_operations;
++	inode->i_fop = &iopen_file_operations;
++	inode->i_mapping->a_ops = 0;
++
++	if (inode->i_state & I_NEW)
++		unlock_new_inode(inode);
++
++	return 1;
++}
+Index: linux-2.6.27.21-0.1/fs/ext4/iopen.h
+===================================================================
+--- /dev/null
++++ linux-2.6.27.21-0.1/fs/ext4/iopen.h
+@@ -0,0 +1,16 @@
++/*
++ * iopen.h
++ *
++ * Special support for opening files by inode number.
++ *
++ * Copyright (C) 2001 by Theodore Ts'o (tytso at alum.mit.edu).
++ *
++ * This file may be redistributed under the terms of the GNU General
++ * Public License.
++ */
++
++extern int ext4_check_for_iopen(struct inode *dir, struct dentry *dentry);
++extern int ext4_iopen_get_inode(struct inode *inode);
++extern struct dentry *iopen_connect_dentry(struct dentry *dentry,
++					   struct inode *inode, int rehash);
++extern void iopen_d_instantiate(struct dentry *dentry, struct inode * inode);
+Index: linux-2.6.27.21-0.1/fs/ext4/inode.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/inode.c
++++ linux-2.6.27.21-0.1/fs/ext4/inode.c
+@@ -38,6 +38,7 @@
+ #include <linux/bio.h>
+ #include "ext4_jbd2.h"
+ #include "xattr.h"
++#include "iopen.h"
+ #include "acl.h"
+ #include "ext4_extents.h"
+ 
+@@ -4115,6 +4116,9 @@ struct inode *ext4_iget(struct super_blo
+ 	ei->i_default_acl = EXT4_ACL_NOT_CACHED;
+ #endif
+ 
++	if (ext4_iopen_get_inode(inode))
++		return inode;
++
+ 	ret = __ext4_get_inode_loc(inode, &iloc, 0);
+ 	if (ret < 0)
+ 		goto bad_inode;
+Index: linux-2.6.27.21-0.1/fs/ext4/super.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/super.c
++++ linux-2.6.27.21-0.1/fs/ext4/super.c
+@@ -955,7 +955,8 @@ enum {
+ 	Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
+ 	Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
+ 	Opt_stripe, Opt_delalloc, Opt_nodelalloc,
+-	Opt_inode_readahead_blks
++	Opt_inode_readahead_blks,
++	Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
+ };
+ 
+ static const match_table_t tokens = {
+@@ -1004,6 +1005,9 @@ static const match_table_t tokens = {
+ 	{Opt_noquota, "noquota"},
+ 	{Opt_quota, "quota"},
+ 	{Opt_usrquota, "usrquota"},
++	{Opt_iopen, "iopen"},
++	{Opt_noiopen, "noiopen"},
++	{Opt_iopen_nopriv, "iopen_nopriv"},
+ 	{Opt_barrier, "barrier=%u"},
+ 	{Opt_extents, "extents"},
+ 	{Opt_noextents, "noextents"},
+@@ -1347,6 +1351,18 @@ set_qf_format:
+ 			else
+ 				clear_opt(sbi->s_mount_opt, BARRIER);
+ 			break;
++		case Opt_iopen:
++			set_opt (sbi->s_mount_opt, IOPEN);
++			clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV);
++			break;
++		case Opt_noiopen:
++			clear_opt (sbi->s_mount_opt, IOPEN);
++			clear_opt (sbi->s_mount_opt, IOPEN_NOPRIV);
++			break;
++		case Opt_iopen_nopriv:
++			set_opt (sbi->s_mount_opt, IOPEN);
++			set_opt (sbi->s_mount_opt, IOPEN_NOPRIV);
++			break;
+ 		case Opt_ignore:
+ 			break;
+ 		case Opt_resize:
+Index: linux-2.6.27.21-0.1/fs/ext4/namei.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/namei.c
++++ linux-2.6.27.21-0.1/fs/ext4/namei.c
+@@ -39,6 +39,7 @@
+ 
+ #include "namei.h"
+ #include "xattr.h"
++#include "iopen.h"
+ #include "acl.h"
+ 
+ /*
+@@ -1054,6 +1055,9 @@ static struct dentry *ext4_lookup(struct
+ 	if (dentry->d_name.len > EXT4_NAME_LEN)
+ 		return ERR_PTR(-ENAMETOOLONG);
+ 
++	if (ext4_check_for_iopen(dir, dentry))
++		return NULL;
++
+ 	bh = ext4_find_entry(dir, &dentry->d_name, &de);
+ 	inode = NULL;
+ 	if (bh) {
+@@ -1068,7 +1072,8 @@ static struct dentry *ext4_lookup(struct
+ 		if (IS_ERR(inode))
+ 			return ERR_CAST(inode);
+ 	}
+-	return d_splice_alias(inode, dentry);
++
++	return iopen_connect_dentry(dentry, inode, 1);
+ }
+ 
+ 
+@@ -1717,7 +1722,7 @@ static int ext4_add_nondir(handle_t *han
+ 	int err = ext4_add_entry(handle, dentry, inode);
+ 	if (!err) {
+ 		ext4_mark_inode_dirty(handle, inode);
+-		d_instantiate(dentry, inode);
++		iopen_d_instantiate(dentry, inode);
+ 		return 0;
+ 	}
+ 	drop_nlink(inode);
+@@ -1876,7 +1881,7 @@ out_clear_inode:
+ 	ext4_inc_count(handle, dir);
+ 	ext4_update_dx_flag(dir);
+ 	ext4_mark_inode_dirty(handle, dir);
+-	d_instantiate(dentry, inode);
++	iopen_d_instantiate(dentry, inode);
+ out_stop:
+ 	ext4_journal_stop(handle);
+ 	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+@@ -2142,10 +2147,6 @@ static int ext4_rmdir(struct inode *dir,
+ 			     inode->i_nlink);
+ 	inode->i_version++;
+ 	clear_nlink(inode);
+-	/* There's no need to set i_disksize: the fact that i_nlink is
+-	 * zero will ensure that the right thing happens during any
+-	 * recovery. */
+-	inode->i_size = 0;
+ 	ext4_orphan_add(handle, inode);
+ 	inode->i_ctime = dir->i_ctime = dir->i_mtime = ext4_current_time(inode);
+ 	ext4_mark_inode_dirty(handle, inode);
+@@ -2271,6 +2272,23 @@ out_stop:
+ 	return err;
+ }
+ 
++/* Like ext4_add_nondir() except for call to iopen_connect_dentry */
++static int ext4_add_link(handle_t *handle, struct dentry *dentry,
++			struct inode *inode)
++{
++	int err = ext4_add_entry(handle, dentry, inode);
++	if (!err) {
++		err = ext4_mark_inode_dirty(handle, inode);
++		if (err == 0) {
++			dput(iopen_connect_dentry(dentry, inode, 0));
++			return 0;
++		}
++	}
++	ext4_dec_count(handle, inode);
++	iput(inode);
++	return err;
++}
++
+ static int ext4_link(struct dentry *old_dentry,
+ 		     struct inode *dir, struct dentry *dentry)
+ {
+@@ -2301,7 +2319,8 @@ retry:
+ 	ext4_inc_count(handle, inode);
+ 	atomic_inc(&inode->i_count);
+ 
+-	err = ext4_add_nondir(handle, dentry, inode);
++	err = ext4_add_link(handle, dentry, inode);
++	ext4_orphan_del(handle, inode);
+ 	ext4_journal_stop(handle);
+ 	if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
+ 		goto retry;
+Index: linux-2.6.27.21-0.1/fs/ext4/Makefile
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/Makefile
++++ linux-2.6.27.21-0.1/fs/ext4/Makefile
+@@ -4,7 +4,7 @@
+ 
+ obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
+ 
+-ext4dev-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
++ext4dev-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
+ 		   ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
+ 		   ext4_jbd2.o migrate.o mballoc.o
+ 
+Index: linux-2.6.27.21-0.1/fs/ext4/ext4.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/ext4.h
++++ linux-2.6.27.21-0.1/fs/ext4/ext4.h
+@@ -540,6 +540,8 @@ do {									       \
+ #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT	0x1000000 /* Journal Async Commit */
+ #define EXT4_MOUNT_I_VERSION            0x2000000 /* i_version support */
+ #define EXT4_MOUNT_DELALLOC		0x8000000 /* Delalloc support */
++#define EXT4_MOUNT_IOPEN		0x10000000 /* Allow access via iopen */
++#define EXT4_MOUNT_IOPEN_NOPRIV		0x20000000 /* Make iopen world-readable */
+ /* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
+ #ifndef _LINUX_EXT2_FS_H
+ #define clear_opt(o, opt)		o &= ~EXT4_MOUNT_##opt
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc3.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc3.series
index 1e24d94..7f3a15c 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc3.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc3.series
@@ -8,5 +8,4 @@ ext3-include-fixes-2.6-rhel4.patch
 ext3-extents-2.6.9-rhel4.patch
 ext3-mballoc2-2.6.9-rhel4.patch 
 ext3-nlinks-2.6.9.patch
-ext3-ialloc-2.6.patch
 ext3-lookup-dotdot-2.6.9.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc5.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc5.series
index 3d78f2a..aaa5ffb 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc5.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-fc5.series
@@ -6,7 +6,6 @@ ext3-include-fixes-2.6-rhel4.patch
 ext3-extents-2.6.15.patch
 ext3-mballoc2-2.6-fc5.patch
 ext3-nlinks-2.6.9.patch
-ext3-ialloc-2.6.patch
 ext3-remove-cond_resched-calls-2.6.12.patch
 ext3-filterdata-2.6.15.patch
 ext3-lookup-dotdot-2.6.9.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel4.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel4.series
index 5cfd377..b9509ec 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel4.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel4.series
@@ -13,7 +13,6 @@ ext3-extents-sanity-checks.patch
 ext3-mballoc3-core.patch 
 ext3-mballoc3-rhel4.patch 
 ext3-nlinks-2.6.9.patch
-ext3-ialloc-2.6.patch
 ext3-lookup-dotdot-2.6.9.patch
 ext3-sector_t-overflow-2.6.9-rhel4.patch
 ext3-check-jbd-errors-2.6.9.patch
@@ -21,11 +20,13 @@ ext3-uninit-2.6.9.patch
 ext3-nanosecond-2.6-rhel4.patch
 ext3-unlink-race.patch
 ext3-mmp-2.6-rhel4.patch
+ext3-fiemap-2.6-sles10.patch
 ext3-external-journal-2.6.9.patch
 ext3-max-dir-size.patch
 ext3-print-inum-in-htree-warning.patch
 ext3-xattr-no-update-ctime-rhel4.patch
 ext3-check-bad-inode.patch
-ext3-fiemap-2.6-rhel4.patch
+ext3-fiemap-fix-rhel4.patch
 ext3-get-raid-stripe-from-sb.patch
 ext3-big-endian-check-2.6-rhel4.patch
+alloc-policy-2.6-rhlel5.diff
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series
new file mode 100644
index 0000000..a56427f
--- /dev/null
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5-ext4.series
@@ -0,0 +1,24 @@
+ext4-wantedi-2.6-rhel5.patch
+iopen-2.6.18-rhel5-ext4.patch
+ext4-map_inode_page-2.6.18-rhel5.patch
+export-ext4-2.6-rhel5.patch
+ext4-include-fixes-2.6-rhel5.patch
+ext4-remove-cond_resched-calls-rhel5.patch
+ext4-filterdata-rhel5.patch
+ext4-inode-version-rhel5.patch
+ext4-mmp-rhel5.patch
+ext4-unlink-race-rhel5.patch
+ext4-fiemap-2.6-rhel5.patch
+ext4-lookup-dotdot-rhel5.patch
+ext4-max-dir-size-rhel5.patch
+ext4-print-inum-in-htree-warning-rhel5.patch
+ext4-xattr-no-update-ctime-rhel5.patch
+ext4-prealloc-rhel5.patch
+ext4-mballoc-extra-checks-rhel5.patch
+ext4-mballoc-handle-dev-paths-rhel5.patch
+ext4-big-endian-check-2.6-rhel5.patch
+ext4-alloc-policy-2.6-rhel5.patch
+ext4-misc-rhel5.patch
+ext4-convert-group-lock-rhel5.patch
+ext4-force_over_8tb-rhel5.patch
+ext4-pa_lock-typo.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series
index bd414b6..973640b 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-rhel5.series
@@ -6,8 +6,7 @@ ext3-include-fixes-2.6-rhel4.patch
 ext3-extents-2.6.18-vanilla.patch
 ext3-mballoc3-core.patch
 ext3-mballoc3-2.6.18.patch
-ext3-nlinks-2.6.9.patch
-ext3-ialloc-2.6.patch
+ext3-nlinks-2.6-rhel5.patch
 ext3-remove-cond_resched-calls-2.6.12.patch
 ext3-filterdata-sles10.patch
 ext3-uninit-2.6.18.patch
@@ -26,3 +25,5 @@ ext3-xattr-no-update-ctime-2.6.22-vanilla.patch
 ext3-journal-chksum-2.6.18-vanilla.patch
 ext3-get-raid-stripe-from-sb.patch
 ext3-big-endian-check-2.6-rhel5.patch
+alloc-policy-2.6-rhlel5.diff 
+ext3-force_over_8tb-rhel5.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series
index bff24e5..b526868 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles10.series
@@ -5,13 +5,12 @@ export-ext3-2.6-rhel4.patch
 ext3-include-fixes-2.6-rhel4.patch
 ext3-extents-2.6.16-sles10.patch
 ext3-extents-fixes-2.6.9-rhel4.patch 
-ext3-extents-multiblock-directio-2.6-sles10.patch
+ext3-extents-multiblock-directio-2.6.9-rhel4.patch
 ext3-extents-search-2.6.9-rhel4.patch
 ext3-extents-sanity-checks.patch
 ext3-mballoc3-core.patch 
 ext3-mballoc3-sles10.patch 
 ext3-nlinks-2.6.9.patch
-ext3-ialloc-2.6.patch
 ext3-remove-cond_resched-calls-2.6.12.patch
 ext3-filterdata-sles10.patch
 ext3-disable-write-bar-by-default-2.6-sles10.patch
@@ -31,3 +30,5 @@ ext3-check-bad-inode.patch
 ext3-journal-chksum-2.6.18-vanilla.patch
 ext3-get-raid-stripe-from-sb.patch
 ext3-big-endian-check-2.6-sles10.patch
+alloc-policy-2.6-rhlel5.diff
+ext3-force_over_8tb-sles10.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series
new file mode 100644
index 0000000..e4c0202
--- /dev/null
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series
@@ -0,0 +1,29 @@
+ext4-wantedi-2.6-sles11.patch
+iopen-sles11.patch
+ext4-map_inode_page-sles11.patch
+export-ext4-2.6-sles11.patch
+ext4-include-fixes-2.6-sles11.patch
+ext4-remove-cond_resched-calls-sles11.patch
+ext4-filterdata-sles11.patch
+ext4-mmp-sles11.patch
+ext4-unlink-race-sles11.patch
+ext4-fiemap-2.6-sles11.patch
+ext4-lookup-dotdot-sles11.patch
+ext4-max-dir-size-sles11.patch
+ext4-print-inum-in-htree-warning-sles11.patch
+ext4-xattr-no-update-ctime-sles11.patch
+ext4-prealloc-sles11.patch
+ext4-mballoc-extra-checks-sles11.patch
+ext4-big-endian-check-2.6-sles11.patch
+ext4-misc-sles11.patch
+ext4-ext_generation-sles11.patch
+ext4-remove-ioctl-filp-sles11.patch
+ext4-super-warning.patch
+ext4-alloc-policy-2.6-sles11.patch
+ext4-disable-delalloc-sles11.patch
+ext4-lustre-i_version.patch
+ext4-lock-cached_extent.patch
+ext4-convert-group-lock-sles11.patch
+ext4-force_over_8tb-sles11.patch
+ext4-claim_inode-free_inode-race.patch
+ext4-pa_lock-typo.patch
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series
index 5e7c0f2..a1d2e2a 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6-suse.series
@@ -14,7 +14,6 @@ ext3-mballoc3-core.patch
 ext3-mballoc3-suse.patch 
 ext3-nlinks-2.6.7.patch
 ext3-rename-reserve-2.6-suse.patch
-ext3-ialloc-2.6.patch
 ext3-lookup-dotdot-2.6.9.patch
 ext3-sector_t-overflow-2.6.5-suse.patch
 ext3-check-jbd-errors-2.6.5.patch
@@ -28,3 +27,4 @@ ext3-xattr-no-update-ctime-suse.patch
 ext3-check-bad-inode.patch
 ext3-get-raid-stripe-from-sb-2.6-suse.patch
 ext3-big-endian-check-2.6-suse.patch
+alloc-policy-2.6-rhlel5.diff
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series
index b034b42..b4d069a 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6.18-vanilla.series
@@ -7,7 +7,6 @@ ext3-extents-2.6.18-vanilla.patch
 ext3-mballoc3-core.patch
 ext3-mballoc3-2.6.18.patch
 ext3-nlinks-2.6.9.patch
-ext3-ialloc-2.6.patch
 ext3-remove-cond_resched-calls-2.6.12.patch
 ext3-filterdata-sles10.patch
 ext3-16tb-overflow-fixes.patch
@@ -17,8 +16,10 @@ ext3-inode-version-2.6.18-vanilla.patch
 ext3-ea-expand-lose-block.patch
 ext3-mmp-2.6.18-vanilla.patch
 ext3-handle-directory-corruption-better.patch
+ext3-fiemap-2.6.18-vanilla.patch
 ext3-lookup-dotdot-2.6.9.patch
 ext3-max-dir-size.patch
 ext3-print-inum-in-htree-warning.patch
 ext3-xattr-no-update-ctime-2.6.22-vanilla.patch
 ext3-check-bad-inode.patch
+alloc-policy-2.6-rhlel5.diff
diff --git a/ldiskfs/kernel_patches/series/ldiskfs-2.6.22-vanilla.series b/ldiskfs/kernel_patches/series/ldiskfs-2.6.22-vanilla.series
index 05ea5a4..cd4ddda 100644
--- a/ldiskfs/kernel_patches/series/ldiskfs-2.6.22-vanilla.series
+++ b/ldiskfs/kernel_patches/series/ldiskfs-2.6.22-vanilla.series
@@ -7,7 +7,6 @@ ext3-extents-2.6.22-vanilla.patch
 ext3-mballoc3-core.patch
 ext3-mballoc3-2.6.22.patch
 ext3-nlinks-2.6.22-vanilla.patch
-ext3-ialloc-2.6.22-vanilla.patch
 ext3-remove-cond_resched-calls-2.6.12.patch
 ext3-filterdata-sles10.patch
 ext3-uninit-2.6.22-vanilla.patch
@@ -26,3 +25,4 @@ ext3-xattr-no-update-ctime-2.6.22-vanilla.patch
 ext3-check-bad-inode.patch
 ext3-get-raid-stripe-from-sb.patch
 ext3-big-endian-check-2.6.22-vanilla.patch
+alloc-policy-2.6-rhlel5.diff
diff --git a/ldiskfs/ldiskfs/Makefile.in b/ldiskfs/ldiskfs/Makefile.in
index d70d42b..7f369b2 100644
--- a/ldiskfs/ldiskfs/Makefile.in
+++ b/ldiskfs/ldiskfs/Makefile.in
@@ -3,15 +3,23 @@ default: all
 MODULES := ldiskfs
 
 # copy makefile over to not break patches
-ext3_extra := $(wildcard @LINUX@/fs/ext3/Makefile)
+backfs_extra := $(wildcard @LINUX@/fs/@BACKFS@/Makefile)
 
-ext3_headers := $(wildcard @LINUX@/fs/ext3/*.h)
-linux_headers := $(wildcard @LINUX@/include/linux/ext3*.h)
+backfs_headers := $(wildcard @LINUX@/fs/@BACKFS@/*.h)
+linux_headers := $(wildcard @LINUX@/include/linux/@BACKFS@*.h)
 
-ext3_sources := $(filter-out %.mod.c,$(wildcard @LINUX@/fs/ext3/*.c))
-new_sources := iopen.c iopen.h extents.c mballoc.c group.h fiemap.h
-new_headers := ext3_extents.h 
-ldiskfs_patched_sources := $(notdir $(ext3_sources) $(ext3_headers)) $(new_sources) $(new_headers)
+backfs_sources := $(filter-out %.mod.c,$(wildcard @LINUX@/fs/@BACKFS@/*.c))
+
+ext3_new_sources := iopen.c iopen.h extents.c mballoc.c group.h fiemap.h
+ext3_new_headers := ext3_extents.h 
+
+ext4_new_sources := iopen.c iopen.h fiemap.h
+ext4_new_headers :=
+
+new_sources := $(@BACKFS at _new_sources)
+new_headers := $(@BACKFS at _new_headers)
+
+ldiskfs_patched_sources := $(notdir $(backfs_sources) $(backfs_headers)) $(new_sources) $(new_headers)
 ldiskfs_sources := $(ldiskfs_patched_sources)
 
 ldiskfs-objs := $(filter %.o,$(ldiskfs_sources:.c=.o))
diff --git a/ldiskfs/ldiskfs/autoMakefile.am b/ldiskfs/ldiskfs/autoMakefile.am
index f7b83ad..13a9558 100644
--- a/ldiskfs/ldiskfs/autoMakefile.am
+++ b/ldiskfs/ldiskfs/autoMakefile.am
@@ -1,40 +1,42 @@
 modulefs_DATA = ldiskfs$(KMODEXT)
 
-ldiskfs_linux_headers := $(addprefix linux/,$(subst ext3,ldiskfs,$(notdir $(linux_headers))))
+ldiskfs_linux_headers := $(addprefix linux/,$(subst @BACKFS@,ldiskfs,$(notdir $(linux_headers))))
 
 $(filter %.c,$(ldiskfs_patched_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources))
 
 ldiskfs_sed_flags = \
-	-e "s/dx_hash_info/ext3_dx_hash_info/g" \
-	-e "s/dir_private_info/ext3_dir_private_info/g" \
-	-e "s/DX_HASH/EXT3_DX_HASH/g" \
-	-e "s/reserve_window/ext3_reserve_window/g" \
-	-e "s/rsv_window_add/ext3_rsv_window_add/g" \
-	-e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g"
+	-e "s/dx_hash_info/@BACKFS at _dx_hash_info/g" \
+	-e "s/dir_private_info/@BACKFS at _dir_private_info/g" \
+	-e "s/DX_HASH/@BACKFSU at _DX_HASH/g" \
+	-e "s/\<reserve_window/@BACKFS at _reserve_window/g" \
+	-e "s/\<rsv_window_add/@BACKFS at _rsv_window_add/g" \
+	-e "s/@BACKFSU@/LDISKFS/g" -e "s/@BACKFS@/ldiskfs/g"
 
-%.c: linux-stage/fs/ext3/%.c
+%.c: linux-stage/fs/@BACKFS@/%.c
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
-%.h: linux-stage/fs/ext3/%.h
+%.h: linux-stage/fs/@BACKFS@/%.h
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
-linux/ldiskfs%.h: linux-stage/include/linux/ext3%.h
+linux/ldiskfs%.h: linux-stage/include/linux/@BACKFS@%.h
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
 series := @top_srcdir@/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES)
 patches := @top_srcdir@/kernel_patches/patches
 
-sources: $(ext3_sources) $(ext3_headers) $(linux_headers) $(series)
+sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series)
 	rm -rf linux-stage linux sources $(ldiskfs_SOURCES)
-	mkdir -p linux-stage/fs/ext3 linux-stage/include/linux
-	cp $(ext3_sources) $(ext3_headers) $(ext3_extra) linux-stage/fs/ext3
-	cp $(linux_headers) linux-stage/include/linux
+	mkdir -p linux-stage/fs/@BACKFS@ linux-stage/include/linux
+	cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/@BACKFS@
+	if test -n "$(linux_headers)" ; then \
+		cp $(linux_headers) linux-stage/include/linux; \
+	fi
 if USE_QUILT
 	ln -s ../$(patches) linux-stage/patches
 	ln -s ../$(series) linux-stage/series
 	cd linux-stage && quilt push -a -q
 else
-	@echo -n "Applying ext3 patches:"
+	@echo -n "Applying @BACKFS@ patches:"
 	@cd linux-stage && for i in $$(<../$(series)) ; do \
 		echo -n " $$i" ; \
 		patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
@@ -42,16 +44,22 @@ else
 	@echo
 endif
 	mkdir linux
-	@echo -n "Replacing 'ext3' with 'ldiskfs':"
-	@for i in $(notdir $(ext3_headers) $(ext3_sources)) $(new_sources) ; do \
+	@echo -n "Replacing '@BACKFS@' with 'ldiskfs':"
+	for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
 		echo -n " $$i" ; \
 		sed $(strip $(ldiskfs_sed_flags)) \
-			linux-stage/fs/ext3/$$i > $$i ; \
+			linux-stage/fs/@BACKFS@/$$i > $$i ; \
 	done
-	@for i in $(subst ext3,,$(notdir $(linux_headers) $(new_headers))) ; do \
-		echo -n " ext3$$i" ; \
+	for i in $(subst @BACKFS@,,$(notdir $(backfs_headers))) ; do \
+		if test -f "@BACKFS@$$i" ; then \
+			echo -n " @BACKFS@$$i" ; \
+			mv @BACKFS@$$i ldiskfs$$i ; \
+		fi ; \
+	done
+	for i in $(subst @BACKFS@,,$(notdir $(linux_headers) $(new_headers))) ; do \
+		echo -n " @BACKFS@$$i" ; \
 		sed $(strip $(ldiskfs_sed_flags)) \
-			linux-stage/include/linux/ext3$$i \
+			linux-stage/include/linux/@BACKFS@$$i \
 			> linux/ldiskfs$$i ; \
 	done
 	@echo
@@ -66,7 +74,7 @@ foo-check:
 	@echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-CLEANFILES = sources $(notdir $(linux_headers) $(ext3_headers) $(ext3_sources) $(new_sources) $(new_headers))
+CLEANFILES = sources $(notdir $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers))
 
 clean: clean-am
-	rm -rf linux linux-stage
+	rm -rf linux linux-stage ldiskfs*.h
diff --git a/ldiskfs/ldiskfs/autoMakefile.in b/ldiskfs/ldiskfs/autoMakefile.in
index cfc74d4..f69740a 100644
--- a/ldiskfs/ldiskfs/autoMakefile.in
+++ b/ldiskfs/ldiskfs/autoMakefile.in
@@ -47,6 +47,8 @@ AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
 AWK = @AWK@
+BACKFS = @BACKFS@
+BACKFSU = @BACKFSU@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
@@ -110,6 +112,8 @@ SHELL = @SHELL@
 STRIP = @STRIP@
 SYMVERFILE = @SYMVERFILE@
 UML_CFLAGS = @UML_CFLAGS@
+USE_EXT4_FALSE = @USE_EXT4_FALSE@
+USE_EXT4_TRUE = @USE_EXT4_TRUE@
 USE_QUILT_FALSE = @USE_QUILT_FALSE@
 USE_QUILT_TRUE = @USE_QUILT_TRUE@
 VERSION = @VERSION@
@@ -160,20 +164,20 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 modulefs_DATA = ldiskfs$(KMODEXT)
 
-ldiskfs_linux_headers := $(addprefix linux/,$(subst ext3,ldiskfs,$(notdir $(linux_headers))))
+ldiskfs_linux_headers := $(addprefix linux/,$(subst @BACKFS@,ldiskfs,$(notdir $(linux_headers))))
 
 ldiskfs_sed_flags = \
-	-e "s/dx_hash_info/ext3_dx_hash_info/g" \
-	-e "s/dir_private_info/ext3_dir_private_info/g" \
-	-e "s/DX_HASH/EXT3_DX_HASH/g" \
-	-e "s/reserve_window/ext3_reserve_window/g" \
-	-e "s/rsv_window_add/ext3_rsv_window_add/g" \
-	-e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g"
+	-e "s/dx_hash_info/@BACKFS at _dx_hash_info/g" \
+	-e "s/dir_private_info/@BACKFS at _dir_private_info/g" \
+	-e "s/DX_HASH/@BACKFSU at _DX_HASH/g" \
+	-e "s/\<reserve_window/@BACKFS at _reserve_window/g" \
+	-e "s/\<rsv_window_add/@BACKFS at _rsv_window_add/g" \
+	-e "s/@BACKFSU@/LDISKFS/g" -e "s/@BACKFS@/ldiskfs/g"
 
 
 series := @top_srcdir@/kernel_patches/series/ldiskfs-$(LDISKFS_SERIES)
 patches := @top_srcdir@/kernel_patches/patches
-CLEANFILES = sources $(notdir $(linux_headers) $(ext3_headers) $(ext3_sources) $(new_sources) $(new_headers))
+CLEANFILES = sources $(notdir $(linux_headers) $(backfs_headers) $(backfs_sources) $(new_sources) $(new_headers))
 subdir = ldiskfs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -338,40 +342,48 @@ uninstall-am: uninstall-info-am uninstall-modulefsDATA
 
 $(filter %.c,$(ldiskfs_patched_sources)): sources $(ldiskfs_linux_headers) $(filter %.h,$(ldiskfs_patched_sources))
 
-%.c: linux-stage/fs/ext3/%.c
+%.c: linux-stage/fs/@BACKFS@/%.c
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
-%.h: linux-stage/fs/ext3/%.h
+%.h: linux-stage/fs/@BACKFS@/%.h
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
-linux/ldiskfs%.h: linux-stage/include/linux/ext3%.h
+linux/ldiskfs%.h: linux-stage/include/linux/@BACKFS@%.h
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
-sources: $(ext3_sources) $(ext3_headers) $(linux_headers) $(series)
+sources: $(backfs_sources) $(backfs_headers) $(linux_headers) $(series)
 	rm -rf linux-stage linux sources $(ldiskfs_SOURCES)
-	mkdir -p linux-stage/fs/ext3 linux-stage/include/linux
-	cp $(ext3_sources) $(ext3_headers) $(ext3_extra) linux-stage/fs/ext3
-	cp $(linux_headers) linux-stage/include/linux
+	mkdir -p linux-stage/fs/@BACKFS@ linux-stage/include/linux
+	cp $(backfs_sources) $(backfs_headers) $(backfs_extra) linux-stage/fs/@BACKFS@
+	if test -n "$(linux_headers)" ; then \
+		cp $(linux_headers) linux-stage/include/linux; \
+	fi
 @USE_QUILT_TRUE@	ln -s ../$(patches) linux-stage/patches
 @USE_QUILT_TRUE@	ln -s ../$(series) linux-stage/series
 @USE_QUILT_TRUE@	cd linux-stage && quilt push -a -q
- at USE_QUILT_FALSE@	@echo -n "Applying ext3 patches:"
+ at USE_QUILT_FALSE@	@echo -n "Applying @BACKFS@ patches:"
 @USE_QUILT_FALSE@	@cd linux-stage && for i in $$(<../$(series)) ; do \
 @USE_QUILT_FALSE@		echo -n " $$i" ; \
 @USE_QUILT_FALSE@		patch -s -p1 < ../$(patches)/$$i || exit 1 ; \
 @USE_QUILT_FALSE@	done
 @USE_QUILT_FALSE@	@echo
 	mkdir linux
-	@echo -n "Replacing 'ext3' with 'ldiskfs':"
-	@for i in $(notdir $(ext3_headers) $(ext3_sources)) $(new_sources) ; do \
+	@echo -n "Replacing '@BACKFS@' with 'ldiskfs':"
+	for i in $(notdir $(backfs_headers) $(backfs_sources)) $(new_sources) ; do \
 		echo -n " $$i" ; \
 		sed $(strip $(ldiskfs_sed_flags)) \
-			linux-stage/fs/ext3/$$i > $$i ; \
+			linux-stage/fs/@BACKFS@/$$i > $$i ; \
 	done
-	@for i in $(subst ext3,,$(notdir $(linux_headers) $(new_headers))) ; do \
-		echo -n " ext3$$i" ; \
+	for i in $(subst @BACKFS@,,$(notdir $(backfs_headers))) ; do \
+		if test -f "@BACKFS@$$i" ; then \
+			echo -n " @BACKFS@$$i" ; \
+			mv @BACKFS@$$i ldiskfs$$i ; \
+		fi ; \
+	done
+	for i in $(subst @BACKFS@,,$(notdir $(linux_headers) $(new_headers))) ; do \
+		echo -n " @BACKFS@$$i" ; \
 		sed $(strip $(ldiskfs_sed_flags)) \
-			linux-stage/include/linux/ext3$$i \
+			linux-stage/include/linux/@BACKFS@$$i \
 			> linux/ldiskfs$$i ; \
 	done
 	@echo
@@ -386,7 +398,7 @@ foo-check:
 	@echo "ldiskfs_LDADD: $(ldiskfs_LDADD)"
 
 clean: clean-am
-	rm -rf linux linux-stage
+	rm -rf linux linux-stage ldiskfs*.h
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/libsysio/configure b/libsysio/configure
index c397ab4..f13a19f 100755
--- a/libsysio/configure
+++ b/libsysio/configure
@@ -4568,20 +4568,20 @@ fi
 
 echo "$as_me:$LINENO: checking whether .text pseudo-op must be used" >&5
 echo $ECHO_N "checking whether .text pseudo-op must be used... $ECHO_C" >&6
-if test "${sysio_asm_dot_text+set}" = set; then
+if test "${am_cv_sysio_asm_dot_text+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat > conftest.s <<EOF
 	.text
 EOF
-	sysio_asm_dot_text=
+	am_cv_sysio_asm_dot_text=
 	if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-		sysio_asm_dot_text=.text
+		am_cv_sysio_asm_dot_text=.text
 	fi
 	rm -f conftest*
 fi
 
-if test -z "$sysio_dot_text"; then
+if test -z "$am_cv_sysio_asm_dot_text"; then
 	echo "$as_me:$LINENO: result: no" >&5
 echo "${ECHO_T}no" >&6
 else
@@ -4591,43 +4591,43 @@ fi
 
 echo "$as_me:$LINENO: checking for assembler global-symbol directive" >&5
 echo $ECHO_N "checking for assembler global-symbol directive... $ECHO_C" >&6
-if test "${sysio_asm_global_directive+set}" = set; then
+if test "${am_cv_sysio_asm_global_directive+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  sysio_asm_global_directive=UNKNOWN
+  am_cv_sysio_asm_global_directive=UNKNOWN
 for ac_globl in .globl .global .EXPORT; do
 	cat > conftest.s <<EOF
-		${sysio_asm_dot_text}
+		${am_cv_sysio_asm_dot_text}
 		${ac_globl} foo
 foo:
 EOF
 	if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-	sysio_asm_global_directive=${ac_globl}
+	am_cv_sysio_asm_global_directive=${ac_globl}
 	fi
 	rm -f conftest*
-	test $sysio_asm_global_directive != UNKNOWN && break
+	test $am_cv_sysio_asm_global_directive != UNKNOWN && break
 done
 fi
-echo "$as_me:$LINENO: result: $sysio_asm_global_directive" >&5
-echo "${ECHO_T}$sysio_asm_global_directive" >&6
-if test $sysio_asm_global_directive = UNKNOWN; then
+echo "$as_me:$LINENO: result: $am_cv_sysio_asm_global_directive" >&5
+echo "${ECHO_T}$am_cv_sysio_asm_global_directive" >&6
+if test $am_cv_sysio_asm_global_directive = UNKNOWN; then
 	{ { echo "$as_me:$LINENO: error: cannot determine asm global directive" >&5
 echo "$as_me: error: cannot determine asm global directive" >&2;}
    { (exit 1); exit 1; }; }
 #else
-#	AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${sysio_asm_global_directive})
+#	AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${am_cv_sysio_asm_global_directive})
 fi
 
 echo "$as_me:$LINENO: checking for .set assembler directive" >&5
 echo $ECHO_N "checking for .set assembler directive... $ECHO_C" >&6
-if test "${sysio_asm_set_directive+set}" = set; then
+if test "${am_cv_sysio_asm_set_directive+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat > conftest.s<<EOF
-${sysio_asm_dot_text}
+${am_cv_sysio_asm_dot_text}
 foo:
 .set bar, foo
-${sysio_asm_global_directive} bar
+${am_cv_sysio_asm_global_directive} bar
 EOF
 	# The alpha-dec-osf1 assembler gives only a warning for `.set'
 	# (but it doesn't work), so we must do a linking check to be sure.
@@ -4637,71 +4637,71 @@ main () { printf ("%d\n", bar); }
 EOF
 	if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
 	   -o conftest conftest.s conftest1.c 1>&5 2>&5; then
-		sysio_asm_set_directive=yes
+		am_cv_sysio_asm_set_directive=yes
 	else
-		sysio_asm_set_directive=no
+		am_cv_sysio_asm_set_directive=no
 	fi
 	rm -f conftest*
 fi
-echo "$as_me:$LINENO: result: $sysio_asm_set_directive" >&5
-echo "${ECHO_T}$sysio_asm_set_directive" >&6
-#if test $sysio_asm_set_directive = yes; then
+echo "$as_me:$LINENO: result: $am_cv_sysio_asm_set_directive" >&5
+echo "${ECHO_T}$am_cv_sysio_asm_set_directive" >&6
+#if test $am_cv_sysio_asm_set_directive = yes; then
 #	AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
 #fi
 
 echo "$as_me:$LINENO: checking for assembler .weak directive" >&5
 echo $ECHO_N "checking for assembler .weak directive... $ECHO_C" >&6
-if test "${sysio_asm_weak_directive+set}" = set; then
+if test "${am_cv_sysio_asm_weak_directive+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat > conftest.s <<EOF
-${sysio_dot_text}
+${am_cv_sysio_asm_dot_text}
 foo:
 .weak foo
 EOF
 	if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-		sysio_asm_weak_directive=yes
+		am_cv_sysio_asm_weak_directive=yes
 	else
-		sysio_asm_weak_directive=no
+		am_cv_sysio_asm_weak_directive=no
 	fi
 	rm -f conftest*
 fi
-echo "$as_me:$LINENO: result: $sysio_asm_weak_directive" >&5
-echo "${ECHO_T}$sysio_asm_weak_directive" >&6
+echo "$as_me:$LINENO: result: $am_cv_sysio_asm_weak_directive" >&5
+echo "${ECHO_T}$am_cv_sysio_asm_weak_directive" >&6
 
-if test $sysio_asm_weak_directive = no; then
+if test $am_cv_sysio_asm_weak_directive = no; then
 	echo "$as_me:$LINENO: checking for assembler .weakext directive" >&5
 echo $ECHO_N "checking for assembler .weakext directive... $ECHO_C" >&6
-if test "${sysio_asm_weakext_directive+set}" = set; then
+if test "${am_cv_sysio_asm_weakext_directive+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat > conftest.s <<EOF
-${sysio_dot_text}
-${sysio_asm_global_directive} foo
+${am_cv_sysio_asm_dot_text}
+${am_cv_sysio_asm_global_directive} foo
 foo:
 .weakext bar foo
 .weakext baz
-${sysio_asm_global_directive} baz
+${am_cv_sysio_asm_global_directive} baz
 baz:
 EOF
 		if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-			sysio_asm_weakext_directive=yes
+			am_cv_sysio_asm_weakext_directive=yes
 		else
-			sysio_asm_weakext_directive=no
+			am_cv_sysio_asm_weakext_directive=no
 		fi
 		rm -f conftest*
 fi
-echo "$as_me:$LINENO: result: $sysio_asm_weakext_directive" >&5
-echo "${ECHO_T}$sysio_asm_weakext_directive" >&6
+echo "$as_me:$LINENO: result: $am_cv_sysio_asm_weakext_directive" >&5
+echo "${ECHO_T}$am_cv_sysio_asm_weakext_directive" >&6
 fi # no .weak
 
-if test x$sysio_asm_weak_directive = xyes; then
+if test x$am_cv_sysio_asm_weak_directive = xyes; then
 	cat >>confdefs.h <<\_ACEOF
 #define HAVE_ASM_WEAK_DIRECTIVE 1
 _ACEOF
 
 fi
-if test x$sysio_asm_weakext_directive = xyes; then
+if test x$am_cv_sysio_asm_weakext_directive = xyes; then
 	cat >>confdefs.h <<\_ACEOF
 #define HAVE_ASM_WEAKEXT_DIRECTIVE 1
 _ACEOF
diff --git a/libsysio/configure.in b/libsysio/configure.in
index 2aedbf1..4fcd3c0 100644
--- a/libsysio/configure.in
+++ b/libsysio/configure.in
@@ -361,49 +361,49 @@ if test x$have_st_gen = xyes; then
 fi
 
 AC_MSG_CHECKING(whether .text pseudo-op must be used)
-AC_CACHE_VAL(sysio_asm_dot_text, [dnl
+AC_CACHE_VAL(am_cv_sysio_asm_dot_text, [dnl
 cat > conftest.s <<EOF
 	.text
 EOF
-	sysio_asm_dot_text=
+	am_cv_sysio_asm_dot_text=
 	if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-		sysio_asm_dot_text=.text
+		am_cv_sysio_asm_dot_text=.text
 	fi
 	rm -f conftest*])
-if test -z "$sysio_dot_text"; then
+if test -z "$am_cv_sysio_asm_dot_text"; then
 	AC_MSG_RESULT(no)
 else
 	AC_MSG_RESULT(yes)
 fi
 
 AC_CACHE_CHECK(for assembler global-symbol directive,
-  sysio_asm_global_directive, [dnl
-sysio_asm_global_directive=UNKNOWN
+  am_cv_sysio_asm_global_directive, [dnl
+am_cv_sysio_asm_global_directive=UNKNOWN
 for ac_globl in .globl .global .EXPORT; do
 	cat > conftest.s <<EOF
-		${sysio_asm_dot_text}
+		${am_cv_sysio_asm_dot_text}
 		${ac_globl} foo
 foo:
 EOF
 	if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-	sysio_asm_global_directive=${ac_globl}
+	am_cv_sysio_asm_global_directive=${ac_globl}
 	fi
 	rm -f conftest*
-	test $sysio_asm_global_directive != UNKNOWN && break
+	test $am_cv_sysio_asm_global_directive != UNKNOWN && break
 done])
-if test $sysio_asm_global_directive = UNKNOWN; then
+if test $am_cv_sysio_asm_global_directive = UNKNOWN; then
 	AC_MSG_ERROR(cannot determine asm global directive)
 #else
-#	AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${sysio_asm_global_directive})
+#	AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${am_cv_sysio_asm_global_directive})
 fi
 
 AC_CACHE_CHECK(for .set assembler directive,
-  sysio_asm_set_directive, [dnl
+  am_cv_sysio_asm_set_directive, [dnl
 cat > conftest.s<<EOF
-${sysio_asm_dot_text}
+${am_cv_sysio_asm_dot_text}
 foo:
 .set bar, foo
-${sysio_asm_global_directive} bar
+${am_cv_sysio_asm_global_directive} bar
 EOF
 	# The alpha-dec-osf1 assembler gives only a warning for `.set'
 	# (but it doesn't work), so we must do a linking check to be sure.
@@ -413,53 +413,53 @@ main () { printf ("%d\n", bar); }
 EOF
 	if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
 	   -o conftest conftest.s conftest1.c 1>&AC_FD_CC 2>&AC_FD_CC; then
-		sysio_asm_set_directive=yes
+		am_cv_sysio_asm_set_directive=yes
 	else
-		sysio_asm_set_directive=no
+		am_cv_sysio_asm_set_directive=no
 	fi
 	rm -f conftest*])
-#if test $sysio_asm_set_directive = yes; then
+#if test $am_cv_sysio_asm_set_directive = yes; then
 #	AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
 #fi
 
-AC_CACHE_CHECK(for assembler .weak directive, sysio_asm_weak_directive,
+AC_CACHE_CHECK(for assembler .weak directive, am_cv_sysio_asm_weak_directive,
 	       [dnl
 cat > conftest.s <<EOF
-${sysio_dot_text}
+${am_cv_sysio_asm_dot_text}
 foo:
 .weak foo
 EOF
 	if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-		sysio_asm_weak_directive=yes
+		am_cv_sysio_asm_weak_directive=yes
 	else
-		sysio_asm_weak_directive=no
+		am_cv_sysio_asm_weak_directive=no
 	fi
 	rm -f conftest*])
 
-if test $sysio_asm_weak_directive = no; then
+if test $am_cv_sysio_asm_weak_directive = no; then
 	AC_CACHE_CHECK(for assembler .weakext directive,
-		       sysio_asm_weakext_directive, [dnl
+		       am_cv_sysio_asm_weakext_directive, [dnl
 cat > conftest.s <<EOF
-${sysio_dot_text}
-${sysio_asm_global_directive} foo
+${am_cv_sysio_asm_dot_text}
+${am_cv_sysio_asm_global_directive} foo
 foo:
 .weakext bar foo
 .weakext baz
-${sysio_asm_global_directive} baz
+${am_cv_sysio_asm_global_directive} baz
 baz:
 EOF
 		if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
-			sysio_asm_weakext_directive=yes
+			am_cv_sysio_asm_weakext_directive=yes
 		else
-			sysio_asm_weakext_directive=no
+			am_cv_sysio_asm_weakext_directive=no
 		fi
 		rm -f conftest*])
 fi # no .weak
 
-if test x$sysio_asm_weak_directive = xyes; then
+if test x$am_cv_sysio_asm_weak_directive = xyes; then
 	AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
 fi
-if test x$sysio_asm_weakext_directive = xyes; then
+if test x$am_cv_sysio_asm_weakext_directive = xyes; then
 	AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
 fi
 
diff --git a/libsysio/src/namei.c b/libsysio/src/namei.c
index 7f8c1e4..63e610e 100644
--- a/libsysio/src/namei.c
+++ b/libsysio/src/namei.c
@@ -268,7 +268,7 @@ _sysio_path_walk(struct pnode *parent, struct nameidata *nd)
 			 * except the last component.
 			 */
 			ND_INIT(&nameidata,
-				(nd->nd_flags | ND_NEGOK),
+				nd->nd_flags,
 				lpath,
 				nd->nd_root,
 				!next.len ? nd->nd_intent : NULL);
diff --git a/lnet/ChangeLog b/lnet/ChangeLog
index b5aa505..5ec02a0 100644
--- a/lnet/ChangeLog
+++ b/lnet/ChangeLog
@@ -1,10 +1,10 @@
-2009-06-05 Sun Microsystems, Inc.
-        * version 1.6.7.2
+2009-07-31  Sun Microsystems, Inc.
+	* version 1.8.1
 	* Support for networks:
 	 socklnd   - any kernel supported by Lustre,
 	 qswlnd    - Qsnet kernel modules 5.20 and later,
 	 openiblnd - IbGold 1.8.2,
-	 o2iblnd   - OFED 1.1, 1.2.0, 1.2.5, and 1.3
+	 o2iblnd   - OFED 1.1, 1.2.0, 1.2.5, 1.3, and 1.4.1
 	 viblnd    - Voltaire ibhost 3.4.5 and later,
 	 ciblnd    - Topspin 3.2.0,
 	 iiblnd    - Infiniserv 3.3 + PathBits patch,
@@ -12,9 +12,101 @@
 	 mxlnd     - MX 1.2.1 or later,
 	 ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
 
--------------------------------------------------------------------------------
-2009-02-07 Sun Microsystems, Inc.
-	* version 1.6.7
+Severity   : normal
+Bugzilla   : 18102
+Description: router_proc.c is rewritten to use sysctl-interface for parameters
+             residing in /proc/sys/lnet
+
+Severity   : normal
+Bugzilla   : 18075
+Description: LNet selftest fixes and enhancements
+
+Severity   : enhancement
+Bugzilla   : 18654
+Description: MXLND: eliminate hosts file, use arp for peer nic_id resolution
+Details    : an update from the upstream developer Scott Atchley.
+
+Severity   : enhancement
+Bugzilla   : 15332
+Description: add a new LND optiion to control peer buffer credits on routers
+
+Severity   : normal
+Bugzilla   : 18844
+Description: Fixing deadlock in usocklnd
+Details    : A deadlock was possible in usocklnd due to race condition while
+             tearing connection down. The problem resulted from erroneous
+             assumption that lnet_finalize() could have been called holding
+             some lnd-level locks.
+
+Severity   : major
+Bugzilla   : 13621, 15983
+Description: Protocol V2 of o2iblnd
+Details    : o2iblnd V2 has several new features:
+             . map-on-demand: map-on-demand is disabled by default, it can
+	       be enabled by using modparam "map_on_demand=@value@", @value@
+	       should >= 0 and < 256, 0 will disable map-on-demand, any other
+	       valid value will enable map-on-demand. 
+	       Oi2blnd will create FMR or physical MR for RDMA if fragments of
+	       RD > @value at .
+	       Enable map-on-demand will take less memory for new connection,
+	       but a little more CPU for RDMA.
+	     . iWARP : to support iWARP, please enable map-on-demand, 32 and 64
+	       are recommanded value. iWARP will probably fail for value >=128.
+	     . OOB NOOP message: to resolve deadlock on router.
+	     . tunable peer_credits_hiw: (high water to return credits),
+	       default value of peer_credits_hiw equals to (peer_credits -1),
+	       user can change it between peer_credits/2 and (peer_credits - 1).
+	       Lower value is recommended for high latency network.
+	     . tunable message queue size: it always equals to peer_credits,
+	       higher value is recommended for high latency network.
+	     . It's compatible with earlier version of o2iblnd
+
+Severity   : normal
+Bugzilla   : 18414
+Description: Fixing 'running out of ports' issue
+Details    : Add a delay before next reconnect attempt in ksocklnd in
+             the case of lost race. Limit the frequency of query-requests
+             in lnet. Improved handling of 'dead peer' notifications in
+             lnet.
+
+Severity   : normal
+Bugzilla   : 16034
+Description: Change ptllnd timeout and watchdog timers
+Details    : Add ptltrace_on_nal_failed and bump ptllnd timeout to match
+             Portals wire timeout.
+
+Severity   : normal
+Bugzilla   : 16186
+Description: One down Lustre FS hangs ALL mounted Lustre filesystems
+Details    : Shared routing enhancements - peer health detection.
+
+Severity   : minor
+Bugzilla   : 11245
+Description: IB path MTU mistakenly set to 1st path MTU when ib_mtu is off
+Details    : See comment 46 in bug 11245 for details - it's indeed a bug
+             introduced by the original 11245 fix.
+
+Severity   : minor
+Bugzilla   : 15984
+Description: uptllnd credit overflow fix
+Details    : kptl_msg_t::ptlm_credits could be overflown by uptllnd since
+             it is only a __u8.
+
+Severity   : major
+Bugzilla   : 14634
+Description: socklnd protocol version 3 
+Details    : With current protocol V2, connections on router can be
+             blocked and can't receive any incoming messages when there is no
+             more router buffer, so ZC-ACK can't be handled (LNet message
+             can't be finalized) and will cause deadlock on router.
+             Protocol V3 has a dedicated connection for emergency messages
+             like ZC-ACK to router, messages on this dedicated connection
+             don't need any credit so will never be blocked. Also, V3 can send
+             keepalive ping in specified period for router healthy checking.
+
+------------------------------------------------------------------------------- 
+12-31-2008  Sun Microsystems, Inc.
+	* version 1.8.0
 	* Support for networks:
 	 socklnd   - any kernel supported by Lustre,
 	 qswlnd    - Qsnet kernel modules 5.20 and later,
@@ -27,6 +119,11 @@
 	 mxlnd     - MX 1.2.1 or later,
 	 ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
 
+Severity   : 
+Bugzilla   : 
+Description: 
+Details    : 
+
 Severity   : major
 Bugzilla   : 15983
 Description: workaround for OOM from o2iblnd
@@ -73,21 +170,89 @@ Bugzilla   : 16321
 Description: concurrent_sends in IB LNDs should not be changeable at run time
 Details    : concurrent_sends in IB LNDs should not be changeable at run time
 
+Severity   : normal
+Bugzilla   : 15272
+Description: ptl_send_rpc hits LASSERT when ptl_send_buf fails
+Details    : only hits under out-of-memory situations
+
+
+-------------------------------------------------------------------------------
+
+2009-02-07 Sun Microsystems, Inc.
+        * version 1.6.7
+	* Support for networks:
+	 socklnd   - any kernel supported by Lustre,
+	 qswlnd    - Qsnet kernel modules 5.20 and later,
+	 openiblnd - IbGold 1.8.2,
+	 o2iblnd   - OFED 1.1, 1.2.0, 1.2.5, and 1.3
+	 viblnd    - Voltaire ibhost 3.4.5 and later,
+	 ciblnd    - Topspin 3.2.0,
+	 iiblnd    - Infiniserv 3.3 + PathBits patch,
+	 gmlnd     - GM 2.1.22 and later,
+	 mxlnd     - MX 1.2.1 or later,
+	 ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
+
+Severity   : major
+Bugzilla   : 15983
+Description: workaround for OOM from o2iblnd
+Details    : OFED needs allocate big chunk of memory for QP while creating
+             connection for o2iblnd, OOM can happen if no such a contiguous
+	     memory chunk.
+	     QP size is decided by concurrent_sends and max_fragments of
+	     o2iblnd, now we permit user to specify smaller value for
+	     concurrent_sends of o2iblnd(i.e: concurrent_sends=7), which
+	     will decrease memory block size required by creating QP.
+
+Severity   : major
+Bugzilla   : 15093
+Description: Support Zerocopy receive of Chelsio device
+Details    : Chelsio driver can support zerocopy for iov[1] if it's
+             contiguous and large enough.
+
+Severity   : normal
+Bugzilla   : 13490
+Description: fix credit flow deadlock in uptllnd
+
+Severity   : normal
+Bugzilla   : 16308
+Description: finalize network operation in reasonable time
+Details    : conf-sanity test_32a couldn't stop ost and mds because it
+             tried to access non-existent peer and tcp connect took
+	     quite long before timing out.
+
+Severity   : major
+Bugzilla   : 16338
+Description: Continuous recovery on 33 of 413 nodes after lustre oss failure
+Details    : Lost reference on conn prevents peer from being destroyed, which
+             could prevent new peer creation if peer count has reached upper
+	     limit.
+
+Severity   : normal
+Bugzilla   : 16102
+Description: LNET Selftest results in Soft lockup on OSS CPU
+Details    : only hits when 8 or more o2ib clients involved and a session is
+             torn down with 'lst end_session' without preceeding 'lst stop'.
+
+Severity   : minor
+Bugzilla   : 16321
+Description: concurrent_sends in IB LNDs should not be changeable at run time
+Details    : concurrent_sends in IB LNDs should not be changeable at run time
+
 -------------------------------------------------------------------------------
 
 11-03-2008  Sun Microsystems, Inc.
         * version 1.6.6
-        * Support for networks:
-         socklnd   - any kernel supported by Lustre,
-         qswlnd    - Qsnet kernel modules 5.20 and later,
-         openiblnd - IbGold 1.8.2,
-         o2iblnd   - OFED 1.1, 1.2.0, 1.2.5, and 1.3
-         viblnd    - Voltaire ibhost 3.4.5 and later,
-         ciblnd    - Topspin 3.2.0,
-         iiblnd    - Infiniserv 3.3 + PathBits patch,
-         gmlnd     - GM 2.1.22 and later,
-         mxlnd     - MX 1.2.1 or later,
-         ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
+	* Support for networks:
+	 socklnd   - any kernel supported by Lustre,
+	 qswlnd    - Qsnet kernel modules 5.20 and later,
+	 openiblnd - IbGold 1.8.2,
+	 o2iblnd   - OFED 1.1, 1.2.0, 1.2.5, and 1.3
+	 viblnd    - Voltaire ibhost 3.4.5 and later,
+	 ciblnd    - Topspin 3.2.0,
+	 iiblnd    - Infiniserv 3.3 + PathBits patch,
+	 gmlnd     - GM 2.1.22 and later,
+	 mxlnd     - MX 1.2.1 or later,
+	 ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
 
 Severity   : normal
 Bugzilla   : 15272
@@ -96,6 +261,7 @@ Details    : only hits under out-of-memory situations
 
 -------------------------------------------------------------------------------
 
+
 04-26-2008  Sun Microsystems, Inc.
        * version 1.6.5
        * Support for networks:
diff --git a/lnet/autoMakefile.in b/lnet/autoMakefile.in
index b7b41a8..903c2df 100644
--- a/lnet/autoMakefile.in
+++ b/lnet/autoMakefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/autoconf/Makefile.am b/lnet/autoconf/Makefile.am
index 171634a..2c72c6e 100644
--- a/lnet/autoconf/Makefile.am
+++ b/lnet/autoconf/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST := lustre-lnet.m4
+EXTRA_DIST := ofed.m4 lustre-lnet.m4
diff --git a/lnet/autoconf/Makefile.in b/lnet/autoconf/Makefile.in
index 4378873..63d28ec 100644
--- a/lnet/autoconf/Makefile.in
+++ b/lnet/autoconf/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -291,7 +291,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-EXTRA_DIST := lustre-lnet.m4
+EXTRA_DIST := ofed.m4 lustre-lnet.m4
 subdir = lnet/autoconf
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4
index b7c02e7..4301227 100644
--- a/lnet/autoconf/lustre-lnet.m4
+++ b/lnet/autoconf/lustre-lnet.m4
@@ -546,7 +546,8 @@ else
 		O2IBCPPFLAGS="-I$O2IBPATH/include"
 		EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
 		EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
-		EXTRA_LNET_INCLUDE="$O2IBCPPFLAGS $EXTRA_LNET_INCLUDE"
+		EXTRA_LNET_INCLUDE="$EXTRA_LNET_INCLUDE $O2IBCPPFLAGS"
+
 		LB_LINUX_TRY_COMPILE([
 		        #include <linux/version.h>
 		        #include <linux/pci.h>
@@ -591,52 +592,22 @@ else
 					break;
 				fi
 			done
-			if test -n $O2IB_SYMVER ; then
+			if test -n "$O2IB_SYMVER"; then
 				AC_MSG_NOTICE([adding $O2IBPATH/Module.symvers to $PWD/$SYMVERFILE])
 				# strip out the existing symbols versions first
-				egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
+				if test -f $PWD/$SYMVERFILE; then
+				    egrep -v $(echo $(awk '{ print $2 }' $O2IBPATH/$O2IB_SYMVER) | tr ' ' '|') $PWD/$SYMVERFILE > $PWD/$SYMVERFILE.old
+				else
+				    touch $PWD/$SYMVERFILE.old
+				fi
 				cat $PWD/$SYMVERFILE.old $O2IBPATH/$O2IB_SYMVER > $PWD/$SYMVERFILE
+				rm $PWD/$SYMVERFILE.old
 			else
 				AC_MSG_ERROR([an external source tree was specified for o2iblnd however I could not find a $O2IBPATH/Module.symvers there])
 			fi
 		fi
 
-		LB_LINUX_TRY_COMPILE([
-			#include <linux/version.h>
-			#include <linux/pci.h>
-			#if !HAVE_GFP_T
-			typedef int gfp_t;
-			#endif
-			#include <rdma/ib_verbs.h>
-		],[
-			ib_dma_map_single(NULL, NULL, 0, 0);
-			return 0;
-		],[
-			AC_MSG_RESULT(yes)
-			AC_DEFINE(HAVE_OFED_IB_DMA_MAP, 1,
-				  [ib_dma_map_single defined])
-		],[
-			AC_MSG_RESULT(NO)
-		])
-
-		LB_LINUX_TRY_COMPILE([
-			#include <linux/version.h>
-			#include <linux/pci.h>
-			#if !HAVE_GFP_T
-			typedef int gfp_t;
-			#endif
-			#include <rdma/ib_verbs.h>
-		],[
-			ib_create_cq(NULL, NULL, NULL, NULL, 0, 0);
-			return 0;
-		],[
-			AC_MSG_RESULT(yes)
-			AC_DEFINE(HAVE_OFED_IB_COMP_VECTOR, 1,
-				  [has completion vector])
-		],[
-			AC_MSG_RESULT(NO)
-		])
-
+		LN_CONFIG_OFED_SPEC
 		EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 	fi
 fi
@@ -1098,24 +1069,48 @@ AC_DEFINE(HAVE_SHOW_TASK, 1, [show_task is exported])
 ])
 ])
 
+# check kernel __u64 type
+AC_DEFUN([LN_KERN__U64_LONG_LONG],
+[AC_MSG_CHECKING([kernel __u64 is long long type])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Werror"
+LB_LINUX_TRY_COMPILE([
+	#include <linux/types.h>
+	#include <linux/stddef.h>
+],[
+	unsigned long long *data1;
+	__u64 *data2 = NULL;
+		
+	data1 = data2;
+],[
+	AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_KERN__U64_LONG_LONG, 1,
+                  [kernel __u64 is long long type])
+],[
+	AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
 # check userland __u64 type
-AC_DEFUN([LN_U64_LONG_LONG],
-[AC_MSG_CHECKING([__u64 is long long type])
+AC_DEFUN([LN_USER__U64_LONG_LONG],
+[AC_MSG_CHECKING([userspace __u64 is long long type])
 tmp_flags="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE([
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		unsigned long long *data1;
-		__u64 *data2;
+		__u64 *data2 = NULL;
 		
 		data1 = data2;
 		return 0;
 	}
 ],[
 	AC_MSG_RESULT([yes])
-        AC_DEFINE(HAVE_U64_LONG_LONG, 1,
-                  [__u64 is long long type])
+        AC_DEFINE(HAVE_USER__U64_LONG_LONG, 1,
+                  [userspace __u64 is long long type])
 ],[
 	AC_MSG_RESULT([no])
 ])
@@ -1129,9 +1124,10 @@ tmp_flags="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE([
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		unsigned long *data1;
-		size_t *data2;
+		size_t *data2 = NULL;
 		
 		data1 = data2;
 		return 0;
@@ -1152,9 +1148,10 @@ tmp_flags="$CFLAGS"
 CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE([
 	#include <linux/types.h>
+	#include <linux/stddef.h>
 	int main(void) {
 		long *data1;
-		ssize_t *data2;
+		ssize_t *data2 = NULL;
 		
 		data1 = data2;
 		return 0;
@@ -1188,6 +1185,24 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 
+# check if task_struct with rcu memeber
+AC_DEFUN([LN_TASK_RCU],
+[AC_MSG_CHECKING([if task_struct has a rcu field])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/sched.h>
+],[
+        struct task_struct tsk;
+
+        tsk.rcu.next = NULL;
+],[
+	AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_TASK_RCU, 1,
+                  [task_struct has rcu field])
+],[
+	AC_MSG_RESULT([no])
+])
+])
+
 # LN_TASKLIST_LOCK
 # 2.6.18 remove tasklist_lock export
 AC_DEFUN([LN_TASKLIST_LOCK],
@@ -1294,6 +1309,7 @@ LB_LINUX_TRY_COMPILE([
 ])
 EXTRA_KCFLAGS="$tmp_flags"
 ])
+
 # 2.6.23 lost dtor argument
 AC_DEFUN([LN_KMEM_CACHE_CREATE_DTOR],
 [AC_MSG_CHECKING([check kmem_cache_create has dtor argument])
@@ -1310,6 +1326,52 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+#
+# LN_FUNC_DUMP_TRACE
+#
+# 2.6.23 exports dump_trace() so we can dump_stack() on any task
+# 2.6.24 has stacktrace_ops.address with "reliable" parameter
+#
+AC_DEFUN([LN_FUNC_DUMP_TRACE],
+[LB_CHECK_SYMBOL_EXPORT([dump_trace],
+[kernel/ksyms.c arch/${LINUX_ARCH%_64}/kernel/traps_64.c],[
+	tmp_flags="$EXTRA_KCFLAGS"
+	EXTRA_KCFLAGS="-Werror"
+	AC_MSG_CHECKING([whether we can really use dump_stack])
+	LB_LINUX_TRY_COMPILE([
+		struct task_struct;
+		struct pt_regs;
+		#include <asm/stacktrace.h>
+	],[
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_DUMP_TRACE, 1, [dump_trace is exported])
+	],[
+		AC_MSG_RESULT(no)
+	],[
+	])
+	AC_MSG_CHECKING([whether print_trace_address has reliable argument])
+	LB_LINUX_TRY_COMPILE([
+		struct task_struct;
+		struct pt_regs;
+		void print_addr(void *data, unsigned long addr, int reliable);
+		#include <asm/stacktrace.h>
+	],[
+		struct stacktrace_ops ops;
+
+		ops.address = print_addr;
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_TRACE_ADDRESS_RELIABLE, 1,
+			  [print_trace_address has reliable argument])
+	],[
+		AC_MSG_RESULT(no)
+	],[
+	])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+])
+
 # 2.6.24 request not use real numbers for ctl_name
 AC_DEFUN([LN_SYSCTL_UNNUMBERED],
 [AC_MSG_CHECKING([for CTL_UNNUMBERED])
@@ -1324,7 +1386,7 @@ LB_LINUX_TRY_COMPILE([
         AC_DEFINE(HAVE_SYSCTL_UNNUMBERED, 1,
                   [sysctl has CTL_UNNUMBERED])
 ],[
-        AC_MSG_RESULT(NO)
+        AC_MSG_RESULT(no)
 ])
 ])
 
@@ -1340,7 +1402,7 @@ LB_LINUX_TRY_COMPILE([
         AC_DEFINE(HAVE_SCATTERLIST_SETPAGE, 1,
                   [struct scatterlist has page member])
 ],[
-        AC_MSG_RESULT(NO)
+        AC_MSG_RESULT(no)
 ])
 ])
 
@@ -1358,10 +1420,36 @@ LB_LINUX_TRY_COMPILE([
         AC_DEFINE(HAVE_SEM_COUNT_ATOMIC, 1,
                   [semaphore counter is atomic])
 ],[
-        AC_MSG_RESULT(NO)
+        AC_MSG_RESULT(no)
 ])
 ])
 
+# 2.6.27 have second argument to sock_map_fd
+AC_DEFUN([LN_SOCK_MAP_FD_2ARG],
+[AC_MSG_CHECKING([sock_map_fd have second argument])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/net.h>
+],[
+        sock_map_fd(NULL, 0);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_SOCK_MAP_FD_2ARG, 1,
+                  [sock_map_fd have second argument])
+],[
+        AC_MSG_RESULT(no)
+])
+])
+
+#
+#
+# LN_CONFIG_USERSPACE
+#
+#
+AC_DEFUN([LN_CONFIG_USERSPACE],
+[
+LN_USER__U64_LONG_LONG
+])
+
 #
 # LN_PROG_LINUX
 #
@@ -1389,10 +1477,11 @@ LN_CONFIG_MX
 LN_STRUCT_PAGE_LIST
 LN_STRUCT_SIGHAND
 LN_FUNC_SHOW_TASK
-LN_U64_LONG_LONG
+LN_KERN__U64_LONG_LONG
 LN_SSIZE_T_LONG
 LN_SIZE_T_LONG
 LN_LE_TYPES
+LN_TASK_RCU
 # 2.6.18
 LN_TASKLIST_LOCK
 # 2.6.19
@@ -1410,6 +1499,9 @@ LN_SYSCTL_UNNUMBERED
 LN_SCATTERLIST_SETPAGE
 # 2.6.26
 LN_SEM_COUNT
+# 2.6.27
+LN_SOCK_MAP_FD_2ARG
+LN_FUNC_DUMP_TRACE
 ])
 
 #
diff --git a/lnet/autoconf/ofed.m4 b/lnet/autoconf/ofed.m4
new file mode 100644
index 0000000..aefc27d
--- /dev/null
+++ b/lnet/autoconf/ofed.m4
@@ -0,0 +1,96 @@
+dnl Checks for OFED
+AC_DEFUN([LN_CONFIG_OFED_SPEC],
+[
+	AC_MSG_CHECKING([if OFED has ib_dma_map_single])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
+	],[
+		ib_dma_map_single(NULL, NULL, 0, 0);
+		return 0;
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_IB_DMA_MAP, 1,
+			  [ib_dma_map_single defined])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if ib_create_cq wants comp_vector])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
+	],[
+		ib_create_cq(NULL, NULL, NULL, NULL, 0, 0);
+		return 0;
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_IB_COMP_VECTOR, 1,
+			  [has completion vector])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if OFED supports iWarp transport])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/ib_verbs.h>
+	],[
+		return RDMA_TRANSPORT_IWARP ==
+		       rdma_node_get_transport(RDMA_NODE_RNIC);
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_TRANSPORT_IWARP, 1,
+			  [has transport iWARP])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if OFED has RDMA_CM_EVENT_ADDR_CHANGE])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/rdma_cm.h>
+	],[
+		return (RDMA_CM_EVENT_ADDR_CHANGE == 0);
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_RDMA_CMEV_ADDRCHANGE, 1,
+			  [has completion vector])
+	],[
+		AC_MSG_RESULT(no)
+	])
+
+	AC_MSG_CHECKING([if OFED has RDMA_CM_EVENT_TIMEWAIT_EXIT])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/version.h>
+		#include <linux/pci.h>
+		#if !HAVE_GFP_T
+		typedef int gfp_t;
+		#endif
+		#include <rdma/rdma_cm.h>
+	],[
+		return (RDMA_CM_EVENT_TIMEWAIT_EXIT == 0);
+	],[
+		AC_MSG_RESULT(yes)
+		AC_DEFINE(HAVE_OFED_RDMA_CMEV_TIMEWAIT_EXIT, 1,
+			  [has completion vector])
+	],[
+		AC_MSG_RESULT(no)
+	])
+])
diff --git a/lnet/doc/Makefile.am b/lnet/doc/Makefile.am
index 6ba3864..fe4c64e 100644
--- a/lnet/doc/Makefile.am
+++ b/lnet/doc/Makefile.am
@@ -56,10 +56,10 @@ all: $(DOCS)
 
 # update date and version in document
 date := $(shell date +%x)
-tag := $(shell echo '$$Name: v1_6_7_2_RC4 $$' | sed -e 's/^\$$Na''me: *\$$$$/HEAD/; s/^\$$Na''me: \(.*\) \$$$$/\1/')
+tag := $(shell echo '$$Name: v1_8_1_RC4 $$' | sed -e 's/^\$$Na''me: *\$$$$/HEAD/; s/^\$$Na''me: \(.*\) \$$$$/\1/')
 addversion = sed -e 's|@T''AG@|$(tag)|g; s|@VER''SION@|$(VERSION)|g; s|@DA''TE@|$(date)|g'
 
-# Regenerate when the $(VERSION) or $Name: v1_6_7_2_RC4 $ changes.
+# Regenerate when the $(VERSION) or $Name: v1_8_1_RC4 $ changes.
 .INTERMEDIATE: $(GENERATED)
 $(GENERATED) : %.lyx: %.lin Makefile
 	$(addversion) $< > $@
diff --git a/lnet/doc/Makefile.in b/lnet/doc/Makefile.in
index 985a495..34cc61c 100644
--- a/lnet/doc/Makefile.in
+++ b/lnet/doc/Makefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -345,7 +345,7 @@ EXTRA_DIST = $(DOCS) $(IMAGES) $(LYXFILES)
 
 # update date and version in document
 date := $(shell date +%x)
-tag := $(shell echo '$$Name: v1_6_7_2_RC4 $$' | sed -e 's/^\$$Na''me: *\$$$$/HEAD/; s/^\$$Na''me: \(.*\) \$$$$/\1/')
+tag := $(shell echo '$$Name: v1_8_1_RC4 $$' | sed -e 's/^\$$Na''me: *\$$$$/HEAD/; s/^\$$Na''me: \(.*\) \$$$$/\1/')
 addversion = sed -e 's|@T''AG@|$(tag)|g; s|@VER''SION@|$(VERSION)|g; s|@DA''TE@|$(date)|g'
 subdir = lnet/doc
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -489,7 +489,7 @@ uninstall-am: uninstall-info-am
 
 all: $(DOCS)
 
-# Regenerate when the $(VERSION) or $Name: v1_6_7_2_RC4 $ changes.
+# Regenerate when the $(VERSION) or $Name: v1_8_1_RC4 $ changes.
 .INTERMEDIATE: $(GENERATED)
 $(GENERATED) : %.lyx: %.lin Makefile
 	$(addversion) $< > $@
diff --git a/lnet/include/Makefile.in b/lnet/include/Makefile.in
index ca11724..89a2767 100644
--- a/lnet/include/Makefile.in
+++ b/lnet/include/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/include/libcfs/Makefile.in b/lnet/include/libcfs/Makefile.in
index 1356609..f03b0f2 100644
--- a/lnet/include/libcfs/Makefile.in
+++ b/lnet/include/libcfs/Makefile.in
@@ -175,9 +175,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/include/libcfs/libcfs.h b/lnet/include/libcfs/libcfs.h
index 5db6433..cf8aaaa 100644
--- a/lnet/include/libcfs/libcfs.h
+++ b/lnet/include/libcfs/libcfs.h
@@ -110,11 +110,15 @@ extern unsigned int libcfs_stack;
 extern unsigned int libcfs_debug;
 extern unsigned int libcfs_printk;
 extern unsigned int libcfs_console_ratelimit;
+extern unsigned int libcfs_watchdog_ratelimit;
 extern cfs_duration_t libcfs_console_max_delay;
 extern cfs_duration_t libcfs_console_min_delay;
 extern unsigned int libcfs_console_backoff;
 extern unsigned int libcfs_debug_binary;
 extern char debug_file_path_arr[1024];
+#ifdef __KERNEL__
+extern char *debug_file_path;
+#endif
 
 int libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys);
 int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys);
@@ -404,8 +408,10 @@ struct lc_watchdog *lc_watchdog_add(int time,
                                     void *data);
 
 /* Enables a watchdog and resets its timer. */
-void lc_watchdog_touch_ms(struct lc_watchdog *lcw, int timeout_ms);
-void lc_watchdog_touch(struct lc_watchdog *lcw);
+void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout);
+#define GET_TIMEOUT(svc) (max_t(int, obd_timeout,                       \
+                          AT_OFF ? 0 : at_get(&svc->srv_at_estimate)) * \
+                          svc->srv_watchdog_factor)
 
 /* Disable a watchdog; touch it to restart it. */
 void lc_watchdog_disable(struct lc_watchdog *lcw);
@@ -562,6 +568,10 @@ extern int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
 extern void libcfs_assertion_failed(const char *expr, const char *file,
                                     const char *fn, const int line);
 
+/* one more external symbol that tracefile provides: */
+extern int trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
+                                const char *knl_buffer, char *append);
+
 static inline void cfs_slow_warning(cfs_time_t now, int seconds, char *msg)
 {
         if (cfs_time_after(cfs_time_current(),
diff --git a/lnet/include/libcfs/linux/Makefile.in b/lnet/include/libcfs/linux/Makefile.in
index 165ed3a..5ba3c9f 100644
--- a/lnet/include/libcfs/linux/Makefile.in
+++ b/lnet/include/libcfs/linux/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/include/libcfs/linux/kp30.h b/lnet/include/libcfs/linux/kp30.h
index ac90aa0..0431bab 100644
--- a/lnet/include/libcfs/linux/kp30.h
+++ b/lnet/include/libcfs/linux/kp30.h
@@ -382,7 +382,8 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
  #define _LWORDSIZE __WORDSIZE
 #endif
 
-#if defined(HAVE_U64_LONG_LONG)
+#if (defined(__KERNEL__) && defined(HAVE_KERN__U64_LONG_LONG)) || \
+    (!defined(__KERNEL__) && defined(HAVE_USER__U64_LONG_LONG))
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
@@ -412,4 +413,17 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 
 #undef _LWORDSIZE
 
+#ifndef get_cpu
+# ifdef CONFIG_PREEMPT
+#  define cfs_get_cpu()  ({ preempt_disable(); smp_processor_id(); })
+#  define cfs_put_cpu()  preempt_enable()
+# else
+#  define cfs_get_cpu()  smp_processor_id()
+#  define cfs_put_cpu()
+# endif
+#else
+# define cfs_get_cpu()   get_cpu()
+# define cfs_put_cpu()   put_cpu()
+#endif /* get_cpu & put_cpu */
+
 #endif
diff --git a/lnet/include/libcfs/linux/linux-fs.h b/lnet/include/libcfs/linux/linux-fs.h
index 706eded..8cbd637 100644
--- a/lnet/include/libcfs/linux/linux-fs.h
+++ b/lnet/include/libcfs/linux/linux-fs.h
@@ -94,5 +94,6 @@ typedef struct file_lock cfs_flock_t;
 ssize_t cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset);
 
 #endif
+#define CFS_IFTODT(type)   (((type) & 0170000) >> 12)
 
 #endif
diff --git a/lnet/include/libcfs/linux/linux-mem.h b/lnet/include/libcfs/linux/linux-mem.h
index 1679946..d538ff0 100644
--- a/lnet/include/libcfs/linux/linux-mem.h
+++ b/lnet/include/libcfs/linux/linux-mem.h
@@ -90,6 +90,9 @@ static inline int cfs_page_count(cfs_page_t *page)
 
 #define cfs_page_index(p)       ((p)->index)
 
+#define cfs_page_pin(page) page_cache_get(page)
+#define cfs_page_unpin(page) page_cache_release(page)
+
 /*
  * Memory allocator
  * XXX Liang: move these declare to public file
diff --git a/lnet/include/libcfs/linux/linux-prim.h b/lnet/include/libcfs/linux/linux-prim.h
index 33450fc..091d703 100644
--- a/lnet/include/libcfs/linux/linux-prim.h
+++ b/lnet/include/libcfs/linux/linux-prim.h
@@ -168,6 +168,7 @@ static inline int cfs_kernel_thread(int (*fn)(void *),
         return rc;
 }
 
+#define CFS_MAX_SCHEDULE_TIMEOUT MAX_SCHEDULE_TIMEOUT
 
 /*
  * Task struct
@@ -235,6 +236,7 @@ static inline cfs_time_t cfs_timer_deadline(cfs_timer_t *t)
         return t->expires;
 }
 
+#define CFS_MAX_SCHEDULE_TIMEOUT MAX_SCHEDULE_TIMEOUT
 
 /* deschedule for a bit... */
 static inline void cfs_pause(cfs_duration_t ticks)
diff --git a/lnet/include/libcfs/linux/portals_compat25.h b/lnet/include/libcfs/linux/portals_compat25.h
index 492fd00..2ad4d1a 100644
--- a/lnet/include/libcfs/linux/portals_compat25.h
+++ b/lnet/include/libcfs/linux/portals_compat25.h
@@ -155,4 +155,11 @@ typedef unsigned long cpumask_t;
 #define DECLARE_LL_PROC_PPOS_DECL
 #endif
 
+/* helper for sysctl handlers */
+int proc_call_handler(void *data, int write,
+                      loff_t *ppos, void *buffer, size_t *lenp,
+                      int (*handler)(void *data, int write,
+                                     loff_t pos, void *buffer, int len));
+
+
 #endif /* _PORTALS_COMPAT_H */
diff --git a/lnet/include/libcfs/user-prim.h b/lnet/include/libcfs/user-prim.h
index 389483a..889174b 100644
--- a/lnet/include/libcfs/user-prim.h
+++ b/lnet/include/libcfs/user-prim.h
@@ -153,6 +153,8 @@ void cfs_kunmap(cfs_page_t *pg);
 #define cfs_get_page(p)			__I_should_not_be_called__(at_all)
 #define cfs_page_count(p)		__I_should_not_be_called__(at_all)
 #define cfs_page_index(p)               ((p)->index)
+#define cfs_page_pin(page) do {} while (0)
+#define cfs_page_unpin(page) do {} while (0)
 
 /*
  * Memory allocator
diff --git a/lnet/include/lnet/Makefile.in b/lnet/include/lnet/Makefile.in
index 797a6b5..c043e63 100644
--- a/lnet/include/lnet/Makefile.in
+++ b/lnet/include/lnet/Makefile.in
@@ -175,9 +175,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h
index d8f4d19..018da31 100644
--- a/lnet/include/lnet/lib-lnet.h
+++ b/lnet/include/lnet/lib-lnet.h
@@ -568,6 +568,7 @@ lnet_net2ni (__u32 net)
 }
 
 int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, time_t when);
+void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, time_t when);
 int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid);
 int lnet_check_routes(void);
 int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
@@ -699,6 +700,7 @@ int lnet_acceptor_start(void);
 void lnet_acceptor_stop(void);
 
 int lnet_peers_start_down(void);
+int lnet_peer_buffer_credits(lnet_ni_t *ni);
 int lnet_router_checker_start(void);
 void lnet_router_checker_stop(void);
 
diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h
index e456514..c049003 100644
--- a/lnet/include/lnet/lib-types.h
+++ b/lnet/include/lnet/lib-types.h
@@ -262,7 +262,6 @@ typedef struct lnet_libmd {
         unsigned int      md_flags;
         void             *md_user_ptr;
         lnet_eq_t        *md_eq;
-        void             *md_addrkey;
         unsigned int      md_niov;                /* # frags */
         union {
                 struct iovec  iov[LNET_MAX_IOV];
@@ -358,6 +357,9 @@ typedef struct lnet_lnd
         /* notification of peer health */
         void (*lnd_notify)(struct lnet_ni *ni, lnet_nid_t peer, int alive);
 
+        /* query of peer aliveness */
+        void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, time_t *when);
+
 #ifdef __KERNEL__
         /* accept a new connection */
         int (*lnd_accept)(struct lnet_ni *ni, cfs_socket_t *sock);
@@ -383,6 +385,8 @@ typedef struct lnet_ni {
         int               ni_txcredits;         /* # tx credits free */
         int               ni_mintxcredits;      /* lowest it's been */
         int               ni_peertxcredits;     /* # per-peer send credits */
+        int               ni_peerrtrcredits;    /* # per-peer router buffer credits */
+        int               ni_peertimeout;       /* seconds to consider peer dead */
         lnet_nid_t        ni_nid;               /* interface's NID */
         void             *ni_data;              /* instance-specific data */
         lnd_t            *ni_lnd;               /* procedural interface */
@@ -407,6 +411,8 @@ typedef struct lnet_peer {
         int               lp_alive_count;       /* # times router went dead<->alive */
         long              lp_txqnob;            /* bytes queued for sending */
         time_t            lp_timestamp;         /* time of last aliveness news */
+        time_t            lp_last_alive;        /* when I was last alive */
+        time_t            lp_last_query;        /* when LND was queried last time */
         time_t            lp_ping_timestamp;    /* time of last ping attempt */
         time_t            lp_ping_deadline;     /* != 0 if ping reply expected */
         lnet_ni_t        *lp_ni;                /* interface peer is on */
@@ -475,6 +481,7 @@ typedef struct {
 typedef struct {
         struct list_head ptl_ml;  /* match list */
         struct list_head ptl_msgq; /* messages blocking for MD */
+        __u64            ptl_ml_version;    /* validity stamp, only changed for new attached MD */
         __u64            ptl_msgq_version;  /* validity stamp */
         unsigned int     ptl_options;
 } lnet_portal_t;
diff --git a/lnet/include/lnet/linux/Makefile.in b/lnet/include/lnet/linux/Makefile.in
index aa90cd2..c64a172 100644
--- a/lnet/include/lnet/linux/Makefile.in
+++ b/lnet/include/lnet/linux/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/include/lnet/ptllnd_wire.h b/lnet/include/lnet/ptllnd_wire.h
index 277c51c..2dd7253 100644
--- a/lnet/include/lnet/ptllnd_wire.h
+++ b/lnet/include/lnet/ptllnd_wire.h
@@ -108,6 +108,9 @@ typedef struct
 
 } kptl_msg_t;
 
+/* kptl_msg_t::ptlm_credits is only a __u8 */
+#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) -1)
+
 #define PTLLND_MSG_MAGIC                LNET_PROTO_PTL_MAGIC
 #define PTLLND_MSG_VERSION              0x04
 
diff --git a/lnet/include/lnet/socklnd.h b/lnet/include/lnet/socklnd.h
index 75a6b9b..c4a34fd 100644
--- a/lnet/include/lnet/socklnd.h
+++ b/lnet/include/lnet/socklnd.h
@@ -50,6 +50,8 @@
 #define SOCKLND_CONN_BULK_OUT   3
 #define SOCKLND_CONN_NTYPES     4
 
+#define SOCKLND_CONN_ACK        SOCKLND_CONN_BULK_IN
+
 typedef struct {
         __u32                   kshm_magic;     /* magic number of socklnd message */
         __u32                   kshm_version;   /* version of socklnd message */
@@ -72,18 +74,26 @@ typedef struct {
 typedef struct {
         __u32                   ksm_type;       /* type of socklnd message */
         __u32                   ksm_csum;       /* checksum if != 0 */
-        __u64                   ksm_zc_req_cookie; /* ack required if != 0 */
-        __u64                   ksm_zc_ack_cookie; /* ack if != 0 */
+        __u64                   ksm_zc_cookies[2]; /* Zero-Copy request/ACK cookie */
         union {
                 ksock_lnet_msg_t lnetmsg;       /* lnet message, it's empty if it's NOOP */
         } WIRE_ATTR ksm_u;
 } WIRE_ATTR ksock_msg_t;
 
-#define KSOCK_MSG_NOOP          0xc0            /* ksm_u empty */ 
+static inline void
+socklnd_init_msg(ksock_msg_t *msg, int type)
+{
+        msg->ksm_csum           = 0;
+        msg->ksm_type           = type;
+        msg->ksm_zc_cookies[0]  = msg->ksm_zc_cookies[1]  = 0;
+}
+
+#define KSOCK_MSG_NOOP          0xc0            /* ksm_u empty */
 #define KSOCK_MSG_LNET          0xc1            /* lnet msg */
 
 /* We need to know this number to parse hello msg from ksocklnd in
- * other LND (usocklnd, for example) */ 
+ * other LND (usocklnd, for example) */
 #define KSOCK_PROTO_V2          2
+#define KSOCK_PROTO_V3          3
 
 #endif
diff --git a/lnet/klnds/autoMakefile.in b/lnet/klnds/autoMakefile.in
index 38aec82..54fb211 100644
--- a/lnet/klnds/autoMakefile.in
+++ b/lnet/klnds/autoMakefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/klnds/ciblnd/Makefile.in b/lnet/klnds/ciblnd/Makefile.in
index 55311ad..27a79d0 100644
--- a/lnet/klnds/ciblnd/Makefile.in
+++ b/lnet/klnds/ciblnd/Makefile.in
@@ -3,6 +3,7 @@ kciblnd-objs := ciblnd.o ciblnd_cb.o ciblnd_modparams.o
 
 default: all
 
+EXTRA_DIST = $(kciblnd-objs:%.o=%.c)
 EXTRA_POST_CFLAGS := @CIBCPPFLAGS@ -I at LUSTRE@/../lnet/klnds/openiblnd
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/ciblnd/autoMakefile.am b/lnet/klnds/ciblnd/autoMakefile.am
index adb8801..5990ada 100644
--- a/lnet/klnds/ciblnd/autoMakefile.am
+++ b/lnet/klnds/ciblnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kciblnd-objs:%.o=%.c)
diff --git a/lnet/klnds/ciblnd/autoMakefile.in b/lnet/klnds/ciblnd/autoMakefile.in
index 75d927b..550f689 100644
--- a/lnet/klnds/ciblnd/autoMakefile.in
+++ b/lnet/klnds/ciblnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_CIBLND_TRUE@@MODULES_TRUE at modulenet_DATA = kciblnd$(KMODEXT)
-DIST_SOURCES = $(kciblnd-objs:%.o=%.c)
 subdir = lnet/klnds/ciblnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/klnds/gmlnd/Makefile.in b/lnet/klnds/gmlnd/Makefile.in
index 1aec50d..e933b59 100644
--- a/lnet/klnds/gmlnd/Makefile.in
+++ b/lnet/klnds/gmlnd/Makefile.in
@@ -1,6 +1,7 @@
 MODULES := kgmlnd
 kgmlnd-objs := gmlnd_api.o gmlnd_cb.o gmlnd_comm.o gmlnd_utils.o gmlnd_module.o
 
+EXTRA_DIST = $(kgmlnd-objs:%.o=%.c) gmlnd.h
 EXTRA_PRE_CFLAGS := @GMCPPFLAGS@ -DGM_KERNEL
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/gmlnd/autoMakefile.am b/lnet/klnds/gmlnd/autoMakefile.am
index 55ebc58..a6e7555 100644
--- a/lnet/klnds/gmlnd/autoMakefile.am
+++ b/lnet/klnds/gmlnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES = $(kgmlnd-objs:%.o=%.c) gmlnd.h
diff --git a/lnet/klnds/gmlnd/autoMakefile.in b/lnet/klnds/gmlnd/autoMakefile.in
index 9fc01c3..e329190 100644
--- a/lnet/klnds/gmlnd/autoMakefile.in
+++ b/lnet/klnds/gmlnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_GMLND_TRUE@@MODULES_TRUE at modulenet_DATA = kgmlnd$(KMODEXT)
-DIST_SOURCES = $(kgmlnd-objs:%.o=%.c) gmlnd.h
 subdir = lnet/klnds/gmlnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = README $(srcdir)/autoMakefile.in Makefile.in \
diff --git a/lnet/klnds/iiblnd/Makefile.in b/lnet/klnds/iiblnd/Makefile.in
index 7ee9b64..72c6e1d 100644
--- a/lnet/klnds/iiblnd/Makefile.in
+++ b/lnet/klnds/iiblnd/Makefile.in
@@ -1,6 +1,7 @@
 MODULES := kiiblnd
 kiiblnd-objs := iiblnd.o iiblnd_cb.o iiblnd_modparams.o
 
+EXTRA_DIST = $(kiiblnd-objs:%.o=%.c) iiblnd.h
 EXTRA_POST_CFLAGS := @IIBCPPFLAGS@
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/iiblnd/autoMakefile.am b/lnet/klnds/iiblnd/autoMakefile.am
index 6e6972f..1facfac 100644
--- a/lnet/klnds/iiblnd/autoMakefile.am
+++ b/lnet/klnds/iiblnd/autoMakefile.am
@@ -40,4 +40,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kiiblnd-objs:%.o=%.c) iiblnd.h
diff --git a/lnet/klnds/iiblnd/autoMakefile.in b/lnet/klnds/iiblnd/autoMakefile.in
index 4f0ecf6..f871886 100644
--- a/lnet/klnds/iiblnd/autoMakefile.in
+++ b/lnet/klnds/iiblnd/autoMakefile.in
@@ -210,9 +210,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -329,12 +329,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_IIBLND_TRUE@@MODULES_TRUE at modulenet_DATA = kiiblnd$(KMODEXT)
-DIST_SOURCES = $(kiiblnd-objs:%.o=%.c) iiblnd.h
 subdir = lnet/klnds/iiblnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/klnds/mxlnd/Makefile.in b/lnet/klnds/mxlnd/Makefile.in
index 378dbdd..7d175c9 100644
--- a/lnet/klnds/mxlnd/Makefile.in
+++ b/lnet/klnds/mxlnd/Makefile.in
@@ -1,6 +1,7 @@
 MODULES := kmxlnd
 kmxlnd-objs := mxlnd.o mxlnd_cb.o mxlnd_modparams.o
 
+EXTRA_DIST = $(kmxlnd-objs:%.o=%.c) mxlnd.h
 EXTRA_POST_CFLAGS := @MXCPPFLAGS@
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/mxlnd/README b/lnet/klnds/mxlnd/README
index eb79608..0acd0cd 100644
--- a/lnet/klnds/mxlnd/README
+++ b/lnet/klnds/mxlnd/README
@@ -29,9 +29,12 @@ I. Installation
 ================
 
 MXLND is supported on Linux 2.6. It may be possible to run it on 2.4,
-but it has not been tested. MXLND requires Myricom's MX version 1.2.1
+but it has not been tested. MXLND requires Myricom's MX version 1.2.8
 or higher. See MX's README for the supported list of processors.
 
+MXLND requires the optional MX kernel library interface. MX must be compiled
+with --enable-kernel-lib.
+
 1. Configuring and compiling
 
 MXLND should be already integrated into the Lustre build process. To 
@@ -68,26 +71,9 @@ The available options are:
     board       index value of the Myrinet board (NIC)
     ep_id       MX endpoint ID
     polling     Use 0 to block (wait). A value > 0 will poll that many times before blocking
-    hosts       IP-to-hostname resolution file
-
-Of these, only hosts is required. It must be the absolute path to the
-MXLND hosts file. For example:
-
-    options kmxlnd hosts=/etc/hosts.mxlnd
-
-The file format for the hosts file is as follows:
-
-IP  HOST  BOARD   EP_ID
-
-The values must be space and/or tab separated where:
-
-    IP is a valid IPv4 address
-    HOST is the name returned by `hostname` on that machine
-    BOARD is the index of the Myricom NIC (0 for the first card, etc.)
-    EP_ID is the MX endpoint ID
 
-You may want to vary the remaining options to obtain the optimal performance
-for your platform.
+You may want to vary the options to obtain the optimal performance for your
+platform.
 
     n_waitd sets the number of threads that process completed MX requests
 (sends and receives). In our testing, the default of 1 performed best.
@@ -111,13 +97,13 @@ of the flow-control system in Lustre. Increasing this value may improve performa
 but it requires more memory since each message requires at least one page.
 
     board is the index of the Myricom NIC. Hosts can have multiple Myricom NICs
-and this identifies which one MXLND should use. This value must match the board
-value in your MXLND hosts file for this host.
+and this identifies which one MXLND should use.
 
     ep_id is the MX endpoint ID. Each process that uses MX is required to have at
 least one MX endpoint to access the MX library and NIC. The ID is a simple index
-starting at 0. This value must match the endpoint ID value in your MXLND hosts 
-file for this host.
+starting at 0. When used on a server, the server will attempt to use this end-
+point. When used on a client, it specifies the endpoint to connect to on the 
+management server.
 
     polling determines whether this host will poll or block for MX request com-
 pletions. A value of 0 blocks and any positive value will poll that many times
diff --git a/lnet/klnds/mxlnd/autoMakefile.am b/lnet/klnds/mxlnd/autoMakefile.am
index f72374e..415333f 100644
--- a/lnet/klnds/mxlnd/autoMakefile.am
+++ b/lnet/klnds/mxlnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kmxlnd-objs:%.o=%.c) mxlnd.h mxlnd_wire.h
diff --git a/lnet/klnds/mxlnd/autoMakefile.in b/lnet/klnds/mxlnd/autoMakefile.in
index 5a0e392..55a4025 100644
--- a/lnet/klnds/mxlnd/autoMakefile.in
+++ b/lnet/klnds/mxlnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_MXLND_TRUE@@MODULES_TRUE at modulenet_DATA = kmxlnd$(KMODEXT)
-DIST_SOURCES = $(kmxlnd-objs:%.o=%.c) mxlnd.h mxlnd_wire.h
 subdir = lnet/klnds/mxlnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = README $(srcdir)/autoMakefile.in Makefile.in \
diff --git a/lnet/klnds/mxlnd/mxlnd.c b/lnet/klnds/mxlnd/mxlnd.c
index 5a22907..4dc6fee 100644
--- a/lnet/klnds/mxlnd/mxlnd.c
+++ b/lnet/klnds/mxlnd/mxlnd.c
@@ -68,9 +68,9 @@ mxlnd_ctx_free(struct kmx_ctx *ctx)
 
         if (ctx->mxc_page != NULL) {
                 __free_page(ctx->mxc_page);
-                spin_lock(&kmxlnd_data.kmx_global_lock);
+                write_lock(&kmxlnd_data.kmx_global_lock);
                 kmxlnd_data.kmx_mem_used -= MXLND_EAGER_SIZE;
-                spin_unlock(&kmxlnd_data.kmx_global_lock);
+                write_unlock(&kmxlnd_data.kmx_global_lock);
         }
 
         if (ctx->mxc_seg_list != NULL) {
@@ -111,9 +111,9 @@ mxlnd_ctx_alloc(struct kmx_ctx **ctxp, enum kmx_req_type type)
                 ret = -ENOMEM;
                 goto failed;
         }
-        spin_lock(&kmxlnd_data.kmx_global_lock);
+        write_lock(&kmxlnd_data.kmx_global_lock);
         kmxlnd_data.kmx_mem_used += MXLND_EAGER_SIZE;
-        spin_unlock(&kmxlnd_data.kmx_global_lock);
+        write_unlock(&kmxlnd_data.kmx_global_lock);
         ctx->mxc_msg = (struct kmx_msg *)((char *)page_address(ctx->mxc_page));
         ctx->mxc_seg.segment_ptr = MX_PA_TO_U64(lnet_page2phys(ctx->mxc_page));
         ctx->mxc_state = MXLND_CTX_IDLE;
@@ -294,242 +294,8 @@ mxlnd_free_peers(void)
         }
 }
 
-int
-mxlnd_host_alloc(struct kmx_host **hostp)
-{
-        struct kmx_host *host   = NULL;
-
-        MXLND_ALLOC(host, sizeof (*host));
-        if (host == NULL) {
-                CDEBUG(D_NETERROR, "Cannot allocate host\n");
-                return -1;
-        }
-        memset(host, 0, sizeof(*host));
-        spin_lock_init(&host->mxh_lock);
-
-        *hostp = host;
-
-        return 0;
-}
-
-void
-mxlnd_host_free(struct kmx_host *host)
-{
-        if (host == NULL) return;
-
-        if (host->mxh_hostname != NULL)
-                MXLND_FREE(host->mxh_hostname, strlen(host->mxh_hostname) + 1);
-
-        MXLND_FREE(host, sizeof(*host));
-        return;
-}
-
 /**
- * mxlnd_free_hosts - free kmx_hosts
- *
- * Called from mxlnd_shutdown()
- */
-void
-mxlnd_free_hosts(void)
-{
-        struct kmx_host         *host   = NULL;
-        struct kmx_host         *next   = NULL;
-
-        list_for_each_entry_safe(host, next, &kmxlnd_data.kmx_hosts, mxh_list) {
-                list_del_init(&host->mxh_list);
-                mxlnd_host_free(host);
-        }
-        return;
-}
-
-#define xstr(s) #s
-#define str(s) xstr(s)
-#define MXLND_MAX_BOARD 4       /* we expect hosts to have fewer NICs than this */
-#define MXLND_MAX_EP_ID 16      /* we expect hosts to have less than this endpoints */
-
-/* this parses a line that consists of:
- * 
- * IP              HOSTNAME           BOARD        ENDPOINT ID
- * 169.192.0.113   mds01              0            3
- * 
- * By default MX uses the alias (short hostname). If you override
- * it using mx_hostname to use the FQDN or some other name, the hostname
- * here must match exactly.
- */
-
-/* MX_MAX_HOSTNAME_LEN = 80. See myriexpress.h */
-int
-mxlnd_parse_line(char *line)
-{
-        int             i               = 0;
-        int             ret             = 0;
-        int             len             = 0;
-        u32             ip[4]           = { 0, 0, 0, 0 };
-        char            hostname[MX_MAX_HOSTNAME_LEN];
-        u32             board           = -1;
-        u32             ep_id           = -1;
-        struct kmx_host *host           = NULL;
-
-        if (line == NULL) return -1;
-
-        len = strlen(line);
-
-        if (len == 0) return -1;
-
-        /* convert tabs to spaces */
-        for (i = 0; i < len; i++) {
-                if (line[i] == '\t') line[i] = ' ';
-        }
-
-        memset(&hostname, 0 , sizeof(hostname));
-        ret = sscanf(line, "%d.%d.%d.%d %" str(MX_MAX_HOSTNAME_LEN) "s %d %d", 
-                     &ip[0], &ip[1], &ip[2], &ip[3], hostname, &board, &ep_id);
-
-        if (ret != 7) {
-                return -1;
-        }
-
-        /* check for valid values */
-        /* we assume a valid IP address (all <= 255), number of NICs,
-         * and number of endpoint IDs */
-        if (ip[0] > 255 || ip [1] > 255 || ip[2] > 255 || ip[3] > 255 ||
-            board > MXLND_MAX_BOARD || ep_id > MXLND_MAX_EP_ID) {
-                CDEBUG(D_NETERROR, "Illegal value in \"%s\". Ignoring "
-                                   "this host.\n", line);
-                return -1;
-        }
-
-        ret = mxlnd_host_alloc(&host);
-        if (ret != 0) return -1;
-
-        host->mxh_addr = ((ip[0]<<24)|(ip[1]<<16)|(ip[2]<<8)|ip[3]);
-        len = strlen(hostname);
-        MXLND_ALLOC(host->mxh_hostname, len + 1);
-        if (host->mxh_hostname == NULL) {
-                mxlnd_host_free(host);
-                return -ENOMEM;
-        }
-        memset(host->mxh_hostname, 0, len + 1);
-        strncpy(host->mxh_hostname, hostname, len);
-        host->mxh_board = board;
-        host->mxh_ep_id = ep_id;
-
-        spin_lock(&kmxlnd_data.kmx_hosts_lock);
-        list_add_tail(&host->mxh_list, &kmxlnd_data.kmx_hosts);
-        spin_unlock(&kmxlnd_data.kmx_hosts_lock);
-
-        return 0;
-}
-
-void
-mxlnd_print_hosts(void)
-{
-#if MXLND_DEBUG
-        struct kmx_host         *host   = NULL;
-
-        list_for_each_entry(host, &kmxlnd_data.kmx_hosts, mxh_list) {
-                int             ip[4];
-                u32             addr    = host->mxh_addr;
-
-                ip[0] = (addr >> 24) & 0xff;
-                ip[1] = (addr >> 16) & 0xff;
-                ip[2] = (addr >>  8) & 0xff;
-                ip[3] = addr & 0xff;
-                CDEBUG(D_NET, "\tip= %d.%d.%d.%d\n\thost= %s\n\tboard= %d\n\tep_id= %d\n\n",
-                            ip[0], ip[1], ip[2], ip[3],
-                            host->mxh_hostname, host->mxh_board, host->mxh_ep_id);
-        }
-#endif
-        return;
-}
-
-#define MXLND_BUFSIZE (PAGE_SIZE - 1)
-
-int
-mxlnd_parse_hosts(char *filename)
-{
-        int             ret             = 0;
-        s32             size            = 0;
-        s32             bufsize         = MXLND_BUFSIZE;
-        s32             allocd          = 0;
-        loff_t          offset          = 0;
-        struct file     *filp           = NULL;
-        struct inode    *inode          = NULL;
-        char            *buf            = NULL;
-        s32             buf_off         = 0;
-        char            *sep            = NULL;
-        char            *line           = NULL;
-
-        if (filename == NULL) return -1;
-
-        filp = filp_open(filename, O_RDONLY, 0);
-        if (IS_ERR(filp)) {
-                CERROR("filp_open() failed for %s\n", filename);
-                return -1;
-        }
-
-        inode = filp->f_dentry->d_inode;
-        if (!S_ISREG(inode->i_mode)) {
-                CERROR("%s is not a regular file\n", filename);
-                return -1;
-        }
-
-        size = (s32) inode->i_size;
-        if (size < MXLND_BUFSIZE) bufsize = size;
-        allocd = bufsize;
-        MXLND_ALLOC(buf, allocd + 1);
-        if (buf == NULL) {
-                CERROR("Cannot allocate buf\n");
-                filp_close(filp, current->files);
-                return -1;
-        }
-
-        while (offset < size) {
-                memset(buf, 0, bufsize + 1);
-                ret = kernel_read(filp, (unsigned long) offset, buf, (unsigned long) bufsize);
-                if (ret < 0) {
-                        CDEBUG(D_NETERROR, "kernel_read() returned %d - closing %s\n", ret, filename);
-                        filp_close(filp, current->files);
-                        MXLND_FREE(buf, allocd + 1);
-                        return -1;
-                }
-
-                if (ret < bufsize) bufsize = ret;
-                buf_off = 0;
-                while (buf_off < bufsize) {
-                        sep = strchr(buf + buf_off, '\n');
-                        if (sep != NULL) {
-                                /* we have a line */
-                                line = buf + buf_off;
-                                *sep = '\0';
-                                ret = mxlnd_parse_line(line);
-                                if (ret != 0 && strlen(line) != 0) {
-                                        CDEBUG(D_NETERROR, "Failed to parse \"%s\". Ignoring this host.\n", line);
-                                }
-                                buf_off += strlen(line) + 1;
-                        } else {
-                                /* last line or we need to read more */
-                                line = buf + buf_off;
-                                ret = mxlnd_parse_line(line);
-                                if (ret != 0) {
-                                        bufsize -= strlen(line) + 1;
-                                }
-                                buf_off += strlen(line) + 1;
-                        }
-                }
-                offset += bufsize;
-                bufsize = MXLND_BUFSIZE;
-        }
-
-        MXLND_FREE(buf, allocd + 1);
-        filp_close(filp, current->files);
-        mxlnd_print_hosts();
-
-        return 0;
-}
-
-/**
- * mxlnd_init_mx - open the endpoint, set out ID, register the EAGER callback
+ * mxlnd_init_mx - open the endpoint, set our ID, register the EAGER callback
  * @ni - the network interface
  *
  * Returns 0 on success, -1 on failure
@@ -538,13 +304,17 @@ int
 mxlnd_init_mx(lnet_ni_t *ni)
 {
         int                     ret     = 0;
-        int                     found   = 0;
+        int                     hash    = 0;
         mx_return_t             mxret;
-        mx_endpoint_addr_t      addr;
+        mx_endpoint_addr_t      epa;
         u32                     board   = *kmxlnd_tunables.kmx_board;
         u32                     ep_id   = *kmxlnd_tunables.kmx_ep_id;
         u64                     nic_id  = 0LL;
-        struct kmx_host         *host   = NULL;
+        char                    *ifname = NULL;
+        __u32                   ip;
+        __u32                   netmask;
+        int                     up      = 0;
+        struct kmx_peer         *peer   = NULL;
 
         mxret = mx_init();
         if (mxret != MX_SUCCESS) {
@@ -552,50 +322,71 @@ mxlnd_init_mx(lnet_ni_t *ni)
                 return -1;
         }
 
-        ret = mxlnd_parse_hosts(*kmxlnd_tunables.kmx_hosts);
-        if (ret != 0) {
-                if (*kmxlnd_tunables.kmx_hosts != NULL) {
-                        CERROR("mxlnd_parse_hosts(%s) failed\n", *kmxlnd_tunables.kmx_hosts);
+        if (ni->ni_interfaces[0] != NULL) {
+                /* Use the IPoMX interface specified in 'networks=' */
+
+                CLASSERT (LNET_MAX_INTERFACES > 1);
+                if (ni->ni_interfaces[1] != NULL) {
+                        CERROR("Multiple interfaces not supported\n");
+                        goto failed_with_init;
                 }
-                mx_finalize();
-                return -1;
+
+                ifname = ni->ni_interfaces[0];
+        } else {
+                ifname = *kmxlnd_tunables.kmx_default_ipif;
         }
 
-        list_for_each_entry(host, &kmxlnd_data.kmx_hosts, mxh_list) {
-                if (strcmp(host->mxh_hostname, system_utsname.nodename) == 0) {
-                        /* override the defaults and module parameters with 
-                         * the info from the hosts file */
-                        board = host->mxh_board;
-                        ep_id = host->mxh_ep_id;
-                        kmxlnd_data.kmx_localhost = host;
-                        CDEBUG(D_NET, "my hostname is %s board %d ep_id %d\n", kmxlnd_data.kmx_localhost->mxh_hostname, kmxlnd_data.kmx_localhost->mxh_board, kmxlnd_data.kmx_localhost->mxh_ep_id);
-                        found = 1;
-                        break;
-                }
+        ret = libcfs_ipif_query(ifname, &up, &ip, &netmask);
+        if (ret != 0) {
+                CERROR("Can't query IPoMX interface %s: %d\n",
+                       ifname, ret);
+                goto failed_with_init;
         }
 
-        if (found == 0) {
-                CERROR("no host entry found for localhost\n");
-                mx_finalize();
-                return -1;
+        if (!up) {
+                CERROR("Can't query IPoMX interface %s: it's down\n",
+                       ifname);
+                goto failed_with_init;
         }
 
-        mxret = mx_open_endpoint(board, ep_id, MXLND_MSG_MAGIC, 
+        mxret = mx_open_endpoint(board, ep_id, MXLND_MSG_MAGIC,
                                  NULL, 0, &kmxlnd_data.kmx_endpt);
         if (mxret != MX_SUCCESS) {
                 CERROR("mx_open_endpoint() failed with %d\n", mxret);
-                mx_finalize();
-                return -1;
+                goto failed_with_init;
         }
 
-        mx_get_endpoint_addr(kmxlnd_data.kmx_endpt, &addr);
-        mx_decompose_endpoint_addr(addr, &nic_id, &ep_id);
-
-        LASSERT(host != NULL);
-        ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid), host->mxh_addr);
+        mx_get_endpoint_addr(kmxlnd_data.kmx_endpt, &epa);
+        mx_decompose_endpoint_addr(epa, &nic_id, &ep_id);
 
+        ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid), ip);
         CDEBUG(D_NET, "My NID is 0x%llx\n", ni->ni_nid);
 
+        ret = mxlnd_peer_alloc(&peer, ni->ni_nid, board, ep_id, nic_id);
+        if (ret != 0) {
+                goto failed_with_endpoint;
+        }
+        peer->mxp_conn->mxk_epa = epa;
+
+        peer->mxp_incarnation = kmxlnd_data.kmx_incarnation;
+        peer->mxp_incompatible = 0;
+        spin_lock(&peer->mxp_conn->mxk_lock);
+        peer->mxp_conn->mxk_credits = *kmxlnd_tunables.kmx_credits;
+        peer->mxp_conn->mxk_outstanding = 0;
+        peer->mxp_conn->mxk_incarnation = kmxlnd_data.kmx_incarnation;
+        peer->mxp_conn->mxk_timeout = 0;
+        peer->mxp_conn->mxk_status = MXLND_CONN_READY;
+        spin_unlock(&peer->mxp_conn->mxk_lock);
+        mx_set_endpoint_addr_context(peer->mxp_conn->mxk_epa, (void *) peer);
+
+        hash = mxlnd_nid_to_hash(ni->ni_nid);
+        list_add_tail(&peer->mxp_peers, &kmxlnd_data.kmx_peers[hash]);
+        atomic_inc(&kmxlnd_data.kmx_npeers);
+
+        mxlnd_conn_decref(peer->mxp_conn); /* drop 2nd ref taken in peer_alloc */
+
+        kmxlnd_data.kmx_localhost = peer;
+
         /* this will catch all unexpected receives. */
         mxret = mx_register_unexp_handler(kmxlnd_data.kmx_endpt,
                                           (mx_unexp_handler_t) mxlnd_unexpected_recv,
@@ -603,19 +394,25 @@ mxlnd_init_mx(lnet_ni_t *ni)
         if (mxret != MX_SUCCESS) {
                 CERROR("mx_register_unexp_callback() failed with %s\n", 
                          mx_strerror(mxret));
-                mx_close_endpoint(kmxlnd_data.kmx_endpt);
-                mx_finalize();
-                return -1;
+                goto failed_with_peer;
         }
         mxret = mx_set_request_timeout(kmxlnd_data.kmx_endpt, NULL, MXLND_COMM_TIMEOUT/HZ*1000);
         if (mxret != MX_SUCCESS) {
                 CERROR("mx_set_request_timeout() failed with %s\n", 
                         mx_strerror(mxret));
-                mx_close_endpoint(kmxlnd_data.kmx_endpt);
-                mx_finalize();
-                return -1;
+                goto failed_with_peer;
         }
         return 0;
+
+failed_with_peer:
+        mxlnd_conn_decref(peer->mxp_conn);
+        mxlnd_conn_decref(peer->mxp_conn);
+        mxlnd_peer_decref(peer);
+failed_with_endpoint:
+        mx_close_endpoint(kmxlnd_data.kmx_endpt);
+failed_with_init:
+        mx_finalize();
+        return -1;
 }
 
 
@@ -689,6 +486,10 @@ mxlnd_shutdown (lnet_ni_t *ni)
                 up(&kmxlnd_data.kmx_tx_queue_sem);
                 mxlnd_sleep(2 * HZ);
 
+                read_lock(&kmxlnd_data.kmx_global_lock);
+                mxlnd_close_matching_conns(LNET_NID_ANY);
+                read_unlock(&kmxlnd_data.kmx_global_lock);
+
                 /* fall through */
 
         case MXLND_INIT_THREADS:
@@ -718,9 +519,6 @@ mxlnd_shutdown (lnet_ni_t *ni)
                 mx_close_endpoint(kmxlnd_data.kmx_endpt);
                 mx_finalize();
 
-                CDEBUG(D_NET, "mxlnd_free_hosts();\n");
-                mxlnd_free_hosts();
-
                 /* fall through */
 
         case MXLND_INIT_RXS:
@@ -805,19 +603,17 @@ mxlnd_startup (lnet_ni_t *ni)
         kmxlnd_data.kmx_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec;
         CDEBUG(D_NET, "my incarnation is %lld\n", kmxlnd_data.kmx_incarnation);
 
-        spin_lock_init (&kmxlnd_data.kmx_global_lock);
+        rwlock_init (&kmxlnd_data.kmx_global_lock);
+        spin_lock_init (&kmxlnd_data.kmx_mem_lock);
 
         INIT_LIST_HEAD (&kmxlnd_data.kmx_conn_req);
         spin_lock_init (&kmxlnd_data.kmx_conn_lock);
         sema_init(&kmxlnd_data.kmx_conn_sem, 0);
 
-        INIT_LIST_HEAD (&kmxlnd_data.kmx_hosts);
-        spin_lock_init (&kmxlnd_data.kmx_hosts_lock);
-
         for (i = 0; i < MXLND_HASH_SIZE; i++) {
                 INIT_LIST_HEAD (&kmxlnd_data.kmx_peers[i]);
         }
-        rwlock_init (&kmxlnd_data.kmx_peers_lock);
+        //rwlock_init (&kmxlnd_data.kmx_peers_lock);
 
         INIT_LIST_HEAD (&kmxlnd_data.kmx_txs);
         INIT_LIST_HEAD (&kmxlnd_data.kmx_tx_idle);
@@ -953,4 +749,4 @@ module_exit(mxlnd_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Myricom, Inc. - help at myri.com");
 MODULE_DESCRIPTION("Kernel MyrinetExpress LND");
-MODULE_VERSION("0.5.0");
+MODULE_VERSION("0.6.0");
diff --git a/lnet/klnds/mxlnd/mxlnd.h b/lnet/klnds/mxlnd/mxlnd.h
index 68d1542..bc629d5 100644
--- a/lnet/klnds/mxlnd/mxlnd.h
+++ b/lnet/klnds/mxlnd/mxlnd.h
@@ -71,14 +71,16 @@
 #include <linux/sysctl.h>
 #include <linux/random.h>
 #include <linux/utsname.h>
+#include <linux/jiffies.h>      /* msecs_to_jiffies */
 
 #include <net/sock.h>
 #include <linux/in.h>
 
-#include <linux/netdevice.h>    /* these are needed for ARP */
-#include <linux/if_arp.h>
-#include <net/arp.h>
-#include <linux/inetdevice.h>
+#include <asm/byteorder.h>      /* __LITTLE_ENDIAN */
+#include <net/arp.h>            /* arp table */
+#include <linux/netdevice.h>    /* get_device_by_name */
+#include <linux/inetdevice.h>   /* neigh_lookup, etc. */
+#include <linux/net.h>          /* sock_create_kern, kernel_connect, sock_release */
 
 #define DEBUG_SUBSYSTEM S_LND
 
@@ -95,6 +97,9 @@
     #error LNET_MAX_IOV is greater then MX_MAX_SEGMENTS
 #endif
 
+#define MXLND_MSG_MAGIC         0x4d583130              /* unique magic 'MX10' */
+#define MXLND_MSG_VERSION       0x02
+
 /* Using MX's 64 match bits
  * We are using the match bits to specify message type and the cookie.  The
  * highest four bits (60-63) are reserved for message type. Below we specify
@@ -105,21 +110,33 @@
  * should allow unique cookies for 4 KB messages at 10 Gbps line rate without
  * rollover for about 8 years. That should be enough. */
 
-/* constants */
-#define MXLND_MASK_ICON_REQ (0xBLL << 60) /* it is a mx_iconnect() completion */
-#define MXLND_MASK_CONN_REQ (0xCLL << 60) /* CONN_REQ msg */
-#define MXLND_MASK_ICON_ACK (0x9LL << 60) /* it is a mx_iconnect() completion */
-#define MXLND_MASK_CONN_ACK (0xALL << 60) /* CONN_ACK msg*/
-#define MXLND_MASK_EAGER    (0xELL << 60) /* EAGER msg */
-#define MXLND_MASK_NOOP     (0x1LL << 60) /* NOOP msg */
-#define MXLND_MASK_PUT_REQ  (0x2LL << 60) /* PUT_REQ msg */
-#define MXLND_MASK_PUT_ACK  (0x3LL << 60) /* PUT_ACK msg */
-#define MXLND_MASK_PUT_DATA (0x4LL << 60) /* PUT_DATA msg */
-#define MXLND_MASK_GET_REQ  (0x5LL << 60) /* GET_REQ msg */
-#define MXLND_MASK_GET_DATA (0x6LL << 60) /* GET_DATA msg */
-//#define MXLND_MASK_NAK      (0x7LL << 60) /* NAK msg */
-
-#define MXLND_MAX_COOKIE    ((1LL << 52) - 1)         /* when to roll-over the cookie value */
+#define MXLND_MSG_OFFSET        60      /* msg type offset */
+#define MXLND_MSG_BITS          (64 - MXLND_MSG_OFFSET)
+#define MXLND_MSG_MASK          (((1ULL<<MXLND_MSG_BITS) - 1) << MXLND_MSG_OFFSET)
+#define MXLND_MSG_TYPE(x)       (((x) & MXLND_MSG_MASK) >> MXLND_MSG_OFFSET)
+
+#define MXLND_ERROR_OFFSET      52      /* error value offset */
+#define MXLND_ERROR_BITS        (MXLND_MSG_OFFSET - MXLND_ERROR_OFFSET)
+#define MXLND_ERROR_MASK        (((1ULL<<MXLND_ERROR_BITS) - 1) << MXLND_ERROR_OFFSET)
+#define MXLND_ERROR_VAL(x)      (((x) & MXLND_ERROR_MASK) >> MXLND_ERROR_OFFSET)
+
+/* message types */
+#define MXLND_MSG_ICON_REQ      0xb     /* mx_iconnect() before CONN_REQ */
+#define MXLND_MSG_CONN_REQ      0xc     /* connection request */
+#define MXLND_MSG_ICON_ACK      0x9     /* mx_iconnect() before CONN_ACK */
+#define MXLND_MSG_CONN_ACK      0xa     /* connection request response */
+#define MXLND_MSG_BYE           0xd     /* disconnect msg */
+#define MXLND_MSG_EAGER         0xe     /* eager message */
+#define MXLND_MSG_NOOP          0x1     /* no msg, return credits */
+#define MXLND_MSG_PUT_REQ       0x2     /* put request src->sink */
+#define MXLND_MSG_PUT_ACK       0x3     /* put ack     src<-sink */
+#define MXLND_MSG_PUT_DATA      0x4     /* put payload src->sink */
+#define MXLND_MSG_GET_REQ       0x5     /* get request sink->src */
+#define MXLND_MSG_GET_DATA      0x6     /* get payload sink<-src */
+
+/* when to roll-over the cookie value */
+#define MXLND_MAX_COOKIE    ((1ULL << MXLND_ERROR_OFFSET) - 1)
+
 #define MXLND_NCOMPLETIONS  (MXLND_N_SCHED + 2)   /* max threads for completion array */
 
 /* defaults for configurable parameters */
@@ -148,36 +165,29 @@
 
 /* debugging features */
 #define MXLND_CKSUM             0               /* checksum kmx_msg_t */
-#define MXLND_DEBUG             0               /* turn on printk()s */
-
-extern inline void mxlnd_noop(char *s, ...);
-#if MXLND_DEBUG
-        #define MXLND_PRINT printk
-#else
-        #define MXLND_PRINT mxlnd_noop
-#endif
+#define MXLND_DEBUG             0               /* additional CDEBUG messages */
 
 /* provide wrappers around LIBCFS_ALLOC/FREE to keep MXLND specific
  * memory usage stats that include pages */
 
 #define MXLND_ALLOC(x, size) \
         do { \
-                spin_lock(&kmxlnd_data.kmx_global_lock); \
+                spin_lock(&kmxlnd_data.kmx_mem_lock); \
                 kmxlnd_data.kmx_mem_used += size; \
-                spin_unlock(&kmxlnd_data.kmx_global_lock); \
+                spin_unlock(&kmxlnd_data.kmx_mem_lock); \
                 LIBCFS_ALLOC(x, size); \
-                if (x == NULL) { \
-                        spin_lock(&kmxlnd_data.kmx_global_lock); \
+                if (unlikely(x == NULL)) { \
+                        spin_lock(&kmxlnd_data.kmx_mem_lock); \
                         kmxlnd_data.kmx_mem_used -= size; \
-                        spin_unlock(&kmxlnd_data.kmx_global_lock); \
+                        spin_unlock(&kmxlnd_data.kmx_mem_lock); \
                 } \
         } while (0)
 
 #define MXLND_FREE(x, size) \
         do { \
-                spin_lock(&kmxlnd_data.kmx_global_lock); \
+                spin_lock(&kmxlnd_data.kmx_mem_lock); \
                 kmxlnd_data.kmx_mem_used -= size; \
-                spin_unlock(&kmxlnd_data.kmx_global_lock); \
+                spin_unlock(&kmxlnd_data.kmx_mem_lock); \
                 LIBCFS_FREE(x, size); \
         } while (0)
 
@@ -190,22 +200,11 @@ typedef struct kmx_tunables {
         int     *kmx_credits;           /* concurrent sends to 1 peer */
         int     *kmx_board;             /* MX board (NIC) number */
         int     *kmx_ep_id;             /* MX endpoint number */
+        char    **kmx_default_ipif;     /* IPoMX interface name */
         int     *kmx_polling;           /* if 0, block. if > 0, poll this many
                                            iterations before blocking */
-        char    **kmx_hosts;            /* Location of hosts file, if used */
 } kmx_tunables_t;
 
-/* structure to hold IP-to-hostname resolution data */
-struct kmx_host {
-        struct kmx_peer    *mxh_peer;           /* pointer to matching peer */
-        u32                 mxh_addr;           /* IP address as int */
-        char               *mxh_hostname;       /* peer's hostname */
-        u32                 mxh_board;          /* peer's board rank */
-        u32                 mxh_ep_id;          /* peer's MX endpoint ID */
-        struct list_head    mxh_list;           /* position on kmx_hosts */
-        spinlock_t          mxh_lock;           /* lock */
-};
-
 /* global interface state */
 typedef struct kmx_data
 {
@@ -216,21 +215,19 @@ typedef struct kmx_data
         lnet_ni_t          *kmx_ni;             /* the LND instance */
         u64                 kmx_incarnation;    /* my incarnation value - unused */
         long                kmx_mem_used;       /* memory used */
-        struct kmx_host    *kmx_localhost;      /* pointer to my kmx_host info */
+        struct kmx_peer    *kmx_localhost;      /* pointer to my kmx_peer info */
         mx_endpoint_t       kmx_endpt;          /* the MX endpoint */
 
-        spinlock_t          kmx_global_lock;    /* global lock */
+        rwlock_t            kmx_global_lock;    /* global lock */
+        spinlock_t          kmx_mem_lock;       /* memory accounting lock */
 
         struct list_head    kmx_conn_req;       /* list of connection requests */
         spinlock_t          kmx_conn_lock;      /* connection list lock */
         struct semaphore    kmx_conn_sem;       /* semaphore for connection request list */
 
-        struct list_head    kmx_hosts;          /* host lookup info */
-        spinlock_t          kmx_hosts_lock;     /* hosts list lock */
-
         struct list_head    kmx_peers[MXLND_HASH_SIZE];
                                                 /* list of all known peers */
-        rwlock_t            kmx_peers_lock;     /* peer list rw lock */
+        //rwlock_t            kmx_peers_lock;     /* peer list rw lock */
         atomic_t            kmx_npeers;         /* number of peers */
 
         struct list_head    kmx_txs;            /* all tx descriptors */
@@ -256,7 +253,67 @@ typedef struct kmx_data
 #define MXLND_INIT_THREADS      5       /* waitd, timeoutd, tx_queued threads */
 #define MXLND_INIT_ALL          6       /* startup completed */
 
-#include "mxlnd_wire.h"
+/************************************************************************
+ * MXLND Wire message format.
+ * These are sent in sender's byte order (i.e. receiver flips).
+ */
+
+typedef struct kmx_connreq_msg
+{
+        u32             mxcrm_queue_depth;              /* per peer max messages in flight */
+        u32             mxcrm_eager_size;               /* size of preposted eager messages */
+} WIRE_ATTR kmx_connreq_msg_t;
+
+typedef struct kmx_eager_msg
+{
+        lnet_hdr_t      mxem_hdr;                       /* lnet header */
+        char            mxem_payload[0];                /* piggy-backed payload */
+} WIRE_ATTR kmx_eager_msg_t;
+
+typedef struct kmx_putreq_msg
+{
+        lnet_hdr_t      mxprm_hdr;                      /* lnet header */
+        u64             mxprm_cookie;                   /* opaque completion cookie */
+} WIRE_ATTR kmx_putreq_msg_t;
+
+typedef struct kmx_putack_msg
+{
+        u64             mxpam_src_cookie;               /* reflected completion cookie */
+        u64             mxpam_dst_cookie;               /* opaque completion cookie */
+} WIRE_ATTR kmx_putack_msg_t;
+
+typedef struct kmx_getreq_msg
+{
+        lnet_hdr_t      mxgrm_hdr;                      /* lnet header */
+        u64             mxgrm_cookie;                   /* opaque completion cookie */
+} WIRE_ATTR kmx_getreq_msg_t;
+
+typedef struct kmx_msg
+{
+        /* First two fields fixed for all time */
+        u32             mxm_magic;                      /* MXLND message */
+        u16             mxm_version;                    /* version number */
+
+        u8              mxm_type;                       /* message type */
+        u8              mxm_credits;                    /* returned credits */
+        u32             mxm_nob;                        /* # of bytes in whole message */
+        u32             mxm_cksum;                      /* checksum (0 == no checksum) */
+        u64             mxm_srcnid;                     /* sender's NID */
+        u64             mxm_srcstamp;                   /* sender's incarnation */
+        u64             mxm_dstnid;                     /* destination's NID */
+        u64             mxm_dststamp;                   /* destination's incarnation */
+        u64             mxm_seq;                        /* sequence number */
+
+        union {
+                kmx_connreq_msg_t       conn_req;
+                kmx_eager_msg_t         eager;
+                kmx_putreq_msg_t        put_req;
+                kmx_putack_msg_t        put_ack;
+                kmx_getreq_msg_t        get_req;
+        } WIRE_ATTR mxm_u;
+} WIRE_ATTR kmx_msg_t;
+
+/***********************************************************************/
 
 enum kmx_req_type {
         MXLND_REQ_TX    = 0,
@@ -356,13 +413,15 @@ struct kmx_peer
 {
         lnet_nid_t          mxp_nid;            /* peer's LNET NID */
         u64                 mxp_incarnation;    /* peer's incarnation value */
+        u32                 mxp_sid;            /* MX session ID */
         atomic_t            mxp_refcount;       /* reference counts */
 
-        struct kmx_host    *mxp_host;           /* peer lookup info */
+        u32                 mxp_ip;             /* IP address as int */
+        u32                 mxp_board;          /* peer's board rank */
+        u32                 mxp_ep_id;          /* peer's MX endpoint ID */
         u64                 mxp_nic_id;         /* remote's MX nic_id for mx_connect() */
 
         struct list_head    mxp_peers;          /* for placing on kmx_peers */
-        spinlock_t          mxp_lock;           /* lock */
 
         struct list_head    mxp_conns;          /* list of connections */
         struct kmx_conn    *mxp_conn;           /* current connection */
@@ -388,8 +447,8 @@ extern void mxlnd_thread_stop(long id);
 extern int  mxlnd_ctx_alloc(struct kmx_ctx **ctxp, enum kmx_req_type type);
 extern void mxlnd_ctx_free(struct kmx_ctx *ctx);
 extern void mxlnd_ctx_init(struct kmx_ctx *ctx);
-extern lnet_nid_t mxlnd_nic_id2nid(lnet_ni_t *ni, u64 nic_id);
-extern u64 mxlnd_nid2nic_id(lnet_nid_t nid);
+extern int  mxlnd_peer_alloc(struct kmx_peer **peerp, lnet_nid_t nid,
+                u32 board, u32 ep_id, u64 nic_id);
 
 /* in mxlnd_cb.c */
 void mxlnd_eager_recv(void *context, uint64_t match_value, uint32_t length);
@@ -398,6 +457,8 @@ extern mx_unexp_handler_action_t mxlnd_unexpected_recv(void *context,
                 void *data_if_available);
 extern void mxlnd_peer_free(struct kmx_peer *peer);
 extern void mxlnd_conn_free(struct kmx_conn *conn);
+extern void mxlnd_conn_disconnect(struct kmx_conn *conn, int mx_dis, int send_bye);
+extern int mxlnd_close_matching_conns(lnet_nid_t nid);
 extern void mxlnd_sleep(unsigned long timeout);
 extern int  mxlnd_tx_queued(void *arg);
 extern void mxlnd_handle_rx_completion(struct kmx_ctx *rx);
@@ -408,6 +469,20 @@ extern int  mxlnd_unex_recvd(void *arg);
 extern int  mxlnd_timeoutd(void *arg);
 extern int  mxlnd_connd(void *arg);
 
+/**
+ * mxlnd_nid_to_hash - hash the nid
+ * @nid - LNET ID
+ *
+ * Takes the u64 nid and XORs the lowest N bits by the next lowest N bits.
+ */
+static inline int
+mxlnd_nid_to_hash(lnet_nid_t nid)
+{
+        return (nid & MXLND_HASH_MASK) ^
+               ((nid & (MXLND_HASH_MASK << MXLND_HASH_BITS)) >> MXLND_HASH_BITS);
+}
+
+
 #define mxlnd_peer_addref(peer)                                 \
 do {                                                            \
         LASSERT(peer != NULL);                                  \
diff --git a/lnet/klnds/mxlnd/mxlnd_cb.c b/lnet/klnds/mxlnd/mxlnd_cb.c
index ebd53cb..a973e96 100644
--- a/lnet/klnds/mxlnd/mxlnd_cb.c
+++ b/lnet/klnds/mxlnd/mxlnd_cb.c
@@ -43,6 +43,15 @@
 
 #include "mxlnd.h"
 
+mx_endpoint_addr_t MX_EPA_NULL; /* use to determine if an endpoint is NULL */
+
+inline int
+mxlnd_endpoint_addr_null(mx_endpoint_addr_t epa)
+{
+        /* if memcmp() == 0, it is NULL */
+        return !(memcmp(&epa, &MX_EPA_NULL, sizeof(epa)));
+}
+
 inline void mxlnd_noop(char *s, ...)
 {
         return;
@@ -101,6 +110,8 @@ mxlnd_msgtype_to_str(int type) {
                 return "MXLND_MSG_CONN_REQ";
         case MXLND_MSG_CONN_ACK:
                 return "MXLND_MSG_CONN_ACK";
+        case MXLND_MSG_BYE:
+                return "MXLND_MSG_BYE";
         case MXLND_MSG_NOOP:
                 return "MXLND_MSG_NOOP";
         case MXLND_MSG_PUT_REQ:
@@ -144,25 +155,26 @@ mxlnd_create_match(struct kmx_ctx *ctx, u8 error)
 {
         u64 type        = (u64) ctx->mxc_msg_type;
         u64 err         = (u64) error;
-        u64 match       = 0LL;
+        u64 match       = 0ULL;
 
         LASSERT(ctx->mxc_msg_type != 0);
-        LASSERT(ctx->mxc_cookie >> 52 == 0);
-        match = (type << 60) | (err << 52) | ctx->mxc_cookie;
+        LASSERT(ctx->mxc_cookie >> MXLND_ERROR_OFFSET == 0);
+        match = (type << MXLND_MSG_OFFSET) | (err << MXLND_ERROR_OFFSET) | ctx->mxc_cookie;
         return match;
 }
 
 static inline void
 mxlnd_parse_match(u64 match, u8 *msg_type, u8 *error, u64 *cookie)
 {
-        *msg_type = (u8) (match >> 60);
-        *error    = (u8) ((match >> 52) & 0xFF);
-        *cookie   = match & 0xFFFFFFFFFFFFFLL;
-        LASSERT(match == (MXLND_MASK_ICON_REQ & 0xF000000000000000LL) ||
-                match == (MXLND_MASK_ICON_ACK & 0xF000000000000000LL) ||
-                *msg_type == MXLND_MSG_EAGER    ||
+        *msg_type = (u8) MXLND_MSG_TYPE(match);
+        *error    = (u8) MXLND_ERROR_VAL(match);
+        *cookie   = match & MXLND_MAX_COOKIE;
+        LASSERT(*msg_type == MXLND_MSG_EAGER    ||
+                *msg_type == MXLND_MSG_ICON_REQ ||
                 *msg_type == MXLND_MSG_CONN_REQ ||
+                *msg_type == MXLND_MSG_ICON_ACK ||
                 *msg_type == MXLND_MSG_CONN_ACK ||
+                *msg_type == MXLND_MSG_BYE      ||
                 *msg_type == MXLND_MSG_NOOP     ||
                 *msg_type == MXLND_MSG_PUT_REQ  ||
                 *msg_type == MXLND_MSG_PUT_ACK  ||
@@ -296,6 +308,9 @@ mxlnd_get_idle_tx(void)
         return tx;
 }
 
+void
+mxlnd_conn_disconnect(struct kmx_conn *conn, int mx_dis, int send_bye);
+
 int
 mxlnd_put_idle_tx(struct kmx_ctx *tx)
 {
@@ -311,8 +326,12 @@ mxlnd_put_idle_tx(struct kmx_ctx *tx)
                 return -EINVAL;
         }
         if (!(tx->mxc_status.code == MX_STATUS_SUCCESS ||
-              tx->mxc_status.code == MX_STATUS_TRUNCATED))
+              tx->mxc_status.code == MX_STATUS_TRUNCATED)) {
+                struct kmx_conn *conn   = tx->mxc_conn;
+
                 result = -EIO;
+                mxlnd_conn_disconnect(conn, 0, 1);
+        }
 
         lntmsg[0] = tx->mxc_lntmsg[0];
         lntmsg[1] = tx->mxc_lntmsg[1];
@@ -346,16 +365,13 @@ mxlnd_conn_free(struct kmx_conn *conn)
                  list_empty (&conn->mxk_tx_free_queue) &&
                  list_empty (&conn->mxk_pending));
         if (!list_empty(&conn->mxk_list)) {
-                spin_lock(&peer->mxp_lock);
                 list_del_init(&conn->mxk_list);
                 if (peer->mxp_conn == conn) {
                         peer->mxp_conn = NULL;
-                        if (!(conn->mxk_epa.stuff[0] == 0 && conn->mxk_epa.stuff[1] == 0)) {
+                        if (!mxlnd_endpoint_addr_null(conn->mxk_epa))
                                 mx_set_endpoint_addr_context(conn->mxk_epa,
                                                              (void *) NULL);
-                        }
                 }
-                spin_unlock(&peer->mxp_lock);
         }
         mxlnd_peer_decref(conn->mxk_peer); /* drop conn's ref to peer */
         MXLND_FREE (conn, sizeof (*conn));
@@ -409,15 +425,19 @@ mxlnd_conn_cancel_pending_rxs(struct kmx_conn *conn)
 /**
  * mxlnd_conn_disconnect - shutdown a connection
  * @conn - a kmx_conn pointer
+ * @mx_dis - call mx_disconnect()
+ * @send_bye - send peer a BYE msg
  *
  * This function sets the status to DISCONNECT, completes queued
  * txs with failure, calls mx_disconnect, which will complete
  * pending txs and matched rxs with failure.
  */
 void
-mxlnd_conn_disconnect(struct kmx_conn *conn, int mx_dis, int notify)
+mxlnd_conn_disconnect(struct kmx_conn *conn, int mx_dis, int send_bye)
 {
+        mx_endpoint_addr_t      epa     = conn->mxk_epa;
         struct list_head        *tmp    = NULL;
+        int                     valid   = !mxlnd_endpoint_addr_null(epa);
 
         spin_lock(&conn->mxk_lock);
         if (conn->mxk_status == MXLND_CONN_DISCONNECT) {
@@ -452,24 +472,33 @@ mxlnd_conn_disconnect(struct kmx_conn *conn, int mx_dis, int notify)
         /* cancel pending rxs */
         mxlnd_conn_cancel_pending_rxs(conn);
 
+        if (send_bye && valid) {
+                u64 match = ((u64) MXLND_MSG_BYE) << MXLND_MSG_OFFSET;
+                /* send a BYE to the peer */
+                CDEBUG(D_NET, "%s: sending a BYE msg to %s\n", __func__,
+                                libcfs_nid2str(conn->mxk_peer->mxp_nid));
+                mx_kisend(kmxlnd_data.kmx_endpt, NULL, 0, MX_PIN_PHYSICAL,
+                                epa, match, NULL, NULL);
+                /* wait to allow the peer to ack our message */
+                mxlnd_sleep(msecs_to_jiffies(20));
+        }
+
         if (kmxlnd_data.kmx_shutdown != 1) {
+                time_t          last_alive      = 0;
+                unsigned long   last_msg        = 0;
 
-                if (mx_dis) mx_disconnect(kmxlnd_data.kmx_endpt, conn->mxk_epa);
+                /* notify LNET that we are giving up on this peer */
+                if (time_after(conn->mxk_last_rx, conn->mxk_last_tx))
+                        last_msg = conn->mxk_last_rx;
+                else
+                        last_msg = conn->mxk_last_tx;
 
-                if (notify) {
-                        time_t          last_alive      = 0;
-                        unsigned long   last_msg        = 0;
+                last_alive = cfs_time_current_sec() -
+                             cfs_duration_sec(cfs_time_current() - last_msg);
+                lnet_notify(kmxlnd_data.kmx_ni, conn->mxk_peer->mxp_nid, 0, last_alive);
 
-                        /* notify LNET that we are giving up on this peer */
-                        if (time_after(conn->mxk_last_rx, conn->mxk_last_tx)) {
-                                last_msg = conn->mxk_last_rx;
-                        } else {
-                                last_msg = conn->mxk_last_tx;
-                        }
-                        last_alive = cfs_time_current_sec() -
-                                     cfs_duration_sec(cfs_time_current() - last_msg);
-                        lnet_notify(kmxlnd_data.kmx_ni, conn->mxk_peer->mxp_nid, 0, last_alive);
-                }
+                if (mx_dis && valid)
+                        mx_disconnect(kmxlnd_data.kmx_endpt, epa);
         }
         mxlnd_conn_decref(conn); /* drop the owning peer's reference */
 
@@ -534,9 +563,9 @@ int
 mxlnd_conn_alloc(struct kmx_conn **connp, struct kmx_peer *peer)
 {
         int ret = 0;
-        spin_lock(&peer->mxp_lock);
+        write_lock(&kmxlnd_data.kmx_global_lock);
         ret = mxlnd_conn_alloc_locked(connp, peer);
-        spin_unlock(&peer->mxp_lock);
+        write_unlock(&kmxlnd_data.kmx_global_lock);
         return ret;
 }
 
@@ -600,15 +629,14 @@ mxlnd_deq_pending_ctx(struct kmx_ctx *ctx)
 void
 mxlnd_peer_free(struct kmx_peer *peer)
 {
-        CDEBUG(D_NET, "freeing peer 0x%p\n", peer);
+        CDEBUG(D_NET, "freeing peer 0x%p %s\n", peer,
+                        peer == kmxlnd_data.kmx_localhost ? "(*** localhost ***)" : "");
 
         LASSERT (atomic_read(&peer->mxp_refcount) == 0);
 
-        if (peer->mxp_host != NULL) {
-                spin_lock(&peer->mxp_host->mxh_lock);
-                peer->mxp_host->mxh_peer = NULL;
-                spin_unlock(&peer->mxp_host->mxh_lock);
-        }
+        if (peer == kmxlnd_data.kmx_localhost)
+                LASSERT(kmxlnd_data.kmx_shutdown);
+
         if (!list_empty(&peer->mxp_peers)) {
                 /* assume we are locked */
                 list_del_init(&peer->mxp_peers);
@@ -619,31 +647,60 @@ mxlnd_peer_free(struct kmx_peer *peer)
         return;
 }
 
-void
-mxlnd_peer_hostname_to_nic_id(struct kmx_peer *peer)
+#define MXLND_LOOKUP_COUNT 10
+
+/* We only want the MAC address of the peer's Myricom NIC. We
+ * require that each node has the IPoMX interface (myriN) up.
+ * We will not pass any traffic over IPoMX, but it allows us
+ * to get the MAC address. */
+static int
+mxlnd_ip2nic_id(u32 ip, u64 *nic_id)
 {
-        u64             nic_id  = 0LL;
-        char            name[MX_MAX_HOSTNAME_LEN + 1];
-        mx_return_t     mxret   = MX_SUCCESS;
+        int                     ret     = 0;
+        int                     try     = 1;
+        int                     fatal   = 0;
+        u64                     tmp_id  = 0ULL;
+        unsigned char           *haddr  = NULL;
+        struct net_device       *dev    = NULL;
+        struct neighbour        *n      = NULL;
+        cfs_socket_t            *sock   = NULL;
+        __be32                  dst_ip  = htonl(ip);
 
-        memset(name, 0, sizeof(name));
-        snprintf(name, sizeof(name), "%s:%d", peer->mxp_host->mxh_hostname, peer->mxp_host->mxh_board);
-        mxret = mx_hostname_to_nic_id(name, &nic_id);
-        if (mxret == MX_SUCCESS) {
-                peer->mxp_nic_id = nic_id;
-        } else {
-                CDEBUG(D_NETERROR, "mx_hostname_to_nic_id() failed for %s "
-                                   "with %s\n", name, mx_strerror(mxret));
-                mxret = mx_hostname_to_nic_id(peer->mxp_host->mxh_hostname, &nic_id);
-                if (mxret == MX_SUCCESS) {
-                        peer->mxp_nic_id = nic_id;
-                } else {
-                        CDEBUG(D_NETERROR, "mx_hostname_to_nic_id() failed for %s "
-                                           "with %s\n", peer->mxp_host->mxh_hostname,
-                                           mx_strerror(mxret));
-                }
+        dev = dev_get_by_name(*kmxlnd_tunables.kmx_default_ipif);
+        if (dev == NULL) {
+                return -ENODEV;
         }
-        return;
+
+        haddr = (unsigned char *) &tmp_id + 2; /* MAC is only 6 bytes */
+
+        do {
+                n = neigh_lookup(&arp_tbl, &dst_ip, dev);
+                if (n) {
+                        n->used = jiffies;
+                        if (n->nud_state & NUD_VALID) {
+                                memcpy(haddr, n->ha, dev->addr_len);
+                                neigh_release(n);
+                                ret = 0;
+                                break;
+                        }
+                }
+                /* not found, try to connect (force an arp) */
+                libcfs_sock_connect(&sock, &fatal, 0, 0, ip, 987);
+                if (!fatal)
+                        libcfs_sock_release(sock);
+                schedule_timeout_interruptible(HZ/10 * try); /* add a little backoff */
+        } while (try++ < MXLND_LOOKUP_COUNT);
+
+        dev_put(dev);
+
+        if (tmp_id == 0ULL)
+                ret = -EHOSTUNREACH;
+#ifdef __LITTLE_ENDIAN
+        *nic_id = ___arch__swab64(tmp_id);
+#else
+        *nic_id = tmp_id;
+#endif
+        return ret;
 }
 
 /**
@@ -654,13 +711,12 @@ mxlnd_peer_hostname_to_nic_id(struct kmx_peer *peer)
  * Returns 0 on success and -ENOMEM on failure
  */
 int
-mxlnd_peer_alloc(struct kmx_peer **peerp, lnet_nid_t nid)
+mxlnd_peer_alloc(struct kmx_peer **peerp, lnet_nid_t nid, u32 board, u32 ep_id, u64 nic_id)
 {
         int                     i       = 0;
         int                     ret     = 0;
-        u32                     addr    = LNET_NIDADDR(nid);
+        u32                     ip      = LNET_NIDADDR(nid);
         struct kmx_peer        *peer    = NULL;
-        struct kmx_host        *host    = NULL;
 
         LASSERT (nid != LNET_NID_ANY && nid != 0LL);
 
@@ -673,28 +729,25 @@ mxlnd_peer_alloc(struct kmx_peer **peerp, lnet_nid_t nid)
 
         memset(peer, 0, sizeof(*peer));
 
-        list_for_each_entry(host, &kmxlnd_data.kmx_hosts, mxh_list) {
-                if (addr == host->mxh_addr) {
-                        peer->mxp_host = host;
-                        spin_lock(&host->mxh_lock);
-                        host->mxh_peer = peer;
-                        spin_unlock(&host->mxh_lock);
-                        break;
-                }
-        }
-        if (peer->mxp_host == NULL) {
-                CDEBUG(D_NETERROR, "unknown host for NID 0x%llx\n", nid);
-                MXLND_FREE(peer, sizeof(*peer));
-                return -ENXIO;
-        }
-
         peer->mxp_nid = nid;
         /* peer->mxp_incarnation */
         atomic_set(&peer->mxp_refcount, 1);     /* ref for kmx_peers list */
-        mxlnd_peer_hostname_to_nic_id(peer);
+
+        peer->mxp_ip = ip;
+        peer->mxp_ep_id = *kmxlnd_tunables.kmx_ep_id;
+        peer->mxp_board = board;
+        peer->mxp_nic_id = nic_id;
+
+        if (nic_id == 0ULL) {
+                ret = mxlnd_ip2nic_id(ip, &nic_id);
+                if (ret != 0)
+                        CERROR("%s: mxlnd_ip2nic_id() returned %d\n", __func__, ret);
+                mx_nic_id_to_board_number(nic_id, &peer->mxp_board);
+        }
+
+        peer->mxp_nic_id = nic_id; /* may be 0ULL if ip2nic_id() failed */
 
         INIT_LIST_HEAD(&peer->mxp_peers);
-        spin_lock_init(&peer->mxp_lock);
         INIT_LIST_HEAD(&peer->mxp_conns);
         ret = mxlnd_conn_alloc(&peer->mxp_conn, peer); /* adds 2nd conn ref here... */
         if (ret != 0) {
@@ -725,19 +778,6 @@ mxlnd_peer_alloc(struct kmx_peer **peerp, lnet_nid_t nid)
         return 0;
 }
 
-/**
- * mxlnd_nid_to_hash - hash the nid
- * @nid - msg pointer
- *
- * Takes the u64 nid and XORs the lowest N bits by the next lowest N bits.
- */
-static inline int
-mxlnd_nid_to_hash(lnet_nid_t nid)
-{
-        return (nid & MXLND_HASH_MASK) ^
-               ((nid & (MXLND_HASH_MASK << MXLND_HASH_BITS)) >> MXLND_HASH_BITS);
-}
-
 static inline struct kmx_peer *
 mxlnd_find_peer_by_nid_locked(lnet_nid_t nid)
 {
@@ -762,9 +802,9 @@ mxlnd_find_peer_by_nid(lnet_nid_t nid)
 {
         struct kmx_peer *peer   = NULL;
 
-        read_lock(&kmxlnd_data.kmx_peers_lock);
+        read_lock(&kmxlnd_data.kmx_global_lock);
         peer = mxlnd_find_peer_by_nid_locked(nid);
-        read_unlock(&kmxlnd_data.kmx_peers_lock);
+        read_unlock(&kmxlnd_data.kmx_global_lock);
         return peer;
 }
 
@@ -1017,7 +1057,7 @@ mxlnd_recv_msg(lnet_msg_t *lntmsg, struct kmx_ctx *rx, u8 msg_type, u64 cookie,
 {
         int             ret     = 0;
         mx_return_t     mxret   = MX_SUCCESS;
-        uint64_t        mask    = 0xF00FFFFFFFFFFFFFLL;
+        uint64_t        mask    = ~(MXLND_ERROR_MASK);
 
         rx->mxc_msg_type = msg_type;
         rx->mxc_lntmsg[0] = lntmsg; /* may be NULL if EAGER */
@@ -1035,7 +1075,7 @@ mxlnd_recv_msg(lnet_msg_t *lntmsg, struct kmx_ctx *rx, u8 msg_type, u64 cookie,
                           cookie, mask, (void *) rx, &rx->mxc_mxreq);
         if (mxret != MX_SUCCESS) {
                 mxlnd_deq_pending_ctx(rx);
-                CDEBUG(D_NETERROR, "mx_kirecv() failed with %s (%d)\n", 
+                CDEBUG(D_NETERROR, "mx_kirecv() failed with %s (%d)\n",
                                    mx_strerror(mxret), (int) mxret);
                 return -1;
         }
@@ -1048,7 +1088,7 @@ mxlnd_recv_msg(lnet_msg_t *lntmsg, struct kmx_ctx *rx, u8 msg_type, u64 cookie,
  *                         unexpected receives
  * @context - NULL, ignore
  * @source - the peer's mx_endpoint_addr_t
- * @match_value - the msg's bit, should be MXLND_MASK_EAGER
+ * @match_value - the msg's bit, should be MXLND_MSG_EAGER
  * @length - length of incoming message
  * @data_if_available - ignore
  *
@@ -1072,7 +1112,7 @@ mxlnd_unexpected_recv(void *context, mx_endpoint_addr_t source,
         mx_ksegment_t   seg;
         u8              msg_type        = 0;
         u8              error           = 0;
-        u64             cookie          = 0LL;
+        u64             cookie          = 0ULL;
 
         if (context != NULL) {
                 CDEBUG(D_NETERROR, "unexpected receive with non-NULL context\n");
@@ -1082,9 +1122,22 @@ mxlnd_unexpected_recv(void *context, mx_endpoint_addr_t source,
         CDEBUG(D_NET, "unexpected_recv() bits=0x%llx length=%d\n", match_value, length);
 #endif
 
+        mxlnd_parse_match(match_value, &msg_type, &error, &cookie);
+        if (msg_type == MXLND_MSG_BYE) {
+                struct kmx_peer *peer   = NULL;
+
+                mx_get_endpoint_addr_context(source, (void **) &peer);
+                if (peer && peer->mxp_conn) {
+                        CDEBUG(D_NET, "peer %s sent BYE msg\n",
+                                        libcfs_nid2str(peer->mxp_nid));
+                        mxlnd_conn_disconnect(peer->mxp_conn, 1, 0);
+                }
+
+                return MX_RECV_FINISHED;
+        }
+
         rx = mxlnd_get_idle_rx();
         if (rx != NULL) {
-                mxlnd_parse_match(match_value, &msg_type, &error, &cookie);
                 if (length <= MXLND_EAGER_SIZE) {
                         ret = mxlnd_recv_msg(NULL, rx, msg_type, match_value, length);
                 } else {
@@ -1100,22 +1153,20 @@ mxlnd_unexpected_recv(void *context, mx_endpoint_addr_t source,
 
                         /* NOTE to avoid a peer disappearing out from under us,
                          *      read lock the peers lock first */
-                        read_lock(&kmxlnd_data.kmx_peers_lock);
+                        read_lock(&kmxlnd_data.kmx_global_lock);
                         mx_get_endpoint_addr_context(source, (void **) &peer);
                         if (peer != NULL) {
                                 mxlnd_peer_addref(peer); /* add a ref... */
-                                spin_lock(&peer->mxp_lock);
                                 conn = peer->mxp_conn;
                                 if (conn) {
                                         mxlnd_conn_addref(conn); /* add ref until rx completed */
                                         mxlnd_peer_decref(peer); /* and drop peer ref */
                                         rx->mxc_conn = conn;
                                 }
-                                spin_unlock(&peer->mxp_lock);
                                 rx->mxc_peer = peer;
                                 rx->mxc_nid = peer->mxp_nid;
                         }
-                        read_unlock(&kmxlnd_data.kmx_peers_lock);
+                        read_unlock(&kmxlnd_data.kmx_global_lock);
                 } else {
                         CDEBUG(D_NETERROR, "could not post receive\n");
                         mxlnd_put_idle_rx(rx);
@@ -1129,10 +1180,10 @@ mxlnd_unexpected_recv(void *context, mx_endpoint_addr_t source,
                         /* ret != 0 */
                         CDEBUG(D_NETERROR, "disconnected peer - dropping rx\n");
                 }
-                seg.segment_ptr = 0LL;
+                seg.segment_ptr = 0ULL;
                 seg.segment_length = 0;
                 mx_kirecv(kmxlnd_data.kmx_endpt, &seg, 1, MX_PIN_PHYSICAL,
-                          match_value, 0xFFFFFFFFFFFFFFFFLL, NULL, NULL);
+                          match_value, ~0ULL, NULL, NULL);
         }
 
         return MX_RECV_CONTINUE;
@@ -1146,19 +1197,18 @@ mxlnd_get_peer_info(int index, lnet_nid_t *nidp, int *count)
         int                      ret    = -ENOENT;
         struct kmx_peer         *peer   = NULL;
 
-        read_lock(&kmxlnd_data.kmx_peers_lock);
+        read_lock(&kmxlnd_data.kmx_global_lock);
         for (i = 0; i < MXLND_HASH_SIZE; i++) {
                 list_for_each_entry(peer, &kmxlnd_data.kmx_peers[i], mxp_peers) {
-                        if (index-- > 0)
-                                continue;
-
-                        *nidp = peer->mxp_nid;
-                        *count = atomic_read(&peer->mxp_refcount);
-                        ret = 0;
-                        break;
+                        if (index-- == 0) {
+                                *nidp = peer->mxp_nid;
+                                *count = atomic_read(&peer->mxp_refcount);
+                                ret = 0;
+                                break;
+                        }
                 }
         }
-        read_unlock(&kmxlnd_data.kmx_peers_lock);
+        read_unlock(&kmxlnd_data.kmx_global_lock);
 
         return ret;
 }
@@ -1167,7 +1217,7 @@ void
 mxlnd_del_peer_locked(struct kmx_peer *peer)
 {
         list_del_init(&peer->mxp_peers); /* remove from the global list */
-        if (peer->mxp_conn) mxlnd_conn_disconnect(peer->mxp_conn, 1, 0);
+        if (peer->mxp_conn) mxlnd_conn_disconnect(peer->mxp_conn, 1, 1);
         mxlnd_peer_decref(peer); /* drop global list ref */
         return;
 }
@@ -1183,10 +1233,13 @@ mxlnd_del_peer(lnet_nid_t nid)
         if (nid != LNET_NID_ANY) {
                 peer = mxlnd_find_peer_by_nid(nid); /* adds peer ref */
         }
-        write_lock(&kmxlnd_data.kmx_peers_lock);
+        write_lock(&kmxlnd_data.kmx_global_lock);
         if (nid != LNET_NID_ANY) {
                 if (peer == NULL) {
                         ret = -ENOENT;
+                } if (peer == kmxlnd_data.kmx_localhost) {
+                        mxlnd_peer_decref(peer); /* and drops it */
+                        CERROR("cannot free this host's NID 0x%llx\n", nid);
                 } else {
                         mxlnd_peer_decref(peer); /* and drops it */
                         mxlnd_del_peer_locked(peer);
@@ -1195,11 +1248,12 @@ mxlnd_del_peer(lnet_nid_t nid)
                 for (i = 0; i < MXLND_HASH_SIZE; i++) {
                         list_for_each_entry_safe(peer, next,
                                                  &kmxlnd_data.kmx_peers[i], mxp_peers) {
-                                mxlnd_del_peer_locked(peer);
+                                if (peer != kmxlnd_data.kmx_localhost)
+                                        mxlnd_del_peer_locked(peer);
                         }
                 }
         }
-        write_unlock(&kmxlnd_data.kmx_peers_lock);
+        write_unlock(&kmxlnd_data.kmx_global_lock);
 
         return ret;
 }
@@ -1211,24 +1265,21 @@ mxlnd_get_conn_by_idx(int index)
         struct kmx_peer         *peer   = NULL;
         struct kmx_conn         *conn   = NULL;
 
-        read_lock(&kmxlnd_data.kmx_peers_lock);
+        read_lock(&kmxlnd_data.kmx_global_lock);
         for (i = 0; i < MXLND_HASH_SIZE; i++) {
                 list_for_each_entry(peer, &kmxlnd_data.kmx_peers[i], mxp_peers) {
-                        spin_lock(&peer->mxp_lock);
                         list_for_each_entry(conn, &peer->mxp_conns, mxk_list) {
                                 if (index-- > 0) {
                                         continue;
                                 }
 
                                 mxlnd_conn_addref(conn); /* add ref here, dec in ctl() */
-                                spin_unlock(&peer->mxp_lock);
-                                read_unlock(&kmxlnd_data.kmx_peers_lock);
+                                read_unlock(&kmxlnd_data.kmx_global_lock);
                                 return conn;
                         }
-                        spin_unlock(&peer->mxp_lock);
                 }
         }
-        read_unlock(&kmxlnd_data.kmx_peers_lock);
+        read_unlock(&kmxlnd_data.kmx_global_lock);
 
         return NULL;
 }
@@ -1239,11 +1290,11 @@ mxlnd_close_matching_conns_locked(struct kmx_peer *peer)
         struct kmx_conn *conn   = NULL;
         struct kmx_conn *next   = NULL;
 
-        spin_lock(&peer->mxp_lock);
-        list_for_each_entry_safe(conn, next, &peer->mxp_conns, mxk_list) {
-                mxlnd_conn_disconnect(conn, 0 , 0);
-        }
-        spin_unlock(&peer->mxp_lock);
+        if (peer == kmxlnd_data.kmx_localhost) return;
+
+        list_for_each_entry_safe(conn, next, &peer->mxp_conns, mxk_list)
+                mxlnd_conn_disconnect(conn, 0, 1);
+
         return;
 }
 
@@ -1254,7 +1305,7 @@ mxlnd_close_matching_conns(lnet_nid_t nid)
         int             ret     = 0;
         struct kmx_peer *peer   = NULL;
 
-        read_lock(&kmxlnd_data.kmx_peers_lock);
+        read_lock(&kmxlnd_data.kmx_global_lock);
         if (nid != LNET_NID_ANY) {
                 peer = mxlnd_find_peer_by_nid(nid); /* adds peer ref */
                 if (peer == NULL) {
@@ -1269,7 +1320,7 @@ mxlnd_close_matching_conns(lnet_nid_t nid)
                                 mxlnd_close_matching_conns_locked(peer);
                 }
         }
-        read_unlock(&kmxlnd_data.kmx_peers_lock);
+        read_unlock(&kmxlnd_data.kmx_global_lock);
 
         return ret;
 }
@@ -1485,7 +1536,7 @@ mxlnd_setup_iov(struct kmx_ctx *ctx, u32 niov, struct iovec *iov, u32 offset, u3
         ctx->mxc_nseg = nseg;
         sum = 0;
         for (i = 0; i < nseg; i++) {
-                seg[i].segment_ptr = MX_KVA_TO_U64(iov[first_iov + i].iov_base);
+                seg[i].segment_ptr = MX_PA_TO_U64(virt_to_phys(iov[first_iov + i].iov_base));
                 seg[i].segment_length = (u32) iov[first_iov + i].iov_len;
                 if (i == 0) {
                         seg[i].segment_ptr += (u64) first_iov_offset;
@@ -1497,7 +1548,7 @@ mxlnd_setup_iov(struct kmx_ctx *ctx, u32 niov, struct iovec *iov, u32 offset, u3
                 sum += seg[i].segment_length;
         }
         ctx->mxc_seg_list = seg;
-        ctx->mxc_pin_type = MX_PIN_KERNEL;
+        ctx->mxc_pin_type = MX_PIN_PHYSICAL;
 #ifdef MX_PIN_FULLPAGES
         ctx->mxc_pin_type |= MX_PIN_FULLPAGES;
 #endif
@@ -1584,7 +1635,7 @@ mxlnd_send_nak(struct kmx_ctx *tx, lnet_nid_t nid, int type, int status, __u64 c
         mxlnd_init_tx_msg(tx, type, sizeof(kmx_putack_msg_t), tx->mxc_nid);
         tx->mxc_cookie = cookie;
         tx->mxc_msg->mxm_u.put_ack.mxpam_src_cookie = cookie;
-        tx->mxc_msg->mxm_u.put_ack.mxpam_dst_cookie = ((u64) status << 52); /* error code */
+        tx->mxc_msg->mxm_u.put_ack.mxpam_dst_cookie = ((u64) status << MXLND_ERROR_OFFSET); /* error code */
         tx->mxc_match = mxlnd_create_match(tx, status);
 
         mxlnd_queue_tx(tx);
@@ -1618,7 +1669,7 @@ mxlnd_send_data(lnet_ni_t *ni, lnet_msg_t *lntmsg, struct kmx_peer *peer, u8 msg
         LASSERT(lntmsg != NULL);
         LASSERT(peer != NULL);
         LASSERT(msg_type == MXLND_MSG_PUT_DATA || msg_type == MXLND_MSG_GET_DATA);
-        LASSERT((cookie>>52) == 0);
+        LASSERT((cookie>>MXLND_ERROR_OFFSET) == 0);
 
         tx = mxlnd_get_idle_tx();
         if (tx == NULL) {
@@ -1685,14 +1736,15 @@ failed_0:
 int
 mxlnd_recv_data(lnet_ni_t *ni, lnet_msg_t *lntmsg, struct kmx_ctx *rx, u8 msg_type, u64 cookie)
 {
-        int                     ret             = 0;
-        lnet_process_id_t       target          = lntmsg->msg_target;
-        unsigned int            niov            = lntmsg->msg_niov;
-        struct iovec           *iov             = lntmsg->msg_iov;
-        lnet_kiov_t            *kiov            = lntmsg->msg_kiov;
-        unsigned int            offset          = lntmsg->msg_offset;
-        unsigned int            nob             = lntmsg->msg_len;
-        mx_return_t             mxret           = MX_SUCCESS;
+        int                     ret     = 0;
+        lnet_process_id_t       target  = lntmsg->msg_target;
+        unsigned int            niov    = lntmsg->msg_niov;
+        struct iovec           *iov     = lntmsg->msg_iov;
+        lnet_kiov_t            *kiov    = lntmsg->msg_kiov;
+        unsigned int            offset  = lntmsg->msg_offset;
+        unsigned int            nob     = lntmsg->msg_len;
+        mx_return_t             mxret   = MX_SUCCESS;
+        u64                     mask    = ~(MXLND_ERROR_MASK);
 
         /* above assumes MXLND_MSG_PUT_DATA */
         if (msg_type == MXLND_MSG_GET_DATA) {
@@ -1706,7 +1758,7 @@ mxlnd_recv_data(lnet_ni_t *ni, lnet_msg_t *lntmsg, struct kmx_ctx *rx, u8 msg_ty
         LASSERT(lntmsg != NULL);
         LASSERT(rx != NULL);
         LASSERT(msg_type == MXLND_MSG_PUT_DATA || msg_type == MXLND_MSG_GET_DATA);
-        LASSERT((cookie>>52) == 0); /* ensure top 12 bits are 0 */
+        LASSERT((cookie>>MXLND_ERROR_OFFSET) == 0); /* ensure top 12 bits are 0 */
 
         rx->mxc_msg_type = msg_type;
         rx->mxc_deadline = jiffies + MXLND_COMM_TIMEOUT;
@@ -1747,7 +1799,7 @@ mxlnd_recv_data(lnet_ni_t *ni, lnet_msg_t *lntmsg, struct kmx_ctx *rx, u8 msg_ty
         mxret = mx_kirecv(kmxlnd_data.kmx_endpt,
                           rx->mxc_seg_list, rx->mxc_nseg,
                           rx->mxc_pin_type, rx->mxc_match,
-                          0xF00FFFFFFFFFFFFFLL, (void *) rx,
+                          mask, (void *) rx,
                           &rx->mxc_mxreq);
         if (mxret != MX_SUCCESS) {
                 if (rx->mxc_conn != NULL) {
@@ -1812,17 +1864,18 @@ mxlnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                 if (unlikely(peer->mxp_incompatible)) {
                         mxlnd_peer_decref(peer); /* drop ref taken above */
                 } else {
-                        spin_lock(&peer->mxp_lock);
+                        read_lock(&kmxlnd_data.kmx_global_lock);
                         conn = peer->mxp_conn;
                         if (conn) {
                                 mxlnd_conn_addref(conn);
                                 mxlnd_peer_decref(peer); /* drop peer ref taken above */
                         }
-                        spin_unlock(&peer->mxp_lock);
+                        read_unlock(&kmxlnd_data.kmx_global_lock);
                 }
         }
+        CDEBUG(D_NET, "%s: peer 0x%llx is 0x%p\n", __func__, nid, peer);
         if (conn == NULL && peer != NULL) {
-                CDEBUG(D_NETERROR, "conn==NULL peer=0x%p nid=0x%llx payload_nob=%d type=%s\n",
+                CDEBUG(D_NET, "conn==NULL peer=0x%p nid=0x%llx payload_nob=%d type=%s\n",
                        peer, nid, payload_nob, mxlnd_lnetmsg_to_str(type));
         }
 
@@ -2027,7 +2080,7 @@ mxlnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
         struct kmx_msg          *txmsg          = NULL;
         struct kmx_peer         *peer           = rx->mxc_peer;
         struct kmx_conn         *conn           = peer->mxp_conn;
-        u64                      cookie         = 0LL;
+        u64                      cookie         = 0ULL;
         int                      msg_type       = rxmsg->mxm_type;
         int                      repost         = 1;
         int                      credit         = 0;
@@ -2236,13 +2289,13 @@ mxlnd_tx_queued(void *arg)
                 peer = mxlnd_find_peer_by_nid(tx->mxc_nid); /* adds peer ref */
                 if (peer != NULL) {
                         tx->mxc_peer = peer;
-                        spin_lock(&peer->mxp_lock);
+                        write_lock(&kmxlnd_data.kmx_global_lock);
                         if (peer->mxp_conn == NULL) {
                                 ret = mxlnd_conn_alloc_locked(&peer->mxp_conn, peer);
                                 if (ret != 0) {
                                         /* out of memory, give up and fail tx */
                                         tx->mxc_status.code = -ENOMEM;
-                                        spin_unlock(&peer->mxp_lock);
+                                        write_unlock(&kmxlnd_data.kmx_global_lock);
                                         mxlnd_peer_decref(peer);
                                         mxlnd_put_idle_tx(tx);
                                         continue;
@@ -2250,7 +2303,7 @@ mxlnd_tx_queued(void *arg)
                         }
                         tx->mxc_conn = peer->mxp_conn;
                         mxlnd_conn_addref(tx->mxc_conn); /* for this tx */
-                        spin_unlock(&peer->mxp_lock);
+                        write_unlock(&kmxlnd_data.kmx_global_lock);
                         mxlnd_peer_decref(peer); /* drop peer ref taken above */
                         mxlnd_queue_tx(tx);
                         found = 1;
@@ -2266,7 +2319,9 @@ mxlnd_tx_queued(void *arg)
                                 tx->mxc_msg_type != MXLND_MSG_GET_DATA);
                         /* create peer */
                         /* adds conn ref for this function */
-                        ret = mxlnd_peer_alloc(&peer, tx->mxc_nid);
+                        ret = mxlnd_peer_alloc(&peer, tx->mxc_nid,
+                                        *kmxlnd_tunables.kmx_board,
+                                        *kmxlnd_tunables.kmx_ep_id, 0ULL);
                         if (ret != 0) {
                                 /* finalize message */
                                 tx->mxc_status.code = ret;
@@ -2280,7 +2335,7 @@ mxlnd_tx_queued(void *arg)
                         /* add peer to global peer list, but look to see
                          * if someone already created it after we released
                          * the read lock */
-                        write_lock(&kmxlnd_data.kmx_peers_lock);
+                        write_lock(&kmxlnd_data.kmx_global_lock);
                         list_for_each_entry(old, &kmxlnd_data.kmx_peers[hash], mxp_peers) {
                                 if (old->mxp_nid == peer->mxp_nid) {
                                         /* somebody beat us here, we created a duplicate */
@@ -2294,18 +2349,16 @@ mxlnd_tx_queued(void *arg)
                                 atomic_inc(&kmxlnd_data.kmx_npeers);
                         } else {
                                 tx->mxc_peer = old;
-                                spin_lock(&old->mxp_lock);
                                 tx->mxc_conn = old->mxp_conn;
                                 /* FIXME can conn be NULL? */
                                 LASSERT(old->mxp_conn != NULL);
                                 mxlnd_conn_addref(old->mxp_conn);
-                                spin_unlock(&old->mxp_lock);
                                 mxlnd_reduce_idle_rxs(*kmxlnd_tunables.kmx_credits - 1);
                                 mxlnd_conn_decref(peer->mxp_conn); /* drop ref taken above.. */
                                 mxlnd_conn_decref(peer->mxp_conn); /* drop peer's ref */
                                 mxlnd_peer_decref(peer);
                         }
-                        write_unlock(&kmxlnd_data.kmx_peers_lock);
+                        write_unlock(&kmxlnd_data.kmx_global_lock);
 
                         mxlnd_queue_tx(tx);
                 }
@@ -2318,34 +2371,39 @@ mxlnd_tx_queued(void *arg)
 void
 mxlnd_iconnect(struct kmx_peer *peer, u64 mask)
 {
-        mx_return_t             mxret   = MX_SUCCESS;
-        mx_request_t            request;
-        struct kmx_conn         *conn   = peer->mxp_conn;
+        mx_return_t     mxret           = MX_SUCCESS;
+        mx_request_t    request;
+        struct kmx_conn *conn           = peer->mxp_conn;
+        u8              msg_type        = (u8) MXLND_MSG_TYPE(mask);
 
         /* NOTE we are holding a conn ref every time we call this function,
          * we do not need to lock the peer before taking another ref */
         mxlnd_conn_addref(conn); /* hold until CONN_REQ or CONN_ACK completes */
 
-        LASSERT(mask == MXLND_MASK_ICON_REQ ||
-                mask == MXLND_MASK_ICON_ACK);
+        LASSERT(msg_type == MXLND_MSG_ICON_REQ || msg_type == MXLND_MSG_ICON_ACK);
 
         if (peer->mxp_reconnect_time == 0) {
                 peer->mxp_reconnect_time = jiffies;
         }
 
-        if (peer->mxp_nic_id == 0LL) {
-                mxlnd_peer_hostname_to_nic_id(peer);
-                if (peer->mxp_nic_id == 0LL) {
+        if (peer->mxp_nic_id == 0ULL) {
+                int             ret     = 0;
+
+                ret = mxlnd_ip2nic_id(peer->mxp_ip, &peer->mxp_nic_id);
+                if (ret == 0) {
+                        mx_nic_id_to_board_number(peer->mxp_nic_id, &peer->mxp_board);
+                }
+                if (peer->mxp_nic_id == 0ULL) {
                         /* not mapped yet, return */
                         spin_lock(&conn->mxk_lock);
                         conn->mxk_status = MXLND_CONN_INIT;
                         spin_unlock(&conn->mxk_lock);
                         if (time_after(jiffies, peer->mxp_reconnect_time + MXLND_WAIT_TIMEOUT)) {
                                 /* give up and notify LNET */
-                                mxlnd_conn_disconnect(conn, 0, 1);
+                                mxlnd_conn_disconnect(conn, 0, 0);
                                 mxlnd_conn_alloc(&peer->mxp_conn, peer); /* adds ref for this
                                                                             function... */
-                                mxlnd_conn_decref(peer->mxp_conn); /* which we no 
+                                mxlnd_conn_decref(peer->mxp_conn); /* which we no
                                                                       longer need */
                         }
                         mxlnd_conn_decref(conn);
@@ -2354,7 +2412,7 @@ mxlnd_iconnect(struct kmx_peer *peer, u64 mask)
         }
 
         mxret = mx_iconnect(kmxlnd_data.kmx_endpt, peer->mxp_nic_id,
-                            peer->mxp_host->mxh_ep_id, MXLND_MSG_MAGIC, mask,
+                            peer->mxp_ep_id, MXLND_MSG_MAGIC, mask,
                             (void *) peer, &request);
         if (unlikely(mxret != MX_SUCCESS)) {
                 spin_lock(&conn->mxk_lock);
@@ -2390,12 +2448,12 @@ mxlnd_check_sends(struct kmx_peer *peer)
                 LASSERT(peer != NULL);
                 return -1;
         }
-        spin_lock(&peer->mxp_lock);
+        write_lock(&kmxlnd_data.kmx_global_lock);
         conn = peer->mxp_conn;
         /* NOTE take a ref for the duration of this function since it is called
          * when there might not be any queued txs for this peer */
         if (conn) mxlnd_conn_addref(conn); /* for duration of this function */
-        spin_unlock(&peer->mxp_lock);
+        write_unlock(&kmxlnd_data.kmx_global_lock);
 
         /* do not add another ref for this tx */
 
@@ -2453,10 +2511,11 @@ mxlnd_check_sends(struct kmx_peer *peer)
         if (unlikely(conn->mxk_status == MXLND_CONN_INIT ||
             conn->mxk_status == MXLND_CONN_FAIL ||
             conn->mxk_status == MXLND_CONN_REQ)) {
+                u64 match = (u64) MXLND_MSG_ICON_REQ << MXLND_MSG_OFFSET;
                 CDEBUG(D_NET, "status=%s\n", mxlnd_connstatus_to_str(conn->mxk_status));
                 conn->mxk_status = MXLND_CONN_WAIT;
                 spin_unlock(&conn->mxk_lock);
-                mxlnd_iconnect(peer, MXLND_MASK_ICON_REQ);
+                mxlnd_iconnect(peer, match);
                 goto done;
         }
         spin_unlock(&conn->mxk_lock);
@@ -2821,14 +2880,16 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
         struct kmx_peer        *peer            = rx->mxc_peer;
         struct kmx_conn        *conn            = rx->mxc_conn;
         u8                      type            = rx->mxc_msg_type;
-        u64                     seq             = 0LL;
+        u64                     seq             = 0ULL;
         lnet_msg_t             *lntmsg[2];
         int                     result          = 0;
-        u64                     nic_id          = 0LL;
+        u64                     nic_id          = 0ULL;
         u32                     ep_id           = 0;
+        u32                     sid             = 0;
         int                     peer_ref        = 0;
         int                     conn_ref        = 0;
         int                     incompatible    = 0;
+        u64                     match           = 0ULL;
 
         /* NOTE We may only know the peer's nid if it is a PUT_REQ, GET_REQ, 
          * failed GET reply, CONN_REQ, or a CONN_ACK */
@@ -2856,7 +2917,7 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
 #endif
 
         if (conn == NULL && peer != NULL) {
-                spin_lock(&peer->mxp_lock);
+                write_lock(&kmxlnd_data.kmx_global_lock);
                 conn = peer->mxp_conn;
                 if (conn) {
                         mxlnd_conn_addref(conn); /* conn takes ref... */
@@ -2864,7 +2925,7 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
                         conn_ref = 1;
                         peer_ref = 0;
                 }
-                spin_unlock(&peer->mxp_lock);
+                write_unlock(&kmxlnd_data.kmx_global_lock);
                 rx->mxc_conn = conn;
         }
 
@@ -2887,8 +2948,8 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
         if (nob == 0) {
                 /* this may be a failed GET reply */
                 if (type == MXLND_MSG_GET_DATA) {
-                        bits = rx->mxc_status.match_info & 0x0FF0000000000000LL;
-                        ret = (u32) (bits>>52);
+                        /* get the error (52-59) bits from the match bits */
+                        ret = (u32) MXLND_ERROR_VAL(rx->mxc_status.match_info);
                         lntmsg[0] = rx->mxc_lntmsg[0];
                         result = -ret;
                         goto cleanup;
@@ -2998,7 +3059,7 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
                 if (cookie > MXLND_MAX_COOKIE) {
                         CDEBUG(D_NETERROR, "NAK for msg_type %d from %s\n", rx->mxc_msg_type,
                                            libcfs_nid2str(rx->mxc_nid));
-                        result = -((cookie >> 52) & 0xff);
+                        result = -((u32) MXLND_ERROR_VAL(cookie));
                         lntmsg[0] = rx->mxc_lntmsg[0];
                 } else {
                         mxlnd_send_data(kmxlnd_data.kmx_ni, rx->mxc_lntmsg[0],
@@ -3037,6 +3098,7 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
                                         (int) MXLND_EAGER_SIZE);
                         incompatible = 1;
                 }
+                mx_decompose_endpoint_addr2(rx->mxc_status.source, &nic_id, &ep_id, &sid);
                 if (peer == NULL) {
                         peer = mxlnd_find_peer_by_nid(msg->mxm_srcnid); /* adds peer ref */
                         if (peer == NULL) {
@@ -3044,17 +3106,18 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
                                 struct kmx_peer *existing_peer    = NULL;
                                 hash = mxlnd_nid_to_hash(msg->mxm_srcnid);
 
-                                mx_decompose_endpoint_addr(rx->mxc_status.source,
-                                                           &nic_id, &ep_id);
                                 rx->mxc_nid = msg->mxm_srcnid;
 
                                 /* adds conn ref for peer and one for this function */
-                                ret = mxlnd_peer_alloc(&peer, msg->mxm_srcnid);
+                                ret = mxlnd_peer_alloc(&peer, msg->mxm_srcnid,
+                                                *kmxlnd_tunables.kmx_board,
+                                                *kmxlnd_tunables.kmx_ep_id, 0ULL);
                                 if (ret != 0) {
                                         goto cleanup;
                                 }
-                                LASSERT(peer->mxp_host->mxh_ep_id == ep_id);
-                                write_lock(&kmxlnd_data.kmx_peers_lock);
+                                peer->mxp_sid = sid;
+                                LASSERT(peer->mxp_ep_id == ep_id);
+                                write_lock(&kmxlnd_data.kmx_global_lock);
                                 existing_peer = mxlnd_find_peer_by_nid_locked(msg->mxm_srcnid);
                                 if (existing_peer) {
                                         mxlnd_conn_decref(peer->mxp_conn);
@@ -3064,10 +3127,11 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
                                 } else {
                                         list_add_tail(&peer->mxp_peers,
                                                       &kmxlnd_data.kmx_peers[hash]);
-                                        write_unlock(&kmxlnd_data.kmx_peers_lock);
                                         atomic_inc(&kmxlnd_data.kmx_npeers);
                                 }
+                                write_unlock(&kmxlnd_data.kmx_global_lock);
                         } else {
+                                /* FIXME should write lock here */
                                 ret = mxlnd_conn_alloc(&conn, peer); /* adds 2nd ref */
                                 mxlnd_peer_decref(peer); /* drop ref taken above */
                                 if (ret != 0) {
@@ -3077,38 +3141,44 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
                         }
                         conn_ref = 1; /* peer/conn_alloc() added ref for this function */
                         conn = peer->mxp_conn;
-                } else {
+                } else { /* found peer */
                         struct kmx_conn *old_conn       = conn;
 
-                        /* do not call mx_disconnect() */
-                        mxlnd_conn_disconnect(old_conn, 0, 0);
+                        if (sid != peer->mxp_sid) {
+                                /* do not call mx_disconnect() or send a BYE */
+                                mxlnd_conn_disconnect(old_conn, 0, 0);
 
-                        /* the ref for this rx was taken on the old_conn */
-                        mxlnd_conn_decref(old_conn);
+                                /* the ref for this rx was taken on the old_conn */
+                                mxlnd_conn_decref(old_conn);
 
-                        /* This allocs a conn, points peer->mxp_conn to this one.
-                         * The old conn is still on the peer->mxp_conns list.
-                         * As the pending requests complete, they will call
-                         * conn_decref() which will eventually free it. */
-                        ret = mxlnd_conn_alloc(&conn, peer);
-                        if (ret != 0) {
-                                CDEBUG(D_NETERROR, "Cannot allocate peer->mxp_conn\n");
-                                goto cleanup;
+                                /* This allocs a conn, points peer->mxp_conn to this one.
+                                * The old conn is still on the peer->mxp_conns list.
+                                * As the pending requests complete, they will call
+                                * conn_decref() which will eventually free it. */
+                                ret = mxlnd_conn_alloc(&conn, peer);
+                                if (ret != 0) {
+                                        CDEBUG(D_NETERROR, "Cannot allocate peer->mxp_conn\n");
+                                        goto cleanup;
+                                }
+                                /* conn_alloc() adds one ref for the peer and one
+                                 * for this function */
+                                conn_ref = 1;
+
+                                peer->mxp_sid = sid;
                         }
-                        /* conn_alloc() adds one ref for the peer and one for this function */
-                        conn_ref = 1;
                 }
-                spin_lock(&peer->mxp_lock);
+                write_lock(&kmxlnd_data.kmx_global_lock);
                 peer->mxp_incarnation = msg->mxm_srcstamp;
                 peer->mxp_incompatible = incompatible;
-                spin_unlock(&peer->mxp_lock);
+                write_unlock(&kmxlnd_data.kmx_global_lock);
                 spin_lock(&conn->mxk_lock);
                 conn->mxk_incarnation = msg->mxm_srcstamp;
                 conn->mxk_status = MXLND_CONN_WAIT;
                 spin_unlock(&conn->mxk_lock);
 
                 /* handle_conn_ack() will create the CONN_ACK msg */
-                mxlnd_iconnect(peer, MXLND_MASK_ICON_ACK);
+                match = (u64) MXLND_MSG_ICON_ACK << MXLND_MSG_OFFSET;
+                mxlnd_iconnect(peer, match);
 
                 break;
 
@@ -3144,10 +3214,10 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
                         incompatible = 1;
                         ret = -1;
                 }
-                spin_lock(&peer->mxp_lock);
+                write_lock(&kmxlnd_data.kmx_global_lock);
                 peer->mxp_incarnation = msg->mxm_srcstamp;
                 peer->mxp_incompatible = incompatible;
-                spin_unlock(&peer->mxp_lock);
+                write_unlock(&kmxlnd_data.kmx_global_lock);
                 spin_lock(&conn->mxk_lock);
                 conn->mxk_credits = *kmxlnd_tunables.kmx_credits;
                 conn->mxk_outstanding = 0;
@@ -3169,7 +3239,7 @@ mxlnd_handle_rx_completion(struct kmx_ctx *rx)
 
 failed:
         if (ret < 0) {
-                MXLND_PRINT("setting PEER_CONN_FAILED\n");
+                CDEBUG(D_NET, "setting PEER_CONN_FAILED\n");
                 spin_lock(&conn->mxk_lock);
                 conn->mxk_status = MXLND_CONN_FAIL;
                 spin_unlock(&conn->mxk_lock);
@@ -3241,12 +3311,11 @@ mxlnd_handle_conn_req(struct kmx_peer *peer, mx_status_t status)
                 if (time_after(jiffies, peer->mxp_reconnect_time + MXLND_WAIT_TIMEOUT)) {
                         struct kmx_conn *new_conn       = NULL;
                         CDEBUG(D_NETERROR, "timeout, calling conn_disconnect()\n");
-                        mxlnd_conn_disconnect(conn, 0, 1);
+                        /* FIXME write lock here ? */
+                        mxlnd_conn_disconnect(conn, 0, 0);
                         mxlnd_conn_alloc(&new_conn, peer); /* adds a ref for this function */
                         mxlnd_conn_decref(new_conn); /* which we no longer need */
-                        spin_lock(&peer->mxp_lock);
                         peer->mxp_reconnect_time = 0;
-                        spin_unlock(&peer->mxp_lock);
                 }
 
                 mxlnd_conn_decref(conn);
@@ -3261,9 +3330,9 @@ mxlnd_handle_conn_req(struct kmx_peer *peer, mx_status_t status)
         mx_set_endpoint_addr_context(conn->mxk_epa, (void *) peer);
 
         /* mx_iconnect() succeeded, reset delay to 0 */
-        spin_lock(&peer->mxp_lock);
+        write_lock(&kmxlnd_data.kmx_global_lock);
         peer->mxp_reconnect_time = 0;
-        spin_unlock(&peer->mxp_lock);
+        write_unlock(&kmxlnd_data.kmx_global_lock);
 
         /* marshal CONN_REQ msg */
         /* we are still using the conn ref from iconnect() - do not take another */
@@ -3297,6 +3366,9 @@ mxlnd_handle_conn_ack(struct kmx_peer *peer, mx_status_t status)
         struct kmx_ctx  *tx     = NULL;
         struct kmx_msg  *txmsg   = NULL;
         struct kmx_conn *conn   = peer->mxp_conn;
+        u64             nic_id  = 0ULL;
+        u32             ep_id   = 0;
+        u32             sid     = 0;
 
         /* a conn ref was taken when calling mx_iconnect(), 
          * hold it until CONN_REQ or CONN_ACK completes */
@@ -3304,12 +3376,12 @@ mxlnd_handle_conn_ack(struct kmx_peer *peer, mx_status_t status)
         CDEBUG(D_NET, "entering\n");
         if (status.code != MX_STATUS_SUCCESS) {
                 CDEBUG(D_NETERROR, "mx_iconnect() failed for CONN_ACK with %s (%d) "
-                       "to %s mxp_nid = 0x%llx mxp_nic_id = 0x%0llx mxh_ep_id = %d\n",
+                       "to %s mxp_nid = 0x%llx mxp_nic_id = 0x%0llx mxp_ep_id = %d\n",
                         mx_strstatus(status.code), status.code,
                         libcfs_nid2str(peer->mxp_nid),
                         peer->mxp_nid,
                         peer->mxp_nic_id,
-                        peer->mxp_host->mxh_ep_id);
+                        peer->mxp_ep_id);
                 spin_lock(&conn->mxk_lock);
                 conn->mxk_status = MXLND_CONN_FAIL;
                 spin_unlock(&conn->mxk_lock);
@@ -3317,18 +3389,18 @@ mxlnd_handle_conn_ack(struct kmx_peer *peer, mx_status_t status)
                 if (time_after(jiffies, peer->mxp_reconnect_time + MXLND_WAIT_TIMEOUT)) {
                         struct kmx_conn *new_conn       = NULL;
                         CDEBUG(D_NETERROR, "timeout, calling conn_disconnect()\n");
+                        /* FIXME write lock here? */
                         mxlnd_conn_disconnect(conn, 0, 1);
                         mxlnd_conn_alloc(&new_conn, peer); /* adds ref for 
                                                               this function... */
                         mxlnd_conn_decref(new_conn); /* which we no longer need */
-                        spin_lock(&peer->mxp_lock);
                         peer->mxp_reconnect_time = 0;
-                        spin_unlock(&peer->mxp_lock);
                 }
 
                 mxlnd_conn_decref(conn);
                 return;
         }
+        mx_decompose_endpoint_addr2(status.source, &nic_id, &ep_id, &sid);
         spin_lock(&conn->mxk_lock);
         conn->mxk_epa = status.source;
         if (likely(!peer->mxp_incompatible)) {
@@ -3340,9 +3412,10 @@ mxlnd_handle_conn_ack(struct kmx_peer *peer, mx_status_t status)
         mx_set_endpoint_addr_context(conn->mxk_epa, (void *) peer);
 
         /* mx_iconnect() succeeded, reset delay to 0 */
-        spin_lock(&peer->mxp_lock);
+        write_lock(&kmxlnd_data.kmx_global_lock);
         peer->mxp_reconnect_time = 0;
-        spin_unlock(&peer->mxp_lock);
+        peer->mxp_sid = sid;
+        write_unlock(&kmxlnd_data.kmx_global_lock);
 
         /* marshal CONN_ACK msg */
         tx = mxlnd_get_idle_tx();
@@ -3402,20 +3475,22 @@ mxlnd_request_waitd(void *arg)
         CDEBUG(D_NET, "%s starting\n", name);
 
         while (!kmxlnd_data.kmx_shutdown) {
+                u8      msg_type        = 0;
+
                 mxret = MX_SUCCESS;
                 result = 0;
 #if MXLND_POLLING
                 if (id == 0 && count++ < *kmxlnd_tunables.kmx_polling) {
-                        mxret = mx_test_any(kmxlnd_data.kmx_endpt, 0LL, 0LL,
+                        mxret = mx_test_any(kmxlnd_data.kmx_endpt, 0ULL, 0ULL,
                                             &status, &result);
                 } else {
                         count = 0;
                         mxret = mx_wait_any(kmxlnd_data.kmx_endpt, MXLND_WAIT_TIMEOUT,
-                                            0LL, 0LL, &status, &result);
+                                            0ULL, 0ULL, &status, &result);
                 }
 #else
                 mxret = mx_wait_any(kmxlnd_data.kmx_endpt, MXLND_WAIT_TIMEOUT,
-                                    0LL, 0LL, &status, &result);
+                                    0ULL, 0ULL, &status, &result);
 #endif
                 if (unlikely(kmxlnd_data.kmx_shutdown))
                         break;
@@ -3432,12 +3507,14 @@ mxlnd_request_waitd(void *arg)
                                (u64) status.match_info, status.msg_length);
                 }
 
+                msg_type = MXLND_MSG_TYPE(status.match_info);
+
                 /* This may be a mx_iconnect() request completing,
                  * check the bit mask for CONN_REQ and CONN_ACK */
-                if (status.match_info == MXLND_MASK_ICON_REQ ||
-                    status.match_info == MXLND_MASK_ICON_ACK) {
+                if (msg_type == MXLND_MSG_ICON_REQ ||
+                    msg_type == MXLND_MSG_ICON_ACK) {
                         peer = (struct kmx_peer*) status.context;
-                        if (status.match_info == MXLND_MASK_ICON_REQ) {
+                        if (msg_type == MXLND_MSG_ICON_REQ) {
                                 mxlnd_handle_conn_req(peer, status);
                         } else {
                                 mxlnd_handle_conn_ack(peer, status);
@@ -3499,25 +3576,23 @@ mxlnd_check_timeouts(unsigned long now)
         struct  kmx_peer        *peer           = NULL;
         struct  kmx_conn        *conn           = NULL;
 
-        read_lock(&kmxlnd_data.kmx_peers_lock);
+        read_lock(&kmxlnd_data.kmx_global_lock);
         for (i = 0; i < MXLND_HASH_SIZE; i++) {
                 list_for_each_entry(peer, &kmxlnd_data.kmx_peers[i], mxp_peers) {
 
                         if (unlikely(kmxlnd_data.kmx_shutdown)) {
-                                read_unlock(&kmxlnd_data.kmx_peers_lock);
+                                read_unlock(&kmxlnd_data.kmx_global_lock);
                                 return next;
                         }
 
-                        spin_lock(&peer->mxp_lock);
                         conn = peer->mxp_conn;
                         if (conn) {
                                 mxlnd_conn_addref(conn);
-                                spin_unlock(&peer->mxp_lock);
                         } else {
-                                spin_unlock(&peer->mxp_lock);
                                 continue;
                         }
 
+                        /* FIXMEis this needed? */
                         spin_lock(&conn->mxk_lock);
 
                         /* if nothing pending (timeout == 0) or
@@ -3525,6 +3600,7 @@ mxlnd_check_timeouts(unsigned long now)
                          * skip this conn */
                         if (conn->mxk_timeout == 0 ||
                             conn->mxk_status == MXLND_CONN_DISCONNECT) {
+                                /* FIXME is this needed? */
                                 spin_unlock(&conn->mxk_lock);
                                 mxlnd_conn_decref(conn);
                                 continue;
@@ -3551,7 +3627,7 @@ mxlnd_check_timeouts(unsigned long now)
                         mxlnd_conn_decref(conn);
                 }
         }
-        read_unlock(&kmxlnd_data.kmx_peers_lock);
+        read_unlock(&kmxlnd_data.kmx_global_lock);
         if (next == 0) next = now + MXLND_COMM_TIMEOUT;
 
         return next;
@@ -3590,25 +3666,28 @@ mxlnd_timeoutd(void *arg)
                         next = mxlnd_check_timeouts(now);
                 }
 
-               read_lock(&kmxlnd_data.kmx_peers_lock);
+               read_lock(&kmxlnd_data.kmx_global_lock);
                 for (i = 0; i < MXLND_HASH_SIZE; i++) {
                         list_for_each_entry(peer, &kmxlnd_data.kmx_peers[i], mxp_peers) {
-                                spin_lock(&peer->mxp_lock);
+                                /* FIXME upgrade to write lock?
+                                 * is any lock needed? */
                                 conn = peer->mxp_conn;
                                 if (conn) mxlnd_conn_addref(conn); /* take ref... */
-                                spin_unlock(&peer->mxp_lock);
 
                                 if (conn == NULL)
                                         continue;
 
                                 if (conn->mxk_status != MXLND_CONN_DISCONNECT &&
                                     time_after(now, conn->mxk_last_tx + HZ)) {
+                                        /* FIXME drop lock or call check_sends_locked */
+                                        read_unlock(&kmxlnd_data.kmx_global_lock);
                                         mxlnd_check_sends(peer);
+                                        read_lock(&kmxlnd_data.kmx_global_lock);
                                 }
                                 mxlnd_conn_decref(conn); /* until here */
                         }
                 }
-                read_unlock(&kmxlnd_data.kmx_peers_lock);
+                read_unlock(&kmxlnd_data.kmx_global_lock);
 
                 mxlnd_sleep(delay);
         }
diff --git a/lnet/klnds/mxlnd/mxlnd_modparams.c b/lnet/klnds/mxlnd/mxlnd_modparams.c
index fb31d4c..c583838 100644
--- a/lnet/klnds/mxlnd/mxlnd_modparams.c
+++ b/lnet/klnds/mxlnd/mxlnd_modparams.c
@@ -70,13 +70,17 @@ CFS_MODULE_PARM(board, "i", int, 0444,
 static int ep_id = MXLND_MX_EP_ID;
 CFS_MODULE_PARM(ep_id, "i", int, 0444, "MX endpoint ID");
 
+static char *ipif_name = "myri0";
+CFS_MODULE_PARM(ipif_name, "s", charp, 0444,
+                "IPoMX interface name");
+
 static int polling = MXLND_POLLING;
 CFS_MODULE_PARM(polling, "i", int, 0444,
                 "Use 0 to block (wait). A value > 0 will poll that many times before blocking");
 
 static char *hosts = NULL;
 CFS_MODULE_PARM(hosts, "s", charp, 0444,
-                "IP-to-hostname resolution file");
+                "Unused - was IP-to-hostname resolution file");
 
 kmx_tunables_t kmxlnd_tunables = {
         .kmx_n_waitd            = &n_waitd,
@@ -86,6 +90,179 @@ kmx_tunables_t kmxlnd_tunables = {
         .kmx_credits            = &credits,
         .kmx_board              = &board,
         .kmx_ep_id              = &ep_id,
-        .kmx_polling            = &polling,
-        .kmx_hosts              = &hosts
+        .kmx_default_ipif       = &ipif_name,
+        .kmx_polling            = &polling
+};
+
+#if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
+
+static char ipif_basename_space[32];
+
+#ifndef HAVE_SYSCTL_UNNUMBERED
+
+enum {
+        MXLND_N_WAITD   = 1,
+        MXLND_MAX_PEERS,
+        MXLND_CKSUM,
+        MXLND_NNTX,
+        MXLND_CREDITS,
+        MXLND_BOARD,
+        MXLND_EP_ID,
+        MXLND_IPIF_BASENAME,
+        MXLND_POLLING
+};
+#else
+
+#define MXLND_N_WAITD           CTL_UNNUMBERED
+#define MXLND_MAX_PEERS         CTL_UNNUMBERED
+#define MXLND_CKSUM             CTL_UNNUMBERED
+#define MXLND_NNTX              CTL_UNNUMBERED
+#define MXLND_CREDITS           CTL_UNNUMBERED
+#define MXLND_BOARD             CTL_UNNUMBERED
+#define MXLND_EP_ID             CTL_UNNUMBERED
+#define MXLND_IPIF_BASENAME     CTL_UNNUMBERED
+#define MXLND_POLLING           CTL_UNNUMBERED
+
+#endif
+
+static cfs_sysctl_table_t kmxlnd_ctl_table[] = {
+        {
+                .ctl_name = 1,
+                .procname = "n_waitd",
+                .data     = &n_waitd,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = 2,
+                .procname = "max_peers",
+                .data     = &max_peers,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = 3,
+                .procname = "cksum",
+                .data     = &cksum,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = 4,
+                .procname = "ntx",
+                .data     = &ntx,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = 5,
+                .procname = "credits",
+                .data     = &credits,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = 6,
+                .procname = "board",
+                .data     = &board,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = 7,
+                .procname = "ep_id",
+                .data     = &ep_id,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = 8,
+                .procname = "ipif_name",
+                .data     = ipif_basename_space,
+                .maxlen   = sizeof(ipif_basename_space),
+                .mode     = 0444,
+                .proc_handler = &proc_dostring
+        },
+        {
+                .ctl_name = 9,
+                .procname = "polling",
+                .data     = &polling,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {0}
+};
+
+static cfs_sysctl_table_t kmxlnd_top_ctl_table[] = {
+        {
+                .ctl_name = 208,
+                .procname = "mxlnd",
+                .data     = NULL,
+                .maxlen   = 0,
+                .mode     = 0555,
+                .child    = kmxlnd_ctl_table
+        },
+        {0}
 };
+
+void
+kmxlnd_initstrtunable(char *space, char *str, int size)
+{
+        strncpy(space, str, size);
+        space[size-1] = 0;
+}
+
+void
+kmxlnd_sysctl_init (void)
+{
+        kmxlnd_initstrtunable(ipif_basename_space, ipif_name,
+                              sizeof(ipif_basename_space));
+
+        kmxlnd_tunables.kib_sysctl =
+                cfs_register_sysctl_table(kmxlnd_top_ctl_table, 0);
+
+        if (kmxlnd_tunables.kib_sysctl == NULL)
+                CWARN("Can't setup /proc tunables\n");
+}
+
+void
+kmxlnd_sysctl_fini (void)
+{
+        if (kmxlnd_tunables.kib_sysctl != NULL)
+                cfs_unregister_sysctl_table(kmxlnd_tunables.kib_sysctl);
+}
+
+#else
+
+void
+kmxlnd_sysctl_init (void)
+{
+}
+
+void
+kmxlnd_sysctl_fini (void)
+{
+}
+
+#endif
+
+int
+kmxlnd_tunables_init (void)
+{
+        kmxlnd_sysctl_init();
+        return 0;
+}
+
+void
+kmxlnd_tunables_fini (void)
+{
+        kmxlnd_sysctl_fini();
+}
diff --git a/lnet/klnds/mxlnd/mxlnd_wire.h b/lnet/klnds/mxlnd/mxlnd_wire.h
deleted file mode 100644
index 39be7fc..0000000
--- a/lnet/klnds/mxlnd/mxlnd_wire.h
+++ /dev/null
@@ -1,114 +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  2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- *
- * Copyright (C) 2006 Myricom, Inc.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lnet/klnds/mxlnd/mxlnd.h
- *
- * Author: Eric Barton <eric at bartonsoftware.com>
- * Author: Scott Atchley <atchley at myri.com>
- */
-
-/*
- * MXLND wire format - sent in sender's byte order
- */
-
-typedef struct kmx_connreq_msg
-{
-        u32             mxcrm_queue_depth;              /* per peer max messages in flight */
-        u32             mxcrm_eager_size;               /* size of preposted eager messages */
-} WIRE_ATTR kmx_connreq_msg_t;
-
-typedef struct kmx_eager_msg
-{
-        lnet_hdr_t      mxem_hdr;                       /* lnet header */
-        char            mxem_payload[0];                /* piggy-backed payload */
-} WIRE_ATTR kmx_eager_msg_t;
-
-typedef struct kmx_putreq_msg
-{
-        lnet_hdr_t      mxprm_hdr;                      /* lnet header */
-        u64             mxprm_cookie;                   /* opaque completion cookie */
-} WIRE_ATTR kmx_putreq_msg_t;
-
-typedef struct kmx_putack_msg
-{
-        u64             mxpam_src_cookie;               /* reflected completion cookie */
-        u64             mxpam_dst_cookie;               /* opaque completion cookie */
-} WIRE_ATTR kmx_putack_msg_t;
-
-typedef struct kmx_getreq_msg
-{
-        lnet_hdr_t      mxgrm_hdr;                      /* lnet header */
-        u64             mxgrm_cookie;                   /* opaque completion cookie */
-} WIRE_ATTR kmx_getreq_msg_t;
-
-typedef struct kmx_msg
-{
-        /* First two fields fixed for all time */
-        u32             mxm_magic;                      /* MXLND message */
-        u16             mxm_version;                    /* version number */
-
-        u8              mxm_type;                       /* message type */
-        u8              mxm_credits;                    /* returned credits */
-        u32             mxm_nob;                        /* # of bytes in whole message */
-        u32             mxm_cksum;                      /* checksum (0 == no checksum) */
-        u64             mxm_srcnid;                     /* sender's NID */
-        u64             mxm_srcstamp;                   /* sender's incarnation */
-        u64             mxm_dstnid;                     /* destination's NID */
-        u64             mxm_dststamp;                   /* destination's incarnation */
-        u64             mxm_seq;                        /* sequence number */
-
-        union {
-                kmx_connreq_msg_t       conn_req;
-                kmx_eager_msg_t         eager;
-                kmx_putreq_msg_t        put_req;
-                kmx_putack_msg_t        put_ack;
-                kmx_getreq_msg_t        get_req;
-        } WIRE_ATTR mxm_u;
-} WIRE_ATTR kmx_msg_t;
-
-#define MXLND_MSG_MAGIC         0x4d583130              /* unique magic 'MX10' */
-#define MXLND_MSG_VERSION       0x01
-
-#define MXLND_MSG_CONN_REQ      0xc                     /* connection request */
-#define MXLND_MSG_CONN_ACK      0xa                     /* connection request response */
-#define MXLND_MSG_EAGER         0xe                     /* eager message */
-#define MXLND_MSG_NOOP          0x1                     /* no msg, return credits */
-#define MXLND_MSG_PUT_REQ       0x2                     /* put request src->sink */
-#define MXLND_MSG_PUT_ACK       0x3                     /* put ack     src<-sink */
-#define MXLND_MSG_PUT_DATA      0x4                     /* put payload src->sink */
-#define MXLND_MSG_GET_REQ       0x5                     /* get request sink->src */
-#define MXLND_MSG_GET_DATA      0x6                     /* get payload sink<-src */
diff --git a/lnet/klnds/o2iblnd/Makefile.in b/lnet/klnds/o2iblnd/Makefile.in
index 569c266..0b74f0a 100644
--- a/lnet/klnds/o2iblnd/Makefile.in
+++ b/lnet/klnds/o2iblnd/Makefile.in
@@ -4,5 +4,6 @@ ko2iblnd-objs := o2iblnd.o o2iblnd_cb.o o2iblnd_modparams.o
 # Need to make sure we use PRE, not POST here so that an external OFED
 # source pool overrides any in-kernel OFED sources
 EXTRA_PRE_CFLAGS := @O2IBCPPFLAGS@
+EXTRA_DIST = $(ko2iblnd-objs:%.o=%.c) o2iblnd.h
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/o2iblnd/autoMakefile.am b/lnet/klnds/o2iblnd/autoMakefile.am
index 38773e3..29c55c7 100644
--- a/lnet/klnds/o2iblnd/autoMakefile.am
+++ b/lnet/klnds/o2iblnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(ko2iblnd-objs:%.o=%.c) o2iblnd.h
diff --git a/lnet/klnds/o2iblnd/autoMakefile.in b/lnet/klnds/o2iblnd/autoMakefile.in
index bcf9db1..7429123 100644
--- a/lnet/klnds/o2iblnd/autoMakefile.in
+++ b/lnet/klnds/o2iblnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_O2IBLND_TRUE@@MODULES_TRUE at modulenet_DATA = ko2iblnd$(KMODEXT)
-DIST_SOURCES = $(ko2iblnd-objs:%.o=%.c) o2iblnd.h
 subdir = lnet/klnds/o2iblnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/klnds/o2iblnd/o2iblnd.c b/lnet/klnds/o2iblnd/o2iblnd.c
index 0416c7c..bc9c0f3 100644
--- a/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/lnet/klnds/o2iblnd/o2iblnd.c
@@ -40,11 +40,12 @@
 
 #include "o2iblnd.h"
 
-lnd_t the_kiblnd = {
+lnd_t the_o2iblnd = {
         .lnd_type       = O2IBLND,
         .lnd_startup    = kiblnd_startup,
         .lnd_shutdown   = kiblnd_shutdown,
         .lnd_ctl        = kiblnd_ctl,
+        .lnd_query      = kiblnd_query,
         .lnd_send       = kiblnd_send,
         .lnd_recv       = kiblnd_recv,
 };
@@ -64,15 +65,129 @@ kiblnd_cksum (void *ptr, int nob)
         return (sum == 0) ? 1 : sum;
 }
 
-void
-kiblnd_init_msg (kib_msg_t *msg, int type, int body_nob)
+static char *
+kiblnd_msgtype2str(int type)
 {
-        msg->ibm_type = type;
-        msg->ibm_nob  = offsetof(kib_msg_t, ibm_u) + body_nob;
+        switch (type) {
+        case IBLND_MSG_CONNREQ:
+                return "CONNREQ";
+
+        case IBLND_MSG_CONNACK:
+                return "CONNACK";
+
+        case IBLND_MSG_NOOP:
+                return "NOOP";
+
+        case IBLND_MSG_IMMEDIATE:
+                return "IMMEDIATE";
+
+        case IBLND_MSG_PUT_REQ:
+                return "PUT_REQ";
+
+        case IBLND_MSG_PUT_NAK:
+                return "PUT_NAK";
+
+        case IBLND_MSG_PUT_ACK:
+                return "PUT_ACK";
+
+        case IBLND_MSG_PUT_DONE:
+                return "PUT_DONE";
+
+        case IBLND_MSG_GET_REQ:
+                return "GET_REQ";
+
+        case IBLND_MSG_GET_DONE:
+                return "GET_DONE";
+
+        default:
+                return "???";
+        }
+}
+
+static int
+kiblnd_msgtype2size(int type)
+{
+        const int hdr_size = offsetof(kib_msg_t, ibm_u);
+
+        switch (type) {
+        case IBLND_MSG_CONNREQ:
+        case IBLND_MSG_CONNACK:
+                return hdr_size + sizeof(kib_connparams_t);
+
+        case IBLND_MSG_NOOP:
+                return hdr_size;
+
+        case IBLND_MSG_IMMEDIATE:
+                return offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[0]);
+
+        case IBLND_MSG_PUT_REQ:
+                return hdr_size + sizeof(kib_putreq_msg_t);
+
+        case IBLND_MSG_PUT_ACK:
+                return hdr_size + sizeof(kib_putack_msg_t);
+
+        case IBLND_MSG_GET_REQ:
+                return hdr_size + sizeof(kib_get_msg_t);
+
+        case IBLND_MSG_PUT_NAK:
+        case IBLND_MSG_PUT_DONE:
+        case IBLND_MSG_GET_DONE:
+                return hdr_size + sizeof(kib_completion_msg_t);
+        default:
+                return -1;
+        }
+}
+
+static int
+kiblnd_unpack_rd(kib_msg_t *msg, int flip)
+{
+        kib_rdma_desc_t   *rd;
+        int                nob;
+        int                n;
+        int                i;
+
+        LASSERT (msg->ibm_type == IBLND_MSG_GET_REQ ||
+                 msg->ibm_type == IBLND_MSG_PUT_ACK);
+
+        rd = msg->ibm_type == IBLND_MSG_GET_REQ ?
+                              &msg->ibm_u.get.ibgm_rd :
+                              &msg->ibm_u.putack.ibpam_rd;
+
+        if (flip) {
+                __swab32s(&rd->rd_key);
+                __swab32s(&rd->rd_nfrags);
+        }
+
+        n = rd->rd_nfrags;
+
+        if (n <= 0 || n > IBLND_MAX_RDMA_FRAGS) {
+                CERROR("Bad nfrags: %d, should be 0 < n <= %d\n",
+                       n, IBLND_MAX_RDMA_FRAGS);
+                return 1;
+        }
+
+        nob = offsetof (kib_msg_t, ibm_u) +
+              kiblnd_rd_msg_size(rd, msg->ibm_type, n);
+
+        if (msg->ibm_nob < nob) {
+                CERROR("Short %s: %d(%d)\n",
+                       kiblnd_msgtype2str(msg->ibm_type), msg->ibm_nob, nob);
+                return 1;
+        }
+
+        if (!flip)
+                return 0;
+
+        for (i = 0; i < n; i++) {
+                __swab32s(&rd->rd_frags[i].rf_nob);
+                __swab64s(&rd->rd_frags[i].rf_addr);
+        }
+
+        return 0;
 }
 
 void
-kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg,
+kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg, int version,
                  int credits, lnet_nid_t dstnid, __u64 dststamp)
 {
         kib_net_t *net = ni->ni_data;
@@ -80,7 +195,7 @@ kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg,
         /* CAVEAT EMPTOR! all message fields not set here should have been
          * initialised previously. */
         msg->ibm_magic    = IBLND_MSG_MAGIC;
-        msg->ibm_version  = IBLND_MSG_VERSION;
+        msg->ibm_version  = version;
         /*   ibm_type */
         msg->ibm_credits  = credits;
         /*   ibm_nob */
@@ -101,12 +216,10 @@ kiblnd_unpack_msg(kib_msg_t *msg, int nob)
 {
         const int hdr_size = offsetof(kib_msg_t, ibm_u);
         __u32     msg_cksum;
-        int       flip;
+        __u16     version;
         int       msg_nob;
-#if !IBLND_MAP_ON_DEMAND
-        int       i;
-        int       n;
-#endif
+        int       flip;
+
         /* 6 bytes are enough to have received magic + version */
         if (nob < 6) {
                 CERROR("Short message: %d\n", nob);
@@ -122,9 +235,10 @@ kiblnd_unpack_msg(kib_msg_t *msg, int nob)
                 return -EPROTO;
         }
 
-        if (msg->ibm_version !=
-            (flip ? __swab16(IBLND_MSG_VERSION) : IBLND_MSG_VERSION)) {
-                CERROR("Bad version: %d\n", msg->ibm_version);
+        version = flip ? __swab16(msg->ibm_version) : msg->ibm_version;
+        if (version != IBLND_MSG_VERSION &&
+            version != IBLND_MSG_VERSION_1) {
+                CERROR("Bad version: %x\n", version);
                 return -EPROTO;
         }
 
@@ -148,14 +262,15 @@ kiblnd_unpack_msg(kib_msg_t *msg, int nob)
                 CERROR("Bad checksum\n");
                 return -EPROTO;
         }
+
         msg->ibm_cksum = msg_cksum;
 
         if (flip) {
                 /* leave magic unflipped as a clue to peer endianness */
-                __swab16s(&msg->ibm_version);
+                msg->ibm_version = version;
                 CLASSERT (sizeof(msg->ibm_type) == 1);
                 CLASSERT (sizeof(msg->ibm_credits) == 1);
-                msg->ibm_nob = msg_nob;
+                msg->ibm_nob     = msg_nob;
                 __swab64s(&msg->ibm_srcnid);
                 __swab64s(&msg->ibm_srcstamp);
                 __swab64s(&msg->ibm_dstnid);
@@ -167,128 +282,37 @@ kiblnd_unpack_msg(kib_msg_t *msg, int nob)
                 return -EPROTO;
         }
 
+        if (msg_nob < kiblnd_msgtype2size(msg->ibm_type)) {
+                CERROR("Short %s: %d(%d)\n", kiblnd_msgtype2str(msg->ibm_type),
+                       msg_nob, kiblnd_msgtype2size(msg->ibm_type));
+                return -EPROTO;
+        }
+
         switch (msg->ibm_type) {
         default:
                 CERROR("Unknown message type %x\n", msg->ibm_type);
                 return -EPROTO;
 
         case IBLND_MSG_NOOP:
-                break;
-
         case IBLND_MSG_IMMEDIATE:
-                if (msg_nob < offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[0])) {
-                        CERROR("Short IMMEDIATE: %d(%d)\n", msg_nob,
-                               (int)offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[0]));
-                        return -EPROTO;
-                }
-                break;
-
         case IBLND_MSG_PUT_REQ:
-                if (msg_nob < hdr_size + sizeof(msg->ibm_u.putreq)) {
-                        CERROR("Short PUT_REQ: %d(%d)\n", msg_nob,
-                               (int)(hdr_size + sizeof(msg->ibm_u.putreq)));
-                        return -EPROTO;
-                }
                 break;
 
         case IBLND_MSG_PUT_ACK:
-                if (msg_nob < hdr_size + sizeof(msg->ibm_u.putack)) {
-                        CERROR("Short PUT_ACK: %d(%d)\n", msg_nob,
-                               (int)(hdr_size + sizeof(msg->ibm_u.putack)));
-                        return -EPROTO;
-                }
-#if IBLND_MAP_ON_DEMAND
-                if (flip) {
-                        __swab64s(&msg->ibm_u.putack.ibpam_rd.rd_addr);
-                        __swab32s(&msg->ibm_u.putack.ibpam_rd.rd_nob);
-                        __swab32s(&msg->ibm_u.putack.ibpam_rd.rd_key);
-                }
-#else
-                if (flip) {
-                        __swab32s(&msg->ibm_u.putack.ibpam_rd.rd_key);
-                        __swab32s(&msg->ibm_u.putack.ibpam_rd.rd_nfrags);
-                }
-
-                n = msg->ibm_u.putack.ibpam_rd.rd_nfrags;
-                if (n <= 0 || n > IBLND_MAX_RDMA_FRAGS) {
-                        CERROR("Bad PUT_ACK nfrags: %d, should be 0 < n <= %d\n", 
-                               n, IBLND_MAX_RDMA_FRAGS);
-                        return -EPROTO;
-                }
-
-                if (msg_nob < offsetof(kib_msg_t, ibm_u.putack.ibpam_rd.rd_frags[n])) {
-                        CERROR("Short PUT_ACK: %d(%d)\n", msg_nob,
-                               (int)offsetof(kib_msg_t, ibm_u.putack.ibpam_rd.rd_frags[n]));
-                        return -EPROTO;
-                }
-
-                if (flip) {
-                        for (i = 0; i < n; i++) {
-                                __swab32s(&msg->ibm_u.putack.ibpam_rd.rd_frags[i].rf_nob);
-                                __swab64s(&msg->ibm_u.putack.ibpam_rd.rd_frags[i].rf_addr);
-                        }
-                }
-#endif
-                break;
-
         case IBLND_MSG_GET_REQ:
-                if (msg_nob < hdr_size + sizeof(msg->ibm_u.get)) {
-                        CERROR("Short GET_REQ: %d(%d)\n", msg_nob,
-                               (int)(hdr_size + sizeof(msg->ibm_u.get)));
-                        return -EPROTO;
-                }
-#if IBLND_MAP_ON_DEMAND
-                if (flip) {
-                        __swab64s(&msg->ibm_u.get.ibgm_rd.rd_addr);
-                        __swab32s(&msg->ibm_u.get.ibgm_rd.rd_nob);
-                        __swab32s(&msg->ibm_u.get.ibgm_rd.rd_key);
-                }
-#else
-                if (flip) {
-                        __swab32s(&msg->ibm_u.get.ibgm_rd.rd_key);
-                        __swab32s(&msg->ibm_u.get.ibgm_rd.rd_nfrags);
-                }
-
-                n = msg->ibm_u.get.ibgm_rd.rd_nfrags;
-                if (n <= 0 || n > IBLND_MAX_RDMA_FRAGS) {
-                        CERROR("Bad GET_REQ nfrags: %d, should be 0 < n <= %d\n", 
-                               n, IBLND_MAX_RDMA_FRAGS);
+                if (kiblnd_unpack_rd(msg, flip))
                         return -EPROTO;
-                }
-                
-                if (msg_nob < offsetof(kib_msg_t, ibm_u.get.ibgm_rd.rd_frags[n])) {
-                        CERROR("Short GET_REQ: %d(%d)\n", msg_nob,
-                               (int)offsetof(kib_msg_t, ibm_u.get.ibgm_rd.rd_frags[n]));
-                        return -EPROTO;
-                }
-                
-                if (flip)
-                        for (i = 0; i < msg->ibm_u.get.ibgm_rd.rd_nfrags; i++) {
-                                __swab32s(&msg->ibm_u.get.ibgm_rd.rd_frags[i].rf_nob);
-                                __swab64s(&msg->ibm_u.get.ibgm_rd.rd_frags[i].rf_addr);
-                        }
-#endif
                 break;
 
         case IBLND_MSG_PUT_NAK:
         case IBLND_MSG_PUT_DONE:
         case IBLND_MSG_GET_DONE:
-                if (msg_nob < hdr_size + sizeof(msg->ibm_u.completion)) {
-                        CERROR("Short RDMA completion: %d(%d)\n", msg_nob,
-                               (int)(hdr_size + sizeof(msg->ibm_u.completion)));
-                        return -EPROTO;
-                }
                 if (flip)
                         __swab32s(&msg->ibm_u.completion.ibcm_status);
                 break;
 
         case IBLND_MSG_CONNREQ:
         case IBLND_MSG_CONNACK:
-                if (msg_nob < hdr_size + sizeof(msg->ibm_u.connparams)) {
-                        CERROR("Short connreq/ack: %d(%d)\n", msg_nob,
-                               (int)(hdr_size + sizeof(msg->ibm_u.connparams)));
-                        return -EPROTO;
-                }
                 if (flip) {
                         __swab16s(&msg->ibm_u.connparams.ibcp_queue_depth);
                         __swab16s(&msg->ibm_u.connparams.ibcp_max_frags);
@@ -320,7 +344,7 @@ kiblnd_create_peer (lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
         peer->ibp_ni = ni;
         peer->ibp_nid = nid;
         peer->ibp_error = 0;
-        peer->ibp_last_alive = cfs_time_current();
+        peer->ibp_last_alive = 0;
         atomic_set(&peer->ibp_refcount, 1);     /* 1 ref for caller */
 
         INIT_LIST_HEAD(&peer->ibp_list);       /* not in the peer table yet */
@@ -363,26 +387,6 @@ kiblnd_destroy_peer (kib_peer_t *peer)
         atomic_dec(&net->ibn_npeers);
 }
 
-void
-kiblnd_destroy_dev (kib_dev_t *dev)
-{
-        LASSERT (dev->ibd_nnets == 0);
-
-        if (!list_empty(&dev->ibd_list)) /* on kib_devs? */
-                list_del_init(&dev->ibd_list);
-
-        if (dev->ibd_mr != NULL)
-                ib_dereg_mr(dev->ibd_mr);
-
-        if (dev->ibd_pd != NULL)
-                ib_dealloc_pd(dev->ibd_pd);
-
-        if (dev->ibd_cmid != NULL)
-                rdma_destroy_id(dev->ibd_cmid);
-
-        LIBCFS_FREE(dev, sizeof(*dev));
-}
-
 kib_peer_t *
 kiblnd_find_peer_locked (lnet_nid_t nid)
 {
@@ -403,9 +407,10 @@ kiblnd_find_peer_locked (lnet_nid_t nid)
                 if (peer->ibp_nid != nid)
                         continue;
 
-                CDEBUG(D_NET, "got peer [%p] -> %s (%d)\n",
+                CDEBUG(D_NET, "got peer [%p] -> %s (%d) version: %x\n",
                        peer, libcfs_nid2str(nid),
-                       atomic_read(&peer->ibp_refcount));
+                       atomic_read(&peer->ibp_refcount),
+                       peer->ibp_version);
                 return peer;
         }
         return NULL;
@@ -603,11 +608,12 @@ kiblnd_debug_conn (kib_conn_t *conn)
 
         spin_lock(&conn->ibc_lock);
 
-        CDEBUG(D_CONSOLE, "conn[%d] %p -> %s: \n",
+        CDEBUG(D_CONSOLE, "conn[%d] %p [version %x] -> %s: \n",
                atomic_read(&conn->ibc_refcount), conn,
-               libcfs_nid2str(conn->ibc_peer->ibp_nid));
-        CDEBUG(D_CONSOLE, "   state %d nposted %d cred %d o_cred %d r_cred %d\n",
-               conn->ibc_state, conn->ibc_nsends_posted, conn->ibc_credits, 
+               conn->ibc_version, libcfs_nid2str(conn->ibc_peer->ibp_nid));
+        CDEBUG(D_CONSOLE, "   state %d nposted %d/%d cred %d o_cred %d r_cred %d\n",
+               conn->ibc_state, conn->ibc_noops_posted,
+               conn->ibc_nsends_posted, conn->ibc_credits,
                conn->ibc_outstanding_credits, conn->ibc_reserved_credits);
         CDEBUG(D_CONSOLE, "   comms_err %d\n", conn->ibc_comms_error);
 
@@ -615,10 +621,6 @@ kiblnd_debug_conn (kib_conn_t *conn)
         list_for_each(tmp, &conn->ibc_early_rxs)
                 kiblnd_debug_rx(list_entry(tmp, kib_rx_t, rx_list));
 
-        CDEBUG(D_CONSOLE, "   tx_noops:\n");
-        list_for_each(tmp, &conn->ibc_tx_noops)
-                kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
-
         CDEBUG(D_CONSOLE, "   tx_queue_nocred:\n");
         list_for_each(tmp, &conn->ibc_tx_queue_nocred)
                 kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
@@ -636,14 +638,56 @@ kiblnd_debug_conn (kib_conn_t *conn)
                 kiblnd_debug_tx(list_entry(tmp, kib_tx_t, tx_list));
 
         CDEBUG(D_CONSOLE, "   rxs:\n");
-        for (i = 0; i < IBLND_RX_MSGS; i++)
+        for (i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++)
                 kiblnd_debug_rx(&conn->ibc_rxs[i]);
 
         spin_unlock(&conn->ibc_lock);
 }
 
+int
+kiblnd_translate_mtu(int value)
+{
+        switch (value) {
+        default:
+                return -1;
+        case 0:
+                return 0;
+        case 256:
+                return IB_MTU_256;
+        case 512:
+                return IB_MTU_512;
+        case 1024:
+                return IB_MTU_1024;
+        case 2048:
+                return IB_MTU_2048;
+        case 4096:
+                return IB_MTU_4096;
+        }
+}
+
+static void
+kiblnd_setup_mtu(struct rdma_cm_id *cmid)
+{
+        unsigned long flags;
+        int           mtu;
+
+        /* XXX There is no path record for iWARP, set by netdev->change_mtu? */
+        if (cmid->route.path_rec == NULL)
+                return;
+
+        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
+
+        mtu = kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu);
+        LASSERT (mtu >= 0);
+        if (mtu != 0)
+                cmid->route.path_rec->mtu = mtu;
+
+        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
+}
+
 kib_conn_t *
-kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid, int state)
+kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
+                   int state, int version)
 {
         /* CAVEAT EMPTOR:
          * If the new conn is created successfully it takes over the caller's
@@ -652,15 +696,13 @@ kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid, int state)
          * she must dispose of 'cmid'.  (Actually I'd block forever if I tried
          * to destroy 'cmid' here since I'm called from the CM which still has
          * its ref on 'cmid'). */
-        kib_conn_t             *conn;
         kib_net_t              *net = peer->ibp_ni->ni_data;
-        int                     i;
-        int                     page_offset;
-        int                     ipage;
-        int                     rc;
-        struct ib_cq           *cq;
         struct ib_qp_init_attr *init_qp_attr;
+        kib_conn_t             *conn;
+        struct ib_cq           *cq;
         unsigned long           flags;
+        int                     rc;
+        int                     i;
 
         LASSERT (net != NULL);
         LASSERT (!in_interrupt());
@@ -682,12 +724,12 @@ kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid, int state)
         memset(conn, 0, sizeof(*conn)); /* zero flags, NULL pointers etc... */
 
         conn->ibc_state = IBLND_CONN_INIT;
+        conn->ibc_version = version;
         conn->ibc_peer = peer;                  /* I take the caller's ref */
         cmid->context = conn;                   /* for future CM callbacks */
         conn->ibc_cmid = cmid;
 
         INIT_LIST_HEAD(&conn->ibc_early_rxs);
-        INIT_LIST_HEAD(&conn->ibc_tx_noops);
         INIT_LIST_HEAD(&conn->ibc_tx_queue);
         INIT_LIST_HEAD(&conn->ibc_tx_queue_rsrvd);
         INIT_LIST_HEAD(&conn->ibc_tx_queue_nocred);
@@ -701,70 +743,50 @@ kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid, int state)
         }
         memset(conn->ibc_connvars, 0, sizeof(*conn->ibc_connvars));
 
-        LIBCFS_ALLOC(conn->ibc_rxs, IBLND_RX_MSGS * sizeof(kib_rx_t));
+        LIBCFS_ALLOC(conn->ibc_rxs, IBLND_RX_MSGS(version) * sizeof(kib_rx_t));
         if (conn->ibc_rxs == NULL) {
                 CERROR("Cannot allocate RX buffers\n");
                 goto failed_2;
         }
-        memset(conn->ibc_rxs, 0, IBLND_RX_MSGS * sizeof(kib_rx_t));
+        memset(conn->ibc_rxs, 0, IBLND_RX_MSGS(version) * sizeof(kib_rx_t));
 
-        rc = kiblnd_alloc_pages(&conn->ibc_rx_pages, IBLND_RX_MSG_PAGES);
+        rc = kiblnd_alloc_pages(&conn->ibc_rx_pages,
+                                IBLND_RX_MSG_PAGES(version));
         if (rc != 0)
                 goto failed_2;
 
-        for (i = ipage = page_offset = 0; i < IBLND_RX_MSGS; i++) {
-                struct page *page = conn->ibc_rx_pages->ibp_pages[ipage];
-                kib_rx_t    *rx = &conn->ibc_rxs[i];
-
-                rx->rx_conn = conn;
-                rx->rx_msg = (kib_msg_t *)(((char *)page_address(page)) +
-                                           page_offset);
-                rx->rx_msgaddr = kiblnd_dma_map_single(cmid->device,
-                                                       rx->rx_msg, IBLND_MSG_SIZE,
-                                                       DMA_FROM_DEVICE);
-                KIBLND_UNMAP_ADDR_SET(rx, rx_msgunmap, rx->rx_msgaddr);
-
-                CDEBUG(D_NET,"rx %d: %p "LPX64"("LPX64")\n",
-                       i, rx->rx_msg, rx->rx_msgaddr,
-                       lnet_page2phys(page) + page_offset);
-
-                page_offset += IBLND_MSG_SIZE;
-                LASSERT (page_offset <= PAGE_SIZE);
-
-                if (page_offset == PAGE_SIZE) {
-                        page_offset = 0;
-                        ipage++;
-                        LASSERT (ipage <= IBLND_RX_MSG_PAGES);
-                }
-        }
+        kiblnd_map_rx_descs(conn);
 
 #ifdef HAVE_OFED_IB_COMP_VECTOR
         cq = ib_create_cq(cmid->device,
                           kiblnd_cq_completion, kiblnd_cq_event, conn,
-                          IBLND_CQ_ENTRIES(), 0);
+                          IBLND_CQ_ENTRIES(version), 0);
 #else
         cq = ib_create_cq(cmid->device,
                           kiblnd_cq_completion, kiblnd_cq_event, conn,
-                          IBLND_CQ_ENTRIES());
+                          IBLND_CQ_ENTRIES(version));
 #endif
-        if (!IS_ERR(cq)) {
-                conn->ibc_cq = cq;
-        } else {
-                CERROR("Can't create CQ: %ld\n", PTR_ERR(cq));
+        if (IS_ERR(cq)) {
+                CERROR("Can't create CQ: %ld, cqe: %d\n",
+                       PTR_ERR(cq), IBLND_CQ_ENTRIES(version));
                 goto failed_2;
         }
 
+        conn->ibc_cq = cq;
+
         rc = ib_req_notify_cq(cq, IB_CQ_NEXT_COMP);
         if (rc != 0) {
                 CERROR("Can't request completion notificiation: %d\n", rc);
                 goto failed_2;
         }
 
+        kiblnd_setup_mtu(cmid);
+
         memset(init_qp_attr, 0, sizeof(*init_qp_attr));
         init_qp_attr->event_handler = kiblnd_qp_event;
         init_qp_attr->qp_context = conn;
-        init_qp_attr->cap.max_send_wr = IBLND_SEND_WRS;
-        init_qp_attr->cap.max_recv_wr = IBLND_RECV_WRS;
+        init_qp_attr->cap.max_send_wr = IBLND_SEND_WRS(version);
+        init_qp_attr->cap.max_recv_wr = IBLND_RECV_WRS(version);
         init_qp_attr->cap.max_send_sge = 1;
         init_qp_attr->cap.max_recv_sge = 1;
         init_qp_attr->sq_sig_type = IB_SIGNAL_REQ_WR;
@@ -772,54 +794,22 @@ kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid, int state)
         init_qp_attr->send_cq = cq;
         init_qp_attr->recv_cq = cq;
 
-        rc = 0;
-        write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
-        switch (*kiblnd_tunables.kib_ib_mtu) {
-        default:
-                rc = *kiblnd_tunables.kib_ib_mtu;
-                /* fall through to... */
-        case 0: /* set tunable to the default
-                 * CAVEAT EMPTOR! this assumes the default is one of the MTUs
-                 * below, otherwise we'll WARN on the next QP create */
-                *kiblnd_tunables.kib_ib_mtu =
-                        ib_mtu_enum_to_int(cmid->route.path_rec->mtu);
-                break;
-        case 256:
-                cmid->route.path_rec->mtu = IB_MTU_256;
-                break;
-        case 512:
-                cmid->route.path_rec->mtu = IB_MTU_512;
-                break;
-        case 1024:
-                cmid->route.path_rec->mtu = IB_MTU_1024;
-                break;
-        case 2048:
-                cmid->route.path_rec->mtu = IB_MTU_2048;
-                break;
-        case 4096:
-                cmid->route.path_rec->mtu = IB_MTU_4096;
-                break;
-        }
-        write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
-
-        if (rc != 0)
-                CWARN("Invalid IB MTU value %d, using default value %d\n",
-                      rc, *kiblnd_tunables.kib_ib_mtu);
-                                
         rc = rdma_create_qp(cmid, net->ibn_dev->ibd_pd, init_qp_attr);
         if (rc != 0) {
-                CERROR("Can't create QP: %d\n", rc);
+                CERROR("Can't create QP: %d, send_wr: %d, recv_wr: %d\n",
+                       rc, init_qp_attr->cap.max_send_wr,
+                       init_qp_attr->cap.max_recv_wr);
                 goto failed_2;
         }
 
         LIBCFS_FREE(init_qp_attr, sizeof(*init_qp_attr));
 
         /* 1 ref for caller and each rxmsg */
-        atomic_set(&conn->ibc_refcount, 1 + IBLND_RX_MSGS);
-        conn->ibc_nrx = IBLND_RX_MSGS;
+        atomic_set(&conn->ibc_refcount, 1 + IBLND_RX_MSGS(version));
+        conn->ibc_nrx = IBLND_RX_MSGS(version);
 
         /* post receives */
-        for (i = 0; i < IBLND_RX_MSGS; i++) {
+        for (i = 0; i < IBLND_RX_MSGS(version); i++) {
                 rc = kiblnd_post_rx(&conn->ibc_rxs[i],
                                     IBLND_POSTRX_NO_CREDIT);
                 if (rc != 0) {
@@ -831,18 +821,24 @@ kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid, int state)
                         /* correct # of posted buffers 
                          * NB locking needed now I'm racing with completion */
                         spin_lock_irqsave(&kiblnd_data.kib_sched_lock, flags);
-                        conn->ibc_nrx -= IBLND_RX_MSGS - i;
+                        conn->ibc_nrx -= IBLND_RX_MSGS(version) - i;
                         spin_unlock_irqrestore(&kiblnd_data.kib_sched_lock,
                                                flags);
 
+                        /* cmid will be destroyed by CM(ofed) after cm_callback
+                         * returned, so we can't refer it anymore
+                         * (by kiblnd_connd()->kiblnd_destroy_conn) */
+                        rdma_destroy_qp(conn->ibc_cmid);
+                        conn->ibc_cmid = NULL;
+
                         /* Drop my own and unused rxbuffer refcounts */
-                        while (i++ <= IBLND_RX_MSGS)
+                        while (i++ <= IBLND_RX_MSGS(version))
                                 kiblnd_conn_decref(conn);
 
                         return NULL;
                 }
         }
-        
+
         /* Init successful! */
         LASSERT (state == IBLND_CONN_ACTIVE_CONNECT ||
                  state == IBLND_CONN_PASSIVE_WAIT);
@@ -866,16 +862,15 @@ kiblnd_destroy_conn (kib_conn_t *conn)
         struct rdma_cm_id *cmid = conn->ibc_cmid;
         kib_peer_t        *peer = conn->ibc_peer;
         int                rc;
-        int                i;
 
         LASSERT (!in_interrupt());
         LASSERT (atomic_read(&conn->ibc_refcount) == 0);
         LASSERT (list_empty(&conn->ibc_early_rxs));
-        LASSERT (list_empty(&conn->ibc_tx_noops));
         LASSERT (list_empty(&conn->ibc_tx_queue));
         LASSERT (list_empty(&conn->ibc_tx_queue_rsrvd));
         LASSERT (list_empty(&conn->ibc_tx_queue_nocred));
         LASSERT (list_empty(&conn->ibc_active_txs));
+        LASSERT (conn->ibc_noops_posted == 0);
         LASSERT (conn->ibc_nsends_posted == 0);
 
         switch (conn->ibc_state) {
@@ -892,7 +887,8 @@ kiblnd_destroy_conn (kib_conn_t *conn)
                 break;
         }
 
-        if (cmid->qp != NULL)
+        /* conn->ibc_cmid might be destroyed by CM already */
+        if (cmid != NULL && cmid->qp != NULL)
                 rdma_destroy_qp(cmid);
 
         if (conn->ibc_cq != NULL) {
@@ -901,26 +897,12 @@ kiblnd_destroy_conn (kib_conn_t *conn)
                         CWARN("Error destroying CQ: %d\n", rc);
         }
 
-        if (conn->ibc_rx_pages != NULL) {
-                LASSERT (conn->ibc_rxs != NULL);
-
-                for (i = 0; i < IBLND_RX_MSGS; i++) {
-                        kib_rx_t *rx = &conn->ibc_rxs[i];
-
-                        LASSERT (rx->rx_nob >= 0); /* not posted */
-
-                        kiblnd_dma_unmap_single(cmid->device,
-                                                KIBLND_UNMAP_ADDR(rx, rx_msgunmap,
-                                                                  rx->rx_msgaddr),
-                                                IBLND_MSG_SIZE, DMA_FROM_DEVICE);
-                }
-
-                kiblnd_free_pages(conn->ibc_rx_pages);
-        }
+        if (conn->ibc_rx_pages != NULL)
+                kiblnd_unmap_rx_descs(conn);
 
         if (conn->ibc_rxs != NULL) {
                 LIBCFS_FREE(conn->ibc_rxs,
-                            IBLND_RX_MSGS * sizeof(kib_rx_t));
+                            IBLND_RX_MSGS(conn->ibc_version) * sizeof(kib_rx_t));
         }
 
         if (conn->ibc_connvars != NULL)
@@ -949,15 +931,21 @@ kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why)
         list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
                 conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                count++;
+                CDEBUG(D_NET, "Closing conn -> %s, "
+                              "version: %x, reason: %d\n",
+                       libcfs_nid2str(peer->ibp_nid),
+                       conn->ibc_version, why);
+
                 kiblnd_close_conn_locked(conn, why);
+                count++;
         }
 
         return count;
 }
 
 int
-kiblnd_close_stale_conns_locked (kib_peer_t *peer, __u64 incarnation)
+kiblnd_close_stale_conns_locked (kib_peer_t *peer,
+                                 int version, __u64 incarnation)
 {
         kib_conn_t         *conn;
         struct list_head   *ctmp;
@@ -967,15 +955,18 @@ kiblnd_close_stale_conns_locked (kib_peer_t *peer, __u64 incarnation)
         list_for_each_safe (ctmp, cnxt, &peer->ibp_conns) {
                 conn = list_entry(ctmp, kib_conn_t, ibc_list);
 
-                if (conn->ibc_incarnation == incarnation)
+                if (conn->ibc_version     == version &&
+                    conn->ibc_incarnation == incarnation)
                         continue;
 
-                CDEBUG(D_NET, "Closing stale conn -> %s incarnation:"LPX64"("LPX64")\n",
+                CDEBUG(D_NET, "Closing stale conn -> %s version: %x, "
+                              "incarnation:"LPX64"(%x, "LPX64")\n",
                        libcfs_nid2str(peer->ibp_nid),
-                       conn->ibc_incarnation, incarnation);
+                       conn->ibc_version, conn->ibc_incarnation,
+                       version, incarnation);
 
-                count++;
                 kiblnd_close_conn_locked(conn, -ESTALE);
+                count++;
         }
 
         return count;
@@ -1052,16 +1043,23 @@ kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
                 break;
         }
         case IOC_LIBCFS_GET_CONN: {
-                kib_conn_t *conn = kiblnd_get_conn_by_idx(ni, data->ioc_count);
+                kib_conn_t *conn;
 
+                rc = 0;
+                conn = kiblnd_get_conn_by_idx(ni, data->ioc_count);
                 if (conn == NULL) {
                         rc = -ENOENT;
-                } else {
-                        // kiblnd_debug_conn(conn);
-                        rc = 0;
-                        data->ioc_nid = conn->ibc_peer->ibp_nid;
-                        kiblnd_conn_decref(conn);
+                        break;
                 }
+
+                LASSERT (conn->ibc_cmid != NULL);
+                data->ioc_nid = conn->ibc_peer->ibp_nid;
+                if (conn->ibc_cmid->route.path_rec == NULL)
+                        data->ioc_u32[0] = 0; /* iWarp has no path MTU */
+                else
+                        data->ioc_u32[0] =
+                        ib_mtu_enum_to_int(conn->ibc_cmid->route.path_rec->mtu);
+                kiblnd_conn_decref(conn);
                 break;
         }
         case IOC_LIBCFS_CLOSE_CONNECTION: {
@@ -1077,11 +1075,44 @@ kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
 }
 
 void
+kiblnd_query (lnet_ni_t *ni, lnet_nid_t nid, time_t *when)
+{
+        cfs_time_t     last_alive = 0;
+        rwlock_t      *glock = &kiblnd_data.kib_global_lock;
+        kib_peer_t    *peer;
+        unsigned long  flags;
+
+        read_lock_irqsave(glock, flags);
+
+        peer = kiblnd_find_peer_locked(nid);
+        if (peer != NULL) {
+                LASSERT (peer->ibp_connecting > 0 || /* creating conns */
+                         peer->ibp_accepting > 0 ||
+                         !list_empty(&peer->ibp_conns));  /* active conn */
+                last_alive = peer->ibp_last_alive;
+        }
+
+        read_unlock_irqrestore(glock, flags);
+
+        if (last_alive != 0)
+                *when = cfs_time_current_sec() -
+                        cfs_duration_sec(cfs_time_current() - last_alive);
+
+        /* peer is not persistent in hash, trigger peer creation
+         * and connection establishment with a NULL tx */
+        if (peer == NULL)
+                kiblnd_launch_tx(ni, NULL, nid);
+        return;
+}
+
+void
 kiblnd_free_pages (kib_pages_t *p)
 {
         int         npages = p->ibp_npages;
         int         i;
 
+        LASSERT (p->ibp_device == NULL);
+
         for (i = 0; i < npages; i++)
                 if (p->ibp_pages[i] != NULL)
                         __free_page(p->ibp_pages[i]);
@@ -1118,179 +1149,1075 @@ kiblnd_alloc_pages (kib_pages_t **pp, int npages)
 }
 
 void
-kiblnd_free_tx_descs (lnet_ni_t *ni)
+kiblnd_unmap_rx_descs(kib_conn_t *conn)
 {
-        int        i;
-        kib_net_t *net = ni->ni_data;
+        kib_rx_t *rx;
+        int       i;
+
+        LASSERT (conn->ibc_rxs != NULL);
+        LASSERT (conn->ibc_rx_pages->ibp_device != NULL);
+
+        for (i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++) {
+                rx = &conn->ibc_rxs[i];
+
+                LASSERT (rx->rx_nob >= 0); /* not posted */
+
+                kiblnd_dma_unmap_single(conn->ibc_rx_pages->ibp_device,
+                                        KIBLND_UNMAP_ADDR(rx, rx_msgunmap,
+                                                          rx->rx_msgaddr),
+                                        IBLND_MSG_SIZE, DMA_FROM_DEVICE);
+        }
+
+        conn->ibc_rx_pages->ibp_device = NULL;
+
+        kiblnd_free_pages(conn->ibc_rx_pages);
+
+        conn->ibc_rx_pages = NULL;
+}
+
+void
+kiblnd_map_rx_descs(kib_conn_t *conn)
+{
+        kib_rx_t       *rx;
+        struct page    *pg;
+        int             pg_off;
+        int             ipg;
+        int             i;
+
+        for (pg_off = ipg = i = 0;
+             i < IBLND_RX_MSGS(conn->ibc_version); i++) {
+                pg = conn->ibc_rx_pages->ibp_pages[ipg];
+                rx = &conn->ibc_rxs[i];
+
+                rx->rx_conn = conn;
+                rx->rx_msg = (kib_msg_t *)(((char *)page_address(pg)) + pg_off);
+
+                rx->rx_msgaddr = kiblnd_dma_map_single(conn->ibc_cmid->device,
+                                                       rx->rx_msg, IBLND_MSG_SIZE,
+                                                       DMA_FROM_DEVICE);
+                LASSERT (!kiblnd_dma_mapping_error(conn->ibc_cmid->device,
+                                                   rx->rx_msgaddr));
+                KIBLND_UNMAP_ADDR_SET(rx, rx_msgunmap, rx->rx_msgaddr);
+
+                CDEBUG(D_NET,"rx %d: %p "LPX64"("LPX64")\n",
+                       i, rx->rx_msg, rx->rx_msgaddr,
+                       lnet_page2phys(pg) + pg_off);
+
+                pg_off += IBLND_MSG_SIZE;
+                LASSERT (pg_off <= PAGE_SIZE);
+
+                if (pg_off == PAGE_SIZE) {
+                        pg_off = 0;
+                        ipg++;
+                        LASSERT (ipg <= IBLND_RX_MSG_PAGES(conn->ibc_version));
+                }
+        }
+
+        conn->ibc_rx_pages->ibp_device = conn->ibc_cmid->device;
+}
+
+static void
+kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
+{
+        kib_tx_t       *tx;
+        int             i;
+
+        LASSERT (tpo->tpo_pool.po_allocated == 0);
+        LASSERT (tpo->tpo_tx_pages->ibp_device != NULL);
+
+        for (i = 0; i < tpo->tpo_pool.po_size; i++) {
+                tx = &tpo->tpo_tx_descs[i];
+                kiblnd_dma_unmap_single(tpo->tpo_tx_pages->ibp_device,
+                                        KIBLND_UNMAP_ADDR(tx, tx_msgunmap,
+                                                          tx->tx_msgaddr),
+                                        IBLND_MSG_SIZE, DMA_TO_DEVICE);
+        }
+        tpo->tpo_tx_pages->ibp_device = NULL;
+}
+
+static void
+kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
+{
+        kib_pages_t    *txpgs = tpo->tpo_tx_pages;
+        kib_pool_t     *pool  = &tpo->tpo_pool;
+        kib_net_t      *net   = pool->po_owner->ps_net;
+        struct page    *page;
+        kib_tx_t       *tx;
+        int             page_offset;
+        int             ipage;
+        int             i;
 
         LASSERT (net != NULL);
+        LASSERT (net->ibn_dev->ibd_cmid != NULL &&
+                 net->ibn_dev->ibd_cmid->device != NULL);
 
-        if (net->ibn_tx_descs != NULL) {
-                for (i = 0; i < IBLND_TX_MSGS(); i++) {
-                        kib_tx_t *tx = &net->ibn_tx_descs[i];
+        /* pre-mapped messages are not bigger than 1 page */
+        CLASSERT (IBLND_MSG_SIZE <= PAGE_SIZE);
 
-#if IBLND_MAP_ON_DEMAND
-                        if (tx->tx_pages != NULL)
-                                LIBCFS_FREE(tx->tx_pages, LNET_MAX_IOV *
-                                            sizeof(*tx->tx_pages));
-#else
-                        if (tx->tx_wrq != NULL)
-                                LIBCFS_FREE(tx->tx_wrq, 
-                                            (1 + IBLND_MAX_RDMA_FRAGS) * 
-                                            sizeof(*tx->tx_wrq));
-
-                        if (tx->tx_sge != NULL)
-                                LIBCFS_FREE(tx->tx_sge, 
-                                            (1 + IBLND_MAX_RDMA_FRAGS) * 
-                                            sizeof(*tx->tx_sge));
-
-                        if (tx->tx_rd != NULL)
-                                LIBCFS_FREE(tx->tx_rd, 
-                                            offsetof(kib_rdma_desc_t, 
-                                               rd_frags[IBLND_MAX_RDMA_FRAGS]));
-
-                        if (tx->tx_frags != NULL)
-                                LIBCFS_FREE(tx->tx_frags, 
-                                            IBLND_MAX_RDMA_FRAGS *
-                                            sizeof(*tx->tx_frags));
-#endif
+        /* No fancy arithmetic when we do the buffer calculations */
+        CLASSERT (PAGE_SIZE % IBLND_MSG_SIZE == 0);
+
+        txpgs->ibp_device = net->ibn_dev->ibd_cmid->device;
+
+        for (ipage = page_offset = i = 0; i < pool->po_size; i++) {
+                page = txpgs->ibp_pages[ipage];
+                tx = &tpo->tpo_tx_descs[i];
+
+                tx->tx_msg = (kib_msg_t *)(((char *)page_address(page)) +
+                                           page_offset);
+
+                tx->tx_msgaddr = kiblnd_dma_map_single(
+                        txpgs->ibp_device, tx->tx_msg,
+                        IBLND_MSG_SIZE, DMA_TO_DEVICE);
+                LASSERT (!kiblnd_dma_mapping_error(txpgs->ibp_device,
+                                                   tx->tx_msgaddr));
+                KIBLND_UNMAP_ADDR_SET(tx, tx_msgunmap, tx->tx_msgaddr);
+
+                list_add(&tx->tx_list, &pool->po_free_list);
+
+                page_offset += IBLND_MSG_SIZE;
+                LASSERT (page_offset <= PAGE_SIZE);
+
+                if (page_offset == PAGE_SIZE) {
+                        page_offset = 0;
+                        ipage++;
+                        LASSERT (ipage <= txpgs->ibp_npages);
                 }
+        }
+}
+
+struct ib_mr *
+kiblnd_find_dma_mr(kib_net_t *net, __u64 addr, __u64 size)
+{
+        __u64   index;
+
+        LASSERT (net->ibn_dev->ibd_mrs[0] != NULL);
 
-                LIBCFS_FREE(net->ibn_tx_descs,
-                            IBLND_TX_MSGS() * sizeof(kib_tx_t));
+        if (net->ibn_dev->ibd_nmrs == 1)
+                return net->ibn_dev->ibd_mrs[0];
+
+        index = addr >> net->ibn_dev->ibd_mr_shift;
+
+        if (index <  net->ibn_dev->ibd_nmrs &&
+            index == ((addr + size - 1) >> net->ibn_dev->ibd_mr_shift))
+                return net->ibn_dev->ibd_mrs[index];
+
+        return NULL;
+}
+
+struct ib_mr *
+kiblnd_find_rd_dma_mr(kib_net_t *net, kib_rdma_desc_t *rd)
+{
+        struct ib_mr *prev_mr;
+        struct ib_mr *mr;
+        int           i;
+
+        LASSERT (net->ibn_dev->ibd_mrs[0] != NULL);
+
+        if (*kiblnd_tunables.kib_map_on_demand > 0 &&
+            *kiblnd_tunables.kib_map_on_demand <= rd->rd_nfrags)
+                return NULL;
+
+        if (net->ibn_dev->ibd_nmrs == 1)
+                return net->ibn_dev->ibd_mrs[0];
+
+        for (i = 0, mr = prev_mr = NULL;
+             i < rd->rd_nfrags; i++) {
+                mr = kiblnd_find_dma_mr(net,
+                                        rd->rd_frags[i].rf_addr,
+                                        rd->rd_frags[i].rf_nob);
+                if (prev_mr == NULL)
+                        prev_mr = mr;
+
+                if (mr == NULL || prev_mr != mr) {
+                        /* Can't covered by one single MR */
+                        mr = NULL;
+                        break;
+                }
         }
 
-        if (net->ibn_tx_pages != NULL)
-                kiblnd_free_pages(net->ibn_tx_pages);
+        return mr;
 }
 
-int
-kiblnd_alloc_tx_descs (lnet_ni_t *ni)
+void
+kiblnd_destroy_fmr_pool(kib_fmr_pool_t *pool)
 {
-        int        i;
-        int        rc;
-        kib_net_t *net = ni->ni_data;
+        LASSERT (pool->fpo_map_count == 0);
 
-        LASSERT (net != NULL);
+        if (pool->fpo_fmr_pool != NULL)
+                ib_destroy_fmr_pool(pool->fpo_fmr_pool);
 
-        rc = kiblnd_alloc_pages(&net->ibn_tx_pages, IBLND_TX_MSG_PAGES());
+        LIBCFS_FREE(pool, sizeof(kib_fmr_pool_t));
+}
 
-        if (rc != 0) {
-                CERROR("Can't allocate tx pages\n");
+void
+kiblnd_destroy_fmr_pool_list(struct list_head *head)
+{
+        kib_fmr_pool_t *pool;
+
+        while (!list_empty(head)) {
+                pool = list_entry(head->next, kib_fmr_pool_t, fpo_list);
+                list_del(&pool->fpo_list);
+                kiblnd_destroy_fmr_pool(pool);
+        }
+}
+
+int
+kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t **pp_fpo)
+{
+        /* FMR pool for RDMA */
+        kib_fmr_pool_t          *fpo;
+        struct ib_fmr_pool_param param = {
+                .max_pages_per_fmr = LNET_MAX_PAYLOAD/PAGE_SIZE,
+                .page_shift        = PAGE_SHIFT,
+                .access            = (IB_ACCESS_LOCAL_WRITE |
+                                      IB_ACCESS_REMOTE_WRITE),
+                .pool_size         = *kiblnd_tunables.kib_fmr_pool_size,
+                .dirty_watermark   = *kiblnd_tunables.kib_fmr_flush_trigger,
+                .flush_function    = NULL,
+                .flush_arg         = NULL,
+                .cache             = !!*kiblnd_tunables.kib_fmr_cache};
+        int rc;
+
+        LASSERT (fps->fps_net->ibn_dev != NULL &&
+                 fps->fps_net->ibn_dev->ibd_pd != NULL);
+
+        LIBCFS_ALLOC(fpo, sizeof(kib_fmr_pool_t));
+        if (fpo == NULL)
+                return -ENOMEM;
+
+        memset(fpo, 0, sizeof(kib_fmr_pool_t));
+        fpo->fpo_fmr_pool = ib_create_fmr_pool(fps->fps_net->ibn_dev->ibd_pd, &param);
+        if (IS_ERR(fpo->fpo_fmr_pool)) {
+                CERROR("Failed to create FMR pool: %ld\n",
+                       PTR_ERR(fpo->fpo_fmr_pool));
+                rc = PTR_ERR(fpo->fpo_fmr_pool);
+                LIBCFS_FREE(fpo, sizeof(kib_fmr_pool_t));
                 return rc;
         }
 
-        LIBCFS_ALLOC (net->ibn_tx_descs,
-                      IBLND_TX_MSGS() * sizeof(kib_tx_t));
-        if (net->ibn_tx_descs == NULL) {
-                CERROR("Can't allocate %d tx descriptors\n", IBLND_TX_MSGS());
+        fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+        fpo->fpo_owner    = fps;
+        *pp_fpo = fpo;
+
+        return 0;
+}
+
+static void
+kiblnd_fini_fmr_pool_set(kib_fmr_poolset_t *fps)
+{
+        kiblnd_destroy_fmr_pool_list(&fps->fps_pool_list);
+}
+
+static int
+kiblnd_init_fmr_pool_set(kib_fmr_poolset_t *fps, kib_net_t *net)
+{
+        kib_fmr_pool_t *fpo;
+        int             rc;
+
+        memset(fps, 0, sizeof(kib_fmr_poolset_t));
+
+        fps->fps_net = net;
+        spin_lock_init(&fps->fps_lock);
+        CFS_INIT_LIST_HEAD(&fps->fps_pool_list);
+        rc = kiblnd_create_fmr_pool(fps, &fpo);
+        if (rc == 0)
+                list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
+
+        return rc;
+}
+
+void
+kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
+{
+        CFS_LIST_HEAD     (zombies);
+        kib_fmr_pool_t    *fpo = fmr->fmr_pool;
+        kib_fmr_poolset_t *fps = fpo->fpo_owner;
+        kib_fmr_pool_t    *tmp;
+        int                rc;
+
+        rc = ib_fmr_pool_unmap(fmr->fmr_pfmr);
+        LASSERT (rc == 0);
+
+        if (status != 0) {
+                rc = ib_flush_fmr_pool(fpo->fpo_fmr_pool);
+                LASSERT (rc == 0);
+        }
+
+        fmr->fmr_pool = NULL;
+        fmr->fmr_pfmr = NULL;
+
+        spin_lock(&fps->fps_lock);
+        fpo->fpo_map_count --;  /* decref the pool */
+
+        list_for_each_entry_safe(fpo, tmp, &fps->fps_pool_list, fpo_list) {
+                /* the first pool is persistent */
+                if (fps->fps_pool_list.next == &fpo->fpo_list)
+                        continue;
+
+                if (fpo->fpo_map_count == 0 &&  /* no more reference */
+                    cfs_time_aftereq(cfs_time_current(), fpo->fpo_deadline)) {
+                        list_move(&fpo->fpo_list, &zombies);
+                        fps->fps_version ++;
+                }
+        }
+        spin_unlock(&fps->fps_lock);
+
+        if (!list_empty(&zombies))
+                kiblnd_destroy_fmr_pool_list(&zombies);
+}
+
+int
+kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
+                    __u64 iov, kib_fmr_t *fmr)
+{
+        struct ib_pool_fmr *pfmr;
+        kib_fmr_pool_t     *fpo;
+        __u64               version;
+        int                 rc;
+
+        LASSERT (fps->fps_net->ibn_with_fmr);
+ again:
+        spin_lock(&fps->fps_lock);
+        version = fps->fps_version;
+        list_for_each_entry(fpo, &fps->fps_pool_list, fpo_list) {
+                fpo->fpo_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+                fpo->fpo_map_count ++;
+                spin_unlock(&fps->fps_lock);
+
+                pfmr = ib_fmr_pool_map_phys(fpo->fpo_fmr_pool,
+                                            pages, npages, iov);
+                if (likely(!IS_ERR(pfmr))) {
+                        fmr->fmr_pool = fpo;
+                        fmr->fmr_pfmr = pfmr;
+                        return 0;
+                }
+
+                spin_lock(&fps->fps_lock);
+                fpo->fpo_map_count --;
+                if (PTR_ERR(pfmr) != -EAGAIN) {
+                        spin_unlock(&fps->fps_lock);
+                        return PTR_ERR(pfmr);
+                }
+
+                /* EAGAIN and ... */
+                if (version != fps->fps_version) {
+                        spin_unlock(&fps->fps_lock);
+                        goto again;
+                }
+        }
+
+        if (fps->fps_increasing) {
+                spin_unlock(&fps->fps_lock);
+                CDEBUG(D_NET, "Another thread is allocating new "
+                              "FMR pool, waiting for her to complete\n");
+                schedule();
+                goto again;
+
+        }
+
+        if (cfs_time_before(cfs_time_current(), fps->fps_next_retry)) {
+                /* someone failed recently */
+                spin_unlock(&fps->fps_lock);
+                return -EAGAIN;
+        }
+
+        fps->fps_increasing = 1;
+        spin_unlock(&fps->fps_lock);
+
+        CDEBUG(D_NET, "Allocate new FMR pool\n");
+        rc = kiblnd_create_fmr_pool(fps, &fpo);
+        spin_lock(&fps->fps_lock);
+        fps->fps_increasing = 0;
+        if (rc == 0) {
+                fps->fps_version ++;
+                list_add_tail(&fpo->fpo_list, &fps->fps_pool_list);
+        } else {
+                fps->fps_next_retry = cfs_time_shift(10);
+        }
+        spin_unlock(&fps->fps_lock);
+
+        goto again;
+}
+
+static void
+kiblnd_fini_pool(kib_pool_t *pool)
+{
+        LASSERT (list_empty(&pool->po_free_list));
+        LASSERT (pool->po_allocated == 0);
+
+        CDEBUG(D_NET, "Finalize %s pool\n", pool->po_owner->ps_name);
+}
+
+static void
+kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int size)
+{
+        CDEBUG(D_NET, "Initialize %s pool\n", ps->ps_name);
+
+        memset(pool, 0, sizeof(kib_pool_t));
+        CFS_INIT_LIST_HEAD(&pool->po_free_list);
+        pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+        pool->po_owner    = ps;
+        pool->po_size     = size;
+}
+
+void
+kiblnd_destroy_pool_list(kib_poolset_t *ps, struct list_head *head)
+{
+        kib_pool_t *pool;
+
+        while (!list_empty(head)) {
+                pool = list_entry(head->next, kib_pool_t, po_list);
+                list_del(&pool->po_list);
+                ps->ps_pool_destroy(pool);
+        }
+}
+
+static void
+kiblnd_fini_pool_set(kib_poolset_t *ps)
+{
+        kiblnd_destroy_pool_list(ps, &ps->ps_pool_list);
+}
+
+static int
+kiblnd_init_pool_set(kib_poolset_t *ps, kib_net_t *net,
+                     char *name, int size,
+                     kib_ps_pool_create_t po_create,
+                     kib_ps_pool_destroy_t po_destroy,
+                     kib_ps_node_init_t nd_init,
+                     kib_ps_node_fini_t nd_fini)
+{
+        kib_pool_t    *pool;
+        int            rc;
+
+        memset(ps, 0, sizeof(kib_poolset_t));
+
+        ps->ps_net          = net;
+        ps->ps_pool_create  = po_create;
+        ps->ps_pool_destroy = po_destroy;
+        ps->ps_node_init    = nd_init;
+        ps->ps_node_fini    = nd_fini;
+        ps->ps_pool_size    = size;
+        strncpy(ps->ps_name, name, IBLND_POOL_NAME_LEN);
+        spin_lock_init(&ps->ps_lock);
+        CFS_INIT_LIST_HEAD(&ps->ps_pool_list);
+
+        rc = ps->ps_pool_create(ps, size, &pool);
+        if (rc == 0)
+                list_add(&pool->po_list, &ps->ps_pool_list);
+        else
+                CERROR("Failed to create the first pool for %s\n", ps->ps_name);
+
+        return rc;
+}
+
+void
+kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
+{
+        CFS_LIST_HEAD  (zombies);
+        kib_poolset_t  *ps = pool->po_owner;
+        kib_pool_t     *tmp;
+        cfs_time_t      now = cfs_time_current();
+
+        spin_lock(&ps->ps_lock);
+
+        if (ps->ps_node_fini != NULL)
+                ps->ps_node_fini(pool, node);
+
+        LASSERT (pool->po_allocated > 0);
+        list_add(node, &pool->po_free_list);
+        pool->po_allocated --;
+
+        list_for_each_entry_safe(pool, tmp, &ps->ps_pool_list, po_list) {
+                /* the first pool is persistent */
+                if (ps->ps_pool_list.next == &pool->po_list)
+                        continue;
+
+                if (pool->po_allocated == 0 &&
+                    cfs_time_aftereq(now, pool->po_deadline))
+                        list_move(&pool->po_list, &zombies);
+        }
+        spin_unlock(&ps->ps_lock);
+
+        if (!list_empty(&zombies))
+                kiblnd_destroy_pool_list(ps, &zombies);
+}
+
+struct list_head *
+kiblnd_pool_alloc_node(kib_poolset_t *ps)
+{
+        struct list_head  *node;
+        kib_pool_t        *pool;
+        int                rc;
+
+ again:
+        spin_lock(&ps->ps_lock);
+        list_for_each_entry(pool, &ps->ps_pool_list, po_list) {
+                if (list_empty(&pool->po_free_list))
+                        continue;
+
+                pool->po_allocated ++;
+                pool->po_deadline = cfs_time_shift(IBLND_POOL_DEADLINE);
+                node = pool->po_free_list.next;
+                list_del(node);
+
+                if (ps->ps_node_init != NULL) {
+                        /* still hold the lock */
+                        ps->ps_node_init(pool, node);
+                }
+                spin_unlock(&ps->ps_lock);
+                return node;
+        }
+
+        /* no available tx pool and ... */
+        if (ps->ps_increasing) {
+                /* another thread is allocating a new pool */
+                spin_unlock(&ps->ps_lock);
+                CDEBUG(D_NET, "Another thread is allocating new "
+                       "%s pool, waiting for her to complete\n",
+                       ps->ps_name);
+                schedule();
+                goto again;
+        }
+
+        if (cfs_time_before(cfs_time_current(), ps->ps_next_retry)) {
+                /* someone failed recently */
+                spin_unlock(&ps->ps_lock);
+                return NULL;
+        }
+
+        ps->ps_increasing = 1;
+        spin_unlock(&ps->ps_lock);
+
+        CDEBUG(D_NET, "%s pool exhausted, allocate new pool\n", ps->ps_name);
+
+        rc = ps->ps_pool_create(ps, ps->ps_pool_size, &pool);
+
+        spin_lock(&ps->ps_lock);
+        ps->ps_increasing = 0;
+        if (rc == 0) {
+                list_add_tail(&pool->po_list, &ps->ps_pool_list);
+        } else {
+                /* retry 10 seconds later */
+                ps->ps_next_retry = cfs_time_shift(10);
+                CERROR("Can't allocate new %s pool because out of memory\n",
+                       ps->ps_name);
+        }
+        spin_unlock(&ps->ps_lock);
+
+        goto again;
+}
+
+void
+kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr)
+{
+        kib_pmr_pool_t      *ppo = pmr->pmr_pool;
+        struct ib_mr        *mr  = pmr->pmr_mr;
+
+        pmr->pmr_mr = NULL;
+        kiblnd_pool_free_node(&ppo->ppo_pool, &pmr->pmr_list);
+        if (mr != NULL)
+                ib_dereg_mr(mr);
+}
+
+int
+kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_rdma_desc_t *rd,
+                    __u64 *iova, kib_phys_mr_t **pp_pmr)
+{
+        kib_phys_mr_t       *pmr;
+        struct list_head    *node;
+        int                  rc;
+        int                  i;
+
+        node = kiblnd_pool_alloc_node(&pps->pps_poolset);
+        if (node == NULL) {
+                CERROR("Failed to allocate PMR descriptor\n");
                 return -ENOMEM;
         }
 
-        memset(net->ibn_tx_descs, 0,
-               IBLND_TX_MSGS() * sizeof(kib_tx_t));
+        pmr = container_of(node, kib_phys_mr_t, pmr_list);
+        for (i = 0; i < rd->rd_nfrags; i ++) {
+                pmr->pmr_ipb[i].addr = rd->rd_frags[i].rf_addr;
+                pmr->pmr_ipb[i].size = rd->rd_frags[i].rf_nob;
+        }
+
+        pmr->pmr_mr = ib_reg_phys_mr(pps->pps_poolset.ps_net->ibn_dev->ibd_pd,
+                                     pmr->pmr_ipb, rd->rd_nfrags,
+                                     IB_ACCESS_LOCAL_WRITE |
+                                     IB_ACCESS_REMOTE_WRITE,
+                                     iova);
+        if (!IS_ERR(pmr->pmr_mr)) {
+                pmr->pmr_iova = *iova;
+                *pp_pmr = pmr;
+                return 0;
+        }
+
+        rc = PTR_ERR(pmr->pmr_mr);
+        CERROR("Failed ib_reg_phys_mr: %d\n", rc);
 
-        for (i = 0; i < IBLND_TX_MSGS(); i++) {
-                kib_tx_t *tx = &net->ibn_tx_descs[i];
+        pmr->pmr_mr = NULL;
+        kiblnd_pool_free_node(&pmr->pmr_pool->ppo_pool, node);
 
-#if IBLND_MAP_ON_DEMAND
-                LIBCFS_ALLOC(tx->tx_pages, LNET_MAX_IOV *
-                             sizeof(*tx->tx_pages));
-                if (tx->tx_pages == NULL) {
-                        CERROR("Can't allocate phys page vector[%d]\n",
-                               LNET_MAX_IOV);
-                        return -ENOMEM;
+        return rc;
+}
+
+static void
+kiblnd_destroy_pmr_pool(kib_pool_t *pool)
+{
+        kib_pmr_pool_t *ppo = container_of(pool, kib_pmr_pool_t, ppo_pool);
+        kib_phys_mr_t  *pmr;
+
+        LASSERT (pool->po_allocated == 0);
+
+        while (!list_empty(&pool->po_free_list)) {
+                pmr = list_entry(pool->po_free_list.next,
+                                 kib_phys_mr_t, pmr_list);
+
+                LASSERT (pmr->pmr_mr == NULL);
+                list_del(&pmr->pmr_list);
+
+                if (pmr->pmr_ipb != NULL) {
+                        LIBCFS_FREE(pmr->pmr_ipb,
+                                    IBLND_MAX_RDMA_FRAGS *
+                                    sizeof(struct ib_phys_buf));
                 }
-#else
+
+                LIBCFS_FREE(pmr, sizeof(kib_phys_mr_t));
+        }
+
+        kiblnd_fini_pool(pool);
+        LIBCFS_FREE(ppo, sizeof(kib_pmr_pool_t));
+}
+
+static int
+kiblnd_create_pmr_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
+{
+        kib_pmr_pool_t      *ppo;
+        kib_pool_t          *pool;
+        kib_phys_mr_t       *pmr;
+        int                  i;
+
+        LIBCFS_ALLOC(ppo, sizeof(kib_pmr_pool_t));
+        if (ppo == NULL) {
+                CERROR("Failed to allocate PMR pool\n");
+                return -ENOMEM;
+        }
+
+        pool = &ppo->ppo_pool;
+        kiblnd_init_pool(ps, pool, size);
+
+        for (i = 0; i < size; i++) {
+                LIBCFS_ALLOC(pmr, sizeof(kib_phys_mr_t));
+                if (pmr == NULL)
+                        break;
+
+                memset(pmr, 0, sizeof(kib_phys_mr_t));
+                pmr->pmr_pool = ppo;
+                LIBCFS_ALLOC(pmr->pmr_ipb,
+                             IBLND_MAX_RDMA_FRAGS *
+                             sizeof(struct ib_phys_buf));
+                if (pmr->pmr_ipb == NULL)
+                        break;
+
+                list_add(&pmr->pmr_list, &pool->po_free_list);
+        }
+
+        if (i < size) {
+                ps->ps_pool_destroy(pool);
+                return -ENOMEM;
+        }
+
+        *pp_po = pool;
+        return 0;
+}
+
+static void
+kiblnd_destroy_tx_pool(kib_pool_t *pool)
+{
+        kib_tx_pool_t  *tpo = container_of(pool, kib_tx_pool_t, tpo_pool);
+        int             i;
+
+        LASSERT (pool->po_allocated == 0);
+
+        if (tpo->tpo_tx_pages != NULL) {
+                if (tpo->tpo_tx_pages->ibp_device != NULL)
+                        kiblnd_unmap_tx_pool(tpo);
+                kiblnd_free_pages(tpo->tpo_tx_pages);
+        }
+
+        if (tpo->tpo_tx_descs == NULL)
+                goto out;
+
+        for (i = 0; i < pool->po_size; i++) {
+                kib_tx_t *tx = &tpo->tpo_tx_descs[i];
+
+                list_del(&tx->tx_list);
+                if (tx->tx_pages != NULL)
+                        LIBCFS_FREE(tx->tx_pages,
+                                    LNET_MAX_IOV *
+                                    sizeof(*tx->tx_pages));
+                if (tx->tx_frags != NULL)
+                        LIBCFS_FREE(tx->tx_frags,
+                                    IBLND_MAX_RDMA_FRAGS *
+                                            sizeof(*tx->tx_frags));
+                if (tx->tx_wrq != NULL)
+                        LIBCFS_FREE(tx->tx_wrq,
+                                    (1 + IBLND_MAX_RDMA_FRAGS) *
+                                    sizeof(*tx->tx_wrq));
+                if (tx->tx_sge != NULL)
+                        LIBCFS_FREE(tx->tx_sge,
+                                    (1 + IBLND_MAX_RDMA_FRAGS) *
+                                    sizeof(*tx->tx_sge));
+                if (tx->tx_rd != NULL)
+                        LIBCFS_FREE(tx->tx_rd,
+                                    offsetof(kib_rdma_desc_t,
+                                             rd_frags[IBLND_MAX_RDMA_FRAGS]));
+        }
+
+        LIBCFS_FREE(tpo->tpo_tx_descs,
+                    pool->po_size * sizeof(kib_tx_t));
+out:
+        kiblnd_fini_pool(pool);
+        LIBCFS_FREE(tpo, sizeof(kib_tx_pool_t));
+}
+
+static int
+kiblnd_create_tx_pool(kib_poolset_t *ps, int size, kib_pool_t **pp_po)
+{
+        int            i;
+        int            npg;
+        kib_pool_t    *pool;
+        kib_tx_pool_t *tpo;
+
+        LIBCFS_ALLOC(tpo, sizeof(kib_tx_pool_t));
+        if (tpo == NULL) {
+                CERROR("Failed to allocate TX pool\n");
+                return -ENOMEM;
+        }
+
+        pool = &tpo->tpo_pool;
+        kiblnd_init_pool(ps, pool, size);
+        tpo->tpo_tx_descs = NULL;
+        tpo->tpo_tx_pages = NULL;
+
+        npg = (size * IBLND_MSG_SIZE + PAGE_SIZE - 1) / PAGE_SIZE;
+        if (kiblnd_alloc_pages(&tpo->tpo_tx_pages, npg) != 0) {
+                CERROR("Can't allocate tx pages: %d\n", npg);
+                LIBCFS_FREE(tpo, sizeof(kib_tx_pool_t));
+                return -ENOMEM;
+        }
+
+        LIBCFS_ALLOC (tpo->tpo_tx_descs, size * sizeof(kib_tx_t));
+        if (tpo->tpo_tx_descs == NULL) {
+                CERROR("Can't allocate %d tx descriptors\n", size);
+                ps->ps_pool_destroy(pool);
+                return -ENOMEM;
+        }
+
+        memset(tpo->tpo_tx_descs, 0, size * sizeof(kib_tx_t));
+
+        for (i = 0; i < size; i++) {
+                kib_tx_t *tx = &tpo->tpo_tx_descs[i];
+
+                tx->tx_pool = tpo;
+                if (ps->ps_net->ibn_with_fmr){
+                        LIBCFS_ALLOC(tx->tx_pages, LNET_MAX_IOV *
+                                     sizeof(*tx->tx_pages));
+                        if (tx->tx_pages == NULL)
+                                break;
+                }
+
+                LIBCFS_ALLOC(tx->tx_frags,
+                             IBLND_MAX_RDMA_FRAGS *
+                             sizeof(*tx->tx_frags));
+                if (tx->tx_frags == NULL)
+                        break;
+
                 LIBCFS_ALLOC(tx->tx_wrq,
                              (1 + IBLND_MAX_RDMA_FRAGS) *
                              sizeof(*tx->tx_wrq));
                 if (tx->tx_wrq == NULL)
-                        return -ENOMEM;
+                        break;
 
                 LIBCFS_ALLOC(tx->tx_sge,
                              (1 + IBLND_MAX_RDMA_FRAGS) *
                              sizeof(*tx->tx_sge));
                 if (tx->tx_sge == NULL)
-                        return -ENOMEM;
+                        break;
 
                 LIBCFS_ALLOC(tx->tx_rd,
                              offsetof(kib_rdma_desc_t,
                                       rd_frags[IBLND_MAX_RDMA_FRAGS]));
                 if (tx->tx_rd == NULL)
-                        return -ENOMEM;
+                        break;
+        }
 
-                LIBCFS_ALLOC(tx->tx_frags,
-                             IBLND_MAX_RDMA_FRAGS * 
-                             sizeof(*tx->tx_frags));
-                if (tx->tx_frags == NULL)
-                        return -ENOMEM;
-#endif
+        if (i == size) {
+                kiblnd_map_tx_pool(tpo);
+                *pp_po = pool;
+                return 0;
         }
 
-        return 0;
+        ps->ps_pool_destroy(pool);
+        return -ENOMEM;
+}
+
+static void
+kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
+{
+        kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t, tps_poolset);
+        kib_tx_t         *tx  = list_entry(node, kib_tx_t, tx_list);
+
+        tx->tx_cookie = tps->tps_next_tx_cookie ++;
 }
 
 void
-kiblnd_unmap_tx_descs (lnet_ni_t *ni)
+kiblnd_ni_fini_pools(kib_net_t *net)
 {
-        int             i;
-        kib_tx_t       *tx;
-        kib_net_t      *net = ni->ni_data;
+        kiblnd_fini_pool_set(&net->ibn_tx_ps.tps_poolset);
+        if (net->ibn_with_fmr)
+                kiblnd_fini_fmr_pool_set(&net->ibn_fmr_ps);
+        else if (net->ibn_with_pmr)
+                kiblnd_fini_pool_set(&net->ibn_pmr_ps.pps_poolset);
+}
 
-        LASSERT (net != NULL);
+int
+kiblnd_net_init_pools(kib_net_t *net)
+{
+        kib_fmr_poolset_t *fps = &net->ibn_fmr_ps;
+        kib_pmr_poolset_t *pps = &net->ibn_pmr_ps;
+        kib_tx_poolset_t  *tps = &net->ibn_tx_ps;
+        int                rc;
 
-        for (i = 0; i < IBLND_TX_MSGS(); i++) {
-                tx = &net->ibn_tx_descs[i];
+        if (*kiblnd_tunables.kib_fmr_pool_size <
+            *kiblnd_tunables.kib_ntx / 4) {
+                CERROR("Can't set fmr pool size (%d) < ntx / 4(%d)\n",
+                       *kiblnd_tunables.kib_fmr_pool_size,
+                       *kiblnd_tunables.kib_ntx / 4);
+                return -EINVAL;
+        }
 
-                kiblnd_dma_unmap_single(net->ibn_dev->ibd_cmid->device,
-                                        KIBLND_UNMAP_ADDR(tx, tx_msgunmap,
-                                                          tx->tx_msgaddr),
-                                        IBLND_MSG_SIZE, DMA_TO_DEVICE);
+        if (*kiblnd_tunables.kib_pmr_pool_size <
+            *kiblnd_tunables.kib_ntx / 4) {
+                CERROR("Can't set pmr pool size (%d) < ntx / 4(%d)\n",
+                       *kiblnd_tunables.kib_pmr_pool_size,
+                       *kiblnd_tunables.kib_ntx / 4);
+                return -EINVAL;
+        }
+
+        if (*kiblnd_tunables.kib_map_on_demand > 0 ||
+            net->ibn_dev->ibd_nmrs > 1) { /* premapping can fail if ibd_nmr > 1,
+                                           * so we always create FMR/PMR pool and
+                                           * map-on-demand if premapping failed */
+                rc = kiblnd_init_fmr_pool_set(fps, net);
+                if (rc == 0) {
+                        net->ibn_with_fmr = 1;
+                } else if (rc == -ENOSYS) {
+                        rc = kiblnd_init_pool_set(&pps->pps_poolset, net, "PMR",
+                                                  *kiblnd_tunables.kib_pmr_pool_size,
+                                                  kiblnd_create_pmr_pool,
+                                                  kiblnd_destroy_pmr_pool,
+                                                  NULL, NULL);
+                        if (rc == 0)
+                                net->ibn_with_pmr = 1;
+                }
+                if (rc != 0)
+                        return rc;
         }
+
+        rc = kiblnd_init_pool_set(&tps->tps_poolset, net, "TX", IBLND_TX_MSGS(),
+                                  kiblnd_create_tx_pool, kiblnd_destroy_tx_pool,
+                                  kiblnd_tx_init, NULL);
+        if (rc == 0)
+                return 0;
+
+        if (net->ibn_with_fmr)
+                kiblnd_fini_fmr_pool_set(fps);
+        else if (net->ibn_with_pmr)
+                kiblnd_fini_pool_set(&pps->pps_poolset);
+
+        return rc;
 }
 
 void
-kiblnd_map_tx_descs (lnet_ni_t *ni)
+kiblnd_dev_cleanup(kib_dev_t *ibdev)
 {
-        int             ipage = 0;
-        int             page_offset = 0;
-        int             i;
-        struct page    *page;
-        kib_tx_t       *tx;
-        kib_net_t      *net = ni->ni_data;
+        int     i;
 
-        LASSERT (net != NULL);
+        if (ibdev->ibd_mrs == NULL)
+                return;
 
-        /* pre-mapped messages are not bigger than 1 page */
-        CLASSERT (IBLND_MSG_SIZE <= PAGE_SIZE);
+        for (i = 0; i < ibdev->ibd_nmrs; i++) {
+                if (ibdev->ibd_mrs[i] == NULL)
+                        break;
 
-        /* No fancy arithmetic when we do the buffer calculations */
-        CLASSERT (PAGE_SIZE % IBLND_MSG_SIZE == 0);
+                ib_dereg_mr(ibdev->ibd_mrs[i]);
+        }
 
-        for (i = 0; i < IBLND_TX_MSGS(); i++) {
-                page = net->ibn_tx_pages->ibp_pages[ipage];
-                tx = &net->ibn_tx_descs[i];
+        LIBCFS_FREE(ibdev->ibd_mrs, sizeof(*ibdev->ibd_mrs) * ibdev->ibd_nmrs);
+        ibdev->ibd_mrs = NULL;
+}
 
-                tx->tx_msg = (kib_msg_t *)(((char *)page_address(page)) +
-                                           page_offset);
+static int
+kiblnd_dev_get_attr(kib_dev_t *ibdev)
+{
+        struct ib_device_attr *attr;
+        int                    rc;
 
-                tx->tx_msgaddr = kiblnd_dma_map_single(
-                        net->ibn_dev->ibd_cmid->device,
-                        tx->tx_msg, IBLND_MSG_SIZE, DMA_TO_DEVICE);
-                KIBLND_UNMAP_ADDR_SET(tx, tx_msgunmap, tx->tx_msgaddr);
+        /* XXX here should be HCA's page shift/size/mask in the future? */
+        ibdev->ibd_page_shift = PAGE_SHIFT;
+        ibdev->ibd_page_size  = 1 << PAGE_SHIFT;
+        ibdev->ibd_page_mask  = ~((__u64)ibdev->ibd_page_size - 1);
 
-                list_add(&tx->tx_list, &net->ibn_idle_txs);
+        LIBCFS_ALLOC(attr, sizeof(*attr));
+        if (attr == NULL) {
+                CERROR("Out of memory\n");
+                return -ENOMEM;
+        }
 
-                page_offset += IBLND_MSG_SIZE;
-                LASSERT (page_offset <= PAGE_SIZE);
+        rc = ib_query_device(ibdev->ibd_cmid->device, attr);
+        if (rc == 0)
+                ibdev->ibd_mr_size = attr->max_mr_size;
 
-                if (page_offset == PAGE_SIZE) {
-                        page_offset = 0;
-                        ipage++;
-                        LASSERT (ipage <= IBLND_TX_MSG_PAGES());
+        LIBCFS_FREE(attr, sizeof(*attr));
+
+        if (rc != 0) {
+                CERROR("Failed to query IB device: %d\n", rc);
+                return rc;
+        }
+
+#ifdef HAVE_OFED_TRANSPORT_IWARP
+        /* XXX We can't trust this value returned by Chelsio driver, it's wrong
+         * and we have reported the bug, remove these in the future when Chelsio
+         * bug got fixed. */
+        if (rdma_node_get_transport(ibdev->ibd_cmid->device->node_type) ==
+            RDMA_TRANSPORT_IWARP)
+                ibdev->ibd_mr_size = (1ULL << 32) - 1;
+#endif
+
+        if (ibdev->ibd_mr_size == ~0ULL) {
+                ibdev->ibd_mr_shift = 64;
+                return 0;
+        }
+
+        for (ibdev->ibd_mr_shift = 0;
+             ibdev->ibd_mr_shift < 64; ibdev->ibd_mr_shift ++) {
+                if (ibdev->ibd_mr_size == (1ULL << ibdev->ibd_mr_shift) ||
+                    ibdev->ibd_mr_size == (1ULL << ibdev->ibd_mr_shift) - 1)
+                        return 0;
+        }
+
+        CERROR("Invalid mr size: "LPX64"\n", ibdev->ibd_mr_size);
+        return -EINVAL;
+}
+
+int
+kiblnd_dev_setup(kib_dev_t *ibdev)
+{
+        struct ib_mr *mr;
+        int           i;
+        int           rc;
+        __u64         mm_size;
+        __u64         mr_size;
+        int           acflags = IB_ACCESS_LOCAL_WRITE |
+                                IB_ACCESS_REMOTE_WRITE;
+
+        rc = kiblnd_dev_get_attr(ibdev);
+        if (rc != 0)
+                return rc;
+
+        if (ibdev->ibd_mr_shift == 64) {
+                LIBCFS_ALLOC(ibdev->ibd_mrs, 1 * sizeof(*ibdev->ibd_mrs));
+                if (ibdev->ibd_mrs == NULL) {
+                        CERROR("Failed to allocate MRs table\n");
+                        return -ENOMEM;
                 }
+
+                ibdev->ibd_mrs[0] = NULL;
+                ibdev->ibd_nmrs   = 1;
+
+                mr = ib_get_dma_mr(ibdev->ibd_pd, acflags);
+                if (IS_ERR(mr)) {
+                        CERROR("Failed ib_get_dma_mr : %ld\n", PTR_ERR(mr));
+                        kiblnd_dev_cleanup(ibdev);
+                        return PTR_ERR(mr);
+                }
+
+                ibdev->ibd_mrs[0] = mr;
+
+                goto out;
         }
+
+        mr_size = (1ULL << ibdev->ibd_mr_shift);
+        mm_size = (unsigned long)high_memory - PAGE_OFFSET;
+
+        ibdev->ibd_nmrs = (int)((mm_size + mr_size - 1) >> ibdev->ibd_mr_shift);
+
+        if (ibdev->ibd_mr_shift < 32 || ibdev->ibd_nmrs > 1024) {
+                /* it's 4T..., assume we will re-code at that time */
+                CERROR("Can't support memory size: x"LPX64
+                       " with MR size: x"LPX64"\n", mm_size, mr_size);
+                return -EINVAL;
+        }
+
+        /* create an array of MRs to cover all memory */
+        LIBCFS_ALLOC(ibdev->ibd_mrs, sizeof(*ibdev->ibd_mrs) * ibdev->ibd_nmrs);
+        if (ibdev->ibd_mrs == NULL) {
+                CERROR("Failed to allocate MRs' table\n");
+                return -ENOMEM;
+        }
+
+        memset(ibdev->ibd_mrs, 0, sizeof(*ibdev->ibd_mrs) * ibdev->ibd_nmrs);
+
+        for (i = 0; i < ibdev->ibd_nmrs; i++) {
+                struct ib_phys_buf ipb;
+                __u64              iova;
+
+                ipb.size = ibdev->ibd_mr_size;
+                ipb.addr = i * mr_size;
+                iova     = ipb.addr;
+
+                mr = ib_reg_phys_mr(ibdev->ibd_pd, &ipb, 1, acflags, &iova);
+                if (IS_ERR(mr)) {
+                        CERROR("Failed ib_reg_phys_mr addr "LPX64
+                               " size "LPX64" : %ld\n",
+                               ipb.addr, ipb.size, PTR_ERR(mr));
+                        kiblnd_dev_cleanup(ibdev);
+                        return PTR_ERR(mr);
+                }
+
+                LASSERT (iova == ipb.addr);
+
+                ibdev->ibd_mrs[i] = mr;
+        }
+
+out:
+        CDEBUG(D_CONSOLE, "Register global MR array, MR size: "
+                          LPX64", array size: %d\n",
+                          ibdev->ibd_mr_size, ibdev->ibd_nmrs);
+
+        list_add_tail(&ibdev->ibd_list,
+                      &kiblnd_data.kib_devs);
+        return 0;
+}
+
+void
+kiblnd_destroy_dev (kib_dev_t *dev)
+{
+        LASSERT (dev->ibd_nnets == 0);
+
+        if (!list_empty(&dev->ibd_list)) /* on kib_devs? */
+                list_del_init(&dev->ibd_list);
+
+        kiblnd_dev_cleanup(dev);
+
+        if (dev->ibd_pd != NULL)
+                ib_dealloc_pd(dev->ibd_pd);
+
+        if (dev->ibd_cmid != NULL)
+                rdma_destroy_id(dev->ibd_cmid);
+
+        LIBCFS_FREE(dev, sizeof(*dev));
 }
 
 void
@@ -1387,7 +2314,7 @@ kiblnd_shutdown (lnet_ni_t *ni)
                         cfs_pause(cfs_time_seconds(1));
                 }
 
-                kiblnd_unmap_tx_descs(ni);
+                kiblnd_ni_fini_pools(net);
 
                 LASSERT (net->ibn_dev->ibd_nnets > 0);
                 net->ibn_dev->ibd_nnets--;
@@ -1397,10 +2324,6 @@ kiblnd_shutdown (lnet_ni_t *ni)
         case IBLND_INIT_NOTHING:
                 LASSERT (atomic_read(&net->ibn_nconns) == 0);
 
-#if IBLND_MAP_ON_DEMAND
-                if (net->ibn_fmrpool != NULL)
-                        ib_destroy_fmr_pool(net->ibn_fmrpool);
-#endif
                 if (net->ibn_dev != NULL &&
                     net->ibn_dev->ibd_nnets == 0)
                         kiblnd_destroy_dev(net->ibn_dev);
@@ -1408,14 +2331,12 @@ kiblnd_shutdown (lnet_ni_t *ni)
                 break;
         }
 
-        kiblnd_free_tx_descs(ni);
-
         CDEBUG(D_MALLOC, "after LND net cleanup: kmem %d\n",
                atomic_read(&libcfs_kmemory));
 
         net->ibn_init = IBLND_INIT_NOTHING;
         ni->ni_data = NULL;
-        
+
         LIBCFS_FREE(net, sizeof(*net));
 
 out:
@@ -1427,18 +2348,11 @@ out:
 int
 kiblnd_base_startup (void)
 {
-        int               rc;
-        int               i;
+        int i;
+        int rc;
 
         LASSERT (kiblnd_data.kib_init == IBLND_INIT_NOTHING);
 
-        if (*kiblnd_tunables.kib_credits > *kiblnd_tunables.kib_ntx) {
-                CERROR("Can't set credits(%d) > ntx(%d)\n",
-                       *kiblnd_tunables.kib_credits,
-                       *kiblnd_tunables.kib_ntx);
-                return -EINVAL;
-        }
-
         PORTAL_MODULE_USE;
         memset(&kiblnd_data, 0, sizeof(kiblnd_data)); /* zero pointers, flags etc */
 
@@ -1500,13 +2414,13 @@ int
 kiblnd_startup (lnet_ni_t *ni)
 {
         char                     *ifname;
+        kib_dev_t                *ibdev = NULL;
         kib_net_t                *net;
-        kib_dev_t                *ibdev;
         struct list_head         *tmp;
         struct timeval            tv;
         int                       rc;
 
-        LASSERT (ni->ni_lnd == &the_kiblnd);
+        LASSERT (ni->ni_lnd == &the_o2iblnd);
 
         if (kiblnd_data.kib_init == IBLND_INIT_NOTHING) {
                 rc = kiblnd_base_startup();
@@ -1524,17 +2438,10 @@ kiblnd_startup (lnet_ni_t *ni)
         do_gettimeofday(&tv);
         net->ibn_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec;
 
-        ni->ni_maxtxcredits = *kiblnd_tunables.kib_credits;
-        ni->ni_peertxcredits = *kiblnd_tunables.kib_peercredits;
-
-        spin_lock_init(&net->ibn_tx_lock);
-        INIT_LIST_HEAD(&net->ibn_idle_txs);
-
-        rc = kiblnd_alloc_tx_descs(ni);
-        if (rc != 0) {
-                CERROR("Can't allocate tx descs\n");
-                goto failed;
-        }
+        ni->ni_peertimeout    = *kiblnd_tunables.kib_peertimeout;
+        ni->ni_maxtxcredits   = *kiblnd_tunables.kib_credits;
+        ni->ni_peertxcredits  = *kiblnd_tunables.kib_peertxcredits;
+        ni->ni_peerrtrcredits = *kiblnd_tunables.kib_peerrtrcredits;
 
         if (ni->ni_interfaces[0] != NULL) {
                 /* Use the IPoIB interface specified in 'networks=' */
@@ -1555,7 +2462,6 @@ kiblnd_startup (lnet_ni_t *ni)
                 goto failed;
         }
 
-        ibdev = NULL;
         list_for_each (tmp, &kiblnd_data.kib_devs) {
                 ibdev = list_entry(tmp, kib_dev_t, ibd_list);
 
@@ -1571,7 +2477,6 @@ kiblnd_startup (lnet_ni_t *ni)
                 int                       up;
                 struct rdma_cm_id        *id;
                 struct ib_pd             *pd;
-                struct ib_mr             *mr;
                 struct sockaddr_in	  addr;
 
                 rc = libcfs_ipif_query(ifname, &up, &ip, &netmask);
@@ -1593,18 +2498,18 @@ kiblnd_startup (lnet_ni_t *ni)
 
                 memset(ibdev, 0, sizeof(*ibdev));
 
-                INIT_LIST_HEAD(&ibdev->ibd_list); /* not yet in kib_devs */
+                CFS_INIT_LIST_HEAD(&ibdev->ibd_list); /* not yet in kib_devs */
                 ibdev->ibd_ifip = ip;
                 strcpy(&ibdev->ibd_ifname[0], ifname);
 
                 id = rdma_create_id(kiblnd_cm_callback, ibdev, RDMA_PS_TCP);
-                if (!IS_ERR(id)) {
-                        ibdev->ibd_cmid = id;
-                } else {
+                if (IS_ERR(id)) {
                         CERROR("Can't create listen ID: %ld\n", PTR_ERR(id));
                         goto failed;
                 }
 
+                ibdev->ibd_cmid = id;
+
                 memset(&addr, 0, sizeof(addr));
                 addr.sin_family      = AF_INET;
                 addr.sin_port        = htons(*kiblnd_tunables.kib_service);
@@ -1618,85 +2523,48 @@ kiblnd_startup (lnet_ni_t *ni)
 
                 /* Binding should have assigned me an IB device */
                 LASSERT (id->device != NULL);
+                CDEBUG(D_CONSOLE, "Listener bound to %s:%u.%u.%u.%u:%d:%s\n",
+                       ifname, HIPQUAD(ip), *kiblnd_tunables.kib_service,
+                       id->device->name);
 
                 pd = ib_alloc_pd(id->device);
-                if (!IS_ERR(pd)) {
-                        ibdev->ibd_pd = pd;
-                } else {
+                if (IS_ERR(pd)) {
                         CERROR("Can't allocate PD: %ld\n", PTR_ERR(pd));
                         goto failed;
                 }
 
-#if IBLND_MAP_ON_DEMAND
-                /* MR for sends and receives */
-                mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE);
-#else
-                /* MR for sends, recieves _and_ RDMA...........v */
-                mr = ib_get_dma_mr(pd, IB_ACCESS_LOCAL_WRITE |
-                                       IB_ACCESS_REMOTE_WRITE);
-#endif
-                if (!IS_ERR(mr)) {
-                        ibdev->ibd_mr = mr;
-                } else {
-                        CERROR("Can't get MR: %ld\n", PTR_ERR(mr));
-                        goto failed;
-                }
+                ibdev->ibd_pd = pd;
 
-                rc = rdma_listen(id, 0);
+                rc = rdma_listen(id, 256);
                 if (rc != 0) {
                         CERROR("Can't start listener: %d\n", rc);
                         goto failed;
                 }
 
-                list_add_tail(&ibdev->ibd_list, 
-                              &kiblnd_data.kib_devs);
+                rc = kiblnd_dev_setup(ibdev);
+                if (rc != 0) {
+                        CERROR("Can't setup device: %d\n", rc);
+                        goto failed;
+                }
         }
 
         ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid), ibdev->ibd_ifip);
         net->ibn_dev = ibdev;
 
-#if IBLND_MAP_ON_DEMAND
-        /* FMR pool for RDMA */
-        {
-                struct ib_fmr_pool      *fmrpool;
-                struct ib_fmr_pool_param param = {
-                        .max_pages_per_fmr = LNET_MAX_PAYLOAD/PAGE_SIZE,
-                        .page_shift        = PAGE_SHIFT,
-                        .access            = (IB_ACCESS_LOCAL_WRITE |
-                                              IB_ACCESS_REMOTE_WRITE),
-                        .pool_size         = *kiblnd_tunables.kib_fmr_pool_size,
-                        .dirty_watermark   = *kiblnd_tunables.kib_fmr_flush_trigger,
-                        .flush_function    = NULL,
-                        .flush_arg         = NULL,
-                        .cache             = *kiblnd_tunables.kib_fmr_cache};
-
-                if (*kiblnd_tunables.kib_fmr_pool_size < 
-                    *kiblnd_tunables.kib_ntx) {
-                        CERROR("Can't set fmr pool size (%d) < ntx(%d)\n",
-                               *kiblnd_tunables.kib_fmr_pool_size,
-                               *kiblnd_tunables.kib_ntx);
-                        goto failed;
-                }
-
-                fmrpool = ib_create_fmr_pool(ibdev->ibd_pd, &param);
-                if (!IS_ERR(fmrpool)) {
-                        net->ibn_fmrpool = fmrpool;
-                } else {
-                        CERROR("Can't create FMR pool: %ld\n", 
-                               PTR_ERR(fmrpool));
-                        goto failed;
-                }
+        rc = kiblnd_net_init_pools(net);
+        if (rc != 0) {
+                CERROR("Failed to initialize NI pools: %d\n", rc);
+                goto failed;
         }
-#endif
-
-        kiblnd_map_tx_descs(ni);
-
         ibdev->ibd_nnets++;
         net->ibn_init = IBLND_INIT_ALL;
 
         return 0;
 
 failed:
+        if (net->ibn_dev == NULL && ibdev != NULL)
+                kiblnd_destroy_dev(ibdev);
+
         kiblnd_shutdown(ni);
 
         CDEBUG(D_NET, "kiblnd_startup failed\n");
@@ -1706,7 +2574,7 @@ failed:
 void __exit
 kiblnd_module_fini (void)
 {
-        lnet_unregister_lnd(&the_kiblnd);
+        lnet_unregister_lnd(&the_o2iblnd);
         kiblnd_tunables_fini();
 }
 
@@ -1716,23 +2584,22 @@ kiblnd_module_init (void)
         int    rc;
 
         CLASSERT (sizeof(kib_msg_t) <= IBLND_MSG_SIZE);
-#if !IBLND_MAP_ON_DEMAND
         CLASSERT (offsetof(kib_msg_t, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
                   <= IBLND_MSG_SIZE);
         CLASSERT (offsetof(kib_msg_t, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS])
                   <= IBLND_MSG_SIZE);
-#endif
+
         rc = kiblnd_tunables_init();
         if (rc != 0)
                 return rc;
 
-        lnet_register_lnd(&the_kiblnd);
+        lnet_register_lnd(&the_o2iblnd);
 
         return 0;
 }
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Kernel OpenIB gen2 LND v1.00");
+MODULE_DESCRIPTION("Kernel OpenIB gen2 LND v2.00");
 MODULE_LICENSE("GPL");
 
 module_init(kiblnd_module_init);
diff --git a/lnet/klnds/o2iblnd/o2iblnd.h b/lnet/klnds/o2iblnd/o2iblnd.h
index 734f39d..d13d931 100644
--- a/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/lnet/klnds/o2iblnd/o2iblnd.h
@@ -99,35 +99,6 @@ typedef int gfp_t;
 
 #define IBLND_PEER_HASH_SIZE         101        /* # peer lists */
 #define IBLND_RESCHED                100        /* # scheduler loops before reschedule */
-#define IBLND_MSG_QUEUE_SIZE         8          /* # messages/RDMAs in-flight */
-#define IBLND_CREDIT_HIGHWATER       7          /* when eagerly to return credits */
-#define IBLND_MSG_SIZE              (4<<10)     /* max size of queued messages (inc hdr) */
-
-#define IBLND_MAP_ON_DEMAND  0
-#if IBLND_MAP_ON_DEMAND
-# define IBLND_MAX_RDMA_FRAGS        1
-#else
-# define IBLND_MAX_RDMA_FRAGS        LNET_MAX_IOV
-#endif
-
-/************************/
-/* derived constants... */
-
-/* TX messages (shared by all connections) */
-#define IBLND_TX_MSGS()       (*kiblnd_tunables.kib_ntx)
-#define IBLND_TX_MSG_BYTES()  (IBLND_TX_MSGS() * IBLND_MSG_SIZE)
-#define IBLND_TX_MSG_PAGES()  ((IBLND_TX_MSG_BYTES() + PAGE_SIZE - 1)/PAGE_SIZE)
-
-/* RX messages (per connection) */
-#define IBLND_RX_MSGS         (IBLND_MSG_QUEUE_SIZE * 2)
-#define IBLND_RX_MSG_BYTES    (IBLND_RX_MSGS * IBLND_MSG_SIZE)
-#define IBLND_RX_MSG_PAGES    ((IBLND_RX_MSG_BYTES + PAGE_SIZE - 1)/PAGE_SIZE)
-
-/* WRs and CQEs (per connection) */
-#define IBLND_RECV_WRS        IBLND_RX_MSGS
-#define IBLND_SEND_WRS        ((*kiblnd_tunables.kib_concurrent_sends) * \
-                               (1 + IBLND_MAX_RDMA_FRAGS))
-#define IBLND_CQ_ENTRIES()    (IBLND_RECV_WRS + IBLND_SEND_WRS)
 
 typedef struct
 {
@@ -139,27 +110,83 @@ typedef struct
         int              *kib_keepalive;        /* keepalive timeout (seconds) */
         int              *kib_ntx;              /* # tx descs */
         int              *kib_credits;          /* # concurrent sends */
-        int              *kib_peercredits;      /* # concurrent sends to 1 peer */
+        int              *kib_peertxcredits;    /* # concurrent sends to 1 peer */
+        int              *kib_peerrtrcredits;   /* # per-peer router buffer credits */
+        int              *kib_peercredits_hiw;  /* # when eagerly to return credits */
+        int              *kib_peertimeout;      /* seconds to consider peer dead */
         char            **kib_default_ipif;     /* default IPoIB interface */
         int              *kib_retry_count;
         int              *kib_rnr_retry_count;
         int              *kib_concurrent_sends; /* send work queue sizing */
         int		 *kib_ib_mtu;		/* IB MTU */
-#if IBLND_MAP_ON_DEMAND
+        int              *kib_map_on_demand;    /* map-on-demand if RD has more fragments
+                                                 * than this value, 0 disable map-on-demand */
+        int              *kib_pmr_pool_size;    /* # physical MR in pool */
         int              *kib_fmr_pool_size;    /* # FMRs in pool */
         int              *kib_fmr_flush_trigger; /* When to trigger FMR flush */
         int              *kib_fmr_cache;        /* enable FMR pool cache? */
-#endif
 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
         cfs_sysctl_table_header_t *kib_sysctl;  /* sysctl interface */
 #endif
 } kib_tunables_t;
 
-typedef struct
+extern kib_tunables_t  kiblnd_tunables;
+
+#define IBLND_MSG_QUEUE_SIZE_V1      8          /* V1 only : # messages/RDMAs in-flight */
+#define IBLND_CREDIT_HIGHWATER_V1    7          /* V1 only : when eagerly to return credits */
+
+#define IBLND_CREDITS_DEFAULT        8          /* default # of peer credits */
+#define IBLND_CREDITS_MAX          ((typeof(((kib_msg_t*) 0)->ibm_credits))-1)  /* Max # of peer credits */
+
+#define IBLND_MSG_QUEUE_SIZE(v)    ((v) == IBLND_MSG_VERSION_1 ? \
+                                     IBLND_MSG_QUEUE_SIZE_V1 :   \
+                                     *kiblnd_tunables.kib_peertxcredits) /* # messages/RDMAs in-flight */
+#define IBLND_CREDITS_HIGHWATER(v) ((v) == IBLND_MSG_VERSION_1 ? \
+                                     IBLND_CREDIT_HIGHWATER_V1 : \
+                                     *kiblnd_tunables.kib_peercredits_hiw) /* when eagerly to return credits */
+
+static inline int
+kiblnd_concurrent_sends_v1(void)
 {
-        int               ibp_npages;           /* # pages */
-        struct page      *ibp_pages[0];
-} kib_pages_t;
+        if (*kiblnd_tunables.kib_concurrent_sends > IBLND_MSG_QUEUE_SIZE_V1 * 2)
+                return IBLND_MSG_QUEUE_SIZE_V1 * 2;
+
+        if (*kiblnd_tunables.kib_concurrent_sends < IBLND_MSG_QUEUE_SIZE_V1 / 2)
+                return IBLND_MSG_QUEUE_SIZE_V1 / 2;
+
+        return *kiblnd_tunables.kib_concurrent_sends;
+}
+
+#define IBLND_CONCURRENT_SENDS(v)  ((v) == IBLND_MSG_VERSION_1 ? \
+                                     kiblnd_concurrent_sends_v1() : \
+                                     *kiblnd_tunables.kib_concurrent_sends)
+/* 2 OOB shall suffice for 1 keepalive and 1 returning credits */
+#define IBLND_OOB_CAPABLE(v)       ((v) != IBLND_MSG_VERSION_1)
+#define IBLND_OOB_MSGS(v)           (IBLND_OOB_CAPABLE(v) ? 2 : 0)
+
+#define IBLND_MSG_SIZE              (4<<10)                 /* max size of queued messages (inc hdr) */
+#define IBLND_MAX_RDMA_FRAGS         LNET_MAX_IOV           /* max # of fragments supported */
+#define IBLND_CFG_RDMA_FRAGS       (*kiblnd_tunables.kib_map_on_demand != 0 ? \
+                                    *kiblnd_tunables.kib_map_on_demand :      \
+                                     IBLND_MAX_RDMA_FRAGS)  /* max # of fragments configured by user */
+#define IBLND_RDMA_FRAGS(v)        ((v) == IBLND_MSG_VERSION_1 ? \
+                                     IBLND_MAX_RDMA_FRAGS : IBLND_CFG_RDMA_FRAGS)
+
+/************************/
+/* derived constants... */
+
+/* TX messages (shared by all connections) */
+#define IBLND_TX_MSGS()            (*kiblnd_tunables.kib_ntx)
+
+/* RX messages (per connection) */
+#define IBLND_RX_MSGS(v)            (IBLND_MSG_QUEUE_SIZE(v) * 2 + IBLND_OOB_MSGS(v))
+#define IBLND_RX_MSG_BYTES(v)       (IBLND_RX_MSGS(v) * IBLND_MSG_SIZE)
+#define IBLND_RX_MSG_PAGES(v)      ((IBLND_RX_MSG_BYTES(v) + PAGE_SIZE - 1) / PAGE_SIZE)
+
+/* WRs and CQEs (per connection) */
+#define IBLND_RECV_WRS(v)            IBLND_RX_MSGS(v)
+#define IBLND_SEND_WRS(v)          ((IBLND_RDMA_FRAGS(v) + 1) * IBLND_CONCURRENT_SENDS(v))
+#define IBLND_CQ_ENTRIES(v)         (IBLND_RECV_WRS(v) + IBLND_SEND_WRS(v))
 
 typedef struct
 {
@@ -170,26 +197,131 @@ typedef struct
 
         struct rdma_cm_id   *ibd_cmid;          /* IB listener (bound to 1 device) */
         struct ib_pd        *ibd_pd;            /* PD for the device */
-        struct ib_mr        *ibd_mr;            /* MR for non RDMA I/O */
+        int                  ibd_page_shift;    /* page shift of current HCA */
+        int                  ibd_page_size;     /* page size of current HCA */
+        __u64                ibd_page_mask;     /* page mask of current HCA */
+        int                  ibd_mr_shift;      /* bits shift of max MR size */
+        __u64                ibd_mr_size;       /* size of MR */
+
+        int                  ibd_nmrs;          /* # of global MRs */
+        struct ib_mr       **ibd_mrs;           /* MR for non RDMA I/O */
 } kib_dev_t;
 
+#define IBLND_POOL_DEADLINE     300             /* # of seconds to keep pool alive */
+
 typedef struct
 {
+        struct ib_device       *ibp_device;             /* device for mapping */
+        int                     ibp_npages;             /* # pages */
+        struct page            *ibp_pages[0];           /* page array */
+} kib_pages_t;
+
+struct kib_pmr_pool;
+
+typedef struct {
+        struct list_head        pmr_list;               /* chain node */
+        struct ib_phys_buf     *pmr_ipb;                /* physical buffer */
+        struct ib_mr           *pmr_mr;                 /* IB MR */
+        struct kib_pmr_pool    *pmr_pool;               /* owner of this MR */
+        __u64                   pmr_iova;               /* Virtual I/O address */
+        int                     pmr_refcount;           /* reference count */
+} kib_phys_mr_t;
+
+struct kib_pool;
+struct kib_poolset;
+
+typedef int  (*kib_ps_pool_create_t)(struct kib_poolset *ps, int inc, struct kib_pool **pp_po);
+typedef void (*kib_ps_pool_destroy_t)(struct kib_pool *po);
+typedef void (*kib_ps_node_init_t)(struct kib_pool *po, struct list_head *node);
+typedef void (*kib_ps_node_fini_t)(struct kib_pool *po, struct list_head *node);
+
+struct kib_net;
+
+#define IBLND_POOL_NAME_LEN     32
+
+typedef struct kib_poolset
+{
+        spinlock_t              ps_lock;                /* serialize */
+        struct kib_net         *ps_net;                 /* network it belongs to */
+        char                    ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */
+        struct list_head        ps_pool_list;           /* list of pools */
+        cfs_time_t              ps_next_retry;          /* time stamp for retry if failed to allocate */
+        int                     ps_increasing;          /* is allocating new pool */
+        int                     ps_pool_size;           /* new pool size */
+
+        kib_ps_pool_create_t    ps_pool_create;         /* create a new pool */
+        kib_ps_pool_destroy_t   ps_pool_destroy;        /* destroy a pool */
+        kib_ps_node_init_t      ps_node_init;           /* initialize new allocated node */
+        kib_ps_node_fini_t      ps_node_fini;           /* finalize node */
+} kib_poolset_t;
+
+typedef struct kib_pool
+{
+        struct list_head        po_list;                /* chain on pool list */
+        struct list_head        po_free_list;           /* pre-allocated node */
+        kib_poolset_t          *po_owner;               /* pool_set of this pool */
+        cfs_time_t              po_deadline;            /* deadline of this pool */
+        int                     po_allocated;           /* # of elements in use */
+        int                     po_size;                /* # of pre-allocated elements */
+} kib_pool_t;
+
+typedef struct {
+        kib_poolset_t           tps_poolset;            /* pool-set */
+        __u64                   tps_next_tx_cookie;     /* cookie of TX */
+} kib_tx_poolset_t;
+
+typedef struct {
+        kib_pool_t              tpo_pool;               /* pool */
+        struct kib_tx          *tpo_tx_descs;           /* all the tx descriptors */
+        kib_pages_t            *tpo_tx_pages;           /* premapped tx msg pages */
+} kib_tx_pool_t;
+
+typedef struct {
+        kib_poolset_t           pps_poolset;            /* pool-set */
+} kib_pmr_poolset_t;
+
+typedef struct kib_pmr_pool {
+        kib_pool_t              ppo_pool;               /* pool */
+} kib_pmr_pool_t;
+
+typedef struct
+{
+        spinlock_t              fps_lock;               /* serialize */
+        struct kib_net         *fps_net;                /* IB network */
+        struct list_head        fps_pool_list;          /* FMR pool list */
+        __u64                   fps_version;            /* validity stamp */
+        int                     fps_increasing;         /* is allocating new pool */
+        cfs_time_t              fps_next_retry;         /* time stamp for retry if failed to allocate */
+} kib_fmr_poolset_t;
+
+typedef struct
+{
+        struct list_head        fpo_list;               /* chain on pool list */
+        kib_fmr_poolset_t      *fpo_owner;              /* owner of this pool */
+        struct ib_fmr_pool     *fpo_fmr_pool;           /* IB FMR pool */
+        cfs_time_t              fpo_deadline;           /* deadline of this pool */
+        int                     fpo_map_count;          /* # of mapped FMR */
+} kib_fmr_pool_t;
+
+typedef struct {
+        struct ib_pool_fmr     *fmr_pfmr;               /* IB pool fmr */
+        kib_fmr_pool_t         *fmr_pool;               /* pool of FMR */
+} kib_fmr_t;
+
+typedef struct kib_net
+{
         __u64                ibn_incarnation;   /* my epoch */
         int                  ibn_init;          /* initialisation state */
         int                  ibn_shutdown;      /* shutting down? */
+        unsigned int         ibn_with_fmr:1;    /* FMR? */
+        unsigned int         ibn_with_pmr:1;    /* PMR? */
 
         atomic_t             ibn_npeers;        /* # peers extant */
         atomic_t             ibn_nconns;        /* # connections extant */
 
-        struct kib_tx       *ibn_tx_descs;      /* all the tx descriptors */
-        kib_pages_t         *ibn_tx_pages;      /* premapped tx msg pages */
-        struct list_head     ibn_idle_txs;      /* idle tx descriptors */
-        spinlock_t           ibn_tx_lock;       /* serialise */
-
-#if IBLND_MAP_ON_DEMAND
-        struct ib_fmr_pool  *ibn_fmrpool;       /* FMR pool for RDMA I/O */
-#endif
+        kib_tx_poolset_t     ibn_tx_ps;         /* tx pool-set */
+        kib_fmr_poolset_t    ibn_fmr_ps;        /* fmr pool-set */
+        kib_pmr_poolset_t    ibn_pmr_ps;        /* pmr pool-set */
 
         kib_dev_t           *ibn_dev;           /* underlying IB device */
 } kib_net_t;
@@ -215,7 +347,6 @@ typedef struct
         struct list_head     kib_sched_conns;   /* conns to check for rx completions */
         spinlock_t           kib_sched_lock;    /* serialise */
 
-        __u64                kib_next_tx_cookie; /* RDMA completion cookie */
         struct ib_qp_attr    kib_error_qpa;      /* QP->ERROR */
 } kib_data_t;
 
@@ -241,14 +372,6 @@ typedef struct
         char              ibim_payload[0];      /* piggy-backed payload */
 } WIRE_ATTR kib_immediate_msg_t;
 
-#if IBLND_MAP_ON_DEMAND
-typedef struct
-{
-	__u64             rd_addr;             	/* IO VMA address */
-	__u32             rd_nob;              	/* # of bytes */
-	__u32             rd_key;		/* remote key */
-} WIRE_ATTR kib_rdma_desc_t;
-#else
 typedef struct
 {
         __u32             rf_nob;               /* # bytes this frag */
@@ -261,7 +384,6 @@ typedef struct
         __u32             rd_nfrags;            /* # fragments */
         kib_rdma_frag_t   rd_frags[0];          /* buffer frags */
 } WIRE_ATTR kib_rdma_desc_t;
-#endif
 
 typedef struct
 {
@@ -316,7 +438,9 @@ typedef struct
 
 #define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC	/* unique magic */
 
-#define IBLND_MSG_VERSION           0x11
+#define IBLND_MSG_VERSION_1         0x11
+#define IBLND_MSG_VERSION_2         0x12
+#define IBLND_MSG_VERSION           IBLND_MSG_VERSION_2
 
 #define IBLND_MSG_CONNREQ           0xc0        /* connection request */
 #define IBLND_MSG_CONNACK           0xc1        /* connection acknowledge */
@@ -333,14 +457,22 @@ typedef struct {
         __u32            ibr_magic;             /* sender's magic */
         __u16            ibr_version;           /* sender's version */
         __u8             ibr_why;               /* reject reason */
+        __u8             ibr_padding;           /* padding */
+        __u64            ibr_incarnation;       /* incarnation of peer */
+        kib_connparams_t ibr_cp;                /* connection parameters */
 } WIRE_ATTR kib_rej_t;
 
-
 /* connection rejection reasons */
 #define IBLND_REJECT_CONN_RACE       1          /* You lost connection race */
 #define IBLND_REJECT_NO_RESOURCES    2          /* Out of memory/conns etc */
 #define IBLND_REJECT_FATAL           3          /* Anything else */
 
+#define IBLND_REJECT_CONN_UNCOMPAT   4          /* incompatible version peer */
+#define IBLND_REJECT_CONN_STALE      5          /* stale peer */
+
+#define IBLND_REJECT_RDMA_FRAGS      6          /* Fatal: peer's rdma frags can't match mine */
+#define IBLND_REJECT_MSG_QUEUE_SIZE  7          /* Fatal: peer's msg queue size can't match mine */
+
 /***********************************************************************/
 
 typedef struct kib_rx                           /* receive message */
@@ -364,10 +496,11 @@ typedef struct kib_rx                           /* receive message */
 typedef struct kib_tx                           /* transmit message */
 {
         struct list_head          tx_list;      /* queue on idle_txs ibc_tx_queue etc. */
+        kib_tx_pool_t            *tx_pool;      /* pool I'm from */
         struct kib_conn          *tx_conn;      /* owning conn */
-        int                       tx_sending;   /* # tx callbacks outstanding */
-        int                       tx_queued;    /* queued for sending */
-        int                       tx_waiting;   /* waiting for peer */
+        short                     tx_sending;   /* # tx callbacks outstanding */
+        short                     tx_queued;    /* queued for sending */
+        short                     tx_waiting;   /* waiting for peer */
         int                       tx_status;    /* LNET completion status */
         unsigned long             tx_deadline;  /* completion deadline */
         __u64                     tx_cookie;    /* completion cookie */
@@ -376,20 +509,17 @@ typedef struct kib_tx                           /* transmit message */
         __u64                     tx_msgaddr;   /* message buffer (I/O addr) */
         DECLARE_PCI_UNMAP_ADDR   (tx_msgunmap); /* for dma_unmap_single() */
         int                       tx_nwrq;      /* # send work items */
-#if IBLND_MAP_ON_DEMAND
-        struct ib_send_wr         tx_wrq[2];    /* send work items... */
-        struct ib_sge             tx_sge[2];    /* ...and their memory */
-        kib_rdma_desc_t           tx_rd[1];     /* rdma descriptor */
-        __u64                    *tx_pages;     /* rdma phys page addrs */
-        struct ib_pool_fmr       *tx_fmr;       /* rdma mapping (mapped if != NULL) */
-#else
         struct ib_send_wr        *tx_wrq;       /* send work items... */
         struct ib_sge            *tx_sge;       /* ...and their memory */
         kib_rdma_desc_t          *tx_rd;        /* rdma descriptor */
         int                       tx_nfrags;    /* # entries in... */
         struct scatterlist       *tx_frags;     /* dma_map_sg descriptor */
+        __u64                    *tx_pages;     /* rdma phys page addrs */
+        union {
+                kib_phys_mr_t      *pmr;        /* MR for physical buffer */
+                kib_fmr_t           fmr;        /* FMR */
+        }                         tx_u;
         int                       tx_dmadir;    /* dma direction */
-#endif
 } kib_tx_t;
 
 typedef struct kib_connvars
@@ -403,20 +533,21 @@ typedef struct kib_conn
         struct kib_peer    *ibc_peer;           /* owning peer */
         struct list_head    ibc_list;           /* stash on peer's conn list */
         struct list_head    ibc_sched_list;     /* schedule for attention */
+        __u16               ibc_version;        /* version of connection */
         __u64               ibc_incarnation;    /* which instance of the peer */
         atomic_t            ibc_refcount;       /* # users */
         int                 ibc_state;          /* what's happening */
         int                 ibc_nsends_posted;  /* # uncompleted sends */
+        int                 ibc_noops_posted;   /* # uncompleted NOOPs */
         int                 ibc_credits;        /* # credits I have */
         int                 ibc_outstanding_credits; /* # credits to return */
         int                 ibc_reserved_credits;/* # ACK/DONE msg credits */
         int                 ibc_comms_error;    /* set on comms error */
-        int                 ibc_nrx:8;          /* receive buffers owned */
+        int                 ibc_nrx:16;         /* receive buffers owned */
         int                 ibc_scheduled:1;    /* scheduled for attention */
         int                 ibc_ready:1;        /* CQ callback fired */
         unsigned long       ibc_last_send;      /* time of last send */
         struct list_head    ibc_early_rxs;      /* rxs completed before ESTABLISHED */
-        struct list_head    ibc_tx_noops;       /* IBLND_MSG_NOOPs */
         struct list_head    ibc_tx_queue;       /* sends that need a credit */
         struct list_head    ibc_tx_queue_nocred;/* sends that don't need a credit */
         struct list_head    ibc_tx_queue_rsrvd; /* sends that need to reserve an ACK/DONE msg */
@@ -446,15 +577,15 @@ typedef struct kib_peer
         atomic_t            ibp_refcount;       /* # users */
         struct list_head    ibp_conns;          /* all active connections */
         struct list_head    ibp_tx_queue;       /* msgs waiting for a conn */
+        __u16               ibp_version;        /* version of peer */
+        __u64               ibp_incarnation;    /* incarnation of peer */
         int                 ibp_connecting;     /* current active connection attempts */
         int                 ibp_accepting;      /* current passive connection attempts */
         int                 ibp_error;          /* errno on closing this peer */
         cfs_time_t          ibp_last_alive;     /* when (in jiffies) I was last alive */
 } kib_peer_t;
 
-
 extern kib_data_t      kiblnd_data;
-extern kib_tunables_t  kiblnd_tunables;
 
 #define kiblnd_conn_addref(conn)                                \
 do {                                                            \
@@ -536,21 +667,19 @@ kiblnd_send_noop(kib_conn_t *conn)
 {
         LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
-        if (conn->ibc_outstanding_credits < IBLND_CREDIT_HIGHWATER &&
+        if (conn->ibc_outstanding_credits <
+            IBLND_CREDITS_HIGHWATER(conn->ibc_version) &&
             !kiblnd_send_keepalive(conn))
                 return 0; /* No need to send NOOP */
 
-        if (!list_empty(&conn->ibc_tx_noops) ||       /* NOOP already queued */
-            !list_empty(&conn->ibc_tx_queue_nocred) || /* can be piggybacked */
-            conn->ibc_credits == 0)                    /* no credit */
-                return 0;
+        if (!list_empty(&conn->ibc_tx_queue_nocred))
+                return 0; /* NOOP can be piggybacked */
 
-        if (conn->ibc_credits == 1 &&      /* last credit reserved for */
-            conn->ibc_outstanding_credits == 0) /* giving back credits */
-                return 0;
+        if (!IBLND_OOB_CAPABLE(conn->ibc_version))
+                return list_empty(&conn->ibc_tx_queue); /* can't piggyback? */
 
         /* No tx to piggyback NOOP onto or no credit to send a tx */
-        return (list_empty(&conn->ibc_tx_queue) || conn->ibc_credits == 1);
+        return (list_empty(&conn->ibc_tx_queue) || conn->ibc_credits == 0);
 }
 
 static inline void
@@ -560,6 +689,25 @@ kiblnd_abort_receives(kib_conn_t *conn)
                      &kiblnd_data.kib_error_qpa, IB_QP_STATE);
 }
 
+static inline const char *
+kiblnd_queue2str (kib_conn_t *conn, struct list_head *q)
+{
+        if (q == &conn->ibc_tx_queue)
+                return "tx_queue";
+
+        if (q == &conn->ibc_tx_queue_rsrvd)
+                return "tx_queue_rsrvd";
+
+        if (q == &conn->ibc_tx_queue_nocred)
+                return "tx_queue_nocred";
+
+        if (q == &conn->ibc_active_txs)
+                return "active_txs";
+
+        LBUG();
+        return NULL;
+}
+
 /* CAVEAT EMPTOR: We rely on descriptor alignment to allow us to use the
  * lowest bits of the work request id to stash the work item type. */
 
@@ -597,13 +745,13 @@ kiblnd_set_conn_state (kib_conn_t *conn, int state)
         mb();
 }
 
-#if IBLND_MAP_ON_DEMAND
-static inline int
-kiblnd_rd_size (kib_rdma_desc_t *rd)
+static inline void
+kiblnd_init_msg (kib_msg_t *msg, int type, int body_nob)
 {
-        return rd->rd_nob;
+        msg->ibm_type = type;
+        msg->ibm_nob  = offsetof(kib_msg_t, ibm_u) + body_nob;
 }
-#else
+
 static inline int
 kiblnd_rd_size (kib_rdma_desc_t *rd)
 {
@@ -615,10 +763,57 @@ kiblnd_rd_size (kib_rdma_desc_t *rd)
 
         return size;
 }
-#endif
+
+static inline __u64
+kiblnd_rd_frag_addr(kib_rdma_desc_t *rd, int index)
+{
+        return rd->rd_frags[index].rf_addr;
+}
+
+static inline __u32
+kiblnd_rd_frag_size(kib_rdma_desc_t *rd, int index)
+{
+        return rd->rd_frags[index].rf_nob;
+}
+
+static inline __u32
+kiblnd_rd_frag_key(kib_rdma_desc_t *rd, int index)
+{
+        return rd->rd_key;
+}
+
+static inline int
+kiblnd_rd_consume_frag(kib_rdma_desc_t *rd, int index, __u32 nob)
+{
+        if (nob < rd->rd_frags[index].rf_nob) {
+                rd->rd_frags[index].rf_addr += nob;
+                rd->rd_frags[index].rf_nob  -= nob;
+        } else {
+                index ++;
+        }
+
+        return index;
+}
+
+static inline int
+kiblnd_rd_msg_size(kib_rdma_desc_t *rd, int msgtype, int n)
+{
+        LASSERT (msgtype == IBLND_MSG_GET_REQ ||
+                 msgtype == IBLND_MSG_PUT_ACK);
+
+        return msgtype == IBLND_MSG_GET_REQ ?
+               offsetof(kib_get_msg_t, ibgm_rd.rd_frags[n]) :
+               offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[n]);
+}
 
 #ifdef HAVE_OFED_IB_DMA_MAP
 
+static inline __u64
+kiblnd_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
+{
+        return ib_dma_mapping_error(dev, dma_addr);
+}
+
 static inline __u64 kiblnd_dma_map_single(struct ib_device *dev,
                                           void *msg, size_t size,
                                           enum dma_data_direction direction)
@@ -671,6 +866,12 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev,
 
 #else
 
+static inline __u64
+kiblnd_dma_mapping_error(struct ib_device *dev, dma_addr_t dma_addr)
+{
+        return dma_mapping_error(dma_addr);
+}
+
 static inline dma_addr_t kiblnd_dma_map_single(struct ib_device *dev,
                                                void *msg, size_t size,
                                                enum dma_data_direction direction)
@@ -721,9 +922,30 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev,
 
 #endif
 
+struct ib_mr *kiblnd_find_rd_dma_mr(kib_net_t *net,
+                                    kib_rdma_desc_t *rd);
+struct ib_mr *kiblnd_find_dma_mr(kib_net_t *net,
+                                 __u64 addr, __u64 size);
+void kiblnd_map_rx_descs(kib_conn_t *conn);
+void kiblnd_unmap_rx_descs(kib_conn_t *conn);
+int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
+                  kib_rdma_desc_t *rd, int nfrags);
+void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx);
+void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node);
+struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps);
+
+int  kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages,
+                         int npages, __u64 iov, kib_fmr_t *fmr);
+void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status);
+
+int  kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_rdma_desc_t *rd,
+                         __u64 *iova, kib_phys_mr_t **pp_pmr);
+void kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr);
+
 int  kiblnd_startup (lnet_ni_t *ni);
 void kiblnd_shutdown (lnet_ni_t *ni);
 int  kiblnd_ctl (lnet_ni_t *ni, unsigned int cmd, void *arg);
+void kiblnd_query (struct lnet_ni *ni, lnet_nid_t nid, time_t *when);
 
 int  kiblnd_tunables_init(void);
 void kiblnd_tunables_fini(void);
@@ -737,6 +959,7 @@ void kiblnd_free_pages (kib_pages_t *p);
 
 int  kiblnd_cm_callback(struct rdma_cm_id *cmid,
                         struct rdma_cm_event *event);
+int  kiblnd_translate_mtu(int value);
 
 int  kiblnd_create_peer (lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid);
 void kiblnd_destroy_peer (kib_peer_t *peer);
@@ -745,18 +968,21 @@ void kiblnd_unlink_peer_locked (kib_peer_t *peer);
 void kiblnd_peer_alive (kib_peer_t *peer);
 kib_peer_t *kiblnd_find_peer_locked (lnet_nid_t nid);
 void kiblnd_peer_connect_failed (kib_peer_t *peer, int active, int error);
-int  kiblnd_close_stale_conns_locked (kib_peer_t *peer, __u64 incarnation);
+int  kiblnd_close_stale_conns_locked (kib_peer_t *peer,
+                                      int version, __u64 incarnation);
+int  kiblnd_close_peer_conns_locked (kib_peer_t *peer, int why);
 
 void kiblnd_connreq_done(kib_conn_t *conn, int status);
 kib_conn_t *kiblnd_create_conn (kib_peer_t *peer, struct rdma_cm_id *cmid,
-                                int state);
+                                int state, int version);
 void kiblnd_destroy_conn (kib_conn_t *conn);
 void kiblnd_close_conn (kib_conn_t *conn, int error);
 void kiblnd_close_conn_locked (kib_conn_t *conn, int error);
 
-int  kiblnd_init_rdma (lnet_ni_t *ni, kib_tx_t *tx, int type,
+int  kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
                        int nob, kib_rdma_desc_t *dstrd, __u64 dstcookie);
 
+void kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid);
 void kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn);
 void kiblnd_queue_tx (kib_tx_t *tx, kib_conn_t *conn);
 void kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob);
@@ -767,8 +993,7 @@ void kiblnd_qp_event(struct ib_event *event, void *arg);
 void kiblnd_cq_event(struct ib_event *event, void *arg);
 void kiblnd_cq_completion(struct ib_cq *cq, void *arg);
 
-void kiblnd_init_msg (kib_msg_t *msg, int type, int body_nob);
-void kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg,
+void kiblnd_pack_msg (lnet_ni_t *ni, kib_msg_t *msg, int version,
                       int credits, lnet_nid_t dstnid, __u64 dststamp);
 int  kiblnd_unpack_msg(kib_msg_t *msg, int nob);
 int  kiblnd_post_rx (kib_rx_t *rx, int credit);
diff --git a/lnet/klnds/o2iblnd/o2iblnd_cb.c b/lnet/klnds/o2iblnd/o2iblnd_cb.c
index d516aab..70f24a8 100644
--- a/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -40,45 +40,6 @@
 
 #include "o2iblnd.h"
 
-char *
-kiblnd_msgtype2str(int type) 
-{
-        switch (type) {
-        case IBLND_MSG_CONNREQ:
-                return "CONNREQ";
-
-        case IBLND_MSG_CONNACK:
-                return "CONNACK";
-
-        case IBLND_MSG_NOOP:
-                return "NOOP";
-
-        case IBLND_MSG_IMMEDIATE:
-                return "IMMEDIATE";
-
-        case IBLND_MSG_PUT_REQ:
-                return "PUT_REQ";
-
-        case IBLND_MSG_PUT_NAK:
-                return "PUT_NAK";
-
-        case IBLND_MSG_PUT_ACK:
-                return "PUT_ACK";
-
-        case IBLND_MSG_PUT_DONE:
-                return "PUT_DONE";
-
-        case IBLND_MSG_GET_REQ:
-                return "GET_REQ";
-
-        case IBLND_MSG_GET_DONE:
-                return "GET_DONE";
-
-        default:
-                return "???";
-        }
-}
-
 void
 kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx)
 {
@@ -92,26 +53,10 @@ kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx)
         LASSERT (!tx->tx_queued);               /* mustn't be queued for sending */
         LASSERT (tx->tx_sending == 0);          /* mustn't be awaiting sent callback */
         LASSERT (!tx->tx_waiting);              /* mustn't be awaiting peer response */
+        LASSERT (tx->tx_pool != NULL);
 
-#if IBLND_MAP_ON_DEMAND
-        if (tx->tx_fmr != NULL) {
-                rc = ib_fmr_pool_unmap(tx->tx_fmr);
-                LASSERT (rc == 0);
-
-                if (tx->tx_status != 0) {
-                        rc = ib_flush_fmr_pool(net->ibn_fmrpool);
-                        LASSERT (rc == 0);
-                }
+        kiblnd_unmap_tx(ni, tx);
 
-                tx->tx_fmr = NULL;
-        }
-#else
-        if (tx->tx_nfrags != 0) {
-                kiblnd_dma_unmap_sg(net->ibn_dev->ibd_cmid->device,
-                                    tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);
-                tx->tx_nfrags = 0;
-        }
-#endif
         /* tx may have up to 2 lnet msgs to finalise */
         lntmsg[0] = tx->tx_lntmsg[0]; tx->tx_lntmsg[0] = NULL;
         lntmsg[1] = tx->tx_lntmsg[1]; tx->tx_lntmsg[1] = NULL;
@@ -127,11 +72,7 @@ kiblnd_tx_done (lnet_ni_t *ni, kib_tx_t *tx)
         tx->tx_nwrq = 0;
         tx->tx_status = 0;
 
-        spin_lock(&net->ibn_tx_lock);
-
-        list_add(&tx->tx_list, &net->ibn_idle_txs);
-
-        spin_unlock(&net->ibn_tx_lock);
+        kiblnd_pool_free_node(&tx->tx_pool->tpo_pool, &tx->tx_list);
 
         /* delay finalize until my descs have been freed */
         for (i = 0; i < 2; i++) {
@@ -150,7 +91,7 @@ kiblnd_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int status)
         while (!list_empty (txlist)) {
                 tx = list_entry (txlist->next, kib_tx_t, tx_list);
 
-                list_del (&tx->tx_list);
+                list_del(&tx->tx_list);
                 /* complete now */
                 tx->tx_waiting = 0;
                 tx->tx_status = status;
@@ -161,27 +102,14 @@ kiblnd_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int status)
 kib_tx_t *
 kiblnd_get_idle_tx (lnet_ni_t *ni)
 {
-        kib_net_t     *net = ni->ni_data;
-        kib_tx_t      *tx;
-
-        LASSERT (net != NULL);
-
-        spin_lock(&net->ibn_tx_lock);
+        kib_net_t        *net = (kib_net_t *)ni->ni_data;
+        struct list_head *node;
+        kib_tx_t         *tx;
 
-        if (list_empty(&net->ibn_idle_txs)) {
-                spin_unlock(&net->ibn_tx_lock);
+        node = kiblnd_pool_alloc_node(&net->ibn_tx_ps.tps_poolset);
+        if (node == NULL)
                 return NULL;
-        }
-
-        tx = list_entry(net->ibn_idle_txs.next, kib_tx_t, tx_list);
-        list_del(&tx->tx_list);
-
-        /* Allocate a new completion cookie.  It might not be needed,
-         * but we've got a lock right now and we're unlikely to
-         * wrap... */
-        tx->tx_cookie = kiblnd_data.kib_next_tx_cookie++;
-
-        spin_unlock(&net->ibn_tx_lock);
+        tx = container_of(node, kib_tx_t, tx_list);
 
         LASSERT (tx->tx_nwrq == 0);
         LASSERT (!tx->tx_queued);
@@ -191,11 +119,8 @@ kiblnd_get_idle_tx (lnet_ni_t *ni)
         LASSERT (tx->tx_conn == NULL);
         LASSERT (tx->tx_lntmsg[0] == NULL);
         LASSERT (tx->tx_lntmsg[1] == NULL);
-#if IBLND_MAP_ON_DEMAND
-        LASSERT (tx->tx_fmr == NULL);
-#else
+        LASSERT (tx->tx_u.pmr == NULL);
         LASSERT (tx->tx_nfrags == 0);
-#endif
 
         return tx;
 }
@@ -205,7 +130,7 @@ kiblnd_drop_rx (kib_rx_t *rx)
 {
         kib_conn_t         *conn = rx->rx_conn;
         unsigned long       flags;
-
+        
         spin_lock_irqsave(&kiblnd_data.kib_sched_lock, flags);
         LASSERT (conn->ibc_nrx > 0);
         conn->ibc_nrx--;
@@ -219,7 +144,8 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
 {
         kib_conn_t         *conn = rx->rx_conn;
         kib_net_t          *net = conn->ibc_peer->ibp_ni->ni_data;
-        struct ib_recv_wr  *bad_wrq;
+        struct ib_recv_wr  *bad_wrq = NULL;
+        struct ib_mr       *mr;
         int                 rc;
 
         LASSERT (net != NULL);
@@ -228,9 +154,12 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
                  credit == IBLND_POSTRX_PEER_CREDIT ||
                  credit == IBLND_POSTRX_RSRVD_CREDIT);
 
+        mr = kiblnd_find_dma_mr(net, rx->rx_msgaddr, IBLND_MSG_SIZE);
+        LASSERT (mr != NULL);
+
+        rx->rx_sge.lkey   = mr->lkey;
+        rx->rx_sge.addr   = rx->rx_msgaddr;
         rx->rx_sge.length = IBLND_MSG_SIZE;
-        rx->rx_sge.lkey = net->ibn_dev->ibd_mr->lkey;
-        rx->rx_sge.addr = rx->rx_msgaddr;
 
         rx->rx_wrq.next = NULL;
         rx->rx_wrq.sg_list = &rx->rx_sge;
@@ -248,13 +177,16 @@ kiblnd_post_rx (kib_rx_t *rx, int credit)
         rx->rx_nob = -1;                        /* flag posted */
 
         rc = ib_post_recv(conn->ibc_cmid->qp, &rx->rx_wrq, &bad_wrq);
+        if (rc != 0) {
+                CERROR("Can't post rx for %s: %d, bad_wrq: %p\n",
+                       libcfs_nid2str(conn->ibc_peer->ibp_nid), rc, bad_wrq);
+                rx->rx_nob = 0;
+        }
 
         if (conn->ibc_state < IBLND_CONN_ESTABLISHED) /* Initial post */
                 return rc;
 
         if (rc != 0) {
-                CERROR("Can't post rx for %s: %d\n",
-                       libcfs_nid2str(conn->ibc_peer->ibp_nid), rc);
                 kiblnd_close_conn(conn, rc);
                 kiblnd_drop_rx(rx);             /* No more posts for this rx */
                 return rc;
@@ -378,13 +310,14 @@ kiblnd_handle_rx (kib_rx_t *rx)
                 /* Have I received credits that will let me send? */
                 spin_lock(&conn->ibc_lock);
 
-                if (conn->ibc_credits + credits > IBLND_MSG_QUEUE_SIZE) {
+                if (conn->ibc_credits + credits >
+                    IBLND_MSG_QUEUE_SIZE(conn->ibc_version)) {
                         rc2 = conn->ibc_credits;
                         spin_unlock(&conn->ibc_lock);
 
                         CERROR("Bad credits from %s: %d + %d > %d\n",
                                libcfs_nid2str(conn->ibc_peer->ibp_nid),
-                               rc2, credits, IBLND_MSG_QUEUE_SIZE);
+                               rc2, credits, IBLND_MSG_QUEUE_SIZE(conn->ibc_version));
 
                         kiblnd_close_conn(conn, -EPROTO);
                         kiblnd_post_rx(rx, IBLND_POSTRX_NO_CREDIT);
@@ -393,10 +326,6 @@ kiblnd_handle_rx (kib_rx_t *rx)
 
                 conn->ibc_credits += credits;
 
-                /* This ensures the credit taken by NOOP can be returned */
-                if (msg->ibm_type == IBLND_MSG_NOOP)
-                        conn->ibc_outstanding_credits++;
-
                 spin_unlock(&conn->ibc_lock);
                 kiblnd_check_sends(conn);
         }
@@ -410,9 +339,9 @@ kiblnd_handle_rx (kib_rx_t *rx)
                 break;
 
         case IBLND_MSG_NOOP:
-                if (credits != 0) /* credit already posted */
+                if (IBLND_OOB_CAPABLE(conn->ibc_version))
                         post_credit = IBLND_POSTRX_NO_CREDIT;
-                else              /* a keepalive NOOP */
+                else
                         post_credit = IBLND_POSTRX_PEER_CREDIT;
                 break;
 
@@ -464,7 +393,7 @@ kiblnd_handle_rx (kib_rx_t *rx)
 
                 tx->tx_nwrq = 0;                /* overwrite PUT_REQ */
 
-                rc2 = kiblnd_init_rdma(ni, tx, IBLND_MSG_PUT_DONE,
+                rc2 = kiblnd_init_rdma(conn, tx, IBLND_MSG_PUT_DONE,
                                        kiblnd_rd_size(&msg->ibm_u.putack.ibpam_rd),
                                        &msg->ibm_u.putack.ibpam_rd,
                                        msg->ibm_u.putack.ibpam_dst_cookie);
@@ -515,7 +444,6 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
         kib_conn_t   *conn = rx->rx_conn;
         lnet_ni_t    *ni = conn->ibc_peer->ibp_ni;
         kib_net_t    *net = ni->ni_data;
-        unsigned long flags;
         int           rc;
         int           err = -EIO;
 
@@ -558,16 +486,17 @@ kiblnd_rx_complete (kib_rx_t *rx, int status, int nob)
         /* racing with connection establishment/teardown! */
 
         if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
-                write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
+                rwlock_t      *g_lock = &kiblnd_data.kib_global_lock;
+                unsigned long  flags;
+
+                write_lock_irqsave(g_lock, flags);
                 /* must check holding global lock to eliminate race */
                 if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
                         list_add_tail(&rx->rx_list, &conn->ibc_early_rxs);
-                        write_unlock_irqrestore(&kiblnd_data.kib_global_lock,
-                                                flags);
+                        write_unlock_irqrestore(g_lock, flags);
                         return;
                 }
-                write_unlock_irqrestore(&kiblnd_data.kib_global_lock,
-                                        flags);
+                write_unlock_irqrestore(g_lock, flags);
         }
         kiblnd_handle_rx(rx);
         return;
@@ -603,19 +532,141 @@ kiblnd_kvaddr_to_page (unsigned long vaddr)
         return page;
 }
 
-#if !IBLND_MAP_ON_DEMAND
+static int
+kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
+{
+        kib_dev_t          *ibdev  = net->ibn_dev;
+        __u64              *pages  = tx->tx_pages;
+        int                 npages;
+        int                 size;
+        int                 rc;
+        int                 i;
+
+        for (i = 0, npages = 0; i < rd->rd_nfrags; i++) {
+                for (size = 0; size <  rd->rd_frags[i].rf_nob;
+                               size += ibdev->ibd_page_size) {
+                        pages[npages ++] = (rd->rd_frags[i].rf_addr &
+                                            ibdev->ibd_page_mask) + size;
+                }
+        }
+
+        rc = kiblnd_fmr_pool_map(&net->ibn_fmr_ps, pages, npages, 0, &tx->tx_u.fmr);
+        if (rc != 0) {
+                CERROR ("Can't map %d pages: %d\n", npages, rc);
+                return rc;
+        }
+
+        /* If rd is not tx_rd, it's going to get sent to a peer, who will need
+         * the rkey */
+        rd->rd_key = (rd != tx->tx_rd) ? tx->tx_u.fmr.fmr_pfmr->fmr->rkey :
+                                         tx->tx_u.fmr.fmr_pfmr->fmr->lkey;
+        rd->rd_frags[0].rf_addr &= ~ibdev->ibd_page_mask;
+        rd->rd_frags[0].rf_nob   = nob;
+        rd->rd_nfrags = 1;
+
+        return 0;
+}
+
+static int
+kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
+{
+        __u64   iova;
+        int     rc;
+
+        iova = rd->rd_frags[0].rf_addr & ~net->ibn_dev->ibd_page_mask;
+
+        rc = kiblnd_pmr_pool_map(&net->ibn_pmr_ps, rd, &iova, &tx->tx_u.pmr);
+        if (rc != 0) {
+                CERROR("Failed to create MR by phybuf: %d\n", rc);
+                return rc;
+        }
+
+        /* If rd is not tx_rd, it's going to get sent to a peer, who will need
+         * the rkey */
+        rd->rd_key = (rd != tx->tx_rd) ? tx->tx_u.pmr->pmr_mr->rkey :
+                                         tx->tx_u.pmr->pmr_mr->lkey;
+        rd->rd_nfrags = 1;
+        rd->rd_frags[0].rf_addr = iova;
+        rd->rd_frags[0].rf_nob  = nob;
+
+        return 0;
+}
+
+void
+kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
+{
+        kib_net_t  *net = ni->ni_data;
+
+        LASSERT (net != NULL);
+
+        if (net->ibn_with_fmr && tx->tx_u.fmr.fmr_pfmr != NULL) {
+                kiblnd_fmr_pool_unmap(&tx->tx_u.fmr, tx->tx_status);
+                tx->tx_u.fmr.fmr_pfmr = NULL;
+        } else if (net->ibn_with_pmr && tx->tx_u.pmr != NULL) {
+                kiblnd_pmr_pool_unmap(tx->tx_u.pmr);
+                tx->tx_u.pmr = NULL;
+        }
+
+        if (tx->tx_nfrags != 0) {
+                kiblnd_dma_unmap_sg(net->ibn_dev->ibd_cmid->device,
+                                    tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);
+                tx->tx_nfrags = 0;
+        }
+}
+
 int
-kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, 
-                    unsigned int niov, struct iovec *iov, int offset, int nob)
+kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
+              kib_rdma_desc_t *rd, int nfrags)
+{
+        kib_net_t          *net   = ni->ni_data;
+        struct ib_mr       *mr    = NULL;
+        __u32               nob;
+        int                 i;
+
+        /* If rd is not tx_rd, it's going to get sent to a peer and I'm the
+         * RDMA sink */
+        tx->tx_dmadir = (rd != tx->tx_rd) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
+        tx->tx_nfrags = nfrags;
 
+        rd->rd_nfrags =
+                kiblnd_dma_map_sg(net->ibn_dev->ibd_cmid->device,
+                                  tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);
+
+        for (i = 0, nob = 0; i < rd->rd_nfrags; i++) {
+                rd->rd_frags[i].rf_nob  = kiblnd_sg_dma_len(
+                        net->ibn_dev->ibd_cmid->device, &tx->tx_frags[i]);
+                rd->rd_frags[i].rf_addr = kiblnd_sg_dma_address(
+                        net->ibn_dev->ibd_cmid->device, &tx->tx_frags[i]);
+                nob += rd->rd_frags[i].rf_nob;
+        }
+
+        /* looking for pre-mapping MR */
+        mr = kiblnd_find_rd_dma_mr(net, rd);
+        if (mr != NULL) {
+                /* found pre-mapping MR */
+                rd->rd_key = (rd != tx->tx_rd) ? mr->rkey : mr->lkey;
+                return 0;
+        }
+
+        if (net->ibn_with_fmr)
+                return kiblnd_fmr_map_tx(net, tx, rd, nob);
+        else if (net->ibn_with_pmr)
+                return kiblnd_pmr_map_tx(net, tx, rd, nob);
+
+        return -EINVAL;
+}
+
+
+int
+kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
+                    unsigned int niov, struct iovec *iov, int offset, int nob)
 {
+        kib_net_t          *net = ni->ni_data;
+        struct page        *page;
         struct scatterlist *sg;
-        int                 i;
-        int                 fragnob;
         unsigned long       vaddr;
-        struct page        *page;
+        int                 fragnob;
         int                 page_offset;
-        kib_net_t          *net = ni->ni_data;
 
         LASSERT (nob > 0);
         LASSERT (niov > 0);
@@ -656,35 +707,16 @@ kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
                 nob -= fragnob;
         } while (nob > 0);
 
-        /* If rd is not tx_rd, it's going to get sent to a peer and I'm the
-         * RDMA sink */
-        tx->tx_nfrags = sg - tx->tx_frags;
-        tx->tx_dmadir = (rd != tx->tx_rd) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
-
-        rd->rd_nfrags = kiblnd_dma_map_sg(net->ibn_dev->ibd_cmid->device,
-                                          tx->tx_frags, tx->tx_nfrags,
-                                          tx->tx_dmadir);
-        rd->rd_key    = (rd != tx->tx_rd) ? 
-                        net->ibn_dev->ibd_mr->rkey : net->ibn_dev->ibd_mr->lkey;
-
-        for (i = 0; i < rd->rd_nfrags; i++) {
-                rd->rd_frags[i].rf_nob  = kiblnd_sg_dma_len(
-                        net->ibn_dev->ibd_cmid->device, &tx->tx_frags[i]);
-                rd->rd_frags[i].rf_addr = kiblnd_sg_dma_address(
-                        net->ibn_dev->ibd_cmid->device, &tx->tx_frags[i]);
-        }
-
-        return 0;
+        return kiblnd_map_tx(ni, tx, rd, sg - tx->tx_frags);
 }
 
 int
-kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, 
+kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
                       int nkiov, lnet_kiov_t *kiov, int offset, int nob)
 {
+        kib_net_t          *net = ni->ni_data;
         struct scatterlist *sg;
-        int                 i;
         int                 fragnob;
-        kib_net_t          *net = ni->ni_data;
 
         CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob);
 
@@ -716,175 +748,138 @@ kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
                 nob -= fragnob;
         } while (nob > 0);
 
-        /* If rd is not tx_rd, it's going to get sent to a peer and I'm the
-         * RDMA sink */
-        tx->tx_nfrags = sg - tx->tx_frags;
-        tx->tx_dmadir = (rd != tx->tx_rd) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
-
-        rd->rd_nfrags = kiblnd_dma_map_sg(net->ibn_dev->ibd_cmid->device,
-                                          tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);
-        rd->rd_key    = (rd != tx->tx_rd) ? 
-                        net->ibn_dev->ibd_mr->rkey : net->ibn_dev->ibd_mr->lkey;
-
-        for (i = 0; i < tx->tx_nfrags; i++) {
-                rd->rd_frags[i].rf_nob  = kiblnd_sg_dma_len(
-                        net->ibn_dev->ibd_cmid->device, &tx->tx_frags[i]);
-                rd->rd_frags[i].rf_addr = kiblnd_sg_dma_address(
-                        net->ibn_dev->ibd_cmid->device, &tx->tx_frags[i]);
-#if 0
-                CDEBUG(D_WARNING,"frag[%d]: "LPX64" for %d\n",
-                       i, rd->rd_frags[i].rf_addr, rd->rd_frags[i].rf_nob);
-#endif
-        }
-
-        return 0;
+        return kiblnd_map_tx(ni, tx, rd, sg - tx->tx_frags);
 }
-#else
+
 int
-kiblnd_map_tx (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
-               int npages, unsigned long page_offset, int nob)
+kiblnd_post_tx_locked (kib_conn_t *conn, kib_tx_t *tx, int credit)
 {
-        struct ib_pool_fmr *fmr;
-        kib_net_t          *net = ni->ni_data;
+        kib_msg_t         *msg = tx->tx_msg;
+        kib_peer_t        *peer = conn->ibc_peer;
+        int                ver = conn->ibc_version;
+        int                rc;
+        int                done;
+        struct ib_send_wr *bad_wrq;
 
-        LASSERT (net != NULL);
-        LASSERT (tx->tx_fmr == NULL);
-        LASSERT (page_offset < PAGE_SIZE);
-        LASSERT (npages >= (1 + ((page_offset + nob - 1)>>PAGE_SHIFT)));
-        LASSERT (npages <= LNET_MAX_IOV);
+        LASSERT (tx->tx_queued);
+        /* We rely on this for QP sizing */
+        LASSERT (tx->tx_nwrq > 0);
+        LASSERT (tx->tx_nwrq <= 1 + IBLND_RDMA_FRAGS(ver));
 
-        rd->rd_addr = 0;
+        LASSERT (credit == 0 || credit == 1);
+        LASSERT (conn->ibc_outstanding_credits >= 0);
+        LASSERT (conn->ibc_outstanding_credits <= IBLND_MSG_QUEUE_SIZE(ver));
+        LASSERT (conn->ibc_credits >= 0);
+        LASSERT (conn->ibc_credits <= IBLND_MSG_QUEUE_SIZE(ver));
 
-        fmr = ib_fmr_pool_map_phys(net->ibn_fmrpool, tx->tx_pages,
-                                   npages, rd->rd_addr);
-        if (IS_ERR(fmr)) {
-                CERROR ("Can't map %d pages: %ld\n", npages, PTR_ERR(fmr));
-                return PTR_ERR(fmr);
+        if (conn->ibc_nsends_posted == IBLND_CONCURRENT_SENDS(ver)) {
+                /* tx completions outstanding... */
+                CDEBUG(D_NET, "%s: posted enough\n",
+                       libcfs_nid2str(peer->ibp_nid));
+                return -EAGAIN;
         }
 
-        /* If rd is not tx_rd, it's going to get sent to a peer, who will need
-         * the rkey */
-
-        rd->rd_key = (rd != tx->tx_rd) ? fmr->fmr->rkey : fmr->fmr->lkey;
-        rd->rd_nob = nob;
-
-        tx->tx_fmr = fmr;
-        return 0;
-}
-
-int
-kiblnd_setup_rd_iov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
-                     unsigned int niov, struct iovec *iov, int offset, int nob)
-
-{
-        int           resid;
-        int           fragnob;
-        struct page  *page;
-        int           npages;
-        unsigned long page_offset;
-        unsigned long vaddr;
-
-        LASSERT (nob > 0);
-        LASSERT (niov > 0);
-
-        while (offset >= iov->iov_len) {
-                offset -= iov->iov_len;
-                niov--;
-                iov++;
-                LASSERT (niov > 0);
+        if (credit != 0 && conn->ibc_credits == 0) {   /* no credits */
+                CDEBUG(D_NET, "%s: no credits\n",
+                       libcfs_nid2str(peer->ibp_nid));
+                return -EAGAIN;
         }
 
-        if (nob > iov->iov_len - offset) {
-                CERROR ("Can't map multiple vaddr fragments\n");
-                return (-EMSGSIZE);
+        if (credit != 0 && !IBLND_OOB_CAPABLE(ver) &&
+            conn->ibc_credits == 1 &&   /* last credit reserved for */
+            conn->ibc_outstanding_credits == 0) { /* giving back credits */
+                CDEBUG(D_NET, "%s: not using last credit\n",
+                       libcfs_nid2str(peer->ibp_nid));
+                return -EAGAIN;
         }
 
-        vaddr = ((unsigned long)iov->iov_base) + offset;
-
-        page_offset = vaddr & (PAGE_SIZE - 1);
-        resid = nob;
-        npages = 0;
-
-        do {
-                LASSERT (npages < LNET_MAX_IOV);
-
-                page = kiblnd_kvaddr_to_page(vaddr);
-                if (page == NULL) {
-                        CERROR("Can't find page for %lu\n", vaddr);
-                        return -EFAULT;
-                }
-
-                tx->tx_pages[npages++] = lnet_page2phys(page);
-
-                fragnob = PAGE_SIZE - (vaddr & (PAGE_SIZE - 1));
-                vaddr += fragnob;
-                resid -= fragnob;
-
-        } while (resid > 0);
+        /* NB don't drop ibc_lock before bumping tx_sending */
+        list_del(&tx->tx_list);
+        tx->tx_queued = 0;
+
+        if (msg->ibm_type == IBLND_MSG_NOOP &&
+            (!kiblnd_send_noop(conn) ||     /* redundant NOOP */
+             (IBLND_OOB_CAPABLE(ver) && /* posted enough NOOP */
+              conn->ibc_noops_posted == IBLND_OOB_MSGS(ver)))) {
+                /* OK to drop when posted enough NOOPs, since
+                 * kiblnd_check_sends will queue NOOP again when
+                 * posted NOOPs complete */
+                spin_unlock(&conn->ibc_lock);
+                kiblnd_tx_done(peer->ibp_ni, tx);
+                spin_lock(&conn->ibc_lock);
+                CDEBUG(D_NET, "%s(%d): redundant or enough NOOP\n",
+                       libcfs_nid2str(peer->ibp_nid),
+                       conn->ibc_noops_posted);
+                return 0;
+        }
 
-        return kiblnd_map_tx(ni, tx, rd, npages, page_offset, nob);
-}
+        kiblnd_pack_msg(peer->ibp_ni, msg, ver, conn->ibc_outstanding_credits,
+                        peer->ibp_nid, conn->ibc_incarnation);
 
-int
-kiblnd_setup_rd_kiov (lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
-                      int nkiov, lnet_kiov_t *kiov, int offset, int nob)
-{
-        int            resid;
-        int            npages;
-        unsigned long  page_offset;
+        conn->ibc_credits -= credit;
+        conn->ibc_outstanding_credits = 0;
+        conn->ibc_nsends_posted++;
+        if (msg->ibm_type == IBLND_MSG_NOOP)
+                conn->ibc_noops_posted++;
 
-        CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob);
+        /* CAVEAT EMPTOR!  This tx could be the PUT_DONE of an RDMA
+         * PUT.  If so, it was first queued here as a PUT_REQ, sent and
+         * stashed on ibc_active_txs, matched by an incoming PUT_ACK,
+         * and then re-queued here.  It's (just) possible that
+         * tx_sending is non-zero if we've not done the tx_complete()
+         * from the first send; hence the ++ rather than = below. */
+        tx->tx_sending++;
+        list_add(&tx->tx_list, &conn->ibc_active_txs);
 
-        LASSERT (nob > 0);
-        LASSERT (nkiov > 0);
-        LASSERT (nkiov <= LNET_MAX_IOV);
+        /* I'm still holding ibc_lock! */
+        if (conn->ibc_state != IBLND_CONN_ESTABLISHED)
+                rc = -ECONNABORTED;
+        else
+                rc = ib_post_send(conn->ibc_cmid->qp,
+                                  tx->tx_wrq, &bad_wrq);
+        conn->ibc_last_send = jiffies;
 
-        while (offset >= kiov->kiov_len) {
-                offset -= kiov->kiov_len;
-                nkiov--;
-                kiov++;
-                LASSERT (nkiov > 0);
-        }
+        if (rc == 0)
+                return 0;
 
-        page_offset = kiov->kiov_offset + offset;
+        /* NB credits are transferred in the actual
+         * message, which can only be the last work item */
+        conn->ibc_credits += credit;
+        conn->ibc_outstanding_credits += msg->ibm_credits;
+        conn->ibc_nsends_posted--;
+        if (msg->ibm_type == IBLND_MSG_NOOP)
+                conn->ibc_noops_posted--;
 
-        resid = offset + nob;
-        npages = 0;
+        tx->tx_status = rc;
+        tx->tx_waiting = 0;
+        tx->tx_sending--;
 
-        do {
-                LASSERT (npages < LNET_MAX_IOV);
-                LASSERT (nkiov > 0);
+        done = (tx->tx_sending == 0);
+        if (done)
+                list_del(&tx->tx_list);
 
-                if ((npages > 0 && kiov->kiov_offset != 0) ||
-                    (resid > kiov->kiov_len &&
-                     (kiov->kiov_offset + kiov->kiov_len) != PAGE_SIZE)) {
-                        /* Can't have gaps */
-                        CERROR ("Can't make payload contiguous in I/O VM:"
-                                "page %d, offset %d, len %d \n",
-                                npages, kiov->kiov_offset, kiov->kiov_len);
+        spin_unlock(&conn->ibc_lock);
 
-                        return -EINVAL;
-                }
+        if (conn->ibc_state == IBLND_CONN_ESTABLISHED)
+                CERROR("Error %d posting transmit to %s\n",
+                       rc, libcfs_nid2str(peer->ibp_nid));
+        else
+                CDEBUG(D_NET, "Error %d posting transmit to %s\n",
+                       rc, libcfs_nid2str(peer->ibp_nid));
 
-                tx->tx_pages[npages++] = lnet_page2phys(kiov->kiov_page);
-                resid -= kiov->kiov_len;
-                kiov++;
-                nkiov--;
-        } while (resid > 0);
+        kiblnd_close_conn(conn, rc);
 
-        return kiblnd_map_tx(ni, tx, rd, npages, page_offset, nob);
+        if (done)
+                kiblnd_tx_done(peer->ibp_ni, tx);
+        return -EIO;
 }
-#endif
 
 void
 kiblnd_check_sends (kib_conn_t *conn)
 {
-        kib_tx_t          *tx;
-        lnet_ni_t         *ni = conn->ibc_peer->ibp_ni;
-        int                rc;
-        int                consume_cred = 0;
-        struct ib_send_wr *bad_wrq;
-        int                done;
+        int        ver = conn->ibc_version;
+        lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+        kib_tx_t  *tx;
 
         /* Don't send anything until after the connection is established */
         if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
@@ -895,8 +890,9 @@ kiblnd_check_sends (kib_conn_t *conn)
 
         spin_lock(&conn->ibc_lock);
 
-        LASSERT (conn->ibc_nsends_posted <=
-                 *kiblnd_tunables.kib_concurrent_sends);
+        LASSERT (conn->ibc_nsends_posted <= IBLND_CONCURRENT_SENDS(ver));
+        LASSERT (!IBLND_OOB_CAPABLE(ver) ||
+                 conn->ibc_noops_posted <= IBLND_OOB_MSGS(ver));
         LASSERT (conn->ibc_reserved_credits >= 0);
 
         while (conn->ibc_reserved_credits > 0 &&
@@ -916,163 +912,26 @@ kiblnd_check_sends (kib_conn_t *conn)
                         kiblnd_init_tx_msg(ni, tx, IBLND_MSG_NOOP, 0);
 
                 spin_lock(&conn->ibc_lock);
-
                 if (tx != NULL)
                         kiblnd_queue_tx_locked(tx, conn);
         }
 
         for (;;) {
+                int credit;
+
                 if (!list_empty(&conn->ibc_tx_queue_nocred)) {
-                        tx = list_entry(conn->ibc_tx_queue_nocred.next, 
+                        credit = 0;
+                        tx = list_entry(conn->ibc_tx_queue_nocred.next,
                                         kib_tx_t, tx_list);
-                        consume_cred = 0;
-                } else if (!list_empty(&conn->ibc_tx_noops)) {
-                        tx = list_entry(conn->ibc_tx_noops.next,
-                                        kib_tx_t, tx_list);
-                        consume_cred = 1;
                 } else if (!list_empty(&conn->ibc_tx_queue)) {
+                        credit = 1;
                         tx = list_entry(conn->ibc_tx_queue.next,
                                         kib_tx_t, tx_list);
-                        consume_cred = 1;
-                } else {
-                        /* nothing to send right now */
+                } else
                         break;
-                }
-
-                LASSERT (tx->tx_queued);
-                /* We rely on this for QP sizing */
-                LASSERT (tx->tx_nwrq > 0 &&
-                         tx->tx_nwrq <= 1 + IBLND_MAX_RDMA_FRAGS);
-
-                LASSERT (conn->ibc_outstanding_credits >= 0);
-                LASSERT (conn->ibc_outstanding_credits <= IBLND_MSG_QUEUE_SIZE);
-                LASSERT (conn->ibc_credits >= 0);
-                LASSERT (conn->ibc_credits <= IBLND_MSG_QUEUE_SIZE);
 
-                if (conn->ibc_nsends_posted == 
-                    *kiblnd_tunables.kib_concurrent_sends) {
-                        /* tx completions outstanding... */
-                        CDEBUG(D_NET, "%s: posted enough\n",
-                               libcfs_nid2str(conn->ibc_peer->ibp_nid));
+                if (kiblnd_post_tx_locked(conn, tx, credit) != 0)
                         break;
-                }
-
-                if (consume_cred) {
-                        if (conn->ibc_credits == 0) {   /* no credits */
-                                CDEBUG(D_NET, "%s: no credits\n",
-                                       libcfs_nid2str(conn->ibc_peer->ibp_nid));
-                                break; /* NB ibc_tx_queue_nocred checked */
-                        }
-
-                        /* Last credit reserved for NOOP */
-                        if (conn->ibc_credits == 1 &&
-                            tx->tx_msg->ibm_type != IBLND_MSG_NOOP) {
-                                CDEBUG(D_NET, "%s: not using last credit\n",
-                                       libcfs_nid2str(conn->ibc_peer->ibp_nid));
-                                break; /* NB ibc_tx_noops checked */
-                        }
-                }
-
-                list_del(&tx->tx_list);
-                tx->tx_queued = 0;
-
-                /* NB don't drop ibc_lock before bumping tx_sending */
-
-                if (tx->tx_msg->ibm_type == IBLND_MSG_NOOP &&
-                    !kiblnd_send_noop(conn)) {
-                        /* redundant NOOP */
-                        spin_unlock(&conn->ibc_lock);
-                        kiblnd_tx_done(ni, tx);
-                        spin_lock(&conn->ibc_lock);
-                        CDEBUG(D_NET, "%s: redundant noop\n",
-                               libcfs_nid2str(conn->ibc_peer->ibp_nid));
-                        continue;
-                }
-
-                kiblnd_pack_msg(ni, tx->tx_msg, conn->ibc_outstanding_credits,
-                                conn->ibc_peer->ibp_nid, conn->ibc_incarnation);
-
-                conn->ibc_outstanding_credits = 0;
-                conn->ibc_nsends_posted++;
-                if (consume_cred)
-                        conn->ibc_credits--;
-
-                /* CAVEAT EMPTOR!  This tx could be the PUT_DONE of an RDMA
-                 * PUT.  If so, it was first queued here as a PUT_REQ, sent and
-                 * stashed on ibc_active_txs, matched by an incoming PUT_ACK,
-                 * and then re-queued here.  It's (just) possible that
-                 * tx_sending is non-zero if we've not done the tx_complete() from
-                 * the first send; hence the ++ rather than = below. */
-                tx->tx_sending++;
-
-                list_add (&tx->tx_list, &conn->ibc_active_txs);
-#if 0
-                {
-                        int i;
-
-                        for (i = 0; i < tx->tx_nwrq - 1; i++) {
-                                LASSERT (tx->tx_wrq[i].opcode == IB_WR_RDMA_WRITE);
-                                LASSERT (tx->tx_wrq[i].next == &tx->tx_wrq[i+1]);
-                                LASSERT (tx->tx_wrq[i].sg_list == &tx->tx_sge[i]);
-
-                                CDEBUG(D_WARNING, "WORK[%d]: RDMA "LPX64
-                                       " for %d k %x -> "LPX64" k %x\n", i,
-                                       tx->tx_wrq[i].sg_list->addr,
-                                       tx->tx_wrq[i].sg_list->length,
-                                       tx->tx_wrq[i].sg_list->lkey,
-                                       tx->tx_wrq[i].wr.rdma.remote_addr,
-                                       tx->tx_wrq[i].wr.rdma.rkey);
-                        }
-
-                        LASSERT (tx->tx_wrq[i].opcode == IB_WR_SEND);
-                        LASSERT (tx->tx_wrq[i].next == NULL);
-                        LASSERT (tx->tx_wrq[i].sg_list == &tx->tx_sge[i]);
-
-                        CDEBUG(D_WARNING, "WORK[%d]: SEND "LPX64" for %d k %x\n", i,
-                               tx->tx_wrq[i].sg_list->addr,
-                               tx->tx_wrq[i].sg_list->length,
-                               tx->tx_wrq[i].sg_list->lkey);
-                }
-#endif           
-                /* I'm still holding ibc_lock! */
-                if (conn->ibc_state != IBLND_CONN_ESTABLISHED)
-                        rc = -ECONNABORTED;
-                else
-                        rc = ib_post_send(conn->ibc_cmid->qp, tx->tx_wrq, &bad_wrq);
-
-                conn->ibc_last_send = jiffies;
-
-                if (rc != 0) {
-                        /* NB credits are transferred in the actual
-                         * message, which can only be the last work item */
-                        conn->ibc_outstanding_credits += tx->tx_msg->ibm_credits;
-                        if (consume_cred)
-                                conn->ibc_credits++;
-                        conn->ibc_nsends_posted--;
-
-                        tx->tx_status = rc;
-                        tx->tx_waiting = 0;
-                        tx->tx_sending--;
-
-                        done = (tx->tx_sending == 0);
-                        if (done)
-                                list_del (&tx->tx_list);
-
-                        spin_unlock(&conn->ibc_lock);
-
-                        if (conn->ibc_state == IBLND_CONN_ESTABLISHED)
-                                CERROR("Error %d posting transmit to %s\n",
-                                       rc, libcfs_nid2str(conn->ibc_peer->ibp_nid));
-                        else
-                                CDEBUG(D_NET, "Error %d posting transmit to %s\n",
-                                       rc, libcfs_nid2str(conn->ibc_peer->ibp_nid));
-
-                        kiblnd_close_conn(conn, rc);
-
-                        if (done)
-                                kiblnd_tx_done(ni, tx);
-                        return;
-                }
         }
 
         spin_unlock(&conn->ibc_lock);
@@ -1107,6 +966,8 @@ kiblnd_tx_complete (kib_tx_t *tx, int status)
 
         tx->tx_sending--;
         conn->ibc_nsends_posted--;
+        if (tx->tx_msg->ibm_type == IBLND_MSG_NOOP)
+                conn->ibc_noops_posted--;
 
         if (failed) {
                 tx->tx_waiting = 0;             /* don't wait for peer */
@@ -1138,6 +999,7 @@ kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
         struct ib_sge     *sge = &tx->tx_sge[tx->tx_nwrq];
         struct ib_send_wr *wrq = &tx->tx_wrq[tx->tx_nwrq];
         int                nob = offsetof (kib_msg_t, ibm_u) + body_nob;
+        struct ib_mr      *mr;
 
         LASSERT (net != NULL);
         LASSERT (tx->tx_nwrq >= 0);
@@ -1146,8 +1008,11 @@ kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
 
         kiblnd_init_msg(tx->tx_msg, type, body_nob);
 
-        sge->addr = tx->tx_msgaddr;
-        sge->lkey = net->ibn_dev->ibd_mr->lkey;
+        mr = kiblnd_find_dma_mr(net, tx->tx_msgaddr, nob);
+        LASSERT (mr != NULL);
+
+        sge->lkey   = mr->lkey;
+        sge->addr   = tx->tx_msgaddr;
         sge->length = nob;
 
         memset(wrq, 0, sizeof(*wrq));
@@ -1163,46 +1028,17 @@ kiblnd_init_tx_msg (lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
 }
 
 int
-kiblnd_init_rdma (lnet_ni_t *ni, kib_tx_t *tx, int type,
-                  int nob, kib_rdma_desc_t *dstrd, __u64 dstcookie)
+kiblnd_init_rdma (kib_conn_t *conn, kib_tx_t *tx, int type,
+                  int resid, kib_rdma_desc_t *dstrd, __u64 dstcookie)
 {
         kib_msg_t         *ibmsg = tx->tx_msg;
         kib_rdma_desc_t   *srcrd = tx->tx_rd;
         struct ib_sge     *sge = &tx->tx_sge[0];
         struct ib_send_wr *wrq = &tx->tx_wrq[0];
-        int                rc = nob;
-
-#if IBLND_MAP_ON_DEMAND
-        LASSERT (!in_interrupt());
-        LASSERT (tx->tx_nwrq == 0);
-        LASSERT (type == IBLND_MSG_GET_DONE ||
-                 type == IBLND_MSG_PUT_DONE);
-
-        sge->addr = srcrd->rd_addr;
-        sge->lkey = srcrd->rd_key;
-        sge->length = nob;
-
-        wrq = &tx->tx_wrq[0];
-
-        wrq->next       = &tx->tx_wrq[1];
-        wrq->wr_id      = kiblnd_ptr2wreqid(tx, IBLND_WID_RDMA);
-        wrq->sg_list    = sge;
-        wrq->num_sge    = 1;
-        wrq->opcode     = IB_WR_RDMA_WRITE;
-        wrq->send_flags = 0;
-
-        wrq->wr.rdma.remote_addr = dstrd->rd_addr;
-        wrq->wr.rdma.rkey        = dstrd->rd_key;
-
-        tx->tx_nwrq = 1;
-#else
-        /* CAVEAT EMPTOR: this 'consumes' the frags in 'dstrd' */
-        int              resid = nob;
-        kib_rdma_frag_t *srcfrag;
-        int              srcidx;
-        kib_rdma_frag_t *dstfrag;
-        int              dstidx;
-        int              wrknob;
+        int                rc  = resid;
+        int                srcidx;
+        int                dstidx;
+        int                wrknob;
 
         LASSERT (!in_interrupt());
         LASSERT (tx->tx_nwrq == 0);
@@ -1210,8 +1046,6 @@ kiblnd_init_rdma (lnet_ni_t *ni, kib_tx_t *tx, int type,
                  type == IBLND_MSG_PUT_DONE);
 
         srcidx = dstidx = 0;
-        srcfrag = &srcrd->rd_frags[0];
-        dstfrag = &dstrd->rd_frags[0];
 
         while (resid > 0) {
                 if (srcidx >= srcrd->rd_nfrags) {
@@ -1226,20 +1060,24 @@ kiblnd_init_rdma (lnet_ni_t *ni, kib_tx_t *tx, int type,
                         break;
                 }
 
-                if (tx->tx_nwrq == IBLND_MAX_RDMA_FRAGS) {
-                        CERROR("RDMA too fragmented: %d/%d src %d/%d dst frags\n",
+                if (tx->tx_nwrq == IBLND_RDMA_FRAGS(conn->ibc_version)) {
+                        CERROR("RDMA too fragmented for %s (%d): "
+                               "%d/%d src %d/%d dst frags\n",
+                               libcfs_nid2str(conn->ibc_peer->ibp_nid),
+                               IBLND_RDMA_FRAGS(conn->ibc_version),
                                srcidx, srcrd->rd_nfrags,
                                dstidx, dstrd->rd_nfrags);
                         rc = -EMSGSIZE;
                         break;
                 }
 
-                wrknob = MIN(MIN(srcfrag->rf_nob, dstfrag->rf_nob), resid);
+                wrknob = MIN(MIN(kiblnd_rd_frag_size(srcrd, srcidx),
+                                 kiblnd_rd_frag_size(dstrd, dstidx)), resid);
 
                 sge = &tx->tx_sge[tx->tx_nwrq];
-                sge->addr   = srcfrag->rf_addr;
+                sge->addr   = kiblnd_rd_frag_addr(srcrd, srcidx);
+                sge->lkey   = kiblnd_rd_frag_key(srcrd, srcidx);
                 sge->length = wrknob;
-                sge->lkey   = srcrd->rd_key;
 
                 wrq = &tx->tx_wrq[tx->tx_nwrq];
 
@@ -1250,38 +1088,26 @@ kiblnd_init_rdma (lnet_ni_t *ni, kib_tx_t *tx, int type,
                 wrq->opcode     = IB_WR_RDMA_WRITE;
                 wrq->send_flags = 0;
 
-                wrq->wr.rdma.remote_addr = dstfrag->rf_addr;
-                wrq->wr.rdma.rkey        = dstrd->rd_key;
+                wrq->wr.rdma.remote_addr = kiblnd_rd_frag_addr(dstrd, dstidx);
+                wrq->wr.rdma.rkey        = kiblnd_rd_frag_key(dstrd, dstidx);
 
-                wrq++;
-                sge++;
+                srcidx = kiblnd_rd_consume_frag(srcrd, srcidx, wrknob);
+                dstidx = kiblnd_rd_consume_frag(dstrd, dstidx, wrknob);
 
                 resid -= wrknob;
-                if (wrknob < srcfrag->rf_nob) {
-                        srcfrag->rf_nob  -= wrknob;
-                        srcfrag->rf_addr += wrknob;
-                } else {
-                        srcfrag++;
-                        srcidx++;
-                }
-
-                if (wrknob < dstfrag->rf_nob) {
-                        dstfrag->rf_nob  -= wrknob;
-                        dstfrag->rf_addr += wrknob;
-                } else {
-                        dstfrag++;
-                        dstidx++;
-                }
 
                 tx->tx_nwrq++;
+                wrq++;
+                sge++;
         }
 
         if (rc < 0)                             /* no RDMA if completing with failure */
                 tx->tx_nwrq = 0;
-#endif
+
         ibmsg->ibm_u.completion.ibcm_status = rc;
         ibmsg->ibm_u.completion.ibcm_cookie = dstcookie;
-        kiblnd_init_tx_msg(ni, tx, type, sizeof (kib_completion_msg_t));
+        kiblnd_init_tx_msg(conn->ibc_peer->ibp_ni, tx,
+                           type, sizeof (kib_completion_msg_t));
 
         return rc;
 }
@@ -1293,6 +1119,7 @@ kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
 
         LASSERT (tx->tx_nwrq > 0);              /* work items set up */
         LASSERT (!tx->tx_queued);               /* not queued for sending already */
+        LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
 
         tx->tx_queued = 1;
         tx->tx_deadline = jiffies + (*kiblnd_tunables.kib_timeout * HZ);
@@ -1324,7 +1151,10 @@ kiblnd_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
                 break;
 
         case IBLND_MSG_NOOP:
-                q = &conn->ibc_tx_noops;
+                if (IBLND_OOB_CAPABLE(conn->ibc_version))
+                        q = &conn->ibc_tx_queue_nocred;
+                else
+                        q = &conn->ibc_tx_queue;
                 break;
 
         case IBLND_MSG_IMMEDIATE:
@@ -1349,6 +1179,7 @@ void
 kiblnd_connect_peer (kib_peer_t *peer)
 {
         struct rdma_cm_id *cmid;
+        kib_dev_t         *dev;
         kib_net_t         *net = peer->ibp_ni->ni_data;
         struct sockaddr_in srcaddr;
         struct sockaddr_in dstaddr;
@@ -1365,9 +1196,10 @@ kiblnd_connect_peer (kib_peer_t *peer)
                 goto failed;
         }
 
+        dev = net->ibn_dev;
         memset(&srcaddr, 0, sizeof(srcaddr));
         srcaddr.sin_family = AF_INET;
-        srcaddr.sin_addr.s_addr = htonl(net->ibn_dev->ibd_ifip);
+        srcaddr.sin_addr.s_addr = htonl(dev->ibd_ifip);
 
         memset(&dstaddr, 0, sizeof(dstaddr));
         dstaddr.sin_family = AF_INET;
@@ -1380,8 +1212,13 @@ kiblnd_connect_peer (kib_peer_t *peer)
                                (struct sockaddr *)&srcaddr,
                                (struct sockaddr *)&dstaddr,
                                *kiblnd_tunables.kib_timeout * 1000);
-        if (rc == 0)
+        if (rc == 0) {
+                LASSERT (cmid->device != NULL);
+                CDEBUG(D_NET, "%s: connection bound to %s:%u.%u.%u.%u:%s\n",
+                       libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname,
+                       HIPQUAD(dev->ibd_ifip), cmid->device->name);
                 return;
+        }
 
         /* Can't initiate address resolution:  */
         CERROR("Can't resolve addr for %s: %d\n",
@@ -1406,8 +1243,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
         /* If I get here, I've committed to send, so I complete the tx with
          * failure on any problems */
 
-        LASSERT (tx->tx_conn == NULL);          /* only set when assigned a conn */
-        LASSERT (tx->tx_nwrq > 0);              /* work items have been set up */
+        LASSERT (tx == NULL || tx->tx_conn == NULL); /* only set when assigned a conn */
+        LASSERT (tx == NULL || tx->tx_nwrq > 0);     /* work items have been set up */
 
         /* First time, just use a read lock since I expect to find my peer
          * connected */
@@ -1421,7 +1258,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
 
                 read_unlock_irqrestore(g_lock, flags);
 
-                kiblnd_queue_tx(tx, conn);
+                if (tx != NULL)
+                        kiblnd_queue_tx(tx, conn);
                 kiblnd_conn_decref(conn); /* ...to here */
                 return;
         }
@@ -1436,7 +1274,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
                         /* found a peer, but it's still connecting... */
                         LASSERT (peer->ibp_connecting != 0 ||
                                  peer->ibp_accepting != 0);
-                        list_add_tail (&tx->tx_list, &peer->ibp_tx_queue);
+                        if (tx != NULL)
+                                list_add_tail(&tx->tx_list, &peer->ibp_tx_queue);
                         write_unlock_irqrestore(g_lock, flags);
                 } else {
                         conn = kiblnd_get_conn_locked(peer);
@@ -1444,7 +1283,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
 
                         write_unlock_irqrestore(g_lock, flags);
 
-                        kiblnd_queue_tx(tx, conn);
+                        if (tx != NULL)
+                                kiblnd_queue_tx(tx, conn);
                         kiblnd_conn_decref(conn); /* ...to here */
                 }
                 return;
@@ -1456,9 +1296,11 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
         rc = kiblnd_create_peer(ni, &peer, nid);
         if (rc != 0) {
                 CERROR("Can't create peer %s\n", libcfs_nid2str(nid));
-                tx->tx_status = -EHOSTUNREACH;
-                tx->tx_waiting = 0;
-                kiblnd_tx_done(ni, tx);
+                if (tx != NULL) {
+                        tx->tx_status = -EHOSTUNREACH;
+                        tx->tx_waiting = 0;
+                        kiblnd_tx_done(ni, tx);
+                }
                 return;
         }
 
@@ -1470,7 +1312,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
                         /* found a peer, but it's still connecting... */
                         LASSERT (peer2->ibp_connecting != 0 ||
                                  peer2->ibp_accepting != 0);
-                        list_add_tail (&tx->tx_list, &peer2->ibp_tx_queue);
+                        if (tx != NULL)
+                                list_add_tail(&tx->tx_list, &peer2->ibp_tx_queue);
                         write_unlock_irqrestore(g_lock, flags);
                 } else {
                         conn = kiblnd_get_conn_locked(peer2);
@@ -1478,7 +1321,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
 
                         write_unlock_irqrestore(g_lock, flags);
 
-                        kiblnd_queue_tx(tx, conn);
+                        if (tx != NULL)
+                                kiblnd_queue_tx(tx, conn);
                         kiblnd_conn_decref(conn); /* ...to here */
                 }
 
@@ -1493,7 +1337,8 @@ kiblnd_launch_tx (lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
         /* always called with a ref on ni, which prevents ni being shutdown */
         LASSERT (((kib_net_t *)ni->ni_data)->ibn_shutdown == 0);
 
-        list_add_tail(&tx->tx_list, &peer->ibp_tx_queue);
+        if (tx != NULL)
+                list_add_tail(&tx->tx_list, &peer->ibp_tx_queue);
 
         kiblnd_peer_addref(peer);
         list_add_tail(&peer->ibp_list, kiblnd_nid2peerlist(nid));
@@ -1561,8 +1406,6 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                 }
 
                 ibmsg = tx->tx_msg;
-                ibmsg->ibm_u.get.ibgm_hdr = *hdr;
-                ibmsg->ibm_u.get.ibgm_cookie = tx->tx_cookie;
 
                 if ((lntmsg->msg_md->md_options & LNET_MD_KIOV) == 0)
                         rc = kiblnd_setup_rd_iov(ni, tx,
@@ -1582,11 +1425,11 @@ kiblnd_send (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                         kiblnd_tx_done(ni, tx);
                         return -EIO;
                 }
-#if IBLND_MAP_ON_DEMAND
-                nob = sizeof(kib_get_msg_t);
-#else
+
                 nob = offsetof(kib_get_msg_t, ibgm_rd.rd_frags[tx->tx_nfrags]);
-#endif
+                ibmsg->ibm_u.get.ibgm_cookie = tx->tx_cookie;
+                ibmsg->ibm_u.get.ibgm_hdr = *hdr;
+
                 kiblnd_init_tx_msg(ni, tx, IBLND_MSG_GET_REQ, nob);
 
                 tx->tx_lntmsg[1] = lnet_create_reply_msg(ni, lntmsg);
@@ -1711,7 +1554,8 @@ kiblnd_reply (lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
                 goto failed_1;
         }
 
-        rc = kiblnd_init_rdma(ni, tx, IBLND_MSG_GET_DONE, nob,
+        rc = kiblnd_init_rdma(rx->rx_conn, tx,
+                              IBLND_MSG_GET_DONE, nob,
                               &rx->rx_msg->ibm_u.get.ibgm_rd,
                               rx->rx_msg->ibm_u.get.ibgm_cookie);
         if (rc < 0) {
@@ -1719,7 +1563,7 @@ kiblnd_reply (lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
                        libcfs_nid2str(target.nid), rc);
                 goto failed_1;
         }
-
+        
         if (nob == 0) {
                 /* No RDMA: local completion may happen now! */
                 lnet_finalize(ni, lntmsg, 0);
@@ -1807,7 +1651,7 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
                                                  &txmsg->ibm_u.putack.ibpam_rd,
                                                  niov, iov, offset, mlen);
                 else
-                        rc = kiblnd_setup_rd_kiov(ni, tx, 
+                        rc = kiblnd_setup_rd_kiov(ni, tx,
                                                   &txmsg->ibm_u.putack.ibpam_rd,
                                                   niov, kiov, offset, mlen);
                 if (rc != 0) {
@@ -1820,13 +1664,10 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
                         break;
                 }
 
+                nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[tx->tx_nfrags]);
                 txmsg->ibm_u.putack.ibpam_src_cookie = rxmsg->ibm_u.putreq.ibprm_cookie;
                 txmsg->ibm_u.putack.ibpam_dst_cookie = tx->tx_cookie;
-#if IBLND_MAP_ON_DEMAND
-                nob = sizeof(kib_putack_msg_t);
-#else
-                nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[tx->tx_nfrags]);
-#endif
+
                 kiblnd_init_tx_msg(ni, tx, IBLND_MSG_PUT_ACK, nob);
 
                 tx->tx_lntmsg[0] = lntmsg;      /* finalise lntmsg on completion */
@@ -1929,7 +1770,6 @@ kiblnd_close_conn_locked (kib_conn_t *conn, int error)
                 return; /* already being handled  */
 
         if (error == 0 &&
-            list_empty(&conn->ibc_tx_noops) &&
             list_empty(&conn->ibc_tx_queue) &&
             list_empty(&conn->ibc_tx_queue_rsrvd) &&
             list_empty(&conn->ibc_tx_queue_nocred) &&
@@ -1937,16 +1777,15 @@ kiblnd_close_conn_locked (kib_conn_t *conn, int error)
                 CDEBUG(D_NET, "closing conn to %s\n", 
                        libcfs_nid2str(peer->ibp_nid));
         } else {
-                CDEBUG(D_NETERROR, "Closing conn to %s: error %d%s%s%s%s%s\n",
+                CDEBUG(D_NETERROR, "Closing conn to %s: error %d%s%s%s%s\n",
                        libcfs_nid2str(peer->ibp_nid), error,
                        list_empty(&conn->ibc_tx_queue) ? "" : "(sending)",
-                       list_empty(&conn->ibc_tx_noops) ? "" : "(sending_noops)",
                        list_empty(&conn->ibc_tx_queue_rsrvd) ? "" : "(sending_rsrvd)",
                        list_empty(&conn->ibc_tx_queue_nocred) ? "" : "(sending_nocred)",
                        list_empty(&conn->ibc_active_txs) ? "" : "(waiting)");
         }
 
-        list_del (&conn->ibc_list);
+        list_del(&conn->ibc_list);
         /* connd (see below) takes over ibc_list's ref */
 
         if (list_empty (&peer->ibp_conns) &&    /* no more conns */
@@ -2005,7 +1844,7 @@ kiblnd_handle_early_rxs(kib_conn_t *conn)
 void
 kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
 {
-        LIST_HEAD           (zombies); 
+        LIST_HEAD           (zombies);
         struct list_head    *tmp;
         struct list_head    *nxt;
         kib_tx_t            *tx;
@@ -2022,12 +1861,12 @@ kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
                 } else {
                         LASSERT (tx->tx_queued);
                 }
-                
+
                 tx->tx_status = -ECONNABORTED;
-                tx->tx_queued = 0;
                 tx->tx_waiting = 0;
-                
+
                 if (tx->tx_sending == 0) {
+                        tx->tx_queued = 0;
                         list_del (&tx->tx_list);
                         list_add (&tx->tx_list, &zombies);
                 }
@@ -2055,7 +1894,6 @@ kiblnd_finalise_conn (kib_conn_t *conn)
         /* Complete all tx descs not waiting for sends to complete.
          * NB we should be safe from RDMA now that the QP has changed state */
 
-        kiblnd_abort_txs(conn, &conn->ibc_tx_noops);
         kiblnd_abort_txs(conn, &conn->ibc_tx_queue);
         kiblnd_abort_txs(conn, &conn->ibc_tx_queue_rsrvd);
         kiblnd_abort_txs(conn, &conn->ibc_tx_queue_nocred);
@@ -2120,17 +1958,17 @@ kiblnd_peer_connect_failed (kib_peer_t *peer, int active, int error)
 void
 kiblnd_connreq_done(kib_conn_t *conn, int status)
 {
-        struct list_head   txs;
-
         kib_peer_t        *peer = conn->ibc_peer;
-        int                active;
-        unsigned long      flags;
         kib_tx_t          *tx;
+        struct list_head   txs;
+        unsigned long      flags;
+        int                active;
 
         active = (conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
 
-        CDEBUG(D_NET,"%s: %d, %d\n", libcfs_nid2str(peer->ibp_nid), 
-               active, status);
+        CDEBUG(D_NET,"%s: active(%d), version(%x), status(%d)\n",
+               libcfs_nid2str(peer->ibp_nid), active,
+               conn->ibc_version, status);
 
         LASSERT (!in_interrupt());
         LASSERT ((conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT &&
@@ -2164,7 +2002,18 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
         else
                 peer->ibp_accepting--;
 
-        kiblnd_close_stale_conns_locked(peer, conn->ibc_incarnation);
+        if (peer->ibp_version == 0) {
+                peer->ibp_version     = conn->ibc_version;
+                peer->ibp_incarnation = conn->ibc_incarnation;
+        }
+
+        if (peer->ibp_version     != conn->ibc_version ||
+            peer->ibp_incarnation != conn->ibc_incarnation) {
+                kiblnd_close_stale_conns_locked(peer, conn->ibc_version,
+                                                conn->ibc_incarnation);
+                peer->ibp_version     = conn->ibc_version;
+                peer->ibp_incarnation = conn->ibc_incarnation;
+        }
 
         /* grab pending txs while I have the lock */
         list_add(&txs, &peer->ibp_tx_queue);
@@ -2189,7 +2038,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
         spin_lock (&conn->ibc_lock);
         while (!list_empty (&txs)) {
                 tx = list_entry (txs.next, kib_tx_t, tx_list);
-                list_del (&tx->tx_list);
+                list_del(&tx->tx_list);
 
                 kiblnd_queue_tx_locked(tx, conn);
         }
@@ -2202,14 +2051,11 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
 }
 
 void
-kiblnd_reject(struct rdma_cm_id *cmid, int why)
+kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej)
 {
         int          rc;
-        kib_rej_t    rej = {.ibr_magic   = IBLND_MSG_MAGIC,
-                            .ibr_version = IBLND_MSG_VERSION,
-                            .ibr_why     = why};
 
-        rc = rdma_reject(cmid, &rej, sizeof(rej));
+        rc = rdma_reject(cmid, rej, sizeof(*rej));
 
         if (rc != 0)
                 CWARN("Error %d sending reject\n", rc);
@@ -2218,19 +2064,21 @@ kiblnd_reject(struct rdma_cm_id *cmid, int why)
 int
 kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
 {
-        kib_msg_t             *ackmsg;
-        kib_msg_t             *reqmsg = priv;
         rwlock_t              *g_lock = &kiblnd_data.kib_global_lock;
-        struct rdma_conn_param cp;
-        unsigned long          flags;
-        lnet_ni_t             *ni = NULL;
+        kib_msg_t             *reqmsg = priv;
+        kib_msg_t             *ackmsg;
         kib_dev_t             *ibdev;
         kib_peer_t            *peer;
         kib_peer_t            *peer2;
         kib_conn_t            *conn;
+        lnet_ni_t             *ni  = NULL;
+        kib_net_t             *net = NULL;
         lnet_nid_t             nid;
+        struct rdma_conn_param cp;
+        kib_rej_t              rej;
+        int                    version = IBLND_MSG_VERSION;
+        unsigned long          flags;
         int                    rc;
-        int                    rej = IBLND_REJECT_FATAL;
 
         LASSERT (!in_interrupt());
 
@@ -2238,25 +2086,33 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
         ibdev = (kib_dev_t *)cmid->context;
         LASSERT (ibdev != NULL);
 
+        memset(&rej, 0, sizeof(rej));
+        rej.ibr_magic                = IBLND_MSG_MAGIC;
+        rej.ibr_why                  = IBLND_REJECT_FATAL;
+        rej.ibr_cp.ibcp_max_msg_size = IBLND_MSG_SIZE;
+
         if (priv_nob < offsetof(kib_msg_t, ibm_type)) {
                 CERROR("Short connection request\n");
                 goto failed;
         }
 
+        /* Future protocol version compatibility support!  If the
+         * o2iblnd-specific protocol changes, or when LNET unifies
+         * protocols over all LNDs, the initial connection will
+         * negotiate a protocol version.  I trap this here to avoid
+         * console errors; the reject tells the peer which protocol I
+         * speak. */
         if (reqmsg->ibm_magic == LNET_PROTO_MAGIC ||
-            reqmsg->ibm_magic == __swab32(LNET_PROTO_MAGIC) ||
-            (reqmsg->ibm_magic == IBLND_MSG_MAGIC &&
-             reqmsg->ibm_version != IBLND_MSG_VERSION) ||
-            (reqmsg->ibm_magic == __swab32(IBLND_MSG_MAGIC) &&
-             reqmsg->ibm_version != __swab16(IBLND_MSG_VERSION))) {
-                /* Future protocol version compatibility support!  If the
-                 * o2iblnd-specific protocol changes, or when LNET unifies
-                 * protocols over all LNDs, the initial connection will
-                 * negotiate a protocol version.  I trap this here to avoid
-                 * console errors; the reject tells the peer which protocol I
-                 * speak. */
+            reqmsg->ibm_magic == __swab32(LNET_PROTO_MAGIC))
+                goto failed;
+        if (reqmsg->ibm_magic == IBLND_MSG_MAGIC &&
+            reqmsg->ibm_version != IBLND_MSG_VERSION &&
+            reqmsg->ibm_version != IBLND_MSG_VERSION_1)
+                goto failed;
+        if (reqmsg->ibm_magic == __swab32(IBLND_MSG_MAGIC) &&
+            reqmsg->ibm_version != __swab16(IBLND_MSG_VERSION) &&
+            reqmsg->ibm_version != __swab16(IBLND_MSG_VERSION_1))
                 goto failed;
-        }
 
         rc = kiblnd_unpack_msg(reqmsg, priv_nob);
         if (rc != 0) {
@@ -2265,6 +2121,36 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
         }
 
         nid = reqmsg->ibm_srcnid;
+        ni  = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid));
+
+        if (ni != NULL) {
+                net = (kib_net_t *)ni->ni_data;
+                rej.ibr_incarnation = net->ibn_incarnation;
+        }
+
+        if (ni == NULL ||                         /* no matching net */
+            ni->ni_nid != reqmsg->ibm_dstnid ||   /* right NET, wrong NID! */
+            net->ibn_dev != ibdev) {              /* wrong device */
+                CERROR("Can't accept %s on %s (%s:%d:%u.%u.%u.%u): "
+                       "bad dst nid %s\n", libcfs_nid2str(nid),
+                       ni == NULL ? "NA" : libcfs_nid2str(ni->ni_nid),
+                       ibdev->ibd_ifname, ibdev->ibd_nnets,
+                       HIPQUAD(ibdev->ibd_ifip),
+                       libcfs_nid2str(reqmsg->ibm_dstnid));
+
+                goto failed;
+        }
+
+       /* check time stamp as soon as possible */
+        if (reqmsg->ibm_dststamp != 0 &&
+            reqmsg->ibm_dststamp != net->ibn_incarnation) {
+                CWARN("Stale connection request\n");
+                rej.ibr_why = IBLND_REJECT_CONN_STALE;
+                goto failed;
+        }
+
+        /* I can accept peer's version */
+        version = reqmsg->ibm_version;
 
         if (reqmsg->ibm_type != IBLND_MSG_CONNREQ) {
                 CERROR("Unexpected connreq msg type: %x from %s\n",
@@ -2272,20 +2158,31 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
                 goto failed;
         }
 
-        if (reqmsg->ibm_u.connparams.ibcp_queue_depth != IBLND_MSG_QUEUE_SIZE) {
+        if (reqmsg->ibm_u.connparams.ibcp_queue_depth !=
+            IBLND_MSG_QUEUE_SIZE(version)) {
                 CERROR("Can't accept %s: incompatible queue depth %d (%d wanted)\n",
-                       libcfs_nid2str(nid),
-                       reqmsg->ibm_u.connparams.ibcp_queue_depth,
-                       IBLND_MSG_QUEUE_SIZE);
+                       libcfs_nid2str(nid), reqmsg->ibm_u.connparams.ibcp_queue_depth,
+                       IBLND_MSG_QUEUE_SIZE(version));
+
+                if (version == IBLND_MSG_VERSION)
+                        rej.ibr_why = IBLND_REJECT_MSG_QUEUE_SIZE;
+
                 goto failed;
         }
 
-        if (reqmsg->ibm_u.connparams.ibcp_max_frags != IBLND_MAX_RDMA_FRAGS) {
-                CERROR("Can't accept %s: incompatible max_frags %d (%d wanted)\n",
-                       libcfs_nid2str(nid),
+        if (reqmsg->ibm_u.connparams.ibcp_max_frags !=
+            IBLND_RDMA_FRAGS(version)) {
+                CERROR("Can't accept %s(version %x): "
+                       "incompatible max_frags %d (%d wanted)\n",
+                       libcfs_nid2str(nid), version,
                        reqmsg->ibm_u.connparams.ibcp_max_frags,
-                       IBLND_MAX_RDMA_FRAGS);
+                       IBLND_RDMA_FRAGS(version));
+
+                if (version == IBLND_MSG_VERSION)
+                        rej.ibr_why = IBLND_REJECT_RDMA_FRAGS;
+
                 goto failed;
+
         }
 
         if (reqmsg->ibm_u.connparams.ibcp_max_msg_size > IBLND_MSG_SIZE) {
@@ -2296,22 +2193,11 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
                 goto failed;
         }
 
-        ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid));
-        if (ni == NULL ||                               /* no matching net */
-            ni->ni_nid != reqmsg->ibm_dstnid ||   /* right NET, wrong NID! */
-            ((kib_net_t*)ni->ni_data)->ibn_dev != ibdev) { /* wrong device */
-                CERROR("Can't accept %s: bad dst nid %s\n",
-                       libcfs_nid2str(nid),
-                       libcfs_nid2str(reqmsg->ibm_dstnid));
-
-                goto failed;
-        }
-
         /* assume 'nid' is a new peer; create  */
         rc = kiblnd_create_peer(ni, &peer, nid);
         if (rc != 0) {
                 CERROR("Can't create peer for %s\n", libcfs_nid2str(nid));
-                rej = IBLND_REJECT_NO_RESOURCES;
+                rej.ibr_why = IBLND_REJECT_NO_RESOURCES;
                 goto failed;
         }
 
@@ -2319,16 +2205,34 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
 
         peer2 = kiblnd_find_peer_locked(nid);
         if (peer2 != NULL) {
-                /* tie-break connection race in favour of the higher NID */                
+                if (peer2->ibp_version == 0) {
+                        peer2->ibp_version     = version;
+                        peer2->ibp_incarnation = reqmsg->ibm_srcstamp;
+                }
+
+                /* not the guy I've talked with */
+                if (peer2->ibp_incarnation != reqmsg->ibm_srcstamp ||
+                    peer2->ibp_version     != version) {
+                        kiblnd_close_peer_conns_locked(peer2, -ESTALE);
+                        write_unlock_irqrestore(g_lock, flags);
+
+                        CWARN("Conn stale %s [old ver: %x, new ver: %x]\n",
+                              libcfs_nid2str(nid), peer2->ibp_version, version);
+
+                        kiblnd_peer_decref(peer);
+                        rej.ibr_why = IBLND_REJECT_CONN_STALE;
+                        goto failed;
+                }
+
+                /* tie-break connection race in favour of the higher NID */
                 if (peer2->ibp_connecting != 0 &&
                     nid < ni->ni_nid) {
                         write_unlock_irqrestore(g_lock, flags);
 
-                        CWARN("Conn race %s\n",
-                              libcfs_nid2str(peer2->ibp_nid));
+                        CWARN("Conn race %s\n", libcfs_nid2str(peer2->ibp_nid));
 
                         kiblnd_peer_decref(peer);
-                        rej = IBLND_REJECT_CONN_RACE;
+                        rej.ibr_why = IBLND_REJECT_CONN_RACE;
                         goto failed;
                 }
 
@@ -2341,10 +2245,15 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
         } else {
                 /* Brand new peer */
                 LASSERT (peer->ibp_accepting == 0);
-                peer->ibp_accepting = 1;
+                LASSERT (peer->ibp_version == 0 &&
+                         peer->ibp_incarnation == 0);
+
+                peer->ibp_accepting   = 1;
+                peer->ibp_version     = version;
+                peer->ibp_incarnation = reqmsg->ibm_srcstamp;
 
                 /* I have a ref on ni that prevents it being shutdown */
-                LASSERT (((kib_net_t *)ni->ni_data)->ibn_shutdown == 0);
+                LASSERT (net->ibn_shutdown == 0);
 
                 kiblnd_peer_addref(peer);
                 list_add_tail(&peer->ibp_list, kiblnd_nid2peerlist(nid));
@@ -2352,11 +2261,11 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
                 write_unlock_irqrestore(g_lock, flags);
         }
 
-        conn = kiblnd_create_conn(peer, cmid, IBLND_CONN_PASSIVE_WAIT);
+        conn = kiblnd_create_conn(peer, cmid, IBLND_CONN_PASSIVE_WAIT, version);
         if (conn == NULL) {
                 kiblnd_peer_connect_failed(peer, 0, -ENOMEM);
                 kiblnd_peer_decref(peer);
-                rej = IBLND_REJECT_NO_RESOURCES;
+                rej.ibr_why = IBLND_REJECT_NO_RESOURCES;
                 goto failed;
         }
 
@@ -2364,20 +2273,21 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
          * CM callback doesn't destroy cmid. */
 
         conn->ibc_incarnation      = reqmsg->ibm_srcstamp;
-        conn->ibc_credits          = IBLND_MSG_QUEUE_SIZE;
-        conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE;
-        LASSERT (conn->ibc_credits + conn->ibc_reserved_credits
-                 <= IBLND_RX_MSGS);
+        conn->ibc_credits          = IBLND_MSG_QUEUE_SIZE(version);
+        conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(version);
+        LASSERT (conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(version)
+                 <= IBLND_RX_MSGS(version));
 
         ackmsg = &conn->ibc_connvars->cv_msg;
         memset(ackmsg, 0, sizeof(*ackmsg));
 
         kiblnd_init_msg(ackmsg, IBLND_MSG_CONNACK,
                         sizeof(ackmsg->ibm_u.connparams));
-        ackmsg->ibm_u.connparams.ibcp_queue_depth = IBLND_MSG_QUEUE_SIZE;
-        ackmsg->ibm_u.connparams.ibcp_max_frags = IBLND_MAX_RDMA_FRAGS;
+        ackmsg->ibm_u.connparams.ibcp_queue_depth  = IBLND_MSG_QUEUE_SIZE(version);
         ackmsg->ibm_u.connparams.ibcp_max_msg_size = IBLND_MSG_SIZE;
-        kiblnd_pack_msg(ni, ackmsg, 0, nid, reqmsg->ibm_srcstamp);
+        ackmsg->ibm_u.connparams.ibcp_max_frags    = IBLND_RDMA_FRAGS(version);
+
+        kiblnd_pack_msg(ni, ackmsg, version, 0, nid, reqmsg->ibm_srcstamp);
 
         memset(&cp, 0, sizeof(cp));
         cp.private_data        = ackmsg;
@@ -2393,7 +2303,10 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
         rc = rdma_accept(cmid, &cp);
         if (rc != 0) {
                 CERROR("Can't accept %s: %d\n", libcfs_nid2str(nid), rc);
-                kiblnd_reject(cmid, IBLND_REJECT_FATAL);
+                rej.ibr_version = version;
+                rej.ibr_why     = IBLND_REJECT_FATAL;
+
+                kiblnd_reject(cmid, &rej);
                 kiblnd_connreq_done(conn, rc);
                 kiblnd_conn_decref(conn);
         }
@@ -2405,14 +2318,20 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob)
         if (ni != NULL)
                 lnet_ni_decref(ni);
 
-        kiblnd_reject(cmid, rej);
+        rej.ibr_version = version;
+        rej.ibr_cp.ibcp_queue_depth = IBLND_MSG_QUEUE_SIZE(version);
+        rej.ibr_cp.ibcp_max_frags   = IBLND_RDMA_FRAGS(version);
+        kiblnd_reject(cmid, &rej);
+
         return -ECONNREFUSED;
 }
 
 void
-kiblnd_reconnect (kib_conn_t *conn, char *why)
+kiblnd_reconnect (kib_conn_t *conn, int version,
+                  __u64 incarnation, int why, kib_connparams_t *cp)
 {
         kib_peer_t    *peer = conn->ibc_peer;
+        char          *reason;
         int            retry = 0;
         unsigned long  flags;
 
@@ -2428,15 +2347,43 @@ kiblnd_reconnect (kib_conn_t *conn, char *why)
             peer->ibp_accepting == 0) {
                 retry = 1;
                 peer->ibp_connecting++;
+
+                peer->ibp_version     = version;
+                peer->ibp_incarnation = incarnation;
         }
 
         write_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
-        if (retry) {
-                CDEBUG(D_NETERROR, "%s: retrying (%s)\n", 
-                       libcfs_nid2str(peer->ibp_nid), why);
-                kiblnd_connect_peer(peer);
+        if (!retry)
+                return;
+
+        switch (why) {
+        default:
+                reason = "Unknown";
+                break;
+
+        case IBLND_REJECT_CONN_STALE:
+                reason = "stale";
+                break;
+
+        case IBLND_REJECT_CONN_RACE:
+                reason = "conn race";
+                break;
+
+        case IBLND_REJECT_CONN_UNCOMPAT:
+                reason = "version negotiation";
+                break;
         }
+
+        CDEBUG(D_NETERROR, "%s: retrying (%s), %x, %x, "
+                           "queue_dep: %d, max_frag: %d, msg_size: %d\n",
+               libcfs_nid2str(peer->ibp_nid),
+               reason, IBLND_MSG_VERSION, version,
+               cp != NULL ? cp->ibcp_queue_depth : IBLND_MSG_QUEUE_SIZE(version),
+               cp != NULL ? cp->ibcp_max_frags   : IBLND_RDMA_FRAGS(version),
+               cp != NULL ? cp->ibcp_max_msg_size: IBLND_MSG_SIZE);
+
+        kiblnd_connect_peer(peer);
 }
 
 void
@@ -2449,17 +2396,57 @@ kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob)
 
         switch (reason) {
         case IB_CM_REJ_STALE_CONN:
-                kiblnd_reconnect(conn, "stale");
+                kiblnd_reconnect(conn, IBLND_MSG_VERSION, 0,
+                                 IBLND_REJECT_CONN_STALE, NULL);
+                break;
+
+        case IB_CM_REJ_INVALID_SERVICE_ID:
+                CDEBUG(D_NETERROR, "%s rejected: no listener at %d\n",
+                       libcfs_nid2str(peer->ibp_nid),
+                       *kiblnd_tunables.kib_service);
                 break;
 
         case IB_CM_REJ_CONSUMER_DEFINED:
-                if (priv_nob >= sizeof(kib_rej_t)) {
-                        kib_rej_t *rej = priv;
+                if (priv_nob >= offsetof(kib_rej_t, ibr_padding)) {
+                        kib_rej_t        *rej         = priv;
+                        kib_connparams_t *cp          = NULL;
+                        int               flip        = 0;
+                        __u64             incarnation = -1;
+
+                        /* NB. default incarnation is -1 because:
+                         * a) V1 will ignore dst incarnation in connreq.
+                         * b) V2 will provide incarnation while rejecting me,
+                         *    -1 will be overwrote.
+                         *
+                         * if I try to connect to a V1 peer with V2 protocol,
+                         * it rejected me then upgrade to V2, I have no idea
+                         * about the upgrading and try to reconnect with V1,
+                         * in this case upgraded V2 can find out I'm trying to
+                         * talk to the old guy and reject me(incarnation is -1). 
+                         */
 
                         if (rej->ibr_magic == __swab32(IBLND_MSG_MAGIC) ||
                             rej->ibr_magic == __swab32(LNET_PROTO_MAGIC)) {
                                 __swab32s(&rej->ibr_magic);
                                 __swab16s(&rej->ibr_version);
+                                flip = 1;
+                        }
+
+                        if (priv_nob >= sizeof(kib_rej_t) &&
+                            rej->ibr_version > IBLND_MSG_VERSION_1) {
+                                /* priv_nob is always 148 in current version
+                                 * of OFED, so we still need to check version.
+                                 * (define of IB_CM_REJ_PRIVATE_DATA_SIZE) */
+                                cp = &rej->ibr_cp;
+
+                                if (flip) {
+                                        __swab64s(&rej->ibr_incarnation);
+                                        __swab16s(&cp->ibcp_queue_depth);
+                                        __swab16s(&cp->ibcp_max_frags);
+                                        __swab32s(&cp->ibcp_max_msg_size);
+                                }
+
+                                incarnation = rej->ibr_incarnation;
                         }
 
                         if (rej->ibr_magic != IBLND_MSG_MAGIC &&
@@ -2469,26 +2456,53 @@ kiblnd_rejected (kib_conn_t *conn, int reason, void *priv, int priv_nob)
                                 break;
                         }
 
-                        if (rej->ibr_version != IBLND_MSG_VERSION) {
-                                CERROR("%s rejected: o2iblnd version %d error\n",
+                        if (rej->ibr_version != IBLND_MSG_VERSION &&
+                            rej->ibr_version != IBLND_MSG_VERSION_1) {
+                                CERROR("%s rejected: o2iblnd version %x error\n",
                                        libcfs_nid2str(peer->ibp_nid),
                                        rej->ibr_version);
                                 break;
                         }
 
+                        if (rej->ibr_why     == IBLND_REJECT_FATAL &&
+                            rej->ibr_version == IBLND_MSG_VERSION_1) {
+                                CDEBUG(D_NET, "rejected by old version peer %s: %x\n",
+                                       libcfs_nid2str(peer->ibp_nid), rej->ibr_version);
+
+                                if (conn->ibc_version != IBLND_MSG_VERSION_1)
+                                        rej->ibr_why = IBLND_REJECT_CONN_UNCOMPAT;
+                        }
+
                         switch (rej->ibr_why) {
                         case IBLND_REJECT_CONN_RACE:
-                                kiblnd_reconnect(conn, "conn race");
+                        case IBLND_REJECT_CONN_STALE:
+                        case IBLND_REJECT_CONN_UNCOMPAT:
+                                kiblnd_reconnect(conn, rej->ibr_version,
+                                                 incarnation, rej->ibr_why, cp);
+                                break;
+
+                        case IBLND_REJECT_MSG_QUEUE_SIZE:
+                                CERROR("%s rejected: incompatible message queue depth %d, %d\n",
+                                       libcfs_nid2str(peer->ibp_nid), cp->ibcp_queue_depth,
+                                       IBLND_MSG_QUEUE_SIZE(conn->ibc_version));
+                                break;
+
+                        case IBLND_REJECT_RDMA_FRAGS:
+                                CERROR("%s rejected: incompatible # of RDMA fragments %d, %d\n",
+                                       libcfs_nid2str(peer->ibp_nid), cp->ibcp_max_frags,
+                                       IBLND_RDMA_FRAGS(conn->ibc_version));
                                 break;
 
                         case IBLND_REJECT_NO_RESOURCES:
                                 CERROR("%s rejected: o2iblnd no resources\n",
                                        libcfs_nid2str(peer->ibp_nid));
                                 break;
+
                         case IBLND_REJECT_FATAL:
                                 CERROR("%s rejected: o2iblnd fatal error\n",
                                        libcfs_nid2str(peer->ibp_nid));
                                 break;
+
                         default:
                                 CERROR("%s rejected: o2iblnd reason %d\n",
                                        libcfs_nid2str(peer->ibp_nid),
@@ -2511,10 +2525,11 @@ void
 kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob)
 {
         kib_peer_t    *peer = conn->ibc_peer;
-        lnet_ni_t     *ni = peer->ibp_ni;
-        kib_net_t     *net = ni->ni_data;
-        kib_msg_t     *msg = priv;
-        int            rc = kiblnd_unpack_msg(msg, priv_nob);
+        lnet_ni_t     *ni   = peer->ibp_ni;
+        kib_net_t     *net  = ni->ni_data;
+        kib_msg_t     *msg  = priv;
+        int            ver  = conn->ibc_version;
+        int            rc   = kiblnd_unpack_msg(msg, priv_nob);
         unsigned long  flags;
 
         LASSERT (net != NULL);
@@ -2532,20 +2547,30 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob)
                 goto failed;
         }
 
-        if (msg->ibm_u.connparams.ibcp_queue_depth != IBLND_MSG_QUEUE_SIZE) {
+        if (ver != msg->ibm_version) {
+                CERROR("%s replied version %x is different with "
+                       "requested version %x\n",
+                       libcfs_nid2str(peer->ibp_nid), msg->ibm_version, ver);
+                rc = -EPROTO;
+                goto failed;
+        }
+
+        if (msg->ibm_u.connparams.ibcp_queue_depth !=
+            IBLND_MSG_QUEUE_SIZE(ver)) {
                 CERROR("%s has incompatible queue depth %d(%d wanted)\n",
                        libcfs_nid2str(peer->ibp_nid),
                        msg->ibm_u.connparams.ibcp_queue_depth,
-                       IBLND_MSG_QUEUE_SIZE);
+                       IBLND_MSG_QUEUE_SIZE(ver));
                 rc = -EPROTO;
                 goto failed;
         }
 
-        if (msg->ibm_u.connparams.ibcp_max_frags != IBLND_MAX_RDMA_FRAGS) {
+        if (msg->ibm_u.connparams.ibcp_max_frags !=
+            IBLND_RDMA_FRAGS(ver)) {
                 CERROR("%s has incompatible max_frags %d (%d wanted)\n",
                        libcfs_nid2str(peer->ibp_nid),
                        msg->ibm_u.connparams.ibcp_max_frags,
-                       IBLND_MAX_RDMA_FRAGS);
+                       IBLND_RDMA_FRAGS(ver));
                 rc = -EPROTO;
                 goto failed;
         }
@@ -2568,16 +2593,18 @@ kiblnd_check_connreply (kib_conn_t *conn, void *priv, int priv_nob)
         read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
 
         if (rc != 0) {
-                CERROR("Stale connection reply from %s\n",
-                       libcfs_nid2str(peer->ibp_nid));
+                CERROR("Bad connection reply from %s, rc = %d, "
+                       "version: %x max_frags: %d\n",
+                       libcfs_nid2str(peer->ibp_nid), rc,
+                       msg->ibm_version, msg->ibm_u.connparams.ibcp_max_frags);
                 goto failed;
         }
 
         conn->ibc_incarnation      = msg->ibm_srcstamp;
-        conn->ibc_credits          = IBLND_MSG_QUEUE_SIZE;
-        conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE;
-        LASSERT (conn->ibc_credits + conn->ibc_reserved_credits
-                 <= IBLND_RX_MSGS);
+        conn->ibc_credits          =
+        conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(ver);
+        LASSERT (conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(ver)
+                 <= IBLND_RX_MSGS(ver));
 
         kiblnd_connreq_done(conn, 0);
         return;
@@ -2600,9 +2627,19 @@ kiblnd_active_connect (struct rdma_cm_id *cmid)
         kib_conn_t              *conn;
         kib_msg_t               *msg;
         struct rdma_conn_param   cp;
+        int                      version;
+        __u64                    incarnation;
+        unsigned long            flags;
         int                      rc;
 
-        conn = kiblnd_create_conn(peer, cmid, IBLND_CONN_ACTIVE_CONNECT);
+        read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
+
+        incarnation = peer->ibp_incarnation;
+        version     = (peer->ibp_version == 0) ? IBLND_MSG_VERSION : peer->ibp_version;
+
+        read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
+
+        conn = kiblnd_create_conn(peer, cmid, IBLND_CONN_ACTIVE_CONNECT, version);
         if (conn == NULL) {
                 kiblnd_peer_connect_failed(peer, 1, -ENOMEM);
                 kiblnd_peer_decref(peer); /* lose cmid's ref */
@@ -2617,10 +2654,12 @@ kiblnd_active_connect (struct rdma_cm_id *cmid)
 
         memset(msg, 0, sizeof(*msg));
         kiblnd_init_msg(msg, IBLND_MSG_CONNREQ, sizeof(msg->ibm_u.connparams));
-        msg->ibm_u.connparams.ibcp_queue_depth = IBLND_MSG_QUEUE_SIZE;
-        msg->ibm_u.connparams.ibcp_max_frags = IBLND_MAX_RDMA_FRAGS;
+        msg->ibm_u.connparams.ibcp_queue_depth  = IBLND_MSG_QUEUE_SIZE(version);
+        msg->ibm_u.connparams.ibcp_max_frags    = IBLND_RDMA_FRAGS(version);
         msg->ibm_u.connparams.ibcp_max_msg_size = IBLND_MSG_SIZE;
-        kiblnd_pack_msg(peer->ibp_ni, msg, 0, peer->ibp_nid, 0);
+
+        kiblnd_pack_msg(peer->ibp_ni, msg, version,
+                        0, peer->ibp_nid, incarnation);
 
         memset(&cp, 0, sizeof(cp));
         cp.private_data        = msg;
@@ -2654,6 +2693,8 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
 
 	switch (event->event) {
 	default:
+                CERROR("Unexpected event: %d, status: %d\n",
+                       event->event, event->status);
                 LBUG();
 
 	case RDMA_CM_EVENT_CONNECT_REQUEST:
@@ -2663,7 +2704,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
                                             KIBLND_CONN_PARAM_LEN(event));
                 CDEBUG(D_NET, "connreq: %d\n", rc);
                 return rc;
-
+                
 	case RDMA_CM_EVENT_ADDR_ERROR:
                 peer = (kib_peer_t *)cmid->context;
                 CDEBUG(D_NETERROR, "%s: ADDR ERROR %d\n",
@@ -2716,7 +2757,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
                 kiblnd_peer_connect_failed(peer, 1, event->status);
                 kiblnd_peer_decref(peer);
                 return event->status;           /* rc != 0 destroys cmid */
-
+                
 	case RDMA_CM_EVENT_UNREACHABLE:
                 conn = (kib_conn_t *)cmid->context;
                 LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT ||
@@ -2782,6 +2823,11 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
                 /* net keeps its ref on conn! */
                 return 0;
 
+#ifdef HAVE_OFED_RDMA_CMEV_TIMEWAIT_EXIT
+        case RDMA_CM_EVENT_TIMEWAIT_EXIT:
+                CDEBUG(D_NET, "Ignore TIMEWAIT_EXIT event\n");
+                return 0;
+#endif
 	case RDMA_CM_EVENT_DISCONNECTED:
                 conn = (kib_conn_t *)cmid->context;
                 if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
@@ -2792,6 +2838,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
                         kiblnd_close_conn(conn, 0);
                 }
                 kiblnd_conn_decref(conn);
+                cmid->context = NULL;
                 return 0;
 
         case RDMA_CM_EVENT_DEVICE_REMOVAL:
@@ -2801,6 +2848,12 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
                 /* Can't remove network from underneath LNET for now, so I have
                  * to ignore this */
                 return 0;
+
+#ifdef HAVE_OFED_RDMA_CMEV_ADDRCHANGE
+        case RDMA_CM_EVENT_ADDR_CHANGE:
+                LCONSOLE_INFO("Physical link changed (eg hca/port)\n");
+                return 0;
+#endif
         }
 }
 
@@ -2825,6 +2878,9 @@ kiblnd_check_txs (kib_conn_t *conn, struct list_head *txs)
 
                 if (time_after_eq (jiffies, tx->tx_deadline)) {
                         timed_out = 1;
+                        CERROR("Timed out tx: %s, %lu seconds\n",
+                               kiblnd_queue2str(conn, txs),
+                               cfs_duration_sec(jiffies - tx->tx_deadline));
                         break;
                 }
         }
@@ -2837,7 +2893,6 @@ int
 kiblnd_conn_timed_out (kib_conn_t *conn)
 {
         return  kiblnd_check_txs(conn, &conn->ibc_tx_queue) ||
-                kiblnd_check_txs(conn, &conn->ibc_tx_noops) ||
                 kiblnd_check_txs(conn, &conn->ibc_tx_queue_rsrvd) ||
                 kiblnd_check_txs(conn, &conn->ibc_tx_queue_nocred) ||
                 kiblnd_check_txs(conn, &conn->ibc_active_txs);
@@ -2884,8 +2939,10 @@ kiblnd_check_conns (int idx)
                         read_unlock_irqrestore(&kiblnd_data.kib_global_lock,
                                                flags);
 
-                        CERROR("Timed out RDMA with %s\n",
-                               libcfs_nid2str(peer->ibp_nid));
+                        CERROR("Timed out RDMA with %s (%lu)\n",
+                               libcfs_nid2str(peer->ibp_nid),
+                               cfs_duration_sec(cfs_time_current() -
+                                                peer->ibp_last_alive));
 
                         kiblnd_close_conn(conn, -ETIMEDOUT);
                         kiblnd_conn_decref(conn); /* ...until here */
@@ -2938,7 +2995,7 @@ kiblnd_connd (void *arg)
                 if (!list_empty (&kiblnd_data.kib_connd_zombies)) {
                         conn = list_entry (kiblnd_data.kib_connd_zombies.next,
                                            kib_conn_t, ibc_list);
-                        list_del (&conn->ibc_list);
+                        list_del(&conn->ibc_list);
 
                         spin_unlock_irqrestore (&kiblnd_data.kib_connd_lock, flags);
                         dropped_lock = 1;
@@ -2951,7 +3008,7 @@ kiblnd_connd (void *arg)
                 if (!list_empty (&kiblnd_data.kib_connd_conns)) {
                         conn = list_entry (kiblnd_data.kib_connd_conns.next,
                                            kib_conn_t, ibc_list);
-                        list_del (&conn->ibc_list);
+                        list_del(&conn->ibc_list);
 
                         spin_unlock_irqrestore (&kiblnd_data.kib_connd_lock, flags);
                         dropped_lock = 1;
@@ -3027,7 +3084,7 @@ kiblnd_qp_event(struct ib_event *event, void *arg)
                 CDEBUG(D_NET, "%s established\n",
                        libcfs_nid2str(conn->ibc_peer->ibp_nid));
                 return;
-
+                
         default:
                 CERROR("%s: Async QP event type %d\n",
                        libcfs_nid2str(conn->ibc_peer->ibp_nid), event->event);
@@ -3074,7 +3131,7 @@ kiblnd_cq_completion (struct ib_cq *cq, void *arg)
          * and this CQ is about to be destroyed so I NOOP. */
         kib_conn_t     *conn = (kib_conn_t *)arg;
         unsigned long   flags;
-
+        
         LASSERT (cq == conn->ibc_cq);
 
         spin_lock_irqsave(&kiblnd_data.kib_sched_lock, flags);
@@ -3189,7 +3246,7 @@ kiblnd_scheduler(void *arg)
                         } else {
                                 conn->ibc_scheduled = 0;
                         }
-
+                        
                         if (rc != 0) {
                                 spin_unlock_irqrestore(&kiblnd_data.kib_sched_lock,
                                                        flags);
diff --git a/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index dff7e7c..f7081a9 100644
--- a/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -64,6 +64,18 @@ static int peer_credits = 8;
 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
                 "# concurrent sends to 1 peer");
 
+static int peer_credits_hiw = 0;
+CFS_MODULE_PARM(peer_credits_hiw, "i", int, 0444,
+                "when eagerly to return credits");
+
+static int peer_buffer_credits = 0;
+CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
+                "# per-peer router buffer credits");
+
+static int peer_timeout = 0;
+CFS_MODULE_PARM(peer_timeout, "i", int, 0444,
+                "Seconds without aliveness news to declare peer dead (<=0 to disable)");
+
 static char *ipif_name = "ib0";
 CFS_MODULE_PARM(ipif_name, "s", charp, 0444,
                 "IPoIB interface name");
@@ -84,18 +96,17 @@ static int ib_mtu = 0;
 CFS_MODULE_PARM(ib_mtu, "i", int, 0444,
                 "IB MTU 256/512/1024/2048/4096");
 
-#if IBLND_MAP_ON_DEMAND
-static int concurrent_sends = IBLND_RX_MSGS;
-#else
-static int concurrent_sends = IBLND_MSG_QUEUE_SIZE;
-#endif
+static int concurrent_sends = 0;
 CFS_MODULE_PARM(concurrent_sends, "i", int, 0444,
                 "send work-queue sizing");
 
-#if IBLND_MAP_ON_DEMAND
+static int map_on_demand = 0;
+CFS_MODULE_PARM(map_on_demand, "i", int, 0444,
+                "map on demand");
+
 static int fmr_pool_size = 512;
 CFS_MODULE_PARM(fmr_pool_size, "i", int, 0444,
-                "size of the fmr pool (>= ntx)");
+                "size of the fmr pool (>= ntx / 4)");
 
 static int fmr_flush_trigger = 384;
 CFS_MODULE_PARM(fmr_flush_trigger, "i", int, 0444,
@@ -104,7 +115,10 @@ CFS_MODULE_PARM(fmr_flush_trigger, "i", int, 0444,
 static int fmr_cache = 1;
 CFS_MODULE_PARM(fmr_cache, "i", int, 0444,
                 "non-zero to enable FMR caching");
-#endif
+
+static int pmr_pool_size = 512;
+CFS_MODULE_PARM(pmr_pool_size, "i", int, 0444,
+                "size of the MR cache pmr pool");
 
 kib_tunables_t kiblnd_tunables = {
         .kib_service                = &service,
@@ -113,17 +127,20 @@ kib_tunables_t kiblnd_tunables = {
         .kib_keepalive              = &keepalive,
         .kib_ntx                    = &ntx,
         .kib_credits                = &credits,
-        .kib_peercredits            = &peer_credits,
+        .kib_peertxcredits          = &peer_credits,
+        .kib_peercredits_hiw        = &peer_credits_hiw,
+        .kib_peerrtrcredits         = &peer_buffer_credits,
+        .kib_peertimeout            = &peer_timeout,
         .kib_default_ipif           = &ipif_name,
         .kib_retry_count            = &retry_count,
         .kib_rnr_retry_count        = &rnr_retry_count,
         .kib_concurrent_sends       = &concurrent_sends,
         .kib_ib_mtu                 = &ib_mtu,
-#if IBLND_MAP_ON_DEMAND
+        .kib_map_on_demand          = &map_on_demand,
         .kib_fmr_pool_size          = &fmr_pool_size,
         .kib_fmr_flush_trigger      = &fmr_flush_trigger,
         .kib_fmr_cache              = &fmr_cache,
-#endif
+        .kib_pmr_pool_size          = &pmr_pool_size,
 };
 
 #if defined(CONFIG_SYSCTL) && !CFS_SYSFS_MODULE_PARM
@@ -138,16 +155,21 @@ enum {
         O2IBLND_TIMEOUT,
         O2IBLND_NTX,
         O2IBLND_CREDITS,
-        O2IBLND_PEER_CREDITS,
+        O2IBLND_PEER_TXCREDITS,
+        O2IBLND_PEER_CREDITS_HIW,
+        O2IBLND_PEER_RTRCREDITS,
+        O2IBLND_PEER_TIMEOUT,
         O2IBLND_IPIF_BASENAME,
         O2IBLND_RETRY_COUNT,
         O2IBLND_RNR_RETRY_COUNT,
         O2IBLND_KEEPALIVE,
         O2IBLND_CONCURRENT_SENDS,
         O2IBLND_IB_MTU,
+        O2IBLND_MAP_ON_DEMAND,
         O2IBLND_FMR_POOL_SIZE,
         O2IBLND_FMR_FLUSH_TRIGGER,
-        O2IBLND_FMR_CACHE
+        O2IBLND_FMR_CACHE,
+        O2IBLND_PMR_POOL_SIZE
 };
 #else
 
@@ -156,16 +178,21 @@ enum {
 #define O2IBLND_TIMEOUT          CTL_UNNUMBERED
 #define O2IBLND_NTX              CTL_UNNUMBERED
 #define O2IBLND_CREDITS          CTL_UNNUMBERED
-#define O2IBLND_PEER_CREDITS     CTL_UNNUMBERED
+#define O2IBLND_PEER_TXCREDITS   CTL_UNNUMBERED
+#define O2IBLND_PEER_CREDITS_HIW CTL_UNNUMBERED
+#define O2IBLND_PEER_RTRCREDITS  CTL_UNNUMBERED
+#define O2IBLND_PEER_TIMEOUT     CTL_UNNUMBERED
 #define O2IBLND_IPIF_BASENAME    CTL_UNNUMBERED
 #define O2IBLND_RETRY_COUNT      CTL_UNNUMBERED
 #define O2IBLND_RNR_RETRY_COUNT  CTL_UNNUMBERED
 #define O2IBLND_KEEPALIVE        CTL_UNNUMBERED
 #define O2IBLND_CONCURRENT_SENDS CTL_UNNUMBERED
 #define O2IBLND_IB_MTU           CTL_UNNUMBERED
+#define O2IBLND_MAP_ON_DEMAND    CTL_UNNUMBERED
 #define O2IBLND_FMR_POOL_SIZE    CTL_UNNUMBERED
 #define O2IBLND_FMR_FLUSH_TRIGGER CTL_UNNUMBERED
 #define O2IBLND_FMR_CACHE        CTL_UNNUMBERED
+#define O2IBLND_PMR_POOL_SIZE    CTL_UNNUMBERED
 
 #endif
 
@@ -211,7 +238,7 @@ static cfs_sysctl_table_t kiblnd_ctl_table[] = {
                 .proc_handler = &proc_dointvec
         },
         {
-                .ctl_name = O2IBLND_PEER_CREDITS,
+                .ctl_name = O2IBLND_PEER_TXCREDITS,
                 .procname = "peer_credits",
                 .data     = &peer_credits,
                 .maxlen   = sizeof(int),
@@ -219,6 +246,30 @@ static cfs_sysctl_table_t kiblnd_ctl_table[] = {
                 .proc_handler = &proc_dointvec
         },
         {
+                .ctl_name = O2IBLND_PEER_CREDITS_HIW,
+                .procname = "peer_credits_hiw",
+                .data     = &peer_credits_hiw,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = O2IBLND_PEER_RTRCREDITS,
+                .procname = "peer_buffer_credits",
+                .data     = &peer_buffer_credits,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
+                .ctl_name = O2IBLND_PEER_TIMEOUT,
+                .procname = "peer_timeout",
+                .data     = &peer_timeout,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
                 .ctl_name = O2IBLND_IPIF_BASENAME,
                 .procname = "ipif_name",
                 .data     = ipif_basename_space,
@@ -266,7 +317,15 @@ static cfs_sysctl_table_t kiblnd_ctl_table[] = {
                 .mode     = 0444,
                 .proc_handler = &proc_dointvec
         },
-#if IBLND_MAP_ON_DEMAND
+        {
+                .ctl_name = O2IBLND_MAP_ON_DEMAND,
+                .procname = "map_on_demand",
+                .data     = &map_on_demand,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+
         {
                 .ctl_name = O2IBLND_FMR_POOL_SIZE,
                 .procname = "fmr_pool_size",
@@ -291,7 +350,14 @@ static cfs_sysctl_table_t kiblnd_ctl_table[] = {
                 .mode     = 0444,
                 .proc_handler = &proc_dointvec
         },
-#endif
+        {
+                .ctl_name = O2IBLND_PMR_POOL_SIZE,
+                .procname = "pmr_pool_size",
+                .data     = &pmr_pool_size,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
         {0}
 };
 
@@ -351,19 +417,55 @@ kiblnd_sysctl_fini (void)
 int
 kiblnd_tunables_init (void)
 {
-        kiblnd_sysctl_init();
+        if (kiblnd_translate_mtu(*kiblnd_tunables.kib_ib_mtu) < 0) {
+                CERROR("Invalid ib_mtu %d, expected 256/512/1024/2048/4096\n",
+                       *kiblnd_tunables.kib_ib_mtu);
+                return -EINVAL;
+        }
+
+        if (*kiblnd_tunables.kib_peertxcredits < IBLND_CREDITS_DEFAULT)
+                *kiblnd_tunables.kib_peertxcredits = IBLND_CREDITS_DEFAULT;
+
+        if (*kiblnd_tunables.kib_peertxcredits > IBLND_CREDITS_MAX)
+                *kiblnd_tunables.kib_peertxcredits = IBLND_CREDITS_MAX;
+
+        if (*kiblnd_tunables.kib_peertxcredits > *kiblnd_tunables.kib_credits)
+                *kiblnd_tunables.kib_peertxcredits = *kiblnd_tunables.kib_credits;
+
+        if (*kiblnd_tunables.kib_peercredits_hiw < *kiblnd_tunables.kib_peertxcredits / 2)
+                *kiblnd_tunables.kib_peercredits_hiw = *kiblnd_tunables.kib_peertxcredits / 2;
+
+        if (*kiblnd_tunables.kib_peercredits_hiw >= *kiblnd_tunables.kib_peertxcredits)
+                *kiblnd_tunables.kib_peercredits_hiw = *kiblnd_tunables.kib_peertxcredits - 1;
 
-        if (*kiblnd_tunables.kib_concurrent_sends > IBLND_RX_MSGS)
-                *kiblnd_tunables.kib_concurrent_sends = IBLND_RX_MSGS;
-        if (*kiblnd_tunables.kib_concurrent_sends < IBLND_MSG_QUEUE_SIZE / 2)
-                *kiblnd_tunables.kib_concurrent_sends = IBLND_MSG_QUEUE_SIZE / 2;
+        if (*kiblnd_tunables.kib_map_on_demand < 0 ||
+            *kiblnd_tunables.kib_map_on_demand > IBLND_MAX_RDMA_FRAGS)
+                *kiblnd_tunables.kib_map_on_demand = 0; /* disable map-on-demand */
 
-        if (*kiblnd_tunables.kib_concurrent_sends < IBLND_MSG_QUEUE_SIZE) {
+        if (*kiblnd_tunables.kib_map_on_demand == 1)
+                *kiblnd_tunables.kib_map_on_demand = 2; /* don't make sense to create map if only one fragment */
+
+        if (*kiblnd_tunables.kib_concurrent_sends == 0) {
+                if (*kiblnd_tunables.kib_map_on_demand > 0 &&
+                    *kiblnd_tunables.kib_map_on_demand <= IBLND_MAX_RDMA_FRAGS / 8)
+                        *kiblnd_tunables.kib_concurrent_sends = (*kiblnd_tunables.kib_peertxcredits) * 2;
+                else
+                        *kiblnd_tunables.kib_concurrent_sends = (*kiblnd_tunables.kib_peertxcredits);
+        }
+
+        if (*kiblnd_tunables.kib_concurrent_sends > *kiblnd_tunables.kib_peertxcredits * 2)
+                *kiblnd_tunables.kib_concurrent_sends = *kiblnd_tunables.kib_peertxcredits * 2;
+
+        if (*kiblnd_tunables.kib_concurrent_sends < *kiblnd_tunables.kib_peertxcredits / 2)
+                *kiblnd_tunables.kib_concurrent_sends = *kiblnd_tunables.kib_peertxcredits / 2;
+
+        if (*kiblnd_tunables.kib_concurrent_sends < *kiblnd_tunables.kib_peertxcredits) {
                 CWARN("Concurrent sends %d is lower than message queue size: %d, "
                       "performance may drop slightly.\n",
-                      *kiblnd_tunables.kib_concurrent_sends, IBLND_MSG_QUEUE_SIZE);
+                      *kiblnd_tunables.kib_concurrent_sends, *kiblnd_tunables.kib_peertxcredits);
         }
 
+        kiblnd_sysctl_init();
         return 0;
 }
 
diff --git a/lnet/klnds/openiblnd/Makefile.in b/lnet/klnds/openiblnd/Makefile.in
index 86fa9cd..0b3dd38 100644
--- a/lnet/klnds/openiblnd/Makefile.in
+++ b/lnet/klnds/openiblnd/Makefile.in
@@ -1,6 +1,7 @@
 MODULES := kopeniblnd
 kopeniblnd-objs := openiblnd.o openiblnd_cb.o openiblnd_modparams.o
 
+EXTRA_DIST = $(kopeniblnd-objs:%.o=%.c) openiblnd.h
 EXTRA_POST_CFLAGS := @OPENIBCPPFLAGS@
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/openiblnd/autoMakefile.am b/lnet/klnds/openiblnd/autoMakefile.am
index ad5ceb4..a20f88b 100644
--- a/lnet/klnds/openiblnd/autoMakefile.am
+++ b/lnet/klnds/openiblnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kopeniblnd-objs:%.o=%.c) openiblnd.h
diff --git a/lnet/klnds/openiblnd/autoMakefile.in b/lnet/klnds/openiblnd/autoMakefile.in
index a1fce60..58eb0ad 100644
--- a/lnet/klnds/openiblnd/autoMakefile.in
+++ b/lnet/klnds/openiblnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_OPENIBLND_TRUE@@MODULES_TRUE at modulenet_DATA = kopeniblnd$(KMODEXT)
-DIST_SOURCES = $(kopeniblnd-objs:%.o=%.c) openiblnd.h
 subdir = lnet/klnds/openiblnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/klnds/ptllnd/Makefile.in b/lnet/klnds/ptllnd/Makefile.in
index ec2f9bb..27a83ab 100755
--- a/lnet/klnds/ptllnd/Makefile.in
+++ b/lnet/klnds/ptllnd/Makefile.in
@@ -1,6 +1,5 @@
 MODULES := kptllnd
 
-EXTRA_POST_CFLAGS := @PTLLNDCPPFLAGS@
 
 kptllnd-objs := ptllnd.o                \
                 ptllnd_cb.o             \
@@ -10,4 +9,7 @@ kptllnd-objs := ptllnd.o                \
                 ptllnd_tx.o		\
                 ptllnd_ptltrace.o
 
+EXTRA_DIST = $(kptllnd-objs:%.o=%.c) ptllnd.h
+EXTRA_POST_CFLAGS := @PTLLNDCPPFLAGS@
+
 @INCLUDE_RULES@
diff --git a/lnet/klnds/ptllnd/autoMakefile.am b/lnet/klnds/ptllnd/autoMakefile.am
index bd8cc9c..11aa155 100755
--- a/lnet/klnds/ptllnd/autoMakefile.am
+++ b/lnet/klnds/ptllnd/autoMakefile.am
@@ -5,4 +5,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kptllnd-objs:%.o=%.c) ptllnd.h
diff --git a/lnet/klnds/ptllnd/autoMakefile.in b/lnet/klnds/ptllnd/autoMakefile.in
index 98b70ba..c360628 100644
--- a/lnet/klnds/ptllnd/autoMakefile.in
+++ b/lnet/klnds/ptllnd/autoMakefile.in
@@ -175,9 +175,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -293,12 +293,12 @@ target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
 @BUILD_PTLLND_TRUE@@MODULES_TRUE at modulenet_DATA = kptllnd$(KMODEXT)
-DIST_SOURCES = $(kptllnd-objs:%.o=%.c) ptllnd.h
 subdir = lnet/klnds/ptllnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = README $(srcdir)/autoMakefile.in Makefile.in \
diff --git a/lnet/klnds/ptllnd/ptllnd.c b/lnet/klnds/ptllnd/ptllnd.c
index 7f2e959..770bfeb 100755
--- a/lnet/klnds/ptllnd/ptllnd.c
+++ b/lnet/klnds/ptllnd/ptllnd.c
@@ -45,6 +45,7 @@ lnd_t kptllnd_lnd = {
         .lnd_startup    = kptllnd_startup,
         .lnd_shutdown   = kptllnd_shutdown,
         .lnd_ctl        = kptllnd_ctl,
+        .lnd_query      = kptllnd_query,
         .lnd_send       = kptllnd_send,
         .lnd_recv       = kptllnd_recv,
         .lnd_eager_recv = kptllnd_eager_recv,
@@ -476,6 +477,27 @@ kptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
         return rc;
 }
 
+void
+kptllnd_query (lnet_ni_t *ni, lnet_nid_t nid, time_t *when)
+{
+        kptl_peer_t       *peer = NULL;
+        lnet_process_id_t  id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID};
+        unsigned long      flags;
+
+        /* NB: kptllnd_find_target connects to peer if necessary */
+        if (kptllnd_find_target(&peer, id) != 0)
+                return;
+
+        spin_lock_irqsave(&peer->peer_lock, flags);
+        if (peer->peer_last_alive != 0)
+                *when = cfs_time_current_sec() -
+                        cfs_duration_sec(cfs_time_current() -
+                                         peer->peer_last_alive);
+        spin_unlock_irqrestore(&peer->peer_lock, flags);
+        kptllnd_peer_decref(peer);
+        return;
+}
+
 int
 kptllnd_startup (lnet_ni_t *ni)
 {
@@ -497,9 +519,8 @@ kptllnd_startup (lnet_ni_t *ni)
                 return -EINVAL;
         }
 
-        /* kptl_msg_t::ptlm_credits is only a __u8 */
-        if (*kptllnd_tunables.kptl_peercredits > 255) {
-                CERROR("kptl_peercredits must be <= 255\n");
+        if (*kptllnd_tunables.kptl_peertxcredits > PTLLND_MSG_MAX_CREDITS) {
+                CERROR("peercredits must be <= %d\n", PTLLND_MSG_MAX_CREDITS);
                 return -EINVAL;
         }
 
@@ -551,8 +572,9 @@ kptllnd_startup (lnet_ni_t *ni)
         /*
          * Setup Credits
          */
-        ni->ni_maxtxcredits = *kptllnd_tunables.kptl_credits;
-        ni->ni_peertxcredits = *kptllnd_tunables.kptl_peercredits;
+        ni->ni_maxtxcredits   = *kptllnd_tunables.kptl_credits;
+        ni->ni_peertxcredits  = *kptllnd_tunables.kptl_peertxcredits;
+        ni->ni_peerrtrcredits = *kptllnd_tunables.kptl_peerrtrcredits;
 
         kptllnd_data.kptl_expected_peers =
                 *kptllnd_tunables.kptl_max_nodes *
@@ -637,6 +659,7 @@ kptllnd_startup (lnet_ni_t *ni)
          */
         rwlock_init(&kptllnd_data.kptl_peer_rw_lock);
         init_waitqueue_head(&kptllnd_data.kptl_watchdog_waitq);
+        atomic_set(&kptllnd_data.kptl_needs_ptltrace, 0);
         INIT_LIST_HEAD(&kptllnd_data.kptl_closing_peers);
         INIT_LIST_HEAD(&kptllnd_data.kptl_zombie_peers);
 
diff --git a/lnet/klnds/ptllnd/ptllnd.h b/lnet/klnds/ptllnd/ptllnd.h
index c3a7c89..e56917a 100755
--- a/lnet/klnds/ptllnd/ptllnd.h
+++ b/lnet/klnds/ptllnd/ptllnd.h
@@ -95,7 +95,7 @@
 # define PTLLND_N_SCHED         1                   /* # schedulers */
 #endif
 
-#define PTLLND_CREDIT_HIGHWATER ((*kptllnd_tunables.kptl_peercredits)-1)
+#define PTLLND_CREDIT_HIGHWATER ((*kptllnd_tunables.kptl_peertxcredits)-1)
   /* when eagerly to return credits */
 
 typedef struct
@@ -110,13 +110,15 @@ typedef struct
         int             *kptl_rxb_npages;       /* number of pages for rx buffer */
         int             *kptl_rxb_nspare;       /* number of spare rx buffers */
         int             *kptl_credits;          /* number of credits */
-        int             *kptl_peercredits;      /* number of credits */
+        int             *kptl_peertxcredits;    /* number of peer tx credits */
+        int             *kptl_peerrtrcredits;   /* number of peer router credits */
         int             *kptl_max_msg_size;     /* max immd message size*/
         int             *kptl_peer_hash_table_size; /* # slots in peer hash table */
         int             *kptl_reschedule_loops; /* scheduler yield loops */
         int             *kptl_ack_puts;         /* make portals ack PUTs */
 #ifdef CRAY_XT3
         int             *kptl_ptltrace_on_timeout; /* dump pltrace on timeout? */
+        int             *kptl_ptltrace_on_fail;    /* dump pltrace on PTL_NAL_FAILED? */
         char           **kptl_ptltrace_basename;  /* ptltrace dump file basename */
 #endif
 #ifdef PJK_DEBUGGING
@@ -282,6 +284,7 @@ struct kptl_data
         struct list_head        kptl_sched_rxbq;       /* rxb requiring reposting */
 
         wait_queue_head_t       kptl_watchdog_waitq;   /* watchdog sleeps here */
+        atomic_t                kptl_needs_ptltrace;   /* watchdog thread to dump ptltrace */
 
         kptl_rx_buffer_pool_t   kptl_rx_buffer_pool;   /* rx buffer pool */
         cfs_mem_cache_t*        kptl_rx_cache;         /* rx descripter cache */
@@ -336,9 +339,21 @@ kptllnd_lnet2ptlnid(lnet_nid_t lnet_nid)
 #endif
 }
 
+static inline void
+kptllnd_schedule_ptltrace_dump (void)
+{
+#ifdef CRAY_XT3
+        if (*kptllnd_tunables.kptl_ptltrace_on_fail) {
+                atomic_inc(&kptllnd_data.kptl_needs_ptltrace);
+                wake_up(&kptllnd_data.kptl_watchdog_waitq);
+        }
+#endif
+}
+
 int  kptllnd_startup(lnet_ni_t *ni);
 void kptllnd_shutdown(lnet_ni_t *ni);
 int  kptllnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg);
+void kptllnd_query (struct lnet_ni *ni, lnet_nid_t nid, time_t *when);
 int  kptllnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg);
 int  kptllnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg,
                   int delayed, unsigned int niov, 
@@ -511,14 +526,14 @@ kptllnd_reserve_buffers(int n)
 static inline int
 kptllnd_peer_reserve_buffers(void)
 {
-        return kptllnd_reserve_buffers(*kptllnd_tunables.kptl_peercredits);
+        return kptllnd_reserve_buffers(*kptllnd_tunables.kptl_peertxcredits);
 }
 
 static inline void
 kptllnd_peer_unreserve_buffers(void)
 {
         kptllnd_rx_buffer_pool_unreserve(&kptllnd_data.kptl_rx_buffer_pool,
-                                         *kptllnd_tunables.kptl_peercredits);
+                                         *kptllnd_tunables.kptl_peertxcredits);
 }
 
 /*
diff --git a/lnet/klnds/ptllnd/ptllnd_cb.c b/lnet/klnds/ptllnd/ptllnd_cb.c
index d3227fb..8acf9d0 100644
--- a/lnet/klnds/ptllnd/ptllnd_cb.c
+++ b/lnet/klnds/ptllnd/ptllnd_cb.c
@@ -301,6 +301,7 @@ kptllnd_active_rdma(kptl_rx_t *rx, lnet_msg_t *lntmsg, int type,
                 kptllnd_peer_close(peer, -EIO);
                 /* Everything (including this RDMA) queued on the peer will
                  * be completed with failure */
+                kptllnd_schedule_ptltrace_dump();
         }
 
         return 0;
@@ -687,6 +688,22 @@ kptllnd_watchdog(void *arg)
         /* threads shut down in phase 2 after all peers have been destroyed */
         while (kptllnd_data.kptl_shutdown < 2) {
 
+                /* add a check for needs ptltrace
+                 * yes, this is blatant hijacking of this thread
+                 * we can't dump directly from tx or rx _callbacks as it deadlocks portals
+                 * and takes out the node
+                */
+
+                if (atomic_read(&kptllnd_data.kptl_needs_ptltrace)) {
+#ifdef CRAY_XT3
+                        kptllnd_dump_ptltrace();
+                        /* we only dump once, no matter how many pending */
+                        atomic_set(&kptllnd_data.kptl_needs_ptltrace, 0);
+#else
+                        LBUG();
+#endif
+                }
+
                 timeout = (int)(deadline - jiffies);
 
                 if (timeout <= 0) {
diff --git a/lnet/klnds/ptllnd/ptllnd_modparams.c b/lnet/klnds/ptllnd/ptllnd_modparams.c
index b63580d..1c8faac 100644
--- a/lnet/klnds/ptllnd/ptllnd_modparams.c
+++ b/lnet/klnds/ptllnd/ptllnd_modparams.c
@@ -57,7 +57,8 @@ static int checksum = 0;
 CFS_MODULE_PARM(checksum, "i", int, 0644,
                 "set non-zero to enable message (not RDMA) checksums");
 
-static int timeout = 50;
+/* NB 250 is the Cray Portals wire timeout */
+static int timeout = 250;
 CFS_MODULE_PARM(timeout, "i", int, 0644,
                 "timeout (seconds)");
 
@@ -85,6 +86,10 @@ static int peercredits = PTLLND_PEERCREDITS;    /* <lnet/ptllnd_wire.h> */
 CFS_MODULE_PARM(peercredits, "i", int, 0444,
                 "concurrent sends to 1 peer");
 
+static int peer_buffer_credits = 0;
+CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
+                "# per-peer router buffer credits");
+
 static int max_msg_size = PTLLND_MAX_KLND_MSG_SIZE;  /* <lnet/ptllnd_wire.h> */
 CFS_MODULE_PARM(max_msg_size, "i", int, 0444,
                 "max size of immediate message");
@@ -106,6 +111,10 @@ static int ptltrace_on_timeout = 0;
 CFS_MODULE_PARM(ptltrace_on_timeout, "i", int, 0644,
                 "dump ptltrace on timeout");
 
+static int ptltrace_on_fail = 1;
+CFS_MODULE_PARM(ptltrace_on_fail, "i", int, 0644,
+                "dump ptltrace on Portals failure");
+
 static char *ptltrace_basename = "/tmp/lnet-ptltrace";
 CFS_MODULE_PARM(ptltrace_basename, "s", charp, 0644,
                 "ptltrace dump file basename");
@@ -128,13 +137,15 @@ kptl_tunables_t kptllnd_tunables = {
         .kptl_rxb_npages             = &rxb_npages,
         .kptl_rxb_nspare             = &rxb_nspare,
         .kptl_credits                = &credits,
-        .kptl_peercredits            = &peercredits,
+        .kptl_peertxcredits          = &peercredits,
+        .kptl_peerrtrcredits         = &peer_buffer_credits,
         .kptl_max_msg_size           = &max_msg_size,
         .kptl_peer_hash_table_size   = &peer_hash_table_size,
         .kptl_reschedule_loops       = &reschedule_loops,
         .kptl_ack_puts               = &ack_puts,
 #ifdef CRAY_XT3
         .kptl_ptltrace_on_timeout    = &ptltrace_on_timeout,
+        .kptl_ptltrace_on_fail       = &ptltrace_on_fail,
         .kptl_ptltrace_basename      = &ptltrace_basename,
 #endif
 #ifdef PJK_DEBUGGING
@@ -168,12 +179,14 @@ enum {
         KPTLLND_PID,
         KPTLLND_RXB_PAGES,
         KPTLLND_CREDITS,
-        KPTLLND_PEERCREDITS,
+        KPTLLND_PEERTXCREDITS,
+        KPTLLND_PEERRTRCREDITS,
         KPTLLND_MAX_MSG_SIZE,
         KPTLLND_PEER_HASH_SIZE,
         KPTLLND_RESHEDULE_LOOPS,
         KPTLLND_ACK_PUTS,
         KPTLLND_TRACETIMEOUT,
+        KPTLLND_TRACEFAIL,
         KPTLLND_TRACEBASENAME,
         KPTLLND_SIMULATION_BITMAP
 };
@@ -188,12 +201,14 @@ enum {
 #define KPTLLND_PID             CTL_UNNUMBERED
 #define KPTLLND_RXB_PAGES       CTL_UNNUMBERED
 #define KPTLLND_CREDITS         CTL_UNNUMBERED
-#define KPTLLND_PEERCREDITS     CTL_UNNUMBERED
+#define KPTLLND_PEERTXCREDITS   CTL_UNNUMBERED
+#define KPTLLND_PEERRTRCREDITS  CTL_UNNUMBERED
 #define KPTLLND_MAX_MSG_SIZE    CTL_UNNUMBERED
 #define KPTLLND_PEER_HASH_SIZE  CTL_UNNUMBERED
 #define KPTLLND_RESHEDULE_LOOPS CTL_UNNUMBERED
 #define KPTLLND_ACK_PUTS        CTL_UNNUMBERED
 #define KPTLLND_TRACETIMEOUT    CTL_UNNUMBERED
+#define KPTLLND_TRACEFAIL       CTL_UNNUMBERED
 #define KPTLLND_TRACEBASENAME   CTL_UNNUMBERED
 #define KPTLLND_SIMULATION_BITMAP CTL_UNNUMBERED
 #endif
@@ -272,7 +287,7 @@ static cfs_sysctl_table_t kptllnd_ctl_table[] = {
                 .proc_handler = &proc_dointvec
         },
         {
-                .ctl_name = KPTLLND_PEERCREDITS,
+                .ctl_name = KPTLLND_PEERTXCREDITS,
                 .procname = "peercredits",
                 .data     = &peercredits,
                 .maxlen   = sizeof(int),
@@ -280,6 +295,14 @@ static cfs_sysctl_table_t kptllnd_ctl_table[] = {
                 .proc_handler = &proc_dointvec
         },
         {
+                .ctl_name = KPTLLND_PEERRTRCREDITS,
+                .procname = "peer_buffer_credits",
+                .data     = &peer_buffer_credits,
+                .maxlen   = sizeof(int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec
+        },
+        {
                 .ctl_name = KPTLLND_MAX_MSG_SIZE,
                 .procname = "max_msg_size",
                 .data     = &max_msg_size,
@@ -321,6 +344,14 @@ static cfs_sysctl_table_t kptllnd_ctl_table[] = {
                 .proc_handler = &proc_dointvec
         },
         {
+                .ctl_name = KPTLLND_TRACEFAIL,
+                .procname = "ptltrace_on_fail",
+                .data     = &ptltrace_on_fail,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_dointvec
+        },
+        {
                 .ctl_name = KPTLLND_TRACEBASENAME,
                 .procname = "ptltrace_basename",
                 .data     = ptltrace_basename_space,
diff --git a/lnet/klnds/ptllnd/ptllnd_peer.c b/lnet/klnds/ptllnd/ptllnd_peer.c
index 4ad2661..2afede2 100644
--- a/lnet/klnds/ptllnd/ptllnd_peer.c
+++ b/lnet/klnds/ptllnd/ptllnd_peer.c
@@ -187,12 +187,12 @@ kptllnd_peer_allocate (lnet_process_id_t lpid, ptl_process_id_t ppid)
 
         peer->peer_state = PEER_STATE_ALLOCATED;
         peer->peer_error = 0;
-        peer->peer_last_alive = cfs_time_current();
+        peer->peer_last_alive = 0;
         peer->peer_id = lpid;
         peer->peer_ptlid = ppid;
         peer->peer_credits = 1;                 /* enough for HELLO */
         peer->peer_next_matchbits = PTL_RESERVED_MATCHBITS;
-        peer->peer_outstanding_credits = *kptllnd_tunables.kptl_peercredits - 1;
+        peer->peer_outstanding_credits = *kptllnd_tunables.kptl_peertxcredits - 1;
         peer->peer_sent_credits = 1;           /* HELLO credit is implicit */
         peer->peer_max_msg_size = PTLLND_MIN_BUFFER_SIZE; /* until we know better */
 
@@ -620,7 +620,7 @@ kptllnd_peer_check_sends (kptl_peer_t *peer)
                 LASSERT (peer->peer_sent_credits >= 0);
                 LASSERT (peer->peer_sent_credits +
                          peer->peer_outstanding_credits <=
-                         *kptllnd_tunables.kptl_peercredits);
+                         *kptllnd_tunables.kptl_peertxcredits);
                 LASSERT (peer->peer_credits >= 0);
 
                 msg_type = tx->tx_msg->ptlm_type;
@@ -768,6 +768,7 @@ kptllnd_peer_check_sends (kptl_peer_t *peer)
         /* Nuke everything (including tx we were trying) */
         kptllnd_peer_close(peer, -EIO);
         kptllnd_tx_decref(tx);
+        kptllnd_schedule_ptltrace_dump();
 }
 
 kptl_tx_t *
@@ -892,7 +893,10 @@ kptllnd_peer_check_bucket (int idx, int stamp)
                        (tx->tx_tposted == 0) ? 0UL : (jiffies - tx->tx_tposted),
                        *kptllnd_tunables.kptl_timeout);
 
-                kptllnd_dump_ptltrace();
+#ifdef CRAY_XT3
+                if (*kptllnd_tunables.kptl_ptltrace_on_timeout)
+                        kptllnd_dump_ptltrace();
+#endif
 
                 kptllnd_tx_decref(tx);
 
diff --git a/lnet/klnds/ptllnd/ptllnd_ptltrace.c b/lnet/klnds/ptllnd/ptllnd_ptltrace.c
index ff98d5e..e85ab5a 100644
--- a/lnet/klnds/ptllnd/ptllnd_ptltrace.c
+++ b/lnet/klnds/ptllnd/ptllnd_ptltrace.c
@@ -38,7 +38,7 @@
 
 #ifdef CRAY_XT3
 static struct semaphore   ptltrace_mutex;
-static struct semaphore   ptltrace_signal;
+static cfs_waitq_t        ptltrace_debug_ctlwq;
 
 void
 kptllnd_ptltrace_to_file(char *filename)
@@ -136,7 +136,7 @@ kptllnd_dump_ptltrace_thread(void *arg)
 {
         static char fname[1024];
 
-        libcfs_daemonize("ptltracedump");
+        libcfs_daemonize("kpt_ptltrace_dump");
 
         /* serialise with other instances of me */
         mutex_down(&ptltrace_mutex);
@@ -150,8 +150,7 @@ kptllnd_dump_ptltrace_thread(void *arg)
         mutex_up(&ptltrace_mutex);
 
         /* unblock my creator */
-        mutex_up(&ptltrace_signal);
-        
+        cfs_waitq_signal(&ptltrace_debug_ctlwq);
         return 0;
 }
 
@@ -159,9 +158,13 @@ void
 kptllnd_dump_ptltrace(void)
 {
         int            rc;     
+        cfs_waitlink_t wait;
+        ENTRY;
 
-        if (!*kptllnd_tunables.kptl_ptltrace_on_timeout)
-                return;
+        /* taken from libcfs_debug_dumplog */
+        cfs_waitlink_init(&wait);
+        set_current_state(TASK_INTERRUPTIBLE);
+        cfs_waitq_add(&ptltrace_debug_ctlwq, &wait);
 
         rc = cfs_kernel_thread(kptllnd_dump_ptltrace_thread,
                                (void *)(long)cfs_curproc_pid(),
@@ -169,28 +172,19 @@ kptllnd_dump_ptltrace(void)
         if (rc < 0) {
                 CERROR("Error %d starting ptltrace dump thread\n", rc);
         } else {
-                /* block until thread completes */
-                mutex_down(&ptltrace_signal);
+                cfs_waitq_wait(&wait, CFS_TASK_INTERRUPTIBLE);
         }
-}
 
-void
-kptllnd_init_ptltrace(void)
-{
-        init_mutex(&ptltrace_mutex);
-        init_mutex_locked(&ptltrace_signal);
-}
-
-#else
-
-void
-kptllnd_dump_ptltrace(void)
-{
+        /* teardown if kernel_thread() failed */
+        cfs_waitq_del(&ptltrace_debug_ctlwq, &wait);
+        set_current_state(TASK_RUNNING);
+        EXIT;
 }
 
 void
 kptllnd_init_ptltrace(void)
 {
+        cfs_waitq_init(&ptltrace_debug_ctlwq);
+        init_mutex(&ptltrace_mutex);
 }
-
 #endif
diff --git a/lnet/klnds/ptllnd/ptllnd_rx_buf.c b/lnet/klnds/ptllnd/ptllnd_rx_buf.c
index f7bf2d3..d1bac62 100644
--- a/lnet/klnds/ptllnd/ptllnd_rx_buf.c
+++ b/lnet/klnds/ptllnd/ptllnd_rx_buf.c
@@ -376,7 +376,7 @@ kptllnd_rx_done(kptl_rx_t *rx, int post_credit)
 
                 LASSERT (peer->peer_outstanding_credits +
                          peer->peer_sent_credits <=
-                         *kptllnd_tunables.kptl_peercredits);
+                         *kptllnd_tunables.kptl_peertxcredits);
 
                 CDEBUG(D_NETTRACE, "%s[%d/%d+%d]: rx %p done\n",
                        libcfs_id2str(peer->peer_id), peer->peer_credits,
@@ -430,7 +430,7 @@ kptllnd_rx_buffer_callback (ptl_event_t *ev)
                        kptllnd_evtype2str(ev->type), ev->type, rxb,
                        kptllnd_errtype2str(ev->ni_fail_type),
                        ev->ni_fail_type, unlinked);
-
+                kptllnd_schedule_ptltrace_dump();
         } else if (ev->type == PTL_EVENT_PUT_END &&
                    !rxbp->rxbp_shutdown) {
 
@@ -532,19 +532,21 @@ kptllnd_nak (kptl_rx_t *rx)
                     *kptllnd_tunables.kptl_portal, 0,
                     LNET_MSG_MATCHBITS, 0, 0);
 
-        if (rc != PTL_OK)
+        if (rc != PTL_OK) {
                 CWARN("Can't NAK %s: put failed %s(%d)\n",
                       kptllnd_ptlid2str(rx->rx_initiator),
                       kptllnd_errtype2str(rc), rc);
+                kptllnd_schedule_ptltrace_dump();
+        }
 }
 
 void
 kptllnd_rx_parse(kptl_rx_t *rx)
 {
         kptl_msg_t             *msg = rx->rx_msg;
+        int                     rc = 0;
         int                     post_credit = PTLLND_POSTRX_PEER_CREDIT;
         kptl_peer_t            *peer;
-        int                     rc;
         unsigned long           flags;
         lnet_process_id_t       srcid;
 
@@ -675,6 +677,7 @@ kptllnd_rx_parse(kptl_rx_t *rx)
 
                 CERROR("%s: buffer overrun [%d/%d+%d]\n",
                        libcfs_id2str(peer->peer_id), c, sc, oc);
+                rc = -EPROTO;
                 goto failed;
         }
         peer->peer_sent_credits--;
@@ -750,9 +753,10 @@ kptllnd_rx_parse(kptl_rx_t *rx)
                 if (rc >= 0)                    /* kptllnd_recv owns 'rx' now */
                         return;
                 goto failed;
-         }
+        }
 
  failed:
+        LASSERT (rc != 0);
         kptllnd_peer_close(peer, rc);
         if (rx->rx_peer == NULL)                /* drop ref on peer */
                 kptllnd_peer_decref(peer);      /* unless rx_done will */
diff --git a/lnet/klnds/ptllnd/ptllnd_tx.c b/lnet/klnds/ptllnd/ptllnd_tx.c
index 4043f8f..96e350b 100644
--- a/lnet/klnds/ptllnd/ptllnd_tx.c
+++ b/lnet/klnds/ptllnd/ptllnd_tx.c
@@ -492,6 +492,7 @@ kptllnd_tx_callback(ptl_event_t *ev)
                        ev->ni_fail_type, unlinked);
                 tx->tx_status = -EIO; 
                 kptllnd_peer_close(peer, -EIO);
+                kptllnd_schedule_ptltrace_dump();
         }
 
         if (!unlinked)
diff --git a/lnet/klnds/qswlnd/Makefile.in b/lnet/klnds/qswlnd/Makefile.in
index b623e02..9ec7d2c 100644
--- a/lnet/klnds/qswlnd/Makefile.in
+++ b/lnet/klnds/qswlnd/Makefile.in
@@ -1,6 +1,7 @@
 MODULES := kqswlnd
 kqswlnd-objs := qswlnd.o qswlnd_cb.o qswlnd_modparams.o
 
+EXTRA_DIST = $(kqswlnd-objs:%.o=%.c) qswlnd.h
 EXTRA_POST_CFLAGS := @QSWCPPFLAGS@ -I/usr/include
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/qswlnd/autoMakefile.am b/lnet/klnds/qswlnd/autoMakefile.am
index 9fd14e6..bf892e8 100644
--- a/lnet/klnds/qswlnd/autoMakefile.am
+++ b/lnet/klnds/qswlnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kqswlnd-objs:%.o=%.c) qswlnd.h
diff --git a/lnet/klnds/qswlnd/autoMakefile.in b/lnet/klnds/qswlnd/autoMakefile.in
index 5df16d8..ba71166 100644
--- a/lnet/klnds/qswlnd/autoMakefile.in
+++ b/lnet/klnds/qswlnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_QSWLND_TRUE@@MODULES_TRUE at modulenet_DATA = kqswlnd$(KMODEXT)
-DIST_SOURCES = $(kqswlnd-objs:%.o=%.c) qswlnd.h
 subdir = lnet/klnds/qswlnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/klnds/ralnd/Makefile.in b/lnet/klnds/ralnd/Makefile.in
index e1f5e82..c9f38f3 100644
--- a/lnet/klnds/ralnd/Makefile.in
+++ b/lnet/klnds/ralnd/Makefile.in
@@ -1,6 +1,7 @@
 MODULES := kralnd
 kralnd-objs := ralnd.o ralnd_cb.o ralnd_modparams.o
 
+EXTRA_DIST = $(kralnd-objs:%.o=%.c) ralnd.h
 EXTRA_POST_CFLAGS := @RACPPFLAGS@
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/ralnd/autoMakefile.am b/lnet/klnds/ralnd/autoMakefile.am
index 2a67c9a..b755074 100644
--- a/lnet/klnds/ralnd/autoMakefile.am
+++ b/lnet/klnds/ralnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kralnd-objs:%.o=%.c) ralnd.h
diff --git a/lnet/klnds/ralnd/autoMakefile.in b/lnet/klnds/ralnd/autoMakefile.in
index fb12110..f246007 100644
--- a/lnet/klnds/ralnd/autoMakefile.in
+++ b/lnet/klnds/ralnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_RALND_TRUE@@MODULES_TRUE at modulenet_DATA = kralnd$(KMODEXT)
-DIST_SOURCES = $(kralnd-objs:%.o=%.c) ralnd.h
 subdir = lnet/klnds/ralnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/klnds/socklnd/Makefile.in b/lnet/klnds/socklnd/Makefile.in
index 3a6c3f7..4d204df 100644
--- a/lnet/klnds/socklnd/Makefile.in
+++ b/lnet/klnds/socklnd/Makefile.in
@@ -1,5 +1,7 @@
 MODULES := ksocklnd
 
-ksocklnd-objs := socklnd.o socklnd_cb.o socklnd_modparams.o socklnd_lib-linux.o
+ksocklnd-objs := socklnd.o socklnd_cb.o socklnd_proto.o socklnd_modparams.o socklnd_lib-linux.o
+
+EXTRA_DIST := $(ksocklnd-objs:%.o=%.c) socklnd_lib-linux.h socklnd.h
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/socklnd/autoMakefile.am b/lnet/klnds/socklnd/autoMakefile.am
index 0dbe697..ced44dc 100644
--- a/lnet/klnds/socklnd/autoMakefile.am
+++ b/lnet/klnds/socklnd/autoMakefile.am
@@ -6,14 +6,11 @@ if LINUX
 endif # LINUX
 endif # MODULES
 
-DIST_SOURCES := $(ksocklnd-objs:%.o=%.c) socklnd_lib-linux.h socklnd.h
-
 if DARWIN
 
   macos_PROGRAMS := ksocklnd
 
-  nodist_ksocklnd_SOURCES := socklnd.c socklnd_cb.c socklnd_modparams.c socklnd_lib-darwin.c
-  DIST_SOURCES += socklnd_lib-darwin.c socklnd_lib-darwin.h
+  nodist_ksocklnd_SOURCES := socklnd.c socklnd_cb.c socklnd_proto.c socklnd_modparams.c socklnd_lib-darwin.c
 
   ksocklnd_CFLAGS := $(EXTRA_KCFLAGS)
   ksocklnd_LDFLAGS := $(EXTRA_KLDFLAGS)
@@ -22,9 +19,9 @@ if DARWIN
   plist_DATA := Info.plist
   install_data_hook := fix-kext-ownership
 
+  EXTRA_DIST := socklnd_lib-darwin.c socklnd_lib-darwin.h $(plist_DATA)
 endif # DARWIN
 
-EXTRA_DIST := $(plist_DATA)
 install-data-hook: $(install_data_hook)
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ socklnd_lib.c
diff --git a/lnet/klnds/socklnd/autoMakefile.in b/lnet/klnds/socklnd/autoMakefile.in
index 786a4d0..f31d98c 100644
--- a/lnet/klnds/socklnd/autoMakefile.in
+++ b/lnet/klnds/socklnd/autoMakefile.in
@@ -38,7 +38,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
- at DARWIN_TRUE@am__append_1 = socklnd_lib-darwin.c socklnd_lib-darwin.h
 ACLOCAL = @ACLOCAL@
 AC_LUSTRE_CLIENT_URN = @AC_LUSTRE_CLIENT_URN@
 AC_LUSTRE_CLI_VER_OFFSET_WARN = @AC_LUSTRE_CLI_VER_OFFSET_WARN@
@@ -176,9 +175,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ socklnd_lib.c
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -296,11 +295,9 @@ target_vendor = @target_vendor@
 
 @LINUX_TRUE@@MODULES_TRUE at modulenet_DATA := ksocklnd$(KMODEXT)
 
-DIST_SOURCES = $(ksocklnd-objs:%.o=%.c) socklnd_lib-linux.h socklnd.h $(am__append_1)
-
 @DARWIN_TRUE at macos_PROGRAMS := ksocklnd
 
- at DARWIN_TRUE@nodist_ksocklnd_SOURCES := socklnd.c socklnd_cb.c socklnd_modparams.c socklnd_lib-darwin.c
+ at DARWIN_TRUE@nodist_ksocklnd_SOURCES := socklnd.c socklnd_cb.c socklnd_proto.c socklnd_modparams.c socklnd_lib-darwin.c
 
 @DARWIN_TRUE at ksocklnd_CFLAGS := $(EXTRA_KCFLAGS)
 @DARWIN_TRUE at ksocklnd_LDFLAGS := $(EXTRA_KLDFLAGS)
@@ -309,7 +306,7 @@ DIST_SOURCES = $(ksocklnd-objs:%.o=%.c) socklnd_lib-linux.h socklnd.h $(am__appe
 @DARWIN_TRUE at plist_DATA := Info.plist
 @DARWIN_TRUE at install_data_hook := fix-kext-ownership
 
-EXTRA_DIST := $(plist_DATA)
+ at DARWIN_TRUE@EXTRA_DIST := socklnd_lib-darwin.c socklnd_lib-darwin.h $(plist_DATA)
 subdir = lnet/klnds/socklnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -321,6 +318,7 @@ PROGRAMS = $(macos_PROGRAMS)
 
 @DARWIN_TRUE at nodist_ksocklnd_OBJECTS = ksocklnd-socklnd.$(OBJEXT) \
 @DARWIN_TRUE@	ksocklnd-socklnd_cb.$(OBJEXT) \
+ at DARWIN_TRUE@	ksocklnd-socklnd_proto.$(OBJEXT) \
 @DARWIN_TRUE@	ksocklnd-socklnd_modparams.$(OBJEXT) \
 @DARWIN_TRUE@	ksocklnd-socklnd_lib-darwin.$(OBJEXT)
 ksocklnd_OBJECTS = $(nodist_ksocklnd_OBJECTS)
@@ -333,11 +331,13 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE at DEP_FILES = ./$(DEPDIR)/ksocklnd-socklnd.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/ksocklnd-socklnd_cb.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/ksocklnd-socklnd_lib-darwin.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/ksocklnd-socklnd_modparams.Po
+ at AMDEP_TRUE@	./$(DEPDIR)/ksocklnd-socklnd_modparams.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/ksocklnd-socklnd_proto.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES =
 DATA = $(modulenet_DATA) $(plist_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
@@ -392,6 +392,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ksocklnd-socklnd_cb.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ksocklnd-socklnd_lib-darwin.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ksocklnd-socklnd_modparams.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ksocklnd-socklnd_proto.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@@ -459,6 +460,28 @@ ksocklnd-socklnd_cb.obj: socklnd_cb.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ksocklnd_CFLAGS) $(CFLAGS) -c -o ksocklnd-socklnd_cb.obj `if test -f 'socklnd_cb.c'; then $(CYGPATH_W) 'socklnd_cb.c'; else $(CYGPATH_W) '$(srcdir)/socklnd_cb.c'; fi`
 
+ksocklnd-socklnd_proto.o: socklnd_proto.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ksocklnd_CFLAGS) $(CFLAGS) -MT ksocklnd-socklnd_proto.o -MD -MP -MF "$(DEPDIR)/ksocklnd-socklnd_proto.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o ksocklnd-socklnd_proto.o `test -f 'socklnd_proto.c' || echo '$(srcdir)/'`socklnd_proto.c; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/ksocklnd-socklnd_proto.Tpo" "$(DEPDIR)/ksocklnd-socklnd_proto.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/ksocklnd-socklnd_proto.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='socklnd_proto.c' object='ksocklnd-socklnd_proto.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/ksocklnd-socklnd_proto.Po' tmpdepfile='$(DEPDIR)/ksocklnd-socklnd_proto.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ksocklnd_CFLAGS) $(CFLAGS) -c -o ksocklnd-socklnd_proto.o `test -f 'socklnd_proto.c' || echo '$(srcdir)/'`socklnd_proto.c
+
+ksocklnd-socklnd_proto.obj: socklnd_proto.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ksocklnd_CFLAGS) $(CFLAGS) -MT ksocklnd-socklnd_proto.obj -MD -MP -MF "$(DEPDIR)/ksocklnd-socklnd_proto.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o ksocklnd-socklnd_proto.obj `if test -f 'socklnd_proto.c'; then $(CYGPATH_W) 'socklnd_proto.c'; else $(CYGPATH_W) '$(srcdir)/socklnd_proto.c'; fi`; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/ksocklnd-socklnd_proto.Tpo" "$(DEPDIR)/ksocklnd-socklnd_proto.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/ksocklnd-socklnd_proto.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='socklnd_proto.c' object='ksocklnd-socklnd_proto.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/ksocklnd-socklnd_proto.Po' tmpdepfile='$(DEPDIR)/ksocklnd-socklnd_proto.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ksocklnd_CFLAGS) $(CFLAGS) -c -o ksocklnd-socklnd_proto.obj `if test -f 'socklnd_proto.c'; then $(CYGPATH_W) 'socklnd_proto.c'; else $(CYGPATH_W) '$(srcdir)/socklnd_proto.c'; fi`
+
 ksocklnd-socklnd_modparams.o: socklnd_modparams.c
 @am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ksocklnd_CFLAGS) $(CFLAGS) -MT ksocklnd-socklnd_modparams.o -MD -MP -MF "$(DEPDIR)/ksocklnd-socklnd_modparams.Tpo" \
 @am__fastdepCC_TRUE@	  -c -o ksocklnd-socklnd_modparams.o `test -f 'socklnd_modparams.c' || echo '$(srcdir)/'`socklnd_modparams.c; \
@@ -720,6 +743,7 @@ uninstall-am: uninstall-info-am uninstall-macosPROGRAMS \
 	uninstall-macosPROGRAMS uninstall-modulenetDATA \
 	uninstall-plistDATA
 
+
 install-data-hook: $(install_data_hook)
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lnet/klnds/socklnd/socklnd.c b/lnet/klnds/socklnd/socklnd.c
index b29eff1..8564da5 100644
--- a/lnet/klnds/socklnd/socklnd.c
+++ b/lnet/klnds/socklnd/socklnd.c
@@ -51,6 +51,7 @@ lnd_t the_ksocklnd = {
         .lnd_send       = ksocknal_send,
         .lnd_recv       = ksocknal_recv,
         .lnd_notify     = ksocknal_notify,
+        .lnd_query      = ksocknal_query,
         .lnd_accept     = ksocknal_accept,
 };
 
@@ -130,8 +131,10 @@ ksocknal_create_peer (ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
         cfs_atomic_set (&peer->ksnp_refcount, 1);   /* 1 ref for caller */
         peer->ksnp_closing = 0;
         peer->ksnp_accepting = 0;
-        peer->ksnp_zc_next_cookie = 1;
         peer->ksnp_proto = NULL;
+        peer->ksnp_last_alive = 0;
+        peer->ksnp_zc_next_cookie = SOCKNAL_KEEPALIVE_PING + 1;
+
         CFS_INIT_LIST_HEAD (&peer->ksnp_conns);
         CFS_INIT_LIST_HEAD (&peer->ksnp_routes);
         CFS_INIT_LIST_HEAD (&peer->ksnp_tx_queue);
@@ -1043,6 +1046,7 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
         ksock_hello_msg_t *hello;
         unsigned int       irq;
         ksock_tx_t        *tx;
+        ksock_tx_t        *txtmp;
         int                rc;
         int                active;
         char              *warn = NULL;
@@ -1071,14 +1075,13 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
         ksocknal_lib_save_callback(sock, conn);
         cfs_atomic_set (&conn->ksnc_conn_refcount, 1); /* 1 ref for me */
 
-        conn->ksnc_zc_capable = ksocknal_lib_zc_capable(sock);
         conn->ksnc_rx_ready = 0;
         conn->ksnc_rx_scheduled = 0;
 
         CFS_INIT_LIST_HEAD (&conn->ksnc_tx_queue);
         conn->ksnc_tx_ready = 0;
         conn->ksnc_tx_scheduled = 0;
-        conn->ksnc_tx_mono = NULL;
+        conn->ksnc_tx_carrier = NULL;
         cfs_atomic_set (&conn->ksnc_tx_nob, 0);
 
         LIBCFS_ALLOC(hello, offsetof(ksock_hello_msg_t,
@@ -1111,10 +1114,12 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
                 cfs_write_unlock_bh(global_lock);
 
                 if (conn->ksnc_proto == NULL) {
-                        conn->ksnc_proto = &ksocknal_protocol_v2x;
+                         conn->ksnc_proto = &ksocknal_protocol_v3x;
 #if SOCKNAL_VERSION_DEBUG
-                        if (*ksocknal_tunables.ksnd_protocol != 2)
-                                conn->ksnc_proto = &ksocknal_protocol_v1x;
+                         if (*ksocknal_tunables.ksnd_protocol == 2)
+                                 conn->ksnc_proto = &ksocknal_protocol_v2x;
+                         else if (*ksocknal_tunables.ksnd_protocol == 1)
+                                 conn->ksnc_proto = &ksocknal_protocol_v1x;
 #endif
                 }
 
@@ -1269,12 +1274,14 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 
         conn->ksnc_peer = peer;                 /* conn takes my ref on peer */
         peer->ksnp_last_alive = cfs_time_current();
+        peer->ksnp_send_keepalive = 0;
         peer->ksnp_error = 0;
 
         sched = ksocknal_choose_scheduler_locked (irq);
         sched->kss_nconns++;
         conn->ksnc_scheduler = sched;
 
+        conn->ksnc_tx_last_post = cfs_time_current();
         /* Set the deadline for the outgoing HELLO to drain */
         conn->ksnc_tx_bufnob = libcfs_sock_wmem_queued(sock);
         conn->ksnc_tx_deadline = cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
@@ -1285,12 +1292,12 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route,
 
         ksocknal_new_packet(conn, 0);
 
-        /* Take all the packets blocking for a connection.
-         * NB, it might be nicer to share these blocked packets among any
-         * other connections that are becoming established. */
-        while (!list_empty (&peer->ksnp_tx_queue)) {
-                tx = list_entry (peer->ksnp_tx_queue.next,
-                                 ksock_tx_t, tx_list);
+        conn->ksnc_zc_capable = ksocknal_lib_zc_capable(conn);
+
+        /* Take packets blocking for this connection. */
+        list_for_each_entry_safe(tx, txtmp, &peer->ksnp_tx_queue, tx_list) {
+                if (conn->ksnc_proto->pro_match_tx(conn, tx, tx->tx_nonblk) == SOCKNAL_MATCH_NO)
+                                continue;
 
                 list_del (&tx->tx_list);
                 ksocknal_queue_tx_locked (tx, conn);
@@ -1459,6 +1466,21 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error)
         if (list_empty (&peer->ksnp_conns)) {
                 /* No more connections to this peer */
 
+                if (!list_empty(&peer->ksnp_tx_queue)) {
+                        ksock_tx_t *tx;
+
+                        LASSERT (conn->ksnc_proto == &ksocknal_protocol_v3x);
+
+                        /* throw them to the last connection...,
+                         * these TXs will be send to /dev/null by scheduler */
+                        list_for_each_entry(tx, &peer->ksnp_tx_queue, tx_list)
+                                ksocknal_tx_prep(conn, tx);
+
+                        spin_lock_bh(&conn->ksnc_scheduler->kss_lock);
+                        list_splice_init(&peer->ksnp_tx_queue, &conn->ksnc_tx_queue);
+                        spin_unlock_bh(&conn->ksnc_scheduler->kss_lock);
+                }
+
                 peer->ksnp_proto = NULL;        /* renegotiate protocol version */
                 peer->ksnp_error = error;       /* stash last conn close reason */
 
@@ -1524,9 +1546,9 @@ ksocknal_finalize_zcreq(ksock_conn_t *conn)
                 if (tx->tx_conn != conn)
                         continue;
 
-                LASSERT (tx->tx_msg.ksm_zc_req_cookie != 0);
+                LASSERT (tx->tx_msg.ksm_zc_cookies[0] != 0);
 
-                tx->tx_msg.ksm_zc_req_cookie = 0;
+                tx->tx_msg.ksm_zc_cookies[0] = 0;
                 list_del(&tx->tx_zc_list);
                 list_add(&tx->tx_zc_list, &zlist);
         }
@@ -1773,6 +1795,62 @@ ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
 }
 
 void
+ksocknal_query (lnet_ni_t *ni, lnet_nid_t nid, time_t *when)
+{
+        int                connect = 1;
+        cfs_time_t         last_alive = 0;
+        ksock_peer_t      *peer = NULL;
+        rwlock_t          *glock = &ksocknal_data.ksnd_global_lock;
+        lnet_process_id_t  id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID};
+
+        read_lock(glock);
+
+        peer = ksocknal_find_peer_locked(ni, id);
+        if (peer != NULL) {
+                struct list_head *tmp;
+                ksock_conn_t     *conn;
+                int               bufnob;
+
+                list_for_each (tmp, &peer->ksnp_conns) {
+                        conn = list_entry(tmp, ksock_conn_t, ksnc_list);
+                        bufnob = libcfs_sock_wmem_queued(conn->ksnc_sock);
+
+                        if (bufnob < conn->ksnc_tx_bufnob) {
+                                /* something got ACKed */
+                                conn->ksnc_tx_deadline =
+                                        cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+                                peer->ksnp_last_alive = cfs_time_current();
+                                conn->ksnc_tx_bufnob = bufnob;
+                        }
+                }
+
+                last_alive = peer->ksnp_last_alive;
+                if (ksocknal_find_connectable_route_locked(peer) == NULL)
+                        connect = 0;
+        }
+
+        read_unlock(glock);
+
+        if (last_alive != 0)
+                *when = cfs_time_current_sec() -
+                        cfs_duration_sec(cfs_time_current() - last_alive);
+
+        if (!connect)
+                return;
+
+        ksocknal_add_peer(ni, id, LNET_NIDADDR(nid), lnet_acceptor_port());
+
+        write_lock_bh(glock);
+
+        peer = ksocknal_find_peer_locked(ni, id);
+        if (peer != NULL)
+                ksocknal_launch_all_connections_locked(peer);
+
+        write_unlock_bh(glock);
+        return;
+}
+
+void
 ksocknal_push_peer (ksock_peer_t *peer)
 {
         int               index;
@@ -2513,8 +2591,10 @@ ksocknal_startup (lnet_ni_t *ni)
         cfs_spin_lock_init(&net->ksnn_lock);
         net->ksnn_incarnation = ksocknal_lib_new_incarnation();
         ni->ni_data = net;
-        ni->ni_maxtxcredits = *ksocknal_tunables.ksnd_credits;
-        ni->ni_peertxcredits = *ksocknal_tunables.ksnd_peercredits;
+        ni->ni_peertimeout    = *ksocknal_tunables.ksnd_peertimeout;
+        ni->ni_maxtxcredits   = *ksocknal_tunables.ksnd_credits;
+        ni->ni_peertxcredits  = *ksocknal_tunables.ksnd_peertxcredits;
+        ni->ni_peerrtrcredits = *ksocknal_tunables.ksnd_peerrtrcredits;
 
         if (ni->ni_interfaces[0] == NULL) {
                 rc = ksocknal_enumerate_interfaces(net);
@@ -2579,7 +2659,8 @@ ksocknal_module_init (void)
         int    rc;
 
         /* check ksnr_connected/connecting field large enough */
-        CLASSERT(SOCKLND_CONN_NTYPES <= 4);
+        CLASSERT (SOCKLND_CONN_NTYPES <= 4);
+        CLASSERT (SOCKLND_CONN_ACK == SOCKLND_CONN_BULK_IN);
 
         rc = ksocknal_lib_tunables_init();
         if (rc != 0)
@@ -2591,7 +2672,7 @@ ksocknal_module_init (void)
 }
 
 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Kernel TCP Socket LND v2.0.0");
+MODULE_DESCRIPTION("Kernel TCP Socket LND v3.0.0");
 MODULE_LICENSE("GPL");
 
-cfs_module(ksocknal, "2.0.0", ksocknal_module_init, ksocknal_module_fini);
+cfs_module(ksocknal, "3.0.0", ksocknal_module_init, ksocknal_module_fini);
diff --git a/lnet/klnds/socklnd/socklnd.h b/lnet/klnds/socklnd/socklnd.h
index 7c5cf9f..be6fd91 100644
--- a/lnet/klnds/socklnd/socklnd.h
+++ b/lnet/klnds/socklnd/socklnd.h
@@ -52,8 +52,6 @@
 #define SOCKNAL_RESCHED         100             /* # scheduler loops before reschedule */
 #define SOCKNAL_ENOMEM_RETRY    CFS_TICK        /* jiffies between retries */
 
-#define SOCKNAL_ROUND_ROBIN     0               /* round robin / load balance */
-
 #define SOCKNAL_SINGLE_FRAG_TX      0           /* disable multi-fragment sends */
 #define SOCKNAL_SINGLE_FRAG_RX      0           /* disable multi-fragment receives */
 
@@ -81,7 +79,6 @@ typedef struct                                  /* per scheduler state */
 #if !SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_SINGLE_FRAG_RX
         struct iovec      kss_scratch_iov[LNET_MAX_IOV];
 #endif
-
 } ksock_sched_t;
 
 typedef struct
@@ -112,14 +109,18 @@ typedef struct
         int              *ksnd_tx_buffer_size;  /* socket tx buffer size */
         int              *ksnd_rx_buffer_size;  /* socket rx buffer size */
         int              *ksnd_nagle;           /* enable NAGLE? */
+        int              *ksnd_round_robin;     /* round robin for multiple interfaces */
+        int              *ksnd_keepalive;       /* # secs for sending keepalive NOOP */
         int              *ksnd_keepalive_idle;  /* # idle secs before 1st probe */
         int              *ksnd_keepalive_count; /* # probes */
         int              *ksnd_keepalive_intvl; /* time between probes */
         int              *ksnd_credits;         /* # concurrent sends */
-        int              *ksnd_peercredits;     /* # concurrent sends to 1 peer */
+        int              *ksnd_peertxcredits;   /* # concurrent sends to 1 peer */
+        int              *ksnd_peerrtrcredits;  /* # per-peer router buffer credits */
+        int              *ksnd_peertimeout;     /* seconds to consider peer dead */
         int              *ksnd_enable_csum;     /* enable check sum */
         int              *ksnd_inject_csum_error; /* set non-zero to inject checksum error */
-        unsigned int     *ksnd_zc_min_frag;     /* minimum zero copy frag size */
+        unsigned int     *ksnd_zc_min_payload;  /* minimum zero copy payload size */
         int              *ksnd_zc_recv;         /* enable ZC receive (for Chelsio TOE) */
         int              *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to enable ZC receive */
 #ifdef CPU_AFFINITY
@@ -215,7 +216,9 @@ typedef struct                                  /* transmit packet */
         int                     tx_niov;        /* # packet iovec frags */
         struct iovec           *tx_iov;         /* packet iovec frags */
         int                     tx_nkiov;       /* # packet page frags */
-        unsigned int            tx_checked_zc;  /* Have I checked if I should ZC? */
+        unsigned int            tx_zc_capable:1; /* payload is large enough for ZC */
+        unsigned int            tx_zc_checked:1; /* Have I checked if I should ZC? */
+        unsigned int            tx_nonblk:1;    /* it's a non-blocking ACK */
         lnet_kiov_t            *tx_kiov;        /* packet page frags */
         struct ksock_conn      *tx_conn;        /* owning conn */
         lnet_msg_t             *tx_lnetmsg;     /* lnet message for lnet_finalize() */
@@ -295,14 +298,13 @@ typedef struct ksock_conn
         /* WRITER */
         struct list_head    ksnc_tx_list;       /* where I enq waiting for output space */
         struct list_head    ksnc_tx_queue;      /* packets waiting to be sent */
-        ksock_tx_t         *ksnc_tx_mono;       /* V2.x only, next mono-packet, mono-packet is :
-                                                 * a. lnet packet without piggyback
-                                                 * b. noop ZC-ACK packet */
+        ksock_tx_t         *ksnc_tx_carrier;    /* next TX that can carry a LNet message or ZC-ACK */
         cfs_time_t          ksnc_tx_deadline;   /* when (in jiffies) tx times out */
         int                 ksnc_tx_bufnob;     /* send buffer marker */
         cfs_atomic_t        ksnc_tx_nob;        /* # bytes queued */
         int                 ksnc_tx_ready;      /* write space */
         int                 ksnc_tx_scheduled;  /* being progressed */
+        cfs_time_t          ksnc_tx_last_post;  /* time stamp of the last posted TX */
 } ksock_conn_t;
 
 typedef struct ksock_route
@@ -324,9 +326,12 @@ typedef struct ksock_route
         int                 ksnr_conn_count;    /* # conns established by this route */
 } ksock_route_t;
 
+#define SOCKNAL_KEEPALIVE_PING          1       /* cookie for keepalive ping */
+
 typedef struct ksock_peer
 {
         struct list_head    ksnp_list;          /* stash on global peer list */
+        cfs_time_t          ksnp_last_alive;    /* when (in jiffies) I was last alive */
         lnet_process_id_t   ksnp_id;            /* who's on the other end(s) */
         cfs_atomic_t        ksnp_refcount;      /* # users */
         int                 ksnp_sharecount;    /* lconf usage counter */
@@ -341,7 +346,7 @@ typedef struct ksock_peer
         struct list_head    ksnp_tx_queue;      /* waiting packets */
         cfs_spinlock_t      ksnp_lock;          /* serialize, NOT safe in g_lock */
         struct list_head    ksnp_zc_req_list;   /* zero copy requests wait for ACK  */
-        cfs_time_t          ksnp_last_alive;    /* when (in jiffies) I was last alive */
+        cfs_time_t          ksnp_send_keepalive; /* time to send keepalive */
         lnet_ni_t          *ksnp_ni;            /* which network */
         int                 ksnp_n_passive_ips; /* # of... */
         __u32               ksnp_passive_ips[LNET_MAX_INTERFACES]; /* preferred local interfaces */
@@ -357,17 +362,31 @@ typedef struct ksock_connreq
 extern ksock_nal_data_t ksocknal_data;
 extern ksock_tunables_t ksocknal_tunables;
 
+#define SOCKNAL_MATCH_NO        0               /* TX can't match type of connection */
+#define SOCKNAL_MATCH_YES       1               /* TX matches type of connection */
+#define SOCKNAL_MATCH_MAY       2               /* TX can be sent on the connection, but not preferred */
+
 typedef struct ksock_proto
 {
-        int     pro_version;                                                /* version number of protocol */
-        int     (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *);     /* handshake function */
-        int     (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int);/* handshake function */
-        void    (*pro_pack)(ksock_tx_t *);                                  /* message pack */
-        void    (*pro_unpack)(ksock_msg_t *);                               /* message unpack */
+        int           pro_version;                                              /* version number of protocol */
+        int         (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *);     /* handshake function */
+        int         (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int);/* handshake function */
+        void        (*pro_pack)(ksock_tx_t *);                                  /* message pack */
+        void        (*pro_unpack)(ksock_msg_t *);                               /* message unpack */
+        ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *);          /* queue tx on the connection */
+        int         (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64); /* queue ZC ack on the connection */
+        int         (*pro_handle_zcreq)(ksock_conn_t *, __u64, int);            /* handle ZC request */
+        int         (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64);          /* handle ZC ACK */
+        int         (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int);         /* msg type matches the connection type:
+                                                                                 * return value:
+                                                                                 *   return MATCH_NO  : no
+                                                                                 *   return MATCH_YES : matching type
+                                                                                 *   return MATCH_MAY : can be backup */
 } ksock_proto_t;
 
 extern ksock_proto_t ksocknal_protocol_v1x;
 extern ksock_proto_t ksocknal_protocol_v2x;
+extern ksock_proto_t ksocknal_protocol_v3x;
 
 #define KSOCK_PROTO_V1_MAJOR    LNET_PROTO_TCP_VERSION_MAJOR
 #define KSOCK_PROTO_V1_MINOR    LNET_PROTO_TCP_VERSION_MINOR
@@ -449,6 +468,7 @@ ksocknal_tx_addref (ksock_tx_t *tx)
         cfs_atomic_inc(&tx->tx_refcount);
 }
 
+extern void ksocknal_tx_prep (ksock_conn_t *, ksock_tx_t *tx);
 extern void ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx);
 
 static inline void
@@ -516,12 +536,23 @@ extern int  ksocknal_close_peer_conns_locked (ksock_peer_t *peer,
                                               __u32 ipaddr, int why);
 extern int ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why);
 extern int ksocknal_close_matching_conns (lnet_process_id_t id, __u32 ipaddr);
-
+extern ksock_conn_t *ksocknal_find_conn_locked(ksock_peer_t *peer,
+                                               ksock_tx_t *tx, int nonblk);
+
+extern int  ksocknal_launch_packet(lnet_ni_t *ni, ksock_tx_t *tx,
+                                   lnet_process_id_t id);
+extern ksock_tx_t *ksocknal_alloc_tx(int type, int size);
+extern void ksocknal_free_tx (ksock_tx_t *tx);
+extern ksock_tx_t *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk);
+extern void ksocknal_next_tx_carrier(ksock_conn_t *conn);
 extern void ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn);
 extern void ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error);
 extern void ksocknal_notify (lnet_ni_t *ni, lnet_nid_t gw_nid, int alive);
+extern void ksocknal_query (struct lnet_ni *ni, lnet_nid_t nid, time_t *when);
 extern int ksocknal_thread_start (int (*fn)(void *arg), void *arg);
 extern void ksocknal_thread_fini (void);
+extern void ksocknal_launch_all_connections_locked (ksock_peer_t *peer);
+extern ksock_route_t *ksocknal_find_connectable_route_locked (ksock_peer_t *peer);
 extern ksock_route_t *ksocknal_find_connecting_route_locked (ksock_peer_t *peer);
 extern int ksocknal_new_packet (ksock_conn_t *conn, int skip);
 extern int ksocknal_scheduler (void *arg);
@@ -535,7 +566,7 @@ extern int ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
 extern void ksocknal_read_callback(ksock_conn_t *conn);
 extern void ksocknal_write_callback(ksock_conn_t *conn);
 
-extern int ksocknal_lib_zc_capable(cfs_socket_t *sock);
+extern int ksocknal_lib_zc_capable(ksock_conn_t *conn);
 extern void ksocknal_lib_save_callback(cfs_socket_t *sock, ksock_conn_t *conn);
 extern void ksocknal_lib_set_callback(cfs_socket_t *sock,  ksock_conn_t *conn);
 extern void ksocknal_lib_reset_callback(cfs_socket_t *sock, ksock_conn_t *conn);
diff --git a/lnet/klnds/socklnd/socklnd_cb.c b/lnet/klnds/socklnd/socklnd_cb.c
index 4c3f704..f6e88c0 100644
--- a/lnet/klnds/socklnd/socklnd_cb.c
+++ b/lnet/klnds/socklnd/socklnd_cb.c
@@ -27,11 +27,13 @@
 #include "socklnd.h"
 
 ksock_tx_t *
-ksocknal_alloc_tx (int size)
+ksocknal_alloc_tx(int type, int size)
 {
         ksock_tx_t *tx = NULL;
 
-        if (size == KSOCK_NOOP_TX_SIZE) {
+        if (type == KSOCK_MSG_NOOP) {
+                LASSERT (size == KSOCK_NOOP_TX_SIZE);
+
                 /* searching for a noop tx in free list */
                 cfs_spin_lock(&ksocknal_data.ksnd_tx_lock);
 
@@ -52,18 +54,47 @@ ksocknal_alloc_tx (int size)
                 return NULL;
 
         cfs_atomic_set(&tx->tx_refcount, 1);
-        tx->tx_desc_size = size;
+        tx->tx_zc_capable = 0;
+        tx->tx_zc_checked = 0;
+        tx->tx_desc_size  = size;
+
         cfs_atomic_inc(&ksocknal_data.ksnd_nactive_txs);
 
         return tx;
 }
 
+ksock_tx_t *
+ksocknal_alloc_tx_noop(__u64 cookie, int nonblk)
+{
+        ksock_tx_t *tx;
+
+        tx = ksocknal_alloc_tx(KSOCK_MSG_NOOP, KSOCK_NOOP_TX_SIZE);
+        if (tx == NULL) {
+                CERROR("Can't allocate noop tx desc\n");
+                return NULL;
+        }
+
+        tx->tx_conn     = NULL;
+        tx->tx_lnetmsg  = NULL;
+        tx->tx_kiov     = NULL;
+        tx->tx_nkiov    = 0;
+        tx->tx_iov      = tx->tx_frags.virt.iov;
+        tx->tx_niov     = 1;
+        tx->tx_nonblk   = nonblk;
+
+        socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP);
+        tx->tx_msg.ksm_zc_cookies[1] = cookie;
+
+        return tx;
+}
+
+
 void
 ksocknal_free_tx (ksock_tx_t *tx)
 {
         cfs_atomic_dec(&ksocknal_data.ksnd_nactive_txs);
 
-        if (tx->tx_desc_size == KSOCK_NOOP_TX_SIZE) {
+        if (tx->tx_lnetmsg == NULL && tx->tx_desc_size == KSOCK_NOOP_TX_SIZE) {
                 /* it's a noop tx */
                 cfs_spin_lock(&ksocknal_data.ksnd_tx_lock);
 
@@ -75,15 +106,6 @@ ksocknal_free_tx (ksock_tx_t *tx)
         }
 }
 
-void
-ksocknal_init_msg(ksock_msg_t *msg, int type)
-{
-        msg->ksm_type           = type;
-        msg->ksm_csum           = 0;
-        msg->ksm_zc_req_cookie  = 0;
-        msg->ksm_zc_ack_cookie  = 0;
-}
-
 int
 ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
 {
@@ -396,7 +418,7 @@ ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error)
                                 le32_to_cpu (tx->tx_lnetmsg->msg_hdr.type),
                                 le32_to_cpu (tx->tx_lnetmsg->msg_hdr.payload_length),
                                 libcfs_nid2str(le64_to_cpu(tx->tx_lnetmsg->msg_hdr.src_nid)),
-                                libcfs_nid2str(le64_to_cpu (tx->tx_lnetmsg->msg_hdr.dest_nid)));
+                                libcfs_nid2str(le64_to_cpu(tx->tx_lnetmsg->msg_hdr.dest_nid)));
                 } else if (error) {
                         CDEBUG (D_NETERROR, "Deleting noop packet\n");
                 }
@@ -413,32 +435,24 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
 {
         ksock_conn_t   *conn = tx->tx_conn;
         ksock_peer_t   *peer = conn->ksnc_peer;
-        lnet_kiov_t    *kiov = tx->tx_kiov;
-        int             nkiov = tx->tx_nkiov;
 
-        /* Set tx_msg.ksm_zc_req_cookie to a unique non-zero cookie and add tx
+        /* Set tx_msg.ksm_zc_cookies[0] to a unique non-zero cookie and add tx
          * to ksnp_zc_req_list if some fragment of this message should be sent
          * zero-copy.  Our peer will send an ACK containing this cookie when
          * she has received this message to tell us we can signal completion.
-         * tx_msg.ksm_zc_req_cookie remains non-zero while tx is on
+         * tx_msg.ksm_zc_cookies[0] remains non-zero while tx is on
          * ksnp_zc_req_list. */
+        LASSERT (tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
+        LASSERT (tx->tx_zc_capable);
 
-        if (conn->ksnc_proto != &ksocknal_protocol_v2x ||
-            !conn->ksnc_zc_capable)
-                return;
+        tx->tx_zc_checked = 1;
 
-        while (nkiov > 0) {
-                if (kiov->kiov_len >= *ksocknal_tunables.ksnd_zc_min_frag)
-                        break;
-                --nkiov;
-                ++kiov;
-        }
-
-        if (nkiov == 0)
+        if (conn->ksnc_proto == &ksocknal_protocol_v1x ||
+            !conn->ksnc_zc_capable)
                 return;
 
         /* assign cookie and queue tx to pending list, it will be released when
-         * a matching ack is received. See ksocknal_handle_zc_ack() */
+         * a matching ack is received. See ksocknal_handle_zcack() */
 
         ksocknal_tx_addref(tx);
 
@@ -448,27 +462,37 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
         tx->tx_deadline =
                 cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
 
-        LASSERT (tx->tx_msg.ksm_zc_req_cookie == 0);
-        tx->tx_msg.ksm_zc_req_cookie = peer->ksnp_zc_next_cookie++;
+        LASSERT (tx->tx_msg.ksm_zc_cookies[0] == 0);
+
+        tx->tx_msg.ksm_zc_cookies[0] = peer->ksnp_zc_next_cookie++;
+
+        if (peer->ksnp_zc_next_cookie == 0)
+                peer->ksnp_zc_next_cookie = SOCKNAL_KEEPALIVE_PING + 1;
+
         list_add_tail(&tx->tx_zc_list, &peer->ksnp_zc_req_list);
 
         cfs_spin_unlock(&peer->ksnp_lock);
 }
 
 static void
-ksocknal_unzc_req(ksock_tx_t *tx)
+ksocknal_uncheck_zc_req(ksock_tx_t *tx)
 {
         ksock_peer_t   *peer = tx->tx_conn->ksnc_peer;
 
+        LASSERT (tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
+        LASSERT (tx->tx_zc_capable);
+
+        tx->tx_zc_checked = 0;
+
         cfs_spin_lock(&peer->ksnp_lock);
 
-        if (tx->tx_msg.ksm_zc_req_cookie == 0) {
+        if (tx->tx_msg.ksm_zc_cookies[0] == 0) {
                 /* Not waiting for an ACK */
                 cfs_spin_unlock(&peer->ksnp_lock);
                 return;
         }
 
-        tx->tx_msg.ksm_zc_req_cookie = 0;
+        tx->tx_msg.ksm_zc_cookies[0] = 0;
         list_del(&tx->tx_zc_list);
 
         cfs_spin_unlock(&peer->ksnp_lock);
@@ -481,10 +505,8 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
 {
         int            rc;
 
-        if (!tx->tx_checked_zc) {
-                tx->tx_checked_zc = 1;
+        if (tx->tx_zc_capable && !tx->tx_zc_checked)
                 ksocknal_check_zc_req(tx);
-        }
 
         rc = ksocknal_transmit (conn, tx);
 
@@ -548,7 +570,8 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
                        conn->ksnc_port);
         }
 
-        ksocknal_unzc_req(tx);
+        if (tx->tx_zc_checked)
+                ksocknal_uncheck_zc_req(tx);
 
         /* it's not an error if conn is being closed */
         ksocknal_close_conn_and_siblings (conn,
@@ -579,125 +602,87 @@ ksocknal_launch_connection_locked (ksock_route_t *route)
         cfs_spin_unlock_bh (&ksocknal_data.ksnd_connd_lock);
 }
 
+void
+ksocknal_launch_all_connections_locked (ksock_peer_t *peer)
+{
+        ksock_route_t *route;
+
+        /* called holding write lock on ksnd_global_lock */
+        for (;;) {
+                /* launch any/all connections that need it */
+                route = ksocknal_find_connectable_route_locked(peer);
+                if (route == NULL)
+                        return;
+
+                ksocknal_launch_connection_locked(route);
+        }
+}
+
 ksock_conn_t *
-ksocknal_find_conn_locked (int payload_nob, ksock_peer_t *peer)
+ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk)
 {
         struct list_head *tmp;
+        ksock_conn_t     *conn;
         ksock_conn_t     *typed = NULL;
-        int               tnob  = 0;
         ksock_conn_t     *fallback = NULL;
+        int               tnob     = 0;
         int               fnob     = 0;
-        ksock_conn_t     *conn;
 
         list_for_each (tmp, &peer->ksnp_conns) {
-                ksock_conn_t *c = list_entry(tmp, ksock_conn_t, ksnc_list);
-                int           hdr_nob = 0;
-#if SOCKNAL_ROUND_ROBIN
-                const int     nob = 0;
-#else
+                ksock_conn_t *c   = list_entry(tmp, ksock_conn_t, ksnc_list);
                 int           nob = cfs_atomic_read(&c->ksnc_tx_nob) +
-                                        libcfs_sock_wmem_queued(c->ksnc_sock);
-#endif
-                LASSERT (!c->ksnc_closing);
-                LASSERT (c->ksnc_proto != NULL);
+                                    libcfs_sock_wmem_queued(c->ksnc_sock);
+                int           rc;
 
-                if (fallback == NULL || nob < fnob) {
-                        fallback = c;
-                        fnob     = nob;
-                }
-
-                if (!*ksocknal_tunables.ksnd_typed_conns)
-                        continue;
+                LASSERT (!c->ksnc_closing);
+                LASSERT (c->ksnc_proto != NULL &&
+                         c->ksnc_proto->pro_match_tx != NULL);
 
-                if (payload_nob == 0) {
-                        /* noop packet */
-                        hdr_nob = offsetof(ksock_msg_t, ksm_u);
-                } else {
-                        /* lnet packet */
-                        hdr_nob = (c->ksnc_proto == &ksocknal_protocol_v2x)?
-                                  offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_payload):
-                                  sizeof(lnet_hdr_t);
-                }
+                rc = c->ksnc_proto->pro_match_tx(c, tx, nonblk);
 
-                switch (c->ksnc_type) {
+                switch (rc) {
                 default:
-                        CERROR("ksnc_type bad: %u\n", c->ksnc_type);
                         LBUG();
-                case SOCKLND_CONN_ANY:
-                        break;
-                case SOCKLND_CONN_BULK_IN:
+                case SOCKNAL_MATCH_NO: /* protocol rejected the tx */
                         continue;
-                case SOCKLND_CONN_BULK_OUT:
-                        if ((hdr_nob + payload_nob) < *ksocknal_tunables.ksnd_min_bulk)
-                                continue;
-                        break;
-                case SOCKLND_CONN_CONTROL:
-                        if ((hdr_nob + payload_nob) >= *ksocknal_tunables.ksnd_min_bulk)
-                                continue;
+
+                case SOCKNAL_MATCH_YES: /* typed connection */
+                        if (typed == NULL || tnob > nob ||
+                            (tnob == nob && *ksocknal_tunables.ksnd_round_robin &&
+                             cfs_time_after(typed->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+                                typed = c;
+                                tnob  = nob;
+                        }
                         break;
-                }
 
-                if (typed == NULL || nob < tnob) {
-                        typed = c;
-                        tnob  = nob;
+                case SOCKNAL_MATCH_MAY: /* fallback connection */
+                        if (fallback == NULL || fnob > nob ||
+                            (fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
+                             cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
+                                fallback = c;
+                                fnob     = nob;
+                        }
+                        break;
                 }
         }
 
         /* prefer the typed selection */
         conn = (typed != NULL) ? typed : fallback;
 
-#if SOCKNAL_ROUND_ROBIN
-        if (conn != NULL) {
-                /* round-robin all else being equal */
-                list_del (&conn->ksnc_list);
-                list_add_tail (&conn->ksnc_list, &peer->ksnp_conns);
-        }
-#endif
+        if (conn != NULL)
+                conn->ksnc_tx_last_post = cfs_time_current();
+
         return conn;
 }
 
 void
-ksocknal_next_mono_tx(ksock_conn_t *conn)
+ksocknal_tx_prep(ksock_conn_t *conn, ksock_tx_t *tx)
 {
-        ksock_tx_t     *tx = conn->ksnc_tx_mono;
-
-        /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
-        LASSERT(conn->ksnc_proto == &ksocknal_protocol_v2x);
-        LASSERT(!list_empty(&conn->ksnc_tx_queue));
-        LASSERT(tx != NULL);
-
-        if (tx->tx_list.next == &conn->ksnc_tx_queue) {
-                /* no more packets queued */
-                conn->ksnc_tx_mono = NULL;
-        } else {
-                conn->ksnc_tx_mono = list_entry(tx->tx_list.next, ksock_tx_t, tx_list);
-                LASSERT(conn->ksnc_tx_mono->tx_msg.ksm_type == tx->tx_msg.ksm_type);
-        }
-}
-
-int
-ksocknal_piggyback_zcack(ksock_conn_t *conn, __u64 cookie)
-{
-        ksock_tx_t     *tx = conn->ksnc_tx_mono;
-
-        /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
-
-        if (tx == NULL)
-                return 0;
-
-        if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) {
-                /* tx is noop zc-ack, can't piggyback zc-ack cookie */
-                return 0;
-        }
-
-        LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_LNET);
-        LASSERT(tx->tx_msg.ksm_zc_ack_cookie == 0);
-
-        /* piggyback the zc-ack cookie */
-        tx->tx_msg.ksm_zc_ack_cookie = cookie;
-        ksocknal_next_mono_tx(conn);
+        conn->ksnc_proto->pro_pack(tx);
 
-        return 1;
+        cfs_atomic_add (tx->tx_nob, &conn->ksnc_tx_nob);
+        ksocknal_conn_addref(conn); /* +1 ref for tx */
+        tx->tx_conn = conn;
 }
 
 void
@@ -705,7 +690,7 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
 {
         ksock_sched_t *sched = conn->ksnc_scheduler;
         ksock_msg_t   *msg = &tx->tx_msg;
-        ksock_tx_t    *ztx;
+        ksock_tx_t    *ztx = NULL;
         int            bufnob = 0;
 
         /* called holding global lock (read or irq-write) and caller may
@@ -714,13 +699,12 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
          * ksnc_sock... */
         LASSERT(!conn->ksnc_closing);
 
-        CDEBUG (D_NET, "Sending to %s ip %d.%d.%d.%d:%d\n",
+        CDEBUG (D_NET, "Sending to %s ip %d.%d.%d.%d:%d\n", 
                 libcfs_id2str(conn->ksnc_peer->ksnp_id),
                 HIPQUAD(conn->ksnc_ipaddr),
                 conn->ksnc_port);
 
-        tx->tx_checked_zc = 0;
-        conn->ksnc_proto->pro_pack(tx);
+        ksocknal_tx_prep(conn, tx);
 
         /* Ensure the frags we've been given EXACTLY match the number of
          * bytes we want to send.  Many TCP/IP stacks disregard any total
@@ -734,14 +718,10 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
         LASSERT (tx->tx_resid == tx->tx_nob);
 
         CDEBUG (D_NET, "Packet %p type %d, nob %d niov %d nkiov %d\n",
-                tx, (tx->tx_lnetmsg != NULL)? tx->tx_lnetmsg->msg_hdr.type:
-                                              KSOCK_MSG_NOOP,
+                tx, (tx->tx_lnetmsg != NULL) ? tx->tx_lnetmsg->msg_hdr.type:
+                                               KSOCK_MSG_NOOP,
                 tx->tx_nob, tx->tx_niov, tx->tx_nkiov);
 
-        cfs_atomic_add (tx->tx_nob, &conn->ksnc_tx_nob);
-        tx->tx_conn = conn;
-        ksocknal_conn_addref(conn); /* +1 ref for tx */
-
         /*
          * FIXME: SOCK_WMEM_QUEUED and SOCK_ERROR could block in __DARWIN8__
          * but they're used inside spinlocks a lot.
@@ -753,71 +733,35 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
                 /* First packet starts the timeout */
                 conn->ksnc_tx_deadline =
                         cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
+                if (conn->ksnc_tx_bufnob > 0) /* something got ACKed */
+                        conn->ksnc_peer->ksnp_last_alive = cfs_time_current();
                 conn->ksnc_tx_bufnob = 0;
                 cfs_mb(); /* order with adding to tx_queue */
         }
 
-        ztx = NULL;
-
         if (msg->ksm_type == KSOCK_MSG_NOOP) {
                 /* The packet is noop ZC ACK, try to piggyback the ack_cookie
                  * on a normal packet so I don't need to send it */
-                LASSERT(msg->ksm_zc_req_cookie == 0);
-                LASSERT(msg->ksm_zc_ack_cookie != 0);
-
-                if (conn->ksnc_tx_mono != NULL) {
-                        if (ksocknal_piggyback_zcack(conn, msg->ksm_zc_ack_cookie)) {
-                                /* zc-ack cookie is piggybacked */
-                                cfs_atomic_sub (tx->tx_nob, &conn->ksnc_tx_nob);
-                                ztx = tx;       /* Put to freelist later */
-                        } else {
-                                /* no packet can piggyback zc-ack cookie */
-                                list_add_tail (&tx->tx_list, &conn->ksnc_tx_queue);
-                        }
-                } else {
-                        /* It's the first mono-packet */
-                        conn->ksnc_tx_mono = tx;
-                        list_add_tail (&tx->tx_list, &conn->ksnc_tx_queue);
-                }
+                LASSERT (msg->ksm_zc_cookies[1] != 0);
+                LASSERT (conn->ksnc_proto->pro_queue_tx_zcack != NULL);
+
+                if (conn->ksnc_proto->pro_queue_tx_zcack(conn, tx, 0))
+                        ztx = tx; /* ZC ACK piggybacked on ztx release tx later */
 
         } else {
                 /* It's a normal packet - can it piggback a noop zc-ack that
                  * has been queued already? */
-                LASSERT(msg->ksm_zc_ack_cookie == 0);
-
-                if (conn->ksnc_proto == &ksocknal_protocol_v2x &&  /* V2.x packet */
-                    conn->ksnc_tx_mono != NULL) {
-                        if (conn->ksnc_tx_mono->tx_msg.ksm_type == KSOCK_MSG_NOOP) {
-                                /* There is a noop zc-ack can be piggybacked */
-                                ztx = conn->ksnc_tx_mono;
+                LASSERT (msg->ksm_zc_cookies[1] == 0);
+                LASSERT (conn->ksnc_proto->pro_queue_tx_msg != NULL);
 
-                                msg->ksm_zc_ack_cookie = ztx->tx_msg.ksm_zc_ack_cookie;
-                                ksocknal_next_mono_tx(conn);
-
-                                /* use tx to replace the noop zc-ack packet, ztx will
-                                 * be put to freelist later */
-                                list_add(&tx->tx_list, &ztx->tx_list);
-                                list_del(&ztx->tx_list);
-
-                                cfs_atomic_sub (ztx->tx_nob, &conn->ksnc_tx_nob);
-                        } else {
-                                /* no noop zc-ack packet, just enqueue it */
-                                LASSERT(conn->ksnc_tx_mono->tx_msg.ksm_type == KSOCK_MSG_LNET);
-                                list_add_tail (&tx->tx_list, &conn->ksnc_tx_queue);
-                        }
-
-                } else if (conn->ksnc_proto == &ksocknal_protocol_v2x) {
-                        /* it's the first mono-packet, enqueue it */
-                        conn->ksnc_tx_mono = tx;
-                        list_add_tail (&tx->tx_list, &conn->ksnc_tx_queue);
-                } else {
-                        /* V1.x packet, just enqueue it */
-                        list_add_tail (&tx->tx_list, &conn->ksnc_tx_queue);
-                }
+                ztx = conn->ksnc_proto->pro_queue_tx_msg(conn, tx);
+                /* ztx will be released later */
         }
 
-        if (ztx != NULL)
+        if (ztx != NULL) {
+                cfs_atomic_sub (ztx->tx_nob, &conn->ksnc_tx_nob);
                 list_add_tail(&ztx->tx_list, &sched->kss_zombie_noop_txs);
+        }
 
         if (conn->ksnc_tx_ready &&      /* able to send */
             !conn->ksnc_tx_scheduled) { /* not scheduled to send */
@@ -832,6 +776,7 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
         cfs_spin_unlock_bh (&sched->kss_lock);
 }
 
+
 ksock_route_t *
 ksocknal_find_connectable_route_locked (ksock_peer_t *peer)
 {
@@ -885,23 +830,20 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
 {
         ksock_peer_t     *peer;
         ksock_conn_t     *conn;
-        ksock_route_t    *route;
         cfs_rwlock_t     *g_lock;
         int               retry;
         int               rc;
 
         LASSERT (tx->tx_conn == NULL);
-        LASSERT (tx->tx_lnetmsg != NULL);
 
         g_lock = &ksocknal_data.ksnd_global_lock;
 
         for (retry = 0;; retry = 1) {
-#if !SOCKNAL_ROUND_ROBIN
                 cfs_read_lock (g_lock);
                 peer = ksocknal_find_peer_locked(ni, id);
                 if (peer != NULL) {
                         if (ksocknal_find_connectable_route_locked(peer) == NULL) {
-                                conn = ksocknal_find_conn_locked (tx->tx_lnetmsg->msg_len, peer);
+                                conn = ksocknal_find_conn_locked(peer, tx, tx->tx_nonblk);
                                 if (conn != NULL) {
                                         /* I've got no routes that need to be
                                          * connecting and I do have an actual
@@ -915,7 +857,7 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
 
                 /* I'll need a write lock... */
                 cfs_read_unlock (g_lock);
-#endif
+
                 cfs_write_lock_bh (g_lock);
 
                 peer = ksocknal_find_peer_locked(ni, id);
@@ -945,16 +887,9 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
                 }
         }
 
-        for (;;) {
-                /* launch any/all connections that need it */
-                route = ksocknal_find_connectable_route_locked (peer);
-                if (route == NULL)
-                        break;
+        ksocknal_launch_all_connections_locked(peer);
 
-                ksocknal_launch_connection_locked (route);
-        }
-
-        conn = ksocknal_find_conn_locked (tx->tx_lnetmsg->msg_len, peer);
+        conn = ksocknal_find_conn_locked(peer, tx, tx->tx_nonblk);
         if (conn != NULL) {
                 /* Connection exists; queue message on it */
                 ksocknal_queue_tx_locked (tx, conn);
@@ -967,7 +902,7 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
                 /* the message is going to be pinned to the peer */
                 tx->tx_deadline =
                         cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
-                
+
                 /* Queue the message until a connection is established */
                 list_add_tail (&tx->tx_list, &peer->ksnp_tx_queue);
                 cfs_write_unlock_bh (g_lock);
@@ -1014,7 +949,7 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                 desc_size = offsetof(ksock_tx_t,
                                      tx_frags.paged.kiov[payload_niov]);
 
-        tx = ksocknal_alloc_tx(desc_size);
+        tx = ksocknal_alloc_tx(KSOCK_MSG_LNET, desc_size);
         if (tx == NULL) {
                 CERROR("Can't allocate tx desc type %d size %d\n",
                        type, desc_size);
@@ -1039,9 +974,12 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
                 tx->tx_nkiov = lnet_extract_kiov(payload_niov, tx->tx_kiov,
                                                  payload_niov, payload_kiov,
                                                  payload_offset, payload_nob);
+
+                if (payload_nob >= *ksocknal_tunables.ksnd_zc_min_payload)
+                        tx->tx_zc_capable = 1;
         }
 
-        ksocknal_init_msg(&tx->tx_msg, KSOCK_MSG_LNET);
+        socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_LNET);
 
         /* The first fragment will be set later in pro_pack */
         rc = ksocknal_launch_packet(ni, tx, target);
@@ -1096,6 +1034,7 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
 
                 switch (conn->ksnc_proto->pro_version) {
                 case  KSOCK_PROTO_V2:
+                case  KSOCK_PROTO_V3:
                         conn->ksnc_rx_state = SOCKNAL_RX_KSM_HEADER;
                         conn->ksnc_rx_iov = (struct iovec *)&conn->ksnc_rx_iov_space;
                         conn->ksnc_rx_iov[0].iov_base = (char *)&conn->ksnc_msg;
@@ -1155,99 +1094,12 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
         return (0);
 }
 
-/* (Sink) handle incoming ZC request from sender */
-static int
-ksocknal_handle_zc_req(ksock_peer_t *peer, __u64 cookie)
-{
-        ksock_conn_t   *conn;
-        ksock_tx_t     *tx;
-        ksock_sched_t  *sched;
-        int             rc;
-
-        cfs_read_lock (&ksocknal_data.ksnd_global_lock);
-
-        conn = ksocknal_find_conn_locked (0, peer);
-        if (conn == NULL) {
-                cfs_read_unlock (&ksocknal_data.ksnd_global_lock);
-                CERROR("Can't find connection to send zcack.\n");
-                return -ECONNRESET;
-        }
-
-        sched = conn->ksnc_scheduler;
-
-        cfs_spin_lock_bh (&sched->kss_lock);
-        rc = ksocknal_piggyback_zcack(conn, cookie);
-        cfs_spin_unlock_bh (&sched->kss_lock);
-
-        cfs_read_unlock (&ksocknal_data.ksnd_global_lock);
-        if (rc) {
-                /* Ack cookie is piggybacked */
-                return 0;
-        }
-
-        tx = ksocknal_alloc_tx(KSOCK_NOOP_TX_SIZE);
-        if (tx == NULL) {
-                CERROR("Can't allocate noop tx desc\n");
-                return -ENOMEM;
-        }
-
-        tx->tx_conn     = NULL;
-        tx->tx_lnetmsg  = NULL;
-        tx->tx_kiov     = NULL;
-        tx->tx_nkiov    = 0;
-        tx->tx_iov      = tx->tx_frags.virt.iov;
-        tx->tx_niov     = 1;
-
-        ksocknal_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP);
-        tx->tx_msg.ksm_zc_ack_cookie = cookie; /* incoming cookie */
-
-        cfs_read_lock (&ksocknal_data.ksnd_global_lock);
-
-        conn = ksocknal_find_conn_locked (0, peer);
-        if (conn == NULL) {
-                cfs_read_unlock (&ksocknal_data.ksnd_global_lock);
-                ksocknal_free_tx(tx);
-                CERROR("Can't find connection to send zcack.\n");
-                return -ECONNRESET;
-        }
-        ksocknal_queue_tx_locked(tx, conn);
-
-        cfs_read_unlock (&ksocknal_data.ksnd_global_lock);
-
-        return 0;
-}
-
-/* (Sender) handle ZC_ACK from sink */
-static int
-ksocknal_handle_zc_ack(ksock_peer_t *peer, __u64 cookie)
-{
-        ksock_tx_t             *tx;
-        struct list_head       *ctmp;
-
-        cfs_spin_lock(&peer->ksnp_lock);
-
-        list_for_each(ctmp, &peer->ksnp_zc_req_list) {
-                tx = list_entry (ctmp, ksock_tx_t, tx_zc_list);
-                if (tx->tx_msg.ksm_zc_req_cookie != cookie)
-                        continue;
-
-                tx->tx_msg.ksm_zc_req_cookie = 0;
-                list_del(&tx->tx_zc_list);
-
-                cfs_spin_unlock(&peer->ksnp_lock);
-
-                ksocknal_tx_decref(tx);
-                return 0;
-        }
-        cfs_spin_unlock(&peer->ksnp_lock);
-
-        return -EPROTO;
-}
-
 int
 ksocknal_process_receive (ksock_conn_t *conn)
 {
-        int           rc;
+        lnet_hdr_t        *lhdr;
+        lnet_process_id_t *id;
+        int                rc;
 
         LASSERT (cfs_atomic_read(&conn->ksnc_conn_refcount) > 0);
 
@@ -1294,8 +1146,8 @@ ksocknal_process_receive (ksock_conn_t *conn)
                 if (conn->ksnc_flip) {
                         __swab32s(&conn->ksnc_msg.ksm_type);
                         __swab32s(&conn->ksnc_msg.ksm_csum);
-                        __swab64s(&conn->ksnc_msg.ksm_zc_req_cookie);
-                        __swab64s(&conn->ksnc_msg.ksm_zc_ack_cookie);
+                        __swab64s(&conn->ksnc_msg.ksm_zc_cookies[0]);
+                        __swab64s(&conn->ksnc_msg.ksm_zc_cookies[1]);
                 }
 
                 if (conn->ksnc_msg.ksm_type != KSOCK_MSG_NOOP &&
@@ -1320,15 +1172,21 @@ ksocknal_process_receive (ksock_conn_t *conn)
                         return (-EIO);
                 }
 
-                if (conn->ksnc_msg.ksm_zc_ack_cookie != 0) {
-                        LASSERT(conn->ksnc_proto == &ksocknal_protocol_v2x);
+                if (conn->ksnc_msg.ksm_zc_cookies[1] != 0) {
+                        __u64 cookie = 0;
+
+                        LASSERT (conn->ksnc_proto != &ksocknal_protocol_v1x);
+
+                        if (conn->ksnc_msg.ksm_type == KSOCK_MSG_NOOP)
+                                cookie = conn->ksnc_msg.ksm_zc_cookies[0];
+
+                        rc = conn->ksnc_proto->pro_handle_zcack(conn, cookie,
+                                               conn->ksnc_msg.ksm_zc_cookies[1]);
 
-                        rc = ksocknal_handle_zc_ack(conn->ksnc_peer,
-                                                    conn->ksnc_msg.ksm_zc_ack_cookie);
                         if (rc != 0) {
-                                CERROR("%s: Unknown zero copy ACK cookie: "LPU64"\n",
+                                CERROR("%s: Unknown ZC-ACK cookie: "LPU64", "LPU64"\n",
                                        libcfs_id2str(conn->ksnc_peer->ksnp_id),
-                                       conn->ksnc_msg.ksm_zc_ack_cookie);
+                                       cookie, conn->ksnc_msg.ksm_zc_cookies[1]);
                                 ksocknal_new_packet(conn, 0);
                                 ksocknal_close_conn_and_siblings(conn, -EPROTO);
                                 return (rc);
@@ -1360,8 +1218,8 @@ ksocknal_process_receive (ksock_conn_t *conn)
 
                 if ((conn->ksnc_peer->ksnp_id.pid & LNET_PID_USERFLAG) != 0) {
                         /* Userspace peer */
-                        lnet_process_id_t *id = &conn->ksnc_peer->ksnp_id;
-                        lnet_hdr_t        *lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
+                        lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
+                        id   = &conn->ksnc_peer->ksnp_id;
 
                         /* Substitute process ID assigned at connection time */
                         lhdr->src_pid = cpu_to_le32(id->pid);
@@ -1405,14 +1263,19 @@ ksocknal_process_receive (ksock_conn_t *conn)
                         rc = -EIO;
                 }
 
-                lnet_finalize(conn->ksnc_peer->ksnp_ni, conn->ksnc_cookie, rc);
+                if (rc == 0 && conn->ksnc_msg.ksm_zc_cookies[0] != 0) {
+                        LASSERT(conn->ksnc_proto != &ksocknal_protocol_v1x);
+
+                        lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
+                        id   = &conn->ksnc_peer->ksnp_id;
 
-                if (rc == 0 && conn->ksnc_msg.ksm_zc_req_cookie != 0) {
-                        LASSERT(conn->ksnc_proto == &ksocknal_protocol_v2x);
-                        rc = ksocknal_handle_zc_req(conn->ksnc_peer,
-                                                    conn->ksnc_msg.ksm_zc_req_cookie);
+                        rc = conn->ksnc_proto->pro_handle_zcreq(conn,
+                                               conn->ksnc_msg.ksm_zc_cookies[0],
+                                               le64_to_cpu(lhdr->src_nid) != id->nid);
                 }
 
+                lnet_finalize(conn->ksnc_peer->ksnp_ni, conn->ksnc_cookie, rc);
+
                 if (rc != 0) {
                         ksocknal_new_packet(conn, 0);
                         ksocknal_close_conn_and_siblings (conn, rc);
@@ -1595,8 +1458,8 @@ int ksocknal_scheduler (void *arg)
                         tx = list_entry(conn->ksnc_tx_queue.next,
                                         ksock_tx_t, tx_list);
 
-                        if (conn->ksnc_tx_mono == tx)
-                                ksocknal_next_mono_tx(conn);
+                        if (conn->ksnc_tx_carrier == tx)
+                                ksocknal_next_tx_carrier(conn);
 
                         /* dequeue now so empty list => more to send */
                         list_del(&tx->tx_list);
@@ -1732,15 +1595,29 @@ void ksocknal_write_callback (ksock_conn_t *conn)
 ksock_proto_t *
 ksocknal_parse_proto_version (ksock_hello_msg_t *hello)
 {
-        if ((hello->kshm_magic   == LNET_PROTO_MAGIC &&
-             hello->kshm_version == KSOCK_PROTO_V2) ||
-            (hello->kshm_magic   == __swab32(LNET_PROTO_MAGIC) &&
-             hello->kshm_version == __swab32(KSOCK_PROTO_V2))) {
+        __u32   version = 0;
+
+        if (hello->kshm_magic == LNET_PROTO_MAGIC)
+                version = hello->kshm_version;
+        else if (hello->kshm_magic == __swab32(LNET_PROTO_MAGIC))
+                version = __swab32(hello->kshm_version);
+
+        if (version != 0) {
 #if SOCKNAL_VERSION_DEBUG
-                if (*ksocknal_tunables.ksnd_protocol != 2)
+                if (*ksocknal_tunables.ksnd_protocol == 1)
+                        return NULL;
+
+                if (*ksocknal_tunables.ksnd_protocol == 2 &&
+                    version == KSOCK_PROTO_V3)
                         return NULL;
 #endif
-                return &ksocknal_protocol_v2x;
+                if (version == KSOCK_PROTO_V2)
+                        return &ksocknal_protocol_v2x;
+
+                if (version == KSOCK_PROTO_V3)
+                        return &ksocknal_protocol_v3x;
+
+                return NULL;
         }
 
         if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) {
@@ -1757,333 +1634,6 @@ ksocknal_parse_proto_version (ksock_hello_msg_t *hello)
         return NULL;
 }
 
-static int
-ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
-{
-        cfs_socket_t        *sock = conn->ksnc_sock;
-        lnet_hdr_t          *hdr;
-        lnet_magicversion_t *hmv;
-        int                  rc;
-        int                  i;
-
-        CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid));
-
-        LIBCFS_ALLOC(hdr, sizeof(*hdr));
-        if (hdr == NULL) {
-                CERROR("Can't allocate lnet_hdr_t\n");
-                return -ENOMEM;
-        }
-
-        hmv = (lnet_magicversion_t *)&hdr->dest_nid;
-
-        /* Re-organize V2.x message header to V1.x (lnet_hdr_t)
-         * header and send out */
-        hmv->magic         = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
-        hmv->version_major = cpu_to_le16 (KSOCK_PROTO_V1_MAJOR);
-        hmv->version_minor = cpu_to_le16 (KSOCK_PROTO_V1_MINOR);
-
-        if (the_lnet.ln_testprotocompat != 0) {
-                /* single-shot proto check */
-                LNET_LOCK();
-                if ((the_lnet.ln_testprotocompat & 1) != 0) {
-                        hmv->version_major++;   /* just different! */
-                        the_lnet.ln_testprotocompat &= ~1;
-                }
-                if ((the_lnet.ln_testprotocompat & 2) != 0) {
-                        hmv->magic = LNET_PROTO_MAGIC;
-                        the_lnet.ln_testprotocompat &= ~2;
-                }
-                LNET_UNLOCK();
-        }
-
-        hdr->src_nid        = cpu_to_le64 (hello->kshm_src_nid);
-        hdr->src_pid        = cpu_to_le32 (hello->kshm_src_pid);
-        hdr->type           = cpu_to_le32 (LNET_MSG_HELLO);
-        hdr->payload_length = cpu_to_le32 (hello->kshm_nips * sizeof(__u32));
-        hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
-        hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
-
-        rc = libcfs_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
-
-        if (rc != 0) {
-                CDEBUG (D_NETERROR, "Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
-                goto out;
-        }
-
-        if (hello->kshm_nips == 0)
-                goto out;
-
-        for (i = 0; i < hello->kshm_nips; i++) {
-                hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]);
-        }
-
-        rc = libcfs_sock_write(sock, hello->kshm_ips,
-                               hello->kshm_nips * sizeof(__u32),
-                               lnet_acceptor_timeout());
-        if (rc != 0) {
-                CDEBUG (D_NETERROR, "Error %d sending HELLO payload (%d)"
-                        " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips,
-                        HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
-        }
-out:
-        LIBCFS_FREE(hdr, sizeof(*hdr));
-
-        return rc;
-}
-
-static int
-ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
-{
-        cfs_socket_t   *sock = conn->ksnc_sock;
-        int             rc;
-
-        hello->kshm_magic       = LNET_PROTO_MAGIC;
-        hello->kshm_version     = KSOCK_PROTO_V2;
-
-        if (the_lnet.ln_testprotocompat != 0) {
-                /* single-shot proto check */
-                LNET_LOCK();
-                if ((the_lnet.ln_testprotocompat & 1) != 0) {
-                        hello->kshm_version++;   /* just different! */
-                        the_lnet.ln_testprotocompat &= ~1;
-                }
-                LNET_UNLOCK();
-        }
-
-        rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
-                               lnet_acceptor_timeout());
-
-        if (rc != 0) {
-                CDEBUG (D_NETERROR, "Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
-                return rc;
-        }
-
-        if (hello->kshm_nips == 0)
-                return 0;
-
-        rc = libcfs_sock_write(sock, hello->kshm_ips,
-                               hello->kshm_nips * sizeof(__u32),
-                               lnet_acceptor_timeout());
-        if (rc != 0) {
-                CDEBUG (D_NETERROR, "Error %d sending HELLO payload (%d)"
-                        " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips,
-                        HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
-        }
-
-        return rc;
-}
-
-static int
-ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout)
-{
-        cfs_socket_t        *sock = conn->ksnc_sock;
-        lnet_hdr_t          *hdr;
-        int                  rc;
-        int                  i;
-
-        LIBCFS_ALLOC(hdr, sizeof(*hdr));
-        if (hdr == NULL) {
-                CERROR("Can't allocate lnet_hdr_t\n");
-                return -ENOMEM;
-        }
-
-        rc = libcfs_sock_read(sock, &hdr->src_nid,
-                              sizeof (*hdr) - offsetof (lnet_hdr_t, src_nid),
-                              timeout);
-        if (rc != 0) {
-                CERROR ("Error %d reading rest of HELLO hdr from %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
-                goto out;
-        }
-
-        /* ...and check we got what we expected */
-        if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) {
-                CERROR ("Expecting a HELLO hdr,"
-                        " but got type %d from %u.%u.%u.%u\n",
-                        le32_to_cpu (hdr->type),
-                        HIPQUAD(conn->ksnc_ipaddr));
-                rc = -EPROTO;
-                goto out;
-        }
-
-        hello->kshm_src_nid         = le64_to_cpu (hdr->src_nid);
-        hello->kshm_src_pid         = le32_to_cpu (hdr->src_pid);
-        hello->kshm_src_incarnation = le64_to_cpu (hdr->msg.hello.incarnation);
-        hello->kshm_ctype           = le32_to_cpu (hdr->msg.hello.type);
-        hello->kshm_nips            = le32_to_cpu (hdr->payload_length) /
-                                         sizeof (__u32);
-
-        if (hello->kshm_nips > LNET_MAX_INTERFACES) {
-                CERROR("Bad nips %d from ip %u.%u.%u.%u\n",
-                       hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr));
-                rc = -EPROTO;
-                goto out;
-        }
-
-        if (hello->kshm_nips == 0)
-                goto out;
-
-        rc = libcfs_sock_read(sock, hello->kshm_ips,
-                              hello->kshm_nips * sizeof(__u32), timeout);
-        if (rc != 0) {
-                CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
-                goto out;
-        }
-
-        for (i = 0; i < hello->kshm_nips; i++) {
-                hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]);
-
-                if (hello->kshm_ips[i] == 0) {
-                        CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n",
-                               i, HIPQUAD(conn->ksnc_ipaddr));
-                        rc = -EPROTO;
-                        break;
-                }
-        }
-out:
-        LIBCFS_FREE(hdr, sizeof(*hdr));
-
-        return rc;
-}
-
-static int
-ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout)
-{
-        cfs_socket_t      *sock = conn->ksnc_sock;
-        int                rc;
-        int                i;
-
-        if (hello->kshm_magic == LNET_PROTO_MAGIC)
-                conn->ksnc_flip = 0;
-        else
-                conn->ksnc_flip = 1;
-
-        rc = libcfs_sock_read(sock, &hello->kshm_src_nid,
-                              offsetof(ksock_hello_msg_t, kshm_ips) -
-                                       offsetof(ksock_hello_msg_t, kshm_src_nid),
-                              timeout);
-        if (rc != 0) {
-                CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
-                return rc;
-        }
-
-        if (conn->ksnc_flip) {
-                __swab32s(&hello->kshm_src_pid);
-                __swab64s(&hello->kshm_src_nid);
-                __swab32s(&hello->kshm_dst_pid);
-                __swab64s(&hello->kshm_dst_nid);
-                __swab64s(&hello->kshm_src_incarnation);
-                __swab64s(&hello->kshm_dst_incarnation);
-                __swab32s(&hello->kshm_ctype);
-                __swab32s(&hello->kshm_nips);
-        }
-
-        if (hello->kshm_nips > LNET_MAX_INTERFACES) {
-                CERROR("Bad nips %d from ip %u.%u.%u.%u\n",
-                       hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr));
-                return -EPROTO;
-        }
-
-        if (hello->kshm_nips == 0)
-                return 0;
-
-        rc = libcfs_sock_read(sock, hello->kshm_ips,
-                              hello->kshm_nips * sizeof(__u32), timeout);
-        if (rc != 0) {
-                CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n",
-                        rc, HIPQUAD(conn->ksnc_ipaddr));
-                LASSERT (rc < 0 && rc != -EALREADY);
-                return rc;
-        }
-
-        for (i = 0; i < hello->kshm_nips; i++) {
-                if (conn->ksnc_flip)
-                        __swab32s(&hello->kshm_ips[i]);
-
-                if (hello->kshm_ips[i] == 0) {
-                        CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n",
-                               i, HIPQUAD(conn->ksnc_ipaddr));
-                        return -EPROTO;
-                }
-        }
-
-        return 0;
-}
-
-static void
-ksocknal_pack_msg_v1(ksock_tx_t *tx)
-{
-        /* V1.x has no KSOCK_MSG_NOOP */
-        LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
-        LASSERT(tx->tx_lnetmsg != NULL);
-
-        tx->tx_iov[0].iov_base = (void *)&tx->tx_lnetmsg->msg_hdr;
-        tx->tx_iov[0].iov_len  = sizeof(lnet_hdr_t);
-
-        tx->tx_resid = tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(lnet_hdr_t);
-}
-
-static void
-ksocknal_pack_msg_v2(ksock_tx_t *tx)
-{
-        tx->tx_iov[0].iov_base = (void *)&tx->tx_msg;
-
-        if (tx->tx_lnetmsg != NULL) {
-                LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
-
-                tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
-                tx->tx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_payload);
-                tx->tx_resid = tx->tx_nob = offsetof(ksock_msg_t,  ksm_u.lnetmsg.ksnm_payload) +
-                                            tx->tx_lnetmsg->msg_len;
-        } else {
-                LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
-
-                tx->tx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr);
-                tx->tx_resid = tx->tx_nob = offsetof(ksock_msg_t,  ksm_u.lnetmsg.ksnm_hdr);
-        }
-        /* Don't checksum before start sending, because packet can be piggybacked with ACK */
-}
-
-static void
-ksocknal_unpack_msg_v1(ksock_msg_t *msg)
-{
-        msg->ksm_type           = KSOCK_MSG_LNET;
-        msg->ksm_csum           = 0;
-        msg->ksm_zc_req_cookie  = 0;
-        msg->ksm_zc_ack_cookie  = 0;
-}
-
-static void
-ksocknal_unpack_msg_v2(ksock_msg_t *msg)
-{
-        return;  /* Do nothing */
-}
-
-ksock_proto_t  ksocknal_protocol_v1x =
-{
-        KSOCK_PROTO_V1,
-        ksocknal_send_hello_v1,
-        ksocknal_recv_hello_v1,
-        ksocknal_pack_msg_v1,
-        ksocknal_unpack_msg_v1
-};
-
-ksock_proto_t  ksocknal_protocol_v2x =
-{
-        KSOCK_PROTO_V2,
-        ksocknal_send_hello_v2,
-        ksocknal_recv_hello_v2,
-        ksocknal_pack_msg_v2,
-        ksocknal_unpack_msg_v2
-};
-
 int
 ksocknal_send_hello (lnet_ni_t *ni, ksock_conn_t *conn,
                      lnet_nid_t peer_nid, ksock_hello_msg_t *hello)
@@ -2213,9 +1763,11 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
         if (proto == NULL) {
                 if (!active) {
                         /* unknown protocol from peer, tell peer my protocol */
-                        conn->ksnc_proto = &ksocknal_protocol_v2x;
+                        conn->ksnc_proto = &ksocknal_protocol_v3x;
 #if SOCKNAL_VERSION_DEBUG
-                        if (*ksocknal_tunables.ksnd_protocol != 2)
+                        if (*ksocknal_tunables.ksnd_protocol == 2)
+                                conn->ksnc_proto = &ksocknal_protocol_v2x;
+                        else if (*ksocknal_tunables.ksnd_protocol == 1)
                                 conn->ksnc_proto = &ksocknal_protocol_v1x;
 #endif
                         hello->kshm_nips = 0;
@@ -2404,6 +1956,18 @@ ksocknal_connect (ksock_route_t *route)
         if (retry_later) {
                 /* re-queue for attention; this frees me up to handle
                  * the peer's incoming connection request */
+
+                if (rc == EALREADY) {
+                        /* We want to introduce a delay before next
+                         * attempt to connect if we lost conn race,
+                         * but the race is resolved quickly usually,
+                         * so min_reconnectms should be good heruistic */
+                        route->ksnr_retry_interval =
+                                cfs_time_seconds(*ksocknal_tunables.ksnd_min_reconnectms)/1000;
+                        route->ksnr_timeout = cfs_time_add(cfs_time_current(),
+                                                           route->ksnr_retry_interval);
+                }
+
                 ksocknal_launch_connection_locked(route);
         }
 
@@ -2432,14 +1996,18 @@ ksocknal_connect (ksock_route_t *route)
         if (!list_empty(&peer->ksnp_tx_queue) &&
             peer->ksnp_accepting == 0 &&
             ksocknal_find_connecting_route_locked(peer) == NULL) {
+                ksock_conn_t *conn;
+
                 /* ksnp_tx_queue is queued on a conn on successful
-                 * connection */
-                LASSERT (list_empty (&peer->ksnp_conns));
+                 * connection for V1.x and V2.x */
+                if (!list_empty (&peer->ksnp_conns)) {
+                        conn = list_entry(peer->ksnp_conns.next, ksock_conn_t, ksnc_list);
+                        LASSERT (conn->ksnc_proto == &ksocknal_protocol_v3x);
+                }
 
                 /* take all the blocked packets while I've got the lock and
                  * complete below... */
-                list_add(&zombies, &peer->ksnp_tx_queue);
-                list_del_init(&peer->ksnp_tx_queue);
+                list_splice_init(&peer->ksnp_tx_queue, &zombies);
         }
 
 #if 0           /* irrelevent with only eager routes */
@@ -2455,30 +2023,36 @@ ksocknal_connect (ksock_route_t *route)
         ksocknal_txlist_done(peer->ksnp_ni, &zombies, 1);
 }
 
-static inline int
-ksocknal_connd_connect_route_locked(void)
+/* Go through connd_routes queue looking for a route that
+   we can process right now */
+static ksock_route_t *
+ksocknal_connd_get_route_locked(signed long *timeout_p)
 {
-        /* Only handle an outgoing connection request if there is someone left
-         * to handle incoming connections */
-        return !list_empty(&ksocknal_data.ksnd_connd_routes) &&
-                ((ksocknal_data.ksnd_connd_connecting + 1) <
-                 *ksocknal_tunables.ksnd_nconnds);
-}
+        ksock_route_t *route;
+        cfs_time_t     now;
 
-static inline int
-ksocknal_connd_ready(void)
-{
-        int            rc;
+        /* Only handle an outgoing connection request if there
+         * is someone left to handle incoming connections */
+        if ((ksocknal_data.ksnd_connd_connecting + 1) >=
+            *ksocknal_tunables.ksnd_nconnds)
+                return NULL;
 
-        cfs_spin_lock_bh (&ksocknal_data.ksnd_connd_lock);
+        now = cfs_time_current();
 
-        rc = ksocknal_data.ksnd_shuttingdown ||
-             !list_empty(&ksocknal_data.ksnd_connd_connreqs) ||
-             ksocknal_connd_connect_route_locked();
+        /* connd_routes can contain both pending and ordinary routes */
+        list_for_each_entry (route, &ksocknal_data.ksnd_connd_routes,
+                             ksnr_connd_list) {
 
-        cfs_spin_unlock_bh (&ksocknal_data.ksnd_connd_lock);
+                if (route->ksnr_retry_interval == 0 ||
+                    cfs_time_aftereq(now, route->ksnr_timeout))
+                        return route;
 
-        return rc;
+                if (*timeout_p == CFS_MAX_SCHEDULE_TIMEOUT ||
+                    (int)*timeout_p > (int)(route->ksnr_timeout - now))
+                        *timeout_p = (int)(route->ksnr_timeout - now);
+        }
+
+        return NULL;
 }
 
 int
@@ -2488,16 +2062,22 @@ ksocknal_connd (void *arg)
         char               name[16];
         ksock_connreq_t   *cr;
         ksock_route_t     *route;
-        int                rc = 0;
+        cfs_waitlink_t     wait;
+        signed long        timeout;
+        int                dropped_lock;
 
         snprintf (name, sizeof (name), "socknal_cd%02ld", id);
         cfs_daemonize (name);
         cfs_block_allsigs ();
 
+        cfs_waitlink_init (&wait);
+
         cfs_spin_lock_bh (&ksocknal_data.ksnd_connd_lock);
 
         while (!ksocknal_data.ksnd_shuttingdown) {
 
+                dropped_lock = 0;
+
                 if (!list_empty(&ksocknal_data.ksnd_connd_connreqs)) {
                         /* Connection accepted by the listener */
                         cr = list_entry(ksocknal_data.ksnd_connd_connreqs.next,
@@ -2505,6 +2085,7 @@ ksocknal_connd (void *arg)
 
                         list_del(&cr->ksncr_list);
                         cfs_spin_unlock_bh (&ksocknal_data.ksnd_connd_lock);
+                        dropped_lock = 1;
 
                         ksocknal_create_conn(cr->ksncr_ni, NULL,
                                              cr->ksncr_sock, SOCKLND_CONN_NONE);
@@ -2514,14 +2095,17 @@ ksocknal_connd (void *arg)
                         cfs_spin_lock_bh (&ksocknal_data.ksnd_connd_lock);
                 }
 
-                if (ksocknal_connd_connect_route_locked()) {
-                        /* Connection request */
-                        route = list_entry (ksocknal_data.ksnd_connd_routes.next,
-                                            ksock_route_t, ksnr_connd_list);
+                /* Sleep till explicit wake_up if no pending routes present */
+                timeout = CFS_MAX_SCHEDULE_TIMEOUT;
 
+                /* Connection request */
+                route = ksocknal_connd_get_route_locked(&timeout);
+
+                if (route != NULL) {
                         list_del (&route->ksnr_connd_list);
                         ksocknal_data.ksnd_connd_connecting++;
                         cfs_spin_unlock_bh (&ksocknal_data.ksnd_connd_lock);
+                        dropped_lock = 1;
 
                         ksocknal_connect (route);
                         ksocknal_route_decref(route);
@@ -2530,12 +2114,18 @@ ksocknal_connd (void *arg)
                         ksocknal_data.ksnd_connd_connecting--;
                 }
 
+                if (dropped_lock)
+                        continue;
+
+                /* Nothing to do for 'timeout'  */
+                cfs_set_current_state (CFS_TASK_INTERRUPTIBLE);
+                cfs_waitq_add_exclusive (&ksocknal_data.ksnd_connd_waitq, &wait);
                 cfs_spin_unlock_bh (&ksocknal_data.ksnd_connd_lock);
 
-                cfs_wait_event_interruptible_exclusive(
-                        ksocknal_data.ksnd_connd_waitq,
-                        ksocknal_connd_ready(), rc);
+                cfs_waitq_timedwait (&wait, CFS_TASK_INTERRUPTIBLE, timeout);
 
+                cfs_set_current_state (CFS_TASK_RUNNING);
+                cfs_waitq_del (&ksocknal_data.ksnd_connd_waitq, &wait);
                 cfs_spin_lock_bh (&ksocknal_data.ksnd_connd_lock);
         }
 
@@ -2656,6 +2246,68 @@ ksocknal_flush_stale_txs(ksock_peer_t *peer)
         ksocknal_txlist_done(peer->ksnp_ni, &stale_txs, 1);
 }
 
+int
+ksocknal_send_keepalive_locked(ksock_peer_t *peer)
+{
+        ksock_sched_t  *sched;
+        ksock_conn_t   *conn;
+        ksock_tx_t     *tx;
+
+        if (list_empty(&peer->ksnp_conns)) /* last_alive will be updated by create_conn */
+                return 0;
+
+        if (peer->ksnp_proto != &ksocknal_protocol_v3x)
+                return 0;
+
+        if (*ksocknal_tunables.ksnd_keepalive <= 0 ||
+            cfs_time_before(cfs_time_current(),
+                            cfs_time_add(peer->ksnp_last_alive,
+                                         cfs_time_seconds(*ksocknal_tunables.ksnd_keepalive))))
+                return 0;
+
+        if (cfs_time_before(cfs_time_current(),
+                            peer->ksnp_send_keepalive))
+                return 0;
+
+        /* retry 10 secs later, so we wouldn't put pressure
+         * on this peer if we failed to send keepalive this time */
+        peer->ksnp_send_keepalive = cfs_time_shift(10);
+
+        conn = ksocknal_find_conn_locked(peer, NULL, 1);
+        if (conn != NULL) {
+                sched = conn->ksnc_scheduler;
+
+                spin_lock_bh (&sched->kss_lock);
+                if (!list_empty(&conn->ksnc_tx_queue)) {
+                        spin_unlock_bh(&sched->kss_lock);
+                        /* there is an queued ACK, don't need keepalive */
+                        return 0;
+                }
+
+                spin_unlock_bh(&sched->kss_lock);
+        }
+
+        read_unlock(&ksocknal_data.ksnd_global_lock);
+
+        /* cookie = 1 is reserved for keepalive PING */
+        tx = ksocknal_alloc_tx_noop(1, 1);
+        if (tx == NULL) {
+                read_lock(&ksocknal_data.ksnd_global_lock);
+                return -ENOMEM;
+        }
+
+        if (ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id) == 0) {
+                read_lock(&ksocknal_data.ksnd_global_lock);
+                return 1;
+        }
+
+        ksocknal_free_tx(tx);
+        read_lock(&ksocknal_data.ksnd_global_lock);
+
+        return -EIO;
+}
+
+
 void
 ksocknal_check_peer_timeouts (int idx)
 {
@@ -2672,6 +2324,11 @@ ksocknal_check_peer_timeouts (int idx)
 
         list_for_each (ptmp, peers) {
                 peer = list_entry (ptmp, ksock_peer_t, ksnp_list);
+                if (ksocknal_send_keepalive_locked(peer) != 0) {
+                        read_unlock (&ksocknal_data.ksnd_global_lock);
+                        goto again;
+                }
+
                 conn = ksocknal_find_timed_out_conn (peer);
 
                 if (conn != NULL) {
diff --git a/lnet/klnds/socklnd/socklnd_lib-linux.c b/lnet/klnds/socklnd/socklnd_lib-linux.c
index 5b0a9e9..7df7eda 100644
--- a/lnet/klnds/socklnd/socklnd_lib-linux.c
+++ b/lnet/klnds/socklnd/socklnd_lib-linux.c
@@ -43,7 +43,9 @@
 enum {
         SOCKLND_TIMEOUT = 1,
         SOCKLND_CREDITS,
-        SOCKLND_PEER_CREDITS,
+        SOCKLND_PEER_TXCREDITS,
+        SOCKLND_PEER_RTRCREDITS,
+        SOCKLND_PEER_TIMEOUT,
         SOCKLND_NCONNDS,
         SOCKLND_RECONNECTS_MIN,
         SOCKLND_RECONNECTS_MAX,
@@ -55,6 +57,8 @@ enum {
         SOCKLND_TX_BUFFER_SIZE,
         SOCKLND_NAGLE,
         SOCKLND_IRQ_AFFINITY,
+        SOCKLND_ROUND_ROBIN,
+        SOCKLND_KEEPALIVE,
         SOCKLND_KEEPALIVE_IDLE,
         SOCKLND_KEEPALIVE_COUNT,
         SOCKLND_KEEPALIVE_INTVL,
@@ -68,7 +72,9 @@ enum {
 
 #define SOCKLND_TIMEOUT         CTL_UNNUMBERED
 #define SOCKLND_CREDITS         CTL_UNNUMBERED
-#define SOCKLND_PEER_CREDITS    CTL_UNNUMBERED
+#define SOCKLND_PEER_TXCREDITS  CTL_UNNUMBERED
+#define SOCKLND_PEER_RTRCREDITS  CTL_UNNUMBERED
+#define SOCKLND_PEER_TIMEOUT    CTL_UNNUMBERED
 #define SOCKLND_NCONNDS         CTL_UNNUMBERED
 #define SOCKLND_RECONNECTS_MIN  CTL_UNNUMBERED
 #define SOCKLND_RECONNECTS_MAX  CTL_UNNUMBERED
@@ -80,6 +86,8 @@ enum {
 #define SOCKLND_TX_BUFFER_SIZE  CTL_UNNUMBERED
 #define SOCKLND_NAGLE           CTL_UNNUMBERED
 #define SOCKLND_IRQ_AFFINITY    CTL_UNNUMBERED
+#define SOCKLND_ROUND_ROBIN     CTL_UNNUMBERED
+#define SOCKLND_KEEPALIVE       CTL_UNNUMBERED
 #define SOCKLND_KEEPALIVE_IDLE  CTL_UNNUMBERED
 #define SOCKLND_KEEPALIVE_COUNT CTL_UNNUMBERED
 #define SOCKLND_KEEPALIVE_INTVL CTL_UNNUMBERED
@@ -110,9 +118,27 @@ static cfs_sysctl_table_t ksocknal_ctl_table[] = {
                 .strategy = &sysctl_intvec,
         },
          {
-                .ctl_name = SOCKLND_PEER_CREDITS,
+                .ctl_name = SOCKLND_PEER_TXCREDITS,
                 .procname = "peer_credits",
-                .data     = &ksocknal_tunables.ksnd_peercredits,
+                .data     = &ksocknal_tunables.ksnd_peertxcredits,
+                .maxlen   = sizeof (int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec,
+                .strategy = &sysctl_intvec,
+        },
+         {
+                .ctl_name = SOCKLND_PEER_RTRCREDITS,
+                .procname = "peer_buffer_credits",
+                .data     = &ksocknal_tunables.ksnd_peerrtrcredits,
+                .maxlen   = sizeof (int),
+                .mode     = 0444,
+                .proc_handler = &proc_dointvec,
+                .strategy = &sysctl_intvec,
+        },
+        {
+                .ctl_name = SOCKLND_PEER_TIMEOUT,
+                .procname = "peer_timeout",
+                .data     = &ksocknal_tunables.ksnd_peertimeout,
                 .maxlen   = sizeof (int),
                 .mode     = 0444,
                 .proc_handler = &proc_dointvec,
@@ -157,7 +183,7 @@ static cfs_sysctl_table_t ksocknal_ctl_table[] = {
         {
                 .ctl_name = SOCKLND_ZERO_COPY,
                 .procname = "zero_copy",
-                .data     = &ksocknal_tunables.ksnd_zc_min_frag,
+                .data     = &ksocknal_tunables.ksnd_zc_min_payload,
                 .maxlen   = sizeof (int),
                 .mode     = 0644,
                 .proc_handler = &proc_dointvec,
@@ -239,6 +265,24 @@ static cfs_sysctl_table_t ksocknal_ctl_table[] = {
         },
 #endif
         {
+                .ctl_name = SOCKLND_ROUND_ROBIN,
+                .procname = "round_robin",
+                .data     = &ksocknal_tunables.ksnd_round_robin,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_dointvec,
+                .strategy = &sysctl_intvec,
+        },
+        {
+                .ctl_name = SOCKLND_KEEPALIVE,
+                .procname = "keepalive",
+                .data     = &ksocknal_tunables.ksnd_keepalive,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_dointvec,
+                .strategy = &sysctl_intvec,
+        },
+        {
                 .ctl_name = SOCKLND_KEEPALIVE_IDLE,
                 .procname = "keepalive_idle",
                 .data     = &ksocknal_tunables.ksnd_keepalive_idle,
@@ -315,6 +359,20 @@ cfs_sysctl_table_t ksocknal_top_ctl_table[] = {
 int
 ksocknal_lib_tunables_init ()
 {
+        if (!*ksocknal_tunables.ksnd_typed_conns) {
+                int rc = -EINVAL;
+#if SOCKNAL_VERSION_DEBUG
+                if (*ksocknal_tunables.ksnd_protocol < 3)
+                        rc = 0;
+#endif
+                if (rc != 0) {
+                        CERROR("Protocol V3.x MUST have typed connections\n");
+                        return rc;
+                }
+        }
+
+        if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10))
+                *ksocknal_tunables.ksnd_zc_min_payload = (2 << 10);
         if (*ksocknal_tunables.ksnd_zc_recv_min_nfrags < 2)
                 *ksocknal_tunables.ksnd_zc_recv_min_nfrags = 2;
         if (*ksocknal_tunables.ksnd_zc_recv_min_nfrags > LNET_MAX_IOV)
@@ -447,9 +505,12 @@ ksocknal_lib_sock_irq (struct socket *sock)
 }
 
 int
-ksocknal_lib_zc_capable(struct socket *sock)
+ksocknal_lib_zc_capable(ksock_conn_t *conn)
 {
-        int  caps = sock->sk->sk_route_caps;
+        int  caps = conn->ksnc_sock->sk->sk_route_caps;
+
+        if (conn->ksnc_proto == &ksocknal_protocol_v1x)
+                return 0;
 
         /* ZC if the socket supports scatter/gather and doesn't need software
          * checksums */
@@ -514,15 +575,16 @@ int
 ksocknal_lib_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
 {
         struct socket *sock = conn->ksnc_sock;
-        lnet_kiov_t    *kiov = tx->tx_kiov;
+        lnet_kiov_t   *kiov = tx->tx_kiov;
         int            rc;
         int            nob;
 
+        /* Not NOOP message */
+        LASSERT (tx->tx_lnetmsg != NULL);
+
         /* NB we can't trust socket ops to either consume our iovs
          * or leave them alone. */
-
-        if (kiov->kiov_len >= *ksocknal_tunables.ksnd_zc_min_frag &&
-            tx->tx_msg.ksm_zc_req_cookie != 0) {
+        if (tx->tx_msg.ksm_zc_cookies[0] != 0) {
                 /* Zero copy is enabled */
                 struct sock   *sk = sock->sk;
                 struct page   *page = kiov->kiov_page;
diff --git a/lnet/klnds/socklnd/socklnd_modparams.c b/lnet/klnds/socklnd/socklnd_modparams.c
index 32ffa3c..d3d7cd0 100644
--- a/lnet/klnds/socklnd/socklnd_modparams.c
+++ b/lnet/klnds/socklnd/socklnd_modparams.c
@@ -33,6 +33,14 @@ static int peer_credits = 8;
 CFS_MODULE_PARM(peer_credits, "i", int, 0444,
                 "# concurrent sends to 1 peer");
 
+static int peer_buffer_credits = 0;
+CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
+                "# per-peer router buffer credits");
+
+static int peer_timeout = 0;
+CFS_MODULE_PARM(peer_timeout, "i", int, 0444,
+                "Seconds without aliveness news to declare peer dead (<=0 to disable)");
+
 static int nconnds = 4;
 CFS_MODULE_PARM(nconnds, "i", int, 0444,
                 "# connection daemons");
@@ -83,6 +91,14 @@ static int nagle = 0;
 CFS_MODULE_PARM(nagle, "i", int, 0644,
                 "enable NAGLE?");
 
+static int round_robin = 1;
+CFS_MODULE_PARM(round_robin, "i", int, 0644,
+                "Round robin for multiple interfaces");
+
+static int keepalive = 30;
+CFS_MODULE_PARM(keepalive, "i", int, 0644,
+                "# seconds before send keepalive");
+
 static int keepalive_idle = 30;
 CFS_MODULE_PARM(keepalive_idle, "i", int, 0644,
                 "# idle seconds before probe");
@@ -113,9 +129,9 @@ CFS_MODULE_PARM(enable_irq_affinity, "i", int, 0644,
                 "enable IRQ affinity");
 #endif
 
-static unsigned int zc_min_frag = (2<<10);
-CFS_MODULE_PARM(zc_min_frag, "i", int, 0644,
-                "minimum fragment to zero copy");
+static unsigned int zc_min_payload = (16 << 10);
+CFS_MODULE_PARM(zc_min_payload, "i", int, 0644,
+                "minimum payload size to zero copy");
 
 static unsigned int zc_recv = 0;
 CFS_MODULE_PARM(zc_recv, "i", int, 0644,
@@ -136,7 +152,7 @@ CFS_MODULE_PARM(backoff_max, "i", int, 0644,
 #endif
 
 #if SOCKNAL_VERSION_DEBUG
-static int protocol = 2;
+static int protocol = 3;
 CFS_MODULE_PARM(protocol, "i", int, 0644,
                 "protocol version");
 #endif
@@ -144,7 +160,9 @@ CFS_MODULE_PARM(protocol, "i", int, 0644,
 ksock_tunables_t ksocknal_tunables = {
         .ksnd_timeout         = &sock_timeout,
         .ksnd_credits         = &credits,
-        .ksnd_peercredits     = &peer_credits,
+        .ksnd_peertxcredits   = &peer_credits,
+        .ksnd_peerrtrcredits  = &peer_buffer_credits,
+        .ksnd_peertimeout     = &peer_timeout,
         .ksnd_nconnds         = &nconnds,
         .ksnd_min_reconnectms = &min_reconnectms,
         .ksnd_max_reconnectms = &max_reconnectms,
@@ -154,12 +172,14 @@ ksock_tunables_t ksocknal_tunables = {
         .ksnd_tx_buffer_size  = &tx_buffer_size,
         .ksnd_rx_buffer_size  = &rx_buffer_size,
         .ksnd_nagle           = &nagle,
+        .ksnd_round_robin     = &round_robin,
+        .ksnd_keepalive       = &keepalive,
         .ksnd_keepalive_idle  = &keepalive_idle,
         .ksnd_keepalive_count = &keepalive_count,
         .ksnd_keepalive_intvl = &keepalive_intvl,
         .ksnd_enable_csum     = &enable_csum,
         .ksnd_inject_csum_error = &inject_csum_error,
-        .ksnd_zc_min_frag     = &zc_min_frag,
+        .ksnd_zc_min_payload  = &zc_min_payload,
         .ksnd_zc_recv         = &zc_recv,
         .ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags,
 #ifdef CPU_AFFINITY
diff --git a/lnet/klnds/socklnd/socklnd_proto.c b/lnet/klnds/socklnd/socklnd_proto.c
new file mode 100644
index 0000000..20bdc4d
--- /dev/null
+++ b/lnet/klnds/socklnd/socklnd_proto.c
@@ -0,0 +1,794 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ *
+ *   Author: Zach Brown <zab at zabbo.net>
+ *   Author: Peter J. Braam <braam at clusterfs.com>
+ *   Author: Phil Schwan <phil at clusterfs.com>
+ *   Author: Eric Barton <eric at bartonsoftware.com>
+ *
+ *   This file is part of Portals, http://www.sf.net/projects/sandiaportals/
+ *
+ *   Portals is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Portals is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Portals; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "socklnd.h"
+
+/*
+ * Protocol entries :
+ *   pro_send_hello       : send hello message
+ *   pro_recv_hello       : receive hello message
+ *   pro_pack             : pack message header
+ *   pro_unpack           : unpack message header
+ *   pro_queue_tx_zcack() : Called holding BH lock: kss_lock
+ *                          return 1 if ACK is piggybacked, otherwise return 0
+ *   pro_queue_tx_msg()   : Called holding BH lock: kss_lock
+ *                          return the ACK that piggybacked by my message, or NULL
+ *   pro_handle_zcreq()   : handler of incoming ZC-REQ
+ *   pro_handle_zcack()   : handler of incoming ZC-ACK
+ *   pro_match_tx()       : Called holding glock
+ */
+
+static ksock_tx_t *
+ksocknal_queue_tx_msg_v1(ksock_conn_t *conn, ksock_tx_t *tx_msg)
+{
+        /* V1.x, just enqueue it */
+        list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
+        return NULL;
+}
+
+void
+ksocknal_next_tx_carrier(ksock_conn_t *conn)
+{
+        ksock_tx_t     *tx = conn->ksnc_tx_carrier;
+
+        /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
+        LASSERT (!list_empty(&conn->ksnc_tx_queue));
+        LASSERT (tx != NULL);
+
+        /* Next TX that can carry ZC-ACK or LNet message */
+        if (tx->tx_list.next == &conn->ksnc_tx_queue) {
+                /* no more packets queued */
+                conn->ksnc_tx_carrier = NULL;
+        } else {
+                conn->ksnc_tx_carrier = list_entry(tx->tx_list.next, ksock_tx_t, tx_list);
+                LASSERT (conn->ksnc_tx_carrier->tx_msg.ksm_type == tx->tx_msg.ksm_type);
+        }
+}
+
+static int
+ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
+                           ksock_tx_t *tx_ack, __u64 cookie)
+{
+        ksock_tx_t *tx = conn->ksnc_tx_carrier;
+
+        LASSERT (tx_ack == NULL ||
+                 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+
+        /*
+         * Enqueue or piggyback tx_ack / cookie
+         * . no tx can piggyback cookie of tx_ack (or cookie), just
+         *   enqueue the tx_ack (if tx_ack != NUL) and return NULL.
+         * . There is tx can piggyback cookie of tx_ack (or cookie),
+         *   piggyback the cookie and return the tx.
+         */
+        if (tx == NULL) {
+                if (tx_ack != NULL) {
+                        list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
+                        conn->ksnc_tx_carrier = tx_ack;
+                }
+                return 0;
+        }
+
+        if (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP) {
+                /* tx is noop zc-ack, can't piggyback zc-ack cookie */
+                if (tx_ack != NULL)
+                        list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
+                return 0;
+        }
+
+        LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_LNET);
+        LASSERT(tx->tx_msg.ksm_zc_cookies[1] == 0);
+
+        if (tx_ack != NULL)
+                cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
+
+        /* piggyback the zc-ack cookie */
+        tx->tx_msg.ksm_zc_cookies[1] = cookie;
+        /* move on to the next TX which can carry cookie */
+        ksocknal_next_tx_carrier(conn);
+
+        return 1;
+}
+
+static ksock_tx_t *
+ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg)
+{
+        ksock_tx_t  *tx  = conn->ksnc_tx_carrier;
+
+        /*
+         * Enqueue tx_msg:
+         * . If there is no NOOP on the connection, just enqueue
+         *   tx_msg and return NULL
+         * . If there is NOOP on the connection, piggyback the cookie
+         *   and replace the NOOP tx, and return the NOOP tx.
+         */
+        if (tx == NULL) { /* nothing on queue */
+                list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
+                conn->ksnc_tx_carrier = tx_msg;
+                return NULL;
+        }
+
+        if (tx->tx_msg.ksm_type == KSOCK_MSG_LNET) { /* nothing to carry */
+                list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue);
+                return NULL;
+        }
+
+        LASSERT (tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+
+        /* There is a noop zc-ack can be piggybacked */
+        tx_msg->tx_msg.ksm_zc_cookies[1] = tx->tx_msg.ksm_zc_cookies[1];
+        ksocknal_next_tx_carrier(conn);
+
+        /* use new_tx to replace the noop zc-ack packet */
+        list_add(&tx_msg->tx_list, &tx->tx_list);
+        list_del(&tx->tx_list);
+
+        return tx;
+}
+
+static int
+ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn,
+                           ksock_tx_t *tx_ack, __u64 cookie)
+{
+        ksock_tx_t *tx;
+
+        if (conn->ksnc_type != SOCKLND_CONN_ACK)
+                return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie);
+
+        /* non-blocking ZC-ACK (to router) */
+        LASSERT (tx_ack == NULL ||
+                 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+
+        if ((tx = conn->ksnc_tx_carrier) == NULL) {
+                if (tx_ack != NULL) {
+                        list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
+                        conn->ksnc_tx_carrier = tx_ack;
+                }
+                return 0;
+        }
+
+        /* conn->ksnc_tx_carrier != NULL */
+
+        if (tx_ack != NULL)
+                cookie = tx_ack->tx_msg.ksm_zc_cookies[1];
+
+        if (cookie == SOCKNAL_KEEPALIVE_PING) /* ignore keepalive PING */
+                return 1;
+
+        if (tx->tx_msg.ksm_zc_cookies[1] == SOCKNAL_KEEPALIVE_PING) {
+                /* replace the keepalive PING with a real ACK */
+                LASSERT (tx->tx_msg.ksm_zc_cookies[0] == 0);
+                tx->tx_msg.ksm_zc_cookies[1] = cookie;
+                return 1;
+        }
+
+        if (cookie == tx->tx_msg.ksm_zc_cookies[0] ||
+            cookie == tx->tx_msg.ksm_zc_cookies[1]) {
+                CWARN("%s: duplicated ZC cookie: "LPU64"\n",
+                      libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie);
+                return 1; /* XXX return error in the future */
+        }
+
+        if (tx->tx_msg.ksm_zc_cookies[0] == 0) {
+                /* NOOP tx has only one ZC-ACK cookie, can carry at least one more */
+                if (tx->tx_msg.ksm_zc_cookies[1] > cookie) {
+                        tx->tx_msg.ksm_zc_cookies[0] = tx->tx_msg.ksm_zc_cookies[1];
+                        tx->tx_msg.ksm_zc_cookies[1] = cookie;
+                } else {
+                        tx->tx_msg.ksm_zc_cookies[0] = cookie;
+                }
+
+                if (tx->tx_msg.ksm_zc_cookies[0] - tx->tx_msg.ksm_zc_cookies[1] > 2) {
+                        /* not likely to carry more ACKs, skip it to simplify logic */
+                        ksocknal_next_tx_carrier(conn);
+                }
+
+                return 1;
+        }
+
+        /* takes two or more cookies already */
+
+        if (tx->tx_msg.ksm_zc_cookies[0] > tx->tx_msg.ksm_zc_cookies[1]) {
+                __u64   tmp = 0;
+
+                /* two seperated cookies: (a+2, a) or (a+1, a) */
+                LASSERT (tx->tx_msg.ksm_zc_cookies[0] -
+                         tx->tx_msg.ksm_zc_cookies[1] <= 2);
+
+                if (tx->tx_msg.ksm_zc_cookies[0] -
+                    tx->tx_msg.ksm_zc_cookies[1] == 2) {
+                        if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1)
+                                tmp = cookie;
+                } else if (cookie == tx->tx_msg.ksm_zc_cookies[1] - 1) {
+                        tmp = tx->tx_msg.ksm_zc_cookies[1];
+                } else if (cookie == tx->tx_msg.ksm_zc_cookies[0] + 1) {
+                        tmp = tx->tx_msg.ksm_zc_cookies[0];
+                }
+
+                if (tmp != 0) {
+                        /* range of cookies */
+                        tx->tx_msg.ksm_zc_cookies[0] = tmp - 1;
+                        tx->tx_msg.ksm_zc_cookies[1] = tmp + 1;
+                        return 1;
+                }
+
+        } else {
+                /* ksm_zc_cookies[0] < ksm_zc_cookies[1], it is range of cookies */
+                if (cookie >= tx->tx_msg.ksm_zc_cookies[0] &&
+                    cookie <= tx->tx_msg.ksm_zc_cookies[1]) {
+                        CWARN("%s: duplicated ZC cookie: "LPU64"\n",
+                              libcfs_id2str(conn->ksnc_peer->ksnp_id), cookie);
+                        return 1; /* XXX: return error in the future */
+                }
+
+                if (cookie == tx->tx_msg.ksm_zc_cookies[1] + 1) {
+                        tx->tx_msg.ksm_zc_cookies[1] = cookie;
+                        return 1;
+                }
+
+                if (cookie == tx->tx_msg.ksm_zc_cookies[0] - 1) {
+                        tx->tx_msg.ksm_zc_cookies[0] = cookie;
+                        return 1;
+                }
+        }
+
+        /* failed to piggyback ZC-ACK */
+        if (tx_ack != NULL) {
+                list_add_tail(&tx_ack->tx_list, &conn->ksnc_tx_queue);
+                /* the next tx can piggyback at least 1 ACK */
+                ksocknal_next_tx_carrier(conn);
+        }
+
+        return 0;
+}
+
+static int
+ksocknal_match_tx(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk)
+{
+        int nob;
+
+#if SOCKNAL_VERSION_DEBUG
+        if (!*ksocknal_tunables.ksnd_typed_conns)
+                return SOCKNAL_MATCH_YES;
+#endif
+
+        if (tx == NULL || tx->tx_lnetmsg == NULL) {
+                /* noop packet */
+                nob = offsetof(ksock_msg_t, ksm_u);
+        } else {
+                nob = tx->tx_lnetmsg->msg_len +
+                      ((conn->ksnc_proto == &ksocknal_protocol_v1x) ?
+                       sizeof(lnet_hdr_t) : sizeof(ksock_msg_t));
+        }
+
+        /* default checking for typed connection */
+        switch (conn->ksnc_type) {
+        default:
+                CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
+                LBUG();
+        case SOCKLND_CONN_ANY:
+                return SOCKNAL_MATCH_YES;
+
+        case SOCKLND_CONN_BULK_IN:
+                return SOCKNAL_MATCH_MAY;
+
+        case SOCKLND_CONN_BULK_OUT:
+                if (nob < *ksocknal_tunables.ksnd_min_bulk)
+                        return SOCKNAL_MATCH_MAY;
+                else
+                        return SOCKNAL_MATCH_YES;
+
+        case SOCKLND_CONN_CONTROL:
+                if (nob >= *ksocknal_tunables.ksnd_min_bulk)
+                        return SOCKNAL_MATCH_MAY;
+                else
+                        return SOCKNAL_MATCH_YES;
+        }
+}
+
+static int
+ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk)
+{
+        int nob;
+
+        if (tx == NULL || tx->tx_lnetmsg == NULL)
+                nob = offsetof(ksock_msg_t, ksm_u);
+        else
+                nob = tx->tx_lnetmsg->msg_len + sizeof(ksock_msg_t);
+
+        switch (conn->ksnc_type) {
+        default:
+                CERROR("ksnc_type bad: %u\n", conn->ksnc_type);
+                LBUG();
+        case SOCKLND_CONN_ANY:
+                return SOCKNAL_MATCH_NO;
+
+        case SOCKLND_CONN_ACK:
+                if (nonblk)
+                        return SOCKNAL_MATCH_YES;
+                else if (tx == NULL || tx->tx_lnetmsg == NULL)
+                        return SOCKNAL_MATCH_MAY;
+                else
+                        return SOCKNAL_MATCH_NO;
+
+        case SOCKLND_CONN_BULK_OUT:
+                if (nonblk)
+                        return SOCKNAL_MATCH_NO;
+                else if (nob < *ksocknal_tunables.ksnd_min_bulk)
+                        return SOCKNAL_MATCH_MAY;
+                else
+                        return SOCKNAL_MATCH_YES;
+
+        case SOCKLND_CONN_CONTROL:
+                if (nonblk)
+                        return SOCKNAL_MATCH_NO;
+                else if (nob >= *ksocknal_tunables.ksnd_min_bulk)
+                        return SOCKNAL_MATCH_MAY;
+                else
+                        return SOCKNAL_MATCH_YES;
+        }
+}
+
+/* (Sink) handle incoming ZC request from sender */
+static int
+ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote)
+{
+        ksock_peer_t   *peer = c->ksnc_peer;
+        ksock_conn_t   *conn;
+        ksock_tx_t     *tx;
+        int             rc;
+
+        cfs_read_lock (&ksocknal_data.ksnd_global_lock);
+
+        conn = ksocknal_find_conn_locked(peer, NULL, !!remote);
+        if (conn != NULL) {
+                ksock_sched_t *sched = conn->ksnc_scheduler;
+
+                LASSERT (conn->ksnc_proto->pro_queue_tx_zcack != NULL);
+
+                cfs_spin_lock_bh (&sched->kss_lock);
+
+                rc = conn->ksnc_proto->pro_queue_tx_zcack(conn, NULL, cookie);
+
+                cfs_spin_unlock_bh (&sched->kss_lock);
+
+                if (rc) { /* piggybacked */
+                        read_unlock (&ksocknal_data.ksnd_global_lock);
+                        return 0;
+                }
+        }
+
+        cfs_read_unlock (&ksocknal_data.ksnd_global_lock);
+
+        /* ACK connection is not ready, or can't piggyback the ACK */
+        tx = ksocknal_alloc_tx_noop(cookie, !!remote);
+        if (tx == NULL)
+                return -ENOMEM;
+
+        if ((rc = ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id)) == 0)
+                return 0;
+
+        ksocknal_free_tx(tx);
+        return rc;
+}
+
+/* (Sender) handle ZC_ACK from sink */
+static int
+ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
+{
+        ksock_peer_t      *peer = conn->ksnc_peer;
+        ksock_tx_t        *tx;
+        ksock_tx_t        *tmp;
+        CFS_LIST_HEAD     (zlist);
+        int                count;
+
+        if (cookie1 == 0)
+                cookie1 = cookie2;
+
+        count = (cookie1 > cookie2) ? 2 : (cookie2 - cookie1 + 1);
+
+        if (cookie2 == SOCKNAL_KEEPALIVE_PING &&
+            conn->ksnc_proto == &ksocknal_protocol_v3x) {
+                /* keepalive PING for V3.x, just ignore it */
+                return count == 1 ? 0 : -EPROTO;
+        }
+
+        cfs_spin_lock(&peer->ksnp_lock);
+
+        list_for_each_entry_safe(tx, tmp,
+                                 &peer->ksnp_zc_req_list, tx_zc_list) {
+                __u64 c = tx->tx_msg.ksm_zc_cookies[0];
+
+                if (c == cookie1 || c == cookie2 || (cookie1 < c && c < cookie2)) {
+                        tx->tx_msg.ksm_zc_cookies[0] = 0;
+                        list_del(&tx->tx_zc_list);
+                        list_add(&tx->tx_zc_list, &zlist);
+
+                        if (--count == 0)
+                                break;
+                }
+        }
+
+        cfs_spin_unlock(&peer->ksnp_lock);
+
+        while (!list_empty(&zlist)) {
+                tx = list_entry(zlist.next, ksock_tx_t, tx_zc_list);
+                list_del(&tx->tx_zc_list);
+                ksocknal_tx_decref(tx);
+        }
+
+        return count == 0 ? 0 : -EPROTO;
+}
+
+static int
+ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
+{
+        cfs_socket_t        *sock = conn->ksnc_sock;
+        lnet_hdr_t          *hdr;
+        lnet_magicversion_t *hmv;
+        int                  rc;
+        int                  i;
+
+        CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid));
+
+        LIBCFS_ALLOC(hdr, sizeof(*hdr));
+        if (hdr == NULL) {
+                CERROR("Can't allocate lnet_hdr_t\n");
+                return -ENOMEM;
+        }
+
+        hmv = (lnet_magicversion_t *)&hdr->dest_nid;
+
+        /* Re-organize V2.x message header to V1.x (lnet_hdr_t)
+         * header and send out */
+        hmv->magic         = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
+        hmv->version_major = cpu_to_le16 (KSOCK_PROTO_V1_MAJOR);
+        hmv->version_minor = cpu_to_le16 (KSOCK_PROTO_V1_MINOR);
+
+        if (the_lnet.ln_testprotocompat != 0) {
+                /* single-shot proto check */
+                LNET_LOCK();
+                if ((the_lnet.ln_testprotocompat & 1) != 0) {
+                        hmv->version_major++;   /* just different! */
+                        the_lnet.ln_testprotocompat &= ~1;
+                }
+                if ((the_lnet.ln_testprotocompat & 2) != 0) {
+                        hmv->magic = LNET_PROTO_MAGIC;
+                        the_lnet.ln_testprotocompat &= ~2;
+                }
+                LNET_UNLOCK();
+        }
+
+        hdr->src_nid        = cpu_to_le64 (hello->kshm_src_nid);
+        hdr->src_pid        = cpu_to_le32 (hello->kshm_src_pid);
+        hdr->type           = cpu_to_le32 (LNET_MSG_HELLO);
+        hdr->payload_length = cpu_to_le32 (hello->kshm_nips * sizeof(__u32));
+        hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
+        hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
+
+        rc = libcfs_sock_write(sock, hdr, sizeof(*hdr), lnet_acceptor_timeout());
+
+        if (rc != 0) {
+                CDEBUG (D_NETERROR, "Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n",
+                        rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+                goto out;
+        }
+
+        if (hello->kshm_nips == 0)
+                goto out;
+
+        for (i = 0; i < (int) hello->kshm_nips; i++) {
+                hello->kshm_ips[i] = __cpu_to_le32 (hello->kshm_ips[i]);
+        }
+
+        rc = libcfs_sock_write(sock, hello->kshm_ips,
+                               hello->kshm_nips * sizeof(__u32),
+                               lnet_acceptor_timeout());
+        if (rc != 0) {
+                CDEBUG (D_NETERROR, "Error %d sending HELLO payload (%d)"
+                        " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips,
+                        HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+        }
+out:
+        LIBCFS_FREE(hdr, sizeof(*hdr));
+
+        return rc;
+}
+
+static int
+ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello)
+{
+        cfs_socket_t   *sock = conn->ksnc_sock;
+        int             rc;
+
+        hello->kshm_magic   = LNET_PROTO_MAGIC;
+        hello->kshm_version = conn->ksnc_proto->pro_version;
+
+        if (the_lnet.ln_testprotocompat != 0) {
+                /* single-shot proto check */
+                LNET_LOCK();
+                if ((the_lnet.ln_testprotocompat & 1) != 0) {
+                        hello->kshm_version++;   /* just different! */
+                        the_lnet.ln_testprotocompat &= ~1;
+                }
+                LNET_UNLOCK();
+        }
+
+        rc = libcfs_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
+                               lnet_acceptor_timeout());
+
+        if (rc != 0) {
+                CDEBUG (D_NETERROR, "Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n",
+                        rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+                return rc;
+        }
+
+        if (hello->kshm_nips == 0)
+                return 0;
+
+        rc = libcfs_sock_write(sock, hello->kshm_ips,
+                               hello->kshm_nips * sizeof(__u32),
+                               lnet_acceptor_timeout());
+        if (rc != 0) {
+                CDEBUG (D_NETERROR, "Error %d sending HELLO payload (%d)"
+                        " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips,
+                        HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port);
+        }
+
+        return rc;
+}
+
+static int
+ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout)
+{
+        cfs_socket_t        *sock = conn->ksnc_sock;
+        lnet_hdr_t          *hdr;
+        int                  rc;
+        int                  i;
+
+        LIBCFS_ALLOC(hdr, sizeof(*hdr));
+        if (hdr == NULL) {
+                CERROR("Can't allocate lnet_hdr_t\n");
+                return -ENOMEM;
+        }
+
+        rc = libcfs_sock_read(sock, &hdr->src_nid,
+                              sizeof (*hdr) - offsetof (lnet_hdr_t, src_nid),
+                              timeout);
+        if (rc != 0) {
+                CERROR ("Error %d reading rest of HELLO hdr from %u.%u.%u.%u\n",
+                        rc, HIPQUAD(conn->ksnc_ipaddr));
+                LASSERT (rc < 0 && rc != -EALREADY);
+                goto out;
+        }
+
+        /* ...and check we got what we expected */
+        if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) {
+                CERROR ("Expecting a HELLO hdr,"
+                        " but got type %d from %u.%u.%u.%u\n",
+                        le32_to_cpu (hdr->type),
+                        HIPQUAD(conn->ksnc_ipaddr));
+                rc = -EPROTO;
+                goto out;
+        }
+
+        hello->kshm_src_nid         = le64_to_cpu (hdr->src_nid);
+        hello->kshm_src_pid         = le32_to_cpu (hdr->src_pid);
+        hello->kshm_src_incarnation = le64_to_cpu (hdr->msg.hello.incarnation);
+        hello->kshm_ctype           = le32_to_cpu (hdr->msg.hello.type);
+        hello->kshm_nips            = le32_to_cpu (hdr->payload_length) /
+                                         sizeof (__u32);
+
+        if (hello->kshm_nips > LNET_MAX_INTERFACES) {
+                CERROR("Bad nips %d from ip %u.%u.%u.%u\n",
+                       hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr));
+                rc = -EPROTO;
+                goto out;
+        }
+
+        if (hello->kshm_nips == 0)
+                goto out;
+
+        rc = libcfs_sock_read(sock, hello->kshm_ips,
+                              hello->kshm_nips * sizeof(__u32), timeout);
+        if (rc != 0) {
+                CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n",
+                        rc, HIPQUAD(conn->ksnc_ipaddr));
+                LASSERT (rc < 0 && rc != -EALREADY);
+                goto out;
+        }
+
+        for (i = 0; i < (int) hello->kshm_nips; i++) {
+                hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]);
+
+                if (hello->kshm_ips[i] == 0) {
+                        CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n",
+                               i, HIPQUAD(conn->ksnc_ipaddr));
+                        rc = -EPROTO;
+                        break;
+                }
+        }
+out:
+        LIBCFS_FREE(hdr, sizeof(*hdr));
+
+        return rc;
+}
+
+static int
+ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout)
+{
+        cfs_socket_t      *sock = conn->ksnc_sock;
+        int                rc;
+        int                i;
+
+        if (hello->kshm_magic == LNET_PROTO_MAGIC)
+                conn->ksnc_flip = 0;
+        else
+                conn->ksnc_flip = 1;
+
+        rc = libcfs_sock_read(sock, &hello->kshm_src_nid,
+                              offsetof(ksock_hello_msg_t, kshm_ips) -
+                                       offsetof(ksock_hello_msg_t, kshm_src_nid),
+                              timeout);
+        if (rc != 0) {
+                CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n",
+                        rc, HIPQUAD(conn->ksnc_ipaddr));
+                LASSERT (rc < 0 && rc != -EALREADY);
+                return rc;
+        }
+
+        if (conn->ksnc_flip) {
+                __swab32s(&hello->kshm_src_pid);
+                __swab64s(&hello->kshm_src_nid);
+                __swab32s(&hello->kshm_dst_pid);
+                __swab64s(&hello->kshm_dst_nid);
+                __swab64s(&hello->kshm_src_incarnation);
+                __swab64s(&hello->kshm_dst_incarnation);
+                __swab32s(&hello->kshm_ctype);
+                __swab32s(&hello->kshm_nips);
+        }
+
+        if (hello->kshm_nips > LNET_MAX_INTERFACES) {
+                CERROR("Bad nips %d from ip %u.%u.%u.%u\n",
+                       hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr));
+                return -EPROTO;
+        }
+
+        if (hello->kshm_nips == 0)
+                return 0;
+
+        rc = libcfs_sock_read(sock, hello->kshm_ips,
+                              hello->kshm_nips * sizeof(__u32), timeout);
+        if (rc != 0) {
+                CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n",
+                        rc, HIPQUAD(conn->ksnc_ipaddr));
+                LASSERT (rc < 0 && rc != -EALREADY);
+                return rc;
+        }
+
+        for (i = 0; i < (int) hello->kshm_nips; i++) {
+                if (conn->ksnc_flip)
+                        __swab32s(&hello->kshm_ips[i]);
+
+                if (hello->kshm_ips[i] == 0) {
+                        CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n",
+                               i, HIPQUAD(conn->ksnc_ipaddr));
+                        return -EPROTO;
+                }
+        }
+
+        return 0;
+}
+
+static void
+ksocknal_pack_msg_v1(ksock_tx_t *tx)
+{
+        /* V1.x has no KSOCK_MSG_NOOP */
+        LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
+        LASSERT(tx->tx_lnetmsg != NULL);
+
+        tx->tx_iov[0].iov_base = (void *)&tx->tx_lnetmsg->msg_hdr;
+        tx->tx_iov[0].iov_len  = sizeof(lnet_hdr_t);
+
+        tx->tx_resid = tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(lnet_hdr_t);
+}
+
+static void
+ksocknal_pack_msg_v2(ksock_tx_t *tx)
+{
+        tx->tx_iov[0].iov_base = (void *)&tx->tx_msg;
+
+        if (tx->tx_lnetmsg != NULL) {
+                LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
+
+                tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
+                tx->tx_iov[0].iov_len = sizeof(ksock_msg_t);
+                tx->tx_resid = tx->tx_nob = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len;
+        } else {
+                LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);
+
+                tx->tx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr);
+                tx->tx_resid = tx->tx_nob = offsetof(ksock_msg_t,  ksm_u.lnetmsg.ksnm_hdr);
+        }
+        /* Don't checksum before start sending, because packet can be piggybacked with ACK */
+}
+
+static void
+ksocknal_unpack_msg_v1(ksock_msg_t *msg)
+{
+        msg->ksm_csum           = 0;
+        msg->ksm_type           = KSOCK_MSG_LNET;
+        msg->ksm_zc_cookies[0]  = msg->ksm_zc_cookies[1]  = 0;
+}
+
+static void
+ksocknal_unpack_msg_v2(ksock_msg_t *msg)
+{
+        return;  /* Do nothing */
+}
+
+ksock_proto_t  ksocknal_protocol_v1x =
+{
+        .pro_version            = KSOCK_PROTO_V1,
+        .pro_send_hello         = ksocknal_send_hello_v1,
+        .pro_recv_hello         = ksocknal_recv_hello_v1,
+        .pro_pack               = ksocknal_pack_msg_v1,
+        .pro_unpack             = ksocknal_unpack_msg_v1,
+        .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v1,
+        .pro_handle_zcreq       = NULL,
+        .pro_handle_zcack       = NULL,
+        .pro_queue_tx_zcack     = NULL,
+        .pro_match_tx           = ksocknal_match_tx
+};
+
+ksock_proto_t  ksocknal_protocol_v2x =
+{
+        .pro_version            = KSOCK_PROTO_V2,
+        .pro_send_hello         = ksocknal_send_hello_v2,
+        .pro_recv_hello         = ksocknal_recv_hello_v2,
+        .pro_pack               = ksocknal_pack_msg_v2,
+        .pro_unpack             = ksocknal_unpack_msg_v2,
+        .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v2,
+        .pro_queue_tx_zcack     = ksocknal_queue_tx_zcack_v2,
+        .pro_handle_zcreq       = ksocknal_handle_zcreq,
+        .pro_handle_zcack       = ksocknal_handle_zcack,
+        .pro_match_tx           = ksocknal_match_tx
+};
+
+ksock_proto_t  ksocknal_protocol_v3x =
+{
+        .pro_version            = KSOCK_PROTO_V3,
+        .pro_send_hello         = ksocknal_send_hello_v2,
+        .pro_recv_hello         = ksocknal_recv_hello_v2,
+        .pro_pack               = ksocknal_pack_msg_v2,
+        .pro_unpack             = ksocknal_unpack_msg_v2,
+        .pro_queue_tx_msg       = ksocknal_queue_tx_msg_v2,
+        .pro_queue_tx_zcack     = ksocknal_queue_tx_zcack_v3,
+        .pro_handle_zcreq       = ksocknal_handle_zcreq,
+        .pro_handle_zcack       = ksocknal_handle_zcack,
+        .pro_match_tx           = ksocknal_match_tx_v3
+};
+
diff --git a/lnet/klnds/viblnd/Makefile.in b/lnet/klnds/viblnd/Makefile.in
index 5b5c2db..a9bedaa 100644
--- a/lnet/klnds/viblnd/Makefile.in
+++ b/lnet/klnds/viblnd/Makefile.in
@@ -1,6 +1,7 @@
 MODULES := kviblnd
 kviblnd-objs := viblnd.o viblnd_cb.o viblnd_modparams.o
 
+EXTRA_DIST = $(kviblnd-objs:%.o=%.c) viblnd.h viblnd_wire.h
 EXTRA_POST_CFLAGS := @VIBCPPFLAGS@
 
 @INCLUDE_RULES@
diff --git a/lnet/klnds/viblnd/autoMakefile.am b/lnet/klnds/viblnd/autoMakefile.am
index b27fc07..63a6d3d 100644
--- a/lnet/klnds/viblnd/autoMakefile.am
+++ b/lnet/klnds/viblnd/autoMakefile.am
@@ -41,4 +41,3 @@ endif
 endif
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
-DIST_SOURCES = $(kviblnd-objs:%.o=%.c) viblnd.h viblnd_wire.h
diff --git a/lnet/klnds/viblnd/autoMakefile.in b/lnet/klnds/viblnd/autoMakefile.in
index 68b6c17..d9350ec 100644
--- a/lnet/klnds/viblnd/autoMakefile.in
+++ b/lnet/klnds/viblnd/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @BUILD_VIBLND_TRUE@@MODULES_TRUE at modulenet_DATA = kviblnd$(KMODEXT)
-DIST_SOURCES = $(kviblnd-objs:%.o=%.c) viblnd.h viblnd_wire.h
 subdir = lnet/klnds/viblnd
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/libcfs/Makefile.in b/lnet/libcfs/Makefile.in
index 0940a56..eb2e674 100644
--- a/lnet/libcfs/Makefile.in
+++ b/lnet/libcfs/Makefile.in
@@ -28,6 +28,7 @@ libcfs-all-objs := debug.o nidstrings.o lwt.o module.o tracefile.o watchdog.o
 
 libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs)
 
+EXTRA_DIST := $(libcfs-all-objs:%.o=%.c) tracefile.h user-prim.c user-lock.c Info.plist
 EXTRA_PRE_CFLAGS := -I at LUSTRE@/../lnet/libcfs
 
 @INCLUDE_RULES@
diff --git a/lnet/libcfs/autoMakefile.am b/lnet/libcfs/autoMakefile.am
index bd39583..7787e26 100644
--- a/lnet/libcfs/autoMakefile.am
+++ b/lnet/libcfs/autoMakefile.am
@@ -77,8 +77,4 @@ endif
 
 install-data-hook: $(install_data_hook)
 
-EXTRA_DIST := Info.plist
-
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux-*.c linux/*.o darwin/*.o libcfs
-DIST_SOURCES := $(libcfs-all-objs:%.o=%.c) tracefile.h user-prim.c \
-                                           user-lock.c user-tcpip.c user-bitops.c
diff --git a/lnet/libcfs/autoMakefile.in b/lnet/libcfs/autoMakefile.in
index 988e489..7c1536c 100644
--- a/lnet/libcfs/autoMakefile.in
+++ b/lnet/libcfs/autoMakefile.in
@@ -212,9 +212,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ linux-*.c linux/*.o darwin/*.o libcfs
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -357,11 +357,6 @@ DIST_SUBDIRS := $(SUBDIRS)
 @DARWIN_TRUE@@MODULES_TRUE at plist_DATA := Info.plist
 
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
-
-EXTRA_DIST := Info.plist
-DIST_SOURCES := $(libcfs-all-objs:%.o=%.c) tracefile.h user-prim.c \
-                                           user-lock.c user-tcpip.c user-bitops.c
-
 subdir = lnet/libcfs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -436,6 +431,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libcfs_a_SOURCES_DIST)
 DATA = $(modulenet_DATA) $(plist_DATA)
 
 
diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c
index 1f61363..872aa2a 100644
--- a/lnet/libcfs/debug.c
+++ b/lnet/libcfs/debug.c
@@ -68,7 +68,7 @@ CFS_MODULE_PARM(libcfs_debug_mb, "i", int, 0644,
                 "Total debug buffer size.");
 EXPORT_SYMBOL(libcfs_debug_mb);
 
-unsigned int libcfs_printk = D_CANTMASK;
+unsigned int libcfs_printk = (D_CANTMASK | D_NETERROR);
 CFS_MODULE_PARM(libcfs_printk, "i", uint, 0644,
                 "Lustre kernel debug console mask");
 EXPORT_SYMBOL(libcfs_printk);
@@ -105,6 +105,9 @@ EXPORT_SYMBOL(portal_enter_debugger);
 unsigned int libcfs_catastrophe;
 EXPORT_SYMBOL(libcfs_catastrophe);
 
+unsigned int libcfs_watchdog_ratelimit = 300;
+EXPORT_SYMBOL(libcfs_watchdog_ratelimit);
+
 unsigned int libcfs_panic_on_lbug = 0;
 CFS_MODULE_PARM(libcfs_panic_on_lbug, "i", uint, 0644,
                 "Lustre kernel panic on LBUG");
@@ -123,7 +126,7 @@ char debug_file_path_arr[1024] = "/r/tmp/lustre-log";
 char debug_file_path_arr[1024] = "/tmp/lustre-log";
 #endif
 /* We need to pass a pointer here, but elsewhere this must be a const */
-static char *debug_file_path = &debug_file_path_arr[0];
+char *debug_file_path = &debug_file_path_arr[0];
 CFS_MODULE_PARM(debug_file_path, "s", charp, 0644,
                 "Path for dumping debug logs, "
                 "set 'NONE' to prevent log dumping");
@@ -524,7 +527,7 @@ int libcfs_debug_clear_buffer(void)
 int libcfs_debug_mark_buffer(const char *text)
 {
         CDEBUG(D_TRACE,"***************************************************\n");
-        CDEBUG(D_WARNING, "DEBUG MARKER: %s\n", text);
+        LCONSOLE(D_WARNING, "DEBUG MARKER: %s\n", text);
         CDEBUG(D_TRACE,"***************************************************\n");
 
         return 0;
diff --git a/lnet/libcfs/linux/Makefile.in b/lnet/libcfs/linux/Makefile.in
index 3caa1f5..035e048 100644
--- a/lnet/libcfs/linux/Makefile.in
+++ b/lnet/libcfs/linux/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/libcfs/linux/linux-debug.c b/lnet/libcfs/linux/linux-debug.c
index b5d4da3..90b0dd9 100644
--- a/lnet/libcfs/linux/linux-debug.c
+++ b/lnet/libcfs/linux/linux-debug.c
@@ -206,6 +206,48 @@ void lbug_with_loc(const char *file, const char *func, const int line)
 
 #ifdef __KERNEL__
 
+#if defined(HAVE_DUMP_TRACE) && !(defined(HAVE_SHOW_TASK))
+#include <linux/nmi.h>
+#include <asm/stacktrace.h>
+
+static void
+print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
+{
+	printk(data);
+	print_symbol(msg, symbol);
+	printk("\n");
+}
+
+static void print_trace_warning(void *data, char *msg)
+{
+	printk("%s%s\n", (char *)data, msg);
+}
+
+static int print_trace_stack(void *data, char *name)
+{
+	printk(" <%s> ", name);
+	return 0;
+}
+
+#ifdef HAVE_TRACE_ADDRESS_RELIABLE
+# define RELIABLE reliable
+# define DUMP_TRACE_CONST const
+static void print_trace_address(void *data, unsigned long addr, int reliable)
+#else
+/* before 2.6.24 there was no reliable arg */
+# define RELIABLE 1
+# define DUMP_TRACE_CONST
+static void print_trace_address(void *data, unsigned long addr)
+#endif
+{
+        char fmt[32];
+	touch_nmi_watchdog();
+        sprintf(fmt, " [<%016lx>] %s%%s\n", addr, RELIABLE ? "": "? ");
+	__print_symbol(fmt, addr);
+}
+
+#endif
+
 void libcfs_debug_dumpstack(struct task_struct *tsk)
 {
 #if defined(__arch_um__)
@@ -221,6 +263,34 @@ void libcfs_debug_dumpstack(struct task_struct *tsk)
                 tsk = current;
         CWARN("showing stack for process %d\n", tsk->pid);
         show_task(tsk);
+#elif defined(HAVE_DUMP_TRACE)
+static DUMP_TRACE_CONST struct stacktrace_ops print_trace_ops = {
+	.warning = print_trace_warning,
+	.warning_symbol = print_trace_warning_symbol,
+	.stack = print_trace_stack,
+	.address = print_trace_address,
+};
+        if (tsk == NULL)
+                tsk = current;
+        /* dump_stack() */
+        /* show_trace() */
+	printk("Pid: %d, comm: %.20s\n", tsk->pid, tsk->comm);
+        /* show_trace_log_lvl() */
+	printk("\nCall Trace:\n");
+	dump_trace(tsk, NULL, NULL,
+#ifdef HAVE_TRACE_ADDRESS_RELIABLE
+                   0,
+#endif /* HAVE_TRACE_ADDRESS_RELIABLE */
+                   &print_trace_ops, NULL);
+	printk("\n");
+#elif defined(HAVE_SCHED_SHOW_TASK)
+        /* exported by lustre patch on 2.6.27 kernel */
+        extern void show_task(struct task_struct *);
+
+        if (tsk == NULL)
+                tsk = current;
+        CWARN("showing stack for process %d\n", tsk->pid);
+        sched_show_task(tsk);
 #else
         if ((tsk == NULL) || (tsk == current))
                 dump_stack();
diff --git a/lnet/libcfs/linux/linux-prim.c b/lnet/libcfs/linux/linux-prim.c
index 3f221c1..d5fef80 100644
--- a/lnet/libcfs/linux/linux-prim.c
+++ b/lnet/libcfs/linux/linux-prim.c
@@ -49,7 +49,7 @@
 void cfs_enter_debugger(void)
 {
 #if defined(CONFIG_KGDB)
-        BREAKPOINT();
+//        BREAKPOINT();
 #elif defined(__arch_um__)
         asm("int $3");
 #else
diff --git a/lnet/libcfs/linux/linux-proc.c b/lnet/libcfs/linux/linux-proc.c
index 2cecd6e..a968a6d 100644
--- a/lnet/libcfs/linux/linux-proc.c
+++ b/lnet/libcfs/linux/linux-proc.c
@@ -103,6 +103,7 @@ enum {
         PSDEV_LNET_DAEMON_FILE,   /* spool kernel debug buffer to file */
         PSDEV_LNET_DEBUG_MB,      /* size of debug buffer */
         PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */
+        PSDEV_LNET_WATCHDOG_RATELIMIT,  /* ratelimit watchdog messages  */
 };
 #else
 #define CTL_LNET                        CTL_UNNUMBERED
@@ -123,10 +124,11 @@ enum {
 #define PSDEV_LNET_DAEMON_FILE          CTL_UNNUMBERED
 #define PSDEV_LNET_DEBUG_MB             CTL_UNNUMBERED
 #define PSDEV_LNET_DEBUG_LOG_UPCALL     CTL_UNNUMBERED
+#define PSDEV_LNET_WATCHDOG_RATELIMIT   CTL_UNNUMBERED
 #endif
 
 
-static int
+int
 proc_call_handler(void *data, int write,
                   loff_t *ppos, void *buffer, size_t *lenp,
                   int (*handler)(void *data, int write,
@@ -188,6 +190,9 @@ static int __proc_dobitmasks(void *data, int write,
 
 DECLARE_PROC_HANDLER(proc_dobitmasks)
 
+static int min_watchdog_ratelimit = 0;          /* disable ratelimiting */
+static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */
+
 static int __proc_dump_kernel(void *data, int write,
                               loff_t pos, void *buffer, int nob)
 {
@@ -454,6 +459,16 @@ static cfs_sysctl_table_t lnet_table[] = {
                 .mode     = 0644,
                 .proc_handler = &proc_debug_mb,
         },
+        {
+                .ctl_name = PSDEV_LNET_WATCHDOG_RATELIMIT,
+                .procname = "watchdog_ratelimit",
+                .data     = &libcfs_watchdog_ratelimit,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_dointvec_minmax,
+                .extra1   = &min_watchdog_ratelimit,
+                .extra2   = &max_watchdog_ratelimit,
+        },
         {0}
 };
 
diff --git a/lnet/libcfs/linux/linux-tcpip.c b/lnet/libcfs/linux/linux-tcpip.c
index bcf85b5..87d5214 100644
--- a/lnet/libcfs/linux/linux-tcpip.c
+++ b/lnet/libcfs/linux/linux-tcpip.c
@@ -63,7 +63,11 @@ libcfs_sock_ioctl(int cmd, unsigned long arg)
                 return rc;
         }
 
+#ifdef HAVE_SOCK_MAP_FD_2ARG
+        fd = sock_map_fd(sock,0);
+#else
         fd = sock_map_fd(sock);
+#endif
         if (fd < 0) {
                 rc = fd;
                 sock_release(sock);
diff --git a/lnet/libcfs/linux/linux-tracefile.c b/lnet/libcfs/linux/linux-tracefile.c
index ada5b8f..1096cf4 100644
--- a/lnet/libcfs/linux/linux-tracefile.c
+++ b/lnet/libcfs/linux/linux-tracefile.c
@@ -41,11 +41,6 @@
 #include <libcfs/kp30.h>
 #include "tracefile.h"
 
-#ifndef get_cpu
-#define get_cpu() smp_processor_id()
-#define put_cpu() do { } while (0)
-#endif
-
 /* three types of trace_data in linux */
 enum {
 	TCD_TYPE_PROC = 0,
@@ -151,7 +146,7 @@ void tracefile_write_unlock()
 char *
 trace_get_console_buffer(void)
 {
-	int  cpu = get_cpu();
+	int  cpu = cfs_get_cpu();
 	int  idx;
 
 	if (in_irq()) {
@@ -168,7 +163,7 @@ trace_get_console_buffer(void)
 void
 trace_put_console_buffer(char *buffer)
 {
-	put_cpu();
+	cfs_put_cpu();
 }
 
 struct trace_cpu_data *
@@ -177,7 +172,7 @@ trace_get_tcd(void)
 	struct trace_cpu_data *tcd;
 	int cpu;
 
-	cpu = get_cpu();
+	cpu = cfs_get_cpu();
 	if (in_irq())
 		tcd = &(*trace_data[TCD_TYPE_IRQ])[cpu].tcd;
 	else if (in_softirq())
@@ -195,7 +190,7 @@ trace_put_tcd (struct trace_cpu_data *tcd)
 {
 	trace_unlock_tcd(tcd);
 
-	put_cpu();
+	cfs_put_cpu();
 }
 
 int trace_lock_tcd(struct trace_cpu_data *tcd)
diff --git a/lnet/libcfs/nidstrings.c b/lnet/libcfs/nidstrings.c
index 796e1b9..048c23b 100644
--- a/lnet/libcfs/nidstrings.c
+++ b/lnet/libcfs/nidstrings.c
@@ -415,7 +415,7 @@ libcfs_nid2str(lnet_nid_t nid)
 static struct netstrfns *
 libcfs_str2net_internal(const char *str, __u32 *net)
 {
-        struct netstrfns *nf;
+        struct netstrfns *nf = NULL;
         int               nob;
         int               netnum;
         int               i;
diff --git a/lnet/libcfs/tracefile.c b/lnet/libcfs/tracefile.c
index a2697fb..a049dc0 100644
--- a/lnet/libcfs/tracefile.c
+++ b/lnet/libcfs/tracefile.c
@@ -183,15 +183,15 @@ static void tcd_shrink(struct trace_cpu_data *tcd)
         struct trace_page *tage;
         struct trace_page *tmp;
 
-	/*
-	 * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT)
-	 * from here: this will lead to infinite recursion.
-	 */
+        /*
+         * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT)
+         * from here: this will lead to infinite recursion.
+         */
 
-	if (printk_ratelimit())
+        if (printk_ratelimit())
                 printk(KERN_WARNING "debug daemon buffer overflowed; "
-		       "discarding  10%% of pages (%d of %ld)\n",
-		       pgcount + 1, tcd->tcd_cur_pages);
+                       "discarding  10%% of pages (%d of %ld)\n",
+                       pgcount + 1, tcd->tcd_cur_pages);
 
         CFS_INIT_LIST_HEAD(&pc.pc_pages);
         spin_lock_init(&pc.pc_lock);
@@ -212,10 +212,10 @@ static struct trace_page *trace_get_tage(struct trace_cpu_data *tcd,
 {
         struct trace_page *tage;
 
-	/*
-	 * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT)
-	 * from here: this will lead to infinite recursion.
-	 */
+        /*
+         * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT)
+         * from here: this will lead to infinite recursion.
+         */
 
         if (len > CFS_PAGE_SIZE) {
                 printk(KERN_ERR
@@ -239,7 +239,7 @@ static struct trace_page *trace_get_tage(struct trace_cpu_data *tcd,
 int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
                        const char *file, const char *fn, const int line,
                        const char *format1, va_list args,
-                       const char *format2, ...)		
+                       const char *format2, ...)
 {
         struct trace_cpu_data   *tcd = NULL;
         struct ptldebug_header   header;
@@ -312,26 +312,26 @@ int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, int subsys, int mask,
                         needed = vsnprintf(string_buf, max_nob, format1, ap);
                         va_end(ap);
                 }
-		
 
                 if (format2) {
-		        remain = max_nob - needed;
+                        remain = max_nob - needed;
                         if (remain < 0)
                                 remain = 0;
-		
+
                         va_start(ap, format2);
-                        needed += vsnprintf(string_buf+needed, remain, format2, ap);
+                        needed += vsnprintf(string_buf + needed, remain,
+                                            format2, ap);
                         va_end(ap);
                 }
 
                 if (needed < max_nob) /* well. printing ok.. */
                         break;
         }
-	
+
         if (*(string_buf+needed-1) != '\n')
                 printk(KERN_INFO "format at %s:%d:%s doesn't end in newline\n",
                        file, line, fn);
-	
+
         header.ph_len = known_size + needed;
         debug_buf = (char *)cfs_page_address(tage->page) + tage->used;
 
@@ -776,6 +776,7 @@ int trace_copyout_string(char *usr_buffer, int usr_buffer_nob,
 
         return nob;
 }
+EXPORT_SYMBOL(trace_copyout_string);
 
 int trace_allocate_string_buffer(char **str, int nob)
 {
@@ -824,22 +825,22 @@ int trace_daemon_command(char *str)
 {
         int       rc = 0;
 
-	tracefile_write_lock();
+        tracefile_write_lock();
 
-	if (strcmp(str, "stop") == 0) {
+        if (strcmp(str, "stop") == 0) {
                 tracefile_write_unlock();
-		trace_stop_thread();
+                trace_stop_thread();
                 tracefile_write_lock();
                 memset(tracefile, 0, sizeof(tracefile));
 
-	} else if (strncmp(str, "size=", 5) == 0) {
-		tracefile_size = simple_strtoul(str + 5, NULL, 0);
-		if (tracefile_size < 10 || tracefile_size > 20480)
-			tracefile_size = TRACEFILE_SIZE;
-		else
-			tracefile_size <<= 20;
+        } else if (strncmp(str, "size=", 5) == 0) {
+                tracefile_size = simple_strtoul(str + 5, NULL, 0);
+                if (tracefile_size < 10 || tracefile_size > 20480)
+                        tracefile_size = TRACEFILE_SIZE;
+                else
+                        tracefile_size <<= 20;
 
-	} else if (strlen(str) >= sizeof(tracefile)) {
+        } else if (strlen(str) >= sizeof(tracefile)) {
                 rc = -ENAMETOOLONG;
 #ifndef __WINNT__
         } else if (str[0] != '/') {
@@ -855,14 +856,14 @@ int trace_daemon_command(char *str)
                 trace_start_thread();
         }
 
-	tracefile_write_unlock();
-	return rc;
+        tracefile_write_unlock();
+        return rc;
 }
 
 int trace_daemon_command_usrstr(void *usr_str, int usr_str_nob)
 {
-	char *str;
-	int   rc;
+        char *str;
+        int   rc;
 
         rc = trace_allocate_string_buffer(&str, usr_str_nob + 1);
         if (rc != 0)
@@ -874,54 +875,55 @@ int trace_daemon_command_usrstr(void *usr_str, int usr_str_nob)
                 rc = trace_daemon_command(str);
 
         trace_free_string_buffer(str, usr_str_nob + 1);
-	return rc;
+
+        return rc;
 }
 
 int trace_set_debug_mb(int mb)
 {
-	int i;
+        int i;
         int j;
         int pages;
         int limit = trace_max_debug_mb();
         struct trace_cpu_data *tcd;
 
-	if (mb < num_possible_cpus())
-		return -EINVAL;
+        if (mb < num_possible_cpus())
+                return -EINVAL;
 
-	if (mb > limit) {
-		printk(KERN_ERR "Lustre: Refusing to set debug buffer size to "
-		       "%dMB - limit is %d\n", mb, limit);
-		return -EINVAL;
-	}
+        if (mb > limit) {
+                printk(KERN_ERR "Lustre: Refusing to set debug buffer size to "
+                       "%dMB - limit is %d\n", mb, limit);
+                return -EINVAL;
+        }
 
-	mb /= num_possible_cpus();
+        mb /= num_possible_cpus();
         pages = mb << (20 - CFS_PAGE_SHIFT);
 
         tracefile_write_lock();
 
         tcd_for_each(tcd, i, j)
-		tcd->tcd_max_pages = (pages * tcd->tcd_pages_factor) / 100;
+                tcd->tcd_max_pages = (pages * tcd->tcd_pages_factor) / 100;
 
         tracefile_write_unlock();
 
-	return 0;
+        return 0;
 }
 
 int trace_set_debug_mb_usrstr(void *usr_str, int usr_str_nob)
 {
-	char     str[32];
+        char     str[32];
         int      rc;
 
         rc = trace_copyin_string(str, sizeof(str), usr_str, usr_str_nob);
         if (rc < 0)
                 return rc;
 
-	return trace_set_debug_mb(simple_strtoul(str, NULL, 0));
+        return trace_set_debug_mb(simple_strtoul(str, NULL, 0));
 }
 
 int trace_get_debug_mb(void)
 {
-	int i;
+        int i;
         int j;
         struct trace_cpu_data *tcd;
         int total_pages = 0;
@@ -944,6 +946,7 @@ static int tracefiled(void *arg)
         struct trace_page *tmp;
         struct ptldebug_header *hdr;
         cfs_file_t *filp;
+        int last_loop = 0;
         int rc;
 
         CFS_DECL_MMSPACE;
@@ -958,20 +961,10 @@ static int tracefiled(void *arg)
         while (1) {
                 cfs_waitlink_t __wait;
 
-                cfs_waitlink_init(&__wait);
-                cfs_waitq_add(&tctl->tctl_waitq, &__wait);
-                set_current_state(TASK_INTERRUPTIBLE);
-                cfs_waitq_timedwait(&__wait, CFS_TASK_INTERRUPTIBLE,
-                                    cfs_time_seconds(1));
-                cfs_waitq_del(&tctl->tctl_waitq, &__wait);
-
-                if (atomic_read(&tctl->tctl_shutdown))
-                        break;
-
                 pc.pc_want_daemon_pages = 0;
                 collect_pages(&pc);
                 if (list_empty(&pc.pc_pages))
-                        continue;
+                        goto end_loop;
 
                 filp = NULL;
                 tracefile_read_lock();
@@ -987,7 +980,7 @@ static int tracefiled(void *arg)
                 if (filp == NULL) {
                         put_pages_on_daemon_list(&pc);
                         __LASSERT(list_empty(&pc.pc_pages));
-                        continue;
+                        goto end_loop;
                 }
 
                 CFS_MMSPACE_OPEN;
@@ -1042,6 +1035,21 @@ static int tracefiled(void *arg)
                         printk(KERN_ALERT "There are %d pages unwritten\n", i);
                 }
                 __LASSERT(list_empty(&pc.pc_pages));
+end_loop:
+                if (atomic_read(&tctl->tctl_shutdown)) {
+                        if (last_loop == 0) {
+                                last_loop = 1;
+                                continue;
+                        } else {
+                                break;
+                        }
+                }
+                cfs_waitlink_init(&__wait);
+                cfs_waitq_add(&tctl->tctl_waitq, &__wait);
+                set_current_state(TASK_INTERRUPTIBLE);
+                cfs_waitq_timedwait(&__wait, CFS_TASK_INTERRUPTIBLE,
+                                    cfs_time_seconds(1));
+                cfs_waitq_del(&tctl->tctl_waitq, &__wait);
         }
         complete(&tctl->tctl_stop);
         return 0;
diff --git a/lnet/libcfs/watchdog.c b/lnet/libcfs/watchdog.c
index 78c1f9e..19eb915 100644
--- a/lnet/libcfs/watchdog.c
+++ b/lnet/libcfs/watchdog.c
@@ -47,14 +47,13 @@
 struct lc_watchdog {
         cfs_timer_t       lcw_timer; /* kernel timer */
         struct list_head  lcw_list;
-        struct timeval    lcw_last_touched;
+        cfs_time_t        lcw_last_touched;
         cfs_task_t       *lcw_task;
 
         void            (*lcw_callback)(pid_t, void *);
         void             *lcw_data;
 
         pid_t             lcw_pid;
-        cfs_duration_t    lcw_time; /* time until watchdog fires, jiffies */
 
         enum {
                 LC_WATCHDOG_DISABLED,
@@ -97,40 +96,46 @@ static spinlock_t lcw_pending_timers_lock = SPIN_LOCK_UNLOCKED; /* BH lock! */
 static struct list_head lcw_pending_timers = \
         LIST_HEAD_INIT(lcw_pending_timers);
 
-#ifdef HAVE_TASKLIST_LOCK
+/* Last time a watchdog expired */
+static cfs_time_t lcw_last_watchdog_time;
+static int lcw_recent_watchdog_count;
+static spinlock_t lcw_last_watchdog_lock = SPIN_LOCK_UNLOCKED;
+
 static void
 lcw_dump(struct lc_watchdog *lcw)
 {
-        cfs_task_t *tsk;
         ENTRY;
 
+#if defined(HAVE_TASKLIST_LOCK)
         read_lock(&tasklist_lock);
-        tsk = find_task_by_pid(lcw->lcw_pid);
-
-        if (tsk == NULL) {
+#elif defined(HAVE_TASK_RCU)
+        rcu_read_lock();
+#else
+        CERROR("unable to dump stack because of missing export\n"); 
+        RETURN_EXIT;
+#endif
+        if (lcw->lcw_task == NULL) {
                 CWARN("Process %d was not found in the task list; "
-                      "watchdog callback may be incomplete\n", (int)lcw->lcw_pid);
-        } else if (tsk != lcw->lcw_task) {
-                CWARN("The current process %d did not set the watchdog; "
-                      "watchdog callback may be incomplete\n", (int)lcw->lcw_pid);
+                      "watchdog callback may be incomplete\n",
+                      (int)lcw->lcw_pid);
         } else {
-                libcfs_debug_dumpstack(tsk);
+                libcfs_debug_dumpstack(lcw->lcw_task);
         }
-        
+
+#if defined(HAVE_TASKLIST_LOCK)
         read_unlock(&tasklist_lock);
+#elif defined(HAVE_TASK_RCU)
+        rcu_read_unlock();
+#endif
         EXIT;
 }
-#else
-static void
-lcw_dump(struct lc_watchdog *lcw)
-{
-        CERROR("unable to dump stack because of missing export\n");
-}
-#endif
 
 static void lcw_cb(unsigned long data)
 {
         struct lc_watchdog *lcw = (struct lc_watchdog *)data;
+        cfs_time_t current_time;
+        cfs_duration_t delta_time;
+        struct timeval timediff;
 
         ENTRY;
 
@@ -140,14 +145,44 @@ static void lcw_cb(unsigned long data)
         }
 
         lcw->lcw_state = LC_WATCHDOG_EXPIRED;
+        current_time = cfs_time_current();
+
+        delta_time = cfs_time_sub(current_time, lcw->lcw_last_touched);
+        cfs_duration_usec(delta_time, &timediff);
+
+        /* Check to see if we should throttle the watchdog timer to avoid
+         * too many dumps going to the console thus triggering an NMI.
+         * Normally we would not hold the spin lock over the CWARN but in
+         * this case we hold it to ensure non ratelimited lcw_dumps are not
+         * interleaved on the console making them hard to read. */
+        spin_lock_bh(&lcw_last_watchdog_lock);
+        delta_time = cfs_duration_sec(cfs_time_sub(current_time,
+                                                   lcw_last_watchdog_time));
+
+        if (delta_time < libcfs_watchdog_ratelimit &&
+            lcw_recent_watchdog_count > 3) {
+                CWARN("Refusing to fire watchdog for pid %d: it was inactive "
+                      "for %lu.%.02lus. Rate limiting 1 per %d seconds.\n",
+                      (int)lcw->lcw_pid, timediff.tv_sec,
+                      timediff.tv_usec / 10000, libcfs_watchdog_ratelimit);
+        } else {
+                if (delta_time < libcfs_watchdog_ratelimit) {
+                        lcw_recent_watchdog_count++;
+                } else {
+                        memcpy(&lcw_last_watchdog_time, &current_time,
+                               sizeof(current_time));
+                        lcw_recent_watchdog_count = 0;
+                }
 
-        /* NB this warning should appear on the console, but may not get into
-         * the logs since we're running in a softirq handler */
-
-        CWARN("Watchdog triggered for pid %d: it was inactive for %lds\n",
-              (int)lcw->lcw_pid, cfs_duration_sec(lcw->lcw_time));
-        lcw_dump(lcw);
+		/* This warning should appear on the console, but may not get
+		 * into the logs since we're running in a softirq handler */
+                CWARN("Watchdog triggered for pid %d: it was inactive for "
+                      "%lu.%.02lus\n", (int)lcw->lcw_pid, timediff.tv_sec,
+                      timediff.tv_usec / 10000);
+                lcw_dump(lcw);
+	}
 
+        spin_unlock_bh(&lcw_last_watchdog_lock);
         spin_lock_bh(&lcw_pending_timers_lock);
 
         if (list_empty(&lcw->lcw_list)) {
@@ -215,9 +250,8 @@ static int lcw_dispatch_main(void *data)
                         list_del_init(&lcw->lcw_list);
                         spin_unlock_bh(&lcw_pending_timers_lock);
 
-                        CDEBUG(D_INFO, "found lcw for pid %d: inactive for "
-                               "%lds\n", (int)lcw->lcw_pid,
-                               cfs_duration_sec(lcw->lcw_time));
+                        CDEBUG(D_INFO, "found lcw for pid %d\n",
+                               (int)lcw->lcw_pid);
 
                         if (lcw->lcw_state != LC_WATCHDOG_DISABLED)
                                 lcw->lcw_callback(lcw->lcw_pid, lcw->lcw_data);
@@ -273,7 +307,7 @@ static void lcw_dispatch_stop(void)
         EXIT;
 }
 
-struct lc_watchdog *lc_watchdog_add(int timeout_ms,
+struct lc_watchdog *lc_watchdog_add(int timeout,
                                     void (*callback)(pid_t, void *),
                                     void *data)
 {
@@ -288,7 +322,6 @@ struct lc_watchdog *lc_watchdog_add(int timeout_ms,
 
         lcw->lcw_task     = cfs_current();
         lcw->lcw_pid      = cfs_curproc_pid();
-        lcw->lcw_time     = cfs_time_seconds(timeout_ms) / 1000;
         lcw->lcw_callback = (callback != NULL) ? callback : lc_watchdog_dumplog;
         lcw->lcw_data     = data;
         lcw->lcw_state    = LC_WATCHDOG_DISABLED;
@@ -297,7 +330,7 @@ struct lc_watchdog *lc_watchdog_add(int timeout_ms,
 
         lcw->lcw_timer.function = lcw_cb;
         lcw->lcw_timer.data = (unsigned long)lcw;
-        lcw->lcw_timer.expires = jiffies + lcw->lcw_time;
+        lcw->lcw_timer.expires = jiffies + cfs_time_seconds(timeout);
         init_timer(&lcw->lcw_timer);
 
         down(&lcw_refcount_sem);
@@ -307,7 +340,7 @@ struct lc_watchdog *lc_watchdog_add(int timeout_ms,
 
         /* Keep this working in case we enable them by default */
         if (lcw->lcw_state == LC_WATCHDOG_ENABLED) {
-                do_gettimeofday(&lcw->lcw_last_touched);
+                lcw->lcw_last_touched = cfs_time_current();
                 add_timer(&lcw->lcw_timer);
         }
 
@@ -317,22 +350,22 @@ EXPORT_SYMBOL(lc_watchdog_add);
 
 static void lcw_update_time(struct lc_watchdog *lcw, const char *message)
 {
-        struct timeval newtime;
-        struct timeval timediff;
+        cfs_time_t newtime = cfs_time_current();;
 
-        do_gettimeofday(&newtime);
         if (lcw->lcw_state == LC_WATCHDOG_EXPIRED) {
-                cfs_timeval_sub(&newtime, &lcw->lcw_last_touched, &timediff);
-                CWARN("Expired watchdog for pid %d %s after %lu.%.4lus\n",
-                      lcw->lcw_pid,
-                      message,
-                      timediff.tv_sec,
-                      timediff.tv_usec / 100);
+                struct timeval timediff;
+                cfs_time_t delta_time = cfs_time_sub(newtime,
+                                                     lcw->lcw_last_touched);
+                cfs_duration_usec(delta_time, &timediff);
+
+                CWARN("Expired watchdog for pid %d %s after %lu.%.02lus\n",
+                      lcw->lcw_pid, message, timediff.tv_sec,
+                      timediff.tv_usec / 10000);
         }
         lcw->lcw_last_touched = newtime;
 }
 
-void lc_watchdog_touch_ms(struct lc_watchdog *lcw, int timeout_ms)
+void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout)
 {
         ENTRY;
         LASSERT(lcw != NULL);
@@ -344,18 +377,10 @@ void lc_watchdog_touch_ms(struct lc_watchdog *lcw, int timeout_ms)
         lcw_update_time(lcw, "touched");
         lcw->lcw_state = LC_WATCHDOG_ENABLED;
 
-        mod_timer(&lcw->lcw_timer, jiffies +
-                  cfs_time_seconds(timeout_ms) / 1000);
+        mod_timer(&lcw->lcw_timer, jiffies + cfs_time_seconds(timeout));
 
         EXIT;
 }
-EXPORT_SYMBOL(lc_watchdog_touch_ms);
-
-/* deprecated - use above instead */
-void lc_watchdog_touch(struct lc_watchdog *lcw)
-{
-        lc_watchdog_touch_ms(lcw, cfs_duration_sec(lcw->lcw_time) * 1000);
-}
 EXPORT_SYMBOL(lc_watchdog_touch);
 
 void lc_watchdog_disable(struct lc_watchdog *lcw)
@@ -412,7 +437,7 @@ EXPORT_SYMBOL(lc_watchdog_dumplog);
 
 #else   /* !defined(WITH_WATCHDOG) */
 
-struct lc_watchdog *lc_watchdog_add(int timeout_ms,
+struct lc_watchdog *lc_watchdog_add(int timeout,
                                     void (*callback)(pid_t pid, void *),
                                     void *data)
 {
@@ -421,12 +446,7 @@ struct lc_watchdog *lc_watchdog_add(int timeout_ms,
 }
 EXPORT_SYMBOL(lc_watchdog_add);
 
-void lc_watchdog_touch_ms(struct lc_watchdog *lcw, int timeout_ms)
-{
-}
-EXPORT_SYMBOL(lc_watchdog_touch_ms);
-
-void lc_watchdog_touch(struct lc_watchdog *lcw)
+void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout)
 {
 }
 EXPORT_SYMBOL(lc_watchdog_touch);
diff --git a/lnet/lnet/Makefile.in b/lnet/lnet/Makefile.in
index 3bc86f6..5ee6084 100644
--- a/lnet/lnet/Makefile.in
+++ b/lnet/lnet/Makefile.in
@@ -7,4 +7,6 @@ lnet-objs += router.o router_proc.o acceptor.o peer.o
 
 default: all
 
+EXTRA_DIST = $(lnet-objs:%.o=%.c)
+
 @INCLUDE_RULES@
diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c
index 8918fea..9e56b87 100644
--- a/lnet/lnet/api-ni.c
+++ b/lnet/lnet/api-ni.c
@@ -100,13 +100,13 @@ lnet_get_portals_compatibility(void)
         }
 
         if (!strcmp(portals_compatibility, "weak")) {
-                return 1;
                 LCONSOLE_WARN("Starting in weak portals-compatible mode\n");
+                return 1;
         }
 
         if (!strcmp(portals_compatibility, "strong")) {
-                return 2;
                 LCONSOLE_WARN("Starting in strong portals-compatible mode\n");
+                return 2;
         }
 
         LCONSOLE_ERROR_MSG(0x102, "portals_compatibility=\"%s\" not supported\n",
@@ -1032,7 +1032,7 @@ lnet_startup_lndnis (void)
 #ifdef __KERNEL__
                 if (lnd == NULL) {
                         LNET_MUTEX_UP(&the_lnet.ln_lnd_mutex);
-                        rc = request_module(libcfs_lnd2modname(lnd_type));
+                        rc = request_module("%s", libcfs_lnd2modname(lnd_type));
                         LNET_MUTEX_DOWN(&the_lnet.ln_lnd_mutex);
 
                         lnd = lnet_find_lnd_by_type(lnd_type);
@@ -1080,6 +1080,8 @@ lnet_startup_lndnis (void)
                         goto failed;
                 }
 
+                LASSERT (ni->ni_peertimeout <= 0 || lnd->lnd_query != NULL);
+
                 list_del(&ni->ni_list);
 
                 LNET_LOCK();
@@ -1119,9 +1121,10 @@ lnet_startup_lndnis (void)
 
                 ni->ni_txcredits = ni->ni_mintxcredits = ni->ni_maxtxcredits;
 
-                CDEBUG(D_LNI, "Added LNI %s [%d/%d]\n",
+                CDEBUG(D_LNI, "Added LNI %s [%d/%d/%d/%d]\n",
                        libcfs_nid2str(ni->ni_nid),
-                       ni->ni_peertxcredits, ni->ni_txcredits);
+                       ni->ni_peertxcredits, ni->ni_txcredits,
+                       ni->ni_peerrtrcredits, ni->ni_peertimeout);
 
                 /* Handle nidstrings for network 0 just like this one */
                 if (the_lnet.ln_ptlcompat > 0) {
diff --git a/lnet/lnet/autoMakefile.am b/lnet/lnet/autoMakefile.am
index 9ce40fe..57e4e65 100644
--- a/lnet/lnet/autoMakefile.am
+++ b/lnet/lnet/autoMakefile.am
@@ -43,4 +43,3 @@ install-data-hook: $(install_data_hook)
 EXTRA_DIST := Info.plist
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ lnet
-DIST_SOURCES = $(lnet-objs:%.o=%.c)
diff --git a/lnet/lnet/autoMakefile.in b/lnet/lnet/autoMakefile.in
index e1a4b61..3fa14d2 100644
--- a/lnet/lnet/autoMakefile.in
+++ b/lnet/lnet/autoMakefile.in
@@ -175,9 +175,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ lnet
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -319,7 +319,6 @@ my_sources = api-errno.c api-ni.c config.c \
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
 
 EXTRA_DIST := Info.plist
-DIST_SOURCES = $(lnet-objs:%.o=%.c)
 subdir = lnet/lnet
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -402,6 +401,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__liblnet_a_SOURCES_DIST) $(am__lnet_SOURCES_DIST)
 DATA = $(modulenet_DATA) $(plist_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/lnet/lib-md.c b/lnet/lnet/lib-md.c
index 39fa978..be16ba6 100644
--- a/lnet/lnet/lib-md.c
+++ b/lnet/lnet/lib-md.c
@@ -244,6 +244,8 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
         } else {
                 rc = lib_md_build(md, &umd, unlink);
                 if (rc == 0) {
+                        the_lnet.ln_portals[me->me_portal].ptl_ml_version++;
+
                         me->me_md = md;
                         md->md_me = me;
 
diff --git a/lnet/lnet/lib-move.c b/lnet/lnet/lib-move.c
index 26fccb4..a835a2e 100644
--- a/lnet/lnet/lib-move.c
+++ b/lnet/lnet/lib-move.c
@@ -898,12 +898,104 @@ lnet_eager_recv_locked(lnet_msg_t *msg)
         return rc;
 }
 
+/* NB: caller shall hold a ref on 'lp' as I'd drop LNET_LOCK */
+void
+lnet_ni_peer_alive(lnet_peer_t *lp)
+{
+        time_t      last_alive = 0;
+        lnet_ni_t  *ni = lp->lp_ni;
+
+        LASSERT (ni != NULL);
+        LASSERT (ni->ni_peertimeout > 0);
+        LASSERT (ni->ni_lnd->lnd_query != NULL);
+
+        LNET_UNLOCK();
+        (ni->ni_lnd->lnd_query)(ni, lp->lp_nid, &last_alive);
+        LNET_LOCK();
+
+        lp->lp_last_query = cfs_time_current_sec();
+
+        if (last_alive != 0) /* NI has updated timestamp */
+                lp->lp_last_alive = last_alive;
+        return;
+}
+
+/* NB: always called with LNET_LOCK held */
+static inline int
+lnet_peer_is_alive (lnet_peer_t *lp, time_t now)
+{
+        lnet_ni_t  *ni = lp->lp_ni;
+        time_t      deadline;
+        int         alive;
+
+        LASSERT (ni != NULL);
+        LASSERT (ni->ni_peertimeout > 0);
+
+        if (!lp->lp_alive && lp->lp_alive_count > 0 &&
+            cfs_time_aftereq(lp->lp_timestamp, lp->lp_last_alive))
+                        return 0;
+
+        deadline = cfs_time_add(lp->lp_last_alive, ni->ni_peertimeout);
+        alive = cfs_time_after(deadline, now);
+        if (alive && !lp->lp_alive) /* update obsolete lp_alive */
+                lnet_notify_locked(lp, 0, 1, lp->lp_last_alive);
+
+        return alive;
+}
+
+/* don't query LND about aliveness of a dead peer more frequently than: */
+static int lnet_queryinterval = 1; /* 1 second */
+
+/* NB: returns 1 when alive, 0 when dead, negative when error;
+ *     may drop the LNET_LOCK */
+int
+lnet_peer_alive_locked (lnet_peer_t *lp)
+{
+        lnet_ni_t  *ni = lp->lp_ni;
+        time_t      now = cfs_time_current_sec();
+
+        LASSERT (ni != NULL);
+
+        if (ni->ni_peertimeout <= 0)  /* disabled */
+                return -ENODEV;
+
+        if (lnet_peer_is_alive(lp, now))
+                return 1;
+
+        /* peer appears dead, should we query right now? */
+        if (lp->lp_last_query != 0) {
+                time_t deadline =
+                        cfs_time_add(lp->lp_last_query,
+                                     lnet_queryinterval);
+
+                if (cfs_time_before(now, deadline)) {
+                        if (lp->lp_alive)
+                                CWARN("Unexpected aliveness of peer %s: "
+                                      "%d < %d (%d/%d)\n",
+                                      libcfs_nid2str(lp->lp_nid),
+                                      (int)now, (int)deadline,
+                                      lnet_queryinterval, ni->ni_peertimeout);
+                        return 0;
+                }
+        }
+
+        /* query LND for latest aliveness news */
+        lnet_ni_peer_alive(lp);
+
+        if (lnet_peer_is_alive(lp, now))
+                return 1;
+
+        lnet_notify_locked(lp, 0, 0, lp->lp_last_alive);
+        return 0;
+}
+
 int
 lnet_post_send_locked (lnet_msg_t *msg, int do_send)
 {
         /* lnet_send is going to LNET_UNLOCK immediately after this, so it sets
          * do_send FALSE and I don't do the unlock/send/lock bit.  I return
-         * EAGAIN if msg blocked and 0 if sent or OK to send */
+         * EAGAIN if msg blocked, EHOSTUNREACH if msg_txpeer appears dead, and
+         * 0 if sent or OK to send */
         lnet_peer_t *lp = msg->msg_txpeer;
         lnet_ni_t   *ni = lp->lp_ni;
 
@@ -911,6 +1003,20 @@ lnet_post_send_locked (lnet_msg_t *msg, int do_send)
         LASSERT (!do_send || msg->msg_delayed);
         LASSERT (!msg->msg_receiving);
 
+        /* NB 'lp' is always the next hop */
+        if ((msg->msg_target.pid & LNET_PID_USERFLAG) == 0 &&
+            lnet_peer_alive_locked(lp) == 0) {
+                LNET_UNLOCK();
+
+                CDEBUG(D_NETERROR, "Dropping message for %s: peer not alive\n",
+                       libcfs_id2str(msg->msg_target));
+                if (do_send)
+                        lnet_finalize(ni, msg, -EHOSTUNREACH);
+
+                LNET_LOCK();
+                return EHOSTUNREACH;
+        }
+
         if (!msg->msg_peertxcredit) {
                 LASSERT ((lp->lp_txcredits < 0) == !list_empty(&lp->lp_txq));
 
@@ -992,7 +1098,7 @@ lnet_post_routed_recv_locked (lnet_msg_t *msg, int do_recv)
 {
         /* lnet_parse is going to LNET_UNLOCK immediately after this, so it
          * sets do_recv FALSE and I don't do the unlock/send/lock bit.  I
-         * return EAGAIN if msg blocked and 0 if sent or OK to send */
+         * return EAGAIN if msg blocked and 0 if received or OK to receive */
         lnet_peer_t         *lp = msg->msg_rxpeer;
         lnet_rtrbufpool_t   *rbp;
         lnet_rtrbuf_t       *rb;
@@ -1329,6 +1435,9 @@ lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg)
         rc = lnet_post_send_locked(msg, 0);
         LNET_UNLOCK();
 
+        if (rc == EHOSTUNREACH)
+                return -EHOSTUNREACH;
+
         if (rc == 0)
                 lnet_ni_send(src_ni, msg);
 
@@ -1604,6 +1713,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
 {
         int               rc;
         int               index;
+        __u64             version;
         lnet_hdr_t       *hdr = &msg->msg_hdr;
         unsigned int      rlength = hdr->payload_length;
         unsigned int      mlength = 0;
@@ -1611,6 +1721,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
         lnet_process_id_t src = {/* .nid = */ hdr->src_nid,
                                  /* .pid = */ hdr->src_pid};
         lnet_libmd_t     *md;
+        lnet_portal_t    *ptl;
 
         /* Convert put fields to host byte order */
         hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits);
@@ -1618,9 +1729,11 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
         hdr->msg.put.offset = le32_to_cpu(hdr->msg.put.offset);
 
         index = hdr->msg.put.ptl_index;
+        ptl = &the_lnet.ln_portals[index];
 
         LNET_LOCK();
 
+ again:
         rc = lnet_match_md(index, LNET_MD_OP_PUT, src,
                            rlength, hdr->msg.put.offset,
                            hdr->msg.put.match_bits, msg,
@@ -1631,24 +1744,31 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
 
         case LNET_MATCHMD_OK:
                 LNET_UNLOCK();
-                lnet_recv_put(md, msg, 0, offset, mlength);
+                lnet_recv_put(md, msg, msg->msg_delayed, offset, mlength);
                 return 0;
 
         case LNET_MATCHMD_NONE:
-                rc = lnet_eager_recv_locked(msg);
-                if (rc == 0 && !the_lnet.ln_shutdown) {
-                        list_add_tail(&msg->msg_list,
-                                      &the_lnet.ln_portals[index].ptl_msgq);
+                version = ptl->ptl_ml_version;
 
-                        the_lnet.ln_portals[index].ptl_msgq_version++;
+                rc = 0;
+                if (!msg->msg_delayed)
+                        rc = lnet_eager_recv_locked(msg);
+
+                if (rc == 0 &&
+                    !the_lnet.ln_shutdown &&
+                    ((ptl->ptl_options & LNET_PTL_LAZY) != 0)) {
+                        if (version != ptl->ptl_ml_version)
+                                goto again;
+
+                        list_add_tail(&msg->msg_list, &ptl->ptl_msgq);
+                        ptl->ptl_msgq_version++;
+                        LNET_UNLOCK();
 
                         CDEBUG(D_NET, "Delaying PUT from %s portal %d match "
                                LPU64" offset %d length %d: no match \n",
                                libcfs_id2str(src), index,
                                hdr->msg.put.match_bits,
                                hdr->msg.put.offset, rlength);
-
-                        LNET_UNLOCK();
                         return 0;
                 }
                 /* fall through */
@@ -1959,6 +2079,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
         int            rc = 0;
         int            for_me;
         lnet_msg_t    *msg;
+        lnet_pid_t     dest_pid;
         lnet_nid_t     dest_nid;
         lnet_nid_t     src_nid;
         __u32          payload_length;
@@ -1969,6 +2090,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
         type = le32_to_cpu(hdr->type);
         src_nid = le64_to_cpu(hdr->src_nid);
         dest_nid = le64_to_cpu(hdr->dest_nid);
+        dest_pid = le32_to_cpu(hdr->dest_pid);
         payload_length = le32_to_cpu(hdr->payload_length);
 
         for_me = lnet_ptlcompat_matchnid(ni->ni_nid, dest_nid);
@@ -2108,7 +2230,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
         LASSERT (for_me);
 #else
         if (!for_me) {
-                msg->msg_target.pid = le32_to_cpu(hdr->dest_pid);
+                msg->msg_target.pid = dest_pid;
                 msg->msg_target.nid = dest_nid;
                 msg->msg_routing = 1;
                 msg->msg_offset = 0;
@@ -2122,7 +2244,6 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
                                 goto free_drop;
                         }
                 }
-
                 lnet_commit_routedmsg(msg);
                 rc = lnet_post_routed_recv_locked(msg, 0);
                 LNET_UNLOCK();
@@ -2138,7 +2259,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
         msg->msg_hdr.src_nid = src_nid;
         msg->msg_hdr.src_pid = le32_to_cpu(msg->msg_hdr.src_pid);
         msg->msg_hdr.dest_nid = dest_nid;
-        msg->msg_hdr.dest_pid = le32_to_cpu(msg->msg_hdr.dest_pid);
+        msg->msg_hdr.dest_pid = dest_pid;
         msg->msg_hdr.payload_length = payload_length;
 
         msg->msg_ev.sender = from_nid;
diff --git a/lnet/lnet/peer.c b/lnet/lnet/peer.c
index 9e033a0..d39507b 100644
--- a/lnet/lnet/peer.c
+++ b/lnet/lnet/peer.c
@@ -180,14 +180,16 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid)
 	CFS_INIT_LIST_HEAD(&lp->lp_txq);
         CFS_INIT_LIST_HEAD(&lp->lp_rtrq);
 	
-	lp->lp_alive = !lnet_peers_start_down(); /* 1 bit!! */
         lp->lp_notify = 0;
         lp->lp_notifylnd = 0;
         lp->lp_notifying = 0;
         lp->lp_alive_count = 0;
-	lp->lp_timestamp = 0;
+        lp->lp_timestamp = 0;
+        lp->lp_alive = !lnet_peers_start_down(); /* 1 bit!! */
+        lp->lp_last_alive = cfs_time_current_sec(); /* assumes alive */
+        lp->lp_last_query = 0; /* didn't ask LND yet */
         lp->lp_ping_timestamp = 0;
-	lp->lp_nid = nid;
+        lp->lp_nid = nid;
         lp->lp_refcount = 2;                    /* 1 for caller; 1 for hash */
         lp->lp_rtr_refcount = 0;
 
@@ -219,12 +221,10 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid)
                 return the_lnet.ln_shutdown ? -ESHUTDOWN : -EHOSTUNREACH;
         }
 
-	lp->lp_txcredits = 
-                lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
-
-        /* As a first approximation; allow this peer the same number of router
-         * buffers as it is allowed outstanding sends */
-        lp->lp_rtrcredits = lp->lp_minrtrcredits = lp->lp_txcredits;
+        lp->lp_txcredits    =
+        lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
+        lp->lp_rtrcredits    =
+        lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
 
         LASSERT (!the_lnet.ln_shutdown);
         /* can't add peers after shutdown starts */
@@ -239,11 +239,12 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid)
 void
 lnet_debug_peer(lnet_nid_t nid)
 {
+        char        *aliveness = "NA";
         int          rc;
         lnet_peer_t *lp;
 
         LNET_LOCK();
-        
+
         rc = lnet_nid2peer_locked(&lp, nid);
         if (rc != 0) {
                 LNET_UNLOCK();
@@ -251,11 +252,13 @@ lnet_debug_peer(lnet_nid_t nid)
                 return;
         }
 
+        if (lnet_isrouter(lp) || lp->lp_ni->ni_peertimeout > 0)
+                aliveness = lp->lp_alive ? "up" : "down";
+
         CDEBUG(D_WARNING, "%-24s %4d %5s %5d %5d %5d %5d %5d %ld\n",
-               libcfs_nid2str(lp->lp_nid), lp->lp_refcount, 
-               !lnet_isrouter(lp) ? "~rtr" : (lp->lp_alive ? "up" : "down"),
-               lp->lp_ni->ni_peertxcredits, 
-               lp->lp_rtrcredits, lp->lp_minrtrcredits, 
+               libcfs_nid2str(lp->lp_nid), lp->lp_refcount,
+               aliveness, lp->lp_ni->ni_peertxcredits,
+               lp->lp_rtrcredits, lp->lp_minrtrcredits,
                lp->lp_txcredits, lp->lp_mintxcredits, lp->lp_txqnob);
 
         lnet_peer_decref_locked(lp);
diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c
index bc7bd71..5491a8c 100644
--- a/lnet/lnet/router.c
+++ b/lnet/lnet/router.c
@@ -39,6 +39,9 @@ CFS_MODULE_PARM(small_router_buffers, "i", int, 0444,
 static int large_router_buffers = 512;
 CFS_MODULE_PARM(large_router_buffers, "i", int, 0444,
                 "# of large messages to buffer in the router");
+static int peer_buffer_credits = 0;
+CFS_MODULE_PARM(peer_buffer_credits, "i", int, 0444,
+                "# router buffer credits per peer");
 
 static int auto_down = 1;
 CFS_MODULE_PARM(auto_down, "i", int, 0444,
@@ -66,6 +69,20 @@ lnet_peers_start_down(void)
         return check_routers_before_use;
 }
 
+int
+lnet_peer_buffer_credits(lnet_ni_t *ni)
+{
+        /* NI option overrides LNet default */
+        if (ni->ni_peerrtrcredits > 0)
+                return ni->ni_peerrtrcredits;
+        if (peer_buffer_credits > 0)
+                return peer_buffer_credits;
+
+        /* As an approximation, allow this peer the same number of router
+         * buffers as it is allowed outstanding sends */
+        return ni->ni_peertxcredits;
+}
+
 void
 lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, time_t when)
 {
@@ -184,6 +201,13 @@ lnet_notify (lnet_ni_t *ni, lnet_nid_t nid, int alive, time_t when)
                 return 0;
         }
 
+        /* We can't fully trust LND on reporting exact peer last_alive
+         * if he notifies us about dead peer. For example ksocklnd can
+         * call us with when == _time_when_the_node_was_booted_ if
+         * no connections were successfully established */
+        if (ni != NULL && !alive && when < lp->lp_last_alive)
+                when = lp->lp_last_alive;
+
         lnet_notify_locked(lp, ni == NULL, alive, when);
 
         LNET_UNLOCK();
@@ -207,6 +231,12 @@ lnet_notify (lnet_ni_t *ni, lnet_nid_t nid, int alive, time_t when)
         return -EOPNOTSUPP;
 }
 
+void
+lnet_notify_locked (lnet_peer_t *lp, int notifylnd, int alive, time_t when)
+{
+        return;
+}
+
 #endif
 
 static void
@@ -1044,6 +1074,12 @@ lnet_peers_start_down(void)
         return 0;
 }
 
+int
+lnet_peer_buffer_credits(lnet_ni_t *ni)
+{
+        return 0;
+}
+
 void
 lnet_router_checker_stop(void)
 {
diff --git a/lnet/lnet/router_proc.c b/lnet/lnet/router_proc.c
index 58733f9..82a82af 100644
--- a/lnet/lnet/router_proc.c
+++ b/lnet/lnet/router_proc.c
@@ -27,1066 +27,657 @@
 
 #if defined(__KERNEL__) && defined(LNET_ROUTER)
 
-#include <linux/seq_file.h>
-
 /* this is really lnet_proc.c */
 
-#define LNET_PROC_ROOT    "sys/lnet"
-#define LNET_PROC_STATS   LNET_PROC_ROOT"/stats"
-#define LNET_PROC_ROUTES  LNET_PROC_ROOT"/routes"
-#define LNET_PROC_ROUTERS LNET_PROC_ROOT"/routers"
-#define LNET_PROC_PEERS   LNET_PROC_ROOT"/peers"
-#define LNET_PROC_BUFFERS LNET_PROC_ROOT"/buffers"
-#define LNET_PROC_NIS     LNET_PROC_ROOT"/nis"
-
-static int
-lnet_router_proc_stats_read (char *page, char **start, off_t off,
-                             int count, int *eof, void *data)
+static cfs_sysctl_table_header_t *lnet_table_header = NULL;
+
+#ifndef HAVE_SYSCTL_UNNUMBERED
+#define CTL_LNET         (0x100)
+enum {
+        PSDEV_LNET_STATS = 100,
+        PSDEV_LNET_ROUTES,
+        PSDEV_LNET_ROUTERS,
+        PSDEV_LNET_PEERS,
+        PSDEV_LNET_BUFFERS,
+        PSDEV_LNET_NIS,
+};
+#else
+#define CTL_LNET           CTL_UNNUMBERED
+#define PSDEV_LNET_STATS   CTL_UNNUMBERED
+#define PSDEV_LNET_ROUTES  CTL_UNNUMBERED
+#define PSDEV_LNET_ROUTERS CTL_UNNUMBERED
+#define PSDEV_LNET_PEERS   CTL_UNNUMBERED
+#define PSDEV_LNET_BUFFERS CTL_UNNUMBERED
+#define PSDEV_LNET_NIS     CTL_UNNUMBERED
+#endif
+
+static int __proc_lnet_stats(void *data, int write,
+                             loff_t pos, void *buffer, int nob)
 {
-        lnet_counters_t *ctrs;
         int              rc;
+        lnet_counters_t *ctrs;
+        int              len;
+        char            *tmpstr;
+        const int        tmpsiz = 256; /* 7 %u and 4 LPU64 */
 
-        *start = page;
-        *eof = 1;
-        if (off != 0)
+        if (write) {
+                LNET_LOCK();
+                memset(&the_lnet.ln_counters, 0, sizeof(the_lnet.ln_counters));
+                LNET_UNLOCK();
                 return 0;
+        }
+
+        /* read */
 
         LIBCFS_ALLOC(ctrs, sizeof(*ctrs));
         if (ctrs == NULL)
                 return -ENOMEM;
 
+        LIBCFS_ALLOC(tmpstr, tmpsiz);
+        if (tmpstr == NULL) {
+                LIBCFS_FREE(ctrs, sizeof(*ctrs));
+                return -ENOMEM;
+        }
+
         LNET_LOCK();
         *ctrs = the_lnet.ln_counters;
         LNET_UNLOCK();
 
-        rc = sprintf(page,
-                     "%u %u %u %u %u %u %u "LPU64" "LPU64" "LPU64" "LPU64"\n",
-                     ctrs->msgs_alloc, ctrs->msgs_max,
-                     ctrs->errors,
-                     ctrs->send_count, ctrs->recv_count,
-                     ctrs->route_count, ctrs->drop_count,
-                     ctrs->send_length, ctrs->recv_length,
-                     ctrs->route_length, ctrs->drop_length);
-
+        len = snprintf(tmpstr, tmpsiz,
+                       "%u %u %u %u %u %u %u "LPU64" "LPU64" "
+                       LPU64" "LPU64,
+                       ctrs->msgs_alloc, ctrs->msgs_max,
+                       ctrs->errors,
+                       ctrs->send_count, ctrs->recv_count,
+                       ctrs->route_count, ctrs->drop_count,
+                       ctrs->send_length, ctrs->recv_length,
+                       ctrs->route_length, ctrs->drop_length);
+
+        if (pos >= min_t(int, len, strlen(tmpstr)))
+                rc = 0;
+        else
+                rc = trace_copyout_string(buffer, nob,
+                                          tmpstr + pos, "\n");
+
+        LIBCFS_FREE(tmpstr, tmpsiz);
         LIBCFS_FREE(ctrs, sizeof(*ctrs));
         return rc;
 }
 
-static int
-lnet_router_proc_stats_write(struct file *file, const char *ubuffer,
-                     unsigned long count, void *data)
+DECLARE_PROC_HANDLER(proc_lnet_stats);
+
+int LL_PROC_PROTO(proc_lnet_routes)
 {
-        LNET_LOCK();
-        memset(&the_lnet.ln_counters, 0, sizeof(the_lnet.ln_counters));
-        LNET_UNLOCK();
+        int        rc     = 0;
+        char      *tmpstr;
+        char      *s;
+        const int  tmpsiz = 256;
+        int        len;
+        int       *ver_p  = (unsigned int *)(&filp->private_data);
 
-        return (count);
-}
+        DECLARE_LL_PROC_PPOS_DECL;
 
-typedef struct {
-        __u64                lrsi_version;
-        lnet_remotenet_t    *lrsi_net;
-        lnet_route_t        *lrsi_route;
-        loff_t               lrsi_off;
-} lnet_route_seq_iterator_t;
+        LASSERT (!write);
 
-int
-lnet_route_seq_seek (lnet_route_seq_iterator_t *lrsi, loff_t off)
-{
-        struct list_head  *n;
-        struct list_head  *r;
-        int                rc;
-        loff_t             here;
-
-        if (off == 0) {
-                lrsi->lrsi_net = NULL;
-                lrsi->lrsi_route = NULL;
-                lrsi->lrsi_off = 0;
+        if (*lenp == 0)
                 return 0;
-        }
 
-        LNET_LOCK();
+        LIBCFS_ALLOC(tmpstr, tmpsiz);
+        if (tmpstr == NULL)
+                return -ENOMEM;
 
-        if (lrsi->lrsi_net != NULL &&
-            lrsi->lrsi_version != the_lnet.ln_remote_nets_version) {
-                /* tables have changed */
-                rc = -ESTALE;
-                goto out;
-        }
+        s = tmpstr; /* points to current position in tmpstr[] */
 
-        if (lrsi->lrsi_net == NULL || lrsi->lrsi_off > off) {
-                /* search from start */
-                n = the_lnet.ln_remote_nets.next;
-                r = NULL;
-                here = 1;
+        if (*ppos == 0) {
+                s += snprintf(s, tmpstr + tmpsiz - s, "Routing %s\n",
+                              the_lnet.ln_routing ? "enabled" : "disabled");
+                LASSERT (tmpstr + tmpsiz - s > 0);
+
+                s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4s %7s %s\n",
+                              "net", "hops", "state", "router");
+                LASSERT (tmpstr + tmpsiz - s > 0);
+
+                LNET_LOCK();
+                *ver_p = (unsigned int)the_lnet.ln_remote_nets_version;
+                LNET_UNLOCK();
         } else {
-                /* continue search */
-                n = &lrsi->lrsi_net->lrn_list;
-                r = &lrsi->lrsi_route->lr_list;
-                here = lrsi->lrsi_off;
-        }
+                struct list_head  *n;
+                struct list_head  *r;
+                lnet_route_t      *route = NULL;
+                lnet_remotenet_t  *rnet  = NULL;
+                int                skip  = *ppos - 1;
+
+                LNET_LOCK();
+
+                if (*ver_p != (unsigned int)the_lnet.ln_remote_nets_version) {
+                        LNET_UNLOCK();
+                        LIBCFS_FREE(tmpstr, tmpsiz);
+                        return -ESTALE;
+                }
 
-        lrsi->lrsi_version = the_lnet.ln_remote_nets_version;
-        lrsi->lrsi_off        = off;
+                n = the_lnet.ln_remote_nets.next;
 
-        while (n != &the_lnet.ln_remote_nets) {
-                lnet_remotenet_t *rnet =
-                        list_entry(n, lnet_remotenet_t, lrn_list);
+                while (n != &the_lnet.ln_remote_nets && route == NULL) {
+                        rnet = list_entry(n, lnet_remotenet_t, lrn_list);
 
-                if (r == NULL)
                         r = rnet->lrn_routes.next;
 
-                while (r != &rnet->lrn_routes) {
-                        lnet_route_t *re =
-                                list_entry(r, lnet_route_t,
-                                           lr_list);
+                        while (r != &rnet->lrn_routes) {
+                                lnet_route_t *re = list_entry(r, lnet_route_t,
+                                                              lr_list);
+                                if (skip == 0) {
+                                        route = re;
+                                        break;
+                                } else
+                                        skip--;
 
-                        if (here == off) {
-                                lrsi->lrsi_net = rnet;
-                                lrsi->lrsi_route = re;
-                                rc = 0;
-                                goto out;
+                                r = r->next;
                         }
 
-                        r = r->next;
-                        here++;
+                        n = n->next;
                 }
 
-                r = NULL;
-                n = n->next;
-        }
+                if (route != NULL) {
+                        __u32        net   = rnet->lrn_net;
+                        unsigned int hops  = rnet->lrn_hops;
+                        lnet_nid_t   nid   = route->lr_gateway->lp_nid;
+                        int          alive = route->lr_gateway->lp_alive;
 
-        lrsi->lrsi_net   = NULL;
-        lrsi->lrsi_route = NULL;
-        rc             = -ENOENT;
- out:
-        LNET_UNLOCK();
-        return rc;
-}
-
-static void *
-lnet_route_seq_start (struct seq_file *s, loff_t *pos)
-{
-        lnet_route_seq_iterator_t *lrsi;
-        int                        rc;
-
-        LIBCFS_ALLOC(lrsi, sizeof(*lrsi));
-        if (lrsi == NULL)
-                return NULL;
-
-        lrsi->lrsi_net = NULL;
-        rc = lnet_route_seq_seek(lrsi, *pos);
-        if (rc == 0)
-                return lrsi;
-
-        LIBCFS_FREE(lrsi, sizeof(*lrsi));
-        return NULL;
-}
-
-static void
-lnet_route_seq_stop (struct seq_file *s, void *iter)
-{
-        lnet_route_seq_iterator_t  *lrsi = iter;
-
-        if (lrsi != NULL)
-                LIBCFS_FREE(lrsi, sizeof(*lrsi));
-}
-
-static void *
-lnet_route_seq_next (struct seq_file *s, void *iter, loff_t *pos)
-{
-        lnet_route_seq_iterator_t *lrsi = iter;
-        int                        rc;
-        loff_t                     next = *pos + 1;
-
-        rc = lnet_route_seq_seek(lrsi, next);
-        if (rc != 0) {
-                LIBCFS_FREE(lrsi, sizeof(*lrsi));
-                return NULL;
-        }
-
-        *pos = next;
-        return lrsi;
-}
+                        s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4u %7s %s\n",
+                                      libcfs_net2str(net), hops,
+                                      alive ? "up" : "down", libcfs_nid2str(nid));
+                        LASSERT (tmpstr + tmpsiz - s > 0);
+                }
 
-static int
-lnet_route_seq_show (struct seq_file *s, void *iter)
-{
-        lnet_route_seq_iterator_t *lrsi = iter;
-        __u32                      net;
-        unsigned int               hops;
-        lnet_nid_t                 nid;
-        int                        alive;
-
-        if (lrsi->lrsi_off == 0) {
-                seq_printf(s, "Routing %s\n",
-                           the_lnet.ln_routing ? "enabled" : "disabled");
-                seq_printf(s, "%-8s %4s %7s %s\n",
-                           "net", "hops", "state", "router");
-                return 0;
+                LNET_UNLOCK();
         }
 
-        LASSERT (lrsi->lrsi_net != NULL);
-        LASSERT (lrsi->lrsi_route != NULL);
+        len = s - tmpstr;     /* how many bytes was written */
 
-        LNET_LOCK();
-
-        if (lrsi->lrsi_version != the_lnet.ln_remote_nets_version) {
-                LNET_UNLOCK();
-                return -ESTALE;
+        if (len > *lenp) {    /* linux-supplied buffer is too small */
+                rc = -EINVAL;
+        } else if (len > 0) { /* wrote something */
+                if (copy_to_user(buffer, tmpstr, len))
+                        rc = -EFAULT;
+                else
+                        *ppos += 1;
         }
 
-        net   = lrsi->lrsi_net->lrn_net;
-        hops  = lrsi->lrsi_net->lrn_hops;
-        nid   = lrsi->lrsi_route->lr_gateway->lp_nid;
-        alive = lrsi->lrsi_route->lr_gateway->lp_alive;
+        LIBCFS_FREE(tmpstr, tmpsiz);
 
-        LNET_UNLOCK();
+        if (rc == 0)
+                *lenp = len;
 
-        seq_printf(s, "%-8s %4u %7s %s\n", libcfs_net2str(net), hops,
-                   alive ? "up" : "down", libcfs_nid2str(nid));
-        return 0;
+        return rc;
 }
 
-static struct seq_operations lnet_routes_sops = {
-        .start = lnet_route_seq_start,
-        .stop  = lnet_route_seq_stop,
-        .next  = lnet_route_seq_next,
-        .show  = lnet_route_seq_show,
-};
-
-static int
-lnet_route_seq_open(struct inode *inode, struct file *file)
+int LL_PROC_PROTO(proc_lnet_routers)
 {
-        struct proc_dir_entry *dp = PDE(inode);
-        struct seq_file       *sf;
-        int                    rc;
-
-        rc = seq_open(file, &lnet_routes_sops);
-        if (rc == 0) {
-                sf = file->private_data;
-                sf->private = dp->data;
-        }
-
-        return rc;
-}
+        int        rc = 0;
+        char      *tmpstr;
+        char      *s;
+        const int  tmpsiz = 256;
+        int        len;
+        int       *ver_p = (unsigned int *)(&filp->private_data);
 
-static struct file_operations lnet_routes_fops = {
-        .owner   = THIS_MODULE,
-        .open    = lnet_route_seq_open,
-        .read    = seq_read,
-        .llseek  = seq_lseek,
-        .release = seq_release,
-};
+        DECLARE_LL_PROC_PPOS_DECL;
 
-typedef struct {
-        __u64                lrtrsi_version;
-        lnet_peer_t         *lrtrsi_router;
-        loff_t               lrtrsi_off;
-} lnet_router_seq_iterator_t;
+        LASSERT (!write);
 
-int
-lnet_router_seq_seek (lnet_router_seq_iterator_t *lrtrsi, loff_t off)
-{
-        struct list_head  *r;
-        lnet_peer_t       *lp;
-        int                rc;
-        loff_t             here;
-
-        if (off == 0) {
-                lrtrsi->lrtrsi_router = NULL;
-                lrtrsi->lrtrsi_off = 0;
+        if (*lenp == 0)
                 return 0;
-        }
 
-        LNET_LOCK();
+        LIBCFS_ALLOC(tmpstr, tmpsiz);
+        if (tmpstr == NULL)
+                return -ENOMEM;
 
-        lp = lrtrsi->lrtrsi_router;
+        s = tmpstr; /* points to current position in tmpstr[] */
 
-        if (lp != NULL &&
-            lrtrsi->lrtrsi_version != the_lnet.ln_routers_version) {
-                /* tables have changed */
-                rc = -ESTALE;
-                goto out;
-        }
+        if (*ppos == 0) {
+                s += snprintf(s, tmpstr + tmpsiz - s,
+                              "%-4s %7s %9s %6s %12s %s\n",
+                              "ref", "rtr_ref", "alive_cnt", "state",
+                              "last_ping", "router");
+                LASSERT (tmpstr + tmpsiz - s > 0);
 
-        if (lp == NULL || lrtrsi->lrtrsi_off > off) {
-                /* search from start */
-                r = the_lnet.ln_routers.next;
-                here = 1;
+                LNET_LOCK();
+                *ver_p = (unsigned int)the_lnet.ln_routers_version;
+                LNET_UNLOCK();
         } else {
-                /* continue search */
-                r = &lp->lp_rtr_list;
-                here = lrtrsi->lrtrsi_off;
-        }
+                struct list_head  *r;
+                lnet_peer_t       *peer = NULL;
+                int                skip = *ppos - 1;
 
-        lrtrsi->lrtrsi_version = the_lnet.ln_routers_version;
-        lrtrsi->lrtrsi_off     = off;
+                LNET_LOCK();
 
-        while (r != &the_lnet.ln_routers) {
-                lnet_peer_t *rtr = list_entry(r, 
-                                              lnet_peer_t,
-                                              lp_rtr_list);
-
-                if (here == off) {
-                        lrtrsi->lrtrsi_router = rtr;
-                        rc = 0;
-                        goto out;
+                if (*ver_p != (unsigned int)the_lnet.ln_routers_version) {
+                        LNET_UNLOCK();
+                        LIBCFS_FREE(tmpstr, tmpsiz);
+                        return -ESTALE;
                 }
 
-                r = r->next;
-                here++;
-        }
-
-        lrtrsi->lrtrsi_router = NULL;
-        rc = -ENOENT;
- out:
-        LNET_UNLOCK();
-        return rc;
-}
-
-static void *
-lnet_router_seq_start (struct seq_file *s, loff_t *pos)
-{
-        lnet_router_seq_iterator_t *lrtrsi;
-        int                        rc;
-
-        LIBCFS_ALLOC(lrtrsi, sizeof(*lrtrsi));
-        if (lrtrsi == NULL)
-                return NULL;
-
-        lrtrsi->lrtrsi_router = NULL;
-        rc = lnet_router_seq_seek(lrtrsi, *pos);
-        if (rc == 0)
-                return lrtrsi;
-
-        LIBCFS_FREE(lrtrsi, sizeof(*lrtrsi));
-        return NULL;
-}
-
-static void
-lnet_router_seq_stop (struct seq_file *s, void *iter)
-{
-        lnet_router_seq_iterator_t  *lrtrsi = iter;
-
-        if (lrtrsi != NULL)
-                LIBCFS_FREE(lrtrsi, sizeof(*lrtrsi));
-}
-
-static void *
-lnet_router_seq_next (struct seq_file *s, void *iter, loff_t *pos)
-{
-        lnet_router_seq_iterator_t *lrtrsi = iter;
-        int                        rc;
-        loff_t                     next = *pos + 1;
-
-        rc = lnet_router_seq_seek(lrtrsi, next);
-        if (rc != 0) {
-                LIBCFS_FREE(lrtrsi, sizeof(*lrtrsi));
-                return NULL;
-        }
+                r = the_lnet.ln_routers.next;
 
-        *pos = next;
-        return lrtrsi;
-}
+                while (r != &the_lnet.ln_routers) {
+                        lnet_peer_t *lp = list_entry(r, lnet_peer_t,
+                                                     lp_rtr_list);
 
-static int
-lnet_router_seq_show (struct seq_file *s, void *iter)
-{
-        lnet_router_seq_iterator_t *lrtrsi = iter;
-        lnet_peer_t *lp;
-        lnet_nid_t   nid;
-        int          alive;
-        int          alive_cnt;
-        int          nrefs;
-        int          nrtrrefs;
-        time_t       last_ping;
-
-        if (lrtrsi->lrtrsi_off == 0) {
-                seq_printf(s, "%-4s %7s %9s %6s %12s %s\n",
-                           "ref", "rtr_ref", "alive_cnt", "state", "last_ping", "router");
-                return 0;
-        }
+                        if (skip == 0) {
+                                peer = lp;
+                                        break;
+                                } else
+                                        skip--;
 
-        lp = lrtrsi->lrtrsi_router;
-        LASSERT (lp != NULL);
+                        r = r->next;
+                }
 
-        LNET_LOCK();
+                if (peer != NULL) {
+                        int        nrefs     = peer->lp_refcount;
+                        int        nrtrrefs  = peer->lp_rtr_refcount;
+                        int        alive_cnt = peer->lp_alive_count;
+                        int        alive     = peer->lp_alive;
+                        time_t     last_ping = peer->lp_ping_timestamp;
+                        lnet_nid_t nid       = peer->lp_nid;
+
+                        s += snprintf(s, tmpstr + tmpsiz - s,
+                                      "%-4d %7d %9d %6s %12lu %s\n",
+                                      nrefs, nrtrrefs,
+                                      alive_cnt, alive ? "up" : "down",
+                                      last_ping, libcfs_nid2str(nid));
+                        LASSERT (tmpstr + tmpsiz - s > 0);
+                }
 
-        if (lrtrsi->lrtrsi_version != the_lnet.ln_routers_version) {
                 LNET_UNLOCK();
-                return -ESTALE;
         }
 
-        nid       = lp->lp_nid;
-        alive     = lp->lp_alive;
-        alive_cnt = lp->lp_alive_count;
-        nrefs     = lp->lp_refcount;
-        nrtrrefs  = lp->lp_rtr_refcount;
-        last_ping = lp->lp_ping_timestamp;
+        len = s - tmpstr;     /* how many bytes was written */
 
-        LNET_UNLOCK();
-
-        seq_printf(s, 
-                   "%-4d %7d %9d %6s %12lu %s\n", nrefs, nrtrrefs,
-                   alive_cnt, alive ? "up" : "down",
-                   last_ping, libcfs_nid2str(nid));
-        return 0;
-}
+        if (len > *lenp) {    /* linux-supplied buffer is too small */
+                rc = -EINVAL;
+        } else if (len > 0) { /* wrote something */
+                if (copy_to_user(buffer, tmpstr, len))
+                        rc = -EFAULT;
+                else
+                        *ppos += 1;
+        }
 
-static struct seq_operations lnet_routers_sops = {
-        .start = lnet_router_seq_start,
-        .stop  = lnet_router_seq_stop,
-        .next  = lnet_router_seq_next,
-        .show  = lnet_router_seq_show,
-};
+        LIBCFS_FREE(tmpstr, tmpsiz);
 
-static int
-lnet_router_seq_open(struct inode *inode, struct file *file)
-{
-        struct proc_dir_entry *dp = PDE(inode);
-        struct seq_file       *sf;
-        int                    rc;
-
-        rc = seq_open(file, &lnet_routers_sops);
-        if (rc == 0) {
-                sf = file->private_data;
-                sf->private = dp->data;
-        }
+        if (rc == 0)
+                *lenp = len;
 
         return rc;
 }
 
-static struct file_operations lnet_routers_fops = {
-        .owner   = THIS_MODULE,
-        .open    = lnet_router_seq_open,
-        .read    = seq_read,
-        .llseek  = seq_lseek,
-        .release = seq_release,
-};
-
-typedef struct {
-        unsigned long long   lpsi_version;
-        int                  lpsi_idx;
-        lnet_peer_t         *lpsi_peer;
-        loff_t               lpsi_off;
-} lnet_peer_seq_iterator_t;
-
-int
-lnet_peer_seq_seek (lnet_peer_seq_iterator_t *lpsi, loff_t off)
-{
-        int                idx;
-        struct list_head  *p;
-        loff_t             here;
-        int                rc;
-
-        if (off == 0) {
-                lpsi->lpsi_idx = 0;
-                lpsi->lpsi_peer = NULL;
-                lpsi->lpsi_off = 0;
+/*
+ * NB: we don't use the highest bit of *ppos because it's signed;
+ *     next 9 bits is used to stash idx (assuming that
+ *     LNET_PEER_HASHSIZE < 512)
+ */
+#define LNET_LOFFT_BITS (sizeof(loff_t) * 8)
+#define LNET_PHASH_BITS 9
+#define LNET_PHASH_IDX_MASK (((1ULL << LNET_PHASH_BITS) - 1) <<               \
+                             (LNET_LOFFT_BITS - LNET_PHASH_BITS - 1))
+#define LNET_PHASH_NUM_MASK ((1ULL <<                                         \
+                              (LNET_LOFFT_BITS - LNET_PHASH_BITS -1)) - 1)
+#define LNET_PHASH_IDX_GET(pos) (int)(((pos) & LNET_PHASH_IDX_MASK) >>  \
+                                      (LNET_LOFFT_BITS - LNET_PHASH_BITS -1))
+#define LNET_PHASH_NUM_GET(pos) (int)((pos) & LNET_PHASH_NUM_MASK)
+#define LNET_PHASH_POS_MAKE(idx, num) ((((loff_t)idx) << (LNET_LOFFT_BITS -   \
+                                                  LNET_PHASH_BITS -1)) | (num))
+
+int LL_PROC_PROTO(proc_lnet_peers)
+{
+        int        rc = 0;
+        char      *tmpstr;
+        char      *s;
+        const int  tmpsiz      = 256;
+        int        len;
+        int       *ver_p       = (unsigned int *)(&filp->private_data);
+        int        idx;
+        int        num;
+
+        DECLARE_LL_PROC_PPOS_DECL;
+
+        idx = LNET_PHASH_IDX_GET(*ppos);
+        num = LNET_PHASH_NUM_GET(*ppos);
+
+        CLASSERT ((1 << LNET_PHASH_BITS) > LNET_PEER_HASHSIZE);
+
+        LASSERT (!write);
+
+        if (*lenp == 0)
                 return 0;
-        }
-
-        LNET_LOCK();
 
-        if (lpsi->lpsi_peer != NULL &&
-            lpsi->lpsi_version != the_lnet.ln_peertable_version) {
-                /* tables have changed */
-                rc = -ESTALE;
-                goto out;
-        }
+        LIBCFS_ALLOC(tmpstr, tmpsiz);
+        if (tmpstr == NULL)
+                return -ENOMEM;
 
-        if (lpsi->lpsi_peer == NULL ||
-            lpsi->lpsi_off > off) {
-                /* search from start */
-                idx = 0;
-                p = NULL;
-                here = 1;
-        } else {
-                /* continue search */
-                idx = lpsi->lpsi_idx;
-                p = &lpsi->lpsi_peer->lp_hashlist;
-                here = lpsi->lpsi_off;
-        }
+        s = tmpstr; /* points to current position in tmpstr[] */
 
-        lpsi->lpsi_version = the_lnet.ln_peertable_version;
-        lpsi->lpsi_off     = off;
+        if (*ppos == 0) {
+                s += snprintf(s, tmpstr + tmpsiz - s,
+                              "%-24s %4s %5s %5s %5s %5s %5s %5s %s\n",
+                              "nid", "refs", "state", "max",
+                              "rtr", "min", "tx", "min", "queue");
+                LASSERT (tmpstr + tmpsiz - s > 0);
 
-        while (idx < LNET_PEER_HASHSIZE) {
-                if (p == NULL)
-                        p = the_lnet.ln_peer_hash[idx].next;
+                LNET_LOCK();
+                *ver_p  = (unsigned int)the_lnet.ln_peertable_version;
+                LNET_UNLOCK();
 
-                while (p != &the_lnet.ln_peer_hash[idx]) {
-                        lnet_peer_t *lp = list_entry(p, lnet_peer_t,
-                                                     lp_hashlist);
+                num++;
+        } else {
+                struct list_head  *p    = NULL;
+                lnet_peer_t       *peer = NULL;
+                int                skip = num - 1;
 
-                        if (here == off) {
-                                lpsi->lpsi_idx = idx;
-                                lpsi->lpsi_peer = lp;
-                                rc = 0;
-                                goto out;
-                        }
+                LNET_LOCK();
 
-                        here++;
-                        p = lp->lp_hashlist.next;
+                if (*ver_p != (unsigned int)the_lnet.ln_peertable_version) {
+                        LNET_UNLOCK();
+                        LIBCFS_FREE(tmpstr, tmpsiz);
+                        return -ESTALE;
                 }
 
-                p = NULL;
-                idx++;
-        }
-
-        lpsi->lpsi_idx  = 0;
-        lpsi->lpsi_peer = NULL;
-        rc              = -ENOENT;
- out:
-        LNET_UNLOCK();
-        return rc;
-}
-
-static void *
-lnet_peer_seq_start (struct seq_file *s, loff_t *pos)
-{
-        lnet_peer_seq_iterator_t *lpsi;
-        int                        rc;
-
-        LIBCFS_ALLOC(lpsi, sizeof(*lpsi));
-        if (lpsi == NULL)
-                return NULL;
-
-        lpsi->lpsi_idx = 0;
-        lpsi->lpsi_peer = NULL;
-        rc = lnet_peer_seq_seek(lpsi, *pos);
-        if (rc == 0)
-                return lpsi;
-
-        LIBCFS_FREE(lpsi, sizeof(*lpsi));
-        return NULL;
-}
+                while (idx < LNET_PEER_HASHSIZE) {
+                        if (p == NULL)
+                                p = the_lnet.ln_peer_hash[idx].next;
+
+                        while (p != &the_lnet.ln_peer_hash[idx]) {
+                                lnet_peer_t *lp = list_entry(p, lnet_peer_t,
+                                                             lp_hashlist);
+                                if (skip == 0) {
+                                        peer = lp;
+
+                                        /* minor optimiztion: start from idx+1
+                                         * on next iteration if we've just
+                                         * drained lp_hashlist */
+                                        if (lp->lp_hashlist.next ==
+                                            &the_lnet.ln_peer_hash[idx]) {
+                                                num = 1;
+                                                idx++;
+                                        } else
+                                                num++;
+
+                                        break;
+                                } else
+                                        skip--;
+
+                                p = lp->lp_hashlist.next;
+                        }
 
-static void
-lnet_peer_seq_stop (struct seq_file *s, void *iter)
-{
-        lnet_peer_seq_iterator_t  *lpsi = iter;
+                        if (peer != NULL)
+                                break;
 
-        if (lpsi != NULL)
-                LIBCFS_FREE(lpsi, sizeof(*lpsi));
-}
-
-static void *
-lnet_peer_seq_next (struct seq_file *s, void *iter, loff_t *pos)
-{
-        lnet_peer_seq_iterator_t *lpsi = iter;
-        int                       rc;
-        loff_t                    next = *pos + 1;
-
-        rc = lnet_peer_seq_seek(lpsi, next);
-        if (rc != 0) {
-                LIBCFS_FREE(lpsi, sizeof(*lpsi));
-                return NULL;
-        }
+                        p = NULL;
+                        num = 1;
+                        idx++;
+                }
 
-        *pos = next;
-        return lpsi;
-}
+                if (peer != NULL) {
+                        lnet_nid_t nid       = peer->lp_nid;
+                        int        nrefs     = peer->lp_refcount;
+                        char      *aliveness = "NA";
+                        int        maxcr     = peer->lp_ni->ni_peertxcredits;
+                        int        txcr      = peer->lp_txcredits;
+                        int        mintxcr   = peer->lp_mintxcredits;
+                        int        rtrcr     = peer->lp_rtrcredits;
+                        int        minrtrcr  = peer->lp_minrtrcredits;
+                        int        txqnob    = peer->lp_txqnob;
+
+                        if (lnet_isrouter(peer) ||
+                            peer->lp_ni->ni_peertimeout > 0)
+                                aliveness = peer->lp_alive ? "up" : "down";
+
+                        s += snprintf(s, tmpstr + tmpsiz - s,
+                                      "%-24s %4d %5s %5d %5d %5d %5d %5d %d\n",
+                                      libcfs_nid2str(nid), nrefs, aliveness,
+                                      maxcr, rtrcr, minrtrcr, txcr,
+                                      mintxcr, txqnob);
+                        LASSERT (tmpstr + tmpsiz - s > 0);
+                }
 
-static int
-lnet_peer_seq_show (struct seq_file *s, void *iter)
-{
-        lnet_peer_seq_iterator_t *lpsi = iter;
-        lnet_peer_t              *lp;
-        lnet_nid_t                nid;
-        int                       maxcr;
-        int                       mintxcr;
-        int                       txcr;
-        int                       minrtrcr;
-        int                       rtrcr;
-        int                       alive;
-        int                       rtr;
-        int                       txqnob;
-        int                       nrefs;
-
-        if (lpsi->lpsi_off == 0) {
-                seq_printf(s, "%-24s %4s %5s %5s %5s %5s %5s %5s %s\n",
-                           "nid", "refs", "state", "max",
-                           "rtr", "min", "tx", "min", "queue");
-                return 0;
+                LNET_UNLOCK();
         }
 
-        LASSERT (lpsi->lpsi_peer != NULL);
-
-        LNET_LOCK();
+        len = s - tmpstr;     /* how many bytes was written */
 
-        if (lpsi->lpsi_version != the_lnet.ln_peertable_version) {
-                LNET_UNLOCK();
-                return -ESTALE;
+        if (len > *lenp) {    /* linux-supplied buffer is too small */
+                rc = -EINVAL;
+        } else if (len > 0) { /* wrote something */
+                if (copy_to_user(buffer, tmpstr, len))
+                        rc = -EFAULT;
+                else
+                        *ppos = LNET_PHASH_POS_MAKE(idx, num);
         }
 
-        lp = lpsi->lpsi_peer;
-
-        nid      = lp->lp_nid;
-        maxcr    = lp->lp_ni->ni_peertxcredits;
-        txcr     = lp->lp_txcredits;
-        mintxcr  = lp->lp_mintxcredits;
-        rtrcr    = lp->lp_rtrcredits;
-        minrtrcr = lp->lp_minrtrcredits;
-        rtr      = lnet_isrouter(lp);
-        alive    = lp->lp_alive;
-        txqnob   = lp->lp_txqnob;
-        nrefs    = lp->lp_refcount;
+        LIBCFS_FREE(tmpstr, tmpsiz);
 
-        LNET_UNLOCK();
+        if (rc == 0)
+                *lenp = len;
 
-        seq_printf(s, "%-24s %4d %5s %5d %5d %5d %5d %5d %d\n",
-                   libcfs_nid2str(nid), nrefs, 
-                   !rtr ? "~rtr" : (alive ? "up" : "down"),
-                   maxcr, rtrcr, minrtrcr, txcr, mintxcr, txqnob);
-        return 0;
+        return rc;
 }
 
-static struct seq_operations lnet_peer_sops = {
-        .start = lnet_peer_seq_start,
-        .stop  = lnet_peer_seq_stop,
-        .next  = lnet_peer_seq_next,
-        .show  = lnet_peer_seq_show,
-};
-
-static int
-lnet_peer_seq_open(struct inode *inode, struct file *file)
+static int __proc_lnet_buffers(void *data, int write,
+                               loff_t pos, void *buffer, int nob)
 {
-        struct proc_dir_entry *dp = PDE(inode);
-        struct seq_file       *sf;
-        int                    rc;
-
-        rc = seq_open(file, &lnet_peer_sops);
-        if (rc == 0) {
-                sf = file->private_data;
-                sf->private = dp->data;
-        }
 
-        return rc;
-}
+        int              rc;
+        int              len;
+        char            *s;
+        char            *tmpstr;
+        const int        tmpsiz = 64 * (LNET_NRBPOOLS + 1); /* (4 %d) * 4 */
+        int              idx;
 
-static struct file_operations lnet_peer_fops = {
-        .owner   = THIS_MODULE,
-        .open    = lnet_peer_seq_open,
-        .read    = seq_read,
-        .llseek  = seq_lseek,
-        .release = seq_release,
-};
+        LASSERT (!write);
 
-typedef struct {
-        int                  lbsi_idx;
-        loff_t               lbsi_off;
-} lnet_buffer_seq_iterator_t;
+        LIBCFS_ALLOC(tmpstr, tmpsiz);
+        if (tmpstr == NULL)
+                return -ENOMEM;
 
-int
-lnet_buffer_seq_seek (lnet_buffer_seq_iterator_t *lbsi, loff_t off)
-{
-        int                idx;
-        loff_t             here;
-        int                rc;
+        s = tmpstr; /* points to current position in tmpstr[] */
 
-        if (off == 0) {
-                lbsi->lbsi_idx = -1;
-                lbsi->lbsi_off = 0;
-                return 0;
-        }
+        s += snprintf(s, tmpstr + tmpsiz - s,
+                      "%5s %5s %7s %7s\n",
+                      "pages", "count", "credits", "min");
+        LASSERT (tmpstr + tmpsiz - s > 0);
 
         LNET_LOCK();
 
-        if (lbsi->lbsi_idx < 0 ||
-            lbsi->lbsi_off > off) {
-                /* search from start */
-                idx = 0;
-                here = 1;
-        } else {
-                /* continue search */
-                idx = lbsi->lbsi_idx;
-                here = lbsi->lbsi_off;
-        }
+        for (idx = 0; idx < LNET_NRBPOOLS; idx++) {
+                lnet_rtrbufpool_t *rbp = &the_lnet.ln_rtrpools[idx];
 
-        lbsi->lbsi_off     = off;
+                int npages = rbp->rbp_npages;
+                int nbuf   = rbp->rbp_nbuffers;
+                int cr     = rbp->rbp_credits;
+                int mincr  = rbp->rbp_mincredits;
 
-        while (idx < LNET_NRBPOOLS) {
-                if (here == off) {
-                        lbsi->lbsi_idx = idx;
-                        rc = 0;
-                        goto out;
-                }
-                here++;
-                idx++;
+                s += snprintf(s, tmpstr + tmpsiz - s,
+                              "%5d %5d %7d %7d\n",
+                              npages, nbuf, cr, mincr);
+                LASSERT (tmpstr + tmpsiz - s > 0);
         }
 
-        lbsi->lbsi_idx  = -1;
-        rc              = -ENOENT;
- out:
         LNET_UNLOCK();
-        return rc;
-}
 
-static void *
-lnet_buffer_seq_start (struct seq_file *s, loff_t *pos)
-{
-        lnet_buffer_seq_iterator_t *lbsi;
-        int                        rc;
+        len = s - tmpstr;
 
-        LIBCFS_ALLOC(lbsi, sizeof(*lbsi));
-        if (lbsi == NULL)
-                return NULL;
+        if (pos >= min_t(int, len, strlen(tmpstr)))
+                rc = 0;
+        else
+                rc = trace_copyout_string(buffer, nob,
+                                          tmpstr + pos, NULL);
 
-        lbsi->lbsi_idx = -1;
-        rc = lnet_buffer_seq_seek(lbsi, *pos);
-        if (rc == 0)
-                return lbsi;
-
-        LIBCFS_FREE(lbsi, sizeof(*lbsi));
-        return NULL;
+        LIBCFS_FREE(tmpstr, tmpsiz);
+        return rc;
 }
 
-static void
-lnet_buffer_seq_stop (struct seq_file *s, void *iter)
-{
-        lnet_buffer_seq_iterator_t  *lbsi = iter;
-
-        if (lbsi != NULL)
-                LIBCFS_FREE(lbsi, sizeof(*lbsi));
-}
+DECLARE_PROC_HANDLER(proc_lnet_buffers);
 
-static void *
-lnet_buffer_seq_next (struct seq_file *s, void *iter, loff_t *pos)
+int LL_PROC_PROTO(proc_lnet_nis)
 {
-        lnet_buffer_seq_iterator_t *lbsi = iter;
-        int                         rc;
-        loff_t                      next = *pos + 1;
-
-        rc = lnet_buffer_seq_seek(lbsi, next);
-        if (rc != 0) {
-                LIBCFS_FREE(lbsi, sizeof(*lbsi));
-                return NULL;
-        }
+        int        rc = 0;
+        char      *tmpstr;
+        char      *s;
+        const int  tmpsiz = 256;
+        int        len;
 
-        *pos = next;
-        return lbsi;
-}
+        DECLARE_LL_PROC_PPOS_DECL;
 
-static int
-lnet_buffer_seq_show (struct seq_file *s, void *iter)
-{
-        lnet_buffer_seq_iterator_t *lbsi = iter;
-        lnet_rtrbufpool_t          *rbp;
-        int                         npages;
-        int                         nbuf;
-        int                         cr;
-        int                         mincr;
-
-        if (lbsi->lbsi_off == 0) {
-                seq_printf(s, "%5s %5s %7s %7s\n",
-                           "pages", "count", "credits", "min");
-                return 0;
-        }
-
-        LASSERT (lbsi->lbsi_idx >= 0 && lbsi->lbsi_idx < LNET_NRBPOOLS);
-
-        LNET_LOCK();
-
-        rbp = &the_lnet.ln_rtrpools[lbsi->lbsi_idx];
-
-        npages = rbp->rbp_npages;
-        nbuf   = rbp->rbp_nbuffers;
-        cr     = rbp->rbp_credits;
-        mincr  = rbp->rbp_mincredits;
-
-        LNET_UNLOCK();
-
-        seq_printf(s, "%5d %5d %7d %7d\n",
-                   npages, nbuf, cr, mincr);
-        return 0;
-}
-
-static struct seq_operations lnet_buffer_sops = {
-        .start = lnet_buffer_seq_start,
-        .stop  = lnet_buffer_seq_stop,
-        .next  = lnet_buffer_seq_next,
-        .show  = lnet_buffer_seq_show,
-};
-
-static int
-lnet_buffer_seq_open(struct inode *inode, struct file *file)
-{
-        struct proc_dir_entry *dp = PDE(inode);
-        struct seq_file       *sf;
-        int                    rc;
-
-        rc = seq_open(file, &lnet_buffer_sops);
-        if (rc == 0) {
-                sf = file->private_data;
-                sf->private = dp->data;
-        }
+        LASSERT (!write);
 
-        return rc;
-}
-
-static struct file_operations lnet_buffers_fops = {
-        .owner   = THIS_MODULE,
-        .open    = lnet_buffer_seq_open,
-        .read    = seq_read,
-        .llseek  = seq_lseek,
-        .release = seq_release,
-};
-
-typedef struct {
-        lnet_ni_t           *lnsi_ni;
-        loff_t               lnsi_off;
-} lnet_ni_seq_iterator_t;
-
-int
-lnet_ni_seq_seek (lnet_ni_seq_iterator_t *lnsi, loff_t off)
-{
-        struct list_head  *n;
-        loff_t             here;
-        int                rc;
-
-        if (off == 0) {
-                lnsi->lnsi_ni = NULL;
-                lnsi->lnsi_off = 0;
+        if (*lenp == 0)
                 return 0;
-        }
 
-        LNET_LOCK();
+        LIBCFS_ALLOC(tmpstr, tmpsiz);
+        if (tmpstr == NULL)
+                return -ENOMEM;
 
-        if (lnsi->lnsi_ni == NULL ||
-            lnsi->lnsi_off > off) {
-                /* search from start */
-                n = NULL;
-                here = 1;
+        s = tmpstr; /* points to current position in tmpstr[] */
+
+        if (*ppos == 0) {
+                s += snprintf(s, tmpstr + tmpsiz - s,
+                              "%-24s %4s %4s %4s %5s %5s %5s\n",
+                              "nid", "refs", "peer", "rtr", "max",
+                              "tx", "min");
+                LASSERT (tmpstr + tmpsiz - s > 0);
         } else {
-                /* continue search */
-                n = &lnsi->lnsi_ni->ni_list;
-                here = lnsi->lnsi_off;
-        }
+                struct list_head  *n;
+                lnet_ni_t         *ni   = NULL;
+                int                skip = *ppos - 1;
 
-        lnsi->lnsi_off = off;
+                LNET_LOCK();
 
-        if (n == NULL)
                 n = the_lnet.ln_nis.next;
 
-        while (n != &the_lnet.ln_nis) {
-                if (here == off) {
-                        lnsi->lnsi_ni = list_entry(n, lnet_ni_t, ni_list);
-                        rc = 0;
-                        goto out;
-                }
-                here++;
-                n = n->next;
-        }
+                while (n != &the_lnet.ln_nis) {
+                        lnet_ni_t *a_ni = list_entry(n, lnet_ni_t, ni_list);
 
-        lnsi->lnsi_ni  = NULL;
-        rc             = -ENOENT;
- out:
-        LNET_UNLOCK();
-        return rc;
-}
-
-static void *
-lnet_ni_seq_start (struct seq_file *s, loff_t *pos)
-{
-        lnet_ni_seq_iterator_t *lnsi;
-        int                     rc;
-
-        LIBCFS_ALLOC(lnsi, sizeof(*lnsi));
-        if (lnsi == NULL)
-                return NULL;
-
-        lnsi->lnsi_ni = NULL;
-        rc = lnet_ni_seq_seek(lnsi, *pos);
-        if (rc == 0)
-                return lnsi;
-
-        LIBCFS_FREE(lnsi, sizeof(*lnsi));
-        return NULL;
-}
+                        if (skip == 0) {
+                                ni = a_ni;
+                                break;
+                        } else
+                                skip--;
 
-static void
-lnet_ni_seq_stop (struct seq_file *s, void *iter)
-{
-        lnet_ni_seq_iterator_t  *lnsi = iter;
+                        n = n->next;
+                }
 
-        if (lnsi != NULL)
-                LIBCFS_FREE(lnsi, sizeof(*lnsi));
-}
+                if (ni != NULL) {
+                        int        maxtxcr = ni->ni_maxtxcredits;
+                        int        txcr = ni->ni_txcredits;
+                        int        mintxcr = ni->ni_mintxcredits;
+                        int        npeertxcr = ni->ni_peertxcredits;
+                        int        npeerrtrcr = ni->ni_peerrtrcredits;
+                        lnet_nid_t nid = ni->ni_nid;
+                        int        nref = ni->ni_refcount;
+
+                        s += snprintf(s, tmpstr + tmpsiz - s,
+                                      "%-24s %4d %4d %4d %5d %5d %5d\n",
+                                      libcfs_nid2str(nid), nref,
+                                      npeertxcr, npeerrtrcr, maxtxcr,
+                                      txcr, mintxcr);
+                        LASSERT (tmpstr + tmpsiz - s > 0);
+                }
 
-static void *
-lnet_ni_seq_next (struct seq_file *s, void *iter, loff_t *pos)
-{
-        lnet_ni_seq_iterator_t *lnsi = iter;
-        int                     rc;
-        loff_t                  next = *pos + 1;
-
-        rc = lnet_ni_seq_seek(lnsi, next);
-        if (rc != 0) {
-                LIBCFS_FREE(lnsi, sizeof(*lnsi));
-                return NULL;
+                LNET_UNLOCK();
         }
 
-        *pos = next;
-        return lnsi;
-}
+        len = s - tmpstr;     /* how many bytes was written */
 
-static int
-lnet_ni_seq_show (struct seq_file *s, void *iter)
-{
-        lnet_ni_seq_iterator_t *lnsi = iter;
-        lnet_ni_t              *ni;
-        int                     maxtxcr;
-        int                     txcr;
-        int                     mintxcr;
-        int                     npeertxcr;
-        lnet_nid_t              nid;
-        int                     nref;
-
-        if (lnsi->lnsi_off == 0) {
-                seq_printf(s, "%-24s %4s %4s %5s %5s %5s\n",
-                           "nid", "refs", "peer", "max", "tx", "min");
-                return 0;
+        if (len > *lenp) {    /* linux-supplied buffer is too small */
+                rc = -EINVAL;
+        } else if (len > 0) { /* wrote something */
+                if (copy_to_user(buffer, tmpstr, len))
+                        rc = -EFAULT;
+                else
+                        *ppos += 1;
         }
 
-        LASSERT (lnsi->lnsi_ni != NULL);
-
-        LNET_LOCK();
-
-        ni = lnsi->lnsi_ni;
-
-        maxtxcr   = ni->ni_maxtxcredits;
-        txcr      = ni->ni_txcredits;
-        mintxcr   = ni->ni_mintxcredits;
-        npeertxcr = ni->ni_peertxcredits;
-        nid       = ni->ni_nid;
-        nref      = ni->ni_refcount;
+        LIBCFS_FREE(tmpstr, tmpsiz);
 
-        LNET_UNLOCK();
+        if (rc == 0)
+                *lenp = len;
 
-        seq_printf(s, "%-24s %4d %4d %5d %5d %5d\n",
-                   libcfs_nid2str(nid), nref,
-                   npeertxcr, maxtxcr, txcr, mintxcr);
-        return 0;
+        return rc;
 }
 
-static struct seq_operations lnet_ni_sops = {
-        .start = lnet_ni_seq_start,
-        .stop  = lnet_ni_seq_stop,
-        .next  = lnet_ni_seq_next,
-        .show  = lnet_ni_seq_show,
+static cfs_sysctl_table_t lnet_table[] = {
+        /*
+         * NB No .strategy entries have been provided since sysctl(8) prefers
+         * to go via /proc for portability.
+         */
+        {
+                .ctl_name = PSDEV_LNET_STATS,
+                .procname = "stats",
+                .mode     = 0644,
+                .proc_handler = &proc_lnet_stats,
+        },
+        {
+                .ctl_name = PSDEV_LNET_ROUTES,
+                .procname = "routes",
+                .mode     = 0444,
+                .proc_handler = &proc_lnet_routes,
+        },
+        {
+                .ctl_name = PSDEV_LNET_ROUTERS,
+                .procname = "routers",
+                .mode     = 0444,
+                .proc_handler = &proc_lnet_routers,
+        },
+        {
+                .ctl_name = PSDEV_LNET_PEERS,
+                .procname = "peers",
+                .mode     = 0444,
+                .proc_handler = &proc_lnet_peers,
+        },
+        {
+                .ctl_name = PSDEV_LNET_PEERS,
+                .procname = "buffers",
+                .mode     = 0444,
+                .proc_handler = &proc_lnet_buffers,
+        },
+        {
+                .ctl_name = PSDEV_LNET_NIS,
+                .procname = "nis",
+                .mode     = 0444,
+                .proc_handler = &proc_lnet_nis,
+        },
+        {0}
 };
 
-static int
-lnet_ni_seq_open(struct inode *inode, struct file *file)
-{
-        struct proc_dir_entry *dp = PDE(inode);
-        struct seq_file       *sf;
-        int                    rc;
-
-        rc = seq_open(file, &lnet_ni_sops);
-        if (rc == 0) {
-                sf = file->private_data;
-                sf->private = dp->data;
+static cfs_sysctl_table_t top_table[] = {
+        {
+                .ctl_name = CTL_LNET,
+                .procname = "lnet",
+                .mode     = 0555,
+                .data     = NULL,
+                .maxlen   = 0,
+                .child    = lnet_table,
+        },
+        {
+                .ctl_name = 0
         }
-
-        return rc;
-}
-
-static struct file_operations lnet_ni_fops = {
-        .owner   = THIS_MODULE,
-        .open    = lnet_ni_seq_open,
-        .read    = seq_read,
-        .llseek  = seq_lseek,
-        .release = seq_release,
 };
 
 void
 lnet_proc_init(void)
 {
-        struct proc_dir_entry *pde;
-
-#if 0
-        pde = proc_mkdir(LNET_PROC_ROOT, NULL);
-        if (pde == NULL) {
-                CERROR("couldn't create "LNET_PROC_ROOT"\n");
-                return; 
-        }
+#ifdef CONFIG_SYSCTL
+        if (lnet_table_header == NULL)
+                lnet_table_header = cfs_register_sysctl_table(top_table, 0);
 #endif
-        /* Initialize LNET_PROC_STATS */
-        pde = create_proc_entry (LNET_PROC_STATS, 0644, NULL);
-        if (pde == NULL) {
-                CERROR("couldn't create proc entry %s\n", LNET_PROC_STATS);
-                return;
-        }
-
-        pde->data = NULL;
-        pde->read_proc = lnet_router_proc_stats_read;
-        pde->write_proc = lnet_router_proc_stats_write;
-
-        /* Initialize LNET_PROC_ROUTES */
-        pde = create_proc_entry (LNET_PROC_ROUTES, 0444, NULL);
-        if (pde == NULL) {
-                CERROR("couldn't create proc entry %s\n", LNET_PROC_ROUTES);
-                return;
-        }
-
-        pde->proc_fops = &lnet_routes_fops;
-        pde->data = NULL;
-
-        /* Initialize LNET_PROC_ROUTERS */
-        pde = create_proc_entry (LNET_PROC_ROUTERS, 0444, NULL);
-        if (pde == NULL) {
-                CERROR("couldn't create proc entry %s\n", LNET_PROC_ROUTERS);
-                return;
-        }
-
-        pde->proc_fops = &lnet_routers_fops;
-        pde->data = NULL;
-
-        /* Initialize LNET_PROC_PEERS */
-        pde = create_proc_entry (LNET_PROC_PEERS, 0444, NULL);
-        if (pde == NULL) {
-                CERROR("couldn't create proc entry %s\n", LNET_PROC_PEERS);
-                return;
-        }
-
-        pde->proc_fops = &lnet_peer_fops;
-        pde->data = NULL;
-
-        /* Initialize LNET_PROC_BUFFERS */
-        pde = create_proc_entry (LNET_PROC_BUFFERS, 0444, NULL);
-        if (pde == NULL) {
-                CERROR("couldn't create proc entry %s\n", LNET_PROC_BUFFERS);
-                return;
-        }
-
-        pde->proc_fops = &lnet_buffers_fops;
-        pde->data = NULL;
-
-        /* Initialize LNET_PROC_NIS */
-        pde = create_proc_entry (LNET_PROC_NIS, 0444, NULL);
-        if (pde == NULL) {
-                CERROR("couldn't create proc entry %s\n", LNET_PROC_NIS);
-                return;
-        }
-
-        pde->proc_fops = &lnet_ni_fops;
-        pde->data = NULL;
 }
 
 void
 lnet_proc_fini(void)
 {
-        remove_proc_entry(LNET_PROC_STATS, 0);
-        remove_proc_entry(LNET_PROC_ROUTES, 0);
-        remove_proc_entry(LNET_PROC_ROUTERS, 0);
-        remove_proc_entry(LNET_PROC_PEERS, 0);
-        remove_proc_entry(LNET_PROC_BUFFERS, 0);
-        remove_proc_entry(LNET_PROC_NIS, 0);
-#if 0   
-        remove_proc_entry(LNET_PROC_ROOT, 0);
+#ifdef CONFIG_SYSCTL
+        if (lnet_table_header != NULL)
+                cfs_unregister_sysctl_table(lnet_table_header);
+
+        lnet_table_header = NULL;
 #endif
 }
 
diff --git a/lnet/selftest/Makefile.in b/lnet/selftest/Makefile.in
index 8ebef75..3c9e96f 100644
--- a/lnet/selftest/Makefile.in
+++ b/lnet/selftest/Makefile.in
@@ -4,4 +4,6 @@ lnet_selftest-objs := console.o conrpc.o conctl.o framework.o timer.o rpc.o work
 
 default: all
 
+EXTRA_DIST = $(lnet_selftest-objs:%.o=%.c) console.h conrpc.h rpc.h selftest.h timer.h
+
 @INCLUDE_RULES@
diff --git a/lnet/selftest/autoMakefile.am b/lnet/selftest/autoMakefile.am
index 36af901..b9ad0ab 100644
--- a/lnet/selftest/autoMakefile.am
+++ b/lnet/selftest/autoMakefile.am
@@ -20,4 +20,3 @@ endif # MODULES
 install-data-hook: $(install_data_hook)
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ selftest
-DIST_SOURCES = $(lnet_selftest-objs:%.o=%.c) console.h conrpc.h rpc.h selftest.h timer.h
diff --git a/lnet/selftest/autoMakefile.in b/lnet/selftest/autoMakefile.in
index 7b9e43b..f9d608f 100644
--- a/lnet/selftest/autoMakefile.in
+++ b/lnet/selftest/autoMakefile.in
@@ -175,9 +175,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@ selftest
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -303,7 +303,6 @@ my_sources = console.c conrpc.c conctl.c console.h conrpc.h \
 @LIBLUSTRE_TRUE at libselftest_a_CFLAGS = $(LLCFLAGS)
 
 @LINUX_TRUE@@MODULES_TRUE at modulenet_DATA = lnet_selftest$(KMODEXT)
-DIST_SOURCES = $(lnet_selftest-objs:%.o=%.c) console.h conrpc.h rpc.h selftest.h timer.h
 subdir = lnet/selftest
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -343,6 +342,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libselftest_a_SOURCES_DIST)
 DATA = $(modulenet_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lnet/selftest/conrpc.h b/lnet/selftest/conrpc.h
index fe52d47..e0d878a 100644
--- a/lnet/selftest/conrpc.h
+++ b/lnet/selftest/conrpc.h
@@ -54,6 +54,9 @@
 /* Console rpc and rpc transaction */
 #define LST_TRANS_TIMEOUT       30
 #define LST_TRANS_MIN_TIMEOUT   3
+
+#define LST_VALIDATE_TIMEOUT(t) MIN(MAX(t, LST_TRANS_MIN_TIMEOUT), LST_TRANS_TIMEOUT)
+
 #define LST_PING_INTERVAL       8
 
 struct lstcon_rpc_trans;
diff --git a/lnet/selftest/console.c b/lnet/selftest/console.c
index 943f332..a3e39b9 100644
--- a/lnet/selftest/console.c
+++ b/lnet/selftest/console.c
@@ -1465,9 +1465,7 @@ lstcon_ndlist_stat(struct list_head *ndlist,
                 return rc;
         }
 
-        timeout = (timeout > LST_TRANS_MIN_TIMEOUT) ? timeout :
-                                                      LST_TRANS_MIN_TIMEOUT;
-        lstcon_rpc_trans_postwait(trans, timeout);
+        lstcon_rpc_trans_postwait(trans, LST_VALIDATE_TIMEOUT(timeout));
 
         rc = lstcon_rpc_trans_interpreter(trans, result_up,
                                           lstcon_statrpc_readent);
@@ -1554,10 +1552,7 @@ lstcon_debug_ndlist(struct list_head *ndlist,
                 return rc;
         }
 
-        timeout = (timeout > LST_TRANS_MIN_TIMEOUT) ? timeout :
-                                                      LST_TRANS_MIN_TIMEOUT;
-
-        lstcon_rpc_trans_postwait(trans, timeout);
+        lstcon_rpc_trans_postwait(trans, LST_VALIDATE_TIMEOUT(timeout));
 
         rc = lstcon_rpc_trans_interpreter(trans, result_up,
                                           lstcon_sesrpc_readent);
@@ -1708,8 +1703,8 @@ lstcon_session_new(char *name, int key,
         if (rc != 0) {
                 lstcon_batch_t *bat;
 
-                lstcon_batch_find(LST_DEFAULT_BATCH, &bat);
-                lstcon_batch_destroy(bat);
+                if (lstcon_batch_find(LST_DEFAULT_BATCH, &bat) == 0)
+                        lstcon_batch_destroy(bat);
 
                 return rc;
         }
@@ -1984,10 +1979,10 @@ lstcon_console_fini(void)
 {
         int     i;
 
-        mutex_down(&console_session.ses_mutex);
-
         libcfs_deregister_ioctl(&lstcon_ioctl_handler);
 
+        mutex_down(&console_session.ses_mutex);
+
         srpc_shutdown_service(&lstcon_acceptor_service);
         srpc_remove_service(&lstcon_acceptor_service);
 
diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c
index 618c1f4..dbe378e 100644
--- a/lnet/selftest/framework.c
+++ b/lnet/selftest/framework.c
@@ -51,7 +51,7 @@ static int session_timeout = 100;
 CFS_MODULE_PARM(session_timeout, "i", int, 0444,
                 "test session timeout in seconds (100 by default, 0 == never)");
 
-#define SFW_TEST_CONCURRENCY     128
+#define SFW_TEST_CONCURRENCY     1792
 #define SFW_TEST_RPC_TIMEOUT     64
 #define SFW_CLIENT_RPC_TIMEOUT   64  /* in seconds */
 #define SFW_EXTRA_TEST_BUFFERS   8 /* tolerate buggy peers with extra buffers */
@@ -211,6 +211,7 @@ sfw_deactivate_session (void)
         sfw_session_t *sn = sfw_data.fw_session;
         int            nactive = 0;
         sfw_batch_t   *tsb;
+        sfw_test_case_t *tsc;
 
         if (sn == NULL) return;
 
@@ -220,6 +221,14 @@ sfw_deactivate_session (void)
         atomic_inc(&sfw_data.fw_nzombies);
         list_add(&sn->sn_list, &sfw_data.fw_zombie_sessions);
 
+        spin_unlock(&sfw_data.fw_lock);
+
+        list_for_each_entry (tsc, &sfw_data.fw_tests, tsc_list) {
+                srpc_abort_service(tsc->tsc_srv_service);
+        }
+
+        spin_lock(&sfw_data.fw_lock);
+
         list_for_each_entry (tsb, &sn->sn_batches, bat_list) {
                 if (sfw_batch_active(tsb)) {
                         nactive++;
diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c
index 8066bde..0c24de4 100644
--- a/lnet/selftest/rpc.c
+++ b/lnet/selftest/rpc.c
@@ -43,8 +43,6 @@
 #include "selftest.h"
 
 
-#define SRPC_PEER_HASH_SIZE       101  /* # peer lists */
-
 typedef enum {
         SRPC_STATE_NONE,
         SRPC_STATE_NI_INIT,
@@ -57,17 +55,12 @@ typedef enum {
 struct smoketest_rpc {
         spinlock_t        rpc_glock;     /* global lock */
         srpc_service_t   *rpc_services[SRPC_SERVICE_MAX_ID + 1];
-        struct list_head *rpc_peers;     /* hash table of known peers */
         lnet_handle_eq_t  rpc_lnet_eq;   /* _the_ LNet event queue */
         srpc_state_t      rpc_state;
         srpc_counters_t   rpc_counters;
         __u64             rpc_matchbits; /* matchbits counter */
 } srpc_data;
 
-static int srpc_peer_credits = 16;
-CFS_MODULE_PARM(srpc_peer_credits, "i", int, 0444,
-                "# in-flight RPCs per peer (16 by default)");
-
 /* forward ref's */
 int srpc_handle_rpc (swi_workitem_t *wi);
 
@@ -181,91 +174,6 @@ srpc_alloc_bulk (int npages, int sink)
         return bk;
 }
 
-
-static inline struct list_head *
-srpc_nid2peerlist (lnet_nid_t nid)
-{
-        unsigned int hash = ((unsigned int)nid) % SRPC_PEER_HASH_SIZE;
-
-        return &srpc_data.rpc_peers[hash];
-}
-
-static inline srpc_peer_t *
-srpc_create_peer (lnet_nid_t nid)
-{
-        srpc_peer_t *peer;
-
-        LASSERT (nid != LNET_NID_ANY);
-
-        LIBCFS_ALLOC(peer, sizeof(srpc_peer_t));
-        if (peer == NULL) {
-                CERROR ("Failed to allocate peer structure for %s\n",
-                        libcfs_nid2str(nid));
-                return NULL;
-        }
-
-        memset(peer, 0, sizeof(srpc_peer_t));
-        peer->stp_nid     = nid;
-        peer->stp_credits = srpc_peer_credits;
-
-        spin_lock_init(&peer->stp_lock);
-        CFS_INIT_LIST_HEAD(&peer->stp_rpcq);
-        CFS_INIT_LIST_HEAD(&peer->stp_ctl_rpcq);
-        return peer;
-}
-
-srpc_peer_t *
-srpc_find_peer_locked (lnet_nid_t nid)
-{
-        struct list_head *peer_list = srpc_nid2peerlist(nid);
-        srpc_peer_t      *peer;
-
-        LASSERT (nid != LNET_NID_ANY);
-
-        list_for_each_entry (peer, peer_list, stp_list) {
-                if (peer->stp_nid == nid)
-                        return peer;
-        }
-
-        return NULL;
-}
-
-static srpc_peer_t *
-srpc_nid2peer (lnet_nid_t nid)
-{
-        srpc_peer_t *peer;
-        srpc_peer_t *new_peer;
-
-        spin_lock(&srpc_data.rpc_glock);
-        peer = srpc_find_peer_locked(nid);
-        spin_unlock(&srpc_data.rpc_glock);
-
-        if (peer != NULL)
-                return peer;
-
-        new_peer = srpc_create_peer(nid);
-
-        spin_lock(&srpc_data.rpc_glock);
-
-        peer = srpc_find_peer_locked(nid);
-        if (peer != NULL) {
-                spin_unlock(&srpc_data.rpc_glock);
-                if (new_peer != NULL)
-                        LIBCFS_FREE(new_peer, sizeof(srpc_peer_t));
-
-                return peer;
-        }
-
-        if (new_peer == NULL) {
-                spin_unlock(&srpc_data.rpc_glock);
-                return NULL;
-        }
-
-        list_add_tail(&new_peer->stp_list, srpc_nid2peerlist(nid));
-        spin_unlock(&srpc_data.rpc_glock);
-        return new_peer;
-}
-
 static inline __u64
 srpc_next_id (void)
 {
@@ -606,10 +514,10 @@ srpc_finish_service (srpc_service_t *sv)
                         rpc = list_entry(sv->sv_active_rpcq.next,
                                          srpc_server_rpc_t, srpc_list);
                         CDEBUG (D_NETERROR,
-                                "Active RPC on shutdown: sv %s, peer %s, "
+                                "Active RPC %p on shutdown: sv %s, peer %s, "
                                 "wi %s scheduled %d running %d, "
                                 "ev fired %d type %d status %d lnet %d\n",
-                                sv->sv_name, libcfs_id2str(rpc->srpc_peer),
+                                rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer),
                                 swi_state2str(rpc->srpc_wi.wi_state),
                                 rpc->srpc_wi.wi_scheduled,
                                 rpc->srpc_wi.wi_running,
@@ -670,6 +578,42 @@ free:
         spin_lock(&sv->sv_lock);
 }
 
+/* called with srpc_service_t::sv_lock held */
+inline void
+srpc_schedule_server_rpc (srpc_server_rpc_t *rpc)
+{
+        srpc_service_t *sv = rpc->srpc_service;
+
+        if (sv->sv_id > SRPC_FRAMEWORK_SERVICE_MAX_ID)
+                swi_schedule_workitem(&rpc->srpc_wi);
+        else    /* framework RPCs are handled one by one */
+                swi_schedule_serial_workitem(&rpc->srpc_wi);
+
+        return;
+}
+
+void
+srpc_abort_service (srpc_service_t *sv)
+{
+        srpc_server_rpc_t *rpc;
+
+        spin_lock(&sv->sv_lock);
+
+        CDEBUG(D_NET, "Aborting service: id %d, name %s\n",
+               sv->sv_id, sv->sv_name);
+
+        /* schedule in-flight RPCs to notice the abort, NB:
+         * racing with incoming RPCs; complete fix should make test
+         * RPCs carry session ID in its headers */
+        list_for_each_entry (rpc, &sv->sv_active_rpcq, srpc_list) {
+                rpc->srpc_aborted = 1;
+                srpc_schedule_server_rpc(rpc);
+        }
+
+        spin_unlock(&sv->sv_lock);
+        return;
+}
+
 void
 srpc_shutdown_service (srpc_service_t *sv)
 {
@@ -678,14 +622,14 @@ srpc_shutdown_service (srpc_service_t *sv)
 
         spin_lock(&sv->sv_lock);
 
-        CDEBUG (D_NET, "Shutting down service: id %d, name %s\n",
-                sv->sv_id, sv->sv_name);
+        CDEBUG(D_NET, "Shutting down service: id %d, name %s\n",
+               sv->sv_id, sv->sv_name);
 
         sv->sv_shuttingdown = 1; /* i.e. no new active RPC */
 
         /* schedule in-flight RPCs to notice the shutdown */
         list_for_each_entry (rpc, &sv->sv_active_rpcq, srpc_list) {
-                swi_schedule_workitem(&rpc->srpc_wi);
+                srpc_schedule_server_rpc(rpc);
         }
 
         spin_unlock(&sv->sv_lock);
@@ -809,20 +753,6 @@ srpc_do_bulk (srpc_server_rpc_t *rpc)
         return rc;
 }
 
-/* called with srpc_service_t::sv_lock held */
-inline void
-srpc_schedule_server_rpc (srpc_server_rpc_t *rpc)
-{
-        srpc_service_t *sv = rpc->srpc_service;
-
-        if (sv->sv_id > SRPC_FRAMEWORK_SERVICE_MAX_ID)
-                swi_schedule_workitem(&rpc->srpc_wi);
-        else    /* framework RPCs are handled one by one */
-                swi_schedule_serial_workitem(&rpc->srpc_wi);
-
-        return;
-}
-
 /* only called from srpc_handle_rpc */
 void
 srpc_server_rpc_done (srpc_server_rpc_t *rpc, int status)
@@ -835,8 +765,8 @@ srpc_server_rpc_done (srpc_server_rpc_t *rpc, int status)
         rpc->srpc_status = status;
 
         CDEBUG (status == 0 ? D_NET : D_NETERROR,
-                "Server RPC done: service %s, peer %s, status %s:%d\n",
-                sv->sv_name, libcfs_id2str(rpc->srpc_peer),
+                "Server RPC %p done: service %s, peer %s, status %s:%d\n",
+                rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer),
                 swi_state2str(rpc->srpc_wi.wi_state), status);
 
         if (status != 0) {
@@ -898,7 +828,7 @@ srpc_handle_rpc (swi_workitem_t *wi)
 
         spin_lock(&sv->sv_lock);
 
-        if (sv->sv_shuttingdown) {
+        if (sv->sv_shuttingdown || rpc->srpc_aborted) {
                 spin_unlock(&sv->sv_lock);
 
                 if (rpc->srpc_bulk != NULL)
@@ -956,8 +886,7 @@ srpc_handle_rpc (swi_workitem_t *wi)
                 }
         }
         case SWI_STATE_BULK_STARTED:
-                /* we cannot LASSERT ev_fired right here because it
-                 * may be set only upon an event with unlinked==1 */
+                LASSERT (rpc->srpc_bulk == NULL || ev->ev_fired);
 
                 if (rpc->srpc_bulk != NULL) {
                         rc = ev->ev_status;
@@ -966,20 +895,11 @@ srpc_handle_rpc (swi_workitem_t *wi)
                                 rc = (*sv->sv_bulk_ready) (rpc, rc);
 
                         if (rc != 0) {
-                                if (ev->ev_fired) {
-                                        srpc_server_rpc_done(rpc, rc);
-                                        return 1;
-                                }
-
-                                rpc->srpc_status = rc;
-                                wi->wi_state     = SWI_STATE_BULK_ERRORED;
-                                LNetMDUnlink(rpc->srpc_bulk->bk_mdh);
-                                return 0; /* wait for UNLINK event  */
+                                srpc_server_rpc_done(rpc, rc);
+                                return 1;
                         }
                 }
 
-                LASSERT (rpc->srpc_bulk == NULL || ev->ev_fired);
-
                 wi->wi_state = SWI_STATE_REPLY_SUBMITTED;
                 rc = srpc_send_reply(rpc);
                 if (rc == 0)
@@ -988,18 +908,17 @@ srpc_handle_rpc (swi_workitem_t *wi)
                 return 1;
 
         case SWI_STATE_REPLY_SUBMITTED:
-                LASSERT (ev->ev_fired);
+                if (!ev->ev_fired) {
+                        CERROR("RPC %p: bulk %p, service %d\n",
+                               rpc, rpc->srpc_bulk, rpc->srpc_service->sv_id);
+                        CERROR("Event: status %d, type %d, lnet %d\n",
+                               ev->ev_status, ev->ev_type, ev->ev_lnet);
+                        LASSERT (ev->ev_fired);
+                }
 
                 wi->wi_state = SWI_STATE_DONE;
                 srpc_server_rpc_done(rpc, ev->ev_status);
                 return 1;
-
-        case SWI_STATE_BULK_ERRORED:
-                LASSERT (rpc->srpc_bulk != NULL && ev->ev_fired);
-                LASSERT (rpc->srpc_status != 0);
-
-                srpc_server_rpc_done(rpc, rpc->srpc_status);
-                return 1;
         }
 
         return 0;
@@ -1073,43 +992,9 @@ srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc)
 }
 
 void
-srpc_check_sends (srpc_peer_t *peer, int credits)
-{
-        struct list_head  *q;
-        srpc_client_rpc_t *rpc;
-
-        LASSERT (credits >= 0);
-        LASSERT (srpc_data.rpc_state == SRPC_STATE_RUNNING);
-
-        spin_lock(&peer->stp_lock);
-        peer->stp_credits += credits;
-
-        while (peer->stp_credits) {
-                if (!list_empty(&peer->stp_ctl_rpcq))
-                        q = &peer->stp_ctl_rpcq;
-                else if (!list_empty(&peer->stp_rpcq))
-                        q = &peer->stp_rpcq;
-                else
-                        break;
-
-                peer->stp_credits--;
-
-                rpc = list_entry(q->next, srpc_client_rpc_t, crpc_privl);
-                list_del_init(&rpc->crpc_privl);
-                srpc_client_rpc_decref(rpc);  /* --ref for peer->*rpcq */
-
-                swi_schedule_workitem(&rpc->crpc_wi);
-        }
-
-        spin_unlock(&peer->stp_lock);
-        return;
-}
-
-void
 srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status)
 {
         swi_workitem_t *wi = &rpc->crpc_wi;
-        srpc_peer_t    *peer = rpc->crpc_peer;
 
         LASSERT (status != 0 || wi->wi_state == SWI_STATE_DONE);
 
@@ -1140,9 +1025,6 @@ srpc_client_rpc_done (srpc_client_rpc_t *rpc, int status)
         spin_unlock(&rpc->crpc_lock);
 
         (*rpc->crpc_done) (rpc);
-
-        if (peer != NULL)
-                srpc_check_sends(peer, 1);
         return;
 }
 
@@ -1285,38 +1167,9 @@ srpc_create_client_rpc (lnet_process_id_t peer, int service,
 }
 
 /* called with rpc->crpc_lock held */
-static inline void
-srpc_queue_rpc (srpc_peer_t *peer, srpc_client_rpc_t *rpc)
-{
-        int service = rpc->crpc_service;
-
-        LASSERT (peer->stp_nid == rpc->crpc_dest.nid);
-        LASSERT (srpc_data.rpc_state == SRPC_STATE_RUNNING);
-
-        rpc->crpc_peer = peer;
-
-        spin_lock(&peer->stp_lock);
-
-        /* Framework RPCs that alter session state shall take precedence
-         * over test RPCs and framework query RPCs */
-        if (service <= SRPC_FRAMEWORK_SERVICE_MAX_ID &&
-            service != SRPC_SERVICE_DEBUG &&
-            service != SRPC_SERVICE_QUERY_STAT)
-                list_add_tail(&rpc->crpc_privl, &peer->stp_ctl_rpcq);
-        else
-                list_add_tail(&rpc->crpc_privl, &peer->stp_rpcq);
-
-        srpc_client_rpc_addref(rpc); /* ++ref for peer->*rpcq */
-        spin_unlock(&peer->stp_lock);
-        return;
-}
-
-/* called with rpc->crpc_lock held */
 void
 srpc_abort_rpc (srpc_client_rpc_t *rpc, int why)
 {
-        srpc_peer_t *peer = rpc->crpc_peer;
-
         LASSERT (why != 0);
 
         if (rpc->crpc_aborted || /* already aborted */
@@ -1330,19 +1183,6 @@ srpc_abort_rpc (srpc_client_rpc_t *rpc, int why)
 
         rpc->crpc_aborted = 1;
         rpc->crpc_status  = why;
-
-        if (peer != NULL) {
-                spin_lock(&peer->stp_lock);
-
-                if (!list_empty(&rpc->crpc_privl)) { /* still queued */
-                        list_del_init(&rpc->crpc_privl);
-                        srpc_client_rpc_decref(rpc); /* --ref for peer->*rpcq */
-                        rpc->crpc_peer = NULL;       /* no credit taken */
-                }
-
-                spin_unlock(&peer->stp_lock);
-        }
-
         swi_schedule_workitem(&rpc->crpc_wi);
         return;
 }
@@ -1351,10 +1191,7 @@ srpc_abort_rpc (srpc_client_rpc_t *rpc, int why)
 void
 srpc_post_rpc (srpc_client_rpc_t *rpc)
 {
-        srpc_peer_t *peer;
-
         LASSERT (!rpc->crpc_aborted);
-        LASSERT (rpc->crpc_peer == NULL);
         LASSERT (srpc_data.rpc_state == SRPC_STATE_RUNNING);
         LASSERT ((rpc->crpc_bulk.bk_len & ~CFS_PAGE_MASK) == 0);
 
@@ -1363,18 +1200,7 @@ srpc_post_rpc (srpc_client_rpc_t *rpc)
                 rpc->crpc_timeout);
 
         srpc_add_client_rpc_timer(rpc);
-
-        peer = srpc_nid2peer(rpc->crpc_dest.nid);
-        if (peer == NULL) {
-                srpc_abort_rpc(rpc, -ENOMEM);
-                return;
-        }
-
-        srpc_queue_rpc(peer, rpc);
-
-        spin_unlock(&rpc->crpc_lock);
-        srpc_check_sends(peer, 0);
-        spin_lock(&rpc->crpc_lock);
+        swi_schedule_workitem(&rpc->crpc_wi);
         return;
 }
 
@@ -1433,7 +1259,6 @@ srpc_lnet_ev_handler (lnet_event_t *ev)
         srpc_service_t    *sv;
         srpc_msg_t        *msg;
         srpc_msg_type_t    type;
-        int                fired_flag = 1;
 
         LASSERT (!in_interrupt());
 
@@ -1447,6 +1272,8 @@ srpc_lnet_ev_handler (lnet_event_t *ev)
 
         switch (rpcev->ev_type) {
         default:
+                CERROR("Unknown event: status %d, type %d, lnet %d\n",
+                       rpcev->ev_status, rpcev->ev_type, rpcev->ev_lnet);
                 LBUG ();
         case SRPC_REQUEST_SENT:
                 if (ev->status == 0 && ev->type != LNET_EVENT_UNLINK) {
@@ -1458,9 +1285,16 @@ srpc_lnet_ev_handler (lnet_event_t *ev)
         case SRPC_BULK_REQ_RCVD:
                 crpc = rpcev->ev_data;
 
-                LASSERT (rpcev == &crpc->crpc_reqstev ||
-                         rpcev == &crpc->crpc_replyev ||
-                         rpcev == &crpc->crpc_bulkev);
+                if (rpcev != &crpc->crpc_reqstev &&
+                    rpcev != &crpc->crpc_replyev &&
+                    rpcev != &crpc->crpc_bulkev) {
+                        CERROR("rpcev %p, crpc %p, reqstev %p, replyev %p, bulkev %p\n",
+                               rpcev, crpc, &crpc->crpc_reqstev,
+                               &crpc->crpc_replyev, &crpc->crpc_bulkev);
+                        CERROR("Bad event: status %d, type %d, lnet %d\n",
+                               rpcev->ev_status, rpcev->ev_type, rpcev->ev_lnet);
+                        LBUG ();
+                }
 
                 spin_lock(&crpc->crpc_lock);
 
@@ -1545,13 +1379,9 @@ srpc_lnet_ev_handler (lnet_event_t *ev)
                          ev->type == LNET_EVENT_REPLY ||
                          ev->type == LNET_EVENT_UNLINK);
 
-                if (ev->type == LNET_EVENT_SEND && !ev->unlinked) {
-                        if (ev->status == 0)
-                                break; /* wait for the final LNET_EVENT_REPLY */
-                        else
-                                fired_flag = 0; /* LNET_EVENT_REPLY may arrive
-                                                   (optimized GET case) */
-                }
+                if (!ev->unlinked)
+                        break; /* wait for final event */
+
         case SRPC_BULK_PUT_SENT:
                 if (ev->status == 0 && ev->type != LNET_EVENT_UNLINK) {
                         spin_lock(&srpc_data.rpc_glock);
@@ -1570,13 +1400,12 @@ srpc_lnet_ev_handler (lnet_event_t *ev)
                 LASSERT (rpcev == &srpc->srpc_ev);
 
                 spin_lock(&sv->sv_lock);
-                if (fired_flag)
-                        rpcev->ev_fired  = 1;
 
+                rpcev->ev_fired  = 1;
                 rpcev->ev_status = (ev->type == LNET_EVENT_UNLINK) ?
                                                 -EINTR : ev->status;
-
                 srpc_schedule_server_rpc(srpc);
+
                 spin_unlock(&sv->sv_lock);
                 break;
         }
@@ -1614,21 +1443,8 @@ srpc_check_event (int timeout)
 int
 srpc_startup (void)
 {
-        int i;
         int rc;
 
-#ifndef __KERNEL__
-        char *s;
-
-        s = getenv("SRPC_PEER_CREDITS");
-        srpc_peer_credits = (s != NULL) ? atoi(s) : srpc_peer_credits;
-#endif
-
-        if (srpc_peer_credits <= 0) {
-                CERROR("Peer credits must be positive: %d\n", srpc_peer_credits);
-                return -EINVAL;
-        }
-
         memset(&srpc_data, 0, sizeof(struct smoketest_rpc));
         spin_lock_init(&srpc_data.rpc_glock);
 
@@ -1638,16 +1454,6 @@ srpc_startup (void)
 
         srpc_data.rpc_state = SRPC_STATE_NONE;
 
-        LIBCFS_ALLOC(srpc_data.rpc_peers,
-                     sizeof(struct list_head) * SRPC_PEER_HASH_SIZE);
-        if (srpc_data.rpc_peers == NULL) {
-                CERROR ("Failed to alloc peer hash.\n");
-                return -ENOMEM;
-        }
-
-        for (i = 0; i < SRPC_PEER_HASH_SIZE; i++)
-                CFS_INIT_LIST_HEAD(&srpc_data.rpc_peers[i]);
-
 #ifdef __KERNEL__
         rc = LNetNIInit(LUSTRE_SRV_LNET_PID);
 #else
@@ -1658,8 +1464,6 @@ srpc_startup (void)
 #endif
         if (rc < 0) {
                 CERROR ("LNetNIInit() has failed: %d\n", rc);
-                LIBCFS_FREE(srpc_data.rpc_peers,
-                            sizeof(struct list_head) * SRPC_PEER_HASH_SIZE);
                 return rc;
         }
 
@@ -1740,24 +1544,5 @@ srpc_shutdown (void)
                 break;
         }
 
-        /* srpc_peer_t's are kept in hash until shutdown */
-        for (i = 0; i < SRPC_PEER_HASH_SIZE; i++) {
-                srpc_peer_t *peer;
-
-                while (!list_empty(&srpc_data.rpc_peers[i])) {
-                        peer = list_entry(srpc_data.rpc_peers[i].next,
-                                          srpc_peer_t, stp_list);
-                        list_del(&peer->stp_list);
-
-                        LASSERT (list_empty(&peer->stp_rpcq));
-                        LASSERT (list_empty(&peer->stp_ctl_rpcq));
-                        LASSERT (peer->stp_credits == srpc_peer_credits);
-
-                        LIBCFS_FREE(peer, sizeof(srpc_peer_t));
-                }
-        }
-
-        LIBCFS_FREE(srpc_data.rpc_peers,
-                    sizeof(struct list_head) * SRPC_PEER_HASH_SIZE);
         return;
 }
diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h
index cdfa933..02af459 100644
--- a/lnet/selftest/selftest.h
+++ b/lnet/selftest/selftest.h
@@ -90,7 +90,6 @@ typedef struct { volatile int counter; } atomic_t;
 #define SWI_STATE_REQUEST_SENT             4
 #define SWI_STATE_REPLY_RECEIVED           5
 #define SWI_STATE_BULK_STARTED             6
-#define SWI_STATE_BULK_ERRORED             7
 #define SWI_STATE_DONE                     10
 
 /* forward refs */
@@ -210,13 +209,13 @@ srpc_service2reply (int service)
 }
 
 typedef enum {
-        SRPC_BULK_REQ_RCVD   = 0, /* passive bulk request(PUT sink/GET source) received */
-        SRPC_BULK_PUT_SENT   = 1, /* active bulk PUT sent (source) */
-        SRPC_BULK_GET_RPLD   = 2, /* active bulk GET replied (sink) */
-        SRPC_REPLY_RCVD      = 3, /* incoming reply received */
-        SRPC_REPLY_SENT      = 4, /* outgoing reply sent */
-        SRPC_REQUEST_RCVD    = 5, /* incoming request received */
-        SRPC_REQUEST_SENT    = 6, /* outgoing request sent */
+        SRPC_BULK_REQ_RCVD   = 1, /* passive bulk request(PUT sink/GET source) received */
+        SRPC_BULK_PUT_SENT   = 2, /* active bulk PUT sent (source) */
+        SRPC_BULK_GET_RPLD   = 3, /* active bulk GET replied (sink) */
+        SRPC_REPLY_RCVD      = 4, /* incoming reply received */
+        SRPC_REPLY_SENT      = 5, /* outgoing reply sent */
+        SRPC_REQUEST_RCVD    = 6, /* incoming request received */
+        SRPC_REQUEST_SENT    = 7, /* outgoing request sent */
 } srpc_event_type_t;
 
 /* RPC event */
@@ -241,15 +240,6 @@ typedef struct {
 #endif
 } srpc_bulk_t; /* bulk descriptor */
 
-typedef struct srpc_peer {
-        struct list_head stp_list;     /* chain on peer hash */
-        struct list_head stp_rpcq;     /* q of non-control RPCs */
-        struct list_head stp_ctl_rpcq; /* q of control RPCs */
-        spinlock_t       stp_lock;     /* serialize */
-        lnet_nid_t       stp_nid;
-        int              stp_credits;  /* available credits */
-} srpc_peer_t;
-
 /* message buffer descriptor */
 typedef struct {
         struct list_head     buf_list; /* chain on srpc_service::*_msgq */
@@ -272,6 +262,7 @@ typedef struct srpc_server_rpc {
         srpc_buffer_t       *srpc_reqstbuf;
         srpc_bulk_t         *srpc_bulk;
 
+        unsigned int         srpc_aborted; /* being given up */
         int                  srpc_status;
         void               (*srpc_done)(struct srpc_server_rpc *);
 } srpc_server_rpc_t;
@@ -279,7 +270,6 @@ typedef struct srpc_server_rpc {
 /* client-side state of a RPC */
 typedef struct srpc_client_rpc {
         struct list_head     crpc_list;   /* chain on user's lists */
-        struct list_head     crpc_privl;  /* chain on srpc_peer_t::*rpcq */
         spinlock_t           crpc_lock;   /* serialize */
         int                  crpc_service;
         atomic_t             crpc_refcount;
@@ -287,7 +277,6 @@ typedef struct srpc_client_rpc {
         stt_timer_t          crpc_timer;
         swi_workitem_t       crpc_wi;
         lnet_process_id_t    crpc_dest;
-        srpc_peer_t         *crpc_peer;
 
         void               (*crpc_done)(struct srpc_client_rpc *);
         void               (*crpc_fini)(struct srpc_client_rpc *);
@@ -360,7 +349,7 @@ typedef struct srpc_service {
         int                (*sv_bulk_ready) (srpc_server_rpc_t *, int);
 } srpc_service_t;
 
-#define SFW_POST_BUFFERS         8
+#define SFW_POST_BUFFERS         256
 #define SFW_SERVICE_CONCURRENCY  (SFW_POST_BUFFERS/2)
 
 typedef struct {
@@ -473,6 +462,7 @@ int srpc_send_reply(srpc_server_rpc_t *rpc);
 int srpc_add_service(srpc_service_t *sv);
 int srpc_remove_service(srpc_service_t *sv);
 void srpc_shutdown_service(srpc_service_t *sv);
+void srpc_abort_service(srpc_service_t *sv);
 int srpc_finish_service(srpc_service_t *sv);
 int srpc_service_add_buffers(srpc_service_t *sv, int nbuffer);
 void srpc_service_remove_buffers(srpc_service_t *sv, int nbuffer);
@@ -494,7 +484,6 @@ srpc_destroy_client_rpc (srpc_client_rpc_t *rpc)
 {
         LASSERT (rpc != NULL);
         LASSERT (!srpc_event_pending(rpc));
-        LASSERT (list_empty(&rpc->crpc_privl));
         LASSERT (atomic_read(&rpc->crpc_refcount) == 0);
 #ifndef __KERNEL__
         LASSERT (rpc->crpc_bulk.bk_pages == NULL);
@@ -521,7 +510,6 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer,
                                 crpc_bulk.bk_iovs[nbulkiov]));
 
         CFS_INIT_LIST_HEAD(&rpc->crpc_list);
-        CFS_INIT_LIST_HEAD(&rpc->crpc_privl);
         swi_init_workitem(&rpc->crpc_wi, rpc, srpc_send_rpc);
         spin_lock_init(&rpc->crpc_lock);
         atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */
@@ -562,7 +550,6 @@ swi_state2str (int state)
                 STATE2STR(SWI_STATE_REQUEST_SENT);
                 STATE2STR(SWI_STATE_REPLY_RECEIVED);
                 STATE2STR(SWI_STATE_BULK_STARTED);
-                STATE2STR(SWI_STATE_BULK_ERRORED);
                 STATE2STR(SWI_STATE_DONE);
         }
 #undef STATE2STR
diff --git a/lnet/selftest/workitem.c b/lnet/selftest/workitem.c
index cd65f5d..5e49b8b 100644
--- a/lnet/selftest/workitem.c
+++ b/lnet/selftest/workitem.c
@@ -218,14 +218,15 @@ swi_serial_scheduler_main (void *arg)
                 int             rc;
                 swi_workitem_t *wi;
 
-                while (!list_empty(&swi_data.wi_serial_runq) && 
+                while (!list_empty(&swi_data.wi_serial_runq) &&
                        nloops < SWI_RESCHED) {
                         wi = list_entry(swi_data.wi_serial_runq.next,
                                         swi_workitem_t, wi_list);
                         list_del_init(&wi->wi_list);
 
-                        LASSERT (!wi->wi_running);
-                        LASSERT (wi->wi_scheduled);
+                        LASSERTF (!wi->wi_running && wi->wi_scheduled,
+                                  "wi %p running %d scheduled %d\n",
+                                  wi, wi->wi_running, wi->wi_scheduled);
 
                         nloops++;
                         wi->wi_running   = 1;
@@ -243,7 +244,7 @@ swi_serial_scheduler_main (void *arg)
 
                 if (nloops < SWI_RESCHED)
                         wait_event_interruptible_exclusive(
-                             swi_data.wi_serial_waitq, 
+                             swi_data.wi_serial_waitq,
                              !swi_sched_cansleep(&swi_data.wi_serial_runq));
                 else
                         our_cond_resched();
diff --git a/lnet/ulnds/autoMakefile.in b/lnet/ulnds/autoMakefile.in
index dee232b..300cda8 100644
--- a/lnet/ulnds/autoMakefile.in
+++ b/lnet/ulnds/autoMakefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/ulnds/ptllnd/Makefile.in b/lnet/ulnds/ptllnd/Makefile.in
index 97d3552..71d44d7 100644
--- a/lnet/ulnds/ptllnd/Makefile.in
+++ b/lnet/ulnds/ptllnd/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/ulnds/ptllnd/ptllnd.c b/lnet/ulnds/ptllnd/ptllnd.c
index 3b504e7..c0fc41a 100644
--- a/lnet/ulnds/ptllnd/ptllnd.c
+++ b/lnet/ulnds/ptllnd/ptllnd.c
@@ -292,9 +292,8 @@ ptllnd_get_tunables(lnet_ni_t *ni)
                                       "PTLLND_PEERCREDITS", PTLLND_PEERCREDITS);
         if (rc != 0)
                 return rc;
-        /* kptl_msg_t::ptlm_credits is only a __u8 */
-        if (plni->plni_peer_credits > 255) {
-                CERROR("PTLLND_PEERCREDITS must be <= 255\n");
+        if (plni->plni_peer_credits > PTLLND_MSG_MAX_CREDITS) {
+                CERROR("PTLLND_PEERCREDITS must be <= %d\n", PTLLND_MSG_MAX_CREDITS);
                 return -EINVAL;
         }
 
diff --git a/lnet/ulnds/ptllnd/ptllnd_cb.c b/lnet/ulnds/ptllnd/ptllnd_cb.c
index c8431df..9cfa071 100644
--- a/lnet/ulnds/ptllnd/ptllnd_cb.c
+++ b/lnet/ulnds/ptllnd/ptllnd_cb.c
@@ -875,9 +875,10 @@ ptllnd_check_sends(ptllnd_peer_t *peer)
                 /*
                  * Return all the credits we have
                  */
-                tx->tx_msg.ptlm_credits = peer->plp_outstanding_credits;
-                peer->plp_sent_credits += peer->plp_outstanding_credits;
-                peer->plp_outstanding_credits = 0;
+                tx->tx_msg.ptlm_credits = MIN(PTLLND_MSG_MAX_CREDITS,
+                                              peer->plp_outstanding_credits);
+                peer->plp_sent_credits += tx->tx_msg.ptlm_credits;
+                peer->plp_outstanding_credits -= tx->tx_msg.ptlm_credits;
 
                 /*
                  * One less credit
diff --git a/lnet/ulnds/socklnd/Makefile.in b/lnet/ulnds/socklnd/Makefile.in
index 1df51f9..2ddc554 100644
--- a/lnet/ulnds/socklnd/Makefile.in
+++ b/lnet/ulnds/socklnd/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/ulnds/socklnd/conn.c b/lnet/ulnds/socklnd/conn.c
index 76ab468..d7e5969 100644
--- a/lnet/ulnds/socklnd/conn.c
+++ b/lnet/ulnds/socklnd/conn.c
@@ -128,6 +128,8 @@ usocklnd_tear_peer_conn(usock_conn_t *conn)
         lnet_process_id_t id;
         int               decref_flag  = 0;
         int               killall_flag = 0;
+        void             *rx_lnetmsg   = NULL; 
+        CFS_LIST_HEAD    (zombie_txs);
         
         if (peer == NULL) /* nothing to tear */
                 return;
@@ -142,11 +144,12 @@ usocklnd_tear_peer_conn(usock_conn_t *conn)
                 if (conn->uc_rx_state == UC_RX_LNET_PAYLOAD) {
                         /* change state not to finalize twice */
                         conn->uc_rx_state = UC_RX_KSM_HEADER;
-                        lnet_finalize(peer->up_ni, conn->uc_rx_lnetmsg, -EIO);                        
+                        /* stash lnetmsg while holding locks */
+                        rx_lnetmsg = conn->uc_rx_lnetmsg;
                 }
                 
-                usocklnd_destroy_txlist(peer->up_ni,
-                                        &conn->uc_tx_list);
+                /* we cannot finilize txs right now (bug #18844) */
+                list_splice_init(&conn->uc_tx_list, &zombie_txs);
 
                 peer->up_conns[idx] = NULL;
                 conn->uc_peer = NULL;
@@ -154,6 +157,9 @@ usocklnd_tear_peer_conn(usock_conn_t *conn)
 
                 if(conn->uc_errored && !peer->up_errored)
                         peer->up_errored = killall_flag = 1;
+
+                /* prevent queueing new txs to this conn */
+                conn->uc_errored = 1;
         }
         
         pthread_mutex_unlock(&conn->uc_lock);
@@ -166,6 +172,11 @@ usocklnd_tear_peer_conn(usock_conn_t *conn)
         if (!decref_flag)
                 return;
 
+        if (rx_lnetmsg != NULL)
+                lnet_finalize(ni, rx_lnetmsg, -EIO);
+        
+        usocklnd_destroy_txlist(ni, &zombie_txs);
+
         usocklnd_conn_decref(conn);
         usocklnd_peer_decref(peer);
 
@@ -392,15 +403,6 @@ usocklnd_set_sock_options(int fd)
         return libcfs_fcntl_nonblock(fd);
 }
 
-void
-usocklnd_init_msg(ksock_msg_t *msg, int type)
-{
-        msg->ksm_type           = type;
-        msg->ksm_csum           = 0;
-        msg->ksm_zc_req_cookie  = 0;
-        msg->ksm_zc_ack_cookie  = 0;
-}
-
 usock_tx_t *
 usocklnd_create_noop_tx(__u64 cookie)
 {
@@ -413,8 +415,8 @@ usocklnd_create_noop_tx(__u64 cookie)
         tx->tx_size = sizeof(usock_tx_t);
         tx->tx_lnetmsg = NULL;
 
-        usocklnd_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP);
-        tx->tx_msg.ksm_zc_ack_cookie = cookie;
+        socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP);
+        tx->tx_msg.ksm_zc_cookies[1] = cookie;
         
         tx->tx_iova[0].iov_base = (void *)&tx->tx_msg;
         tx->tx_iova[0].iov_len = tx->tx_resid = tx->tx_nob =
@@ -447,7 +449,7 @@ usocklnd_create_tx(lnet_msg_t *lntmsg)
                 offsetof(ksock_msg_t,  ksm_u.lnetmsg.ksnm_payload) +
                 payload_nob;
         
-        usocklnd_init_msg(&tx->tx_msg, KSOCK_MSG_LNET);
+        socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_LNET);
         tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = lntmsg->msg_hdr;
         tx->tx_iova[0].iov_base = (void *)&tx->tx_msg;
         tx->tx_iova[0].iov_len = offsetof(ksock_msg_t,
@@ -861,6 +863,13 @@ usocklnd_find_or_create_conn(usock_peer_t *peer, int type,
 
         LASSERT(tx == NULL || zc_ack == NULL);
         if (tx != NULL) {
+                /* usocklnd_tear_peer_conn() could signal us stop queueing */
+                if (conn->uc_errored) {
+                        rc = -EIO;
+                        pthread_mutex_unlock(&conn->uc_lock);
+                        goto find_or_create_conn_failed;
+                }
+
                 usocklnd_enqueue_tx(conn, tx, send_immediately);
         } else {
                 rc = usocklnd_enqueue_zcack(conn, zc_ack);        
diff --git a/lnet/ulnds/socklnd/handlers.c b/lnet/ulnds/socklnd/handlers.c
index e9fc984..91fe30c 100644
--- a/lnet/ulnds/socklnd/handlers.c
+++ b/lnet/ulnds/socklnd/handlers.c
@@ -153,13 +153,13 @@ usocklnd_read_msg(usock_conn_t *conn, int *cont_flag)
                 if (conn->uc_flip) {
                         __swab32s(&conn->uc_rx_msg.ksm_type);
                         __swab32s(&conn->uc_rx_msg.ksm_csum);
-                        __swab64s(&conn->uc_rx_msg.ksm_zc_req_cookie);
-                        __swab64s(&conn->uc_rx_msg.ksm_zc_ack_cookie);
+                        __swab64s(&conn->uc_rx_msg.ksm_zc_cookies[0]);
+                        __swab64s(&conn->uc_rx_msg.ksm_zc_cookies[1]);
                 } 
 
                 /* we never send packets for wich zc-acking is required */
                 if (conn->uc_rx_msg.ksm_type != KSOCK_MSG_LNET ||
-                    conn->uc_rx_msg.ksm_zc_ack_cookie != 0) {
+                    conn->uc_rx_msg.ksm_zc_cookies[1] != 0) {
                         conn->uc_errored = 1;
                         return -EPROTO;
                 }
@@ -230,7 +230,7 @@ usocklnd_read_msg(usock_conn_t *conn, int *cont_flag)
 
                 lnet_finalize(conn->uc_peer->up_ni, conn->uc_rx_lnetmsg, 0);
 
-                cookie = conn->uc_rx_msg.ksm_zc_req_cookie;
+                cookie = conn->uc_rx_msg.ksm_zc_cookies[0];
                 if (cookie != 0)
                         rc = usocklnd_handle_zc_req(conn->uc_peer, cookie);
                 
@@ -742,7 +742,7 @@ usocklnd_try_piggyback(struct list_head *tx_list_p,
                 list_del(&tx->tx_list);
 
                 /* already piggybacked or partially send */
-                if (tx->tx_msg.ksm_zc_ack_cookie ||
+                if (tx->tx_msg.ksm_zc_cookies[1] != 0 ||
                     tx->tx_resid != tx->tx_nob)
                         return tx;
         }
@@ -758,7 +758,7 @@ usocklnd_try_piggyback(struct list_head *tx_list_p,
                 
         if (tx != NULL)
                 /* piggyback the zc-ack cookie */
-                tx->tx_msg.ksm_zc_ack_cookie = zc_ack->zc_cookie;
+                tx->tx_msg.ksm_zc_cookies[1] = zc_ack->zc_cookie;
         else
                 /* cannot piggyback, need noop */
                 tx = usocklnd_create_noop_tx(zc_ack->zc_cookie);                     
@@ -999,7 +999,8 @@ usocklnd_read_data(usock_conn_t *conn)
                 
                 nob = libcfs_sock_readv(conn->uc_fd, conn->uc_rx_iov, conn->uc_rx_niov);                
                 if (nob <= 0) {/* read nothing or error */
-                        conn->uc_errored = 1;
+                        if (nob < 0)
+                                conn->uc_errored = 1;
                         return nob;
                 }
                 
diff --git a/lnet/ulnds/socklnd/poll.c b/lnet/ulnds/socklnd/poll.c
index 3388d85..1c16b5a 100644
--- a/lnet/ulnds/socklnd/poll.c
+++ b/lnet/ulnds/socklnd/poll.c
@@ -113,7 +113,7 @@ usocklnd_poll_thread(void *arg)
                           pt_data->upt_nfds,
                           usock_tuns.ut_poll_timeout * 1000);
 
-                if (rc < 0) {
+                if (rc < 0 && errno != EINTR) {
                         CERROR("Cannot poll(2): errno=%d\n", errno);
                         break;
                 }
diff --git a/lnet/ulnds/socklnd/usocklnd.h b/lnet/ulnds/socklnd/usocklnd.h
index a7fc493..82680ba 100644
--- a/lnet/ulnds/socklnd/usocklnd.h
+++ b/lnet/ulnds/socklnd/usocklnd.h
@@ -324,7 +324,6 @@ int usocklnd_create_active_conn(usock_peer_t *peer, int type,
 int usocklnd_connect_srv_mode(int *fdp, __u32 dst_ip, __u16 dst_port);
 int usocklnd_connect_cli_mode(int *fdp, __u32 dst_ip, __u16 dst_port);
 int usocklnd_set_sock_options(int fd);
-void usocklnd_init_msg(ksock_msg_t *msg, int type);
 usock_tx_t *usocklnd_create_noop_tx(__u64 cookie);
 usock_tx_t *usocklnd_create_tx(lnet_msg_t *lntmsg);
 void usocklnd_init_hello_msg(ksock_hello_msg_t *hello,
diff --git a/lnet/utils/Makefile.in b/lnet/utils/Makefile.in
index bfe9650..22382f0 100644
--- a/lnet/utils/Makefile.in
+++ b/lnet/utils/Makefile.in
@@ -218,9 +218,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lnet/utils/debug.c b/lnet/utils/debug.c
index e0128a3..973cac0 100644
--- a/lnet/utils/debug.c
+++ b/lnet/utils/debug.c
@@ -631,7 +631,7 @@ int jt_dbg_debug_kernel(int argc, char **argv)
                 return 1;
         }
         if (argc > 1) {
-                fdout = open(argv[1], O_WRONLY | O_CREAT);
+                fdout = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC);
                 if (fdout < 0) {
                         fprintf(stderr, "fopen(%s) failed: %s\n", argv[1],
                                 strerror(errno));
diff --git a/lnet/utils/nidstrings.c b/lnet/utils/nidstrings.c
index 796e1b9..048c23b 100644
--- a/lnet/utils/nidstrings.c
+++ b/lnet/utils/nidstrings.c
@@ -415,7 +415,7 @@ libcfs_nid2str(lnet_nid_t nid)
 static struct netstrfns *
 libcfs_str2net_internal(const char *str, __u32 *net)
 {
-        struct netstrfns *nf;
+        struct netstrfns *nf = NULL;
         int               nob;
         int               netnum;
         int               i;
diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c
index fc700c3..9d043b7 100644
--- a/lnet/utils/portals.c
+++ b/lnet/utils/portals.c
@@ -813,6 +813,10 @@ jt_ptl_print_connections (int argc, char **argv)
                         printf ("%-20s [%d]\n",
                                 libcfs_nid2str(data.ioc_nid),
                                 data.ioc_u32[0] /* device id */);
+                } else if (g_net_is_compatible (NULL, O2IBLND, 0)) {
+                        printf ("%s mtu %d\n",
+                                libcfs_nid2str(data.ioc_nid),
+                                data.ioc_u32[0]); /* path MTU */
                 } else {
                         printf ("%s\n", libcfs_nid2str(data.ioc_nid));
                 }
diff --git a/lnet/utils/wirecheck.c b/lnet/utils/wirecheck.c
index 6afd4dc..8da2aeb 100644
--- a/lnet/utils/wirecheck.c
+++ b/lnet/utils/wirecheck.c
@@ -34,6 +34,10 @@
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/wait.h>
diff --git a/lustre.spec b/lustre.spec
index 418ba57..e0579aa 100644
--- a/lustre.spec
+++ b/lustre.spec
@@ -1,11 +1,17 @@
 # lustre.spec
-%define version 1.6.7.2
-%define kversion 
+%{!?version: %define version 1.8.1}
+%{!?kversion: %define kversion }
+%{!?release: %define release }
+%{!?lustre_name: %define lustre_name lustre}
+
+%define is_client %(bash -c "if [[ %{lustre_name} = *-client ]]; then echo -n '1'; else echo -n '0'; fi")
+# for those uses that don't want the -smp/-bigsmp on the end of %kversion
+%define krequires %(bash -c "echo %{kversion} | sed -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
 
 Summary: Lustre File System
-Name: lustre
+Name: %{lustre_name}
 Version: %{version}
-Release: 
+Release: %{release}
 License: GPL
 Group: Utilities/System
 Source: lustre-%{version}.tar.gz
@@ -13,6 +19,7 @@ URL: http://www.sun.com/software/products/lustre/index.xml
 BuildRoot: %{_tmppath}/lustre-%{version}-root
 Obsoletes: lustre-lite, lustre-lite-utils, lustre-ldap nfs-utils-lustre
 Provides: lustre-lite = %{version}, lustre-lite-utils = %{version}
+Requires: %{name}-modules = %{version}
 # GSS requires this: BuildRequires: pkgconfig, libgssapi-devel >= 0.10
 
 %description
@@ -20,7 +27,7 @@ Userspace tools and files for the Lustre file system.
 
 %package modules
 Summary: Kernel Lustre modules for Linux %{kversion}
-Requires: modutils >= 2.4.10
+Requires: modutils >= 2.4.10, kernel = %{krequires}
 Group: Development/Kernel
 
 %description modules
@@ -51,8 +58,8 @@ Lustre sources for further development
 Summary: Lustre dependencies meta-package for SLES
 Group: Utilities/System
 Provides: lustre-deps = %{version}
-Requires: lustre = %{version}, sles-release
-Conflicts: lustre-deps-rhel
+Requires: %{name} = %{version}, sles-release
+Conflicts: %{name}-deps-rhel
 
 %description deps-sles
 This package has RPM dependencies appropriate for SLES systems.
@@ -61,8 +68,8 @@ This package has RPM dependencies appropriate for SLES systems.
 Summary: Lustre dependencies meta-package for RHEL
 Group: Utilities/System
 Provides: lustre-deps = %{version}
-Requires: lustre = %{version}, redhat-release
-Conflicts: lustre-deps-sles
+Requires: %{name} = %{version}, redhat-release
+Conflicts: %{name}-deps-sles
 
 %description deps-rhel
 This package has RPM dependencies appropriate for RHEL, RHL, and FC
@@ -71,8 +78,8 @@ systems.
 %package tests
 Summary: Lustre testing framework
 Group: Development/Kernel
-Provides: lustre-tests = %{version}
-Requires: lustre = %{version}, lustre-modules = %{version}
+Provides: %{name}-tests = %{version}
+Requires: %{name} = %{version}, %{name}-modules = %{version}
 
 %description tests
 This package contains a set of test binaries and scripts that are intended
@@ -131,7 +138,7 @@ cat >lustre.files <<EOF
 %attr(-, root, root) /usr/sbin/*
 %attr(-, root, root) /usr/bin/*
 
-%attr(-, root, root) /usr/share/lustre/*
+%attr(-, root, root) /usr/share/lustre
 
 %attr(-, root, root) %{_libdir}/libptlctl.a
 %attr(-, root, root) %{_libdir}/liblustreapi.a
@@ -232,6 +239,21 @@ do
 	fi
 done
 
+# If the kernel was built to reject unsupported modules (e.g. not a Lustre
+# kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
+# print a warning so that users are aware of this issue.
+if sysctl kernel.unsupported >/dev/null 2>&1 &&
+   [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
+    ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
+     echo "
+     warning: the Lustre modules are not supported by Novell. To use Lustre
+              on this system, you should put
+
+     allow_unsupported_modules 1
+
+     into /etc/modprobe.d/unsupported_modules"
+fi
+
 %postun modules
 if [ -f /boot/System.map-%{kversion} ]; then
 	depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
diff --git a/lustre.spec.in b/lustre.spec.in
index 1cd2ddd..6013892 100644
--- a/lustre.spec.in
+++ b/lustre.spec.in
@@ -1,11 +1,17 @@
 # lustre.spec
-%define version @VERSION@
-%define kversion @LINUXRELEASE@
+%{!?version: %define version @VERSION@}
+%{!?kversion: %define kversion @LINUXRELEASE@}
+%{!?release: %define release @RELEASE@}
+%{!?lustre_name: %define lustre_name lustre}
+
+%define is_client %(bash -c "if [[ %{lustre_name} = *-client ]]; then echo -n '1'; else echo -n '0'; fi")
+# for those uses that don't want the -smp/-bigsmp on the end of %kversion
+%define krequires %(bash -c "echo %{kversion} | sed -e 's/-smp$//' -e 's/-bigsmp$//' -e 's/-ppc64$//' -e 's/-default$//'")
 
 Summary: Lustre File System
-Name: lustre
+Name: %{lustre_name}
 Version: %{version}
-Release: @RELEASE@
+Release: %{release}
 License: GPL
 Group: Utilities/System
 Source: lustre-%{version}.tar.gz
@@ -13,6 +19,7 @@ URL: http://www.sun.com/software/products/lustre/index.xml
 BuildRoot: %{_tmppath}/lustre-%{version}-root
 Obsoletes: lustre-lite, lustre-lite-utils, lustre-ldap nfs-utils-lustre
 Provides: lustre-lite = %{version}, lustre-lite-utils = %{version}
+Requires: %{name}-modules = %{version}
 # GSS requires this: BuildRequires: pkgconfig, libgssapi-devel >= 0.10
 
 %description
@@ -20,7 +27,7 @@ Userspace tools and files for the Lustre file system.
 
 %package modules
 Summary: Kernel Lustre modules for Linux %{kversion}
-Requires: modutils >= 2.4.10
+Requires: modutils >= 2.4.10, kernel = %{krequires}
 Group: Development/Kernel
 
 %description modules
@@ -51,8 +58,8 @@ Lustre sources for further development
 Summary: Lustre dependencies meta-package for SLES
 Group: Utilities/System
 Provides: lustre-deps = %{version}
-Requires: lustre = %{version}, sles-release
-Conflicts: lustre-deps-rhel
+Requires: %{name} = %{version}, sles-release
+Conflicts: %{name}-deps-rhel
 
 %description deps-sles
 This package has RPM dependencies appropriate for SLES systems.
@@ -61,8 +68,8 @@ This package has RPM dependencies appropriate for SLES systems.
 Summary: Lustre dependencies meta-package for RHEL
 Group: Utilities/System
 Provides: lustre-deps = %{version}
-Requires: lustre = %{version}, redhat-release
-Conflicts: lustre-deps-sles
+Requires: %{name} = %{version}, redhat-release
+Conflicts: %{name}-deps-sles
 
 %description deps-rhel
 This package has RPM dependencies appropriate for RHEL, RHL, and FC
@@ -71,8 +78,8 @@ systems.
 %package tests
 Summary: Lustre testing framework
 Group: Development/Kernel
-Provides: lustre-tests = %{version}
-Requires: lustre = %{version}, lustre-modules = %{version}
+Provides: %{name}-tests = %{version}
+Requires: %{name} = %{version}, %{name}-modules = %{version}
 
 %description tests
 This package contains a set of test binaries and scripts that are intended
@@ -131,7 +138,7 @@ cat >lustre.files <<EOF
 %attr(-, root, root) /usr/sbin/*
 %attr(-, root, root) /usr/bin/*
 
-%attr(-, root, root) /usr/share/lustre/*
+%attr(-, root, root) /usr/share/lustre
 
 %attr(-, root, root) %{_libdir}/libptlctl.a
 %attr(-, root, root) %{_libdir}/liblustreapi.a
@@ -232,6 +239,21 @@ do
 	fi
 done
 
+# If the kernel was built to reject unsupported modules (e.g. not a Lustre
+# kernel), and this hasn't been overridden in /etc/modprobe.d yet, then
+# print a warning so that users are aware of this issue.
+if sysctl kernel.unsupported >/dev/null 2>&1 &&
+   [ "$(sysctl -n kernel.unsupported 2>/dev/null)" = "0" ] &&
+    ! modprobe -c | grep -q "^allow_unsupported_modules[ \t]1" ; then
+     echo "
+     warning: the Lustre modules are not supported by Novell. To use Lustre
+              on this system, you should put
+
+     allow_unsupported_modules 1
+
+     into /etc/modprobe.d/unsupported_modules"
+fi
+
 %postun modules
 if [ -f /boot/System.map-%{kversion} ]; then
 	depmod -ae -F /boot/System.map-%{kversion} %{kversion} || exit 0
diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 6267175..fb6be26 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -1,75 +1,254 @@
-2009-06-05 Sun Microsystems, Inc.
-        * version 1.6.7.2
-        * Support for kernels:
-	 2.6.5-7.314 (SLES 9),
-	 2.6.9-78.0.22.EL (RHEL 4),
-	 2.6.16.60-0.37 (SLES 10),
-	 2.6.18-92.1.26.el5 (RHEL 5),
-	 2.6.22.14 vanilla (kernel.org)
+2009-07-31 Sun Microsystems, Inc.
+	* version 1.8.1
+	* Support for kernels:
+	 2.6.16.60-0.39.3 (SLES 10),
+	 2.6.27.23-0.1 (SLES11, i686 & x84_64 only),
+	 2.6.18-128.1.14.el5 (RHEL 5),
 	* Client support for unpatched kernels:
 	  (see http://wiki.lustre.org/index.php?title=Patchless_Client)
-	  2.6.16 - 2.6.22 vanilla (kernel.org)
-	* Client support for unpatched kernels:
-	  we do not recommend using patchless RHEL4 clients with kernels
-	  prior to 2.6.9-55EL (RHEL4U5).
-	* Recommended e2fsprogs version: 1.40.11-sun1
-	* RHEL 4 and RHEL 5/SLES 10 clients behaves differently on 'cd' to a
-	  removed cwd "./" (refer to Bugzilla 14399).
-	* A new quota file format was introduced in 1.6.6 (for 2.6.16+ kernels).
-	  The format conversion from prior releases is handled transparently,
-	  but releases older than 1.6.6/1.8.0 don't understand this new
-	  format. The automatic format conversion can be avoided by running
-	  the following commands on the MDS and OSS servers (for
-	  pre 1.4.12-1.6.5 quota files):
-	  	'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV',
-		'tunefs.lustre --param="ost.quota_type=ug1" $MDTDEV'
-		or (for 1.4.12/1.6.5 quota files)
-		'tunefs.lustre --param="mdt.quota_type=ug2" $MDTDEV',
-		'tunefs.lustre --param="ost.quota_type=ug2" $MDTDEV'
-	  For more information, please refer to bugzilla 13904.
-	* Output of lfs quota has been made less detailed by default,
-	  old (verbose) output can be obtained by using -v option.
-	* File join has been disabled in this release, refer to Bugzilla
-	  16929.
-	* A new Lustre ADIO driver is available for MPICH2-1.0.7.
-	* NFS export disabled when stack size < 8192. Since the NFSv4 export of
-	  Lustre filesystem with 4K stack may cause a stack overflow. For more
-	  information, please refer to bugzilla 17630.
+	  2.6.16 - 2.6.27 vanilla (kernel.org)
+	* Recommended e2fsprogs version: 1.41.6.sun1
+	* File join has been disabled in this release, refer to Bugzilla 16929.
+	* NFS export disabled when stack size < 8192. Since the NFSv4 export
+	  of Lustre filesystem with 4K stack may cause a stack overflow. For
+	  more information, please refer to bugzilla 17630.
+	* ext4 support for RHEL5 is experimental and thus should not be
+	  used in production.
 
 Severity   : enhancement
-Bugzilla   : 19601
-Description: Update kernel to RHEL5.2 2.6.18-92.1.26.
+Bugzilla   : 19847
+Description: Update kernel to SLES10 SP2 2.6.16.60-0.39.3.
 
-Severity   : critical, only with RHEL4/SLES9 MDS
-Bugzilla   : 19453
-Description: user xattr corruption
-Details    : setting extended attributes can corrupt other attributes stored in
-	     the inode body. Both user & lustre internal (LOV EA) attributes
-	     are concerned. In the latter case, the lustre filesystem can be
-	     damaged.
+Severity   : normal
+Frequency  : with 1.8 server and 1.6 clients
+Bugzilla   : 20020
+Description: correctly shrink reply for avoid send too big message to client.
+Details    : 1.8 mds is allocate to big buffer to LOV EA data and this produce
+	     some problems with sending this reply to 1.6 client.
+
+Severity   : normal
+Bugzilla   : 19917
+Description: Repeated atomic allocation failures.
+Details    : Use GFP_HIGHUSER | __GFP_NOMEMALLOC flags for memory allocations 
+	     to generate memory pressure and allow reclaiming of inactive pages.
+	     At the same time, do not allow to exhaust emergency pools.
+	     For local clients the use of GFP_NOFS will be introduced in 1.8.2
 
 Severity   : enhancement
-Bugzilla   : 16504
-Description: Update kernel to RHEL4.7 2.6.9-78.0.22.
+Bugzilla   : 19846, 18289
+Description: Update kernel to RHEL5 2.6.18-128.1.14.el5.
 
 Severity   : enhancement
-Bugzilla   : 18289
-Description: allow the use of the kernel provided OFED stack
-Details    : This patch allows for lbuild to use the OFED stack provided
-	     by the kernel vendor.
-	     For the RHEL4 and RHEL5 kernels, we enable the kernel supplied
-	     OFED stack.
+Bugzilla   : 19625, 16893, 18668, 19848
+Description: Add support for SLES11 2.6.27.23-0.1.
 
 Severity   : enhancement
-Bugzilla   : 18775
-Description: improve lctl set/get_param
-Details    : handle the bad options, support more than one arguments,
-	     add '-F' option to append the indicator to the parameters.
+Bugzilla   : 14250
+Description: Update client support to vanila kernels up to 2.6.27.
 
 Severity   : enhancement
 Bugzilla   : 19212
 Description: Update kernel to SLES10 SP2 2.6.16.60-0.37.
 
+Severity   : enhancement
+Bugzilla   : 15981
+Description: Compile with -Werror by default for i686 and x86_64.
+
+Severity   : normal
+Bugzilla   : 19528
+Description: resolve race between obd_disconnect and class_disconnect_exports
+Details    : if obd_disconnect will be called to already disconnected export he
+	     forget release one reference and osc module can't unloaded.
+
+Severity   : enhancement
+Bugzilla   : 19293
+Description: move AT tunable parameters for more consistent usage
+Details    : add AT tunables under /proc/sys/lustre, add to conf_param parsing
+
+Severity   : normal
+Bugzilla   : 19223
+Descriptoin: correctly skip time estimate if in recovery
+Details    : rq_send_state insn't bitmask so using bitwise ops is forbid.
+
+Severity   : normal
+Bugzilla   : 18399
+Descriptoin: OSS DeadLock
+Details    : Use trylock to prevent deadlock when shrink icache.
+
+Severity   : enhancement
+Bugzilla   : 18688
+Description: Allow tuning service thread via /proc
+Details    : For each service a new
+	     /proc/fs/lustre/{service}/*/thread_{min,max,started} entry is
+	     created that can be used to set min/max thread counts, and get the
+	     current number of running threads.
+
+Severity   : enhancement
+Bugzilla   : 18798
+Description: Add state history info file, enhance import info file
+Details    : Track import connection state changes in a new osc/mdc proc file;
+	     add overview-type data to the osc/mdc import proc file.
+
+Severity   : normal
+Bugzilla   : 18645
+Description: Reduce small size read RPC
+Details    : Set read-ahead limite for every file and only do read-ahead when
+	     available read-ahead pages are bigger than 1M to avoid small size
+	     read RPC.
+
+Severity   : normal
+Bugzilla   : 18204
+Description: free_entry erroneously used groups_free instead of put_group_info
+
+Severity   : enhancement
+Bugzilla   : 17817
+Description: Make read-ahead stripe size aligned.
+
+Severity   : enhancement
+Bugzilla   : 17536
+Description: MDS create should not wait for statfs RPC while holding DLM lock.
+
+Severity   : normal
+Frequency  : rare, connect and disconnect target at same time
+Bugzilla   : 17310
+Descriptoin: ASSERTION(atomic_read(&imp->imp_inflight) == 0
+Details    : don't call obd_disconnect under lov_lock. this long time
+	     operation and can block ptlrpcd which answer to connect request.
+
+Severity   : normal
+Frequency  : start MDS on uncleanly shutdowned MDS device
+Bugzilla   : 16839
+Descriptoin: ll_sync thread stay in waiting mds<>ost recovery finished
+Details    : stay in waiting mds<>ost recovery finished produce random bugs
+	     due race between two ll_sync thread for one lov target. send
+	     ACTIVATE event only if connect realy finished and import have
+	     FULL state.
+
+Severity   : normal
+Frequency  : start MDS on uncleanly shutdowned MDS device
+Bugzilla   : 18049
+Descriptoin: aborting recovery hang on MDS
+Details    : don't throttle destroy RPCs for the MDT.
+
+Severity   : low
+Bugzilla   : 18016
+Description: Slow reads beyond 8Tb offsets.
+Details    : Page index integer overflow in ll_read_ahead_page
+
+Severity   : normal
+Bugzilla   : 18304
+Description: Soft lockup on OSS after MDS failover
+Details    : MSG_CONNECT_INITIAL is not set on the initial MDS->OST connect.
+	     As a conseqence, the patch from bug 18224 is not operational
+	     and the MDS export cannot be reused on the OSTs until it gets
+	     evicted.
+
+Severity   : major
+Frequency  : rare, only if using MMP with Linux RAID
+Bugzilla   : 17895
+Description: MMP doesn't work with Linux RAID
+Details    : While using HA for Lustre servers with Linux RAID, it is possible
+	     that MMP will not detect multiple mounts. To make this work we
+	     need to unplug the device queue in RAID when the MMP block is being
+	     written. Also while reading the MMP block, we should read it from
+	     disk and not the cached one.
+
+Severity   : minor
+Frequency  : rare, during recovery
+Bugzilla   : 17895
+Description: Assertion failure in ldlm_lock_put
+Details    : Do not put cancelled locks into replay list, hold references on
+	     locks in replay list
+
+Severity   : normal
+Bugzilla   : 18577
+Description: 1.6.5 mdsrate performance is slower than 1.4.11/12 (MDS is not cpu bound!)
+Details    : create_count always drops to the min value (=32) because grow_count
+	     is being changed before the precreate RPC completes.
+
+Severity   : normal
+Frequency  : Only in RHEL5 when mounting multiple ext3 filesystems
+	     simultaneously
+Bugzilla   : 19184
+Description: "kmem_cache_create: duplicate cache jbd_4k" error message
+Details    : add proper locking for creation of jbd_4k slab cache
+
+Severity   : normal
+Bugzilla   : 19058
+Description: MMP check in ext3_remount() fails without displaying any error
+Details    : When multiple mount protection fails during remount, proper error
+	     should be returned
+
+Severity   : Low
+Bugzilla   : 15010
+Description: Rare Client crash on resend if the file was deleted.
+Details    : When file is opened, but open reply is lost and file is
+	     subsequently deleted before resend, resend processing logic
+	     breaks trying to open the file again, should not try to open.
+
+Severity   : high
+Bugzilla   : 17569
+Description: add check for >8TB ldiskfs filesystems
+Details    : ext3-based ldiskfs does not support greater than 8TB LUNs.
+	     Don't allow >8TB ldiskfs filesystems to be mounted without
+	     force_over_8tb mount option
+
+Severity   : normal
+Bugzilla   : 20011
+Description: Client locked up when running multiple instances of an app. on
+	     multiple mount points
+Details    : ll_shrink_cache() can sleep while holding the ll_sb_lock.
+	     Convert ll_sb_lock to a read/write semaphore to fix the problem.
+
+Severity   : normal
+Bugzilla   : 19559
+Description: Cannot acces an NFS-mounted Lustre filesystem
+Details    : An NFS client cannot access the Lustre filesystem NFS-mounted
+	     from a Lustre-client exporting the Lustre filesystem via NFS.
+
+Severity   : normal
+Bugzilla   : 20139
+Description: panic in ll_statahead_thread
+Details    : grab dentry reference in parent process.
+
+-------------------------------------------------------------------------------
+
+tbd Sun Microsystems, Inc.
+        * version 1.8.0.1
+        * Support for kernels:
+         2.6.16.60-0.31 (SLES 10),
+         2.6.18-128.1.6.el5 (RHEL 5),
+         2.6.22.14 vanilla (kernel.org)
+        * Client support for unpatched kernels:
+          (see http://wiki.lustre.org/index.php?title=Patchless_Client)
+          2.6.16 - 2.6.22 vanilla (kernel.org)
+        * Recommended e2fsprogs version: 1.40.11-sun1
+        * File join has been disabled, refer to Bugzilla 16929.
+        * A new Lustre ADIO driver is available for MPICH2-1.0.7.
+        * NFS export disabled when stack size < 8192. Since the NFSv4 export of
+          Lustre filesystem with 4K stack may cause a stack overflow. For more
+          information, please refer to bugzilla 17630.
+
+Severity   : enhancement
+Bugzilla   : 19024
+Description: Update to RHEL5.3 kernel-2.6.18-128.1.6.el5.
+
+Severity   : enhancement
+Bugzilla   : 17671
+Description: Update OFED release to 1.4.1 RC4
+
+Severity   : major, only with big OST
+Bugzilla   : 18518
+Description: Very poor metadata performance on Infiniband lustre configuration
+Details    : OST object precreation becomes very slow on big OSTs. This is due
+	     to the ialloc patch spending too much time scanning groups.
+
+Severity   : normal
+Frequency  : during recovery
+Bugzilla   : 18192
+Description: don't mix llog inodes with normal.
+Details    : allocate inodes for log in last inode group
+
 Severity   : major
 Frequency  : rare
 Bugzilla   : 19495
@@ -85,10 +264,10 @@ Details    : This patch fixes:
                 -        if (!ll_sb_any_quota_active(qctxt->lqc_sb))
                 -                RETURN(0);
 
---------------------------------------------------------------------------
+-------------------------------------------------------------------------------
 
-2009-04-06 Sun Microsystems, Inc.
-	* version 1.6.7.1
+2008-12-31 Sun Microsystems, Inc.
+	* version 1.8.0
 	* Support for kernels:
 	 2.6.5-7.314 (SLES 9),
 	 2.6.9-67.0.22.EL (RHEL 4),
@@ -102,9 +281,17 @@ Details    : This patch fixes:
 	  we do not recommend using patchless RHEL4 clients with kernels
 	  prior to 2.6.9-55EL (RHEL4U5).
 	* Recommended e2fsprogs version: 1.40.11-sun1
+	* Note that reiserfs quotas are disabled on SLES 10 in this kernel.
 	* RHEL 4 and RHEL 5/SLES 10 clients behaves differently on 'cd' to a
 	  removed cwd "./" (refer to Bugzilla 14399).
-	* A new quota file format was introduced in 1.6.6 (for 2.6.16+ kernels).
+	* A new quota file format has been introduced in 1.6.5.
+	  The format conversion from prior releases is handled transparently,
+	  but releases older than 1.4.12/1.6.5 don't understand this new
+	  format. The automatic format conversion can be avoided by running
+	  the following command on the MDS:
+		'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV'.
+	  For more information, please refer to bugzilla 13904.
+	* A new quota file format was introduced in 1.6.6/1.8.0 (kernels 2.6.16+).
 	  The format conversion from prior releases is handled transparently,
 	  but releases older than 1.6.6/1.8.0 don't understand this new
 	  format. The automatic format conversion can be avoided by running
@@ -118,119 +305,81 @@ Details    : This patch fixes:
 	  For more information, please refer to bugzilla 13904.
 	* Output of lfs quota has been made less detailed by default,
 	  old (verbose) output can be obtained by using -v option.
-	* File join has been disabled in this release, refer to Bugzilla
-	  16929.
+	* File join has been disabled in this release, refer to Bugzilla 16929.
 	* A new Lustre ADIO driver is available for MPICH2-1.0.7.
 	* NFS export disabled when stack size < 8192. Since the NFSv4 export of
 	  Lustre filesystem with 4K stack may cause a stack overflow. For more
 	  information, please refer to bugzilla 17630.
 
-Severity   : minor
-Frequency  : common
-Bugzilla   : 18480
-Description: correct count of recoverable clients
-Details    : if recovery failed for client for some reasons (goal inode or
-	     something else) server can wait failed clients for finish recovery.
+Severity   : enhancement
+Bugzilla   : 12182
+Description: Caching OSS
+Details    : introduce data caching on the OSS. The OSS now relies on the linux
+	     kernel page cache to keep recently accessed data in memory.
+	     It is worth noting that all write requests are still flushed
+	     synchronously as in lustre 1.6.
 
-Severity   : critical
-Frequency  : when directories had atime set in past (e.g. untar)
-Bugzilla   : 18695
-Descriptoin: Lustre detected file system corruption with inode out of bounds
-Details    : don't update i_size on MDS_CLOSE for directories. This causes
-	     directory corruptions on the MDT.
+Severity   : enhancement
+Bugzilla   : 10609
+Description: Version based recovery
+Details    : introduce finer grained recovery able to detect transaction
+	     dependencies and can deal with transaction gaps caused by clients
+	     failing at the same time as the server.
 
-Severity   : major
-Frequency  : rare
-Bugzilla   : 18810
-Description: fix racy locking of mballoc block bitmaps causing BUG
-Details    : The locking of the mballoc buddy bitmap and the in-memory
-	     block bitmap was using two different spin locks in some
-	     cases.  This made it possible to incorrectly access the
-	     mballoc bitmap while another process was modifying it,
-	     causing a sanity assertion to fail.  While no on-disk corruption
-	     was reported, there was some risk of this happening.
+Severity   : enhancement
+Bugzilla   : 3055
+Description: Enable adaptive timeouts by default
+Details    : The Lustre timeout value in /proc/sys/lustre/timeout is now
+	     managed dynamically based on server load and should not need
+	     to be tuned manually based on cluster size. This allows Lustre
+	     to work under a wider variety of system sizes and loads, without
+	     unnecessarily causing lengthy recovery times.
 
-Severity   : normal
-Frequency  : on failed service startup
-Bugzilla   : 18895
-Description: replay-single test_61d: LustreError:
-	     17392:0:(lprocfs_status.c:859:lprocfs_obd_cleanup())
-	     ASSERTION(obd->obd_proc_exports_entry->subdir == NULL) failed
-Details    : cleanup lprocfs entries on error.
+Severity   : enhancement
+Bugzilla   : 15899
+Description: Add OST Pools support
+Details    : File striping can now be set to use an arbitrary pool of OSTs
+
+Severity   : enhancement
+Bugzilla   : 17974
+Description: add lazystatfs mount option to allow statfs(2) to skip down OSTs
+Details    : allow skip disconnected ost for send statfs request and hide error
+             in this case.
 
 Severity   : normal
-Frequency  : rare
-Bugzilla   : 18903
-Description: llmount.sh: BUG: spinlock wrong owner on CPU#0, mount.lustre/8180
-Details    : fix typo in import_set_conn() causing spinlock corruption.
+Frequency  : rare, on llog test 6
+Bugzilla   : 16839
+Descriptoin: don't allow connect to already connected import
+Details    : allowing connect to already connected import is hide connecting problem.
 
 Severity   : normal
-Frequency  : rare, only when using group lock on client
-Bugzilla   : 18859
-Description: Group Lock in Lustre: write call is blocking
-Details    : fix wrong return code of ll_is_file_contended() causing processes
-	     to be blocked indefinitely.
+Frequency  : rare, on failed llog setup
+Bugzilla   : 18896
+Descriptoin: don't leak obd reference on failed llog setup
+Details    : for failed llog setup - mgc forget call class_destroy_import for
+             client import, move destroy import to more generic place.
 
 Severity   : normal
 Frequency  : rare
-Bugzilla   : 17757
-Description: ASSERTION(new_lock != NULL) failed:op 0x1 lockh 0x0
-Details    : DISP_OPEN_LOCK is not cleared properly in reconstruct_open() since
-	     intent_disposition() is used instead of intent_set_disposition().
-
-Severity   : major
-Frequency  : occasional when using software RAID5
-Bugzilla   : 15428
-Description: raid5 panics
-Details    : fix panic in raid5_end_read_request().
+Bugzilla   : 18902
+Descriptoin: allow kill process which wait statahead result
+Details    : for some reasons 'ls' can stick in waiting result from statahead,
+             in this case need way for kill this process.
 
---------------------------------------------------------------------------
+Severity   : normal
+Frequency  : rare, at shutdown
+Bugzilla   : 18773
+Descriptoin: panic at umount
+Details    : llap_shrinker can be raced with killing super block from list and
+             this produce panic with access to already freeded pointer
 
-2009-02-07 Sun Microsystems, Inc.
-	* version 1.6.7
-	* Support for kernels:
-	 2.6.5-7.314 (SLES 9),
-	 2.6.9-67.0.22.EL (RHEL 4),
-	 2.6.16.60-0.31 (SLES 10),
-	 2.6.18-92.1.17.el5 (RHEL 5),
-	 2.6.22.14 vanilla (kernel.org)
-	* Client support for unpatched kernels:
-	  (see http://wiki.lustre.org/index.php?title=Patchless_Client)
-	  2.6.16 - 2.6.22 vanilla (kernel.org)
-	* Client support for unpatched kernels:
-	  we do not recommend using patchless RHEL4 clients with kernels
-	  prior to 2.6.9-55EL (RHEL4U5).
-	* Recommended e2fsprogs version: 1.40.11-sun1
-	* Note that reiserfs quotas are disabled on SLES 10 in this kernel.
-	* RHEL 4 and RHEL 5/SLES 10 clients behaves differently on 'cd' to a
-	  removed cwd "./" (refer to Bugzilla 14399).
-	* A new quota file format has been introduced in 1.6.5.
-	  The format conversion from prior releases is handled transparently,
-	  but releases older than 1.4.12/1.6.5 don't understand this new
-	  format. The automatic format conversion can be avoided by running
-	  the following command on the MDS:
-		'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV'.
-	  For more information, please refer to bugzilla 13904.
-	* A new quota file format was introduced in 1.6.6 (for 2.6.16+ kernels).
-	  The format conversion from prior releases is handled transparently,
-	  but releases older than 1.6.6/1.8.0 don't understand this new
-	  format. The automatic format conversion can be avoided by running
-	  the following commands on the MDS and OSS servers (for
-	  pre 1.4.12-1.6.5 quota files):
-		'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV',
-		'tunefs.lustre --param="ost.quota_type=ug1" $MDTDEV'
-		or (for 1.4.12/1.6.5 quota files)
-		'tunefs.lustre --param="mdt.quota_type=ug2" $MDTDEV',
-		'tunefs.lustre --param="ost.quota_type=ug2" $MDTDEV'
-	  For more information, please refer to bugzilla 13904.
-	* Output of lfs quota has been made less detailed by default,
-	  old (verbose) output can be obtained by using -v option.
-	* File join has been disabled in this release, refer to Bugzilla
-	  16929.
-	* A new Lustre ADIO driver is available for MPICH2-1.0.7.
-	* NFS export disabled when stack size < 8192. Since the NFSv4 export of
-	  Lustre filesystem with 4K stack may cause a stack overflow. For more
-	  information, please refer to bugzilla 17630.
+Severity   : normal
+Frequency  : rare
+Bugzilla   : 18154
+Descriptoin: don't lose wakeup for imp_recovery_waitq
+Details    : recover_import_no_retry or invalidate_import and import_close can
+             both sleep on imp_recovery_waitq, but we was send only one wakeup
+             to sleep queue.
 
 Severity   : normal
 Frequency  : rare
@@ -242,7 +391,7 @@ Severity   : normal
 Frequency  : rare
 Bugzilla   : 17972
 Descriptoin: stuck in cache_remove_extent() or panic with accessing to already
-             freed look.
+	     freed look.
 Details    : release lock refernce only after add page to pages list.
 
 Severity   : normal
@@ -252,17 +401,13 @@ Descriptoin: mds can't pack reply with long acl.
 Details    : mds don't control size of acl but they limited by reint/getattr
 	     reply buffer.
 
-Severity   : normal
-Frequency  : start MDS on uncleanly shutdowned MDS device
-Bugzilla   : 18049
-Descriptoin: aborting recovery hang on MDS
-Details    : don't throttle destroy RPCs for the MDT.
 
 Severity   : major
 Frequency  : on remount
 Bugzilla   : 18018
 Description: external journal device not working after the remount
-Details    : clear dev_rdonly flag for external journal devices in blkdev_put()
+Details    : clear dev_rdonly flag for external journal devices in
+	     blkdev_put()
 
 Severity   : minor
 Frequency  : rare
@@ -293,7 +438,7 @@ Bugzilla   : 17201
 Description: Update to RHEL5 kernel-2.6.18-92.1.17.el5.
 
 Severity   : normal
-Frequency  : rare, need ACLs on inode.
+Frequency  : rare, need acl's on inode.
 Bugzilla   : 16492
 Description: client can't handle ost additional correctly
 Details    : if ost was added after client connected to mds client can have
@@ -317,13 +462,13 @@ Details    : If there is no extra space in the request for early cancels,
 	     ldlm_req_handles_avail() returns 0 instead of a negative value.
 
 Severity   : major
-Frequency  : rare, during racing unlink and create in same directory
+Frequency  : rare
 Bugzilla   : 16492
 Description: mds is deadlocked
-Details    : in rare cases, inode in directory can have inode number lower than
-	     parent inode number.  This produces wrong locking order during
-	     open and parallel unlink.  Teach mds_open to grab locks in
-	     inode number order, not parent -> child order.
+Details    : in rare cases, inode in catalog can have i_no less than have parent
+	     i_no, this produce wrong order for locking during open, and
+	     parallel unlink can be lock open. this need teach mds_open to grab
+	     locks in resource id order, not at parent -> child order.
 
 Severity   : enhancement
 Bugzilla   : 1819
@@ -338,6 +483,13 @@ Description: Re-disable certain /proc logging
 Details    : Enable and disable client's offset_stats, extents_stats and
 	     extents_stats_per_process stats logging on the fly.
 
+Severity   : major
+Frequency  : Only on FC kernels 2.6.22+
+Bugzilla   : 16303
+Description: oops in statahead
+Details    : Do not drop reference count for the dentry from VFS when lookup,
+	     VFS will do that by itself.
+
 Severity   : enhancement
 Bugzilla   : 16643
 Description: Generic /proc file permissions
@@ -351,13 +503,27 @@ Details    : Properly handle request reference release in
 	     ll_release_openhandle().
 
 Severity   : normal
+Bugzilla   : 15975
+Frequency  : only patchless client
+Description: add workaround for race between add/remove dentry from hash
+
+Severity   : enhancement
+Bugzilla   : 16845
+Description: Allow OST glimpses to return PW locks
+
+Severity   : minor
+Bugzilla   : 16717
+Description: LBUG when llog conf file is full
+Details    : When llog bitmap is full, ENOSPC should be returned for plain
+	     log.
+
+Severity   : normal
 Bugzilla   : 16907
 Description: Prevent import from entering FULL state when server in recovery
 
-Severity   : normal
-Frequency  : only with devices that have a ':' in the name
+Severity   : major
 Bugzilla   : 16750
-Description: service mount cannot take device name with ':'
+Description: service mount cannot take device name with ":"
 Details    : Only when device name contains ":/" will mount treat it as
 	     client mount.
 
@@ -379,6 +545,13 @@ Severity   : enhancement
 Bugzilla   : 16633
 Description: Update to RHEL5 kernel-2.6.18-92.1.10.el5.
 
+Severity   : normal
+Bugzilla   : 15825
+Description: Kernel BUG tries to release flock
+Details    : Lustre does not destroy flock lock before last reference goes
+	     away. So always drop flock locks when client is evicted and
+	     perform unlock regardless of successfulness of speaking to MDS.
+
 Severity   : enhancement
 Bugzilla   : 16547
 Description: Update to SLES10 SP2 kernel-2.6.16.60-0.27.
@@ -394,171 +567,17 @@ Details    : Allow for a user mode script to be called once a Lustre log has
 Severity   : minor
 Bugzilla   : 16583
 Frequency  : rare
-Description: avoid messages about idr_remove called for unallocated id.
-Details    : Move s_dev assigment for clustered NFS to end of initialization,
-	     to avoid problem with error handling.
+Description: avoid messages about idr_remove called for id that is not allocated
+Details    : Move assigment s_dev for clustered nfs to end of initialization,
+	     for avoid problem with error handling.
 
 Severity   : minor
 Bugzilla   : 16109
 Frequency  : rare
 Description: avoid Already found the key in hash [CONN_UNUSED_HASH] messages
-Details    : When connection is reused this not moved from CONN_UNUSED_HASH
-	     into CONN_USED_HASH and this prodice warning when put connection
-	     again in unused hash.
-
-Severity   : enhancement
-Bugzilla   : 16573
-Description: Export bytes_read/bytes_write count on OSC/OST.
-
-Severity   : normal
-Bugzilla   : 16237
-Description: Early reply size mismatch, MGC loses connection
-Details    : Apply the MGS_CONNECT_SUPPORTED mask at reconnect time so
-	     the connect flags are properly negotiated.
-
-Severity   : major
-Bugzilla   : 14840
-Description: quota recovery deadlock during mds failover
-Details    : This patch includes att18982, att18236, att18237 in bz14840.
-	     Solve the problems:
-	     1. fix osts hang when mds does failover with quotaon
-	     2. prevent watchdog storm when osts threads wait for the
-	        recovery of mds
-
-Severity   : enhancement
-Bugzilla   : 14095
-Description: Add lustre_start utility to start or stop multiple Lustre servers
-	     from a CSV file.
-
-Severity   : normal
-Bugzilla   : 17026
-Description: kptllnd_peer_check_sends() ASSERTION(!in_interrupt()) failed
-Details    : fix stack overflow in distributed lock manager by defering export
-	     eviction after a failed callback to the ELT thread instead of
-	     handling it in the DLM interpret routine.
-
-Severity   : enhancement
-Bugzilla   : 12800
-Description: More exported tunables for mballoc
-Details    : Add support for tunable preallocation window and new tunables for
-	     large/small requests
-
-Severity   : normal
-Bugzilla   : 16680
-Description: Detect corruption of block bitmap and checking for preallocations
-Details    : Checks validity of on-disk block bitmap. Also it does better
-	     checking of number of applied preallocations. When corruption is
-	     found, it turns filesystem readonly to prevent further corruptions.
-
-Severity   : normal
-Bugzilla   : 17197
-Description: ll_read_ahead_pages()) ASSERTION(page_idx > ria->ria_stoff) failed
-Details    : Once the unmatched stride IO mode is detected, shrink the
-	     stride-ahead window to 0. If it does hit cache miss, and read
-	     pattern is still stride-io mode, does not reset the stride window,
-	     but also does not increase the stride window length in this case.
-
-Severity   : normal
-Bugzilla   : 16438
-Frequency  : only for big-endian servers
-Description: Check if system is big-endian while mounting fs with extents
-Details    : Mounting a filesystem with extents feature will fail on big-endian
-	     systems since ext3-based ldiskfs is not supported on big-endian
-	     systems.  Can be bypassed with "bigendian_extents" mount option.
-
-Severity   : normal
-Bugzilla   : 16860
-Description: Excessive recovery window
-Details    : With AT enabled, the recovery window can be excessively long
-	     (6000+ seconds). To address this problem, we no longer use
-	     OBD_RECOVERY_FACTOR when extending the recovery window (the connect
-	     timeout no longer depends on the service time, it is set to
-	     INITIAL_CONNECT_TIMEOUT now) and clients report the old service
-	     time via pb_service_time.
-
-Severity   : normal
-Bugzilla   : 16522
-Description: Watchdog triggered on MDS failover
-Details    : enable OBD_CONNECT_MDT flag when connecting from the MDS so that
-	     the OSTs know that the MDS "UUID" can be reused for the same export
-	     from a different NID, so we do not need to wait for the export to
-	     be evicted.
-
-Severity   : normal
-Frequency  : start MDS on uncleanly shutdowned MDS device
-Bugzilla   : 16839
-Description: ll_sync thread stay in waiting mds<>ost recovery finished
-Details    : fix race due to two ll_sync threads processing the same lov target
-	     causing random failures in various tests. The solution is to send
-	     ACTIVATE event only if connect already finished and import is in
-	     FULL state.
-
-Severity   : major
-Frequency  : rare, only if using MMP with Linux RAID
-Bugzilla   : 17895
-Description: MMP doesn't work with Linux RAID
-Details    : While using HA for Lustre servers with Linux RAID, it is possible
-	     that MMP will not detect multiple mounts. To make this work we
-	     need to unplug the device queue in RAID when the MMP block is being
-	     written. Also while reading the MMP block, we should read it from
-	     disk and not the cached one.
-
---------------------------------------------------------------------------
-
-2008-08-31 Sun Microsystems, Inc.
-	* version 1.6.6
-	* Support for kernels:
-	 2.6.5-7.312 (SLES 9),
-	 2.6.9-78.EL (RHEL 4),
-	 2.6.16.60-0.23 (SLES 10),
-	 2.6.18-92.1.6.el5 (RHEL 5),
-	 2.6.22.14 vanilla (kernel.org)
-	* Client support for unpatched kernels:
-	  (see http://wiki.lustre.org/index.php?title=Patchless_Client)
-	  2.6.16 - 2.6.22 vanilla (kernel.org)
-	* Client support for unpatched kernels:
-	  we do not recommend using patchless RHEL4 clients with kernels
-	  prior to 2.6.9-55EL (RHEL4U5).
-	* Recommended e2fsprogs version: 1.40.11-sun1
-	* Note that reiserfs quotas are disabled on SLES 10 in this kernel.
-	* RHEL 4 and RHEL 5/SLES 10 clients behaves differently on 'cd' to a
-	  removed cwd "./" (refer to Bugzilla 14399).
-	* A new quota file format has been introduced in 1.6.5.
-	  The format conversion from prior releases is handled transparently,
-	  but releases older than 1.4.12/1.6.5 don't understand this new
-	  format. The automatic format conversion can be avoided by running
-	  the following command on the MDS:
-		'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV'.
-	  For more information, please refer to bugzilla 13904.
-	* A new quota file format was introduced in 1.6.6 (for 2.6.16+ kernels).
-	  The format conversion from prior releases is handled transparently,
-	  but releases older than 1.6.6/1.8.0 don't understand this new
-	  format. The automatic format conversion can be avoided by running
-	  the following commands on the MDS and OSS servers (for
-	  pre 1.4.12-1.6.5 quota files):
-		'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV',
-		'tunefs.lustre --param="ost.quota_type=ug1" $MDTDEV'
-		or (for 1.4.12/1.6.5 quota files)
-		'tunefs.lustre --param="mdt.quota_type=ug2" $MDTDEV',
-		'tunefs.lustre --param="ost.quota_type=ug2" $MDTDEV'
-	  For more information, please refer to bugzilla 13904.
-	* Output of lfs quota has been made less detailed by default,
-	  old (verbose) output can be obtained by using -v option.
-
-Severity   : enhancement
-Bugzilla   : 16504
-Description: Update to RHEL4.7 kernel-2.6.9-78.
-
-Severity   : minor
-Bugzilla   : 15899
-Description: Add support for downgrading pools-striped files
-Details    : This version can understand the new LOV magic from pools
-	     striped files (pools will be available in a future release).
-
-Severity   : normal
-Bugzilla   : 15975
-Frequency  : only patchless client
-Description: add workaround for race between add/remove dentry from hash
+Details    : When connection is reused this not moved from CONN_UNUSED_HASH into
+	     CONN_USED_HASH and this prodice warning when put connection again
+	     in unused hash.
 
 Severity   : normal
 Bugzilla   : 15139
@@ -576,11 +595,26 @@ Details    : add workaround for get valid ost count for avoid warnings about
 	     can be blocked on reconnect and break normal replay, fix access
 	     to wrong pointer.
 
+Severity   : enhancement
+Bugzilla   : 16573
+Description: Export bytes_read/bytes_write count on OSC/OST.
+
+Severity   : normal
+Bugzilla   : 16237
+Description: Early reply size mismatch, MGC loses connection
+Details    : Apply the MGS_CONNECT_SUPPORTED mask at reconnect time so
+	     the connect flags are properly negotiated.
+
 Severity   : normal
 Bugzilla   : 16006
 Description: Properly propagate oinfo flags from lov to osc for statfs
 Details    : restore missing copy oi_flags to lov requests.
 
+Severity   : normal
+Bugzilla   : 16317
+Description: exports in /proc are broken
+Details    : recreate /proc entries for clients when they reconnect.
+
 Severity   : enhancement
 Bugzilla   : 16581
 Description: Add man pages for llobdstat(8), llstat(8), plot-llstat(8),
@@ -600,13 +634,6 @@ Severity   : enhancement
 Bugzilla   : 16503
 Description: Update to RHEL4 kernel-2.6.9-67.0.22.EL.
 
-Severity   : enhancement
-Bugzilla   : 16091
-Description: configure's --enable-quota should check the
-	   : kernel .config for CONFIG_QUOTA
-Details    : configure is terminated if --enable-quota is passed but
-	   : no quota support is in kernel
-
 Severity   : normal
 Bugzilla   : 16317
 Description: exports in /proc are broken
@@ -620,20 +647,19 @@ Details    : if client connected until mds will be know about real ost count
 	     for LOV EA.
 
 Severity   : normal
-Frequency  : only for filesystems larger than 8TB
-Bugzilla   : 16101
-Description: ldiskfs BUG ldiskfs_mb_use_best_found()
-Details    : The ldiskfs mballoc3 code was using a __u16 to store the group
-	     number, but with 8TB+ filesystems there are more than 65536
-	     groups, causing an oops.
-
-Severity   : normal
 Bugzilla   : 15576
 Description: Resolve device initialization race
 Details    : Prevent proc handler from accessing devices added to the
 	     obd_devs array but yet be intialized.
 
 Severity   : enhancement
+Bugzilla   : 16091
+Description: configure's --enable-quota should check the
+	   : kernel .config for CONFIG_QUOTA
+Details    : configure is terminated if --enable-quota is passed but
+	   : no quota support is in kernel
+
+Severity   : enhancement
 Bugzilla   : 15308
 Description: Update to SLES10 SP2 kernel-2.6.16.60-0.23.
 
@@ -650,18 +676,13 @@ Details    : bug similar bug 14856, but in different function.
 
 Severity   : enhancement
 Bugzilla   : 15754
-Description: lfs quota tool enhancements
+Description: lfs quota tool enhancement
 Details    : added units specifiers support for setquota, default to
 	     current uid/gid for quota report, short quota stats by
 	     default, nonpositional parameters for setquota, added
 	     llapi_quotactl manual page.
 
-Severity   : normal
-Bugzilla   : 16037
-Description: Client runs out of low memory
-Details    : Consider only lowmem when counting initial number of llap pages
-
-Severity   : normal
+Severity   : enhancement
 Bugzilla   : 15625
 Description: *optional* service tags registration
 Details    : if the "service tags" package is installed on a Lustre node
@@ -670,26 +691,33 @@ Details    : if the "service tags" package is installed on a Lustre node
 	     about the Service Tags asset management system.
 
 Severity   : normal
+Bugzilla   : 16037
+Description: Client runs out of low memory
+Details    : Consider only lowmem when counting initial number of llap pages
+
 Bugzilla   : 15825
 Description: Kernel BUG tries to release flock
 Details    : Lustre does not destroy flock lock before last reference goes
 	     away. So always drop flock locks when client is evicted and
 	     perform unlock regardless of successfulness of speaking to MDS.
 
-Severity   : enhancement
-Bugzilla   : 16189
-Description: Update to RHEL4 kernel-2.6.9-67.0.20.
-
 Severity   : normal
+Frequency  : occasional
 Bugzilla   : 15210
 Description: add refcount for osc callbacks, so avoid panic on shutdown
 
+Severity   : enhancement
+Bugzilla   : 16189
+Description: Update to RHEL4 kernel-2.6.9-67.0.20.
+
 Severity   : normal
+Frequency  : testing only
 Bugzilla   : 12653
 Description: sanity test 65a fails if stripecount of -1 is set
 Details    : handle -1 striping on filesystem in ll_dirstripe_verify
 
 Severity   : normal
+Frequency  : only in unusual configurations
 Bugzilla   : 16014
 Description: Kernel panic with find ost index.
 Details    : lov_obd have panic if some OST's have sparse indexes.
@@ -699,23 +727,27 @@ Bugzilla   : 15865
 Description: Update to RHEL5 kernel-2.6.18-53.1.21.el5.
 
 Severity   : major
+Frequency  : rarely, if filesystem is mounted with -o flock
 Bugzilla   : 15924
 Description: do not process already freed flock
 Details    : flock can possibly be freed by another thread before it reaches
 	     to ldlm_flock_completion_ast.
 
 Severity   : normal
+Frequency  : rarely, if filesystem is mounted with -o flock
 Bugzilla   : 14480
 Description: LBUG during stress test
 Details    : Need properly lock accesses the flock deadlock detection list.
 
 Severity   : minor
+Frequency  : rarely, if binaries are being run from Lustre
 Bugzilla   : 15837
 Description: oops in page fault handler
 Details    : kernel page fault handler can return two special 'pages' in
 	     error case, don't try dereference NOPAGE_SIGBUS and NOPAGE_OMM.
 
 Severity   : minor
+Frequency  : rarely, during shutdown
 Bugzilla   : 15716
 Description: timeout with invalidate import.
 Details    : ptlrpcd_check call obd_zombie_impexp_cull and wait request which
@@ -723,6 +755,7 @@ Details    : ptlrpcd_check call obd_zombie_impexp_cull and wait request which
 	     -ETIMEOUT ptlrpc_invalidate_import and as result LASSERT.
 
 Severity   : normal
+Frequency  : rarely
 Bugzilla   : 14742
 Frequency  : rare
 Description: ASSERTION(CheckWriteback(page,cmd)) failed
@@ -759,7 +792,7 @@ Details    : store magic in native order avoid panic's in recovery on PPC
 	     of twice swab data. Fix get lov striping to userpace.
 
 Severity   : normal
-Frequency  : rare, replay get lost on server
+Frequency  : rarely, if replay get lost on server
 Bugzilla   : 15756
 Description: server incorrectly drop resent replays lead to recovery failure.
 Details    : do not drop replay according to msg flags, instead we check the
@@ -845,6 +878,13 @@ Details    : skiplists are used to group compatible locks on granted list
 	     group the patch changes that to using doubly linked lists
 
 Severity   : normal
+Bugzilla   : 15933
+Description: delete compatibility for 32bit qdata
+Details    : as planned, when lustre is beyond b1_8, lquota won't support 32bit
+	     qunit. That means servers of b1_4 and servers of b1_8 can't be
+	     used together if users want to use quota.
+
+Severity   : normal
 Frequency  : only with administrator action
 Bugzilla   : 14693
 Description: mount failure if config log has invalid conf_param setting
@@ -882,11 +922,11 @@ Description: add -gid, -group, -uid, -user options to lfs find
 
 Severity   : enhancement
 Bugzilla   : 15284
-Description: ll_recover_lost_found_objs - rename objects in lost+found to object ID
-Details    : OST crashes and subsequent e2fsck can lead to objects being moved
-	     to lost+found directory. Using the "ll_recover_lost_found_objs"
+Description: ll_recover_lost_found_objs - recover objects in lost+found
+Details    : OST corruption and subsequent e2fsck can leave objects in the
+	     lost+found directory.  Using the "ll_recover_lost_found_objs"
 	     tool, these objects can be retrieved and data can be salvaged
-	     by using the object ID saved in the fid.
+	     by using the object ID saved in the fid EA on each object.
 
 Severity   : minor
 Frequency  : rare
@@ -925,7 +965,7 @@ Details    : If insertion of an extent fails, then discard the inode
 Severity   : normal
 Bugzilla   : 16199
 Description: don't always update ctime in ext3_xattr_set_handle()
-Details    : Current xattr code updates the inode ctime in ext3_xattr_set_handle.
+Details    : Current xattr code updates inode ctime in ext3_xattr_set_handle()
 	     In some cases the ctime should not be updated, for example for
 	     2.0->1.8 compatibility it is necessary to delete an xattr and it
 	     should not update the ctime.
@@ -959,12 +999,12 @@ Description: assertion failure in ldlm_handle2lock()
 Details    : fix a race between class_handle_unhash() and class_handle2object()
 	     introduced in lustre 1.6.5 by bug 13622.
 
-Severity   : minor
-Frequency  : rare
-Bugzilla   : 15899
-Description: Pools downgrade compatibility
-Details    : Files striped across pools in future (1.8) releases will be
-	     properly understood if the server is downgraded to this version.
+Severity   : enhancement
+Bugzilla   : 11817
+Description: superblock lock contention with many SMP cores on one client
+Details    : several client filesystem locks were highly contended on SMP
+	     NUMA systems with 8 or more cores.  Per-CPU datastructures
+	     and more efficient locking implemented to reduce contention.
 
 Severity   : minor
 Frequency  : rare
@@ -999,12 +1039,6 @@ Details    : FIEMAP ioctl will allow an application to efficiently fetch the
 	     extent information of a file. It can be used to map logical blocks
 	     in a file to physical blocks in the block device.
 
-Severity   : minor
-Bugzilla   : 16717
-Description: LBUG when llog conf file is full
-Details    : When llog bitmap is full, ENOSPC should be returned for plain
-	     log.
-
 Severity   : normal
 Frequency  : only with adaptive timeout enabled
 Bugzilla   : 16972
@@ -1019,12 +1053,30 @@ Bugzilla   : 16813
 Description: X2 build failures
 Details    : fix build failures on Cray X2.
 
+Severity   : normal
+Bugzilla   : 2066
+Description: xid & resent requests
+Details    : Initialize RPC XID from clock at startup (randomly if clock is
+	     bad).
+
 Severity   : major
-Frequency  : Only on FC kernels 2.6.22+
-Bugzilla   : 16303
-Description: oops in statahead
-Details    : Do not drop reference count for the dentry from VFS when lookup,
-	     VFS will do that by itself.
+Bugzilla   : 14840
+Description: quota recovery deadlock during mds failover
+Details    : This patch includes att18982, att18236, att18237 in bz14840.
+	     Solve the problems:
+	     1. fix osts hang when mds does failover with quotaon
+	     2. prevent watchdog storm when osts threads wait for the
+	        recovery of mds
+
+Severity   : normal
+Bugzilla   : 16695
+Description: kernel panic on racer
+Details    : Do not access dchild->d_inode when IS_ERR(dchild) is true.
+
+Severity   : enhancement
+Bugzilla   : 14095
+Description: Add lustre_start utility to start or stop multiple Lustre servers
+	     from a CSV file.
 
 Severity   : major
 Bugzilla   : 17024
@@ -1032,8 +1084,68 @@ Description: Lustre GPF in {:ptlrpc:ptlrpc_server_free_request+373}
 Details    : In case of memory pressure, list_del() can be called twice on
 	     req->rq_history_list, causing a kernel oops.
 
--------------------------------------------------------------------------------
+Severity   : normal
+Bugzilla   : 17026
+Description: (ptllnd_peer.c:557:kptllnd_peer_check_sends()) ASSERTION(!in_interrupt()) failed
+Details    : fix stack overflow in the distributed lock manager by defering
+	     export eviction after a failed ast to the elt thread instead of
+	     handling it in the dlm interpret routine.
+
+Severity   : enhancement
+Bugzilla   : 12800
+Description: More exported tunables for mballoc
+Details    : Add support for tunable preallocation window and new tunables for
+	     large/small requests
 
+Severity   : normal
+Bugzilla   : 16680
+Description: Detect corruption of block bitmap and checking for preallocations
+Details    : Checks validity of on-disk block bitmap. Also it does better
+	     checking of number of applied preallocations. When corruption is
+	     found, it turns filesystem readonly to prevent further corruptions.
+
+Severity   : normal
+Bugzilla   : 16438
+Frequency  : only for big-endian servers
+Description: Check for big-endian system while mounting fs with extents feature
+Details    : Mounting a filesystem with extents feature will fail on big-endian
+	     systems since ext3-based ldiskfs is not supported on big-endian
+	     systems.  Can be over-ridden with "bigendian_extents" mount option.
+
+Severity   : normal
+Bugzilla   : 16860
+Description: Excessive recovery window
+Details    : With AT enabled, the recovery window can be excessively long (6000+
+	     seconds). To address this problem, we no longer use
+	     OBD_RECOVERY_FACTOR when extending the recovery window (the connect
+	     timeout no longer depends on the service time, it is set to
+	     INITIAL_CONNECT_TIMEOUT now) and clients report the old service
+	     time via pb_service_time.
+
+Bugzilla   : 16919
+Descriptoin: Don't sync journal after every i/o
+Details    : Implement write RPC replay to allow server replies for write RPCs
+	     before data is on disk. However, this feature is disabled by
+	     default since some issues leading to data corruptions have been
+	     found during recovery (e.g. bug 19128). This feature can be enabled
+	     by running the following command on the OSSs:
+	     lctl set_param obdfilter.*.sync_journal=0
+
+Severity   : normal
+Bugzilla   : 16522
+Description: Watchdog triggered on MDS failover
+Details    : enable OBD_CONNECT_MDT flag when connecting from the MDS so that
+	     the OSTs know that the MDS "UUID" can be reused for the same export
+	     from a different NID, so we do not need to wait for the export to
+	     be evicted.
+
+Severity   : critical
+Bugzilla   : 18695
+Descriptoin: Lustre detected file system corruption with inode out of bounds
+Details    : don't update i_size on MDS_CLOSE for directories. This causes
+	     directory corruptions on the MDT.
+
+-------------------------------------------------------------------------------
 
 2008-05-26  Sun Microsystems, Inc.
        * version 1.6.5
@@ -1978,6 +2090,14 @@ Description: Incorrect file ownership on O_DIRECT output files
 Details    : block usage reported by 'lfs quota' does not take into account
 	     files that have been written with O_DIRECT.
 
+Severity   : normal
+Bugzilla   : 17197
+Description: (rw.c:1323:ll_read_ahead_pages()) ASSERTION(page_idx > ria->ria_stoff) failed
+Details    : Once the unmatched stride IO mode is detected, shrink the stride-ahead
+	     window to 0. If it does hit cache miss, and read-pattern is still
+	     stride-io mode, does not reset the stride window, but also does not
+	     increase the stride window length in this case.
+
 --------------------------------------------------------------------------------
 
 2007-09-27         Cluster File Systems, Inc. <info at clusterfs.com>
@@ -2632,10 +2752,10 @@ Details    : Lov_mds_md was not free in an error handler in mds_create_object.
 	     be freed no matter whether fsfilt_commit success or not.
 
 Severity   : minor
-Frequency  : only with huge numbers of clients
+Frequency  : only with large numbers of cores on a single node
 Bugzilla   : 11817
 Description: Prevents from taking the superblock lock in llap_from_page for
-	     a soon died page.
+	     a soon killed page.
 Details    : using LL_ORIGIN_REMOVEPAGE origin flag instead of LL_ORIGIN_UNKNOW
 	     for llap_from_page call in ll_removepage() prevents from taking
 	     the superblock lock for a soon died page.
diff --git a/lustre/autoMakefile.in b/lustre/autoMakefile.in
index 238f177..0e0cbd0 100644
--- a/lustre/autoMakefile.in
+++ b/lustre/autoMakefile.in
@@ -214,9 +214,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/autoconf/Makefile.in b/lustre/autoconf/Makefile.in
index 440d1a9..becc838 100644
--- a/lustre/autoconf/Makefile.in
+++ b/lustre/autoconf/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 04f47b0..d4f3c2c 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -83,77 +83,26 @@ $2
 ])
 
 #
-# LC_STRUCT_KIOBUF
-#
-# rh 2.4.18 has iobuf->dovary, but other kernels do not
-#
-AC_DEFUN([LC_STRUCT_KIOBUF],
-[AC_MSG_CHECKING([if struct kiobuf has a dovary field])
-LB_LINUX_TRY_COMPILE([
-	#include <linux/iobuf.h>
-],[
-	struct kiobuf iobuf;
-	iobuf.dovary = 1;
-],[
-	AC_MSG_RESULT([yes])
-	AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field])
-],[
-	AC_MSG_RESULT([no])
-])
-])
 
 #
-# LC_FUNC_COND_RESCHED
+# LC_FUNC_RELEASEPAGE_WITH_GFP
 #
-# cond_resched() was introduced in 2.4.20
+# if ->releasepage() takes a gfp_t arg in 2.6.9
+# This kernel defines gfp_t (HAS_GFP_T) but doesn't use it for this function,
+# while others either don't have gfp_t or pass gfp_t as the parameter.
 #
-AC_DEFUN([LC_FUNC_COND_RESCHED],
-[AC_MSG_CHECKING([if kernel offers cond_resched])
-LB_LINUX_TRY_COMPILE([
-	#include <linux/sched.h>
-],[
-	cond_resched();
-],[
-	AC_MSG_RESULT([yes])
-	AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found])
-],[
-	AC_MSG_RESULT([no])
-])
-])
-
-#
-# LC_FUNC_ZAP_PAGE_RANGE
-#
-# if zap_page_range() takes a vma arg
-#
-AC_DEFUN([LC_FUNC_ZAP_PAGE_RANGE],
-[AC_MSG_CHECKING([if zap_page_range with vma parameter])
-ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`"
-if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then
-	AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter])
+AC_DEFUN([LC_FUNC_RELEASEPAGE_WITH_GFP],
+[AC_MSG_CHECKING([if releasepage has a gfp_t parameter])
+RELEASEPAGE_WITH_GFP="`grep -c 'releasepage.*gfp_t' $LINUX/include/linux/fs.h`"
+if test "$RELEASEPAGE_WITH_GFP" != 0 ; then
+	AC_DEFINE(HAVE_RELEASEPAGE_WITH_GFP, 1,
+                  [releasepage with gfp_t parameter])
 	AC_MSG_RESULT([yes])
 else
 	AC_MSG_RESULT([no])
 fi
 ])
 
-#
-# LC_FUNC_PDE
-#
-# if proc_fs.h defines PDE()
-#
-AC_DEFUN([LC_FUNC_PDE],
-[AC_MSG_CHECKING([if kernel defines PDE])
-HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`"
-if test "$HAVE_PDE" != 0 ; then
-	AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE])
-	AC_MSG_RESULT([yes])
-else
-	AC_MSG_RESULT([no])
-fi
-])
-
-#
 # LC_FUNC_FILEMAP_FDATASYNC
 #
 # if filemap_fdatasync() exists
@@ -173,22 +122,6 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LC_FUNC_DIRECT_IO
-#
-# if direct_IO takes a struct file argument
-#
-AC_DEFUN([LC_FUNC_DIRECT_IO],
-[AC_MSG_CHECKING([if kernel passes struct file to direct_IO])
-HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`"
-if test "$HAVE_DIO_FILE" != 0 ; then
-	AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO])
-	AC_MSG_RESULT(yes)
-else
-	AC_MSG_RESULT(no)
-fi
-])
-
-#
 # LC_HEADER_MM_INLINE
 #
 # RHEL kernels define page_count in mm_inline.h
@@ -234,27 +167,52 @@ LB_LINUX_TRY_COMPILE([
 # LC_FUNC_REGISTER_CACHE
 #
 # if register_cache() is defined by kernel
+# 
+# There are two ways to shrink one customized cache in linux kernels. For the
+# kernels are prior than 2.6.5(?), register_cache() is used, and for latest 
+# kernels, set_shrinker() is used instead.
 #
 AC_DEFUN([LC_FUNC_REGISTER_CACHE],
-[AC_MSG_CHECKING([if kernel defines register_cache()])
+[AC_MSG_CHECKING([if kernel defines cache pressure hook])
 LB_LINUX_TRY_COMPILE([
-	#include <linux/list.h>
-	#include <linux/cache_def.h>
+	#include <linux/mm.h>
 ],[
-	struct cache_definition cache;
+	shrinker_t shrinker;
+
+	set_shrinker(1, shrinker);
 ],[
-	AC_MSG_RESULT([yes])
-	AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
-	AC_MSG_CHECKING([if kernel expects return from cache shrink function])
-	HAVE_CACHE_RETURN_INT="`grep -c 'int.*shrink' $LINUX/include/linux/cache_def.h`"
-	if test "$HAVE_CACHE_RETURN_INT" != 0 ; then
-		AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [kernel expects return from shrink_cache])
-		AC_MSG_RESULT(yes)
-	else
-		AC_MSG_RESULT(no)
-	fi
+	AC_MSG_RESULT([set_shrinker])
+	AC_DEFINE(HAVE_SHRINKER_CACHE, 1, [shrinker_cache found])
+	AC_DEFINE(HAVE_CACHE_RETURN_INT, 1, [shrinkers should return int])
 ],[
-	AC_MSG_RESULT([no])
+	LB_LINUX_TRY_COMPILE([
+		#include <linux/list.h>
+		#include <linux/cache_def.h>
+	],[
+		struct cache_definition cache;
+	],[
+		AC_MSG_RESULT([register_cache])
+		AC_DEFINE(HAVE_REGISTER_CACHE, 1, [register_cache found])
+		AC_MSG_CHECKING([if kernel expects return from cache shrink ])
+		tmp_flags="$EXTRA_KCFLAGS"
+		EXTRA_KCFLAGS="-Werror"
+		LB_LINUX_TRY_COMPILE([
+			#include <linux/list.h>
+			#include <linux/cache_def.h>
+		],[
+			struct cache_definition c;
+			c.shrinker = (int (*)(int, unsigned int))1;
+		],[
+			AC_DEFINE(HAVE_CACHE_RETURN_INT, 1,
+				  [kernel expects return from shrink_cache])
+			AC_MSG_RESULT(yes)
+		],[
+			AC_MSG_RESULT(no)
+		])
+		EXTRA_KCFLAGS="$tmp_flags"
+	],[
+		AC_MSG_RESULT([no])
+	])
 ])
 ])
 
@@ -310,7 +268,7 @@ BACKINGFS="ldiskfs"
 if test x$with_ldiskfs = xno ; then
 	BACKINGFS="ext3"
 
-	if test x$linux25$enable_server = xyesyes ; then
+	if test x$enable_server = xyes ; then
 		AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.])
 	fi
 
@@ -630,14 +588,18 @@ AC_DEFUN([LC_LUSTRE_VERSION_H],
         	enable_server='no'
 	fi
 ])
-])
-
-AC_DEFUN([LC_FUNC_SET_FS_PWD],
-[LB_CHECK_SYMBOL_EXPORT([set_fs_pwd],
-[fs/namespace.c],[
-        AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd is exported])
-],[
-])
+	if test x$enable_server = xyes ; then
+		if test x$RHEL_KERNEL = xyes -a x$LINUXRELEASE != x${LINUXRELEASE##2.6.9} ; then
+        		AC_MSG_WARN([Lustre server has been disabled with rhel4 kernel;])
+        		AC_MSG_WARN([disabling server build])
+        		enable_server='no'
+		fi
+		if test x$SUSE_KERNEL = xyes -a x$LINUXRELEASE != x${LINUXRELEASE##2.6.5} ; then
+        		AC_MSG_WARN([Lustre server has been disabled with sles9 kernel;])
+        		AC_MSG_WARN([disabling server build])
+			enable_server='no'
+		fi
+	fi
 ])
 
 #
@@ -808,6 +770,17 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# LC_EXPORT_SYNCHRONIZE_RCU
+# after 2.6.12 synchronize_rcu is preferred over synchronize_kernel
+AC_DEFUN([LC_EXPORT_SYNCHRONIZE_RCU],
+[LB_CHECK_SYMBOL_EXPORT([synchronize_rcu],
+[kernel/rcupdate.c],[
+        AC_DEFINE(HAVE_SYNCHRONIZE_RCU, 1,
+                [in 2.6.12 synchronize_rcu preferred over synchronize_kernel])
+],[
+])
+])
+
 # LC_INODE_I_MUTEX
 # after 2.6.15 inode have i_mutex intead of i_sem
 AC_DEFUN([LC_INODE_I_MUTEX],
@@ -940,6 +913,23 @@ LB_LINUX_TRY_COMPILE([
 EXTRA_KCFLAGS="$tmp_flags"
 ])
 
+# inode have i_private field since 2.6.17
+AC_DEFUN([LC_INODE_IPRIVATE],
+[AC_MSG_CHECKING([if inode has a i_private field])
+LB_LINUX_TRY_COMPILE([
+#include <linux/fs.h>
+],[
+	struct inode i;
+	i.i_private = NULL; 
+],[
+	AC_MSG_RESULT(yes)
+	AC_DEFINE(HAVE_INODE_IPRIVATE, 1,
+		[struct inode has i_private field])
+],[
+	AC_MSG_RESULT(no)
+])
+])
+
 # 2.6.19 API changes
 # inode don't have i_blksize field
 AC_DEFUN([LC_INODE_BLKSIZE],
@@ -986,6 +976,23 @@ LB_LINUX_TRY_COMPILE([
 EXTRA_KCFLAGS="$tmp_flags"
 ])
 
+# LC_FILE_UPDATE_TIME
+# 2.6.9 has inode_update_time instead of file_update_time
+AC_DEFUN([LC_FILE_UPDATE_TIME],
+[AC_MSG_CHECKING([if file_update_time is exported])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        file_update_time(NULL);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_FILE_UPDATE_TIME, 1,
+                [use file_update_time])
+],[
+       AC_MSG_RESULT(no)
+])
+])
+
 # LC_FILE_WRITEV
 # 2.6.19 replaced writev with aio_write
 AC_DEFUN([LC_FILE_WRITEV],
@@ -1048,6 +1055,10 @@ LB_LINUX_TRY_COMPILE([
         #include <linux/mm.h>
         #include <linux/page-flags.h>
 ],[
+        /* tmp workaround for broken OFED 1.4.1 at SLES10 */
+        #if defined(CONFIG_SLE_VERSION) && CONFIG_SLE_VERSION == 10 && defined(_BACKPORT_LINUX_MM_H_)
+        #error badly implementation of cancel_dirty_pages
+        #endif
         cancel_dirty_page(NULL, 0);
 ],[
         AC_MSG_RESULT(yes)
@@ -1106,15 +1117,20 @@ LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_PAGE_CHECKED],
 [AC_MSG_CHECKING([kernel has PageChecked and SetPageChecked])
 LB_LINUX_TRY_COMPILE([
-        #include <linux/mm.h>
-        #include <linux/page-flags.h>
+        #include <linux/autoconf.h>
+#ifdef HAVE_LINUX_MMTYPES_H
+        #include <linux/mm_types.h>
+#endif
+	#include <linux/page-flags.h>
 ],[
-        #ifndef PageChecked
-        #error PageChecked not defined in kernel
-        #endif
-        #ifndef SetPageChecked
-        #error SetPageChecked not defined in kernel
-        #endif
+ 	struct page *p;
+
+        /* before 2.6.26 this define*/
+        #ifndef PageChecked	
+ 	/* 2.6.26 use function instead of define for it */
+ 	SetPageChecked(p);
+ 	PageChecked(p);
+ 	#endif
 ],[
         AC_MSG_RESULT(yes)
         AC_DEFINE(HAVE_PAGE_CHECKED, 1,
@@ -1124,7 +1140,7 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
-AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE],
+AC_DEFUN([LC_EXPORT_TRUNCATE_COMPLETE_PAGE],
 [LB_CHECK_SYMBOL_EXPORT([truncate_complete_page],
 [mm/truncate.c],[
 AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
@@ -1133,6 +1149,15 @@ AC_DEFINE(HAVE_TRUNCATE_COMPLETE_PAGE, 1,
 ])
 ])
 
+AC_DEFUN([LC_EXPORT_TRUNCATE_RANGE],
+[LB_CHECK_SYMBOL_EXPORT([truncate_inode_pages_range],
+[mm/truncate.c],[
+AC_DEFINE(HAVE_TRUNCATE_RANGE, 1,
+            [kernel export truncate_inode_pages_range])
+],[
+])
+])
+
 AC_DEFUN([LC_EXPORT_D_REHASH_COND],
 [LB_CHECK_SYMBOL_EXPORT([d_rehash_cond],
 [fs/dcache.c],[
@@ -1169,6 +1194,38 @@ AC_DEFINE(HAVE___D_MOVE, 1,
 ])
 ])
 
+#
+# LC_EXPORT_INVALIDATE_MAPPING_PAGES
+#
+# SLES9, RHEL4, RHEL5, vanilla 2.6.24 export invalidate_mapping_pages() but
+# SLES10 2.6.16 does not, for some reason.  For filter cache invalidation.
+#
+AC_DEFUN([LC_EXPORT_INVALIDATE_MAPPING_PAGES],
+    [LB_CHECK_SYMBOL_EXPORT([invalidate_mapping_pages], [mm/truncate.c], [
+         AC_DEFINE(HAVE_INVALIDATE_MAPPING_PAGES, 1,
+                        [exported invalidate_mapping_pages])],
+    [LB_CHECK_SYMBOL_EXPORT([invalidate_inode_pages], [mm/truncate.c], [
+         AC_DEFINE(HAVE_INVALIDATE_INODE_PAGES, 1,
+                        [exported invalidate_inode_pages])], [
+       AC_MSG_ERROR([no way to invalidate pages])
+  ])
+    ],[])
+])
+
+#
+# LC_EXPORT_FILEMAP_FDATASYNC_RANGE
+#
+# No standard kernels export this
+#
+AC_DEFUN([LC_EXPORT_FILEMAP_FDATAWRITE_RANGE],
+[LB_CHECK_SYMBOL_EXPORT([filemap_fdatawrite_range],
+[mm/filemap.c],[
+AC_DEFINE(HAVE_FILEMAP_FDATAWRITE_RANGE, 1,
+            [filemap_fdatawrite_range is exported by the kernel])
+],[
+])
+])
+
 # The actual symbol exported varies among architectures, so we need
 # to check many symbols (but only in the current architecture.)  No
 # matter what symbol is exported, the kernel #defines node_to_cpumask
@@ -1232,6 +1289,29 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# 2.6.12 merge patch from oracle to convert tree_lock from spinlock to rwlock
+AC_DEFUN([LC_RW_TREE_LOCK],
+[AC_MSG_CHECKING([if kernel has tree_lock as rwlock])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct address_space a;
+
+        write_lock(&a.tree_lock);
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_RW_TREE_LOCK, 1, [kernel has tree_lock as rw_lock])
+],[
+        AC_MSG_RESULT([no])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+# 2.6.18
+
+
 # 2.6.23 have return type 'void' for unregister_blkdev
 AC_DEFUN([LC_UNREGISTER_BLKDEV_RETURN_INT],
 [AC_MSG_CHECKING([if unregister_blkdev return int])
@@ -1249,6 +1329,25 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 # 2.6.23 change .sendfile to .splice_read
+# RHEL4 (-92 kernel) have both sendfile and .splice_read API
+AC_DEFUN([LC_KERNEL_SENDFILE],
+[AC_MSG_CHECKING([if kernel has .sendfile])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct file_operations file;
+
+        file.sendfile = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_KERNEL_SENDFILE, 1,
+                [kernel has .sendfile])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.23 change .sendfile to .splice_read
 AC_DEFUN([LC_KERNEL_SPLICE_READ],
 [AC_MSG_CHECKING([if kernel has .splice_read])
 LB_LINUX_TRY_COMPILE([
@@ -1268,11 +1367,446 @@ LB_LINUX_TRY_COMPILE([
 
 # 2.6.23 extract nfs export related data into exportfs.h
 AC_DEFUN([LC_HAVE_EXPORTFS_H],
-[
-tmpfl="$CFLAGS"
-CFLAGS="$CFLAGS -I$LINUX_OBJ/include"
-AC_CHECK_HEADERS([linux/exportfs.h])
-CFLAGS="$tmpfl"
+[LB_CHECK_FILE([$LINUX/include/linux/exportfs.h], [
+        AC_DEFINE(HAVE_LINUX_EXPORTFS_H, 1,
+                [kernel has include/exportfs.h])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.23 have new page fault handling API
+AC_DEFUN([LC_VM_OP_FAULT],
+[AC_MSG_CHECKING([if kernel has .fault in vm_operation_struct])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/mm.h>
+],[
+        struct vm_operations_struct op;
+
+        op.fault = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_VM_OP_FAULT, 1,
+                [if kernel has .fault in vm_operation_struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#2.6.23 has new shrinker API
+AC_DEFUN([LC_REGISTER_SHRINKER],
+[AC_MSG_CHECKING([if kernel has register_shrinker])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/mm.h>
+],[
+        register_shrinker(NULL);
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_REGISTER_SHRINKER, 1,
+                [if kernel has register_shrinker])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.23 add code to wait other users to complete before removing procfs entry
+AC_DEFUN([LC_PROCFS_USERS],
+[AC_MSG_CHECKING([if kernel has pde_users member in procfs entry struct])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/proc_fs.h>
+],[
+        struct proc_dir_entry pde;
+
+        pde.pde_users   = 0;
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_PROCFS_USERS, 1, 
+                [kernel has pde_users member in procfs entry struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 has bio_endio with 2 args
+AC_DEFUN([LC_BIO_ENDIO_2ARG],
+[AC_MSG_CHECKING([if kernel has bio_endio with 2 args])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/bio.h>
+],[
+        bio_endio(NULL, 0);
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_BIO_ENDIO_2ARG, 1,
+                [if kernel has bio_endio with 2 args])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 has new members in exports struct.
+AC_DEFUN([LC_FH_TO_DENTRY],
+[AC_MSG_CHECKING([if kernel has .fh_to_dentry member in export_operations struct])
+LB_LINUX_TRY_COMPILE([
+#ifdef HAVE_LINUX_EXPORTFS_H
+        #include <linux/exportfs.h>
+#else
+        #include <linux/fs.h>
+#endif
+],[
+        struct export_operations exp;
+
+        exp.fh_to_dentry   = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_FH_TO_DENTRY, 1,
+                [kernel has .fh_to_dentry member in export_operations struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 need linux/mm_types.h included
+AC_DEFUN([LC_HAVE_MMTYPES_H],
+[LB_CHECK_FILE([$LINUX/include/linux/mm_types.h], [
+        AC_DEFINE(HAVE_LINUX_MMTYPES_H, 1,
+                [kernel has include/mm_types.h])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.24 remove long aged procfs entry -> deleted member
+AC_DEFUN([LC_PROCFS_DELETED],
+[AC_MSG_CHECKING([if kernel has deleted member in procfs entry struct])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/proc_fs.h>
+],[
+        struct proc_dir_entry pde;
+
+        pde.deleted   = NULL;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_PROCFS_DELETED, 1,
+                [kernel has deleted member in procfs entry struct])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.25 change define to inline
+AC_DEFUN([LC_MAPPING_CAP_WRITEBACK_DIRTY],
+[AC_MSG_CHECKING([if kernel have mapping_cap_writeback_dirty])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/backing-dev.h>
+],[
+        #ifndef mapping_cap_writeback_dirty
+        mapping_cap_writeback_dirty(NULL);
+        #endif
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_MAPPING_CAP_WRITEBACK_DIRTY, 1,
+                [kernel have mapping_cap_writeback_dirty])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+
+
+# 2.6.26 isn't export set_fs_pwd and change paramter in fs struct
+AC_DEFUN([LC_FS_STRUCT_USE_PATH],
+[AC_MSG_CHECKING([fs_struct use path structure])
+LB_LINUX_TRY_COMPILE([
+        #include <asm/atomic.h>
+        #include <linux/spinlock.h>
+        #include <linux/fs_struct.h>
+],[
+        struct path path;
+        struct fs_struct fs;
+
+        fs.pwd = path;
+], [
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_FS_STRUCT_USE_PATH, 1,
+                [fs_struct use path structure])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#2.6.27
+AC_DEFUN([LC_INODE_PERMISION_2ARGS],
+[AC_MSG_CHECKING([inode_operations->permission have two args])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct inode *inode;
+
+        inode->i_op->permission(NULL,0);
+],[
+        AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1, 
+                  [inode_operations->permission have two args])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 have file_remove_suid instead of remove_suid
+AC_DEFUN([LC_FILE_REMOVE_SUID],
+[AC_MSG_CHECKING([kernel have file_remove_suid])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        file_remove_suid(NULL);
+],[
+        AC_DEFINE(HAVE_FILE_REMOVE_SUID, 1,
+                  [kernel have file_remove_suid])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 have new page locking API
+AC_DEFUN([LC_TRYLOCKPAGE],
+[AC_MSG_CHECKING([kernel use trylock_page for page lock])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/pagemap.h>
+],[
+        trylock_page(NULL);
+],[
+        AC_DEFINE(HAVE_TRYLOCK_PAGE, 1,
+                  [kernel use trylock_page for page lock])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 and some older have mapping->tree_lock as spin_lock
+AC_DEFUN([LC_RW_TREE_LOCK],
+[AC_MSG_CHECKING([mapping->tree_lock is rw_lock])
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_LINUX_TRY_COMPILE([
+	#include <linux/fs.h>
+],[
+	struct address_space *map = NULL;
+
+	write_lock_irq(&map->tree_lock);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_RW_TREE_LOCK, 1,
+                [mapping->tree_lock is rw_lock])
+],[
+        AC_MSG_RESULT(no)
+])
+EXTRA_KCFLAGS="$tmp_flags"
+])
+
+# 2.6.5 sles9 hasn't define sysctl_vfs_cache_pressure
+AC_DEFUN([LC_HAVE_SYSCTL_VFS_CACHE_PRESSURE],
+[LB_CHECK_SYMBOL_EXPORT([sysctl_vfs_cache_pressure],
+[fs/dcache.c],[
+        AC_DEFINE(HAVE_SYSCTL_VFS_CACHE_PRESSURE, 1, [kernel exports sysctl_vfs_cache_pressure])
+],[
+])
+])
+
+# vfs_symlink seems to have started out with 3 args until 2.6.7 where a
+# "mode" argument was added, but then again, in some later version it was
+# removed
+AC_DEFUN([LC_4ARGS_VFS_SYMLINK],
+[AC_MSG_CHECKING([if vfs_symlink wants 4 args])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/fs.h>
+],[
+	struct inode *dir;
+	struct dentry *dentry;
+	const char *oldname = NULL;
+	int mode = 0;
+
+	vfs_symlink(dir, dentry, oldname, mode);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_4ARGS_VFS_SYMLINK, 1,
+                  [vfs_symlink wants 4 args])
+],[
+        AC_MSG_RESULT(no)
+])
+])
+
+# 2.6.27 sles11 remove the bi_hw_segments
+AC_DEFUN([LC_BI_HW_SEGMENTS],
+[AC_MSG_CHECKING([struct bio has a bi_hw_segments field])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/bio.h>
+],[
+        struct bio io;
+        io.bi_hw_segments = 0;
+],[
+        AC_DEFINE(HAVE_BI_HW_SEGMENTS, 1,
+                [struct bio has a bi_hw_segments field])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 sles11 move the quotaio_v1.h to fs
+AC_DEFUN([LC_HAVE_QUOTAIO_V1_H],
+[LB_CHECK_FILE([$LINUX/include/linux/quotaio_v1.h],[
+        AC_DEFINE(HAVE_QUOTAIO_V1_H, 1,
+                [kernel has include/linux/quotaio_v1.h])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# sles10 sp2 need 5 parameter for vfs_symlink
+AC_DEFUN([LC_VFS_SYMLINK_5ARGS],
+[AC_MSG_CHECKING([vfs_symlink need 5 parameter])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct inode *dir = NULL;
+        struct dentry *dentry = NULL;
+        struct vfsmount *mnt = NULL;
+        const char * path = NULL;
+        vfs_symlink(dir, dentry, mnt, path, 0);
+],[
+        AC_DEFINE(HAVE_VFS_SYMLINK_5ARGS, 1,
+                [vfs_symlink need 5 parameteres])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 removed the read_inode from super_operations.
+AC_DEFUN([LC_READ_INODE_IN_SBOPS],
+[AC_MSG_CHECKING([super_operations has a read_inode field])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        struct super_operations *sop;
+        sop->read_inode(NULL);
+],[
+        AC_DEFINE(HAVE_READ_INODE_IN_SBOPS, 1,
+                [super_operations has a read_inode])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 sles11 has sb_any_quota_active
+AC_DEFUN([LC_SB_ANY_QUOTA_ACTIVE],
+[AC_MSG_CHECKING([Kernel has sb_any_quota_active])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quotaops.h>
+],[
+        sb_any_quota_active(NULL);
+],[
+        AC_DEFINE(HAVE_SB_ANY_QUOTA_ACTIVE, 1,
+                [Kernel has a sb_any_quota_active])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 sles11 has sb_has_quota_active
+AC_DEFUN([LC_SB_HAS_QUOTA_ACTIVE],
+[AC_MSG_CHECKING([Kernel has sb_has_quota_active])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quotaops.h>
+],[
+        sb_has_quota_active(NULL, 0);
+],[
+        AC_DEFINE(HAVE_SB_HAS_QUOTA_ACTIVE, 1,
+                [Kernel has a sb_has_quota_active])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 has inode_permission instead of permisson
+AC_DEFUN([LC_EXPORT_INODE_PERMISSION],
+[LB_CHECK_SYMBOL_EXPORT([inode_permission],
+[fs/namei.c],[
+AC_DEFINE(HAVE_EXPORT_INODE_PERMISSION, 1,
+            [inode_permission is exported by the kernel])
+],[
+])
+])
+
+# 2.6.27 use 5th parameter in quota_on for remount.
+AC_DEFUN([LC_QUOTA_ON_5ARGS],
+[AC_MSG_CHECKING([quota_on needs 5 parameters])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quota.h>
+],[
+        struct quotactl_ops *qop;
+        qop->quota_on(NULL, 0, 0, NULL, 0);
+],[
+        AC_DEFINE(HAVE_QUOTA_ON_5ARGS, 1,
+                [quota_on needs 5 paramters])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 use 3th parameter in quota_off for remount.
+AC_DEFUN([LC_QUOTA_OFF_3ARGS],
+[AC_MSG_CHECKING([quota_off needs 3 parameters])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quota.h>
+],[
+        struct quotactl_ops *qop;
+        qop->quota_off(NULL, 0, 0);
+],[
+        AC_DEFINE(HAVE_QUOTA_OFF_3ARGS, 1,
+                [quota_off needs 3 paramters])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+# 2.6.27 has vfs_dq_off inline function.
+AC_DEFUN([LC_VFS_DQ_OFF],
+[AC_MSG_CHECKING([vfs_dq_off is defined])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/quotaops.h>
+],[
+        vfs_dq_off(NULL, 0);
+],[
+        AC_DEFINE(HAVE_VFS_DQ_OFF, 1, [vfs_dq_off is defined])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
+# Ensure stack size big than 8k in Lustre server
+AC_DEFUN([LC_STACK_SIZE],
+[AC_MSG_CHECKING([stack size big than 8k])
+LB_LINUX_TRY_COMPILE([
+	#include <linux/thread_info.h>
+],[
+        #if THREAD_SIZE < 8192
+        #error "stack size < 8192"
+        #endif
+],[
+        AC_MSG_RESULT(yes)
+],[
+        AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 8KB stack.])
+])
 ])
 
 #
@@ -1284,6 +1818,7 @@ AC_DEFUN([LC_PROG_LINUX],
          [LC_LUSTRE_VERSION_H
           if test x$enable_server = xyes ; then
               LC_CONFIG_BACKINGFS
+              LC_STACK_SIZE
           fi
           LC_CONFIG_PINGER
           LC_CONFIG_CHECKSUM
@@ -1291,22 +1826,20 @@ AC_DEFUN([LC_PROG_LINUX],
           LC_CONFIG_HEALTH_CHECK_WRITE
           LC_CONFIG_LRU_RESIZE
           LC_CONFIG_ADAPTIVE_TIMEOUTS
+          LC_CONFIG_DELAYED_RECOVERY
           LC_QUOTA_MODULE
 
           LC_TASK_PPTR
           # RHEL4 patches
-          LC_EXPORT_TRUNCATE_COMPLETE
+          LC_EXPORT_TRUNCATE_COMPLETE_PAGE
+          LC_EXPORT_TRUNCATE_RANGE
           LC_EXPORT_D_REHASH_COND
           LC_EXPORT___D_REHASH
           LC_EXPORT_D_MOVE_LOCKED
           LC_EXPORT___D_MOVE
           LC_EXPORT_NODE_TO_CPUMASK
 
-          LC_STRUCT_KIOBUF
-          LC_FUNC_COND_RESCHED
-          LC_FUNC_ZAP_PAGE_RANGE
-          LC_FUNC_PDE
-          LC_FUNC_DIRECT_IO
+          LC_FUNC_RELEASEPAGE_WITH_GFP
           LC_HEADER_MM_INLINE
           LC_STRUCT_INODE
           LC_FUNC_REGISTER_CACHE
@@ -1323,18 +1856,26 @@ AC_DEFUN([LC_PROG_LINUX],
           LC_STRUCT_INTENT_FILE
           LC_POSIX_ACL_XATTR_H
           LC_EXPORT___IGET
-          LC_FUNC_SET_FS_PWD
           LC_FUNC_MS_FLOCK_LOCK
           LC_FUNC_HAVE_CAN_SLEEP_ARG
           LC_FUNC_F_OP_FLOCK
           LC_QUOTA_READ
           LC_COOKIE_FOLLOW_LINK
           LC_FUNC_RCU
+          LC_PERCPU_COUNTER
           LC_QUOTA64
+          LC_4ARGS_VFS_SYMLINK
 
           # does the kernel have VFS intent patches?
           LC_VFS_INTENT_PATCHES
 
+	  # 2.6.5 sles9
+	  LC_HAVE_SYSCTL_VFS_CACHE_PRESSURE
+
+          # 2.6.12
+          LC_RW_TREE_LOCK
+          LC_EXPORT_SYNCHRONIZE_RCU
+
           # 2.6.15
           LC_INODE_I_MUTEX
 
@@ -1350,6 +1891,11 @@ AC_DEFUN([LC_PROG_LINUX],
           LC_VFS_KERN_MOUNT
           LC_INVALIDATEPAGE_RETURN_INT
           LC_UMOUNTBEGIN_HAS_VFSMOUNT
+          LC_INODE_IPRIVATE
+          LC_EXPORT_FILEMAP_FDATAWRITE_RANGE
+          if test x$enable_server = xyes ; then
+                LC_EXPORT_INVALIDATE_MAPPING_PAGES
+          fi
 
           #2.6.18 + RHEL5 (fc6)
           LC_PG_FS_MISC
@@ -1358,6 +1904,7 @@ AC_DEFUN([LC_PROG_LINUX],
           # 2.6.19
           LC_INODE_BLKSIZE
           LC_VFS_READDIR_U64_INO
+          LC_FILE_UPDATE_TIME
           LC_FILE_WRITEV
           LC_FILE_READV
 
@@ -1366,14 +1913,49 @@ AC_DEFUN([LC_PROG_LINUX],
 
           # raid5-zerocopy patch
           LC_PAGE_CONSTANT
-	  
-	  # 2.6.22
+
+          # 2.6.22
           LC_INVALIDATE_BDEV_2ARG
           LC_FS_RENAME_DOES_D_MOVE
           # 2.6.23
           LC_UNREGISTER_BLKDEV_RETURN_INT
+          LC_KERNEL_SENDFILE
           LC_KERNEL_SPLICE_READ
           LC_HAVE_EXPORTFS_H
+          LC_VM_OP_FAULT
+          LC_REGISTER_SHRINKER
+          LC_PROCFS_USERS
+
+          # 2.6.25
+          LC_MAPPING_CAP_WRITEBACK_DIRTY
+
+          # 2.6.24
+          LC_HAVE_MMTYPES_H
+          LC_BIO_ENDIO_2ARG
+          LC_FH_TO_DENTRY
+          LC_PROCFS_DELETED
+
+          # 2.6.26
+          LC_FS_STRUCT_USE_PATH
+          LC_RCU_LIST_SAFE
+
+          # 2.6.27
+          LC_INODE_PERMISION_2ARGS
+          LC_FILE_REMOVE_SUID
+          LC_TRYLOCKPAGE
+          LC_RW_TREE_LOCK
+          LC_READ_INODE_IN_SBOPS
+          LC_EXPORT_INODE_PERMISSION
+          LC_QUOTA_ON_5ARGS
+          LC_QUOTA_OFF_3ARGS
+          LC_VFS_DQ_OFF
+
+          # 2.6.27.15-2 sles11
+          LC_BI_HW_SEGMENTS
+          LC_HAVE_QUOTAIO_V1_H
+          LC_VFS_SYMLINK_5ARGS
+          LC_SB_ANY_QUOTA_ACTIVE
+          LC_SB_HAS_QUOTA_ACTIVE
 ])
 
 #
@@ -1435,46 +2017,48 @@ fi
 # --enable-mpitest
 #
 AC_ARG_ENABLE(mpitests,
-	AC_HELP_STRING([--enable-mpitest=yes|no|mpich directory],
+	AC_HELP_STRING([--enable-mpitests=yes|no|mpicc wrapper],
                            [include mpi tests]),
 	[
 	 enable_mpitests=yes
          case $enableval in
          yes)
-		MPI_ROOT=/opt/mpich
-		LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
-		CFLAGS="$CFLAGS -I$MPI_ROOT/include"
+		MPICC_WRAPPER=mpicc
 		;;
          no)
 		enable_mpitests=no
 		;;
-	 [[\\/$]]* | ?:[[\\/]]* )
-		MPI_ROOT=$enableval
-		LDFLAGS="$LDFLAGS -L$with_mpi/lib"
-		CFLAGS="$CFLAGS -I$MPI_ROOT/include"
-                ;;
          *)
-                 AC_MSG_ERROR([expected absolute directory name for --enable-mpitests or yes or no])
+		MPICC_WRAPPER=$enableval
                  ;;
 	 esac
 	],
 	[
-	MPI_ROOT=/opt/mpich
-        LDFLAGS="$LDFLAGS -L$MPI_ROOT/ch-p4/lib -L$MPI_ROOT/ch-p4/lib64"
-        CFLAGS="$CFLAGS -I$MPI_ROOT/include"
+	MPICC_WRAPPER=mpicc
 	enable_mpitests=yes
 	]
 )
-AC_SUBST(MPI_ROOT)
 
 if test x$enable_mpitests != xno; then
-	AC_MSG_CHECKING([whether to mpitests can be built])
-        AC_CHECK_FILE([$MPI_ROOT/include/mpi.h],
-                      [AC_CHECK_LIB([mpich],[MPI_Start],[enable_mpitests=yes],[enable_mpitests=no])],
-                      [enable_mpitests=no])
+	AC_MSG_CHECKING([whether mpitests can be built])
+	oldcc=$CC
+	CC=$MPICC_WRAPPER
+	AC_LINK_IFELSE(
+	    [AC_LANG_PROGRAM([[
+		    #include <mpi.h>
+	        ]],[[
+		    int flag;
+		    MPI_Initialized(&flag);
+		]])],
+	    [
+		    AC_MSG_RESULT([yes])
+	    ],[
+		    AC_MSG_RESULT([no])
+		    enable_mpitests=no
+	])
+	CC=$oldcc
 fi
-AC_MSG_RESULT([$enable_mpitests])
-
+AC_SUBST(MPICC_WRAPPER)
 
 AC_MSG_NOTICE([Enabling Lustre configure options for libsysio])
 ac_configure_args="$ac_configure_args --with-lustre-hack --with-sockets"
@@ -1498,15 +2082,28 @@ fi
 AC_DEFUN([LC_CONFIG_ADAPTIVE_TIMEOUTS],
 [AC_MSG_CHECKING([whether to enable ptlrpc adaptive timeouts support])
 AC_ARG_ENABLE([adaptive_timeouts],
-	AC_HELP_STRING([--enable-adaptive-timeouts],
-			[enable ptlrpc adaptive timeouts support]),
-	[],[enable_adaptive_timeouts='no'])
+	AC_HELP_STRING([--disable-adaptive-timeouts],
+			[disable ptlrpc adaptive timeouts support]),
+	[],[enable_adaptive_timeouts='yes'])
 AC_MSG_RESULT([$enable_adaptive_timeouts])
 if test x$enable_adaptive_timeouts == xyes; then
    AC_DEFINE(HAVE_AT_SUPPORT, 1, [Enable adaptive timeouts support])
 fi
 ])
 
+# config delayed recovery
+AC_DEFUN([LC_CONFIG_DELAYED_RECOVERY],
+[AC_MSG_CHECKING([whether to enable delayed recovery support])
+AC_ARG_ENABLE([delayed-recovery],
+	AC_HELP_STRING([--enable-delayed-recovery],
+			[enable late recovery after main one]),
+	[],[enable_delayed_recovery='no'])
+AC_MSG_RESULT([$enable_delayed_recovery])
+if test x$enable_delayed_recovery == xyes; then
+   AC_DEFINE(HAVE_DELAYED_RECOVERY, 1, [Enable delayed recovery support])
+fi
+])
+
 #
 # LC_CONFIG_QUOTA
 #
@@ -1606,6 +2203,7 @@ LB_LINUX_TRY_COMPILE([
         ],[
                 AC_MSG_RESULT([no]) 
         ])
+
 ],[
         AC_MSG_RESULT([no])
 ])
@@ -1616,6 +2214,7 @@ LB_LINUX_TRY_COMPILE([
 # linux kernel may have 64-bit limits support
 #
 AC_DEFUN([LC_QUOTA64],
+if test x$enable_server = xyes ; then
 [AC_MSG_CHECKING([if kernel has 64-bit quota limits support])
 LB_LINUX_TRY_COMPILE([
         #include <linux/kernel.h>
@@ -1626,17 +2225,30 @@ LB_LINUX_TRY_COMPILE([
 ],[],[
         AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
         AC_MSG_RESULT([yes])
-
 ],[
-        AC_MSG_WARN([4 TB (or larger) block quota limits can only be used with OSTs not larger than 4 TB.])
-        AC_MSG_WARN([Continuing with limited quota support.])
-        AC_MSG_WARN([quotacheck is needed for filesystems with recent quota versions.])
-        AC_MSG_RESULT([no])
+        tmp_flags="$EXTRA_KCFLAGS"
+        EXTRA_KCFLAGS="-I $LINUX/fs"
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/kernel.h>
+                #include <linux/fs.h>
+                #include <quotaio_v2.h>
+                struct v2r1_disk_dqblk dqblk_r1;
+        ],[],[
+                AC_DEFINE(HAVE_QUOTA64, 1, [have quota64])
+                AC_MSG_RESULT([yes])
+        ],[
+                AC_MSG_RESULT([no])
+                AC_MSG_WARN([4 TB (or larger) block quota limits can only be used with OSTs not larger than 4 TB.])
+                AC_MSG_WARN([Continuing with limited quota support.])
+                AC_MSG_WARN([quotacheck is needed for filesystems with recent quota versions.])
+        ])
+        EXTRA_KCFLAGS=$tmp_flags
 ])
+fi
 ])
 
 # LC_SECURITY_PLUG  # for SLES10 SP2
-# check security plug in sles10 sp2 kernel 
+# check security plug in sles10 sp2 kernel
 AC_DEFUN([LC_SECURITY_PLUG],
 [AC_MSG_CHECKING([If kernel has security plug support])
 LB_LINUX_TRY_COMPILE([
@@ -1656,6 +2268,32 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+AC_DEFUN([LC_PERCPU_COUNTER],
+[AC_MSG_CHECKING([if have struct percpu_counter defined])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/percpu_counter.h>
+],[],[
+        AC_DEFINE(HAVE_PERCPU_COUNTER, 1, [percpu_counter found])
+        AC_MSG_RESULT([yes])
+
+        AC_MSG_CHECKING([if percpu_counter_inc takes the 2nd argument])
+        LB_LINUX_TRY_COMPILE([
+                #include <linux/percpu_counter.h>
+        ],[
+                struct percpu_counter c;
+                percpu_counter_init(&c, 0);
+        ],[
+                AC_DEFINE(HAVE_PERCPU_2ND_ARG, 1, [percpu_counter_init has two
+                                                   arguments])
+                AC_MSG_RESULT([yes])
+        ],[
+                AC_MSG_RESULT([no])
+        ])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
 #
 # LC_CONFIGURE
 #
@@ -1664,6 +2302,10 @@ LB_LINUX_TRY_COMPILE([
 AC_DEFUN([LC_CONFIGURE],
 [LC_CONFIG_OBD_BUFFER_SIZE
 
+if test $target_cpu == "i686" -o $target_cpu == "x86_64"; then
+        CFLAGS="$CFLAGS -Werror"
+fi
+
 # include/liblustre.h
 AC_CHECK_HEADERS([asm/page.h sys/user.h sys/vfs.h stdint.h blkid/blkid.h])
 
@@ -1766,6 +2408,7 @@ lustre/kernel_patches/targets/2.6-rhel5.target
 lustre/kernel_patches/targets/2.6-fc5.target
 lustre/kernel_patches/targets/2.6-patchless.target
 lustre/kernel_patches/targets/2.6-sles10.target
+lustre/kernel_patches/targets/2.6-sles11.target
 lustre/kernel_patches/targets/hp_pnnl-2.4.target
 lustre/kernel_patches/targets/rh-2.4.target
 lustre/kernel_patches/targets/rhel-2.4.target
@@ -1774,6 +2417,7 @@ lustre/kernel_patches/targets/sles-2.4.target
 lustre/ldlm/Makefile
 lustre/liblustre/Makefile
 lustre/liblustre/tests/Makefile
+lustre/liblustre/tests/mpi/Makefile
 lustre/llite/Makefile
 lustre/llite/autoMakefile
 lustre/lov/Makefile
@@ -1804,8 +2448,8 @@ lustre/ptlrpc/autoMakefile
 lustre/quota/Makefile
 lustre/quota/autoMakefile
 lustre/scripts/Makefile
-lustre/scripts/version_tag.pl
 lustre/tests/Makefile
+lustre/tests/mpi/Makefile
 lustre/utils/Makefile
 ])
 case $lb_target_os in
diff --git a/lustre/autoconf/lustre-version.ac b/lustre/autoconf/lustre-version.ac
index 8afb36e..9b0ae63 100644
--- a/lustre/autoconf/lustre-version.ac
+++ b/lustre/autoconf/lustre-version.ac
@@ -1,14 +1,14 @@
 m4_define([LUSTRE_MAJOR],[1])
-m4_define([LUSTRE_MINOR],[6])
-m4_define([LUSTRE_PATCH],[7])
-m4_define([LUSTRE_FIX],[2])
+m4_define([LUSTRE_MINOR],[8])
+m4_define([LUSTRE_PATCH],[1])
+m4_define([LUSTRE_FIX],[0])
 # Note: we're starting prerelease versions at 50 this time.
 
 dnl # don't forget to update the service tags info
-m4_define([CLIENT_URN],["LUSTRE-167-CLT"])
-m4_define([MDS_URN],["LUSTRE-167-MDS"])
-m4_define([MGS_URN],["LUSTRE-167-MGS"])
-m4_define([OSS_URN],["LUSTRE-167-OSS"])
+m4_define([CLIENT_URN],["LUSTRE-181-CLT"])
+m4_define([MDS_URN],["LUSTRE-181-MDS"])
+m4_define([MGS_URN],["LUSTRE-181-MGS"])
+m4_define([OSS_URN],["LUSTRE-181-OSS"])
 
 dnl # liblustre delta is 0.0.1.32 , next version with fixes is ok, but
 dnl # after following release candidate/beta would spill this warning already.
diff --git a/lustre/contrib/Makefile.in b/lustre/contrib/Makefile.in
index badd47f..01fee10 100644
--- a/lustre/contrib/Makefile.in
+++ b/lustre/contrib/Makefile.in
@@ -176,9 +176,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/doc/Makefile.am b/lustre/doc/Makefile.am
index 16fe376..d4d36b6 100644
--- a/lustre/doc/Makefile.am
+++ b/lustre/doc/Makefile.am
@@ -47,8 +47,9 @@ TEXEXPAND = texexpand
 SUFFIXES = .lin .lyx .pdf .ps .sgml .html .txt .tex .fig .eps .dvi
 
 MANFILES = lustre.7 lfs.1 mount.lustre.8 mkfs.lustre.8 tunefs.lustre.8 lctl.8 \
-	llverdev.8 llbackup.8 llapi_quotactl.3 llobdstat.8 llstat.8 plot-llstat.8 \
-	l_getgroups.8 lst.8 routerstat.8 lshowmount.8 ll_recover_lost_found_objs.8
+	llverdev.8 llbackup.8 llapi_quotactl.3 llobdstat.8 llstat.8 \
+	plot-llstat.8 l_getgroups.8 lst.8 routerstat.8 lshowmount.8 \
+	ll_recover_lost_found_objs.8 llog_reader.8 llapi_file_open.3
 if UTILS
 man_MANS = $(MANFILES)
 endif
diff --git a/lustre/doc/Makefile.in b/lustre/doc/Makefile.in
index d30086f..b6bfb5f 100644
--- a/lustre/doc/Makefile.in
+++ b/lustre/doc/Makefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -341,8 +341,9 @@ TEXEXPAND = texexpand
 SUFFIXES = .lin .lyx .pdf .ps .sgml .html .txt .tex .fig .eps .dvi
 
 MANFILES = lustre.7 lfs.1 mount.lustre.8 mkfs.lustre.8 tunefs.lustre.8 lctl.8 \
-	llverdev.8 llbackup.8 llapi_quotactl.3 llobdstat.8 llstat.8 plot-llstat.8 \
-	l_getgroups.8 lst.8 routerstat.8 lshowmount.8 ll_recover_lost_found_objs.8
+	llverdev.8 llbackup.8 llapi_quotactl.3 llobdstat.8 llstat.8 \
+	plot-llstat.8 l_getgroups.8 lst.8 routerstat.8 lshowmount.8 \
+	ll_recover_lost_found_objs.8 llog_reader.8 llapi_file_open.3
 
 @UTILS_TRUE at man_MANS = $(MANFILES)
 
diff --git a/lustre/doc/lfs.1 b/lustre/doc/lfs.1
index 2f1b7e5..baf9906 100644
--- a/lustre/doc/lfs.1
+++ b/lustre/doc/lfs.1
@@ -17,18 +17,27 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
         \fB[[!] --uid|-u N] [[!] --user|-U <name>]
         \fB<dirname|filename>\fR
 .br
+.B lfs osts
+.br
 .B lfs getstripe [--obd|-O <uuid>] [--quiet|-q] [--verbose|-v] 
-              \fB[--recursive|-r] <dirname|filename>\fR
+        \fB[--recursive|-r] <dirname|filename>\fR
 .br
 .B lfs setstripe [--size|-s stripe-size] [--count|-c stripe-cnt]
-              \fB[--index|-i start-ost] <filename|dirname>\fR
+        \fB[--offset|-o start-ost] [--pool|-p pool-name]
+        \fB<dir|filename>\fR
 .br
-.B lfs setstripe -d <dirname>
+.B lfs setstripe -d <dir>
 .br
-.B lfs quotachown [-i] <filesystem>
+.B lfs poollist <filesystem>[.<pool>] | <pathname>
+.br
+.B lfs quota [-v] [-o obd_uuid] [-u <username>|-g <groupname>] <filesystem>
+.br
+.B lfs quota -t <-u|-g> <filesystem>
 .br
 .B lfs quotacheck [-ug] <filesystem>
 .br
+.B lfs quotachown [-i] <filesystem>
+.br
 .B lfs quotaon [-ugf] <filesystem>
 .br
 .B lfs quotaoff [-ug] <filesystem>
@@ -52,19 +61,14 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
              \fB[--inode-grace <inode-grace>]
              \fB<filesystem>\fR
 .br
-.B lfs setquota -t <-u|-g>
+.B lfs setquota -t [-u|-g]
              \fB[-b <block-grace>] [-i <inode-grace>]
              \fB<filesystem>\fR
 .br
-
-.B lfs quota [-v] [-o obd_uuid] [-u <username>|-g <groupname>] <filesystem>
-.br
-.B lfs quota -t <-u|-g> <filesystem>
-.br
 .B lfs help
 .SH DESCRIPTION
 .B lfs
-can be used to create a new file with a specific striping pattern, determine the default striping pattern, gather the extended attributes (object numbers and location) for a specific file. It can be invoked interactively without any arguments or in a non-interactive mode with one of the arguements supported. 
+can be used to create a new file with a specific striping pattern, determine the default striping pattern, gather the extended attributes (object numbers and location) for a specific file, find files with specific attributes, list OST information, or set quota limits. It can be invoked interactively without any arguments or in a non-interactive mode with one of the arguements supported. 
 .SH OPTIONS
 The various options supported by lctl are listed and explained below:
 .TP
@@ -75,15 +79,17 @@ Display the status of MDS or OSTs (as specified in the command) or all the serve
 Report filesystem disk space usage or inodes usage of each MDT/OST.
 .TP
 .B find 
-To search the directory tree rooted at the given dir/file name for the files that match the given parameters: \fB--atime\fR (file was last accessed N*24 hours ago), \fB--ctime\fR (file's status was last changed N*24 hours ago), \fB--mtime\fR (file's data was last modified N*24 hours ago), \fB--obd\fR (file has an object on a specific OST or OSTs), \fB--size\fR (file has size in bytes, or \fBk\fRilo-, \fBM\fRega-, \fBG\fRiga-, \fBT\fRera-, \fBP\fReta-, or \fBE\fRxabytes if a suffix is given), \fB--type\fR (file has the type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory, \fBp\fRipe, \fBf\fRile, sym\fBl\fRink, \fBs\fRocket, or \fBD\fRoor (Solaris)), \fB--uid\fR (file has specific numeric user ID), \fB--user\fR (file owned by specific user, numeric user ID allowed), \fB--gid\fR (file has specific group ID), \fB--group\fR (file belongs to specific group, numeric group ID allowed). The option \fB--maxdepth\fR allows find to decend at most N levels of directory tree. The options \fB--print\fR and \fB--print0\fR print full file name, followed by a newline or NUL character correspondingly.  Using \fB!\fR before an option negates its meaning (\fIfiles NOT matching the parameter\fR).  Using \fB+\fR before a numeric value means \fIfiles with the parameter OR MORE\fR, while \fB-\fR before a numeric value means \fIfiles with the parameter OR LESS\fR.
-.TP
-.B getstripe
-To list the striping info for a given filename or files in a directory, optionally recursively, for all files in a directory tree: \fB--quiet\fR (don't print object IDs), \fB--verbose\fR (print striping parameters), \fB--recursive\fR (recurse into subdirectories).
+To search the directory tree rooted at the given dir/file name for the files that match the given parameters: \fB--atime\fR (file was last accessed N*24 hours ago), \fB--ctime\fR (file's status was last changed N*24 hours ago), \fB--mtime\fR (file's data was last modified N*24 hours ago), \fB--obd\fR (file has an object on a specific OST or OSTs), \fB--size\fR (file has size in bytes, or \fBk\fRilo-, \fBM\fRega-, \fBG\fRiga-, \fBT\fRera-, \fBP\fReta-, or \fBE\fRxabytes if a suffix is given), \fB--type\fR (file has the type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory, \fBp\fRipe, \fBf\fRile, sym\fBl\fRink, \fBs\fRocket, or \fBD\fRoor (Solaris)), \fB--uid\fR (file has specific numeric user ID), \fB--user\fR (file owned by specific user, numeric user ID allowed), \fB--gid\fR (file has specific group ID), \fB--group\fR (file belongs to specific group, numeric group ID allowed). The option \fB--maxdepth\fR limits find to decend at most N levels of directory tree. The options \fB--print\fR and \fB--print0\fR print full file name, followed by a newline or NUL character correspondingly.  Using \fB!\fR before an option negates its meaning (\fIfiles NOT matching the parameter\fR).  Using \fB+\fR before a numeric value means \fIfiles with the parameter OR MORE\fR, while \fB-\fR before a numeric value means \fIfiles with the parameter OR LESS\fR.
 .TP
 .B osts 
 List all the OSTs for the filesystem
 .TP
-.B setstripe [--size stripe-size] [--count stripe-cnt] [--index start-ost]
+.B getstripe
+To list the striping info for a given filename or files in a directory, optionally recursively, for all files in a directory tree: \fB--quiet\fR (don't print object IDs), \fB--verbose\fR (print striping parameters), \fB--recursive\fR (recurse into subdirectories).
+.TP
+.B setstripe [--size stripe-size] [--count stripe-cnt] 
+	\fB[--offset start-ost] [--pool pool-name]\fR
+.br
 To create a new file, or set the directory default, with the specified striping parameters.  The
 .I stripe-count
 is the number of OSTs to stripe a file over. A
@@ -96,15 +102,24 @@ is the number of bytes to store on each OST before moving to the next OST.  A
 .I stripe-size
 of 0 means to use the filesystem-wide default stripe size (default 1MB).  The
 .I start-ost
-is the OST index (starting at 0) on which to start striping for this file.  A
+is the OST index (base 10, starting at 0) on which to start striping for this file.  A
 .I start-ost
-of -1 allows the MDS to specify the starting index and it is strongly
-recommended that the starting OST not be given, as this allows space and
-load balancing to be done by the MDS as needed.
+of -1 allows the MDS to choose the starting index and it is strongly recommended, as this allows space and load balancing to be done by the MDS as needed.  The
+.I pool-name
+is the name of a predefined pool of OSTs (see 
+.I lctl
+) that will be used for striping. The 
+.I stripe-count, stripe-size, start-ost
+will be used as well; the 
+.I start-ost
+must be part of the pool or an error will be returned. 
 .TP
-.B lfs setstripe -d
+.B setstripe -d
 Delete the default striping on the specified directory.
 .TP
+.B poollist <filesystem>[.<pool>] | <pathname>
+List the pools in \fBfilesystem\fR or \fBpathname\fR, or the OSTs in \fBfilesystem.pool\fR
+.TP
 .B quotachown
 To change files' owner and group on OSTs of the specified filesystem
 .TP
diff --git a/lustre/doc/llapi_file_open.3 b/lustre/doc/llapi_file_open.3
new file mode 100644
index 0000000..0d84d72
--- /dev/null
+++ b/lustre/doc/llapi_file_open.3
@@ -0,0 +1,154 @@
+.TH LLAPI_FILE_OPEN 3 "2009 Jul 10" Lustre API
+.SH NAME
+llapi_file_open, llapi_file_create \- open and possibly create a file or a device on a Lustre filesystem
+.SH SYNOPSIS
+.nf
+.B #include <sys/types.h>
+.B #include <sys/stat.h>
+.B #include <fcntl.h>
+.B #include <liblustre.h>
+.B #include <lustre/lustre_idl.h>
+.B #include <lustre/liblustreapi.h>
+.B #include <lustre/lustre_user.h>
+.sp
+.BI "int llapi_file_open(const char *"name ", int " flags ", int " mode "," 
+.BI "                    unsigned long long " stripe_size ", int " stripe_offset "," 
+.BI "                    int " stripe_count ", int " stripe_pattern );
+
+.BI "int llapi_file_create(const char *" name ", unsigned long long " stripe_size ","
+.BI "                      int " stripe_offset ", int " stripe_count ","
+.BI "                      int " stripe_pattern );
+.sp
+.fi
+.SH DESCRIPTION
+.LP
+.B llapi_file_create(\|)
+call is equivalent to 
+.B llapi_file_open
+call with 
+.I flags 
+equal to
+.B O_CREAT|O_WRONLY
+and
+.I mode
+equal to
+.BR 0644 ,
+followed by file close.
+.PP
+.B llapi_file_open(\|)
+opens a file with a given 
+.I name
+on a Lustre filesystem.
+.TP 15
+.I flags
+can be a combination of 
+.BR O_RDONLY ,
+.BR O_WRONLY ,
+.BR O_RDWR ,
+.BR O_CREAT ,
+.BR O_EXCL ,
+.BR O_NOCTTY ,
+.BR O_TRUNC ,
+.BR O_APPEND ,
+.BR O_NONBLOCK ,
+.BR O_SYNC ,
+.BR FASYNC ,
+.BR O_DIRECT ,
+.BR O_LARGEFILE ,
+.BR O_DIRECTORY ,
+.BR O_NOFOLLOW ,
+.BR O_NOATIME .
+
+Refer to
+.BR open(2)
+man page for a detailed description.
+.TP 15
+.I mode
+specifies the permission bits to be used for a new file when
+.BR O_CREAT
+is used.
+
+Refer to
+.BR open(2)
+man page for a detailed description.
+.TP 15
+.I stripe_size
+specifies stripe size in bytes and should be multiple of 64 KiB not exceeding 4 GiB.
+.TP 15
+.I stripe_offset
+specifies an OST index from which the file should start, -1 to use the default setting.
+.TP 15
+.I stripe_count
+specifies number of OSTs to stripe the file across, -1 to use the default setting.
+.TP 15
+.I stripe_pattern
+specifies striping pattern, only LOV_PATTERN_RAID0 is available in this Lustre version, 0 to use the default setting.
+.SH RETURN VALUES
+.LP
+.B llapi_file_open(\|) 
+and 
+.B llapi_file_create(\|) 
+return:
+.TP
+>=0
+on success, for
+.B llapi_file_open
+the return value is a file descriptor.
+.TP
+<0
+on failure, the absolute value is an error code.
+.SH ERRORS
+.TP 15
+.SM EINVAL
+.I stripe_size
+or
+.I stripe_offset
+or
+.I stripe_count
+or
+.I stripe_pattern
+is invalid.
+.TP
+.SM EEXIST
+Striping information has already been set and cannot be altered.
+.IP
+.I name
+already exists.
+.TP
+.SM EALREADY
+Striping information has already been set and cannot be altered.
+.TP
+.SM ENOTTY
+.I name
+may not point to a Lustre filesystem.
+.SH "EXAMPLE"
+.nf
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <liblustre.h>
+#include <lustre/lustre_idl.h>
+#include <lustre/liblustreapi.h>
+#include <lustre/lustre_user.h>
+int main(int argc, char *argv[])
+{
+        int rc;
+
+        if (argc != 2)
+                return -1;
+
+        rc = llapi_file_create(argv[1], 1048576, 0, 2, LOV_PATTERN_RAID0);
+        if (rc < 0) {
+                fprintf(stderr, "file creation has failed, %s\\n", strerror(-rc));
+                return -1;
+        }
+        printf("%s with stripe size 1048576, striped across 2 OSTs,"
+               " has been created!\\n", argv[1]);
+        return 0;
+}
+.fi
+.SH "SEE ALSO"
+.BR open (2),
+.BR lustre (7)
diff --git a/lustre/doc/llog_reader.8 b/lustre/doc/llog_reader.8
new file mode 100644
index 0000000..b77542c
--- /dev/null
+++ b/lustre/doc/llog_reader.8
@@ -0,0 +1,40 @@
+.TH llog_reader 8 "2009 Apr 02" Lustre "System management commands"
+.SH NAME
+llog_reader \- lustre on-disk log parsing utility
+.SH SYNOPSIS
+.B "llog_reader filename"
+.br
+.SH DESCRIPTION
+.B llog_reader
+parses the binary format of Lustre's on-disk configuration logs.
+It can only read the logs.  Use
+.B tunefs.lustre
+to write to them.
+.LP
+To examine a log file on a stopped Lustre server, first mount its
+backing file system as ldiskfs, then use
+.B llog_reader
+to dump the log file's contents, e.g.
+.IP
+.nf
+mount -t ldiskfs /dev/sda /mnt/mgs
+llog_reader /mnt/mgs/CONFIGS/tfs-client
+.fi
+.LP
+To examine the same log file on a running Lustre server, use the
+ldiskfs-enabled debugfs utility (called
+.B debug.ldiskfs
+on some distros) to extract the file, e.g.
+.IP
+.nf
+debugfs -c -R 'dump CONFIGS/tfs-client /tmp/tfs-client' /dev/sda
+llog_reader /tmp/tfs-client
+.fi
+.SH CAVEATS
+Although they are stored in the CONFIGS directory, \fImountdata\fR
+files do not use the config log format and will confuse \fBllog_reader\fR.
+.SH SEE ALSO
+Lustre Operations Manual, Section 21.1, \fITroubleshooting Lustre\fR.
+.br
+.BR lustre (7),
+.BR tunefs.lustre (8)
diff --git a/lustre/include/Makefile.in b/lustre/include/Makefile.in
index 125bff5..232ce39 100644
--- a/lustre/include/Makefile.in
+++ b/lustre/include/Makefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/include/class_hash.h b/lustre/include/class_hash.h
index e2b2b11..495b979 100644
--- a/lustre/include/class_hash.h
+++ b/lustre/include/class_hash.h
@@ -85,11 +85,9 @@ lh_hash(lustre_hash_t *lh, void *key, unsigned mask)
 {
         LASSERT(lh);
         LASSERT(LHO(lh));
+        LASSERT(LHP(lh, hash));
 
-        if (LHP(lh, hash))
-                return LHP(lh, hash)(lh, key, mask);
-
-        return -EOPNOTSUPP;
+        return LHP(lh, hash)(lh, key, mask);
 }
 
 static inline void *
@@ -225,8 +223,22 @@ __lustre_hash_bucket_del(lustre_hash_t *lh,
         return lh_put(lh, hnode);
 }
 
+/* Some hash init argument constants */
+#define HASH_POOLS_CUR_BITS 3
+#define HASH_POOLS_MAX_BITS 7
+#define HASH_UUID_CUR_BITS 7
+#define HASH_UUID_MAX_BITS 12
+#define HASH_NID_CUR_BITS 7
+#define HASH_NID_MAX_BITS 12
+#define HASH_NID_STATS_CUR_BITS 7
+#define HASH_NID_STATS_MAX_BITS 12
+#define HASH_LQS_CUR_BITS 7
+#define HASH_LQS_MAX_BITS 12
+#define HASH_CONN_CUR_BITS 5
+#define HASH_CONN_MAX_BITS 15
+
 /* Hash init/cleanup functions */
-lustre_hash_t *lustre_hash_init(char *name, unsigned int cur_bits, 
+lustre_hash_t *lustre_hash_init(char *name, unsigned int cur_bits,
                                 unsigned int max_bits,
                                 lustre_hash_ops_t *ops, int flags);
 void lustre_hash_exit(lustre_hash_t *lh);
@@ -252,9 +264,9 @@ void lustre_hash_for_each_empty(lustre_hash_t *lh, lh_for_each_cb, void *data);
 void lustre_hash_for_each_key(lustre_hash_t *lh, void *key,
                               lh_for_each_cb, void *data);
 
-/* 
+/*
  * Rehash - Theta is calculated to be the average chained
- * hash depth assuming a perfectly uniform hash funcion. 
+ * hash depth assuming a perfectly uniform hash funcion.
  */
 int lustre_hash_rehash(lustre_hash_t *lh, int bits);
 void lustre_hash_rehash_key(lustre_hash_t *lh, void *old_key,
@@ -272,7 +284,7 @@ static inline int __lustre_hash_theta_int(int theta)
 /* Return a fractional value between 0 and 999 */
 static inline int __lustre_hash_theta_frac(int theta)
 {
-        return ((theta * 1000) >> LH_THETA_BITS) - 
+        return ((theta * 1000) >> LH_THETA_BITS) -
                (__lustre_hash_theta_int(theta) * 1000);
 }
 
diff --git a/lustre/include/interval_tree.h b/lustre/include/interval_tree.h
index df85d56..d0d3ac2 100644
--- a/lustre/include/interval_tree.h
+++ b/lustre/include/interval_tree.h
@@ -93,7 +93,7 @@ static inline void interval_set(struct interval_node *node,
  *  - the callback returns INTERVAL_ITER_STOP when it thinks the iteration
  *    should be stopped. It will then cause the iteration function to return
  *    immediately with return value INTERVAL_ITER_STOP.
- *  - callbacks for interval_iterate and interval_iterate_reverse: Every 
+ *  - callbacks for interval_iterate and interval_iterate_reverse: Every
  *    nodes in the tree will be set to @node before the callback being called
  *  - callback for interval_search: Only overlapped node will be set to @node
  *    before the callback being called.
@@ -112,15 +112,15 @@ enum interval_iter interval_search(struct interval_node *root,
                                    interval_callback_t func, void *data);
 
 /* Iterate every node in the tree - by reverse order or regular order. */
-enum interval_iter interval_iterate(struct interval_node *root, 
+enum interval_iter interval_iterate(struct interval_node *root,
                                     interval_callback_t func, void *data);
 enum interval_iter interval_iterate_reverse(struct interval_node *root,
                                     interval_callback_t func,void *data);
 
-void interval_expand(struct interval_node *root, 
+void interval_expand(struct interval_node *root,
                      struct interval_node_extent *ext,
                      struct interval_node_extent *limiter);
-int interval_is_overlapped(struct interval_node *root, 
+int interval_is_overlapped(struct interval_node *root,
                            struct interval_node_extent *ex);
 struct interval_node *interval_find(struct interval_node *root,
                                     struct interval_node_extent *ex);
diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h
index dc1e481..0f76b89 100644
--- a/lustre/include/liblustre.h
+++ b/lustre/include/liblustre.h
@@ -210,17 +210,30 @@ typedef int (write_proc_t)(struct file *file, const char *buffer,
 
 static __inline__ int ext2_set_bit(int nr, void *addr)
 {
+#ifdef __BIG_ENDIAN
+        return set_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
+#else
         return set_bit(nr, addr);
+#endif
 }
 
 static __inline__ int ext2_clear_bit(int nr, void *addr)
 {
+#ifdef __BIG_ENDIAN
+        return clear_bit((nr ^ ((BITS_PER_LONG-1) & ~0x7)), addr);
+#else
         return clear_bit(nr, addr);
+#endif
 }
 
 static __inline__ int ext2_test_bit(int nr, void *addr)
 {
+#ifdef __BIG_ENDIAN
+        __const__ unsigned char *tmp = (__const__ unsigned char *) addr;
+        return (tmp[nr >> 3] >> (nr & 7)) & 1;
+#else
         return test_bit(nr, addr);
+#endif
 }
 
 /* modules */
@@ -337,6 +350,7 @@ typedef spinlock_t rwlock_t;
 #ifndef ERESTARTSYS
 #define ERESTARTSYS ERESTART
 #endif
+#undef HZ
 #define HZ 1
 
 /* random */
@@ -366,6 +380,7 @@ typedef struct {
          int size;
 } kmem_cache_t;
 #define SLAB_HWCACHE_ALIGN 0
+#define SLAB_DESTROY_BY_RCU 0
 static inline kmem_cache_t *
 kmem_cache_create(const char *name, size_t objsize, size_t cdum,
                   unsigned long d,
@@ -889,10 +904,10 @@ void posix_acl_release(struct posix_acl *acl)
 }
 
 #ifdef LIBLUSTRE_POSIX_ACL
- #ifndef posix_acl_xattr_entry 
+ #ifndef posix_acl_xattr_entry
   #define posix_acl_xattr_entry xattr_acl_entry
  #endif
- #ifndef posix_acl_xattr_header 
+ #ifndef posix_acl_xattr_header
   #define posix_acl_xattr_header xattr_acl_header
  #endif
  #ifndef posix_acl_xattr_size
diff --git a/lustre/include/linux/Makefile.in b/lustre/include/linux/Makefile.in
index 3df6a0c..a40322d 100644
--- a/lustre/include/linux/Makefile.in
+++ b/lustre/include/linux/Makefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h
index f8a5b11..34ea09e 100644
--- a/lustre/include/linux/lustre_compat25.h
+++ b/lustre/include/linux/lustre_compat25.h
@@ -56,7 +56,25 @@ struct ll_iattr_struct {
 #define ll_iattr_struct iattr
 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14) */
 
-#ifndef HAVE_SET_FS_PWD
+#ifdef HAVE_FS_STRUCT_USE_PATH
+static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
+                struct dentry *dentry)
+{
+        struct path path;
+	struct path old_pwd;
+
+        path.mnt = mnt;
+        path.dentry = dentry;
+        write_lock(&fs->lock);
+        old_pwd = fs->pwd;
+        path_get(&path);
+        fs->pwd = path;
+        write_unlock(&fs->lock);
+
+	if (old_pwd.dentry)
+		path_put(&old_pwd);
+}
+#else
 static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
                 struct dentry *dentry)
 {
@@ -75,9 +93,7 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
                 mntput(old_pwdmnt);
         }
 }
-#else
-#define ll_set_fs_pwd set_fs_pwd
-#endif /* HAVE_SET_FS_PWD */
+#endif /* HAVE_FS_STRUCT_USE_PATH */
 
 #ifdef HAVE_INODE_I_MUTEX
 #define UNLOCK_INODE_MUTEX(inode) do {mutex_unlock(&(inode)->i_mutex); } while(0)
@@ -151,7 +167,12 @@ void groups_free(struct group_info *ginfo);
 #endif
 
 /* XXX our code should be using the 2.6 calls, not the other way around */
+#ifndef HAVE_TRYLOCK_PAGE
 #define TryLockPage(page)               TestSetPageLocked(page)
+#else
+#define TryLockPage(page)               (!trylock_page(page))
+#endif
+
 #define Page_Uptodate(page)             PageUptodate(page)
 #define ll_redirty_page(page)           set_page_dirty(page)
 
@@ -159,7 +180,12 @@ void groups_free(struct group_info *ginfo);
 
 #define LTIME_S(time)                   (time.tv_sec)
 #define ll_path_lookup                  path_lookup
+
+#ifdef HAVE_EXPORT_INODE_PERMISSION
+#define ll_permission(inode,mask,nd)    inode_permission(inode,mask)
+#else
 #define ll_permission(inode,mask,nd)    permission(inode,mask,nd)
+#endif
 
 #define ll_pgcache_lock(mapping)          spin_lock(&mapping->page_lock)
 #define ll_pgcache_unlock(mapping)        spin_unlock(&mapping->page_lock)
@@ -262,23 +288,32 @@ static inline int mapping_has_pages(struct address_space *mapping)
 #define KIOBUF_GET_BLOCKS(k) ((k)->blocks)
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
-#define ll_set_dflags(dentry, flags) do { dentry->d_vfs_flags |= flags; } while(0)
+#ifdef HAVE_SECURITY_PLUG
+#ifdef HAVE_VFS_SYMLINK_5ARGS
+#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
+                vfs_symlink(dir, dentry, mnt, path, mode)
+#else
+#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
+                vfs_symlink(dir, dentry, mnt, path)
+#endif
+#else
+#ifdef HAVE_4ARGS_VFS_SYMLINK
+#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
+                vfs_symlink(dir, dentry, path, mode)
+#else
 #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
                        vfs_symlink(dir, dentry, path)
+#endif
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
+#define ll_set_dflags(dentry, flags) do { dentry->d_vfs_flags |= flags; } while(0)
 #else
 #define ll_set_dflags(dentry, flags) do { \
                 spin_lock(&dentry->d_lock); \
                 dentry->d_flags |= flags; \
                 spin_unlock(&dentry->d_lock); \
         } while(0)
-#ifdef HAVE_SECURITY_PLUG
-#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
-                vfs_symlink(dir, dentry, mnt, path, mode)
-#else
-#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \
-                vfs_symlink(dir, dentry, path, mode)
-#endif
 #endif
 
 #ifndef container_of
@@ -313,6 +348,45 @@ static inline int mapping_has_pages(struct address_space *mapping)
 #define filemap_fdatawrite(mapping)      filemap_fdatasync(mapping)
 #endif
 
+#include <linux/mpage.h>        /* for generic_writepages */
+#ifndef HAVE_FILEMAP_FDATAWRITE_RANGE
+#include <linux/backing-dev.h>  /* for mapping->backing_dev_info */
+static inline int filemap_fdatawrite_range(struct address_space *mapping,
+                                           loff_t start, loff_t end)
+{
+        int rc;
+        struct writeback_control wbc = {
+                .sync_mode = WB_SYNC_ALL,
+                .nr_to_write = (end - start + PAGE_SIZE - 1) >> PAGE_SHIFT,
+        };
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+        wbc.range_start = start;
+        wbc.range_end = end;
+#else
+        wbc.start = start;
+        wbc.end = end;
+#endif
+
+#ifdef HAVE_MAPPING_CAP_WRITEBACK_DIRTY
+        if (!mapping_cap_writeback_dirty(mapping))
+		rc = 0;
+#else
+        if (mapping->backing_dev_info->memory_backed)
+                rc = 0;
+#endif
+        /* do_writepages() */
+        else if (mapping->a_ops->writepages)
+                rc = mapping->a_ops->writepages(mapping, &wbc);
+        else
+                rc = generic_writepages(mapping, &wbc);
+        return rc;
+}
+#else
+int filemap_fdatawrite_range(struct address_space *mapping,
+                             loff_t start, loff_t end);
+#endif
+
 #ifdef HAVE_VFS_KERN_MOUNT
 static inline 
 struct vfsmount *
@@ -364,8 +438,21 @@ int ll_unregister_blkdev(unsigned int dev, const char *name)
 #define LL_RENAME_DOES_D_MOVE	FS_ODD_RENAME
 #endif
 
+#ifdef HAVE_FILE_REMOVE_SUID
+#define ll_remove_suid(file, mnt)       file_remove_suid(file)
+#else
+ #ifdef HAVE_SECURITY_PLUG
+  #define ll_remove_suid(file,mnt)      remove_suid(file->f_dentry,mnt)
+ #else
+  #define ll_remove_suid(file,mnt)      remove_suid(file->f_dentry)
+ #endif
+#endif
+
+#ifndef HAVE_SYNCHRONIZE_RCU
+#define synchronize_rcu() synchronize_kernel()
+#endif
+
 #ifdef HAVE_SECURITY_PLUG
-#define ll_remove_suid(inode,mnt)               remove_suid(inode,mnt)
 #define ll_vfs_rmdir(dir,entry,mnt)             vfs_rmdir(dir,entry,mnt)
 #define ll_vfs_mkdir(inode,dir,mnt,mode)        vfs_mkdir(inode,dir,mnt,mode)
 #define ll_vfs_link(old,mnt,dir,new,mnt1)       vfs_link(old,mnt,dir,new,mnt1)
@@ -377,7 +464,6 @@ int ll_unregister_blkdev(unsigned int dev, const char *name)
 #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \
                 vfs_rename(old,old_dir,mnt,new,new_dir,mnt1)
 #else
-#define ll_remove_suid(inode,mnt)               remove_suid(inode)
 #define ll_vfs_rmdir(dir,entry,mnt)             vfs_rmdir(dir,entry)
 #define ll_vfs_mkdir(inode,dir,mnt,mode)        vfs_mkdir(inode,dir,mode)
 #define ll_vfs_link(old,mnt,dir,new,mnt1)       vfs_link(old,dir,new)
@@ -388,6 +474,67 @@ int ll_unregister_blkdev(unsigned int dev, const char *name)
                 vfs_rename(old,old_dir,new,new_dir)
 #endif
 
+#ifndef for_each_possible_cpu
+#define for_each_possible_cpu(i) for_each_cpu(i)
+#endif
+
+#ifndef cpu_to_node
+#define cpu_to_node(cpu)         0
+#endif
+
+#ifdef HAVE_REGISTER_SHRINKER
+typedef int (*shrinker_t)(int nr_to_scan, gfp_t gfp_mask);
+
+static inline
+struct shrinker *set_shrinker(int seek, shrinker_t func)
+{
+        struct shrinker *s;
+
+        s = kmalloc(sizeof(*s), GFP_KERNEL);
+        if (s == NULL)
+                return (NULL);
+
+        s->shrink = func;
+        s->seeks = seek;
+
+        register_shrinker(s);
+
+        return s;
+}
+
+static inline
+void remove_shrinker(struct shrinker *shrinker) 
+{
+        if (shrinker == NULL)
+                return;
+
+        unregister_shrinker(shrinker);
+        kfree(shrinker);
+}
+#endif
+
+#ifdef HAVE_BIO_ENDIO_2ARG
+#define cfs_bio_io_error(a,b)   bio_io_error((a))
+#define cfs_bio_endio(a,b,c)    bio_endio((a),(c))
+#else
+#define cfs_bio_io_error(a,b)   bio_io_error((a),(b))
+#define cfs_bio_endio(a,b,c)    bio_endio((a),(b),(c))
+#endif
+
+#ifdef HAVE_FS_STRUCT_USE_PATH
+#define cfs_fs_pwd(fs)       ((fs)->pwd.dentry)
+#define cfs_fs_mnt(fs)       ((fs)->pwd.mnt)
+#define cfs_path_put(nd)     path_put(&(nd)->path)
+#else
+#define cfs_fs_pwd(fs)       ((fs)->pwd)
+#define cfs_fs_mnt(fs)       ((fs)->pwdmnt)
+#define cfs_path_put(nd)     path_release(nd)
+#endif
+
+#ifndef list_for_each_safe_rcu
+#define list_for_each_safe_rcu(a,b,c) list_for_each_rcu(a, c)
+#endif
+
 #ifndef abs
 static inline int abs(int x)
 {
@@ -407,5 +554,72 @@ static inline long labs(long x)
 #define __fls fls
 #endif
 
+#ifdef HAVE_INVALIDATE_INODE_PAGES
+#define invalidate_mapping_pages(mapping,s,e) invalidate_inode_pages(mapping)
+#endif
+
+#ifndef SLAB_DESTROY_BY_RCU
+#define SLAB_DESTROY_BY_RCU 0
+#endif
+
+#ifdef HAVE_INODE_IPRIVATE
+#define INODE_PRIVATE_DATA(inode)       ((inode)->i_private)
+#else
+#define INODE_PRIVATE_DATA(inode)       ((inode)->u.generic_ip)
+#endif
+
+#ifndef	HAVE_SYSCTL_VFS_CACHE_PRESSURE
+#define	sysctl_vfs_cache_pressure	100
+#endif
+
+#ifdef HAVE_SB_HAS_QUOTA_ACTIVE
+#define ll_sb_has_quota_active(sb, type) sb_has_quota_active(sb, type)
+#else
+#define ll_sb_has_quota_active(sb, type) sb_has_quota_enabled(sb, type)
+#endif
+
+#ifdef HAVE_SB_ANY_QUOTA_ACTIVE
+#define ll_sb_any_quota_active(sb) sb_any_quota_active(sb)
+#else
+#define ll_sb_any_quota_active(sb) sb_any_quota_enabled(sb)
+#endif
+
+static inline int
+ll_quota_on(struct super_block *sb, int off, int ver, char *name, int remount)
+{
+        if (sb->s_qcop->quota_on) {
+                return sb->s_qcop->quota_on(sb, off, ver, name
+#ifdef HAVE_QUOTA_ON_5ARGS
+                                            , remount
+#endif
+                                           );
+        }
+        else
+                return -ENOSYS;
+}
+
+static inline int ll_quota_off(struct super_block *sb, int off, int remount)
+{
+        if (sb->s_qcop->quota_off) {
+                return sb->s_qcop->quota_off(sb, off
+#ifdef HAVE_QUOTA_OFF_3ARGS
+                                             , remount
+#endif
+                                            );
+        }
+        else
+                return -ENOSYS;
+}
+
+#ifndef HAVE_BI_HW_SEGMENTS
+#define bio_hw_segments(q, bio) 0
+#endif
+
+#ifdef HAVE_FILE_UPDATE_TIME
+#define ll_update_time(file) file_update_time(file)
+#else
+#define ll_update_time(file) inode_update_time(file->f_mapping->host, 1)
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */
diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h
index 0e9f801..65a9e67 100644
--- a/lustre/include/linux/lustre_fsfilt.h
+++ b/lustre/include/linux/lustre_fsfilt.h
@@ -331,11 +331,24 @@ static inline int fsfilt_setattr(struct obd_device *obd, struct dentry *dentry,
         return rc;
 }
 
-static inline int fsfilt_iocontrol(struct obd_device *obd, struct inode *inode,
-                                   struct file *file, unsigned int cmd,
-                                   unsigned long arg)
+static inline int fsfilt_iocontrol(struct obd_device *obd, struct dentry *dentry,
+                                   unsigned int cmd, unsigned long arg)
 {
-        return obd->obd_fsops->fs_iocontrol(inode, file, cmd, arg);
+        struct file *dummy_file = NULL;
+        int ret;
+
+        OBD_ALLOC_PTR(dummy_file);
+        if (!dummy_file)
+                return(-ENOMEM);
+
+        dummy_file->f_dentry = dentry;
+        dummy_file->f_vfsmnt = obd->u.obt.obt_vfsmnt;
+
+        ret = obd->obd_fsops->fs_iocontrol(dentry->d_inode, dummy_file, cmd,
+                                           arg);
+
+        OBD_FREE_PTR(dummy_file);
+        return ret;
 }
 
 static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode,
diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h
index 1092c61..875615a 100644
--- a/lustre/include/linux/lustre_lib.h
+++ b/lustre/include/linux/lustre_lib.h
@@ -49,7 +49,6 @@
 # include <string.h>
 # include <sys/types.h>
 #else
-# include <asm/semaphore.h>
 # include <linux/rwsem.h>
 # include <linux/sched.h>
 # include <linux/signal.h>
diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h
index 9fe241b..2b64bb1 100644
--- a/lustre/include/linux/lustre_lite.h
+++ b/lustre/include/linux/lustre_lite.h
@@ -60,6 +60,36 @@
 #include <linux/lustre_compat25.h>
 #include <linux/pagemap.h>
 
+#ifdef HAVE_PERCPU_COUNTER
+#include <linux/percpu_counter.h>
+
+typedef struct percpu_counter lcounter_t;
+
+#define lcounter_read_positive(counter) percpu_counter_read_positive(counter)
+#define lcounter_read(counter)          (int)percpu_counter_read(counter)
+#define lcounter_inc(counter)           percpu_counter_inc(counter)
+#define lcounter_dec(counter)           percpu_counter_dec(counter)
+
+#ifdef HAVE_PERCPU_2ND_ARG
+# define lcounter_init(counter)          percpu_counter_init(counter, 0)
+#else
+# define lcounter_init(counter)          percpu_counter_init(counter)
+#endif
+
+#define lcounter_destroy(counter)       percpu_counter_destroy(counter)
+
+#else
+typedef struct { atomic_t count; } lcounter_t;
+
+#define lcounter_read(counter)          atomic_read(&counter->count)
+#define lcounter_read_positive(counter) lcounter_read(counter)
+#define lcounter_inc(counter)           atomic_inc(&counter->count)
+#define lcounter_dec(counter)           atomic_dec(&counter->count)
+#define lcounter_init(counter)          atomic_set(&counter->count, 0)
+#define lcounter_destroy(counter)       
+
+#endif /* if defined HAVE_PERCPU_COUNTER */
+
 /* lprocfs.c */
 enum {
          LPROC_LL_DIRTY_HITS = 0,
diff --git a/lustre/include/linux/lustre_patchless_compat.h b/lustre/include/linux/lustre_patchless_compat.h
index 6a1b9f5..f5ba194 100644
--- a/lustre/include/linux/lustre_patchless_compat.h
+++ b/lustre/include/linux/lustre_patchless_compat.h
@@ -52,7 +52,7 @@ static inline void ll_remove_from_page_cache(struct page *page)
 
         BUG_ON(!PageLocked(page));
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
+#ifdef HAVE_RW_TREE_LOCK
         write_lock_irq(&mapping->tree_lock);
 #else
 	spin_lock_irq(&mapping->tree_lock);
@@ -65,7 +65,7 @@ static inline void ll_remove_from_page_cache(struct page *page)
 #else
 	__dec_zone_page_state(page, NR_FILE_PAGES);
 #endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
+#ifdef HAVE_RW_TREE_LOCK
         write_unlock_irq(&mapping->tree_lock);
 #else
 	spin_unlock_irq(&mapping->tree_lock);
diff --git a/lustre/include/linux/lvfs_linux.h b/lustre/include/linux/lvfs_linux.h
index 7a1712a..e53f1e0 100644
--- a/lustre/include/linux/lvfs_linux.h
+++ b/lustre/include/linux/lvfs_linux.h
@@ -74,6 +74,11 @@ struct lvfs_dentry_params
         __u32            ldp_magic;
 };
 #define LVFS_DENTRY_PARAMS_INIT         { .ldp_magic = LVFS_DENTRY_PARAM_MAGIC }
+/* Only use the least 3 bits of ldp_flags for goal policy */
+typedef enum {
+        DP_GOAL_POLICY       = 0,
+        DP_LASTGROUP_REVERSE = 1,
+} dp_policy_t;
 
 #define lvfs_sbdev(SB)       ((SB)->s_bdev)
 #define lvfs_sbdev_type      struct block_device *
diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h
index 32579d8..7106e91 100644
--- a/lustre/include/lprocfs_status.h
+++ b/lustre/include/lprocfs_status.h
@@ -42,7 +42,6 @@
 #ifndef _LPROCFS_SNMP_H
 #define _LPROCFS_SNMP_H
 
-#include <lustre/lustre_idl.h>
 #if defined(__linux__)
 #include <linux/lprocfs_status.h>
 #elif defined(__APPLE__)
@@ -52,6 +51,7 @@
 #else
 #error Unsupported operating system.
 #endif
+#include <lustre/lustre_idl.h>
 
 #undef LPROCFS
 #if (defined(__KERNEL__) && defined(CONFIG_PROC_FS))
@@ -165,9 +165,11 @@ struct lprocfs_percpu {
 #define LPROCFS_GET_SMP_ID  0x0002
 
 enum lprocfs_stats_flags {
-        LPROCFS_STATS_FLAG_PERCPU   = 0x0000, /* per cpu counter */
+        LPROCFS_STATS_FLAG_NONE     = 0x0000, /* per cpu counter */
         LPROCFS_STATS_FLAG_NOPERCPU = 0x0001, /* stats have no percpu
                                                * area and need locking */
+        LPROCFS_STATS_GET_SMP_ID    = 0x0002, /* just record locking with
+                                               * LPROCFS_GET_SMP_ID flag */
 };
 
 enum lprocfs_fields_flags {
@@ -222,7 +224,7 @@ static inline int opcode_offset(__u32 opc) {
                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
                         (OST_LAST_OPC - OST_FIRST_OPC));
-        } else if (opc < QUOTA_LAST_OPC) {
+       } else if (opc < QUOTA_LAST_OPC) {
                 /* LQUOTA Opcode */
                 return (opc - QUOTA_FIRST_OPC +
                         (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
@@ -231,6 +233,16 @@ static inline int opcode_offset(__u32 opc) {
                         (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
                         (MDS_LAST_OPC - MDS_FIRST_OPC) +
                         (OST_LAST_OPC - OST_FIRST_OPC));
+        } else if (opc < SEQ_LAST_OPC) {
+                /* SEQ opcode */
+                return (opc - SEQ_FIRST_OPC +
+                        (QUOTA_LAST_OPC - QUOTA_FIRST_OPC) +
+                        (LLOG_LAST_OPC - LLOG_FIRST_OPC) +
+                        (OBD_LAST_OPC - OBD_FIRST_OPC) +
+                        (MGS_LAST_OPC - MGS_FIRST_OPC) +
+                        (LDLM_LAST_OPC - LDLM_FIRST_OPC) +
+                        (MDS_LAST_OPC - MDS_FIRST_OPC) +
+                        (OST_LAST_OPC - OST_FIRST_OPC));
         } else {
                 /* Unknown Opcode */
                 return -1;
@@ -243,7 +255,8 @@ static inline int opcode_offset(__u32 opc) {
                             (MGS_LAST_OPC - MGS_FIRST_OPC)     + \
                             (OBD_LAST_OPC - OBD_FIRST_OPC)     + \
                             (LLOG_LAST_OPC - LLOG_FIRST_OPC)   + \
-                            (QUOTA_LAST_OPC - QUOTA_FIRST_OPC))
+                            (QUOTA_LAST_OPC - QUOTA_FIRST_OPC) + \
+                            (SEQ_LAST_OPC - SEQ_FIRST_OPC))
 
 #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR)  + \
                            (EXTRA_LAST_OPC - EXTRA_FIRST_OPC))
@@ -316,8 +329,10 @@ static inline int lprocfs_stats_lock(struct lprocfs_stats *stats, int type)
         } else {
                 if (type & LPROCFS_GET_NUM_CPU)
                         rc = num_possible_cpus();
-                if (type & LPROCFS_GET_SMP_ID)
-                        rc = smp_processor_id();
+                if (type & LPROCFS_GET_SMP_ID) {
+			stats->ls_flags |= LPROCFS_STATS_GET_SMP_ID;
+                        rc = cfs_get_cpu();
+		}
         }
         return rc;
 }
@@ -326,6 +341,8 @@ static inline void lprocfs_stats_unlock(struct lprocfs_stats *stats)
 {
         if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU)
                 spin_unlock(&stats->ls_lock);
+	else if (stats->ls_flags & LPROCFS_STATS_GET_SMP_ID)
+		cfs_put_cpu();
 }
 
 /* Two optimized LPROCFS counter increment functions are provided:
@@ -381,9 +398,12 @@ extern int lprocfs_add_clear_entry(struct obd_device * obd,
 extern int lprocfs_exp_setup(struct obd_export *exp,
                              lnet_nid_t *peer_nid, int *newnid);
 extern int lprocfs_exp_cleanup(struct obd_export *exp);
-extern int lprocfs_add_simple(struct proc_dir_entry *root,
-                              char *name, read_proc_t *read_proc,
-                              write_proc_t *write_proc, void *data);
+extern cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
+                                                char *name,
+                                                read_proc_t *read_proc,
+                                                write_proc_t *write_proc,
+                                                void *data,
+                                                struct file_operations *fops);
 extern int lprocfs_register_stats(cfs_proc_dir_entry_t *root, const char *name,
                                   struct lprocfs_stats *stats);
 
@@ -404,9 +424,6 @@ extern cfs_proc_dir_entry_t *lprocfs_srch(cfs_proc_dir_entry_t *root,
 
 extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
 extern int lprocfs_obd_cleanup(struct obd_device *obd);
-extern int lprocfs_add_simple(struct proc_dir_entry *root, char *name,
-                              read_proc_t *read_proc, write_proc_t *write_proc,
-                              void *data);
 struct nid_stat;
 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
 extern int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
@@ -448,6 +465,8 @@ extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
                                 int count, int *eof, void *data);
 extern int lprocfs_rd_import(char *page, char **start, off_t off, int count,
                              int *eof, void *data);
+extern int lprocfs_rd_state(char *page, char **start, off_t off, int count,
+                            int *eof, void *data);
 extern int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
                                     int count, int *eof, void *data);
 extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
@@ -497,11 +516,9 @@ void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value);
 void lprocfs_oh_clear(struct obd_histogram *oh);
 unsigned long lprocfs_oh_sum(struct obd_histogram *oh);
 
-/* lprocfs_status.c: counter read/write functions */
-extern int lprocfs_counter_read(char *page, char **start, off_t off,
-                                int count, int *eof, void *data);
-extern int lprocfs_counter_write(struct file *file, const char *buffer,
-                                 unsigned long count, void *data);
+void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
+                           struct lprocfs_counter *cnt);
+
 
 /* lprocfs_status.c: recovery status */
 int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
@@ -515,12 +532,36 @@ extern int lprocfs_seq_release(struct inode *, struct file *);
 
 /* in lprocfs_stat.c, to protect the private data for proc entries */
 extern struct rw_semaphore _lprocfs_lock;
+
+/* to begin from 2.6.23, Linux defines self file_operations (proc_reg_file_ops)
+ * in procfs, the proc file_operation defined by Lustre (lprocfs_generic_fops)
+ * will be wrapped into the new defined proc_reg_file_ops, which instroduces 
+ * user count in proc_dir_entrey(pde_users) to protect the proc entry from 
+ * being deleted. then the protection lock (_lprocfs_lock) defined by Lustre
+ * isn't necessary anymore for lprocfs_generic_fops(e.g. lprocfs_fops_read).
+ * see bug19706 for detailed information.
+ */
+#ifndef HAVE_PROCFS_USERS
+
 #define LPROCFS_ENTRY()           do {  \
         down_read(&_lprocfs_lock);      \
 } while(0)
 #define LPROCFS_EXIT()            do {  \
         up_read(&_lprocfs_lock);        \
 } while(0)
+
+#else
+
+#define LPROCFS_ENTRY()
+#define LPROCFS_EXIT()
+#endif
+
+#ifdef HAVE_PROCFS_DELETED
+
+#ifdef HAVE_PROCFS_USERS
+#error proc_dir_entry->deleted is conflicted with proc_dir_entry->pde_users
+#endif
+
 #define LPROCFS_ENTRY_AND_CHECK(dp) do {        \
         typecheck(struct proc_dir_entry *, dp); \
         LPROCFS_ENTRY();                        \
@@ -529,6 +570,39 @@ extern struct rw_semaphore _lprocfs_lock;
                 return -ENODEV;                 \
         }                                       \
 } while(0)
+#define LPROCFS_CHECK_DELETED(dp) ((dp)->deleted)
+
+#elif HAVE_PROCFS_USERS
+
+#define LPROCFS_CHECK_DELETED(dp) ({            \
+        int deleted = 0;                        \
+        spin_lock(&(dp)->pde_unload_lock);      \
+        if (dp->proc_fops == NULL)              \
+                deleted = 1;                    \
+        spin_unlock(&(dp)->pde_unload_lock);    \
+        deleted;                                \
+})
+             
+#define LPROCFS_ENTRY_AND_CHECK(dp) do {        \
+        if (LPROCFS_CHECK_DELETED(dp))          \
+                return -ENODEV;                 \
+} while(0)
+
+#else
+        
+#define LPROCFS_ENTRY_AND_CHECK(dp) \
+        LPROCFS_ENTRY();
+#define LPROCFS_CHECK_DELETED(dp) (0)
+#endif
+
+#define LPROCFS_SRCH_ENTRY()      do {  \
+        down_read(&_lprocfs_lock);      \
+} while(0)
+
+#define LPROCFS_SRCH_EXIT()       do {  \
+        up_read(&_lprocfs_lock);        \
+} while(0)
+
 #define LPROCFS_WRITE_ENTRY()     do {  \
         down_write(&_lprocfs_lock);     \
 } while(0)
@@ -536,6 +610,7 @@ extern struct rw_semaphore _lprocfs_lock;
         up_write(&_lprocfs_lock);       \
 } while(0)
 
+
 /* You must use these macros when you want to refer to
  * the import in a client obd_device for a lprocfs entry */
 #define LPROCFS_CLIMP_CHECK(obd) do {           \
@@ -591,7 +666,15 @@ int lprocfs_obd_rd_recovery_maxtime(char *page, char **start, off_t off,
 int lprocfs_obd_wr_recovery_maxtime(struct file *file, const char *buffer,
                                     unsigned long count, void *data);
 #endif
-
+#ifdef HAVE_DELAYED_RECOVERY
+int lprocfs_obd_rd_stale_export_age(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data);
+int lprocfs_obd_wr_stale_export_age(struct file *file, const char *buffer,
+                                    unsigned long count, void *data);
+int lprocfs_obd_attach_stale_exports(struct obd_device *dev);
+int lprocfs_obd_wr_flush_stale_exports(struct file *file, const char *buffer,
+                                       unsigned long count, void *data);
+#endif
 /* all quota proc functions */
 extern int lprocfs_quota_rd_bunit(char *page, char **start, off_t off, int count,
                                   int *eof, void *data);
@@ -689,11 +772,12 @@ static inline int lprocfs_exp_setup(struct obd_export *exp,
 { return 0; }
 static inline int lprocfs_exp_cleanup(struct obd_export *exp)
 { return 0; }
-static inline int lprocfs_add_simple(struct proc_dir_entry *root,
-                                     char *name,
-                                     read_proc_t *read_proc,
-                                     write_proc_t *write_proc,
-                                     void *data)
+static inline cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
+                                                char *name,
+                                                read_proc_t *read_proc,
+                                                write_proc_t *write_proc,
+                                                void *data,
+                                                struct file_operations *fops)
 {return 0; }
 struct nid_stat;
 static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
@@ -732,8 +816,12 @@ static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
 static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
                                        int count, int *eof, void *data)
 { return 0; }
-static inline int lprocfs_rd_import(char *page, char **start, off_t off, int count,
-                                    int *eof, void *data) { return 0; }
+static inline int lprocfs_rd_import(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{ return 0; }
+static inline int lprocfs_rd_state(char *page, char **start, off_t off,
+                                   int count, int *eof, void *data)
+{ return 0; }
 static inline int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
                                            int count, int *eof, void *data)
 { return 0; }
@@ -759,8 +847,23 @@ static inline int lprocfs_wr_evict_client(struct file *file, const char *buffer,
 static inline int lprocfs_wr_ping(struct file *file, const char *buffer,
                                   unsigned long count, void *data)
 { return 0; }
-
-
+#ifdef HAVE_DELAYED_RECOVERY
+static inline
+int lprocfs_obd_rd_stale_export_age(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{ return 0; }
+static inline
+int lprocfs_obd_wr_stale_export_age(struct file *file, const char *buffer,
+                                    unsigned long count, void *data)
+{ return 0; }
+static inline
+int lprocfs_obd_attach_stale_exports(struct obd_device *dev)
+{ return 0; }
+static inline
+int lprocfs_obd_wr_flush_stale_exports(struct file *file, const char *buffer,
+                                       unsigned long count, void *data)
+{ return 0; }
+#endif
 /* Statfs helpers */
 static inline
 int lprocfs_rd_blksize(char *page, char **start, off_t off,
@@ -792,11 +895,8 @@ void lprocfs_oh_clear(struct obd_histogram *oh) {}
 static inline
 unsigned long lprocfs_oh_sum(struct obd_histogram *oh) { return 0; }
 static inline
-int lprocfs_counter_read(char *page, char **start, off_t off,
-                         int count, int *eof, void *data) { return 0; }
-static inline
-int lprocfs_counter_write(struct file *file, const char *buffer,
-                          unsigned long count, void *data) { return 0; }
+void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
+                           struct lprocfs_counter *cnt) {}
 
 static inline
 __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
diff --git a/lustre/include/lustre/Makefile.in b/lustre/include/lustre/Makefile.in
index addcb89..af51066 100644
--- a/lustre/include/lustre/Makefile.in
+++ b/lustre/include/lustre/Makefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/include/lustre/liblustreapi.h b/lustre/include/lustre/liblustreapi.h
index 74fe4b6..0c88b12 100644
--- a/lustre/include/lustre/liblustreapi.h
+++ b/lustre/include/lustre/liblustreapi.h
@@ -73,6 +73,15 @@ extern int llapi_file_create(const char *name, unsigned long long stripe_size,
 extern int llapi_file_open(const char *name, int flags, int mode,
                            unsigned long long stripe_size, int stripe_offset,
                            int stripe_count, int stripe_pattern);
+extern int llapi_file_create_pool(const char *name,
+                                  unsigned long long stripe_size,
+                                  int stripe_offset, int stripe_count,
+                                  int stripe_pattern, char *pool_name);
+extern int llapi_file_open_pool(const char *name, int flags, int mode,
+                                unsigned long long stripe_size,
+                                int stripe_offset, int stripe_count,
+                                int stripe_pattern, char *pool_name);
+extern int llapi_poollist(char *name);
 extern int llapi_file_get_stripe(const char *path, struct lov_user_md *lum);
 #define HAVE_LLAPI_FILE_LOOKUP
 extern int llapi_file_lookup(int dirfd, const char *name);
@@ -103,7 +112,9 @@ struct find_param {
                         exclude_gid:1,
                         exclude_uid:1,
                         check_gid:1,
-                        check_uid:1;
+                        check_uid:1,
+                        check_pool:1,
+                        exclude_pool:1;
 
         int     verbose;
         int     quiet;
@@ -125,6 +136,8 @@ struct find_param {
         /* In-precess parameters. */
         unsigned int depth;
         dev_t   st_dev;
+
+        char poolname[LOV_MAXPOOLNAME + 1];
 };
 
 extern int llapi_getstripe(char *path, struct find_param *param);
@@ -138,13 +151,12 @@ extern int llapi_target_check(int num_types, char **obd_types, char *dir);
 extern int llapi_catinfo(char *dir, char *keyword, char *node_name);
 extern int llapi_file_get_lov_uuid(const char *path, struct obd_uuid *lov_uuid);
 extern int llapi_file_fget_lov_uuid(int fd, struct obd_uuid *lov_uuid);
-/* Use llapi_file_fget_lov_uuid() instead of llapi_file_get_lov_fuuid(), the
- * latter is deprecated and will be removed in a later Lustre release. */
-extern int llapi_file_get_lov_fuuid(int fd, struct obd_uuid *lov_uuid);
 extern int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count);
 extern int llapi_is_lustre_mnttype(const char *type);
 extern int parse_size(char *optarg, unsigned long long *size,
                       unsigned long long *size_units, int bytes_spec);
+extern void llapi_ping_target(char *obd_type, char *obd_name,
+                              char *obd_uuid, void *args);
 struct mntent;
 #define HAVE_LLAPI_IS_LUSTRE_MNT
 extern int llapi_is_lustre_mnt(struct mntent *mnt);
diff --git a/lustre/include/lustre/ll_fiemap.h b/lustre/include/lustre/ll_fiemap.h
index 92f71a9..271ca5b 100644
--- a/lustre/include/lustre/ll_fiemap.h
+++ b/lustre/include/lustre/ll_fiemap.h
@@ -50,27 +50,27 @@
 #include <linux/lustre_types.h>
 
 struct ll_fiemap_extent {
-        __u64   fe_logical;  /* logical offset in bytes for the start of
-                              * the extent from the beginning of the file */
-        __u64   fe_physical; /* physical offset in bytes for the start
-                              * of the extent from the beginning of the disk */
-        __u64   fe_length;   /* length in bytes for the extent */
-        __u32   fe_flags;    /* FIEMAP_EXTENT_* flags for the extent */
-        __u32   fe_device;   /* device number for this extent */
+        __u64 fe_logical;  /* logical offset in bytes for the start of
+                            * the extent from the beginning of the file */
+        __u64 fe_physical; /* physical offset in bytes for the start
+                            * of the extent from the beginning of the disk */
+        __u64 fe_length;   /* length in bytes for this extent */
+        __u64 fe_reserved64[2];
+        __u32 fe_flags;    /* FIEMAP_EXTENT_* flags for this extent */
+        __u32 fe_device;   /* device number for this extent */
+        __u32 fe_reserved[2];
 };
 
 struct ll_user_fiemap {
-        __u64   fm_start;         /* logical offset (inclusive) at
-                                   * which to start mapping (in) */
-        __u64   fm_length;        /* logical length of mapping which
-                                   * userspace wants (in) */
-        __u32   fm_flags;         /* FIEMAP_FLAG_* flags for request (in/out) */
-        __u32   fm_mapped_extents;/* number of extents that were mapped (out) */
-        __u32   fm_extent_count;  /* size of fm_extents array (in) */
-        __u32   fm_reserved;
-        struct  ll_fiemap_extent   fm_extents[0]; /* array of mapped extents (out).
-                                                   * Lustre uses first extent to
-                                                   * send end_offset */
+        __u64 fm_start;  /* logical offset (inclusive) at
+                          * which to start mapping (in) */
+        __u64 fm_length; /* logical length of mapping which
+                          * userspace wants (in) */
+        __u32 fm_flags;  /* FIEMAP_FLAG_* flags for request (in/out) */
+        __u32 fm_mapped_extents;/* number of extents that were mapped (out) */
+        __u32 fm_extent_count;  /* size of fm_extents array (in) */
+        __u32 fm_reserved;
+        struct ll_fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
 };
 
 #define FIEMAP_MAX_OFFSET      (~0ULL)
@@ -82,30 +82,31 @@ struct ll_user_fiemap {
 #define FIEMAP_FLAGS_COMPAT    (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR | \
                                 FIEMAP_FLAG_DEVICE_ORDER)
 
-#define FIEMAP_EXTENT_LAST             0x00000001 /* Last extent in file. */
-#define FIEMAP_EXTENT_UNKNOWN          0x00000002 /* Data location unknown. */
-#define FIEMAP_EXTENT_DELALLOC         0x00000004 /* Location still pending.
-                                                   * Sets EXTENT_UNKNOWN. */
-#define FIEMAP_EXTENT_NO_DIRECT        0x00000008 /* Data mapping undefined */
-#define FIEMAP_EXTENT_SECONDARY        0x00000010 /* Data copied offline. May
-                                                   * set EXTENT_NO_DIRECT. */
-#define FIEMAP_EXTENT_NET              0x00000020 /* Data stored remotely.
-                                                   * Sets EXTENT_NO_DIRECT. */
-#define FIEMAP_EXTENT_DATA_COMPRESSED  0x00000040 /* Data is compressed by fs.
-                                                   * Sets EXTENT_NO_DIRECT. */
-#define FIEMAP_EXTENT_DATA_ENCRYPTED   0x00000080 /* Data is encrypted by fs.
-                                                   * Sets EXTENT_NO_DIRECT. */
-#define FIEMAP_EXTENT_NOT_ALIGNED      0x00000100 /* Extent offsets may not be
-                                                   * block aligned. */
-#define FIEMAP_EXTENT_DATA_INLINE      0x00000200 /* Data mixed with metadata.
-                                                   * Sets EXTENT_NOT_ALIGNED.*/
-#define FIEMAP_EXTENT_DATA_TAIL        0x00000400 /* Multiple files in block.
-                                                   * Sets EXTENT_NOT_ALIGNED.*/
-#define FIEMAP_EXTENT_UNWRITTEN        0x00000800 /* Space allocated, but
-                                                   * no data (i.e. zero). */
-#define FIEMAP_EXTENT_MERGED           0x00001000 /* File does not natively
-                                                   * support extents. Result
-                                                   * merged for efficiency. */
+
+#define FIEMAP_EXTENT_LAST              0x00000001 /* Last extent in file. */
+#define FIEMAP_EXTENT_UNKNOWN           0x00000002 /* Data location unknown. */
+#define FIEMAP_EXTENT_DELALLOC          0x00000004 /* Location still pending.
+                                                    * Sets EXTENT_UNKNOWN. */
+#define FIEMAP_EXTENT_ENCODED           0x00000008 /* Data can not be read
+                                                    * while fs is unmounted */
+#define FIEMAP_EXTENT_DATA_ENCRYPTED    0x00000080 /* Data is encrypted by fs.
+                                                    * Sets EXTENT_NO_DIRECT. */
+#define FIEMAP_EXTENT_NOT_ALIGNED       0x00000100 /* Extent offsets may not be
+                                                    * block aligned. */
+#define FIEMAP_EXTENT_DATA_INLINE       0x00000200 /* Data mixed with metadata.
+                                                    * Sets EXTENT_NOT_ALIGNED.*/
+#define FIEMAP_EXTENT_DATA_TAIL         0x00000400 /* Multiple files in block.
+                                                    * Sets EXTENT_NOT_ALIGNED.*/
+#define FIEMAP_EXTENT_UNWRITTEN         0x00000800 /* Space allocated, but
+                                                    * no data (i.e. zero). */
+#define FIEMAP_EXTENT_MERGED            0x00001000 /* File does not natively
+                                                    * support extents. Result
+                                                    * merged for efficiency. */
+
+/* Lustre specific flags - use a high bit, don't conflict with upstream flag */
+#define FIEMAP_EXTENT_NO_DIRECT         0x40000000 /* Data mapping undefined */
+#define FIEMAP_EXTENT_NET               0x80000000 /* Data stored remotely.
+                                                    * Sets NO_DIRECT flag */
 
 #else
 
diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h
index 61681f1..dd460bc 100644
--- a/lustre/include/lustre/lustre_idl.h
+++ b/lustre/include/lustre/lustre_idl.h
@@ -98,6 +98,8 @@
 #include <lustre_ver.h>
 #include <lustre/ll_fiemap.h>
 
+#include <libcfs/kp30.h>
+
 /*
  * this file contains all data structures used in Lustre interfaces:
  * - obdo and obd_request records
@@ -137,11 +139,16 @@
 //#define PTLBD_BULK_PORTAL              21
 #define MDS_SETATTR_PORTAL             22
 #define MDS_READPAGE_PORTAL            23
+#define MDS_MDS_PORTAL                 24
 
 #define MGC_REPLY_PORTAL               25
 #define MGS_REQUEST_PORTAL             26
 #define MGS_REPLY_PORTAL               27
 #define OST_REQUEST_PORTAL             28
+#define FLD_REQUEST_PORTAL             29
+#define SEQ_METADATA_PORTAL            30
+#define SEQ_DATA_PORTAL                31
+#define SEQ_CONTROLLER_PORTAL          32
 
 #define SVC_KILLED               1
 #define SVC_EVENT                2
@@ -231,7 +238,8 @@ struct lustre_msg_v2 {
         __u32 lm_buflens[0];
 };
 
-/* without security, ptlrpc_body is put in the first buffer. */
+/* without gss, ptlrpc_body is put at the first buffer. */
+#define PTLRPC_NUM_VERSIONS     4
 struct ptlrpc_body {
         struct lustre_handle pb_handle;
         __u32 pb_type;
@@ -239,7 +247,7 @@ struct ptlrpc_body {
         __u32 pb_opc;
         __u32 pb_status;
         __u64 pb_last_xid;
-        __u64 pb_last_seen;
+        __u64 pb_last_seen; /* not used */
         __u64 pb_last_committed;
         __u64 pb_transno;
         __u32 pb_flags;
@@ -249,9 +257,13 @@ struct ptlrpc_body {
         __u32 pb_service_time; /* for rep, actual service time */
         __u32 pb_limit;
         __u64 pb_slv;
+        /* VBR: pre-versions */
+        __u64 pb_pre_versions[PTLRPC_NUM_VERSIONS];
+        /* padding for future needs */
+        __u64 pb_padding[4];
 };
 
-extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
+extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb, int msgsize);
 
 /* message body offset for lustre_msg_v2 */
 /* ptlrpc body offset in all request/reply messages */
@@ -281,24 +293,33 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define MSG_OP_FLAG_SHIFT  16
 
 /* Flags that apply to all requests are in the bottom 16 bits */
-#define MSG_GEN_FLAG_MASK      0x0000ffff
-#define MSG_LAST_REPLAY        1
-#define MSG_RESENT             2
-#define MSG_REPLAY             4
-/* #define MSG_AT_SUPPORT         8  avoid until 1.10+ */
+#define MSG_GEN_FLAG_MASK     0x0000ffff
+#define MSG_LAST_REPLAY           0x0001
+#define MSG_RESENT                0x0002
+#define MSG_REPLAY                0x0004
+/* #define MSG_AT_SUPPORT         0x0008
+ * This was used in early prototypes of adaptive timeouts, and while there
+ * shouldn't be any users of that code there also isn't a need for using this
+ * bits. Defer usage until at least 1.10 to avoid potential conflict. */
+#define MSG_DELAY_REPLAY          0x0010
+#define MSG_VERSION_REPLAY        0x0020
+#define MSG_REQ_REPLAY_DONE       0x0040
+#define MSG_LOCK_REPLAY_DONE      0x0080
 
 /*
  * Flags for all connect opcodes (MDS_CONNECT, OST_CONNECT)
  */
 
-#define MSG_CONNECT_RECOVERING  0x1
-#define MSG_CONNECT_RECONNECT   0x2
-#define MSG_CONNECT_REPLAYABLE  0x4
+#define MSG_CONNECT_RECOVERING  0x00000001
+#define MSG_CONNECT_RECONNECT   0x00000002
+#define MSG_CONNECT_REPLAYABLE  0x00000004
 //#define MSG_CONNECT_PEER        0x8
-#define MSG_CONNECT_LIBCLIENT   0x10
-#define MSG_CONNECT_INITIAL     0x20
-#define MSG_CONNECT_ASYNC       0x40
-#define MSG_CONNECT_NEXT_VER    0x80 /* use next version of lustre_msg */
+#define MSG_CONNECT_LIBCLIENT   0x00000010
+#define MSG_CONNECT_INITIAL     0x00000020
+#define MSG_CONNECT_ASYNC       0x00000040
+#define MSG_CONNECT_NEXT_VER    0x00000080 /* use next version of lustre_msg */
+#define MSG_CONNECT_TRANSNO     0x00000100 /* report transno */
+#define MSG_CONNECT_DELAYED     0x00000200
 
 /* Connect flags */
 #define OBD_CONNECT_RDONLY            0x1ULL /*client allowed read-only access*/
@@ -317,8 +338,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define OBD_CONNECT_JOIN           0x2000ULL /*files can be concatenated */
 #define OBD_CONNECT_ATTRFID        0x4000ULL /*Server supports GetAttr By Fid */
 #define OBD_CONNECT_NODEVOH        0x8000ULL /*No open handle on special nodes*/
-#define OBD_CONNECT_LCL_CLIENT    0x10000ULL /*local 1.8 client */
-#define OBD_CONNECT_RMT_CLIENT    0x20000ULL /*Remote 1.8 client */
+#define OBD_CONNECT_RMT_CLIENT    0x10000ULL /*Remote client */
+#define OBD_CONNECT_RMT_CLIENT_FORCE 0x20000ULL /*Remote client by force */
 #define OBD_CONNECT_BRW_SIZE      0x40000ULL /*Max bytes per rpc */
 #define OBD_CONNECT_QUOTA64       0x80000ULL /*64bit qunit_data.qd_count */
 #define OBD_CONNECT_MDS_CAPA     0x100000ULL /*MDS capability */
@@ -326,14 +347,16 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define OBD_CONNECT_CANCELSET    0x400000ULL /*Early batched cancels. */
 #define OBD_CONNECT_SOM        0x00800000ULL /*Size on MDS */
 #define OBD_CONNECT_AT         0x01000000ULL /*client uses adaptive timeouts */
-#define OBD_CONNECT_LRU_RESIZE 0x02000000ULL /*Lru resize feature. */
+#define OBD_CONNECT_LRU_RESIZE 0x02000000ULL /*LRU resize feature. */
 #define OBD_CONNECT_MDS_MDS    0x04000000ULL /*MDS-MDS connection */
 #define OBD_CONNECT_REAL       0x08000000ULL /*real connection */
 #define OBD_CONNECT_CHANGE_QS  0x10000000ULL /*shrink/enlarge qunit b=10600 */
 #define OBD_CONNECT_CKSUM      0x20000000ULL /*support several cksum algos */
-#define OBD_CONNECT_FID        0x40000000ULL /* FID is supported */
-#define OBD_CONNECT_VBR        0x80000000ULL /* version based recovery */
-#define OBD_CONNECT_LOV_V3    0x100000000ULL /* client supports lov v3 ea */
+#define OBD_CONNECT_FID        0x40000000ULL /*FID is supported by server */
+#define OBD_CONNECT_VBR        0x80000000ULL /*version based recovery */
+#define OBD_CONNECT_LOV_V3    0x100000000ULL /*client supports LOV v3 EA */
+#define OBD_CONNECT_GRANT_SHRINK  0x200000000ULL /* support grant shrink */
+#define OBD_CONNECT_SKIP_ORPHAN   0x400000000ULL /* don't reuse orphan objids */
 /* also update obd_connect_names[] for lprocfs_rd_connect_flags()
  * and lustre/utils/wirecheck.c */
 
@@ -348,19 +371,19 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                 OBD_CONNECT_IBITS | OBD_CONNECT_JOIN | \
                                 OBD_CONNECT_NODEVOH | OBD_CONNECT_ATTRFID | \
                                 OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \
-                                LRU_RESIZE_CONNECT_FLAG)
+                                LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_VBR |\
+                                OBD_CONNECT_LOV_V3)
 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
                                 OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
                                 OBD_CONNECT_BRW_SIZE | OBD_CONNECT_QUOTA64 | \
                                 OBD_CONNECT_CANCELSET | OBD_CONNECT_AT | \
                                 LRU_RESIZE_CONNECT_FLAG | OBD_CONNECT_CKSUM | \
-                                OBD_CONNECT_CHANGE_QS | OBD_CONNECT_MDS)
+                                OBD_CONNECT_VBR | OBD_CONNECT_CHANGE_QS | \
+                                OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN)
 #define ECHO_CONNECT_SUPPORTED (0)
 #define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT)
 
-#define MAX_QUOTA_COUNT32 (0xffffffffULL)
-
 #define OBD_OCD_VERSION(major,minor,patch,fix) (((major)<<24) + ((minor)<<16) +\
                                                 ((patch)<<8) + (fix))
 #define OBD_OCD_VERSION_MAJOR(version) ((int)((version)>>24)&255)
@@ -373,23 +396,31 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
  * If we eventually have separate connect data for different types, which we
  * almost certainly will, then perhaps we stick a union in here. */
 struct obd_connect_data {
-        __u64 ocd_connect_flags;        /* OBD_CONNECT_* per above */
-        __u32 ocd_version;              /* lustre release version number */
-        __u32 ocd_grant;                /* initial cache grant amount (bytes) */
-        __u32 ocd_index;                /* LOV index to connect to */
-        __u32 ocd_brw_size;             /* Maximum BRW size in bytes */
-        __u64 ocd_ibits_known;          /* inode bits this client understands */
-        __u32 ocd_nllu;                 /* non-local-lustre-user */
-        __u32 ocd_nllg;                 /* non-local-lustre-group */
-        __u64 ocd_transno;              /* Used in lustre 1.8 */
-        __u32 ocd_group;                /* Used in lustre 1.8 */
-        __u32 ocd_cksum_types;          /* supported checksum algorithms */
-        __u64 padding1;                 /* also fix lustre_swab_connect */
-        __u64 padding2;                 /* also fix lustre_swab_connect */
+        __u64 ocd_connect_flags; /* OBD_CONNECT_* per above */
+        __u32 ocd_version;       /* lustre release version number */
+        __u32 ocd_grant;         /* initial cache grant amount (bytes) */
+        __u32 ocd_index;         /* LOV index to connect to */
+        __u32 ocd_brw_size;      /* Maximum BRW size in bytes */
+        __u64 ocd_ibits_known;   /* inode bits this client understands */
+        __u32 ocd_nllu;          /* non-local-lustre-user */
+        __u32 ocd_nllg;          /* non-local-lustre-group */
+        __u64 ocd_transno;       /* Used in lustre 1.8 */
+        __u32 ocd_group;         /* Used in lustre 1.8 */
+        __u32 ocd_cksum_types;   /* supported checksum algorithms */
+        __u64 padding1;          /* also fix lustre_swab_connect */
+        __u64 padding2;          /* also fix lustre_swab_connect */
 };
 
 extern void lustre_swab_connect(struct obd_connect_data *ocd);
 
+/* b1_6 has smaller body. The defines below is for interoperability */
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2,0,0,0)
+#define PTLRPC_INTEROP_1_6      1
+#define PTLRPC_BODY_MIN_SIZE    offsetof(struct ptlrpc_body, pb_pre_versions)
+#else
+#define PTLRPC_BODY_MIN_SIZE    sizeof(struct ptlrpc_body)
+#endif
+
 /*
  * Supported checksum algorithms. Up to 32 checksum types are supported.
  * (32-bit mask stored in obd_connect_data::ocd_cksum_types)
@@ -446,30 +477,32 @@ typedef __u32 obd_gid;
 typedef __u32 obd_flag;
 typedef __u32 obd_count;
 
-#define OBD_FL_INLINEDATA    (0x00000001)
-#define OBD_FL_OBDMDEXISTS   (0x00000002)
-#define OBD_FL_DELORPHAN     (0x00000004) /* if set in o_flags delete orphans */
-#define OBD_FL_NORPC         (0x00000008) /* set in o_flags do in OSC not OST */
-#define OBD_FL_IDONLY        (0x00000010) /* set in o_flags only adjust obj id*/
-#define OBD_FL_RECREATE_OBJS (0x00000020) /* recreate missing obj */
-#define OBD_FL_DEBUG_CHECK   (0x00000040) /* echo client/server debug check */
-#define OBD_FL_NO_USRQUOTA   (0x00000100) /* the object's owner is over quota */
-#define OBD_FL_NO_GRPQUOTA   (0x00000200) /* the object's group is over quota */
-#define OBD_FL_CREATE_CROW   (0x00000400) /* object should be create on write */
-
-/*
- * set this to delegate DLM locking during obd_punch() to the OSTs. Only OSTs
- * that declared OBD_CONNECT_TRUNCLOCK in their connect flags support this
- * functionality.
- */
-#define OBD_FL_TRUNCLOCK     (0x00000800)
-
-/*
- * Checksum types
- */
-#define OBD_FL_CKSUM_CRC32    (0x00001000)
-#define OBD_FL_CKSUM_ADLER    (0x00002000)
-#define OBD_FL_CKSUM_ALL      (OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER)
+enum obdo_flags {
+        OBD_FL_INLINEDATA   = 0x00000001,
+        OBD_FL_OBDMDEXISTS  = 0x00000002,
+        OBD_FL_DELORPHAN    = 0x00000004, /* if set in o_flags delete orphans */
+        OBD_FL_NORPC        = 0x00000008, /* set in o_flags do in OSC not OST */
+        OBD_FL_IDONLY       = 0x00000010, /* set in o_flags only adjust obj id*/
+        OBD_FL_RECREATE_OBJS= 0x00000020, /* recreate missing obj */
+        OBD_FL_DEBUG_CHECK  = 0x00000040, /* echo client/server debug check */
+        OBD_FL_NO_USRQUOTA  = 0x00000100, /* the object's owner is over quota */
+        OBD_FL_NO_GRPQUOTA  = 0x00000200, /* the object's group is over quota */
+        OBD_FL_CREATE_CROW  = 0x00000400, /* object should be create on write */
+        OBD_FL_TRUNCLOCK    = 0x00000800, /* delegate DLM locking during punch*/
+        OBD_FL_CKSUM_CRC32  = 0x00001000, /* CRC32 checksum type */
+        OBD_FL_CKSUM_ADLER  = 0x00002000, /* ADLER checksum type */
+        OBD_FL_CKSUM_RSVD1  = 0x00004000, /* for future cksum types */
+        OBD_FL_CKSUM_RSVD2  = 0x00008000, /* for future cksum types */
+        OBD_FL_CKSUM_RSVD3  = 0x00010000, /* for future cksum types */
+        OBD_FL_SHRINK_GRANT = 0x00020000, /* object shrink the grant */
+
+        OBD_FL_CKSUM_ALL    = OBD_FL_CKSUM_CRC32 | OBD_FL_CKSUM_ADLER,
+
+        /* mask for local-only flag, which won't be sent over network */
+        OBD_FL_LOCAL_MASK   = 0xF0000000,
+        /* temporary OBDO used by osc_brw_async (see bug 18364) */
+        OBD_FL_TEMPORARY    = 0x10000000,
+};
 
 #define LOV_MAGIC_V1      0x0BD10BD0
 #define LOV_MAGIC         LOV_MAGIC_V1
@@ -484,9 +517,6 @@ typedef __u32 obd_count;
 #define LOV_OBJECT_GROUP_DEFAULT ~0ULL
 #define LOV_OBJECT_GROUP_CLEAR 0ULL
 
-#define MAXPOOLNAME 16
-#define POOLNAMEF "%.16s"
-
 #define lov_ost_data lov_ost_data_v1
 struct lov_ost_data_v1 {          /* per-stripe data structure (little-endian)*/
         __u64 l_object_id;        /* OST object ID */
@@ -513,7 +543,7 @@ struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
         __u64 lmm_object_gr;      /* LOV object group */
         __u32 lmm_stripe_size;    /* size of stripe in bytes */
         __u32 lmm_stripe_count;   /* num stripes in use for this object */
-        char  lmm_pool_name[MAXPOOLNAME]; /* must be 32bit aligned */
+        char  lmm_pool_name[LOV_MAXPOOLNAME]; /* must be 32bit aligned */
         struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 };
 
@@ -532,18 +562,19 @@ struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
 #define OBD_MD_FLFLAGS     (0x00000800ULL) /* flags word */
 #define OBD_MD_FLNLINK     (0x00002000ULL) /* link count */
 #define OBD_MD_FLGENER     (0x00004000ULL) /* generation number */
-/*#define OBD_MD_FLINLINE      (0x00008000ULL) inline data. used until 1.6.5 */
+/*#define OBD_MD_FLINLINE    (0x00008000ULL) inline data. used until 1.6.5 */
 #define OBD_MD_FLRDEV      (0x00010000ULL) /* device number */
 #define OBD_MD_FLEASIZE    (0x00020000ULL) /* extended attribute data */
 #define OBD_MD_LINKNAME    (0x00040000ULL) /* symbolic link target */
 #define OBD_MD_FLHANDLE    (0x00080000ULL) /* file/lock handle */
 #define OBD_MD_FLCKSUM     (0x00100000ULL) /* bulk data checksum */
 #define OBD_MD_FLQOS       (0x00200000ULL) /* quality of service stats */
-#define OBD_MD_FLOSCOPQ    (0x00400000ULL) /* osc opaque data */
+/*#define OBD_MD_FLOSCOPQ    (0x00400000ULL) osc opaque data, never used */
 #define OBD_MD_FLCOOKIE    (0x00800000ULL) /* log cancellation cookie */
 #define OBD_MD_FLGROUP     (0x01000000ULL) /* group */
 #define OBD_MD_FLFID       (0x02000000ULL) /* ->ost write inline fid */
 #define OBD_MD_FLEPOCH     (0x04000000ULL) /* ->ost write easize is epoch */
+                                           /* ->mds if epoch opens or closes */
 #define OBD_MD_FLGRANT     (0x08000000ULL) /* ost preallocation space grant */
 #define OBD_MD_FLDIREA     (0x10000000ULL) /* dir's extended attribute data */
 #define OBD_MD_FLUSRQUOTA  (0x20000000ULL) /* over quota flags sent from ost */
@@ -552,11 +583,24 @@ struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
 
 #define OBD_MD_MDS         (0x0000000100000000ULL) /* where an inode lives on */
 #define OBD_MD_REINT       (0x0000000200000000ULL) /* reintegrate oa */
+#define OBD_MD_MEA         (0x0000000400000000ULL) /* CMD split EA  */
 
 #define OBD_MD_FLXATTR     (0x0000001000000000ULL) /* xattr */
 #define OBD_MD_FLXATTRLS   (0x0000002000000000ULL) /* xattr list */
 #define OBD_MD_FLXATTRRM   (0x0000004000000000ULL) /* xattr remove */
 #define OBD_MD_FLACL       (0x0000008000000000ULL) /* ACL */
+#define OBD_MD_FLRMTPERM   (0x0000010000000000ULL) /* remote permission */
+#define OBD_MD_FLMDSCAPA   (0x0000020000000000ULL) /* MDS capability */
+#define OBD_MD_FLOSSCAPA   (0x0000040000000000ULL) /* OSS capability */
+#define OBD_MD_FLCKSPLIT   (0x0000080000000000ULL) /* Check split on server */
+#define OBD_MD_FLCROSSREF  (0x0000100000000000ULL) /* Cross-ref case */
+
+#define OBD_FL_TRUNC       (0x0000200000000000ULL) /* for filter_truncate */
+
+#define OBD_MD_FLRMTLSETFACL    (0x0001000000000000ULL) /* lfs lsetfacl case */
+#define OBD_MD_FLRMTLGETFACL    (0x0002000000000000ULL) /* lfs lgetfacl case */
+#define OBD_MD_FLRMTRSETFACL    (0x0004000000000000ULL) /* lfs rsetfacl case */
+#define OBD_MD_FLRMTRGETFACL    (0x0008000000000000ULL) /* lfs rgetfacl case */
 
 #define OBD_MD_FLGETATTR (OBD_MD_FLID    | OBD_MD_FLATIME | OBD_MD_FLMTIME | \
                           OBD_MD_FLCTIME | OBD_MD_FLSIZE  | OBD_MD_FLBLKSZ | \
@@ -564,10 +608,17 @@ struct lov_mds_md_v3 {            /* LOV EA mds/wire data (little-endian) */
                           OBD_MD_FLGID   | OBD_MD_FLFLAGS | OBD_MD_FLNLINK | \
                           OBD_MD_FLGENER | OBD_MD_FLRDEV  | OBD_MD_FLGROUP)
 
-
 /* don't forget obdo_fid which is way down at the bottom so it can
  * come after the definition of llog_cookie */
 
+enum obd_statfs_state {
+        OS_STATE_DEGRADED       = 0x00000001, /**< RAID degraded/rebuilding */
+        OS_STATE_READONLY       = 0x00000002, /**< filesystem is read-only */
+        OS_STATE_RDONLY_1       = 0x00000004, /**< obsolete 1.6, was EROFS=30 */
+        OS_STATE_RDONLY_2       = 0x00000008, /**< obsolete 1.6, was EROFS=30 */
+        OS_STATE_RDONLY_3       = 0x00000010, /**< obsolete 1.6, was EROFS=30 */
+};
+
 struct obd_statfs {
         __u64           os_type;
         __u64           os_blocks;
@@ -579,7 +630,7 @@ struct obd_statfs {
         __u32           os_bsize;
         __u32           os_namelen;
         __u64           os_maxbytes;
-        __u32           os_state;       /* positive error code on server */
+        __u32           os_state;       /**< obd_statfs_state OS_STATE_* flag */
         __u32           os_spare1;
         __u32           os_spare2;
         __u32           os_spare3;
@@ -594,9 +645,14 @@ struct obd_statfs {
 extern void lustre_swab_obd_statfs (struct obd_statfs *os);
 #define OBD_STATFS_NODELAY      0x0001  /* requests should be send without delay
                                          * and resends for avoid deadlocks */
-
 #define OBD_STATFS_FROM_CACHE   0x0002  /* the statfs callback should not update
                                          * obd_osfs_age */
+#define OBD_STATFS_PTLRPCD      0x0004  /* requests will be sent via ptlrpcd
+                                         * instead of a specific set. This
+                                         * means that we cannot rely on the set
+                                         * interpret routine to be called.
+                                         * lov_statfs_fini() must thus be called
+                                         * by the request interpret routine */
 
 /* ost_body.data values for OST_BRW */
 
@@ -610,6 +666,7 @@ extern void lustre_swab_obd_statfs (struct obd_statfs *os);
 #define OBD_BRW_DROP            0x80 /* drop the page after IO */
 #define OBD_BRW_NOQUOTA        0x100
 #define OBD_BRW_SRVLOCK        0x200 /* Client holds no lock over this page */
+#define OBD_BRW_ASYNC          0x400 /* Server may delay commit to disk */
 
 #define OBD_OBJECT_EOF 0xffffffffffffffffULL
 
@@ -636,7 +693,7 @@ extern void lustre_swab_niobuf_remote (struct niobuf_remote *nbr);
 
 /* lock value block communicated between the filter and llite */
 
-/* OST_LVB_ERR_INIT is needed because the return code in rc is 
+/* OST_LVB_ERR_INIT is needed because the return code in rc is
  * negative, i.e. because ((MASK + rc) & MASK) != MASK. */
 #define OST_LVB_ERR_INIT 0xffbadbad80000000ULL
 #define OST_LVB_ERR_MASK 0xffbadbad00000000ULL
@@ -680,6 +737,8 @@ typedef enum {
         MDS_QUOTACTL     = 48,
         MDS_GETXATTR     = 49,
         MDS_SETXATTR     = 50,
+        MDS_WRITEPAGE    = 51,
+        MDS_IS_SUBDIR    = 52,
         MDS_LAST_OPC
 } mds_cmd_t;
 
@@ -696,8 +755,9 @@ typedef enum {
         REINT_UNLINK   = 4,
         REINT_RENAME   = 5,
         REINT_OPEN     = 6,
-//      REINT_CLOSE    = 7,
-//      REINT_WRITE    = 8,
+        REINT_SETXATTR = 7,
+//      REINT_CLOSE    = 8,
+//      REINT_WRITE    = 9,
         REINT_MAX
 } mds_reint_t;
 
@@ -723,8 +783,290 @@ typedef enum {
 /* This FULL lock is useful to take on unlink sort of operations */
 #define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1)
 
+
+/**
+ * Enumeration of possible directory entry attributes.
+ *
+ * Attributes follow directory entry header in the order they appear in this
+ * enumeration.
+ */
+enum lu_dirent_attrs {
+        LUDA_FID    = 0x0001,
+        LUDA_TYPE   = 0x0002,
+};
+
+
 extern void lustre_swab_ll_fid (struct ll_fid *fid);
 
+struct lu_fid {
+        __u64 f_seq;  /* holds fid sequence. Lustre should support 2^64
+                       * objects, thus even if one sequence has one object we
+                       * reach this value. */
+        __u32 f_oid;  /* fid number within its sequence. */
+        __u32 f_ver;  /* holds fid version. */
+};
+
+#define DFID "[0x%16.16"LPF64"x/0x%8.8x:0x%8.8x]"
+
+#define PFID(fid)     \
+        fid_seq(fid), \
+        fid_oid(fid), \
+        fid_ver(fid)
+
+enum {
+        /** put FID sequence at this offset in ldlm_res_id. */
+        LUSTRE_RES_ID_SEQ_OFF = 0,
+        /** put FID oid at this offset in ldlm_res_id. */
+        LUSTRE_RES_ID_OID_OFF = 1,
+        /** put FID version at this offset in ldlm_res_id. */
+        LUSTRE_RES_ID_VER_OFF = 2,
+        /** put pdo hash at this offset in ldlm_res_id. */
+        LUSTRE_RES_ID_HSH_OFF = 3
+};
+
+typedef __u64 seqno_t;
+
+/**
+ * Describes a range of sequence, lsr_start is included but lsr_end is
+ * not in the range.
+ */
+struct lu_seq_range {
+        __u64 lsr_start;
+        __u64 lsr_end;
+        /** this feild is not used in 1.8 client interop */
+        __u32 lsr_mdt;
+        __u32 lsr_padding;
+};
+
+/**
+ * returns  width of given range \a r
+ */
+
+static inline __u64 range_space(const struct lu_seq_range *r)
+{
+        return r->lsr_end - r->lsr_start;
+}
+
+/**
+ * initialize range to zero
+ */
+static inline void range_init(struct lu_seq_range *r)
+{
+        r->lsr_start = r->lsr_end = 0;
+}
+
+/**
+ * check if given seq id \a s is within given range \a r
+ */
+static inline int range_within(const struct lu_seq_range *r,
+                               __u64 s)
+{
+        return s >= r->lsr_start && s < r->lsr_end;
+}
+
+/**
+ * sanity check for range \a r
+ */
+static inline int range_is_sane(const struct lu_seq_range *r)
+{
+        return (r->lsr_end >= r->lsr_start);
+}
+
+static inline int range_is_zero(struct lu_seq_range *r)
+{
+        return (r->lsr_start == 0 && r->lsr_end == 0);
+}
+
+static inline int range_is_exhausted(const struct lu_seq_range *r)
+{
+        return range_space(r) == 0;
+}
+
+#define DRANGE "[%#16.16"LPF64"x-%#16.16"LPF64"x)"
+
+#define PRANGE(range)      \
+        (range)->lsr_start, \
+        (range)->lsr_end
+
+enum {
+        /*
+         * This is how may FIDs may be allocated in one sequence.
+         */
+        LUSTRE_SEQ_MAX_WIDTH = 0x0000000000004000ULL,
+};
+
+enum lu_cli_type {
+        LUSTRE_SEQ_METADATA,
+        LUSTRE_SEQ_DATA
+};
+
+struct lu_client_seq {
+        /* Sequence-controller export. */
+        struct obd_export      *lcs_exp;
+        struct semaphore        lcs_sem;
+
+        /*
+         * Range of allowed for allocation sequences. When using lu_client_seq
+         * on clients, this contains meta-sequence range. And for servers this
+         * contains super-sequence range.
+         */
+        struct lu_seq_range         lcs_space;
+
+        /* This holds last allocated fid in last obtained seq */
+        struct lu_fid           lcs_fid;
+
+        /* LUSTRE_SEQ_METADATA or LUSTRE_SEQ_DATA */
+        enum lu_cli_type        lcs_type;
+        /*
+         * Service uuid, passed from MDT + seq name to form unique seq name to
+         * use it with procfs.
+         */
+        char                    lcs_name[80];
+
+        /*
+         * Sequence width, that is how many objects may be allocated in one
+         * sequence. Default value for it is LUSTRE_SEQ_MAX_WIDTH.
+         */
+        __u64                   lcs_width;
+
+};
+
+/*
+ * fid constants
+ */
+enum {
+        /* initial fid id value */
+        LUSTRE_FID_INIT_OID  = 1UL
+};
+
+extern void lustre_swab_lu_fid(struct lu_fid *fid);
+
+/* get object sequence */
+static inline __u64 fid_seq(const struct lu_fid *fid)
+{
+        return fid->f_seq;
+}
+
+/* get object id */
+static inline __u32 fid_oid(const struct lu_fid *fid)
+{
+        return fid->f_oid;
+}
+
+/* get object version */
+static inline __u32 fid_ver(const struct lu_fid *fid)
+{
+        return fid->f_ver;
+}
+
+static inline void fid_init(struct lu_fid *fid)
+{
+        memset(fid, 0, sizeof(*fid));
+}
+
+/* Normal FID sequence starts from this value, i.e. 1<<33 */
+#define FID_SEQ_START  0x200000000ULL
+
+/* IDIF sequence starts from this value, i.e. 1<<32 */
+#define IDIF_SEQ_START 0x100000000ULL
+
+/**
+ * Check if a fid is igif or not.
+ * \param fid the fid to be tested.
+ * \return true if the fid is a igif; otherwise false.
+ */
+static inline int fid_is_igif(const struct lu_fid *fid)
+{
+        return fid_seq(fid) > 0 && fid_seq(fid) < IDIF_SEQ_START;
+}
+
+/**
+ * Check if a fid is idif or not.
+ * \param fid the fid to be tested.
+ * \return true if the fid is a idif; otherwise false.
+ */
+static inline int fid_is_idif(const struct lu_fid *fid)
+{
+        return fid_seq(fid) >= IDIF_SEQ_START  && fid_seq(fid) < FID_SEQ_START;
+}
+
+/**
+ * Check if a fid sequence is sane or not
+ * \param seq the sequence to be tested.
+ * \return true if the sequence is a sane sequence; otherwise false.
+ */
+static inline int fid_seq_is_sane(__u64 seq)
+{
+        return seq != 0;
+}
+
+/**
+ * Check if a fid is sane or not
+ * \param fid the fid to be tested.
+ * \return true if the fid is sane; otherwise false.
+ */
+static inline int fid_is_sane(const struct lu_fid *fid)
+{
+        return
+                fid != NULL &&
+                ((fid_seq_is_sane(fid_seq(fid)) && fid_oid(fid) != 0
+                                                && fid_ver(fid) == 0) ||
+                fid_is_igif(fid));
+}
+/**
+ * Check if a fid is zero.
+ * \param fid the fid to be tested.
+ * \return true if the fid is zero; otherwise false.
+ */
+static inline int fid_is_zero(const struct lu_fid *fid)
+{
+        return fid_seq(fid) == 0 && fid_oid(fid) == 0;
+}
+
+/**
+ * Get inode number from a igif.
+ * \param fid a igif to get inode number from.
+ * \return inode number for the igif.
+ */
+static inline ino_t lu_igif_ino(const struct lu_fid *fid)
+{
+        return fid_seq(fid);
+}
+
+/**
+ * Get inode generation from a igif.
+ * \param fid a igif to get inode generation from.
+ * \return inode generation for the igif.
+ */
+static inline __u32 lu_igif_gen(const struct lu_fid *fid)
+{
+        return fid_oid(fid);
+}
+
+/**
+ * Check if two fids are equal or not.
+ * \param f0 the first fid
+ * \param f1 the second fid
+ * \return true if the two fids are equal; otherwise false.
+ */
+static inline int lu_fid_eq(const struct lu_fid *f0,
+                            const struct lu_fid *f1)
+{
+        /* Check that there is no alignment padding. */
+        CLASSERT(sizeof *f0 ==
+                 sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver);
+        LASSERTF(fid_is_igif(f0) || fid_ver(f0) == 0, DFID"\n", PFID(f0));
+        LASSERTF(fid_is_igif(f1) || fid_ver(f1) == 0, DFID"\n", PFID(f1));
+        return memcmp(f0, f1, sizeof *f0) == 0;
+}
+
+void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src);
+void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src);
+
+struct ldlm_res_id *
+fid_build_reg_res_name(const struct lu_fid *f, struct ldlm_res_id *name);
+int fid_res_name_eq(const struct lu_fid *f, const struct ldlm_res_id *name);
+
 #define MDS_STATUS_CONN 1
 #define MDS_STATUS_LOV 2
 
@@ -769,7 +1111,7 @@ static inline int ll_ext_to_inode_flags(int flags)
 static inline int ll_inode_to_ext_flags(int iflags, int keep)
 {
         return keep ? (iflags & ~MDS_BFLAG_EXT_FLAGS) :
-                (((iflags & S_SYNC)     ? MDS_SYNC_FL      : 0) |
+               (((iflags & S_SYNC)      ? MDS_SYNC_FL      : 0) |
                 ((iflags & S_NOATIME)   ? MDS_NOATIME_FL   : 0) |
                 ((iflags & S_APPEND)    ? MDS_APPEND_FL    : 0) |
 #if defined(S_DIRSYNC)
@@ -779,6 +1121,16 @@ static inline int ll_inode_to_ext_flags(int iflags, int keep)
 }
 #endif
 
+/*
+ * while mds_body is to interact with 1.6, mdt_body is to interact with 2.0.
+ * both of them should have the same fields layout, because at client side
+ * one could be dynamically cast to the other.
+ *
+ * mdt_body has large size than mds_body, with unused padding (48 bytes)
+ * at the end. client always use size of mdt_body to prepare request/reply
+ * buffers, and actual data could be interepeted as mdt_body or mds_body
+ * accordingly.
+ */
 struct mds_body {
         struct ll_fid  fid1;
         struct ll_fid  fid2;
@@ -805,12 +1157,48 @@ struct mds_body {
         __u32          eadatasize;
         __u32          aclsize;
         __u32          max_mdsize;
-        __u32          max_cookiesize; /* also fix lustre_swab_mds_body */
+        __u32          max_cookiesize;
         __u32          padding_4; /* also fix lustre_swab_mds_body */
 };
 
 extern void lustre_swab_mds_body (struct mds_body *b);
 
+struct mdt_body {
+        struct lu_fid  fid1;
+        struct lu_fid  fid2;
+        struct lustre_handle handle;
+        __u64          valid;
+        __u64          size;   /* Offset, in the case of MDS_READPAGE */
+        __u64          mtime;
+        __u64          atime;
+        __u64          ctime;
+        __u64          blocks; /* XID, in the case of MDS_READPAGE */
+        __u64          ioepoch;
+        __u64          ino;    /* for 1.6 compatibility */
+        __u32          fsuid;
+        __u32          fsgid;
+        __u32          capability;
+        __u32          mode;
+        __u32          uid;
+        __u32          gid;
+        __u32          flags; /* from vfs for pin/unpin, MDS_BFLAG for close */
+        __u32          rdev;
+        __u32          nlink; /* #bytes to read in the case of MDS_READPAGE */
+        __u32          generation; /* for 1.6 compatibility */
+        __u32          suppgid;
+        __u32          eadatasize;
+        __u32          aclsize;
+        __u32          max_mdsize;
+        __u32          max_cookiesize;
+        __u32          padding_4; /* also fix lustre_swab_mdt_body */
+        __u64          padding_5;
+        __u64          padding_6;
+        __u64          padding_7;
+        __u64          padding_8;
+        __u64          padding_9;
+        __u64          padding_10;
+};
+
 #define Q_QUOTACHECK    0x800100
 #define Q_INITQUOTA     0x800101        /* init slave limits */
 #define Q_GETOINFO      0x800102        /* get obd quota info */
@@ -845,7 +1233,7 @@ struct quota_adjust_qunit {
 };
 extern void lustre_swab_quota_adjust_qunit(struct quota_adjust_qunit *q);
 
-/* flags in qunit_data and quota_adjust_qunit will use macroes below */
+/* flags is shared among quota structures */
 #define LQUOTA_FLAGS_GRP       1UL   /* 0 is user, 1 is group */
 #define LQUOTA_FLAGS_BLK       2UL   /* 0 is inode, 1 is block */
 #define LQUOTA_FLAGS_ADJBLK    4UL   /* adjust the block qunit size */
@@ -853,16 +1241,21 @@ extern void lustre_swab_quota_adjust_qunit(struct quota_adjust_qunit *q);
 #define LQUOTA_FLAGS_CHG_QS   16UL   /* indicate whether it has capability of
                                       * OBD_CONNECT_CHANGE_QS */
 
+/* flags is specific for quota_adjust_qunit */
+#define LQUOTA_QAQ_CREATE_LQS  (1 << 31) /* when it is set, need create lqs */
+
 /* the status of lqs_flags in struct lustre_qunit_size  */
 #define LQUOTA_QUNIT_FLAGS (LQUOTA_FLAGS_GRP | LQUOTA_FLAGS_BLK)
 
-#define QAQ_IS_GRP(qaq)    ((qaq)->qaq_flags & LQUOTA_FLAGS_GRP)
-#define QAQ_IS_ADJBLK(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJBLK)
-#define QAQ_IS_ADJINO(qaq) ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJINO)
+#define QAQ_IS_GRP(qaq)         ((qaq)->qaq_flags & LQUOTA_FLAGS_GRP)
+#define QAQ_IS_ADJBLK(qaq)      ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJBLK)
+#define QAQ_IS_ADJINO(qaq)      ((qaq)->qaq_flags & LQUOTA_FLAGS_ADJINO)
+#define QAQ_IS_CREATE_LQS(qaq)  ((qaq)->qaq_flags & LQUOTA_QAQ_CREATE_LQS)
 
-#define QAQ_SET_GRP(qaq)    ((qaq)->qaq_flags |= LQUOTA_FLAGS_GRP)
-#define QAQ_SET_ADJBLK(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJBLK)
-#define QAQ_SET_ADJINO(qaq) ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJINO)
+#define QAQ_SET_GRP(qaq)        ((qaq)->qaq_flags |= LQUOTA_FLAGS_GRP)
+#define QAQ_SET_ADJBLK(qaq)     ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJBLK)
+#define QAQ_SET_ADJINO(qaq)     ((qaq)->qaq_flags |= LQUOTA_FLAGS_ADJINO)
+#define QAQ_SET_CREATE_LQS(qaq) ((qaq)->qaq_flags |= LQUOTA_QAQ_CREATE_LQS)
 
 struct mds_rec_setattr {
         __u32           sa_opcode;
@@ -883,6 +1276,8 @@ struct mds_rec_setattr {
         __u32           sa_padding; /* also fix lustre_swab_mds_rec_setattr */
 };
 
+extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
+
 /*
  * Attribute flags used in mds_rec_setattr::sa_valid.
  * The kernel's #defines for ATTR_* should not be used over the network
@@ -904,8 +1299,7 @@ struct mds_rec_setattr {
 #define MDS_ATTR_KILL_SGID  0x1000ULL /* = 4096 */
 #define MDS_ATTR_CTIME_SET  0x2000ULL /* = 8192 */
 #define MDS_ATTR_FROM_OPEN  0x4000ULL /* = 16384, called from open path, ie O_TRUNC */
-
-extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
+#define MDS_ATTR_BLOCKS     0x8000ULL /* = 32768 */
 
 #ifndef FMODE_READ
 #define FMODE_READ               00000001
@@ -922,6 +1316,11 @@ extern void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa);
 #define MDS_OPEN_DELAY_CREATE  0100000000 /* delay initial object create */
 #define MDS_OPEN_OWNEROVERRIDE 0200000000 /* NFSD rw-reopen ro file for owner */
 #define MDS_OPEN_JOIN_FILE     0400000000 /* open for join file*/
+#define MDS_CREATE_RMT_ACL    01000000000 /* indicate create on remote server
+                                           * with default ACL */
+#define MDS_CREATE_SLAVE_OBJ  02000000000 /* indicate create slave object
+                                           * actually, this is for create, not
+                                           * conflict with other open flags */
 #define MDS_OPEN_LOCK         04000000000 /* This open requires open lock */
 #define MDS_OPEN_HAS_EA      010000000000 /* specify object create pattern */
 #define MDS_OPEN_HAS_OBJS    020000000000 /* Just set the EA the obj exist */
@@ -947,6 +1346,39 @@ struct mds_rec_create {
 
 extern void lustre_swab_mds_rec_create (struct mds_rec_create *cr);
 
+struct mdt_rec_create {
+        __u32           cr_opcode;
+        __u32           cr_cap;
+        __u32           cr_fsuid;
+        __u32           cr_fsuid_h;
+        __u32           cr_fsgid;
+        __u32           cr_fsgid_h;
+        __u32           cr_suppgid1;
+        __u32           cr_suppgid1_h;
+        __u32           cr_suppgid2;
+        __u32           cr_suppgid2_h;
+        struct lu_fid   cr_fid1;
+        struct lu_fid   cr_fid2;
+        struct lustre_handle cr_old_handle; /* handle in case of open replay */
+        __u64           cr_time;
+        __u64           cr_rdev;
+        __u64           cr_ioepoch;
+        __u64           cr_padding_1; /* pad for 64 bits*/
+        __u32           cr_mode;
+        __u32           cr_bias;
+        __u32           cr_flags;     /* for use with open */
+        __u32           cr_padding_2; /* pad for 64 bits*/
+        __u32           cr_padding_3; /* pad for 64 bits*/
+        __u32           cr_padding_4; /* pad for 64 bits*/
+};
+
+struct mdt_epoch {
+        struct lustre_handle handle;
+        __u64  ioepoch;
+        __u32  flags;
+        __u32  padding;
+};
+
 struct mds_rec_join {
         struct ll_fid  jr_fid;
         __u64          jr_headsize;
@@ -954,6 +1386,13 @@ struct mds_rec_join {
 
 extern void lustre_swab_mds_rec_join (struct mds_rec_join *jr);
 
+struct mdt_rec_join {
+        struct lu_fid  jr_fid;
+        __u64          jr_headsize;
+};
+
+extern void lustre_swab_mdt_rec_join (struct mdt_rec_join *jr);
+
 struct mds_rec_link {
         __u32           lk_opcode;
         __u32           lk_fsuid;
@@ -972,6 +1411,32 @@ struct mds_rec_link {
 
 extern void lustre_swab_mds_rec_link (struct mds_rec_link *lk);
 
+struct mdt_rec_link {
+        __u32           lk_opcode;
+        __u32           lk_cap;
+        __u32           lk_fsuid;
+        __u32           lk_fsuid_h;
+        __u32           lk_fsgid;
+        __u32           lk_fsgid_h;
+        __u32           lk_suppgid1;
+        __u32           lk_suppgid1_h;
+        __u32           lk_suppgid2;
+        __u32           lk_suppgid2_h;
+        struct lu_fid   lk_fid1;
+        struct lu_fid   lk_fid2;
+        __u64           lk_time;
+        __u64           lk_padding_1;
+        __u64           lk_padding_2;
+        __u64           lk_padding_3;
+        __u64           lk_padding_4;
+        __u32           lk_bias;
+        __u32           lk_padding_5;
+        __u32           lk_padding_6;
+        __u32           lk_padding_7;
+        __u32           lk_padding_8;
+        __u32           lk_padding_9;
+};
+
 struct mds_rec_unlink {
         __u32           ul_opcode;
         __u32           ul_fsuid;
@@ -990,6 +1455,32 @@ struct mds_rec_unlink {
 
 extern void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul);
 
+struct mdt_rec_unlink {
+        __u32           ul_opcode;
+        __u32           ul_cap;
+        __u32           ul_fsuid;
+        __u32           ul_fsuid_h;
+        __u32           ul_fsgid;
+        __u32           ul_fsgid_h;
+        __u32           ul_suppgid1;
+        __u32           ul_suppgid1_h;
+        __u32           ul_suppgid2;
+        __u32           ul_suppgid2_h;
+        struct lu_fid   ul_fid1;
+        struct lu_fid   ul_fid2;
+        __u64           ul_time;
+        __u64           ul_padding_2;
+        __u64           ul_padding_3;
+        __u64           ul_padding_4;
+        __u64           ul_padding_5;
+        __u32           ul_bias;
+        __u32           ul_mode;
+        __u32           ul_padding_6;
+        __u32           ul_padding_7;
+        __u32           ul_padding_8;
+        __u32           ul_padding_9;
+};
+
 struct mds_rec_rename {
         __u32           rn_opcode;
         __u32           rn_fsuid;
@@ -1008,6 +1499,100 @@ struct mds_rec_rename {
 
 extern void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn);
 
+struct mdt_rec_rename {
+        __u32           rn_opcode;
+        __u32           rn_cap;
+        __u32           rn_fsuid;
+        __u32           rn_fsuid_h;
+        __u32           rn_fsgid;
+        __u32           rn_fsgid_h;
+        __u32           rn_suppgid1;
+        __u32           rn_suppgid1_h;
+        __u32           rn_suppgid2;
+        __u32           rn_suppgid2_h;
+        struct lu_fid   rn_fid1;
+        struct lu_fid   rn_fid2;
+        __u64           rn_time;
+        __u64           rn_padding_1;
+        __u64           rn_padding_2;
+        __u64           rn_padding_3;
+        __u64           rn_padding_4;
+        __u32           rn_bias;      /* some operation flags */
+        __u32           rn_mode;      /* cross-ref rename has mode */
+        __u32           rn_padding_5;
+        __u32           rn_padding_6;
+        __u32           rn_padding_7;
+        __u32           rn_padding_8;
+};
+
+struct mdt_rec_setattr {
+        __u32           sa_opcode;
+        __u32           sa_cap;
+        __u32           sa_fsuid;
+        __u32           sa_fsuid_h;
+        __u32           sa_fsgid;
+        __u32           sa_fsgid_h;
+        __u32           sa_suppgid;
+        __u32           sa_suppgid_h;
+        __u32           sa_padding_1;
+        __u32           sa_padding_1_h;
+        struct lu_fid   sa_fid;
+        __u64           sa_valid;
+        __u32           sa_uid;
+        __u32           sa_gid;
+        __u64           sa_size;
+        __u64           sa_blocks;
+        __u64           sa_mtime;
+        __u64           sa_atime;
+        __u64           sa_ctime;
+        __u32           sa_attr_flags;
+        __u32           sa_mode;
+        __u32           sa_padding_2;
+        __u32           sa_padding_3;
+        __u32           sa_padding_4;
+        __u32           sa_padding_5;
+};
+
+struct mdt_rec_setxattr {
+        __u32           sx_opcode;
+        __u32           sx_cap;
+        __u32           sx_fsuid;
+        __u32           sx_fsuid_h;
+        __u32           sx_fsgid;
+        __u32           sx_fsgid_h;
+        __u32           sx_suppgid1;
+        __u32           sx_suppgid1_h;
+        __u32           sx_suppgid2;
+        __u32           sx_suppgid2_h;
+        struct lu_fid   sx_fid;
+        __u64           sx_padding_1; /* These three members are lu_fid size */
+        __u32           sx_padding_2;
+        __u32           sx_padding_3;
+        __u64           sx_valid;
+        __u64           sx_time;
+        __u64           sx_padding_5;
+        __u64           sx_padding_6;
+        __u64           sx_padding_7;
+        __u32           sx_size;
+        __u32           sx_flags;
+        __u32           sx_padding_8;
+        __u32           sx_padding_9;
+        __u32           sx_padding_10;
+        __u32           sx_padding_11;
+};
+
+enum seq_rpc_opc {
+        SEQ_QUERY                       = 700,
+        SEQ_LAST_OPC,
+        SEQ_FIRST_OPC                   = SEQ_QUERY
+};
+
+enum seq_op {
+        SEQ_ALLOC_SUPER = 0,
+        SEQ_ALLOC_META = 1
+};
+
+
 /*
  *  LOV data structures
  */
@@ -1068,13 +1653,13 @@ extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id);
 /* lock types */
 typedef enum {
         LCK_MINMODE = 0,
-        LCK_EX = 1,
-        LCK_PW = 2,
-        LCK_PR = 4,
-        LCK_CW = 8,
-        LCK_CR = 16,
-        LCK_NL = 32,
-        LCK_GROUP = 64,
+        LCK_EX      = 1,
+        LCK_PW      = 2,
+        LCK_PR      = 4,
+        LCK_CW      = 8,
+        LCK_CR      = 16,
+        LCK_NL      = 32,
+        LCK_GROUP   = 64,
         LCK_MAXMODE
 } ldlm_mode_t;
 
@@ -1161,6 +1746,8 @@ struct ldlm_request {
         struct lustre_handle lock_handle[LDLM_LOCKREQ_HANDLES];
 };
 
+extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
+
 /* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available.
  * Otherwise, 2 are available. */
 #define ldlm_request_bufsize(count,type)                                \
@@ -1172,8 +1759,6 @@ struct ldlm_request {
         sizeof(struct lustre_handle);                                   \
 })
 
-extern void lustre_swab_ldlm_request (struct ldlm_request *rq);
-
 struct ldlm_reply {
         __u32 lock_flags;
         __u32 lock_padding;     /* also fix lustre_swab_ldlm_reply */
@@ -1185,7 +1770,6 @@ struct ldlm_reply {
 
 extern void lustre_swab_ldlm_reply (struct ldlm_reply *r);
 
-
 /*
  * Opcodes for mountconf (mgs and mgc)
  */
@@ -1263,14 +1847,14 @@ typedef enum {
 
 /* catalog of log objects */
 
-/* Identifier for a single log object */
+/** Identifier for a single log object */
 struct llog_logid {
         __u64                   lgl_oid;
         __u64                   lgl_ogr;
         __u32                   lgl_ogen;
 } __attribute__((packed));
 
-/* Records written to the CATALOGS list */
+/** Records written to the CATALOGS list */
 #define CATLIST "CATALOGS"
 struct llog_catid {
         struct llog_logid       lci_logid;
@@ -1279,7 +1863,7 @@ struct llog_catid {
         __u32                   lci_padding3;
 } __attribute__((packed));
 
-/*join file lov mds md*/
+/** join file lov mds md*/
 struct lov_mds_md_join {
         struct lov_mds_md lmmj_md;
         /*join private info*/
@@ -1299,10 +1883,13 @@ typedef enum {
         OST_RAID1_REC    = LLOG_OP_MAGIC | 0x01000,
         MDS_UNLINK_REC   = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_UNLINK,
         MDS_SETATTR_REC  = LLOG_OP_MAGIC | 0x10000 | (MDS_REINT << 8) | REINT_SETATTR,
+        MDS_SETATTR64_REC= LLOG_OP_MAGIC | 0x90000 | (MDS_REINT << 8) | REINT_SETATTR,
         OBD_CFG_REC      = LLOG_OP_MAGIC | 0x20000,
         PTL_CFG_REC      = LLOG_OP_MAGIC | 0x30000, /* obsolete */
         LLOG_GEN_REC     = LLOG_OP_MAGIC | 0x40000,
         LLOG_JOIN_REC    = LLOG_OP_MAGIC | 0x50000,
+         /** changelog record type */
+        CHANGELOG_REC    = LLOG_OP_MAGIC | 0x60000,
         LLOG_HDR_MAGIC   = LLOG_OP_MAGIC | 0x45539,
         LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b,
 } llog_op_type;
@@ -1316,7 +1903,7 @@ typedef enum {
          __swab32(LLOG_OP_MAGIC) ||                                     \
          (((r)->lrh_type == 0) && ((r)->lrh_len > LLOG_CHUNK_SIZE)))
 
-/* Log record header - stored in little endian order.
+/** Log record header - stored in little endian order.
  * Each record must start with this struct, end with a llog_rec_tail,
  * and be a multiple of 256 bits in size.
  */
@@ -1343,7 +1930,7 @@ struct llog_logid_rec {
         struct llog_rec_tail    lid_tail;
 } __attribute__((packed));
 
-/* MDS extent description
+/** MDS extent description
  * It is for joined file extent info, each extent info for joined file
  * just like (start, end, lmm).
  */
@@ -1352,7 +1939,8 @@ struct mds_extent_desc {
         __u64                   med_len;   /* extent length */
         struct lov_mds_md       med_lmm;   /* extent's lmm  */
 };
-/*Joined file array extent log record*/
+
+/** Joined file array extent log record*/
 struct llog_array_rec {
         struct llog_rec_hdr     lmr_hdr;
         struct mds_extent_desc  lmr_med;
@@ -1363,7 +1951,7 @@ struct llog_create_rec {
         struct llog_rec_hdr     lcr_hdr;
         struct ll_fid           lcr_fid;
         obd_id                  lcr_oid;
-        obd_count               lcr_ogen;
+        obd_count               lcr_ogr;
         __u32                   padding;
         struct llog_rec_tail    lcr_tail;
 } __attribute__((packed));
@@ -1379,21 +1967,33 @@ struct llog_orphan_rec {
 struct llog_unlink_rec {
         struct llog_rec_hdr     lur_hdr;
         obd_id                  lur_oid;
-        obd_count               lur_ogen;
-        __u32                   padding;
+        obd_count               lur_ogr;
+        obd_count               lur_count; /* to destroy the lost precreated */
         struct llog_rec_tail    lur_tail;
 } __attribute__((packed));
 
 struct llog_setattr_rec {
         struct llog_rec_hdr     lsr_hdr;
         obd_id                  lsr_oid;
-        obd_count               lsr_ogen;
+        obd_count               lsr_ogr;
         __u32                   lsr_uid;
         __u32                   lsr_gid;
         __u32                   padding;
         struct llog_rec_tail    lsr_tail;
 } __attribute__((packed));
 
+struct llog_setattr64_rec {
+        struct llog_rec_hdr     lsr_hdr;
+        obd_id                  lsr_oid;
+        obd_count               lsr_ogr;
+        __u32                   padding;
+        __u32                   lsr_uid;
+        __u32                   lsr_uid_h;
+        __u32                   lsr_gid;
+        __u32                   lsr_gid_h;
+        struct llog_rec_tail    lsr_tail;
+} __attribute__((packed));
+
 struct llog_size_change_rec {
         struct llog_rec_hdr     lsc_hdr;
         struct ll_fid           lsc_fid;
@@ -1443,7 +2043,7 @@ struct llog_log_hdr {
                                  llh->llh_bitmap_offset -       \
                                  sizeof(llh->llh_tail)) * 8)
 
-/* log cookies are used to reference a specific log file and a record therein */
+/** log cookies are used to reference a specific log file and a record therein */
 struct llog_cookie {
         struct llog_logid       lgc_lgl;
         __u32                   lgc_subsys;
@@ -1451,8 +2051,8 @@ struct llog_cookie {
         __u32                   lgc_padding;
 } __attribute__((packed));
 
-/* llog protocol */
-typedef enum {
+/** llog protocol */
+typedef enum llogd_rpc_ops {
         LLOG_ORIGIN_HANDLE_CREATE       = 501,
         LLOG_ORIGIN_HANDLE_NEXT_BLOCK   = 502,
         LLOG_ORIGIN_HANDLE_READ_HEADER  = 503,
@@ -1505,7 +2105,7 @@ struct lov_user_md_join {         /* LOV EA user data (host-endian) */
         struct lov_user_ost_data_join lmm_objects[0]; /* per-stripe data */
 } __attribute__((packed));
 
-
+/* Note: 64-bit types are 64-bit aligned in structure */
 struct obdo {
         obd_valid               o_valid;        /* hot fields in this obdo */
         obd_id                  o_id;
@@ -1546,6 +2146,23 @@ struct obdo {
 #define o_dropped o_misc
 #define o_cksum   o_nlink
 
+static inline void lustre_set_wire_obdo(struct obdo *wobdo, struct obdo *lobdo)
+{
+        memcpy(wobdo, lobdo, sizeof(*lobdo));
+        wobdo->o_flags &= ~OBD_FL_LOCAL_MASK;
+}
+
+static inline void lustre_get_wire_obdo(struct obdo *lobdo, struct obdo *wobdo)
+{
+        obd_flag local_flags = lobdo->o_flags & OBD_FL_LOCAL_MASK;
+
+        LASSERT(!(wobdo->o_flags & OBD_FL_LOCAL_MASK));
+        
+        memcpy(lobdo, wobdo, sizeof(*lobdo));
+        lobdo->o_flags &= ~OBD_FL_LOCAL_MASK;
+        lobdo->o_flags |= local_flags;
+}
+
 extern void lustre_swab_obdo (struct obdo *o);
 
 /* request structure for OST's */
@@ -1564,9 +2181,10 @@ extern void lustre_swab_ost_body (struct ost_body *b);
 extern void lustre_swab_ost_last_id(obd_id *id);
 extern void lustre_swab_fiemap(struct ll_user_fiemap *fiemap);
 
-extern void lustre_swab_lov_user_md(struct lov_user_md *lum);
-extern void lustre_swab_lov_user_md_objects(struct lov_user_md *lum);
+extern int  lustre_swab_lov_user_md(struct lov_user_md_v1 *lum);
+extern int  lustre_swab_lov_user_md_objects(struct lov_user_md *lod);
 extern void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj);
+extern void lustre_swab_lov_mds_md(struct lov_mds_md *lmm);
 
 /* llog_swab.c */
 extern void lustre_swab_llogd_body (struct llogd_body *d);
@@ -1615,23 +2233,7 @@ struct qunit_data_old2 {
 #warning "remove quota code above for format absolete in new release"
 #endif
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-struct qunit_data_old {
-        __u32 qd_id;    /* ID appiles to (uid, gid) */
-        __u32 qd_type;  /* Quota type (USRQUOTA, GRPQUOTA) */
-        __u32 qd_count; /* acquire/release count (bytes for block quota) */
-        __u32 qd_isblk; /* Block quota or file quota */
-};
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
-
 extern void lustre_swab_qdata(struct qunit_data *d);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-extern void lustre_swab_qdata_old(struct qunit_data_old *d);
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
 extern void lustre_swab_qdata_old2(struct qunit_data_old2 *d);
 #else
@@ -1657,10 +2259,40 @@ typedef enum {
 #define QUOTA_IMPORT    0
 
 /* quota check function */
-#define QUOTA_RET_OK           0 /* return successfully */
-#define QUOTA_RET_NOQUOTA      1 /* not support quota */
-#define QUOTA_RET_NOLIMIT      2 /* quota limit isn't set */
-#define QUOTA_RET_ACQUOTA      4 /* need to acquire extra quota */
+#define QUOTA_RET_OK           0 /**< return successfully */
+#define QUOTA_RET_NOQUOTA      1 /**< not support quota */
+#define QUOTA_RET_NOLIMIT      2 /**< quota limit isn't set */
+#define QUOTA_RET_ACQUOTA      4 /**< need to acquire extra quota */
 
 extern int quota_get_qunit_data_size(__u64 flag);
+
+/* security opcodes */
+typedef enum {
+        SEC_CTX_INIT            = 801,
+        SEC_CTX_INIT_CONT       = 802,
+        SEC_CTX_FINI            = 803,
+        SEC_LAST_OPC,
+        SEC_FIRST_OPC           = SEC_CTX_INIT
+} sec_cmd_t;
+
+/*
+ * capa related definitions
+ */
+#define CAPA_HMAC_MAX_LEN       64
+#define CAPA_HMAC_KEY_MAX_LEN   56
+
+/* NB take care when changing the sequence of elements this struct,
+ * because the offset info is used in find_capa() */
+struct lustre_capa {
+        struct lu_fid   lc_fid;         /** fid */
+        __u64           lc_opc;         /** operations allowed */
+        __u64           lc_uid;         /** file owner */
+        __u64           lc_gid;         /** file group */
+        __u32           lc_flags;       /** HMAC algorithm & flags */
+        __u32           lc_keyid;       /** key# used for the capability */
+        __u32           lc_timeout;     /** capa timeout value (sec) */
+        __u32           lc_expiry;      /** expiry time (sec) */
+        __u8            lc_hmac[CAPA_HMAC_MAX_LEN];   /** HMAC */
+} __attribute__((packed));
+
 #endif
diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h
index 8061f04..dbeaa1e 100644
--- a/lustre/include/lustre/lustre_user.h
+++ b/lustre/include/lustre/lustre_user.h
@@ -55,15 +55,13 @@
 /* for statfs() */
 #define LL_SUPER_MAGIC 0x0BD00BD0
 
-#ifndef EXT3_IOC_GETFLAGS
-#define EXT3_IOC_GETFLAGS               _IOR('f', 1, long)
-#define EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
-#define EXT3_IOC_GETVERSION             _IOR('f', 3, long)
-#define EXT3_IOC_SETVERSION             _IOW('f', 4, long)
-#define EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
-#define EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
-#define EXT3_IOC_FIEMAP                 _IOWR('f', 10, struct ll_user_fiemap)
-#endif
+#define FSFILT_IOC_GETFLAGS               _IOR('f', 1, long)
+#define FSFILT_IOC_SETFLAGS               _IOW('f', 2, long)
+#define FSFILT_IOC_GETVERSION             _IOR('f', 3, long)
+#define FSFILT_IOC_SETVERSION             _IOW('f', 4, long)
+#define FSFILT_IOC_GETVERSION_OLD         _IOR('v', 1, long)
+#define FSFILT_IOC_SETVERSION_OLD         _IOW('v', 2, long)
+#define FSFILT_IOC_FIEMAP                 _IOWR('f', 11, struct ll_user_fiemap)
 
 /* FIEMAP flags supported by Lustre */
 #define LUSTRE_FIEMAP_FLAGS_COMPAT (FIEMAP_FLAG_SYNC | FIEMAP_FLAG_DEVICE_ORDER)
@@ -115,7 +113,6 @@ struct obd_statfs;
 #define IOC_MDC_GETSTRIPE       IOC_MDC_GETFILESTRIPE
 
 #define O_LOV_DELAY_CREATE 0100000000  /* hopefully this does not conflict */
-#define O_JOIN_FILE        0400000000  /* hopefully this does not conflict */
 
 #define LL_FILE_IGNORE_LOCK             0x00000001
 #define LL_FILE_GROUP_LOCKED            0x00000002
@@ -123,13 +120,19 @@ struct obd_statfs;
 
 #define LOV_USER_MAGIC_V1 0x0BD10BD0
 #define LOV_USER_MAGIC    LOV_USER_MAGIC_V1
-
 #define LOV_USER_MAGIC_JOIN 0x0BD20BD0
+#define LOV_USER_MAGIC_V3 0x0BD30BD0
+
+#define LOV_USER_MAGIC_V1_SWABBED 0xD00BD10B
+#define LOV_USER_MAGIC_V3_SWABBED 0xD00BD30B
 
 #define LOV_PATTERN_RAID0 0x001
 #define LOV_PATTERN_RAID1 0x002
 #define LOV_PATTERN_FIRST 0x100
 
+#define LOV_MAXPOOLNAME 16
+#define LOV_POOLNAMEF "%.16s"
+
 #define lov_user_ost_data lov_user_ost_data_v1
 struct lov_user_ost_data_v1 {     /* per-stripe data structure */
         __u64 l_object_id;        /* OST object ID */
@@ -150,6 +153,18 @@ struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
         struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 } __attribute__((packed));
 
+struct lov_user_md_v3 {           /* LOV EA user data (host-endian) */
+        __u32 lmm_magic;          /* magic number = LOV_USER_MAGIC_V3 */
+        __u32 lmm_pattern;        /* LOV_PATTERN_RAID0, LOV_PATTERN_RAID1 */
+        __u64 lmm_object_id;      /* LOV object ID */
+        __u64 lmm_object_gr;      /* LOV object group */
+        __u32 lmm_stripe_size;    /* size of stripe in bytes */
+        __u16 lmm_stripe_count;   /* num stripes in use for this object */
+        __u16 lmm_stripe_offset;  /* starting stripe offset in lmm_objects */
+        char  lmm_pool_name[LOV_MAXPOOLNAME]; /* pool name */
+        struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
+} __attribute__((packed));
+
 /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to
  * use this.  It is unsafe to #define those values in this header as it
  * is possible the application has already #included <sys/stat.h>. */
@@ -157,7 +172,12 @@ struct lov_user_md_v1 {           /* LOV EA user data (host-endian) */
 #define lov_user_mds_data lov_user_mds_data_v1
 struct lov_user_mds_data_v1 {
         lstat_t lmd_st;                 /* MDS stat struct */
-        struct lov_user_md_v1 lmd_lmm;  /* LOV EA user data */
+        struct lov_user_md_v1 lmd_lmm;  /* LOV EA V1 user data */
+} __attribute__((packed));
+
+struct lov_user_mds_data_v3 {
+        lstat_t lmd_st;                 /* MDS stat struct */
+        struct lov_user_md_v3 lmd_lmm;  /* LOV EA V3 user data */
 } __attribute__((packed));
 #endif
 
@@ -243,17 +263,6 @@ struct mds_grp_downcall_data {
 };
 
 #ifdef NEED_QUOTA_DEFS
-#ifndef QUOTABLOCK_BITS
-#define QUOTABLOCK_BITS 10
-#endif
-
-#ifndef QUOTABLOCK_SIZE
-#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
-#endif
-
-#ifndef toqb
-#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
-#endif
 
 #ifndef QIF_BLIMITS
 #define QIF_BLIMITS     1
diff --git a/lustre/include/lustre_cfg.h b/lustre/include/lustre_cfg.h
index 5823986..c58edd4 100644
--- a/lustre/include/lustre_cfg.h
+++ b/lustre/include/lustre_cfg.h
@@ -47,29 +47,37 @@
 #define LCFG_HDR_SIZE(count) \
     size_round(offsetof (struct lustre_cfg, lcfg_buflens[(count)]))
 
-/* If not LCFG_REQUIRED, we can ignore this cmd and go on. */
+/* If the LCFG_REQUIRED bit is set in a configuration command,
+ * then the client is required to understand this parameter
+ * in order to mount the filesystem. If it does not understand
+ * a REQUIRED command the client mount will fail. */
 #define LCFG_REQUIRED         0x0001000
 
 enum lcfg_command_type {
-        LCFG_ATTACH         = 0x00cf001,
-        LCFG_DETACH         = 0x00cf002,
-        LCFG_SETUP          = 0x00cf003,
-        LCFG_CLEANUP        = 0x00cf004,
-        LCFG_ADD_UUID       = 0x00cf005,
-        LCFG_DEL_UUID       = 0x00cf006,
-        LCFG_MOUNTOPT       = 0x00cf007,
-        LCFG_DEL_MOUNTOPT   = 0x00cf008,
-        LCFG_SET_TIMEOUT    = 0x00cf009,
-        LCFG_SET_UPCALL     = 0x00cf00a,
-        LCFG_ADD_CONN       = 0x00cf00b,
-        LCFG_DEL_CONN       = 0x00cf00c,
-        LCFG_LOV_ADD_OBD    = 0x00cf00d,
-        LCFG_LOV_DEL_OBD    = 0x00cf00e,
-        LCFG_PARAM          = 0x00cf00f,
-        LCFG_MARKER         = 0x00cf010,
-        LCFG_LOG_START      = 0x00ce011,
-        LCFG_LOG_END        = 0x00ce012,
-        LCFG_LOV_ADD_INA    = 0x00ce013,
+        LCFG_ATTACH             = 0x00cf001,
+        LCFG_DETACH             = 0x00cf002,
+        LCFG_SETUP              = 0x00cf003,
+        LCFG_CLEANUP            = 0x00cf004,
+        LCFG_ADD_UUID           = 0x00cf005,
+        LCFG_DEL_UUID           = 0x00cf006,
+        LCFG_MOUNTOPT           = 0x00cf007,
+        LCFG_DEL_MOUNTOPT       = 0x00cf008,
+        LCFG_SET_TIMEOUT        = 0x00cf009,
+        LCFG_SET_UPCALL         = 0x00cf00a,
+        LCFG_ADD_CONN           = 0x00cf00b,
+        LCFG_DEL_CONN           = 0x00cf00c,
+        LCFG_LOV_ADD_OBD        = 0x00cf00d,
+        LCFG_LOV_DEL_OBD        = 0x00cf00e,
+        LCFG_PARAM              = 0x00cf00f,
+        LCFG_MARKER             = 0x00cf010,
+        LCFG_LOG_START          = 0x00ce011,
+        LCFG_LOG_END            = 0x00ce012,
+        LCFG_LOV_ADD_INA        = 0x00ce013,
+        LCFG_POOL_NEW           = 0x00ce020,
+        LCFG_POOL_ADD           = 0x00ce021,
+        LCFG_POOL_REM           = 0x00ce022,
+        LCFG_POOL_DEL           = 0x00ce023,
+        LCFG_SET_LDLM_TIMEOUT   = 0x00ce030,
 };
 
 struct lustre_cfg_bufs {
@@ -214,7 +222,7 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd,
         OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount,
                                        bufs->lcfg_buflen));
         if (!lcfg)
-                RETURN(lcfg);
+                RETURN(ERR_PTR(-ENOMEM));
 
         lcfg->lcfg_version = LUSTRE_CFG_VERSION;
         lcfg->lcfg_command = cmd;
diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h
index 9e45e64..1e55a80 100644
--- a/lustre/include/lustre_disk.h
+++ b/lustre/include/lustre_disk.h
@@ -166,7 +166,7 @@ struct lustre_mount_data {
 #define LMD_FLG_SERVER       0x0001  /* Mounting a server */
 #define LMD_FLG_CLIENT       0x0002  /* Mounting a client */
 #define LMD_FLG_ABORT_RECOV  0x0008  /* Abort recovery */
-#define LMD_FLG_NOSVC        0x0010  /* Only start MGS/MGC for servers, 
+#define LMD_FLG_NOSVC        0x0010  /* Only start MGS/MGC for servers,
                                         no other services */
 #define LMD_FLG_NOMGS        0x0020  /* Only start target for servers, reusing
                                         existing MGS services */
@@ -182,6 +182,7 @@ struct lustre_mount_data {
 #if LR_CLIENT_START < LR_SERVER_SIZE
 #error "Can't have LR_CLIENT_START < LR_SERVER_SIZE"
 #endif
+
 /*
  * This limit is arbitrary (131072 clients on x86), but it is convenient to use
  * 2^n * CFS_PAGE_SIZE * 8 for the number of bits that fit an order-n allocation.
@@ -189,6 +190,9 @@ struct lustre_mount_data {
  * should become an array of single-page pointers that are allocated on demand.
  */
 #define LR_MAX_CLIENTS max(128 * 1024UL, CFS_PAGE_SIZE * 8)
+/* version recovery */
+#define LR_EPOCH_BITS   32
+#define lr_epoch(a) ((a) >> LR_EPOCH_BITS)
 
 /* COMPAT_146 */
 #define OBD_COMPAT_OST          0x00000002 /* this is an OST (temporary) */
@@ -202,8 +206,10 @@ struct lustre_mount_data {
 #define OBD_INCOMPAT_OST        0x00000002 /* this is an OST */
 #define OBD_INCOMPAT_MDT        0x00000004 /* this is an MDT */
 #define OBD_INCOMPAT_COMMON_LR  0x00000008 /* common last_rvcd format */
+#define OBD_INCOMPAT_FID        0x00000010 /* FID is enabled */
+#define OBD_INCOMPAT_SOM        0x00000020 /* Size-On-MDS is enabled */
 
-
+#define LR_EXPIRE_INTERVALS 16 /**< number of intervals to track transno */
 /* Data stored per server at the head of the last_rcvd file.  In le32 order.
    This should be common to filter_internal.h, lustre_mds.h */
 struct lr_server_data {
@@ -223,7 +229,13 @@ struct lr_server_data {
         __u8  lsd_peeruuid[40];    /* UUID of MDS associated with this OST */
         __u32 lsd_ost_index;       /* index number of OST in LOV */
         __u32 lsd_mdt_index;       /* index number of MDT in LMV */
-        __u8  lsd_padding[LR_SERVER_SIZE - 148];
+        __u32 lsd_start_epoch;     /* VBR: start epoch from last boot */
+        /** transaction values since lsd_trans_table_time */
+        __u64 lsd_trans_table[LR_EXPIRE_INTERVALS];
+        /** start point of transno table below */
+        __u32 lsd_trans_table_time; /* time of first slot in table above */
+        __u32 lsd_expire_intervals; /* LR_EXPIRE_INTERVALS */
+        __u8  lsd_padding[LR_SERVER_SIZE - 288];
 };
 
 /* Data stored per client in the last_rcvd file.  In le32 order. */
@@ -238,9 +250,21 @@ struct lsd_client_data {
         __u64 lcd_last_close_xid;     /* xid for the last transaction */
         __u32 lcd_last_close_result;  /* result from last RPC */
         __u32 lcd_last_close_data;    /* per-op data */
-        __u8  lcd_padding[LR_CLIENT_SIZE - 88];
+        /* VBR: last versions */
+        __u64 lcd_pre_versions[4];
+        __u32 lcd_last_epoch;
+        /** orphans handling for delayed export rely on that */
+        __u32 lcd_first_epoch;
+        __u8  lcd_padding[LR_CLIENT_SIZE - 128];
 };
 
+static inline __u64 lsd_last_transno(struct lsd_client_data *lcd)
+{
+        return le64_to_cpu(lcd->lcd_last_transno) >
+               le64_to_cpu(lcd->lcd_last_close_transno) ?
+               le64_to_cpu(lcd->lcd_last_transno) :
+               le64_to_cpu(lcd->lcd_last_close_transno);
+}
 
 #ifdef __KERNEL__
 /****************** superblock additional info *********************/
diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h
index c629386..cb635f9 100644
--- a/lustre/include/lustre_dlm.h
+++ b/lustre/include/lustre_dlm.h
@@ -167,7 +167,7 @@ typedef enum {
  * the 1st operation, whereas the 2nd operation has canceled this lock and
  * is waiting for rpc_lock which is taken by the 1st operation.
  * LDLM_FL_BL_AST is to be set by ldlm_callback_handler() to the lock not allow
- * ELC code to cancel it. 
+ * ELC code to cancel it.
  * LDLM_FL_BL_DONE is to be set by ldlm_cancel_callback() when lock cache is
  * droped to let ldlm_callback_handler() return EINVAL to the server. It is
  * used when ELC rpc is already prepared and is waiting for rpc_lock, too late
@@ -184,8 +184,15 @@ typedef enum {
 /* Flags sent in AST lock_flags to be mapped into the receiving lock. */
 #define LDLM_AST_FLAGS         (LDLM_FL_DISCARD_DATA)
 
-/* Lock marked with this flag is going to fail to obtain cp_ast with emulating 
- * -EINTR while waiting. */
+/* 
+ * --------------------------------------------------------------------------
+ * NOTE! Starting from this point, that is, LDLM_FL_* flags with values above
+ * 0x80000000 will not be sent over the wire.
+ * --------------------------------------------------------------------------
+ */
+
+/* Used for marking lock as an target for -EINTR while cp_ast sleep
+ * emulation + race with upcoming bl_ast.  */
 #define LDLM_FL_FAIL_LOC       0x100000000ULL
 
 /* The blocking callback is overloaded to perform two functions.  These flags
@@ -255,7 +262,7 @@ struct ldlm_namespace;
 
 struct ldlm_pool_ops {
         int (*po_recalc)(struct ldlm_pool *pl);
-        int (*po_shrink)(struct ldlm_pool *pl, int nr, 
+        int (*po_shrink)(struct ldlm_pool *pl, int nr,
                          unsigned int gfp_mask);
         int (*po_setup)(struct ldlm_pool *pl, int limit);
 };
@@ -347,7 +354,6 @@ struct ldlm_pool {
          */
         struct lprocfs_stats  *pl_stats;
 };
-
 typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **,
                                void *req_cookie, ldlm_mode_t mode, int flags,
                                void *data);
@@ -369,12 +375,6 @@ typedef enum {
 #define NS_DEFAULT_CONTENTION_SECONDS 2
 #define NS_DEFAULT_CONTENDED_LOCKS 32
 
-/* Default value for ->ns_shrink_thumb. If lock is not extent one its cost 
- * is one page. Here we have 256 pages which is 1M on i386. Thus by default
- * all extent locks which have more than 1M long extent will be kept in lru,
- * others (including ibits locks) will be canceled on memory pressure event. */
-#define LDLM_LOCK_SHRINK_THUMB 256
-
 struct ldlm_namespace {
         char                  *ns_name;
         ldlm_side_t            ns_client; /* is this a client-side lock tree? */
@@ -397,8 +397,6 @@ struct ldlm_namespace {
         unsigned int           ns_max_age;
         unsigned int           ns_timeouts;
 
-        /* Lower limit to number of pages in lock to keep it in cache */
-        unsigned int           ns_shrink_thumb;
         cfs_time_t             ns_next_dump;   /* next debug dump, jiffies */
 
         atomic_t               ns_locks;
@@ -427,7 +425,7 @@ struct ldlm_namespace {
 static inline int ns_is_client(struct ldlm_namespace *ns)
 {
         LASSERT(ns != NULL);
-        LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT | 
+        LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |
                                     LDLM_NAMESPACE_SERVER)));
         LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||
                 ns->ns_client == LDLM_NAMESPACE_SERVER);
@@ -437,7 +435,7 @@ static inline int ns_is_client(struct ldlm_namespace *ns)
 static inline int ns_is_server(struct ldlm_namespace *ns)
 {
         LASSERT(ns != NULL);
-        LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT | 
+        LASSERT(!(ns->ns_client & ~(LDLM_NAMESPACE_CLIENT |
                                     LDLM_NAMESPACE_SERVER)));
         LASSERT(ns->ns_client == LDLM_NAMESPACE_CLIENT ||
                 ns->ns_client == LDLM_NAMESPACE_SERVER);
@@ -472,7 +470,7 @@ typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);
 /* Interval node data for each LDLM_EXTENT lock */
 struct ldlm_interval {
         struct interval_node li_node;   /* node for tree mgmt */
-        struct list_head     li_group;  /* the locks which have the same 
+        struct list_head     li_group;  /* the locks which have the same
                                          * policy - group of the policy */
 };
 #define to_ldlm_interval(n) container_of(n, struct ldlm_interval, li_node)
@@ -490,7 +488,7 @@ struct ldlm_lock {
         struct portals_handle l_handle; // must be first in the structure
         atomic_t              l_refc;
 
-        /* internal spinlock protects l_resource.  we should hold this lock 
+        /* internal spinlock protects l_resource.  we should hold this lock
          * first before grabbing res_lock.*/
         spinlock_t            l_lock;
 
@@ -558,7 +556,7 @@ struct ldlm_lock {
         /* for ldlm_add_ast_work_item() */
         struct list_head      l_bl_ast;
         struct list_head      l_cp_ast;
-        struct ldlm_lock     *l_blocking_lock; 
+        struct ldlm_lock     *l_blocking_lock;
         int                   l_bl_ast_run;
 
         /* protected by lr_lock, linkages to "skip lists" */
@@ -910,9 +908,9 @@ void ldlm_pools_recalc(ldlm_side_t client);
 int ldlm_pools_init(void);
 void ldlm_pools_fini(void);
 
-int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, 
+int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
                    int idx, ldlm_side_t client);
-int ldlm_pool_shrink(struct ldlm_pool *pl, int nr, 
+int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
                      unsigned int gfp_mask);
 void ldlm_pool_fini(struct ldlm_pool *pl);
 int ldlm_pool_setup(struct ldlm_pool *pl, int limit);
diff --git a/lustre/include/lustre_export.h b/lustre/include/lustre_export.h
index 4ffd166..a49a6a3 100644
--- a/lustre/include/lustre_export.h
+++ b/lustre/include/lustre_export.h
@@ -37,21 +37,30 @@
 #ifndef __EXPORT_H
 #define __EXPORT_H
 
-#include <lustre/lustre_idl.h>
 #include <lustre_dlm.h>
+#include <lustre/lustre_idl.h>
 #include <lprocfs_status.h>
 #include <class_hash.h>
 
-/* Data stored per client in the last_rcvd file.  In le32 order. */
+struct lu_export_data {
+        struct semaphore        led_lcd_lock; /**< protect led_lcd */
+        struct lsd_client_data *led_lcd;      /**< client data */
+        loff_t                  led_lr_off;   /**< offset in last_rcvd */
+        int                     led_lr_idx;   /**< client index */
+};
+
 struct mds_export_data {
+        struct lu_export_data   med_led;
         struct list_head        med_open_head;
         spinlock_t              med_open_lock; /* lock med_open_head, mfd_list*/
-        struct lsd_client_data *med_lcd;
         __u64                   med_ibits_known;
-        loff_t                  med_lr_off;
-        int                     med_lr_idx;
 };
 
+#define med_lcd_lock    med_led.led_lcd_lock
+#define med_lcd         med_led.led_lcd
+#define med_lr_off      med_led.led_lr_off
+#define med_lr_idx      med_led.led_lr_idx
+
 struct osc_creator {
         spinlock_t              oscc_lock;
         struct list_head        oscc_list;
@@ -71,36 +80,45 @@ struct ec_export_data { /* echo client */
 
 /* In-memory access to client data from OST struct */
 struct filter_export_data {
-        spinlock_t                 fed_lock;      /* protects fed_open_head */
-        struct lsd_client_data    *fed_lcd;
-        loff_t                     fed_lr_off;
-        int                        fed_lr_idx;
+        struct lu_export_data      fed_led;
+        spinlock_t                 fed_lock;      /**< protects fed_mod_list */
         long                       fed_dirty;    /* in bytes */
         long                       fed_grant;    /* in bytes */
         struct list_head           fed_mod_list; /* files being modified */
         int                        fed_mod_count;/* items in fed_writing list */
         long                       fed_pending;  /* bytes just being written */
-        struct brw_stats           fed_brw_stats;
 };
 
-typedef struct nid_stat_uuid {
-        struct list_head ns_uuid_list;
-        struct obd_uuid  ns_uuid;
-} nid_stat_uuid_t;
+#define fed_lcd_lock    fed_led.led_lcd_lock
+#define fed_lcd         fed_led.led_lcd
+#define fed_lr_off      fed_led.led_lr_off
+#define fed_lr_idx      fed_led.led_lr_idx
 
 typedef struct nid_stat {
         lnet_nid_t               nid;
         struct hlist_node        nid_hash;
         struct list_head         nid_list;
-        struct list_head         nid_uuid_list;
         struct obd_device       *nid_obd;
         struct proc_dir_entry   *nid_proc;
         struct lprocfs_stats    *nid_stats;
         struct brw_stats        *nid_brw_stats;
         struct lprocfs_stats    *nid_ldlm_stats;
-        int                      nid_exp_ref_count;
+        atomic_t                 nid_exp_ref_count; /* for obd_nid_stats_hash
+                                                           exp_nid_stats */
 } nid_stat_t;
 
+#define nidstat_getref(nidstat)                                                \
+do {                                                                           \
+        atomic_inc(&(nidstat)->nid_exp_ref_count);                             \
+} while(0)
+
+#define nidstat_putref(nidstat)                                                \
+do {                                                                           \
+        atomic_dec(&(nidstat)->nid_exp_ref_count);                             \
+        LASSERTF(atomic_read(&(nidstat)->nid_exp_ref_count) >= 0,              \
+                 "stat %p nid_exp_ref_count < 0\n", nidstat);                  \
+} while(0)
+
 enum obd_option {
         OBD_OPT_FORCE =         0x0001,
         OBD_OPT_FAILOVER =      0x0002,
@@ -127,6 +145,8 @@ struct obd_export {
         lustre_hash_t            *exp_lock_hash; /* existing lock hash */
         spinlock_t                exp_lock_hash_lock;
         struct list_head          exp_outstanding_replies;
+        struct list_head          exp_uncommitted_replies;
+        spinlock_t                exp_uncommitted_replies_lock;
         time_t                    exp_last_request_time;
         struct list_head          exp_req_replay_queue;
         spinlock_t                exp_lock; /* protects flags int below */
@@ -134,26 +154,39 @@ struct obd_export {
         __u64                     exp_connect_flags;
         enum obd_option           exp_flags;
         unsigned long             exp_failed:1,
+                                  exp_in_recovery:1,
                                   exp_disconnected:1,
                                   exp_connecting:1,
+                                  /* VBR: export missed recovery */
+                                  exp_delayed:1,
+                                  /* VBR: failed version checking */
+                                  exp_vbr_failed:1,
                                   exp_replay_needed:1,
                                   exp_need_sync:1, /* needs sync from connect */
-                                  exp_bflag:1,     /* for 1.6 only to track
-                                                      MDS_BFLAG_EXT_FLAGS */
                                   exp_libclient:1; /* liblustre client? */
         struct list_head          exp_queued_rpc;  /* RPC to be handled */
+        /* VBR: per-export last committed */
+        __u64                     exp_last_committed;
         union {
+                struct lu_export_data     eu_target_data;
                 struct mds_export_data    eu_mds_data;
                 struct filter_export_data eu_filter_data;
                 struct ec_export_data     eu_ec_data;
         } u;
 };
 
+#define exp_target_data u.eu_target_data
 #define exp_mds_data    u.eu_mds_data
-#define exp_lov_data    u.eu_lov_data
 #define exp_filter_data u.eu_filter_data
 #define exp_ec_data     u.eu_ec_data
 
+static inline int exp_expired(struct obd_export *exp, __u32 age)
+{
+        LASSERT(exp->exp_delayed);
+        return cfs_time_before(exp->exp_last_request_time + age,
+                               cfs_time_current_sec());
+}
+
 static inline int exp_connect_cancelset(struct obd_export *exp)
 {
         LASSERT(exp != NULL);
@@ -166,6 +199,13 @@ static inline int exp_connect_lru_resize(struct obd_export *exp)
         return !!(exp->exp_connect_flags & OBD_CONNECT_LRU_RESIZE);
 }
 
+static inline int exp_connect_vbr(struct obd_export *exp)
+{
+        LASSERT(exp != NULL);
+        LASSERT(exp->exp_connection);
+        return !!(exp->exp_connect_flags & OBD_CONNECT_VBR);
+}
+
 static inline int imp_connect_lru_resize(struct obd_import *imp)
 {
         struct obd_connect_data *ocd;
diff --git a/lustre/include/lustre_import.h b/lustre/include/lustre_import.h
index 7613b11..8fdb36e 100644
--- a/lustre/include/lustre_import.h
+++ b/lustre/include/lustre_import.h
@@ -40,7 +40,6 @@
 #include <lustre_handles.h>
 #include <lustre/lustre_idl.h>
 
-
 /* Adaptive Timeout stuff */
 #define D_ADAPTTO D_OTHER
 #define AT_BINS 4                  /* "bin" means "N seconds of history" */
@@ -69,6 +68,14 @@ enum lustre_imp_state {
         LUSTRE_IMP_EVICTED    = 10,
 };
 
+struct ptlrpc_at_array {
+        struct list_head *paa_reqs_array; /* array to hold requests */
+        __u32             paa_size;       /* the size of array */
+        __u32             paa_count;      /* the total count of reqs */
+        time_t            paa_deadline;   /* the earliest deadline of reqs */
+        __u32            *paa_reqs_count; /* the count of reqs in each entry */
+};
+
 static inline char * ptlrpc_import_state_name(enum lustre_imp_state state)
 {
         static char* import_state_names[] = {
@@ -96,13 +103,20 @@ struct obd_import_conn {
         __u64                     oic_last_attempt; /* jiffies, 64-bit */
 };
 
-#define IMP_AT_MAX_PORTALS 4
+#define IMP_AT_MAX_PORTALS 8
 struct imp_at {
         int                     iat_portal[IMP_AT_MAX_PORTALS];
         struct adaptive_timeout iat_net_latency;
         struct adaptive_timeout iat_service_estimate[IMP_AT_MAX_PORTALS];
 };
 
+/* state history */
+#define IMP_STATE_HIST_LEN 16
+struct import_state_hist {
+        enum lustre_imp_state ish_state;
+        time_t                ish_time;
+};
+
 struct obd_import {
         struct portals_handle     imp_handle;
         atomic_t                  imp_refcount;
@@ -125,8 +139,11 @@ struct obd_import {
         atomic_t                  imp_inflight;
         atomic_t                  imp_unregistering;
         atomic_t                  imp_replay_inflight;
-        atomic_t                  imp_inval_count;
+        atomic_t                  imp_inval_count;  /* in-progress invalidations */
+        atomic_t                  imp_timeouts;
         enum lustre_imp_state     imp_state;
+        struct import_state_hist  imp_state_hist[IMP_STATE_HIST_LEN];
+        int                       imp_state_hist_idx;
         int                       imp_generation;
         __u32                     imp_conn_cnt;
         int                       imp_last_generation_checked;
@@ -150,8 +167,11 @@ struct obd_import {
                                   imp_replayable:1,       /* try to recover the import */
                                   imp_dlm_fake:1,         /* don't run recovery (timeout instead) */
                                   imp_server_timeout:1,   /* use 1/2 timeout on MDS' OSCs */
-                                  imp_initial_recov:1,    /* retry the initial connection */  
+                                  imp_initial_recov:1,    /* retry the initial connection */
                                   imp_initial_recov_bk:1, /* turn off init_recov after trying all failover nids */
+                                  imp_delayed_recovery:1, /* VBR: imp in delayed recovery */
+                                  imp_no_lock_replay:1,   /* VBR: if gap was found then no lock replays */
+                                  imp_vbr_failed:1,       /* recovery by versions was failed */
                                   imp_force_verify:1,     /* force an immidiate ping */
                                   imp_pingable:1,         /* pingable */
                                   imp_resend_replay:1,    /* resend for replay */
diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h
index 2de4329..0f1aa74 100644
--- a/lustre/include/lustre_lib.h
+++ b/lustre/include/lustre_lib.h
@@ -71,6 +71,18 @@ struct obd_export;
 
 void target_client_add_cb(struct obd_device *obd, __u64 transno, void *cb_data,
                           int error);
+void target_trans_table_init(struct obd_device *obd);
+__u32 target_trans_table_last_time(struct obd_export *exp);
+void target_trans_table_recalc(struct obd_device *obd, __u32 new_age);
+void target_trans_table_update(struct obd_export *exp, __u64 transno);
+#ifdef __KERNEL__
+int target_fs_version_capable(struct obd_device *obd);
+#else
+static inline int target_fs_version_capable(struct obd_device *obd)
+{
+        return 0;
+}
+#endif
 int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler);
 int target_handle_disconnect(struct ptlrpc_request *req);
 void target_destroy_export(struct obd_export *exp);
@@ -88,10 +100,11 @@ int target_handle_dqacq_callback(struct ptlrpc_request *req);
 
 void target_cancel_recovery_timer(struct obd_device *obd);
 void target_abort_recovery(void *data);
+int target_recovery_check_and_stop(struct obd_device *obd);
 void target_cleanup_recovery(struct obd_device *obd);
 int target_queue_recovery_request(struct ptlrpc_request *req,
                                   struct obd_device *obd);
-int target_queue_last_replay_reply(struct ptlrpc_request *req, int rc);
+int target_handle_reply(struct ptlrpc_request *req, int rc, int fail);
 void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id);
 
 /* client.c */
@@ -459,6 +472,7 @@ static inline void obd_ioctl_freedata(char *buf, int len)
 
 #define OBD_IOC_LOV_GET_CONFIG         _IOWR('f', 132, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_CLIENT_RECOVER         _IOW ('f', 133, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_PING_TARGET            _IOW ('f', 136, OBD_IOC_DATA_TYPE)
 
 #define OBD_IOC_DEC_FS_USE_COUNT       _IO  ('f', 139      )
 #define OBD_IOC_NO_TRANSNO             _IOW ('f', 140, OBD_IOC_DATA_TYPE)
@@ -489,6 +503,7 @@ static inline void obd_ioctl_freedata(char *buf, int len)
 #define OBD_IOC_DUMP_LOG               _IOWR('f', 185, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_CLEAR_LOG              _IOWR('f', 186, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_PARAM                  _IOW ('f', 187, OBD_IOC_DATA_TYPE)
+#define OBD_IOC_POOL                   _IOWR('f', 188, OBD_IOC_DATA_TYPE)
 
 #define OBD_IOC_CATLOGLIST             _IOWR('f', 190, OBD_IOC_DATA_TYPE)
 #define OBD_IOC_LLOG_INFO              _IOWR('f', 191, OBD_IOC_DATA_TYPE)
diff --git a/lustre/include/lustre_lite.h b/lustre/include/lustre_lite.h
index 6543cba..5c6c6d4 100644
--- a/lustre/include/lustre_lite.h
+++ b/lustre/include/lustre_lite.h
@@ -129,7 +129,7 @@ struct lustre_client_ocd {
          * under ->lco_lock.
          */
         __u64      lco_flags;
-        spinlock_t lco_lock;
+        struct semaphore   lco_lock;
         struct obd_export *lco_mdc_exp;
         struct obd_export *lco_osc_exp;
 };
@@ -158,12 +158,12 @@ static inline int ll_ocd_update(struct obd_device *host,
                 flags = cli->cl_import->imp_connect_data.ocd_connect_flags;
                 CDEBUG(D_SUPER, "Changing connect_flags: "LPX64" -> "LPX64"\n",
                        lco->lco_flags, flags);
-                spin_lock(&lco->lco_lock);
+                mutex_down(&lco->lco_lock);
                 lco->lco_flags &= flags;
                 /* for each osc event update ea size */
                 if (lco->lco_osc_exp)
                         mdc_init_ea_size(lco->lco_mdc_exp, lco->lco_osc_exp);
-                spin_unlock(&lco->lco_lock);
+                mutex_up(&lco->lco_lock);
 
                 result = 0;
         } else {
diff --git a/lustre/include/lustre_log.h b/lustre/include/lustre_log.h
index d332827..1b1333a 100644
--- a/lustre/include/lustre_log.h
+++ b/lustre/include/lustre_log.h
@@ -251,6 +251,7 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
 int llog_put_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
                       char *name, int idx, int count, struct llog_catid *idarray);
 
+#define LLOG_CTXT_FLAG_UNINITIALIZED     0x00000001
 struct llog_ctxt {
         int                      loc_idx; /* my index the obd array of ctxt's */
         struct llog_gen          loc_gen;
@@ -265,6 +266,7 @@ struct llog_ctxt {
         atomic_t                 loc_refcount;
         struct llog_commit_master *loc_lcm;
         void                    *llog_proc_cb;
+        long                    loc_flags; /* flags, see above defines */
 };
 
 #define LCM_NAME_SIZE 64
@@ -415,14 +417,16 @@ static inline struct llog_ctxt *llog_get_context(struct obd_device *obd,
                                                    int index)
 {
          struct llog_ctxt *ctxt;
- 
-         if (index < 0 || index >= LLOG_MAX_CTXTS)
+
+         if (index < 0 || index >= LLOG_MAX_CTXTS) {
+                 CDEBUG(D_INFO, "obd %p bad index %d\n", obd, index);
                  return NULL;
-        
-         spin_lock(&obd->obd_dev_lock);  
+         }
+
+         spin_lock(&obd->obd_dev_lock);
          if (obd->obd_llog_ctxt[index] == NULL) {
                  spin_unlock(&obd->obd_dev_lock);
-                 CDEBUG(D_INFO, "obd %p and ctxt index %d is NULL \n", obd, index);
+                 CDEBUG(D_INFO,"obd %p and ctxt index %d is NULL \n",obd,index);
                  return NULL;
          }
          ctxt = llog_ctxt_get(obd->obd_llog_ctxt[index]);
diff --git a/lustre/include/lustre_mds.h b/lustre/include/lustre_mds.h
index 73e7521..87c6978 100644
--- a/lustre/include/lustre_mds.h
+++ b/lustre/include/lustre_mds.h
@@ -232,8 +232,8 @@ struct obd_client_handle;
 void mdc_set_open_replay_data(struct obd_client_handle *och,
                               struct ptlrpc_request *open_req);
 void mdc_clear_open_replay_data(struct obd_client_handle *och);
-int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *,
-              struct ptlrpc_request **);
+int mdc_close(struct obd_export *, struct mdc_op_data *, struct obdo *,
+              struct obd_client_handle *, struct ptlrpc_request **);
 int mdc_readpage(struct obd_export *exp, struct ll_fid *mdc_fid, __u64 offset,
                  struct page *, struct ptlrpc_request **);
 int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
@@ -258,10 +258,10 @@ int mdc_resource_get_unused(struct obd_export *exp, struct ll_fid *fid,
 void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
                                 int repoff);
 int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data);
-int mdc_done_writing(struct obd_export *exp, struct obdo *);
+int mdc_done_writing(struct obd_export *, struct mdc_op_data *, struct obdo *);
 
-static inline void mdc_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen,
-                                int type)
+static inline void ll_pack_fid(struct ll_fid *fid, obd_id ino, __u32 gen,
+                               int type)
 {
         fid->id = ino;
         fid->generation = gen;
@@ -308,4 +308,9 @@ struct md_enqueue_info {
         void                   *mi_cbdata;
 };
 
+/* these are local flags, used only on the client, private */
+#define M_CHECK_STALE           0200000000 
+#define M_JOIN_FILE             0400000000 /* its counterpart is
+                                            * MDS_OPEN_JOIN_FILE */
+
 #endif
diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h
index 20e58ff..de90bd1 100644
--- a/lustre/include/lustre_net.h
+++ b/lustre/include/lustre_net.h
@@ -101,9 +101,8 @@
  * considered full when less than ?_MAXREQSIZE is left in them.
  */
 
-#define LDLM_THREADS_AUTO_MIN                                                 \
-        min((int)(num_online_cpus() * num_online_cpus() * 2), 8)
-#define LDLM_THREADS_AUTO_MAX (LDLM_THREADS_AUTO_MIN * 16)
+#define LDLM_THREADS_AUTO_MIN (2)
+#define LDLM_THREADS_AUTO_MAX min(num_online_cpus()*num_online_cpus()*32, 128)
 #define LDLM_BL_THREADS  LDLM_THREADS_AUTO_MIN
 #define LDLM_NBUFS      (64 * num_online_cpus())
 #define LDLM_BUFSIZE    (8 * 1024)
@@ -134,7 +133,7 @@
  * except in the open case where there are a large number of OSTs in a LOV.
  */
 #define MDS_MAXREQSIZE  (5 * 1024)
-#define MDS_MAXREPSIZE  max(9 * 1024, 280 + LOV_MAX_STRIPE_COUNT * 56)
+#define MDS_MAXREPSIZE  max(9 * 1024, 362 + LOV_MAX_STRIPE_COUNT * 56)
 
 #define MGS_THREADS_AUTO_MIN 2
 #define MGS_THREADS_AUTO_MAX 32
@@ -301,6 +300,8 @@ struct ptlrpc_request {
         struct ptlrpc_hpreq_ops *rq_ops;        /* server-side hp handlers */
 
         __u64            rq_history_seq;        /* history sequence # */
+        /* the index of service's srv_at_array into which request is linked */
+        time_t rq_at_index;
         int rq_status;
         spinlock_t rq_lock;
         /* client-side flags are serialized by rq_lock */
@@ -321,7 +322,8 @@ struct ptlrpc_request {
                 /* server-side flags */
                 rq_packed_final:1,  /* packed final reply */
                 rq_sent_final:1,    /* stop sending early replies */
-                rq_hp:1;            /* high priority RPC */
+                rq_hp:1,            /* high priority RPC */
+                rq_at_linked:1;     /* link into service's srv_at_array */
         enum rq_phase rq_phase;     /* one of RQ_PHASE_* */
         enum rq_phase rq_next_phase; /* one of RQ_PHASE_* to be used next */
         atomic_t rq_refcount;   /* client-side refcount for SENT race,
@@ -557,6 +559,8 @@ struct ptlrpc_thread {
         unsigned int t_id; /* service thread index, from ptlrpc_start_threads */
         struct lc_watchdog *t_watchdog; /* put watchdog in the structure per
                                          * thread b=14840 */
+        struct ptlrpc_service *t_svc;   /* the svc this thread belonged to
+                                         * b=18582 */
         cfs_waitq_t t_ctl_waitq;
 };
 
@@ -603,7 +607,7 @@ struct ptlrpc_service {
         /* AT stuff */
         struct adaptive_timeout srv_at_estimate;/* estimated rpc service time */
         spinlock_t        srv_at_lock;
-        struct list_head  srv_at_list;          /* reqs waiting for replies */
+        struct ptlrpc_at_array  srv_at_array;   /* reqs waiting for replies */
         cfs_timer_t       srv_at_timer;         /* early reply timer */
 
         int               srv_n_queued_reqs;    /* # reqs in either of the queues below */
@@ -692,7 +696,7 @@ struct ptlrpcd_ctl {
         char                        pc_name[16];
 #ifndef __KERNEL__
         /**
-         * Async rpcs flag to make sure that ptlrpcd_check() is called only 
+         * Async rpcs flag to make sure that ptlrpcd_check() is called only
          * once.
          */
         int                         pc_recurred;
@@ -810,6 +814,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req);
 int ptlrpc_unregister_reply(struct ptlrpc_request *req, int async);
 void ptlrpc_restart_req(struct ptlrpc_request *req);
 void ptlrpc_abort_inflight(struct obd_import *imp);
+void ptlrpc_cleanup_imp(struct obd_import *imp);
 void ptlrpc_abort_set(struct ptlrpc_request_set *set);
 
 struct ptlrpc_request_set *ptlrpc_prep_set(void);
@@ -860,7 +865,7 @@ __u64 ptlrpc_req_xid(struct ptlrpc_request *request);
 /* ptlrpc/service.c */
 void ptlrpc_save_lock (struct ptlrpc_request *req,
                        struct lustre_handle *lock, int mode);
-void ptlrpc_commit_replies (struct obd_device *obd);
+void ptlrpc_commit_replies (struct obd_export *exp);
 void ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs);
 struct ptlrpc_service *ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size,
                                        int max_reply_size,
@@ -881,6 +886,7 @@ void ptlrpc_daemonize(char *name);
 int ptlrpc_service_health_check(struct ptlrpc_service *);
 void ptlrpc_hpreq_reorder(struct ptlrpc_request *req);
 
+
 struct ptlrpc_svc_data {
         char *name;
         struct ptlrpc_service *svc;
@@ -911,7 +917,7 @@ void lustre_shrink_reply(struct ptlrpc_request *req, int segment,
 void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
 int lustre_msg_size(__u32 magic, int count, __u32 *lengths);
 int lustre_packed_msg_size(struct lustre_msg *msg);
-int lustre_msg_early_size(void);
+int lustre_msg_early_size(struct ptlrpc_request *req);
 int lustre_unpack_msg(struct lustre_msg *m, int len);
 void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
 int lustre_msg_buflen(struct lustre_msg *m, int n);
@@ -938,6 +944,7 @@ void lustre_msg_add_version(struct lustre_msg *msg, int version);
 __u32 lustre_msg_get_opc(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_xid(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
+__u64 *lustre_msg_get_versions(struct lustre_msg *msg);
 __u64 lustre_msg_get_transno(struct lustre_msg *msg);
 __u64 lustre_msg_get_slv(struct lustre_msg *msg);
 __u32 lustre_msg_get_limit(struct lustre_msg *msg);
@@ -956,6 +963,7 @@ void lustre_msg_set_type(struct lustre_msg *msg, __u32 type);
 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc);
 void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid);
 void lustre_msg_set_last_committed(struct lustre_msg *msg,__u64 last_committed);
+void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions);
 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno);
 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status);
 void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt);
@@ -968,19 +976,19 @@ ptlrpc_rqphase_move(struct ptlrpc_request *req, enum rq_phase new_phase)
 {
         if (req->rq_phase == new_phase)
                 return;
-        
+
         if (new_phase == RQ_PHASE_UNREGISTERING) {
                 req->rq_next_phase = req->rq_phase;
                 if (req->rq_import)
                         atomic_inc(&req->rq_import->imp_unregistering);
         }
-        
+
         if (req->rq_phase == RQ_PHASE_UNREGISTERING) {
                 if (req->rq_import)
                         atomic_dec(&req->rq_import->imp_unregistering);
         }
 
-        DEBUG_REQ(D_RPCTRACE, req, "move req \"%s\" -> \"%s\"", 
+        DEBUG_REQ(D_RPCTRACE, req, "move req \"%s\" -> \"%s\"",
                   ptlrpc_rqphase2str(req), ptlrpc_phase2str(new_phase));
 
         req->rq_phase = new_phase;
@@ -1088,7 +1096,7 @@ ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, __u32 *lens)
 {
         int size = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
 
-        req->rq_replen = size + lustre_msg_early_size();
+        req->rq_replen = size + lustre_msg_early_size(req);
         if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
                 req->rq_reqmsg->lm_repsize = size;
 }
@@ -1106,8 +1114,20 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid);
 int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid);
 
 /* ptlrpc/pinger.c */
+enum timeout_event {
+        TIMEOUT_GRANT = 1
+};
+struct timeout_item;
+typedef int (*timeout_cb_t)(struct timeout_item *, void *);
 int ptlrpc_pinger_add_import(struct obd_import *imp);
 int ptlrpc_pinger_del_import(struct obd_import *imp);
+int ptlrpc_add_timeout_client(int time, enum timeout_event event,
+                              timeout_cb_t cb, void *data,
+                              struct list_head *obd_list);
+int ptlrpc_del_timeout_client(struct list_head *obd_list,
+                              enum timeout_event event);
+struct ptlrpc_request * ptlrpc_prep_ping(struct obd_import *imp);
+int ptlrpc_obd_ping(struct obd_device *obd);
 #ifdef __KERNEL__
 void ping_evictor_start(void);
 void ping_evictor_stop(void);
@@ -1121,6 +1141,7 @@ int ptlrpcd_start(char *name, struct ptlrpcd_ctl *pc);
 void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force);
 void ptlrpcd_wake(struct ptlrpc_request *req);
 void ptlrpcd_add_req(struct ptlrpc_request *req);
+void ptlrpcd_add_rqset(struct ptlrpc_request_set *set);
 int ptlrpcd_addref(void);
 void ptlrpcd_decref(void);
 
diff --git a/lustre/include/lustre_param.h b/lustre/include/lustre_param.h
index 52b1d29..56552ec 100644
--- a/lustre/include/lustre_param.h
+++ b/lustre/include/lustre_param.h
@@ -54,17 +54,23 @@ int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
 
 
 /****************** User-settable parameter keys *********************/
-/* e.g. 
+/* e.g.
         tunefs.lustre --param="failover.node=192.168.0.13 at tcp0" /dev/sda
         lctl conf_param testfs-OST0000 failover.node=3 at elan,192.168.0.3 at tcp0
                     ... testfs-MDT0000.lov.stripesize=4M
                     ... testfs-OST0000.ost.client_cache_seconds=15
-                    ... testfs.sys.timeout=<secs> 
+                    ... testfs.sys.timeout=<secs>
                     ... testfs.llite.max_read_ahead_mb=16
 */
 
 /* System global or special params not handled in obd's proc */
-#define PARAM_SYS_TIMEOUT          "sys.timeout="      /* global */
+#define PARAM_TIMEOUT              "timeout="          /* global */
+#define PARAM_LDLM_TIMEOUT         "ldlm_timeout="     /* global */
+#define PARAM_AT_MIN               "at_min="           /* global */
+#define PARAM_AT_MAX               "at_max="           /* global */
+#define PARAM_AT_EXTRA             "at_extra="         /* global */
+#define PARAM_AT_EARLY_MARGIN      "at_early_margin="  /* global */
+#define PARAM_AT_HISTORY           "at_history="       /* global */
 #define PARAM_MGSNODE              "mgsnode="          /* during mount */
 #define PARAM_FAILNODE             "failover.node="    /* llog generation */
 #define PARAM_FAILMODE             "failover.mode="    /* llog generation */
@@ -78,5 +84,6 @@ int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
 #define PARAM_MDC                  "mdc."
 #define PARAM_LLITE                "llite."
 #define PARAM_LOV                  "lov."
+#define PARAM_SYS                  "sys."              /* global */
 
 #endif /* _LUSTRE_PARAM_H */
diff --git a/lustre/include/lustre_quota.h b/lustre/include/lustre_quota.h
index 75010a3..cfec87c 100644
--- a/lustre/include/lustre_quota.h
+++ b/lustre/include/lustre_quota.h
@@ -47,8 +47,8 @@
 #error Unsupported operating system.
 #endif
 
-#include <lustre/lustre_idl.h>
 #include <lustre_net.h>
+#include <lustre/lustre_idl.h>
 #include <lvfs.h>
 #include <obd_support.h>
 #include <class_hash.h>
@@ -60,8 +60,28 @@ struct client_obd;
 #define NR_DQHASH 45
 #endif
 
+#ifndef QUOTABLOCK_BITS
+#define QUOTABLOCK_BITS 10
+#endif
+
+#ifndef QUOTABLOCK_SIZE
+#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
+#endif
+
+#ifndef toqb
+#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
+#endif
+
 #ifdef HAVE_QUOTA_SUPPORT
 
+#ifndef MAX_IQ_TIME
+#define MAX_IQ_TIME  604800     /* (7*24*60*60) 1 week */
+#endif
+
+#ifndef MAX_DQ_TIME
+#define MAX_DQ_TIME  604800     /* (7*24*60*60) 1 week */
+#endif
+
 #ifdef __KERNEL__
 
 #ifdef LPROCFS
@@ -150,7 +170,12 @@ struct lustre_dquot {
 struct dquot_id {
         struct list_head        di_link;
         __u32                   di_id;
+        __u32                   di_flag;
 };
+/* set inode quota limitation on a quota uid/gid */
+#define QI_SET                (1 << 30)
+/* set block quota limitation on a quota uid/gid */
+#define QB_SET                (1 << 31)
 
 #define QFILE_CHK               1
 #define QFILE_RD_INFO           2
@@ -171,7 +196,11 @@ int lustre_get_qids(struct file *file, struct inode *inode, int type,
                     struct list_head *list);
 int lustre_quota_convert(struct lustre_quota_info *lqi, int type);
 
-#define LL_DQUOT_OFF(sb)    DQUOT_OFF(sb)
+#ifdef HAVE_VFS_DQ_OFF
+#define LL_DQUOT_OFF(sb, remount)    vfs_dq_off(sb, remount)
+#else
+#define LL_DQUOT_OFF(sb, remount)    DQUOT_OFF(sb)
+#endif
 
 typedef int (*dqacq_handler_t) (struct obd_device * obd, struct qunit_data * qd,
                                 int opc);
@@ -226,13 +255,16 @@ struct lustre_quota_ctxt {
         int           lqc_sync_blk;         /* when blk qunit reaches this value,
                                              * later write reqs from client
                                              * should be sync b=16642 */
-        spinlock_t    lqc_lock;         /* guard lqc_imp_valid now */
+        spinlock_t    lqc_lock;             /* guard lqc_imp_valid now */
         cfs_waitq_t   lqc_wait_for_qmaster; /* when mds isn't connected, threads
                                              * on osts who send the quota reqs
                                              * with wait==1 will be put here
                                              * b=14840 */
         struct proc_dir_entry *lqc_proc_dir;
         struct lprocfs_stats  *lqc_stats; /* lquota statistics */
+
+        atomic_t      lqc_lqs;              /* the number of used hashed lqs */
+        cfs_waitq_t   lqc_lqs_waitq;        /* no lqs are in use */
 };
 
 #define QUOTA_MASTER_READY(qctxt)   (qctxt)->lqc_setup = 1
@@ -241,7 +273,8 @@ struct lustre_quota_ctxt {
 struct lustre_qunit_size {
         struct hlist_node lqs_hash; /* the hash entry */
         unsigned int lqs_id;        /* id of user/group */
-        unsigned long lqs_flags;    /* is user/group; FULLBUF or LESSBUF */
+        unsigned long lqs_flags;    /* 31st bit is QB_SET, 30th bit is QI_SET
+                                     * other bits are same as LQUOTA_FLAGS_* */
         unsigned long lqs_iunit_sz; /* Unit size of file quota currently */
         unsigned long lqs_itune_sz; /* Trigger dqacq when available file quota
                                      * less than this value, trigger dqrel
@@ -260,7 +293,7 @@ struct lustre_qunit_size {
         cfs_time_t lqs_last_bshrink;   /* time of last block shrink */
         cfs_time_t lqs_last_ishrink;   /* time of last inode shrink */
         spinlock_t lqs_lock;
-        struct quota_adjust_qunit lqs_key; /* hash key */
+        unsigned long long lqs_key; /* hash key */
         struct lustre_quota_ctxt *lqs_ctxt; /* quota ctxt */
 };
 
@@ -272,9 +305,18 @@ struct lustre_qunit_size {
 #define LQS_SET_ADJBLK(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJBLK)
 #define LQS_SET_ADJINO(lqs) ((lqs)->lqs_flags |= LQUOTA_FLAGS_ADJINO)
 
+/* In the hash for lustre_qunit_size, the key is decided by
+ * grp_or_usr and uid/gid, in here, I combine these two values,
+ * which will make comparing easier and more efficient */
+#define LQS_KEY(is_grp, id)  ((is_grp ? 1ULL << 32: 0) + id)
+#define LQS_KEY_ID(key)      (key & 0xffffffff)
+#define LQS_KEY_GRP(key)     (key >> 32)
+
 static inline void lqs_getref(struct lustre_qunit_size *lqs)
 {
-        atomic_inc(&lqs->lqs_refcount);
+        if (atomic_inc_return(&lqs->lqs_refcount) == 2) /* quota_create_lqs */
+                atomic_inc(&lqs->lqs_ctxt->lqc_lqs);
+
         CDEBUG(D_QUOTA, "lqs=%p refcount %d\n",
                lqs, atomic_read(&lqs->lqs_refcount));
 }
@@ -289,7 +331,9 @@ static inline void lqs_putref(struct lustre_qunit_size *lqs)
                                 &lqs->lqs_key, &lqs->lqs_hash);
                 OBD_FREE_PTR(lqs);
         } else {
-                atomic_dec(&lqs->lqs_refcount);
+                if (atomic_dec_return(&lqs->lqs_refcount) == 1)
+                        if (atomic_dec_and_test(&lqs->lqs_ctxt->lqc_lqs))
+                                cfs_waitq_signal(&lqs->lqs_ctxt->lqc_lqs_waitq);
                 CDEBUG(D_QUOTA, "lqs=%p refcount %d\n",
                        lqs, atomic_read(&lqs->lqs_refcount));
 
@@ -313,7 +357,7 @@ struct lustre_quota_ctxt {
 
 #else
 
-#define LL_DQUOT_OFF(sb) do {} while(0)
+#define LL_DQUOT_OFF(sb, remount) do {} while(0)
 
 struct lustre_quota_info {
 };
diff --git a/lustre/include/lustre_ver.h b/lustre/include/lustre_ver.h
index 2bb30de..78804ff 100644
--- a/lustre/include/lustre_ver.h
+++ b/lustre/include/lustre_ver.h
@@ -5,14 +5,14 @@
  * Changes made directly to this file will be lost. */
 
 #define LUSTRE_MAJOR 1
-#define LUSTRE_MINOR 6
-#define LUSTRE_PATCH 7
-#define LUSTRE_FIX 2
-#define LUSTRE_VERSION_STRING "1.6.7.2"
-#define CLIENT_URN "LUSTRE-167-CLT"
-#define MDS_URN "LUSTRE-167-MDS"
-#define MGS_URN "LUSTRE-167-MGS"
-#define OSS_URN "LUSTRE-167-OSS"
+#define LUSTRE_MINOR 8
+#define LUSTRE_PATCH 1
+#define LUSTRE_FIX 0
+#define LUSTRE_VERSION_STRING "1.8.1"
+#define CLIENT_URN "LUSTRE-181-CLT"
+#define MDS_URN "LUSTRE-181-MDS"
+#define MGS_URN "LUSTRE-181-MGS"
+#define OSS_URN "LUSTRE-181-OSS"
 
 #define LUSTRE_VERSION_CODE OBD_OCD_VERSION(LUSTRE_MAJOR,LUSTRE_MINOR,LUSTRE_PATCH,LUSTRE_FIX)
 
diff --git a/lustre/include/obd.h b/lustre/include/obd.h
index 9252272..0762e06 100644
--- a/lustre/include/obd.h
+++ b/lustre/include/obd.h
@@ -148,6 +148,7 @@ struct lov_stripe_md {
                 __u32 lw_stripe_size;      /* size of the stripe */
                 __u32 lw_pattern;          /* striping pattern (RAID0, RAID1) */
                 unsigned lw_stripe_count;  /* number of objects being striped over */
+                char  lw_pool_name[LOV_MAXPOOLNAME]; /* pool name */
         } lsm_wire;
 
         struct lov_array_info *lsm_array; /*Only for joined file array info*/
@@ -161,6 +162,7 @@ struct lov_stripe_md {
 #define lsm_stripe_size  lsm_wire.lw_stripe_size
 #define lsm_pattern      lsm_wire.lw_pattern
 #define lsm_stripe_count lsm_wire.lw_stripe_count
+#define lsm_pool_name    lsm_wire.lw_pool_name
 
 struct obd_info;
 
@@ -190,7 +192,7 @@ struct obd_info {
          * level. E.g. it is used for update lsm->lsm_oinfo at every recieved
          * request in osc level for enqueue requests. It is also possible to
          * update some caller data from LOV layer if needed. */
-        obd_enqueue_update_f     oi_cb_up;
+        obd_enqueue_update_f    oi_cb_up;
 };
 
 /* compare all relevant fields. */
@@ -276,9 +278,27 @@ struct ost_server_data;
 /* hold common fields for "target" device */
 struct obd_device_target {
         struct super_block       *obt_sb;
+        /** last_rcvd file */
+        struct file              *obt_rcvd_filp;
+        /** server data in last_rcvd file */
+        struct lr_server_data    *obt_lsd;
+        /** Lock protecting client bitmap */
+        spinlock_t                obt_client_bitmap_lock;
+        /** Bitmap of known clients */
+        unsigned long            *obt_client_bitmap;
+        /** Server last transaction number */
+        __u64                     obt_last_transno;
+        /** Lock protecting last transaction number */
+        spinlock_t                obt_translock;
+        /** Number of mounts */
+        __u64                     obt_mount_count;
         atomic_t                  obt_quotachecking;
         struct lustre_quota_ctxt  obt_qctxt;
         lustre_quota_version_t    obt_qfmt;
+        __u32                     obt_stale_export_age;
+        spinlock_t                obt_trans_table_lock;
+        struct vfsmount          *obt_vfsmnt;
+        struct file              *obt_health_check_filp;
 };
 
 typedef void (*obd_pin_extent_cb)(void *data);
@@ -298,17 +318,10 @@ struct filter_obd {
         /* NB this field MUST be first */
         struct obd_device_target fo_obt;
         const char          *fo_fstype;
-        struct vfsmount     *fo_vfsmnt;
         cfs_dentry_t        *fo_dentry_O;
         cfs_dentry_t       **fo_dentry_O_groups;
         cfs_dentry_t       **fo_dentry_O_sub;
         spinlock_t           fo_objidlock;      /* protect fo_lastobjid */
-        spinlock_t           fo_translock;      /* protect fsd_last_transno */
-        struct file         *fo_rcvd_filp;
-        struct file         *fo_health_check_filp;
-        struct lr_server_data *fo_fsd;
-        unsigned long       *fo_last_rcvd_slots;
-        __u64                fo_mount_count;
 
         int                  fo_destroy_in_progress;
         struct semaphore     fo_create_lock;
@@ -319,8 +332,11 @@ struct filter_obd {
         obd_size             fo_tot_dirty;      /* protected by obd_osfs_lock */
         obd_size             fo_tot_granted;    /* all values in bytes */
         obd_size             fo_tot_pending;
+        int                  fo_tot_granted_clients;
 
         obd_size             fo_readcache_max_filesize;
+        int                  fo_read_cache;
+        int                  fo_writethrough_cache;
 
         struct obd_import   *fo_mdc_imp;
         struct obd_uuid      fo_mdc_uuid;
@@ -356,9 +372,17 @@ struct filter_obd {
 
         int                      fo_fmd_max_num; /* per exp filter_mod_data */
         int                      fo_fmd_max_age; /* jiffies to fmd expiry */
+        int                      fo_syncjournal; /* sync journal on writes */
         struct llog_commit_master *fo_lcm;
 };
 
+#define fo_translock            fo_obt.obt_translock
+#define fo_rcvd_filp            fo_obt.obt_rcvd_filp
+#define fo_fsd                  fo_obt.obt_lsd
+#define fo_last_rcvd_slots      fo_obt.obt_client_bitmap
+#define fo_mount_count          fo_obt.obt_mount_count
+#define fo_vfsmnt               fo_obt.obt_vfsmnt
+
 #define OSC_MAX_RIF_DEFAULT       8
 #define OSC_MAX_RIF_MAX         256
 #define OSC_MAX_DIRTY_DEFAULT  (OSC_MAX_RIF_DEFAULT * 4)
@@ -368,9 +392,20 @@ struct filter_obd {
 #define MDC_MAX_RIF_DEFAULT       8
 #define MDC_MAX_RIF_MAX         512
 
+
 struct mdc_rpc_lock;
 struct obd_import;
 struct lustre_cache;
+
+struct timeout_item {
+        enum timeout_event ti_event;
+        cfs_time_t         ti_timeout;
+        timeout_cb_t       ti_cb;
+        void              *ti_cb_data;
+        struct list_head   ti_obd_list;
+        struct list_head   ti_chain;
+};
+
 struct client_obd {
         struct rw_semaphore      cl_sem;
         struct obd_uuid          cl_target_uuid;
@@ -391,6 +426,10 @@ struct client_obd {
         long                     cl_avail_grant;   /* bytes of credit for ost */
         long                     cl_lost_grant;    /* lost credits (trunc) */
         struct list_head         cl_cache_waiters; /* waiting for cache/grant */
+        cfs_time_t               cl_next_shrink_grant;   /* jiffies */
+        struct list_head         cl_grant_shrink_list;  /* Timeout event list */
+        struct semaphore         cl_grant_sem;   /*grant shrink list semaphore*/
+        int                      cl_grant_shrink_interval; /* seconds */
 
         /* keep track of objects that have lois that contain pages which
          * have been queued for async brw.  this lock also protects the
@@ -457,6 +496,10 @@ struct client_obd {
 
         /* used by quotacheck */
         int                      cl_qchk_stat; /* quotacheck stat of the peer */
+
+        /* sequence manager */
+        struct lu_client_seq    *cl_seq;
+
         atomic_t                 cl_resends; /* resend count */
         /* Cache of triples */
         struct lustre_cache     *cl_cache;
@@ -483,19 +526,13 @@ struct mds_obd {
         struct ptlrpc_service           *mds_service;
         struct ptlrpc_service           *mds_setattr_service;
         struct ptlrpc_service           *mds_readpage_service;
-        struct vfsmount                 *mds_vfsmnt;
         cfs_dentry_t                    *mds_fid_de;
         int                              mds_max_mdsize;
         int                              mds_max_cookiesize;
-        struct file                     *mds_rcvd_filp;
-        spinlock_t                       mds_transno_lock;
-        __u64                            mds_last_transno;
-        __u64                            mds_mount_count;
         __u64                            mds_io_epoch;
         unsigned long                    mds_atime_diff;
         struct semaphore                 mds_epoch_sem;
         struct ll_fid                    mds_rootfid;
-        struct lr_server_data           *mds_server_data;
         cfs_dentry_t                    *mds_pending_dir;
         cfs_dentry_t                    *mds_logs_dir;
         cfs_dentry_t                    *mds_objects_dir;
@@ -506,7 +543,7 @@ struct mds_obd {
         char                            *mds_profile;
         struct obd_export               *mds_osc_exp; /* XXX lov_exp */
         struct lov_desc                  mds_lov_desc;
-	
+
         /* mark pages dirty for write. */
         bitmap_t                         *mds_lov_page_dirty;
         /* array for store pages with obd_id */
@@ -518,8 +555,6 @@ struct mds_obd {
         __u32                            mds_lov_objid_lastpage;
         __u32                            mds_lov_objid_lastidx;
 
-        struct file                     *mds_health_check_filp;
-        unsigned long                   *mds_client_bitmap;
         struct upcall_cache             *mds_group_hash;
 
         struct lustre_quota_info         mds_quota_info;
@@ -536,8 +571,18 @@ struct mds_obd {
         uid_t                            mds_squash_uid;
         gid_t                            mds_squash_gid;
         lnet_nid_t                       mds_nosquash_nid;
+        /* do we need permission sync */
+        unsigned int                     mds_sync_permission;
 };
 
+#define mds_transno_lock         mds_obt.obt_translock
+#define mds_rcvd_filp            mds_obt.obt_rcvd_filp
+#define mds_server_data          mds_obt.obt_lsd
+#define mds_client_bitmap        mds_obt.obt_client_bitmap
+#define mds_mount_count          mds_obt.obt_mount_count
+#define mds_last_transno         mds_obt.obt_last_transno
+#define mds_vfsmnt               mds_obt.obt_vfsmnt
+
 /* lov objid */
 #define mds_max_ost_index  (0xFFFF)
 #define MDS_LOV_ALLOC_SIZE (CFS_PAGE_SIZE)
@@ -569,6 +614,7 @@ struct ost_obd {
         struct ptlrpc_service *ost_create_service;
         struct ptlrpc_service *ost_io_service;
         struct semaphore       ost_health_sem;
+        int                    ost_sync_on_lock_cancel;
 };
 
 struct echo_client_obd {
@@ -598,21 +644,49 @@ struct ltd_qos {
         unsigned int        ltq_usable:1;    /* usable for striping */
 };
 
+/* Generic subset of OSTs */
+struct ost_pool {
+        __u32              *op_array;        /* array of index of
+                                                lov_obd->lov_tgts */
+        unsigned int        op_count;        /* number of OSTs in the array */
+        unsigned int        op_size;         /* allocated size of lp_array */
+        struct rw_semaphore op_rw_sem;       /* to protect ost_pool use */
+};
+
+/* Round-robin allocator data */
+struct lov_qos_rr {
+        __u32               lqr_start_idx;   /* start index of new inode */
+        __u32               lqr_offset_idx;  /* aliasing for start_idx  */
+        int                 lqr_start_count; /* reseed counter */
+        struct ost_pool     lqr_pool;        /* round-robin optimized list */
+        unsigned long       lqr_dirty:1;     /* recalc round-robin list */
+};
+
+struct lov_statfs_data {
+        struct obd_info   lsd_oi;
+        struct obd_statfs lsd_statfs;
+};
+/* Stripe placement optimization */
 struct lov_qos {
         struct list_head    lq_oss_list;    /* list of OSSs that targets use */
         struct rw_semaphore lq_rw_sem;
         __u32               lq_active_oss_count;
-        __u32              *lq_rr_array;    /* round-robin optimized list */
-        unsigned int        lq_rr_size;     /* rr array size */
         unsigned int        lq_prio_free;   /* priority for free space */
+        unsigned int        lq_threshold_rr;/* priority for rr */
+        struct lov_qos_rr   lq_rr;          /* round robin qos data */
         unsigned long       lq_dirty:1,     /* recalc qos data */
-                            lq_dirty_rr:1,  /* recalc round-robin list */
                             lq_same_space:1,/* the ost's all have approx.
                                                the same space avail */
-                            lq_reset:1;     /* zero current penalties */
+                            lq_reset:1,     /* zero current penalties */
+                            lq_statfs_in_progress:1; /* statfs op in progress */
+        /* qos statfs data */
+        struct lov_statfs_data *lq_statfs_data;
+        cfs_waitq_t         lq_statfs_waitq; /* waitqueue to notify statfs
+                                              * requests completion */
 };
 
 struct lov_tgt_desc {
+        struct list_head    ltd_kill;
         struct obd_uuid     ltd_uuid;
         struct obd_export  *ltd_exp;
         struct ltd_qos      ltd_qos;     /* qos info per target */
@@ -623,9 +697,30 @@ struct lov_tgt_desc {
                             ltd_reap:1;  /* should this target be deleted */
 };
 
+/* Pool metadata */
+#define pool_tgt_size(_p)   _p->pool_obds.op_size
+#define pool_tgt_count(_p)  _p->pool_obds.op_count
+#define pool_tgt_array(_p)  _p->pool_obds.op_array
+#define pool_tgt_rw_sem(_p) _p->pool_obds.op_rw_sem
+#define pool_tgt(_p, _i)    _p->pool_lov->lov_tgts[_p->pool_obds.op_array[_i]]
+
+struct pool_desc {
+        char                  pool_name[LOV_MAXPOOLNAME + 1]; /* name of pool */
+        struct ost_pool       pool_obds;              /* pool members */
+        atomic_t              pool_refcount;          /* pool ref. counter */
+        struct lov_qos_rr     pool_rr;                /* round robin qos */
+        struct hlist_node     pool_hash;              /* access by poolname */
+        struct list_head      pool_list;              /* serial access */
+        cfs_proc_dir_entry_t *pool_proc_entry;        /* file in /proc */
+        struct lov_obd       *pool_lov;               /* lov obd to which this
+                                                         pool belong */
+};
+
 struct lov_obd {
         struct lov_desc         desc;
-        struct lov_tgt_desc   **lov_tgts;
+        struct lov_tgt_desc   **lov_tgts;              /* sparse array */
+        struct ost_pool         lov_packed;            /* all OSTs in a packed
+                                                          array */
         struct semaphore        lov_lock;
         struct obd_connect_data lov_ocd;
         struct lov_qos          lov_qos;               /* qos info per lov */
@@ -634,13 +729,14 @@ struct lov_obd {
         __u32                   lov_active_tgt_count;  /* how many active */
         __u32                   lov_death_row;/* tgts scheduled to be deleted */
         __u32                   lov_tgt_size;   /* size of tgts array */
-        __u32                   lov_start_idx;  /* start index of new inode */
-        __u32                   lov_offset_idx; /* aliasing for start_idx  */
-        int                     lov_start_count;/* reseed counter */
         int                     lov_connects;
         obd_page_removal_cb_t   lov_page_removal_cb;
         obd_pin_extent_cb       lov_page_pin_cb;
         obd_lock_cancel_cb      lov_lock_cancel_cb;
+        int                     lov_pool_count;
+        lustre_hash_t          *lov_pools_hash_body; /* used for key access */
+        struct list_head        lov_pool_list; /* used for sequential access */
+        cfs_proc_dir_entry_t   *lov_pool_proc_entry;
 };
 
 struct niobuf_local {
@@ -694,6 +790,8 @@ struct obd_trans_info {
         /* initial thread handling transaction */
         struct ptlrpc_thread *   oti_thread;
         __u32                    oti_conn_cnt;
+        /* VBR: versions */
+        __u64                    oti_pre_version;
 
         struct obd_uuid         *oti_ost_uuid;
 };
@@ -709,7 +807,16 @@ static inline void oti_init(struct obd_trans_info *oti,
                 return;
 
         oti->oti_xid = req->rq_xid;
+        /* VBR: take versions from request */
+        if (req->rq_reqmsg != NULL &&
+            lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
+                __u64 *pre_version = lustre_msg_get_versions(req->rq_reqmsg);
+                /* b1.6 interoperability check. pre_versions may be NULL */
+                oti->oti_pre_version = pre_version ? pre_version[0] : 0;
+                oti->oti_transno = lustre_msg_get_transno(req->rq_reqmsg);
+        }
 
+        /* called from mds_create_objects */
         if (req->rq_repmsg != NULL)
                 oti->oti_transno = lustre_msg_get_transno(req->rq_repmsg);
         oti->oti_thread = req->rq_svc_thread;
@@ -801,6 +908,7 @@ struct obd_notify_upcall {
 /* corresponds to one of the obd's */
 #define MAX_OBD_NAME 128
 #define OBD_DEVICE_MAGIC        0XAB5CD6EF
+#define OBD_DEV_BY_DEVNAME      0xffffd0de
 struct obd_device {
         struct obd_type        *obd_type;
         __u32                   obd_magic;
@@ -813,7 +921,8 @@ struct obd_device {
         unsigned long obd_attached:1,      /* finished attach */
                       obd_set_up:1,        /* finished setup */
                       obd_recovering:1,    /* there are recoverable clients */
-                      obd_abort_recovery:1,/* somebody ioctl'ed us to abort */
+                      obd_abort_recovery:1,/* recovery expired */
+                      obd_version_recov:1, /* obd uses version checking */
                       obd_replayable:1,    /* recovery is enabled; inform clients */
                       obd_no_transno:1,    /* no committed-transno notification */
                       obd_no_recov:1,      /* fail instead of retry messages */
@@ -824,7 +933,7 @@ struct obd_device {
                       obd_async_recov:1,   /* allow asyncronous orphan cleanup */
                       obd_no_conn:1,       /* deny new connections */
                       obd_inactive:1;      /* device active/inactive
-                                           * (for /proc/status only!!) */
+                                            * (for /proc/status only!!) */
         /* uuid-export hash body */
         struct lustre_hash     *obd_uuid_hash;
         /* nid-export hash body */
@@ -835,6 +944,7 @@ struct obd_device {
         atomic_t                obd_refcount;
         cfs_waitq_t             obd_refcount_waitq;
         struct list_head        obd_exports;
+        struct list_head        obd_delayed_exports;
         int                     obd_num_exports;
         spinlock_t              obd_nid_lock;
         struct ldlm_namespace  *obd_namespace;
@@ -849,7 +959,7 @@ struct obd_device {
         __u64                   obd_osfs_age;
         struct lvfs_run_ctxt    obd_lvfs_ctxt;
 
-        struct llog_ctxt       *obd_llog_ctxt[LLOG_MAX_CTXTS];
+        struct llog_ctxt        *obd_llog_ctxt[LLOG_MAX_CTXTS];
         struct semaphore        obd_llog_alloc;
         struct semaphore        obd_llog_cat_process;
         cfs_waitq_t             obd_llog_waitq;
@@ -866,14 +976,16 @@ struct obd_device {
         int                              obd_max_recoverable_clients;
         int                              obd_connected_clients;
         int                              obd_recoverable_clients;
+        int                              obd_stale_clients;
+        int                              obd_delayed_clients;
         spinlock_t                       obd_processing_task_lock; /* BH lock (timer) */
         pid_t                            obd_processing_task;
+        /* thread to handle recovery queue */
+        struct ptlrpc_thread            *obd_recovery_thread;
         __u64                            obd_next_recovery_transno;
         int                              obd_replayed_requests;
         int                              obd_requests_queued_for_recovery;
         cfs_waitq_t                      obd_next_transno_waitq;
-        struct list_head                 obd_uncommitted_replies;
-        spinlock_t                       obd_uncommitted_replies_lock;
         cfs_timer_t                      obd_recovery_timer;
         struct list_head                 obd_recovery_queue;
         struct list_head                 obd_delayed_reply_queue;
@@ -947,9 +1059,12 @@ enum obd_cleanup_stage {
 #define KEY_BLOCKSIZE           "blocksize"
 #define KEY_BLOCKSIZE_BITS      "blocksize_bits"
 #define KEY_MAX_EASIZE          "max_ea_size"
-#define KEY_FIEMAP              "FIEMAP"
+#define KEY_FIEMAP              "fiemap"
 /* XXX unused */
 #define KEY_ASYNC               "async"
+#define KEY_CAPA_KEY            "capa_key"
+#define KEY_GRANT_SHRINK        "grant_shrink"
+#define KEY_OFF_RPCSIZE         "off_rpcsize"
 
 struct obd_ops {
         struct module *o_owner;
@@ -985,6 +1100,10 @@ struct obd_ops {
                            void *localdata);
         int (*o_disconnect)(struct obd_export *exp);
 
+        /* Initialize/finalize fids infrastructure. */
+        int (*o_fid_init)(struct obd_export *exp);
+        int (*o_fid_fini)(struct obd_export *exp);
+
         int (*o_statfs)(struct obd_device *obd, struct obd_statfs *osfs,
                         __u64 max_age, __u32 flags);
         int (*o_statfs_async)(struct obd_device *obd, struct obd_info *oinfo,
@@ -1057,13 +1176,16 @@ struct obd_ops {
                                      struct lov_oinfo *loi, void *cookie);
         int (*o_merge_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
                            struct ost_lvb *lvb, int kms_only);
+        int (*o_update_lvb)(struct obd_export *exp, struct lov_stripe_md *lsm,
+                            struct ost_lvb *lvb, obd_flag valid);
         int (*o_adjust_kms)(struct obd_export *exp, struct lov_stripe_md *lsm,
                             obd_off size, int shrink);
         int (*o_punch)(struct obd_export *exp, struct obd_info *oinfo,
                        struct obd_trans_info *oti,
                        struct ptlrpc_request_set *rqset);
-        int (*o_sync)(struct obd_export *exp, struct obdo *oa,
-                      struct lov_stripe_md *ea, obd_size start, obd_size end);
+        int (*o_sync)(struct obd_export *exp, struct obd_info *oinfo,
+                      obd_size start, obd_size end,
+                      struct ptlrpc_request_set *rqset);
         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
                          struct lov_stripe_md *src, obd_size start,
                          obd_size end, struct obd_trans_info *oti);
@@ -1075,18 +1197,20 @@ struct obd_ops {
                          obd_id *startid, obd_gr group, void *data);
         int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
                         int objcount, struct obd_ioobj *obj,
-                        int niocount, struct niobuf_remote *remote,
-                        struct niobuf_local *local, struct obd_trans_info *oti);
+                        struct niobuf_remote *remote, int *nr_pages,
+                        struct niobuf_local *local,
+                        struct obd_trans_info *oti);
         int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
                           int objcount, struct obd_ioobj *obj,
-                          int niocount, struct niobuf_local *local,
+                          struct niobuf_remote *remote, int pages,
+                          struct niobuf_local *local,
                           struct obd_trans_info *oti, int rc);
         int (*o_enqueue)(struct obd_export *, struct obd_info *oinfo,
                          struct ldlm_enqueue_info *einfo,
                          struct ptlrpc_request_set *rqset);
         int (*o_match)(struct obd_export *, struct lov_stripe_md *, __u32 type,
                        ldlm_policy_data_t *, __u32 mode, int *flags, void *data,
-                       struct lustre_handle *lockh);
+                       struct lustre_handle *lockh, int *n_matches);
         int (*o_change_cbdata)(struct obd_export *, struct lov_stripe_md *,
                                ldlm_iterator_t it, void *data);
         int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
@@ -1107,7 +1231,7 @@ struct obd_ops {
         int (*o_llog_finish)(struct obd_device *obd, int count);
 
         /* metadata-only methods */
-        int (*o_pin)(struct obd_export *, obd_id ino, __u32 gen, int type,
+        int (*o_pin)(struct obd_export *, struct ll_fid *,
                      struct obd_client_handle *, int flag);
         int (*o_unpin)(struct obd_export *, struct obd_client_handle *, int);
 
@@ -1138,6 +1262,15 @@ struct obd_ops {
                                        obd_lock_cancel_cb cb);
         int (*o_unregister_lock_cancel_cb)(struct obd_device *obd,
                                          obd_lock_cancel_cb cb);
+        /* pools methods */
+        int (*o_pool_new)(struct obd_device *obd, char *poolname);
+        int (*o_pool_del)(struct obd_device *obd, char *poolname);
+        int (*o_pool_add)(struct obd_device *obd, char *poolname,
+                          char *ostname);
+        int (*o_pool_rem)(struct obd_device *obd, char *poolname,
+                          char *ostname);
+        void (*o_getref)(struct obd_device *obd);
+        void (*o_putref)(struct obd_device *obd);
 
         /*
          * NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line
@@ -1163,15 +1296,18 @@ struct lsm_operations {
                              struct lov_mds_md *lmm);
 };
 
-extern struct lsm_operations lsm_plain_ops;
+extern struct lsm_operations lsm_v1_ops;
 extern struct lsm_operations lsm_join_ops;
+extern struct lsm_operations lsm_v3_ops;
 static inline struct lsm_operations *lsm_op_find(int magic)
 {
         switch(magic) {
-        case LOV_MAGIC:
-               return &lsm_plain_ops;
+        case LOV_MAGIC_V1:
+               return &lsm_v1_ops;
         case LOV_MAGIC_JOIN:
                return &lsm_join_ops;
+        case LOV_MAGIC_V3:
+               return &lsm_v3_ops;
         default:
                CERROR("Cannot recognize lsm_magic %x\n", magic);
                return NULL;
@@ -1181,23 +1317,34 @@ static inline struct lsm_operations *lsm_op_find(int magic)
 int lvfs_check_io_health(struct obd_device *obd, struct file *file);
 
 /* Requests for obd_extent_calc() */
-#define OBD_CALC_STRIPE_START   1
-#define OBD_CALC_STRIPE_END     2
+#define OBD_CALC_STRIPE_START          0x0001
+#define OBD_CALC_STRIPE_END            0x0010
+#define OBD_CALC_STRIPE_RPC_ALIGN      0x0100
+
+#define OBD_CALC_STRIPE_RPC_START_ALIGN (OBD_CALC_STRIPE_START | \
+                                         OBD_CALC_STRIPE_RPC_ALIGN)
+#define OBD_CALC_STRIPE_RPC_END_ALIGN (OBD_CALC_STRIPE_START | \
+                                       OBD_CALC_STRIPE_RPC_ALIGN)
 
 static inline void obd_transno_commit_cb(struct obd_device *obd, __u64 transno,
-                                         int error)
+                                         struct obd_export *exp, int error)
 {
         if (error) {
                 CERROR("%s: transno "LPU64" commit error: %d\n",
                        obd->obd_name, transno, error);
                 return;
         }
-        CDEBUG(D_HA, "%s: transno "LPU64" committed\n",
-               obd->obd_name, transno);
-        if (transno > obd->obd_last_committed) {
-                obd->obd_last_committed = transno;
-                ptlrpc_commit_replies (obd);
+        if (exp && transno > exp->exp_last_committed) {
+                CDEBUG(D_INFO, "%s: transno "LPU64" committed\n",
+                       obd->obd_name, transno);
+                exp->exp_last_committed = transno;
+                ptlrpc_commit_replies(exp);
+        } else {
+                CDEBUG(D_INFO, "%s: transno "LPU64" committed\n",
+                       obd->obd_name, transno);
         }
+        if (transno > obd->obd_last_committed)
+                obd->obd_last_committed = transno;
 }
 
 static inline void init_obd_quota_ops(quota_interface_t *interface,
diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h
index 03bad87..8088f0d 100644
--- a/lustre/include/obd_class.h
+++ b/lustre/include/obd_class.h
@@ -192,6 +192,7 @@ void class_del_profiles(void);
         exp_;                                                                  \
 })
 
+/* class_export_put() is non-blocking */
 #define class_export_put(exp)                                                  \
 do {                                                                           \
         LASSERT((exp) != NULL);                                                \
@@ -220,8 +221,12 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd,
 int class_disconnect(struct obd_export *exp);
 void class_fail_export(struct obd_export *exp);
 void class_disconnect_exports(struct obd_device *obddev);
+void class_set_export_delayed(struct obd_export *exp);
+void class_handle_stale_exports(struct obd_device *obddev);
+void class_disconnect_expired_exports(struct obd_device *obd);
 void class_disconnect_stale_exports(struct obd_device *obddev,
                                     enum obd_option flags);
+int class_stale_export_list(struct obd_device *obd, struct obd_ioctl_data *data);
 int class_manual_cleanup(struct obd_device *obd);
 
 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
@@ -718,6 +723,30 @@ static inline int obd_disconnect(struct obd_export *exp)
         RETURN(rc);
 }
 
+static inline int obd_fid_init(struct obd_export *exp)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(exp->exp_obd, fid_init, 0);
+        EXP_COUNTER_INCREMENT(exp, fid_init);
+
+        rc = OBP(exp->exp_obd, fid_init)(exp);
+        RETURN(rc);
+}
+
+static inline int obd_fid_fini(struct obd_export *exp)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(exp->exp_obd, fid_fini, 0);
+        EXP_COUNTER_INCREMENT(exp, fid_fini);
+
+        rc = OBP(exp->exp_obd, fid_fini)(exp);
+        RETURN(rc);
+}
+
 static inline int obd_ping(struct obd_export *exp)
 {
         int rc;
@@ -730,6 +759,74 @@ static inline int obd_ping(struct obd_export *exp)
         RETURN(rc);
 }
 
+static inline int obd_pool_new(struct obd_device *obd, char *poolname)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(obd, pool_new, -EOPNOTSUPP);
+        OBD_COUNTER_INCREMENT(obd, pool_new);
+
+        rc = OBP(obd, pool_new)(obd, poolname);
+        RETURN(rc);
+}
+
+static inline int obd_pool_del(struct obd_device *obd, char *poolname)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(obd, pool_del, -EOPNOTSUPP);
+        OBD_COUNTER_INCREMENT(obd, pool_del);
+
+        rc = OBP(obd, pool_del)(obd, poolname);
+        RETURN(rc);
+}
+
+static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(obd, pool_add, -EOPNOTSUPP);
+        OBD_COUNTER_INCREMENT(obd, pool_add);
+
+        rc = OBP(obd, pool_add)(obd, poolname, ostname);
+        RETURN(rc);
+}
+
+static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(obd, pool_rem, -EOPNOTSUPP);
+        OBD_COUNTER_INCREMENT(obd, pool_rem);
+
+        rc = OBP(obd, pool_rem)(obd, poolname, ostname);
+        RETURN(rc);
+}
+
+static inline void obd_getref(struct obd_device *obd)
+{
+        ENTRY;
+        if (OBT(obd) && OBP(obd, getref)) {
+                OBD_COUNTER_INCREMENT(obd, getref);
+                OBP(obd, getref)(obd);
+        }
+        EXIT;
+}
+
+static inline void obd_putref(struct obd_device *obd)
+{
+        ENTRY;
+        if (OBT(obd) && OBP(obd, putref)) {
+                OBD_COUNTER_INCREMENT(obd, putref);
+                OBP(obd, putref)(obd);
+        }
+        EXIT;
+}
+
 static inline int obd_init_export(struct obd_export *exp)
 {
         int rc = 0;
@@ -871,17 +968,38 @@ static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         RETURN(rc);
 }
 
-static inline int obd_sync(struct obd_export *exp, struct obdo *oa,
-                           struct lov_stripe_md *ea, obd_size start,
-                           obd_size end)
+static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo,
+                                 obd_size start, obd_size end)
 {
+        struct ptlrpc_request_set *set = NULL;
         int rc;
         ENTRY;
 
         OBD_CHECK_OP(exp->exp_obd, sync, -EOPNOTSUPP);
         EXP_COUNTER_INCREMENT(exp, sync);
 
-        rc = OBP(exp->exp_obd, sync)(exp, oa, ea, start, end);
+        set =  ptlrpc_prep_set();
+        if (set == NULL)
+                RETURN(-ENOMEM);
+
+        rc = OBP(exp->exp_obd, sync)(exp, oinfo, start, end, set);
+        if (rc == 0)
+                rc = ptlrpc_set_wait(set);
+        ptlrpc_set_destroy(set);
+        RETURN(rc);
+}
+
+static inline int obd_sync(struct obd_export *exp, struct obd_info *oinfo,
+                           obd_size start, obd_size end,
+                           struct ptlrpc_request_set *set)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(exp->exp_obd, sync, -EOPNOTSUPP);
+        EXP_COUNTER_INCREMENT(exp, sync);
+
+        rc = OBP(exp->exp_obd, sync)(exp, oinfo, start, end, set);
         RETURN(rc);
 }
 
@@ -1124,7 +1242,7 @@ static inline int obd_teardown_async_page(struct obd_export *exp,
 
 static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                              int objcount, struct obd_ioobj *obj,
-                             int niocount, struct niobuf_remote *remote,
+                             struct niobuf_remote *remote, int *pages,
                              struct niobuf_local *local,
                              struct obd_trans_info *oti)
 {
@@ -1134,14 +1252,15 @@ static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
         OBD_CHECK_OP(exp->exp_obd, preprw, -EOPNOTSUPP);
         EXP_COUNTER_INCREMENT(exp, preprw);
 
-        rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, niocount,
-                                       remote, local, oti);
+        rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, remote,
+                                       pages, local, oti);
         RETURN(rc);
 }
 
 static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
                                int objcount, struct obd_ioobj *obj,
-                               int niocount, struct niobuf_local *local,
+                               struct niobuf_remote *rnb, int pages,
+                               struct niobuf_local *local,
                                struct obd_trans_info *oti, int rc)
 {
         ENTRY;
@@ -1149,8 +1268,8 @@ static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
         OBD_CHECK_OP(exp->exp_obd, commitrw, -EOPNOTSUPP);
         EXP_COUNTER_INCREMENT(exp, commitrw);
 
-        rc = OBP(exp->exp_obd, commitrw)(cmd, exp, oa, objcount, obj, niocount,
-                                         local, oti, rc);
+        rc = OBP(exp->exp_obd, commitrw)(cmd, exp, oa, objcount, obj,
+                                         rnb, pages, local, oti, rc);
         RETURN(rc);
 }
 
@@ -1168,6 +1287,20 @@ static inline int obd_merge_lvb(struct obd_export *exp,
         RETURN(rc);
 }
 
+static inline int obd_update_lvb(struct obd_export *exp,
+                                 struct lov_stripe_md *lsm,
+                                 struct ost_lvb *lvb, obd_flag valid)
+{
+        int rc;
+        ENTRY;
+
+        OBD_CHECK_OP(exp->exp_obd, update_lvb, -EOPNOTSUPP);
+        EXP_COUNTER_INCREMENT(exp, update_lvb);
+
+        rc = OBP(exp->exp_obd, update_lvb)(exp, lsm, lvb, valid);
+        RETURN(rc);
+}
+
 static inline int obd_adjust_kms(struct obd_export *exp,
                                  struct lov_stripe_md *lsm, obd_off size,
                                  int shrink)
@@ -1234,7 +1367,8 @@ static inline int obd_enqueue(struct obd_export *exp,
 
 static inline int obd_match(struct obd_export *exp, struct lov_stripe_md *ea,
                             __u32 type, ldlm_policy_data_t *policy, __u32 mode,
-                            int *flags, void *data, struct lustre_handle *lockh)
+                            int *flags, void *data, struct lustre_handle *lockh,
+                            int *n_matches)
 {
         int rc;
         ENTRY;
@@ -1243,7 +1377,7 @@ static inline int obd_match(struct obd_export *exp, struct lov_stripe_md *ea,
         EXP_COUNTER_INCREMENT(exp, match);
 
         rc = OBP(exp->exp_obd, match)(exp, ea, type, policy, mode, flags, data,
-                                      lockh);
+                                      lockh, n_matches);
         RETURN(rc);
 }
 
@@ -1302,8 +1436,8 @@ static inline int obd_join_lru(struct obd_export *exp,
         RETURN(rc);
 }
 
-static inline int obd_pin(struct obd_export *exp, obd_id ino, __u32 gen,
-                          int type, struct obd_client_handle *handle, int flag)
+static inline int obd_pin(struct obd_export *exp, struct ll_fid *fid,
+                          struct obd_client_handle *handle, int flag)
 {
         int rc;
         ENTRY;
@@ -1311,7 +1445,7 @@ static inline int obd_pin(struct obd_export *exp, obd_id ino, __u32 gen,
         EXP_CHECK_OP(exp, pin);
         EXP_COUNTER_INCREMENT(exp, pin);
 
-        rc = OBP(exp->exp_obd, pin)(exp, ino, gen, type, handle, flag);
+        rc = OBP(exp->exp_obd, pin)(exp, fid, handle, flag);
         RETURN(rc);
 }
 
diff --git a/lustre/include/obd_lov.h b/lustre/include/obd_lov.h
index 64798ab..da3ca51 100644
--- a/lustre/include/obd_lov.h
+++ b/lustre/include/obd_lov.h
@@ -42,13 +42,17 @@ static inline int lov_stripe_md_size(int stripes)
         return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*);
 }
 
-#define lov_mds_md_size(stripes) lov_mds_md_v1_size(stripes)
-static inline int lov_mds_md_v1_size(int stripes)
+static inline int lov_mds_md_size(int stripes, int lmm_magic)
 {
-        return sizeof(struct lov_mds_md_v1) +
-                stripes * sizeof(struct lov_ost_data_v1);
+        if (lmm_magic == LOV_MAGIC_V3)
+                return sizeof(struct lov_mds_md_v3) +
+                        stripes * sizeof(struct lov_ost_data_v1);
+        else
+                return sizeof(struct lov_mds_md_v1) +
+                        stripes * sizeof(struct lov_ost_data_v1);
 }
 
+
 #define IOC_LOV_TYPE                   'g'
 #define IOC_LOV_MIN_NR                 50
 #define IOC_LOV_SET_OSC_ACTIVE         _IOWR('g', 50, long)
diff --git a/lustre/include/obd_ost.h b/lustre/include/obd_ost.h
index cb24772..5ae31e9 100644
--- a/lustre/include/obd_ost.h
+++ b/lustre/include/obd_ost.h
@@ -56,6 +56,7 @@ struct osc_brw_async_args {
         struct list_head aa_oaps;
 };
 
+#define osc_grant_args osc_brw_async_args
 struct osc_async_args {
         struct obd_info   *aa_oi;
 };
@@ -70,4 +71,24 @@ int osc_extent_blocking_cb(struct ldlm_lock *lock,
                            struct ldlm_lock_desc *new, void *data,
                            int flag);
 
+/** 
+ * Build DLM resource name from object id & group for osc-ost extent lock.
+ */
+static inline struct ldlm_res_id *osc_build_res_name(__u64 id, __u64 gr,
+                                                     struct ldlm_res_id *name)
+{
+        memset(name, 0, sizeof *name);
+        name->name[0] = id;
+        name->name[1] = gr;
+        return name;
+}
+
+/**
+ * Return true if the resource is for the object identified by this id & group.
+ */
+static inline int osc_res_name_eq(__u64 id, __u64 gr, struct ldlm_res_id *name)
+{
+        return name->name[0] == id && name->name[1] == gr;
+}
+
 #endif
diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h
index 2e36ec3..51a0309 100644
--- a/lustre/include/obd_support.h
+++ b/lustre/include/obd_support.h
@@ -59,6 +59,11 @@ extern unsigned int obd_dump_on_eviction;
    networking / disk / timings affected by load (use Adaptive Timeouts) */
 extern unsigned int obd_timeout;          /* seconds */
 extern unsigned int ldlm_timeout;         /* seconds */
+extern unsigned int at_min;
+extern unsigned int at_max;
+extern unsigned int at_history;
+extern int at_early_margin;
+extern int at_extra;
 extern unsigned int obd_sync_filter;
 extern unsigned int obd_max_dirty_pages;
 extern atomic_t obd_dirty_pages;
@@ -70,6 +75,11 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_TIMEOUT_DEFAULT             100
 #define LDLM_TIMEOUT_DEFAULT            20
 #define MDS_LDLM_TIMEOUT_DEFAULT        6
+#ifdef HAVE_DELAYED_RECOVERY
+#define STALE_EXPORT_MAXTIME_DEFAULT    (24*60*60) /**< one day, in seconds */
+#else
+#define STALE_EXPORT_MAXTIME_DEFAULT    (0) /**< zero if no delayed recovery */
+#endif
 #ifdef CRAY_XT3
  #define OBD_RECOVERY_MAX_TIME (obd_timeout * 18) /* b13079 */
 #endif
@@ -78,6 +88,8 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_RECOVERY_FACTOR (3) /* times obd_timeout */
 /* Change recovery-small 26b time if you change this */
 #define PING_INTERVAL max(obd_timeout / 4, 1U)
+/* a bit more than maximal journal commit time in seconds */
+#define PING_INTERVAL_SHORT 7
 /* Client may skip 1 ping; we must wait at least 2.5. But for multiple
  * failover targets the client only pings one server at a time, and pings
  * can be lost on a loaded network. Since eviction has serious consequences,
@@ -105,6 +117,11 @@ extern unsigned int obd_alloc_fail_rate;
 #endif
 #define LONG_UNLINK 300          /* Unlink should happen before now */
 
+/**
+ * Time interval of shrink, if the client is "idle" more than this interval,
+ * then the ll_grant thread will return the requested grant space to filter
+ */
+#define GRANT_SHRINK_INTERVAL            1200/*20 minutes*/
 
 #define OBD_FAIL_MDS                     0x100
 #define OBD_FAIL_MDS_HANDLE_UNPACK       0x101
@@ -168,7 +185,11 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_MDS_CLOSE_NET_REP       0x13b
 #define OBD_FAIL_MDS_BLOCK_QUOTA_REQ     0x13c
 #define OBD_FAIL_MDS_DROP_QUOTA_REQ      0x13d
+#define OBD_FAIL_MDS_REMOVE_COMMON_EA    0x13e
+#define OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING   0x13f
 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD    0x140
+#define OBD_FAIL_MDS_LOV_PREP_CREATE     0x141
+#define OBD_FAIL_MDS_SPLIT_OPEN          0x142
 
 #define OBD_FAIL_OST                     0x200
 #define OBD_FAIL_OST_CONNECT_NET         0x201
@@ -208,6 +229,7 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_OST_PAUSE_CREATE        0x223
 #define OBD_FAIL_OST_BRW_PAUSE_PACK      0x224
 #define OBD_FAIL_OST_CONNECT_NET2        0x225
+#define OBD_FAIL_OST_NOMEM               0x226
 
 #define OBD_FAIL_LDLM                    0x300
 #define OBD_FAIL_LDLM_NAMESPACE_NEW      0x301
@@ -236,6 +258,9 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_LDLM_CP_BL_RACE         0x318
 #define OBD_FAIL_LDLM_ENQUEUE_LOCAL      0x319
 
+/* LOCKLESS IO */
+#define OBD_FAIL_LDLM_SET_CONTENTION     0x385
+
 #define OBD_FAIL_OSC                     0x400
 #define OBD_FAIL_OSC_BRW_READ_BULK       0x401
 #define OBD_FAIL_OSC_BRW_WRITE_BULK      0x402
@@ -250,6 +275,7 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_OSC_CONNECT_CKSUM       0x40b
 #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY    0x40c
 #define OBD_FAIL_OSC_DIO_PAUSE           0x40d
+#define OBD_FAIL_OSC_OBJECT_CONTENTION   0x40e
 
 #define OBD_FAIL_PTLRPC                  0x500
 #define OBD_FAIL_PTLRPC_ACK              0x501
@@ -262,6 +288,7 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB   0x508
 #define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
 #define OBD_FAIL_PTLRPC_PAUSE_REP        0x50c
+#define OBD_FAIL_PTLRPC_IMP_DEACTIVE     0x50d
 
 #define OBD_FAIL_PTLRPC_DUMP_LOG         0x50e
 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
@@ -285,6 +312,9 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_TGT_DELAY_PRECREATE     0x705
 #define OBD_FAIL_TGT_TOOMANY_THREADS     0x706
 #define OBD_FAIL_TGT_REPLAY_DROP         0x707
+#define OBD_FAIL_TGT_FAKE_EXP            0x708
+#define OBD_FAIL_TGT_REPLAY_DELAY        0x709
+#define OBD_FAIL_TGT_LAST_REPLAY         0x710
 
 #define OBD_FAIL_MDC_REVALIDATE_PAUSE    0x800
 #define OBD_FAIL_MDC_ENQUEUE_PAUSE       0x801
@@ -298,11 +328,6 @@ extern unsigned int obd_alloc_fail_rate;
 #define OBD_FAIL_MGS_PAUSE_REQ           0x904
 #define OBD_FAIL_MGS_PAUSE_TARGET_REG    0x905
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-#define OBD_FAIL_QUOTA_QD_COUNT_32BIT    0xA00
-#else
-#warning "remove quota code above for format obsolete in new release"
-#endif
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
 #define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS    0xA01
 #else
@@ -310,6 +335,7 @@ extern unsigned int obd_alloc_fail_rate;
 #endif
 
 #define OBD_FAIL_QUOTA_RET_QDATA         0xA02
+#define OBD_FAIL_QUOTA_DELAY_REL         0xA03
 
 #define OBD_FAIL_LPROC_REMOVE            0xB00
 
@@ -570,7 +596,7 @@ do {                                                                          \
 
 #ifdef HAVE_RCU
 # ifdef HAVE_CALL_RCU_PARAM
-#  define my_call_rcu(rcu, cb)            call_rcu(rcu, cb, rcu)
+#  define my_call_rcu(rcu, cb)            call_rcu(rcu, (void (*) (void *))(cb), rcu)
 # else
 #  define my_call_rcu(rcu, cb)            call_rcu(rcu, cb)
 # endif
diff --git a/lustre/kernel_patches/LICENSE.cray b/lustre/kernel_patches/LICENSE.cray
index 62c2c08..2a767f3 100644
--- a/lustre/kernel_patches/LICENSE.cray
+++ b/lustre/kernel_patches/LICENSE.cray
@@ -368,4 +368,4 @@ LICENSE file included with this distribution for more information.
 If you did not agree to a different license, then this copy of Lustre
 is open source software; you can redistribute it and/or modify it
 under the terms of version 2 of the GNU General Public License as
-published by the Free Software Foundation.	
+published by the Free Software Foundation.
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-i686-bigsmp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-i686-bigsmp.config
index 97d697e..71f99af 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-i686-bigsmp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-i686-bigsmp.config
@@ -3455,11 +3455,11 @@ CONFIG_SECURITY_APPARMOR=m
 # Cryptographic options
 #
 CONFIG_CRYPTO=y
-CONFIG_CRYPTO_ALGAPI=m
+CONFIG_CRYPTO_ALGAPI=y
 CONFIG_CRYPTO_ABLKCIPHER=m
 CONFIG_CRYPTO_BLKCIPHER=m
-CONFIG_CRYPTO_HASH=m
-CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_XCBC=m
 CONFIG_CRYPTO_NULL=m
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-x86_64-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-x86_64-smp.config
index eb87a50..e4af959 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-x86_64-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.16-2.6-sles10-x86_64-smp.config
@@ -3029,8 +3029,8 @@ CONFIG_CRYPTO=y
 CONFIG_CRYPTO_ALGAPI=y
 CONFIG_CRYPTO_ABLKCIPHER=m
 CONFIG_CRYPTO_BLKCIPHER=m
-CONFIG_CRYPTO_HASH=m
-CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_XCBC=m
 CONFIG_CRYPTO_NULL=m
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686-smp.config
index 6af2baf..97328b8 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686-smp.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.18-prep
-# Fri Jun 27 01:40:54 2008
+# Thu Jan 22 12:00:56 2009
 #
 CONFIG_X86_32=y
 CONFIG_GENERIC_TIME=y
@@ -55,10 +55,14 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SHMEM=y
 CONFIG_SLAB=y
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
@@ -166,6 +170,7 @@ CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
 CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
 CONFIG_X86_LOCAL_APIC=y
 CONFIG_X86_IO_APIC=y
 CONFIG_X86_MCE=y
@@ -263,6 +268,11 @@ CONFIG_ACPI_SYSTEM=y
 CONFIG_X86_PM_TIMER=y
 CONFIG_ACPI_CONTAINER=y
 CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
 
 #
 # APM (Advanced Power Management) BIOS Support
@@ -331,9 +341,13 @@ CONFIG_PCI_GOANY=y
 CONFIG_PCI_BIOS=y
 CONFIG_PCI_DIRECT=y
 CONFIG_PCI_MMCONFIG=y
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
 CONFIG_PCIEPORTBUS=y
 CONFIG_HOTPLUG_PCI_PCIE=m
 # CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
 CONFIG_PCI_MSI=y
 # CONFIG_PCI_DEBUG is not set
 CONFIG_ISA_DMA_API=y
@@ -445,6 +459,7 @@ CONFIG_TCP_CONG_VEGAS=m
 CONFIG_TCP_CONG_SCALABLE=m
 CONFIG_TCP_CONG_LP=m
 CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
 
 #
 # IP: Virtual Server Configuration
@@ -805,9 +820,26 @@ CONFIG_NL80211=y
 CONFIG_WIRELESS_EXT=y
 CONFIG_NET_WIRELESS_RTNETLINK=y
 CONFIG_MAC80211=m
-CONFIG_MAC80211_RCSIMPLE=y
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
 CONFIG_MAC80211_LEDS=y
 # CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
 CONFIG_MAC80211_DEBUG=y
 # CONFIG_MAC80211_HT_DEBUG is not set
 # CONFIG_MAC80211_VERBOSE_DEBUG is not set
@@ -1029,6 +1061,7 @@ CONFIG_CDROM_PKTCDVD=m
 CONFIG_CDROM_PKTCDVD_BUFFERS=8
 # CONFIG_CDROM_PKTCDVD_WCACHE is not set
 CONFIG_ATA_OVER_ETH=m
+CONFIG_VIRTIO_BLK=m
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -1105,6 +1138,7 @@ CONFIG_IDEDMA_AUTO=y
 #
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
 CONFIG_SCSI_NETLINK=y
 CONFIG_SCSI_PROC_FS=y
 
@@ -1141,6 +1175,8 @@ CONFIG_SCSI_SAS_LIBSAS=m
 #
 # SCSI low-level drivers
 #
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
 # CONFIG_ISCSI_TCP is not set
 CONFIG_BLK_DEV_3W_XXXX_RAID=m
 CONFIG_SCSI_3W_9XXX=m
@@ -1207,10 +1243,15 @@ CONFIG_PCMCIA_FDOMAIN=m
 # CONFIG_PCMCIA_NINJA_SCSI is not set
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
 CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
 CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
 CONFIG_SATA_SVW=m
 CONFIG_ATA_PIIX=m
 CONFIG_SATA_MV=m
@@ -1220,7 +1261,6 @@ CONFIG_SATA_QSTOR=m
 CONFIG_SATA_PROMISE=m
 CONFIG_SATA_SX4=m
 CONFIG_SATA_SIL=m
-CONFIG_SATA_SIL24=m
 CONFIG_SATA_SIS=m
 CONFIG_SATA_ULI=m
 CONFIG_SATA_VIA=m
@@ -1252,6 +1292,7 @@ CONFIG_PATA_MARVELL=m
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
 # CONFIG_PATA_NS87410 is not set
 CONFIG_PATA_NS87415=m
 # CONFIG_PATA_OPTI is not set
@@ -1267,6 +1308,7 @@ CONFIG_PATA_PDC2027X=m
 CONFIG_PATA_SIS=m
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
 CONFIG_ATA_INTEL_COMBINED=y
 
 #
@@ -1291,6 +1333,7 @@ CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
 CONFIG_DM_MULTIPATH_RDAC=m
 CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
 # CONFIG_DM_UEVENT is not set
 
 #
@@ -1304,8 +1347,13 @@ CONFIG_FUSION_MAX_SGE=40
 CONFIG_FUSION_CTL=m
 CONFIG_FUSION_LAN=m
 # CONFIG_FUSION_LOGGING is not set
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
 CONFIG_FIREWIRE=m
 CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
 CONFIG_FIREWIRE_SBP2=m
 
 #
@@ -1435,7 +1483,6 @@ CONFIG_NS83820=m
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 CONFIG_R8169=m
-CONFIG_R8169_NAPI=y
 CONFIG_R8169_VLAN=y
 CONFIG_SIS190=m
 CONFIG_SKGE=m
@@ -1450,17 +1497,18 @@ CONFIG_QLA3XXX=m
 # Ethernet (10000 Mbit)
 #
 CONFIG_CHELSIO_T1=m
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
 CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -1523,6 +1571,8 @@ CONFIG_PCMCIA_WL3501=m
 #
 CONFIG_PRISM54=m
 CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
 CONFIG_HOSTAP=m
 CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
@@ -1539,12 +1589,38 @@ CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
 CONFIG_ZD1211RW=m
 # CONFIG_ZD1211RW_DEBUG is not set
 CONFIG_NET_WIRELESS=y
-CONFIG_IWL4965=m
-# CONFIG_IWL4965_QOS is not set
-# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
-# CONFIG_IWL4965_SENSITIVITY is not set
-# CONFIG_IWL4965_DEBUG is not set
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
 # CONFIG_IWL3945 is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
 
 #
 # PCMCIA network device support
@@ -1618,6 +1694,7 @@ CONFIG_NETPOLL=y
 # CONFIG_NETPOLL_RX is not set
 CONFIG_NETPOLL_TRAP=y
 CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
 
 #
 # ISDN subsystem
@@ -2122,6 +2199,8 @@ CONFIG_SENSORS_HDAPS=m
 # Misc devices
 #
 CONFIG_IBM_ASM=m
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
 
 #
 # Multimedia devices
@@ -2178,6 +2257,7 @@ CONFIG_VIDEO_UPD64083=m
 #
 # V4L USB devices
 #
+CONFIG_USB_VIDEO_CLASS=m
 CONFIG_VIDEO_PVRUSB2=m
 CONFIG_VIDEO_PVRUSB2_24XXX=y
 CONFIG_VIDEO_PVRUSB2_SYSFS=y
@@ -2238,6 +2318,7 @@ CONFIG_FB_CIRRUS=m
 # CONFIG_FB_IMSTT is not set
 CONFIG_FB_VGA16=m
 CONFIG_FB_VESA=y
+# CONFIG_FB_EFI is not set
 # CONFIG_FB_IMAC is not set
 # CONFIG_FB_HGA is not set
 # CONFIG_FB_S1D13XXX is not set
@@ -2322,6 +2403,7 @@ CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
 
 #
 # Generic devices
@@ -2380,6 +2462,8 @@ CONFIG_SND_ES1968=m
 CONFIG_SND_FM801=m
 CONFIG_SND_FM801_TEA575X_BOOL=y
 CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
 CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_HDSPM=m
@@ -2662,32 +2746,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -2768,8 +2827,14 @@ CONFIG_EXT3_FS=m
 CONFIG_EXT3_FS_XATTR=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
 CONFIG_JBD=m
 # CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
@@ -2895,6 +2960,7 @@ CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 # CONFIG_CIFS_DEBUG2 is not set
 # CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_CIFS_UPCALL=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -3011,6 +3077,9 @@ CONFIG_DEBUG_LIST=y
 # CONFIG_FORCED_INLINING is not set
 CONFIG_BOOT_DELAY=y
 # CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
 CONFIG_EARLY_PRINTK=y
 CONFIG_DEBUG_STACKOVERFLOW=y
 CONFIG_DEBUG_STACK_USAGE=y
@@ -3050,11 +3119,13 @@ CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
 CONFIG_CRYPTO_ALGAPI=m
 CONFIG_CRYPTO_AEAD=m
 CONFIG_CRYPTO_BLKCIPHER=m
 CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
 CONFIG_CRYPTO_MANAGER=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_NHMAC=m
@@ -3093,16 +3164,29 @@ CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
 
 #
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
 # Hardware crypto devices
 #
 CONFIG_CRYPTO_DEV_PADLOCK=m
 CONFIG_CRYPTO_DEV_PADLOCK_AES=y
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+
+#
+# Xen PV-ON-HVM Configuration
+#
+CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
 #
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=y
 CONFIG_AUDIT_GENERIC=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686.config
index 467117c..97328b8 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-i686.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.18-prep
-# Fri Jun 27 01:41:47 2008
+# Thu Jan 22 12:00:56 2009
 #
 CONFIG_X86_32=y
 CONFIG_GENERIC_TIME=y
@@ -21,7 +21,7 @@ CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
@@ -39,6 +39,7 @@ CONFIG_TASK_DELAY_ACCT=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
 # CONFIG_IKCONFIG is not set
+CONFIG_CPUSETS=y
 CONFIG_RELAY=y
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -54,10 +55,14 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SHMEM=y
 CONFIG_SLAB=y
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
@@ -74,6 +79,7 @@ CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_MODULE_SIG=y
 # CONFIG_MODULE_SIG_FORCE is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
 
 #
 # Process debugging support
@@ -104,8 +110,8 @@ CONFIG_DEFAULT_IOSCHED="deadline"
 #
 # Processor type and features
 #
-# CONFIG_SMP is not set
-CONFIG_X86_PC=y
+CONFIG_SMP=y
+# CONFIG_X86_PC is not set
 # CONFIG_X86_XEN is not set
 # CONFIG_X86_ELAN is not set
 # CONFIG_X86_VOYAGER is not set
@@ -113,8 +119,9 @@ CONFIG_X86_PC=y
 # CONFIG_X86_SUMMIT is not set
 # CONFIG_X86_BIGSMP is not set
 # CONFIG_X86_VISWS is not set
-# CONFIG_X86_GENERICARCH is not set
+CONFIG_X86_GENERICARCH=y
 # CONFIG_X86_ES7000 is not set
+CONFIG_X86_CYCLONE_TIMER=y
 # CONFIG_M386 is not set
 # CONFIG_M486 is not set
 # CONFIG_M586 is not set
@@ -156,12 +163,19 @@ CONFIG_X86_TSC=y
 CONFIG_HPET_TIMER=y
 CONFIG_HPET_EMULATE_RTC=y
 CONFIG_TICK_DIVIDER=y
+CONFIG_NR_CPUS=32
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
-# CONFIG_X86_UP_APIC is not set
+CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
 CONFIG_X86_MCE=y
 # CONFIG_X86_MCE_NONFATAL is not set
+CONFIG_X86_MCE_P4THERMAL=y
 CONFIG_VM86=y
 CONFIG_TOSHIBA=m
 CONFIG_I8K=m
@@ -184,22 +198,20 @@ CONFIG_HIGHMEM4G=y
 # CONFIG_HIGHMEM64G is not set
 CONFIG_PAGE_OFFSET=0xC0000000
 CONFIG_HIGHMEM=y
-CONFIG_ARCH_FLATMEM_ENABLE=y
-CONFIG_ARCH_SPARSEMEM_ENABLE=y
-CONFIG_ARCH_SELECT_MEMORY_MODEL=y
 CONFIG_SELECT_MEMORY_MODEL=y
 CONFIG_FLATMEM_MANUAL=y
 # CONFIG_DISCONTIGMEM_MANUAL is not set
 # CONFIG_SPARSEMEM_MANUAL is not set
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
-CONFIG_SPARSEMEM_STATIC=y
+# CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4096
 CONFIG_RESOURCES_64BIT=y
 CONFIG_HIGHPTE=y
 # CONFIG_MATH_EMULATION is not set
 CONFIG_MTRR=y
 CONFIG_EFI=y
+# CONFIG_IRQBALANCE is not set
 CONFIG_BOOT_IOREMAP=y
 CONFIG_REGPARM=y
 # CONFIG_SECCOMP is not set
@@ -212,6 +224,7 @@ CONFIG_KEXEC=y
 CONFIG_CRASH_DUMP=y
 CONFIG_RELOCATABLE=y
 CONFIG_PHYSICAL_ALIGN=0x400000
+CONFIG_HOTPLUG_CPU=y
 # CONFIG_COMPAT_VDSO is not set
 CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
 
@@ -223,6 +236,7 @@ CONFIG_PM_LEGACY=y
 # CONFIG_PM_DEBUG is not set
 CONFIG_SOFTWARE_SUSPEND=y
 CONFIG_PM_STD_PARTITION=""
+CONFIG_SUSPEND_SMP=y
 
 #
 # ACPI (Advanced Configuration and Power Interface) Support
@@ -240,6 +254,7 @@ CONFIG_ACPI_FAN=y
 CONFIG_ACPI_DOCK=y
 CONFIG_ACPI_BAY=y
 CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_HOTPLUG_CPU=y
 CONFIG_ACPI_THERMAL=y
 CONFIG_ACPI_ASUS=m
 CONFIG_ACPI_IBM=m
@@ -253,6 +268,11 @@ CONFIG_ACPI_SYSTEM=y
 CONFIG_X86_PM_TIMER=y
 CONFIG_ACPI_CONTAINER=y
 CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
 
 #
 # APM (Advanced Power Management) BIOS Support
@@ -321,9 +341,14 @@ CONFIG_PCI_GOANY=y
 CONFIG_PCI_BIOS=y
 CONFIG_PCI_DIRECT=y
 CONFIG_PCI_MMCONFIG=y
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
 CONFIG_PCIEPORTBUS=y
 CONFIG_HOTPLUG_PCI_PCIE=m
 # CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCI_MSI=y
 # CONFIG_PCI_DEBUG is not set
 CONFIG_ISA_DMA_API=y
 # CONFIG_ISA is not set
@@ -361,6 +386,7 @@ CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_FAKE=m
 CONFIG_HOTPLUG_PCI_COMPAQ=m
 # CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM is not set
+CONFIG_HOTPLUG_PCI_IBM=m
 CONFIG_HOTPLUG_PCI_ACPI=m
 CONFIG_HOTPLUG_PCI_ACPI_IBM=m
 # CONFIG_HOTPLUG_PCI_CPCI is not set
@@ -433,6 +459,7 @@ CONFIG_TCP_CONG_VEGAS=m
 CONFIG_TCP_CONG_SCALABLE=m
 CONFIG_TCP_CONG_LP=m
 CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
 
 #
 # IP: Virtual Server Configuration
@@ -793,9 +820,26 @@ CONFIG_NL80211=y
 CONFIG_WIRELESS_EXT=y
 CONFIG_NET_WIRELESS_RTNETLINK=y
 CONFIG_MAC80211=m
-CONFIG_MAC80211_RCSIMPLE=y
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
 CONFIG_MAC80211_LEDS=y
 # CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
 CONFIG_MAC80211_DEBUG=y
 # CONFIG_MAC80211_HT_DEBUG is not set
 # CONFIG_MAC80211_VERBOSE_DEBUG is not set
@@ -1017,6 +1061,7 @@ CONFIG_CDROM_PKTCDVD=m
 CONFIG_CDROM_PKTCDVD_BUFFERS=8
 # CONFIG_CDROM_PKTCDVD_WCACHE is not set
 CONFIG_ATA_OVER_ETH=m
+CONFIG_VIRTIO_BLK=m
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -1093,6 +1138,7 @@ CONFIG_IDEDMA_AUTO=y
 #
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
 CONFIG_SCSI_NETLINK=y
 CONFIG_SCSI_PROC_FS=y
 
@@ -1129,6 +1175,8 @@ CONFIG_SCSI_SAS_LIBSAS=m
 #
 # SCSI low-level drivers
 #
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
 # CONFIG_ISCSI_TCP is not set
 CONFIG_BLK_DEV_3W_XXXX_RAID=m
 CONFIG_SCSI_3W_9XXX=m
@@ -1195,10 +1243,15 @@ CONFIG_PCMCIA_FDOMAIN=m
 # CONFIG_PCMCIA_NINJA_SCSI is not set
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
 CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
 CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
 CONFIG_SATA_SVW=m
 CONFIG_ATA_PIIX=m
 CONFIG_SATA_MV=m
@@ -1208,7 +1261,6 @@ CONFIG_SATA_QSTOR=m
 CONFIG_SATA_PROMISE=m
 CONFIG_SATA_SX4=m
 CONFIG_SATA_SIL=m
-CONFIG_SATA_SIL24=m
 CONFIG_SATA_SIS=m
 CONFIG_SATA_ULI=m
 CONFIG_SATA_VIA=m
@@ -1240,6 +1292,7 @@ CONFIG_PATA_MARVELL=m
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
 # CONFIG_PATA_NS87410 is not set
 CONFIG_PATA_NS87415=m
 # CONFIG_PATA_OPTI is not set
@@ -1255,6 +1308,7 @@ CONFIG_PATA_PDC2027X=m
 CONFIG_PATA_SIS=m
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
 CONFIG_ATA_INTEL_COMBINED=y
 
 #
@@ -1279,6 +1333,7 @@ CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
 CONFIG_DM_MULTIPATH_RDAC=m
 CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
 # CONFIG_DM_UEVENT is not set
 
 #
@@ -1292,8 +1347,13 @@ CONFIG_FUSION_MAX_SGE=40
 CONFIG_FUSION_CTL=m
 CONFIG_FUSION_LAN=m
 # CONFIG_FUSION_LOGGING is not set
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
 CONFIG_FIREWIRE=m
 CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
 CONFIG_FIREWIRE_SBP2=m
 
 #
@@ -1375,7 +1435,6 @@ CONFIG_WINBOND_840=m
 CONFIG_DM9102=m
 CONFIG_ULI526X=m
 CONFIG_PCMCIA_XIRCOM=m
-# CONFIG_PCMCIA_XIRTULIP is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 CONFIG_PCNET32=m
@@ -1424,7 +1483,6 @@ CONFIG_NS83820=m
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 CONFIG_R8169=m
-CONFIG_R8169_NAPI=y
 CONFIG_R8169_VLAN=y
 CONFIG_SIS190=m
 CONFIG_SKGE=m
@@ -1439,17 +1497,18 @@ CONFIG_QLA3XXX=m
 # Ethernet (10000 Mbit)
 #
 CONFIG_CHELSIO_T1=m
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
 CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -1512,6 +1571,8 @@ CONFIG_PCMCIA_WL3501=m
 #
 CONFIG_PRISM54=m
 CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
 CONFIG_HOSTAP=m
 CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
@@ -1528,12 +1589,38 @@ CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
 CONFIG_ZD1211RW=m
 # CONFIG_ZD1211RW_DEBUG is not set
 CONFIG_NET_WIRELESS=y
-CONFIG_IWL4965=m
-# CONFIG_IWL4965_QOS is not set
-# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
-# CONFIG_IWL4965_SENSITIVITY is not set
-# CONFIG_IWL4965_DEBUG is not set
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
 # CONFIG_IWL3945 is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
 
 #
 # PCMCIA network device support
@@ -1607,6 +1694,7 @@ CONFIG_NETPOLL=y
 # CONFIG_NETPOLL_RX is not set
 CONFIG_NETPOLL_TRAP=y
 CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
 
 #
 # ISDN subsystem
@@ -1628,7 +1716,6 @@ CONFIG_ISDN_TTY_FAX=y
 #
 # ISDN feature submodules
 #
-# CONFIG_ISDN_DRV_LOOP is not set
 CONFIG_ISDN_DIVERSION=m
 
 #
@@ -1695,7 +1782,6 @@ CONFIG_HISAX_HDLC=y
 #
 # Active cards
 #
-# CONFIG_HYSDN is not set
 
 #
 # Siemens Gigaset
@@ -1848,7 +1934,6 @@ CONFIG_SYNCLINK=m
 CONFIG_SYNCLINKMP=m
 CONFIG_SYNCLINK_GT=m
 CONFIG_N_HDLC=m
-# CONFIG_RISCOM8 is not set
 # CONFIG_SPECIALIX is not set
 # CONFIG_SX is not set
 # CONFIG_RIO is not set
@@ -1952,7 +2037,6 @@ CONFIG_SONYPI=m
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 CONFIG_AGP=y
 CONFIG_AGP_ALI=y
 CONFIG_AGP_ATI=y
@@ -2115,6 +2199,8 @@ CONFIG_SENSORS_HDAPS=m
 # Misc devices
 #
 CONFIG_IBM_ASM=m
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
 
 #
 # Multimedia devices
@@ -2171,6 +2257,7 @@ CONFIG_VIDEO_UPD64083=m
 #
 # V4L USB devices
 #
+CONFIG_USB_VIDEO_CLASS=m
 CONFIG_VIDEO_PVRUSB2=m
 CONFIG_VIDEO_PVRUSB2_24XXX=y
 CONFIG_VIDEO_PVRUSB2_SYSFS=y
@@ -2231,6 +2318,7 @@ CONFIG_FB_CIRRUS=m
 # CONFIG_FB_IMSTT is not set
 CONFIG_FB_VGA16=m
 CONFIG_FB_VESA=y
+# CONFIG_FB_EFI is not set
 # CONFIG_FB_IMAC is not set
 # CONFIG_FB_HGA is not set
 # CONFIG_FB_S1D13XXX is not set
@@ -2315,6 +2403,7 @@ CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
 
 #
 # Generic devices
@@ -2373,6 +2462,8 @@ CONFIG_SND_ES1968=m
 CONFIG_SND_FM801=m
 CONFIG_SND_FM801_TEA575X_BOOL=y
 CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
 CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_HDSPM=m
@@ -2655,32 +2746,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -2761,8 +2827,14 @@ CONFIG_EXT3_FS=m
 CONFIG_EXT3_FS_XATTR=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
 CONFIG_JBD=m
 # CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
@@ -2888,6 +2960,7 @@ CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 # CONFIG_CIFS_DEBUG2 is not set
 # CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_CIFS_UPCALL=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -3004,6 +3077,9 @@ CONFIG_DEBUG_LIST=y
 # CONFIG_FORCED_INLINING is not set
 CONFIG_BOOT_DELAY=y
 # CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
 CONFIG_EARLY_PRINTK=y
 CONFIG_DEBUG_STACKOVERFLOW=y
 CONFIG_DEBUG_STACK_USAGE=y
@@ -3013,6 +3089,8 @@ CONFIG_DEBUG_STACK_USAGE=y
 #
 CONFIG_DEBUG_RODATA=y
 # CONFIG_4KSTACKS is not set
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
 CONFIG_DOUBLEFAULT=y
 
 #
@@ -3041,11 +3119,13 @@ CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
 CONFIG_CRYPTO_ALGAPI=m
 CONFIG_CRYPTO_AEAD=m
 CONFIG_CRYPTO_BLKCIPHER=m
 CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
 CONFIG_CRYPTO_MANAGER=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_NHMAC=m
@@ -3084,16 +3164,29 @@ CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
 
 #
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
 # Hardware crypto devices
 #
 CONFIG_CRYPTO_DEV_PADLOCK=m
 CONFIG_CRYPTO_DEV_PADLOCK_AES=y
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+
+#
+# Xen PV-ON-HVM Configuration
+#
+CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
 #
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=y
 CONFIG_AUDIT_GENERIC=y
@@ -3111,5 +3204,9 @@ CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_HT=y
 CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
 CONFIG_KTIME_SCALAR=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64-smp.config
index beb4f67..a272203 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64-smp.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.18-prep
-# Fri Jun 27 01:42:44 2008
+# Thu Jan 22 12:02:35 2009
 #
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
@@ -42,10 +42,14 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SHMEM=y
 CONFIG_SLAB=y
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
@@ -337,6 +341,7 @@ CONFIG_TCP_CONG_VEGAS=m
 CONFIG_TCP_CONG_SCALABLE=m
 CONFIG_TCP_CONG_LP=m
 CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
 
 #
 # IP: Virtual Server Configuration
@@ -697,9 +702,26 @@ CONFIG_NL80211=y
 CONFIG_WIRELESS_EXT=y
 CONFIG_NET_WIRELESS_RTNETLINK=y
 CONFIG_MAC80211=m
-CONFIG_MAC80211_RCSIMPLE=y
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
 CONFIG_MAC80211_LEDS=y
 # CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
 CONFIG_MAC80211_DEBUG=y
 # CONFIG_MAC80211_HT_DEBUG is not set
 # CONFIG_MAC80211_VERBOSE_DEBUG is not set
@@ -890,6 +912,7 @@ CONFIG_IDEDMA_AUTO=y
 #
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
 CONFIG_SCSI_NETLINK=y
 CONFIG_SCSI_PROC_FS=y
 
@@ -926,6 +949,8 @@ CONFIG_SCSI_SAS_LIBSAS=m
 #
 # SCSI low-level drivers
 #
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
 # CONFIG_ISCSI_TCP is not set
 CONFIG_BLK_DEV_3W_XXXX_RAID=m
 CONFIG_SCSI_3W_9XXX=m
@@ -984,10 +1009,15 @@ CONFIG_SCSI_DC395x=m
 # CONFIG_PCMCIA_FDOMAIN is not set
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
 CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
 CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
 CONFIG_SATA_SVW=m
 CONFIG_ATA_PIIX=m
 CONFIG_SATA_MV=m
@@ -997,7 +1027,6 @@ CONFIG_SATA_QSTOR=m
 CONFIG_SATA_PROMISE=m
 CONFIG_SATA_SX4=m
 CONFIG_SATA_SIL=m
-CONFIG_SATA_SIL24=m
 CONFIG_SATA_SIS=m
 CONFIG_SATA_ULI=m
 CONFIG_SATA_VIA=m
@@ -1027,6 +1056,7 @@ CONFIG_PATA_MARVELL=m
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
 # CONFIG_PATA_NS87410 is not set
 CONFIG_PATA_NS87415=m
 # CONFIG_PATA_OPTI is not set
@@ -1042,6 +1072,7 @@ CONFIG_PATA_PDC2027X=m
 CONFIG_PATA_SIS=m
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
 CONFIG_ATA_INTEL_COMBINED=y
 
 #
@@ -1066,6 +1097,7 @@ CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
 CONFIG_DM_MULTIPATH_RDAC=m
 CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
 # CONFIG_DM_UEVENT is not set
 
 #
@@ -1079,8 +1111,13 @@ CONFIG_FUSION_MAX_SGE=40
 CONFIG_FUSION_CTL=m
 CONFIG_FUSION_LAN=m
 # CONFIG_FUSION_LOGGING is not set
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
 CONFIG_FIREWIRE=m
 CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
 CONFIG_FIREWIRE_SBP2=m
 
 #
@@ -1200,7 +1237,6 @@ CONFIG_NS83820=m
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 CONFIG_R8169=m
-CONFIG_R8169_NAPI=y
 CONFIG_R8169_VLAN=y
 CONFIG_SIS190=m
 CONFIG_SKGE=m
@@ -1215,17 +1251,18 @@ CONFIG_QLA3XXX=m
 # Ethernet (10000 Mbit)
 #
 CONFIG_CHELSIO_T1=m
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
 CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -1279,6 +1316,8 @@ CONFIG_PCMCIA_WL3501=m
 #
 CONFIG_PRISM54=m
 CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
 CONFIG_HOSTAP=m
 CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
@@ -1289,12 +1328,38 @@ CONFIG_HOSTAP_CS=m
 CONFIG_ZD1211RW=m
 # CONFIG_ZD1211RW_DEBUG is not set
 CONFIG_NET_WIRELESS=y
-CONFIG_IWL4965=m
-# CONFIG_IWL4965_QOS is not set
-# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
-# CONFIG_IWL4965_SENSITIVITY is not set
-# CONFIG_IWL4965_DEBUG is not set
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
 # CONFIG_IWL3945 is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
 
 #
 # PCMCIA network device support
@@ -1818,6 +1883,8 @@ CONFIG_SENSORS_W83627EHF=m
 #
 # Misc devices
 #
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
 
 #
 # Multimedia devices
@@ -1873,6 +1940,7 @@ CONFIG_VIDEO_UPD64083=m
 #
 # V4L USB devices
 #
+CONFIG_USB_VIDEO_CLASS=m
 CONFIG_VIDEO_PVRUSB2=m
 CONFIG_VIDEO_PVRUSB2_24XXX=y
 CONFIG_VIDEO_PVRUSB2_SYSFS=y
@@ -2002,6 +2070,7 @@ CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
 
 #
 # Generic devices
@@ -2058,6 +2127,8 @@ CONFIG_SND_ES1968=m
 CONFIG_SND_FM801=m
 CONFIG_SND_FM801_TEA575X_BOOL=y
 CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
 CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_HDSPM=m
@@ -2338,33 +2409,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -2428,8 +2473,14 @@ CONFIG_EXT3_FS=m
 CONFIG_EXT3_FS_XATTR=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
 CONFIG_JBD=m
 # CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
@@ -2545,6 +2596,7 @@ CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 # CONFIG_CIFS_DEBUG2 is not set
 # CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_CIFS_UPCALL=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2626,6 +2678,7 @@ CONFIG_DLM_DEBUG=y
 #
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=y
 CONFIG_ZLIB_INFLATE=y
@@ -2684,6 +2737,9 @@ CONFIG_DEBUG_LIST=y
 # CONFIG_FORCED_INLINING is not set
 CONFIG_BOOT_DELAY=y
 # CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
 CONFIG_IA64_GRANULE_16MB=y
 # CONFIG_IA64_GRANULE_64MB is not set
 # CONFIG_IA64_PRINT_HAZARDS is not set
@@ -2717,11 +2773,13 @@ CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
 CONFIG_CRYPTO_ALGAPI=m
 CONFIG_CRYPTO_AEAD=m
 CONFIG_CRYPTO_BLKCIPHER=m
 CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
 CONFIG_CRYPTO_MANAGER=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_NHMAC=m
@@ -2759,5 +2817,17 @@ CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
 
 #
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
 # Hardware crypto devices
 #
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+
+#
+# Xen PV-ON-HVM Configuration
+#
+CONFIG_XEN_PV_ON_HVM=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64.config
index 485afd8..a272203 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ia64.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.18-prep
-# Fri Jun 27 01:43:25 2008
+# Thu Jan 22 12:02:35 2009
 #
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
@@ -9,7 +9,7 @@ CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
@@ -27,6 +27,7 @@ CONFIG_TASK_DELAY_ACCT=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
 # CONFIG_IKCONFIG is not set
+CONFIG_CPUSETS=y
 CONFIG_RELAY=y
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -41,10 +42,14 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SHMEM=y
 CONFIG_SLAB=y
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
@@ -61,6 +66,7 @@ CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_MODULE_SIG=y
 # CONFIG_MODULE_SIG_FORCE is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
 
 #
 # Process debugging support
@@ -129,8 +135,12 @@ CONFIG_IA64_CYCLONE=y
 CONFIG_IOSAPIC=y
 CONFIG_IA64_SGI_SN_XP=m
 CONFIG_FORCE_MAX_ZONEORDER=17
-# CONFIG_SMP is not set
+CONFIG_SMP=y
+CONFIG_NR_CPUS=1024
+CONFIG_HOTPLUG_CPU=y
 CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_SCHED_SMT=y
+# CONFIG_PERMIT_BSP_REMOVE is not set
 # CONFIG_PREEMPT is not set
 CONFIG_SELECT_MEMORY_MODEL=y
 # CONFIG_FLATMEM_MANUAL is not set
@@ -193,6 +203,7 @@ CONFIG_ACPI_BUTTON=m
 CONFIG_ACPI_FAN=y
 # CONFIG_ACPI_DOCK is not set
 CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_HOTPLUG_CPU=y
 CONFIG_ACPI_THERMAL=y
 CONFIG_ACPI_NUMA=y
 CONFIG_ACPI_BLACKLIST_YEAR=0
@@ -330,6 +341,7 @@ CONFIG_TCP_CONG_VEGAS=m
 CONFIG_TCP_CONG_SCALABLE=m
 CONFIG_TCP_CONG_LP=m
 CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
 
 #
 # IP: Virtual Server Configuration
@@ -690,9 +702,26 @@ CONFIG_NL80211=y
 CONFIG_WIRELESS_EXT=y
 CONFIG_NET_WIRELESS_RTNETLINK=y
 CONFIG_MAC80211=m
-CONFIG_MAC80211_RCSIMPLE=y
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
 CONFIG_MAC80211_LEDS=y
 # CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
 CONFIG_MAC80211_DEBUG=y
 # CONFIG_MAC80211_HT_DEBUG is not set
 # CONFIG_MAC80211_VERBOSE_DEBUG is not set
@@ -883,6 +912,7 @@ CONFIG_IDEDMA_AUTO=y
 #
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
 CONFIG_SCSI_NETLINK=y
 CONFIG_SCSI_PROC_FS=y
 
@@ -919,6 +949,8 @@ CONFIG_SCSI_SAS_LIBSAS=m
 #
 # SCSI low-level drivers
 #
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
 # CONFIG_ISCSI_TCP is not set
 CONFIG_BLK_DEV_3W_XXXX_RAID=m
 CONFIG_SCSI_3W_9XXX=m
@@ -977,10 +1009,15 @@ CONFIG_SCSI_DC395x=m
 # CONFIG_PCMCIA_FDOMAIN is not set
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
 CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
 CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
 CONFIG_SATA_SVW=m
 CONFIG_ATA_PIIX=m
 CONFIG_SATA_MV=m
@@ -990,7 +1027,6 @@ CONFIG_SATA_QSTOR=m
 CONFIG_SATA_PROMISE=m
 CONFIG_SATA_SX4=m
 CONFIG_SATA_SIL=m
-CONFIG_SATA_SIL24=m
 CONFIG_SATA_SIS=m
 CONFIG_SATA_ULI=m
 CONFIG_SATA_VIA=m
@@ -1020,6 +1056,7 @@ CONFIG_PATA_MARVELL=m
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
 # CONFIG_PATA_NS87410 is not set
 CONFIG_PATA_NS87415=m
 # CONFIG_PATA_OPTI is not set
@@ -1035,6 +1072,7 @@ CONFIG_PATA_PDC2027X=m
 CONFIG_PATA_SIS=m
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
 CONFIG_ATA_INTEL_COMBINED=y
 
 #
@@ -1059,6 +1097,7 @@ CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
 CONFIG_DM_MULTIPATH_RDAC=m
 CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
 # CONFIG_DM_UEVENT is not set
 
 #
@@ -1072,8 +1111,13 @@ CONFIG_FUSION_MAX_SGE=40
 CONFIG_FUSION_CTL=m
 CONFIG_FUSION_LAN=m
 # CONFIG_FUSION_LOGGING is not set
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
 CONFIG_FIREWIRE=m
 CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
 CONFIG_FIREWIRE_SBP2=m
 
 #
@@ -1147,7 +1191,6 @@ CONFIG_WINBOND_840=m
 CONFIG_DM9102=m
 CONFIG_ULI526X=m
 CONFIG_PCMCIA_XIRCOM=m
-# CONFIG_PCMCIA_XIRTULIP is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 CONFIG_PCNET32=m
@@ -1194,7 +1237,6 @@ CONFIG_NS83820=m
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 CONFIG_R8169=m
-CONFIG_R8169_NAPI=y
 CONFIG_R8169_VLAN=y
 CONFIG_SIS190=m
 CONFIG_SKGE=m
@@ -1209,17 +1251,18 @@ CONFIG_QLA3XXX=m
 # Ethernet (10000 Mbit)
 #
 CONFIG_CHELSIO_T1=m
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
 CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -1273,6 +1316,8 @@ CONFIG_PCMCIA_WL3501=m
 #
 CONFIG_PRISM54=m
 CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
 CONFIG_HOSTAP=m
 CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
@@ -1283,12 +1328,38 @@ CONFIG_HOSTAP_CS=m
 CONFIG_ZD1211RW=m
 # CONFIG_ZD1211RW_DEBUG is not set
 CONFIG_NET_WIRELESS=y
-CONFIG_IWL4965=m
-# CONFIG_IWL4965_QOS is not set
-# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
-# CONFIG_IWL4965_SENSITIVITY is not set
-# CONFIG_IWL4965_DEBUG is not set
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
 # CONFIG_IWL3945 is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
 
 #
 # PCMCIA network device support
@@ -1378,7 +1449,6 @@ CONFIG_ISDN_TTY_FAX=y
 #
 # ISDN feature submodules
 #
-# CONFIG_ISDN_DRV_LOOP is not set
 CONFIG_ISDN_DIVERSION=m
 
 #
@@ -1445,7 +1515,6 @@ CONFIG_HISAX_HDLC=y
 #
 # Active cards
 #
-# CONFIG_HYSDN is not set
 
 #
 # Siemens Gigaset
@@ -1588,7 +1657,6 @@ CONFIG_CYCLADES=m
 CONFIG_SYNCLINKMP=m
 CONFIG_SYNCLINK_GT=m
 CONFIG_N_HDLC=m
-# CONFIG_RISCOM8 is not set
 # CONFIG_SPECIALIX is not set
 # CONFIG_SX is not set
 # CONFIG_RIO is not set
@@ -1815,6 +1883,8 @@ CONFIG_SENSORS_W83627EHF=m
 #
 # Misc devices
 #
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
 
 #
 # Multimedia devices
@@ -1870,6 +1940,7 @@ CONFIG_VIDEO_UPD64083=m
 #
 # V4L USB devices
 #
+CONFIG_USB_VIDEO_CLASS=m
 CONFIG_VIDEO_PVRUSB2=m
 CONFIG_VIDEO_PVRUSB2_24XXX=y
 CONFIG_VIDEO_PVRUSB2_SYSFS=y
@@ -1999,6 +2070,7 @@ CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
 
 #
 # Generic devices
@@ -2055,6 +2127,8 @@ CONFIG_SND_ES1968=m
 CONFIG_SND_FM801=m
 CONFIG_SND_FM801_TEA575X_BOOL=y
 CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
 CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_HDSPM=m
@@ -2335,33 +2409,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -2425,8 +2473,14 @@ CONFIG_EXT3_FS=m
 CONFIG_EXT3_FS_XATTR=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
 CONFIG_JBD=m
 # CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
@@ -2542,6 +2596,7 @@ CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 # CONFIG_CIFS_DEBUG2 is not set
 # CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_CIFS_UPCALL=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2623,6 +2678,7 @@ CONFIG_DLM_DEBUG=y
 #
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=y
 CONFIG_ZLIB_INFLATE=y
@@ -2638,6 +2694,7 @@ CONFIG_HAS_IOPORT=y
 CONFIG_HAS_DMA=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
 CONFIG_IRQ_PER_CPU=y
 
 #
@@ -2680,6 +2737,9 @@ CONFIG_DEBUG_LIST=y
 # CONFIG_FORCED_INLINING is not set
 CONFIG_BOOT_DELAY=y
 # CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
 CONFIG_IA64_GRANULE_16MB=y
 # CONFIG_IA64_GRANULE_64MB is not set
 # CONFIG_IA64_PRINT_HAZARDS is not set
@@ -2713,11 +2773,13 @@ CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
 CONFIG_CRYPTO_ALGAPI=m
 CONFIG_CRYPTO_AEAD=m
 CONFIG_CRYPTO_BLKCIPHER=m
 CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
 CONFIG_CRYPTO_MANAGER=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_NHMAC=m
@@ -2755,5 +2817,17 @@ CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
 
 #
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
 # Hardware crypto devices
 #
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+
+#
+# Xen PV-ON-HVM Configuration
+#
+CONFIG_XEN_PV_ON_HVM=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64-smp.config
index 34e56ed..d8a493c 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64-smp.config
@@ -1405,8 +1405,7 @@ CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
 CONFIG_NETXEN_NIC=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -2687,34 +2686,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_EHCA=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64.config
index 34e56ed..d8a493c 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-ppc64.config
@@ -1405,8 +1405,7 @@ CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
 CONFIG_NETXEN_NIC=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -2687,34 +2686,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_EHCA=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64-smp.config
index d39a453..1989337 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64-smp.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.18-prep
-# Sat Nov 24 07:53:07 2007
+# Thu Jan 22 11:53:40 2009
 #
 CONFIG_X86_64=y
 CONFIG_64BIT=y
@@ -60,10 +60,14 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SHMEM=y
 CONFIG_SLAB=y
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
@@ -126,6 +130,7 @@ CONFIG_MICROCODE=m
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
 CONFIG_X86_HT=y
+# CONFIG_EFI is not set
 CONFIG_X86_IO_APIC=y
 CONFIG_X86_LOCAL_APIC=y
 CONFIG_MTRR=y
@@ -136,6 +141,7 @@ CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
 CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
 CONFIG_NUMA=y
 CONFIG_K8_NUMA=y
 CONFIG_NODES_SHIFT=6
@@ -174,6 +180,8 @@ CONFIG_TICK_DIVIDER=y
 CONFIG_IOMMU=y
 CONFIG_CALGARY_IOMMU=y
 # CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT is not set
+CONFIG_AMD_IOMMU=y
+CONFIG_IOMMU_HELPER=y
 CONFIG_SWIOTLB=y
 CONFIG_X86_MCE=y
 CONFIG_X86_MCE_INTEL=y
@@ -222,8 +230,7 @@ CONFIG_ACPI_HOTPLUG_CPU=y
 CONFIG_ACPI_THERMAL=y
 CONFIG_ACPI_NUMA=y
 CONFIG_ACPI_ASUS=m
-CONFIG_ACPI_IBM=m
-CONFIG_ACPI_IBM_BAY=y
+# CONFIG_ACPI_IBM is not set
 CONFIG_ACPI_TOSHIBA=m
 CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
@@ -234,12 +241,17 @@ CONFIG_X86_PM_TIMER=y
 CONFIG_ACPI_CONTAINER=y
 CONFIG_ACPI_HOTPLUG_MEMORY=m
 CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
 
 #
 # CPU Frequency scaling
 #
 CONFIG_CPU_FREQ=y
-CONFIG_CPU_FREQ_TABLE=y
+CONFIG_CPU_FREQ_TABLE=m
 CONFIG_CPU_FREQ_DEBUG=y
 CONFIG_CPU_FREQ_STAT=m
 CONFIG_CPU_FREQ_STAT_DETAILS=y
@@ -254,9 +266,9 @@ CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
 #
 # CPUFreq processor drivers
 #
-CONFIG_X86_POWERNOW_K8=y
+CONFIG_X86_POWERNOW_K8=m
 CONFIG_X86_POWERNOW_K8_ACPI=y
-CONFIG_X86_SPEEDSTEP_CENTRINO=y
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
 CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
 CONFIG_X86_ACPI_CPUFREQ=m
 
@@ -272,9 +284,13 @@ CONFIG_X86_ACPI_CPUFREQ=m
 CONFIG_PCI=y
 CONFIG_PCI_DIRECT=y
 CONFIG_PCI_MMCONFIG=y
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
 CONFIG_PCIEPORTBUS=y
 CONFIG_HOTPLUG_PCI_PCIE=m
 # CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
 CONFIG_PCI_MSI=y
 # CONFIG_PCI_DEBUG is not set
 
@@ -382,6 +398,7 @@ CONFIG_TCP_CONG_VEGAS=m
 CONFIG_TCP_CONG_SCALABLE=m
 CONFIG_TCP_CONG_LP=m
 CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
 
 #
 # IP: Virtual Server Configuration
@@ -420,7 +437,7 @@ CONFIG_IPV6=m
 CONFIG_IPV6_PRIVACY=y
 CONFIG_IPV6_ROUTER_PREF=y
 CONFIG_IPV6_ROUTE_INFO=y
-# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_IPV6_OPTIMISTIC_DAD=y
 CONFIG_INET6_AH=m
 CONFIG_INET6_ESP=m
 CONFIG_INET6_IPCOMP=m
@@ -742,17 +759,27 @@ CONFIG_NL80211=y
 CONFIG_WIRELESS_EXT=y
 CONFIG_NET_WIRELESS_RTNETLINK=y
 CONFIG_MAC80211=m
-CONFIG_MAC80211_RCSIMPLE=y
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
 CONFIG_MAC80211_LEDS=y
 # CONFIG_MAC80211_DEBUGFS is not set
-CONFIG_MAC80211_DEBUG=y
-# CONFIG_MAC80211_HT_DEBUG is not set
-# CONFIG_MAC80211_VERBOSE_DEBUG is not set
-# CONFIG_MAC80211_LOWTX_FRAME_DUMP is not set
-# CONFIG_TKIP_DEBUG is not set
-# CONFIG_MAC80211_DEBUG_COUNTERS is not set
-# CONFIG_MAC80211_IBSS_DEBUG is not set
-# CONFIG_MAC80211_VERBOSE_PS_DEBUG is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
 CONFIG_IEEE80211=m
 # CONFIG_IEEE80211_DEBUG is not set
 CONFIG_IEEE80211_CRYPT_WEP=m
@@ -964,6 +991,7 @@ CONFIG_CDROM_PKTCDVD=m
 CONFIG_CDROM_PKTCDVD_BUFFERS=8
 # CONFIG_CDROM_PKTCDVD_WCACHE is not set
 CONFIG_ATA_OVER_ETH=m
+CONFIG_VIRTIO_BLK=m
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -1038,6 +1066,7 @@ CONFIG_IDEDMA_AUTO=y
 #
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
 CONFIG_SCSI_NETLINK=y
 CONFIG_SCSI_PROC_FS=y
 
@@ -1068,12 +1097,14 @@ CONFIG_SCSI_FC_ATTRS=m
 # CONFIG_SCSI_ISCSI_ATTRS is not set
 CONFIG_SCSI_SAS_ATTRS=m
 CONFIG_SCSI_SAS_LIBSAS=m
-# CONFIG_SCSI_SAS_ATA is not set
+CONFIG_SCSI_SAS_ATA=y
 # CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
 
 #
 # SCSI low-level drivers
 #
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
 # CONFIG_ISCSI_TCP is not set
 CONFIG_BLK_DEV_3W_XXXX_RAID=m
 CONFIG_SCSI_3W_9XXX=m
@@ -1103,6 +1134,7 @@ CONFIG_MEGARAID_LEGACY=m
 CONFIG_MEGARAID_SAS=m
 CONFIG_SCSI_HPTIOP=m
 # CONFIG_SCSI_BUSLOGIC is not set
+CONFIG_FCOE_FNIC=m
 # CONFIG_SCSI_DMX3191D is not set
 # CONFIG_SCSI_EATA is not set
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
@@ -1135,10 +1167,15 @@ CONFIG_SCSI_DC395x=m
 # CONFIG_PCMCIA_FDOMAIN is not set
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
 CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
 CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
 CONFIG_SATA_SVW=m
 CONFIG_ATA_PIIX=m
 CONFIG_SATA_MV=m
@@ -1148,13 +1185,12 @@ CONFIG_SATA_QSTOR=m
 CONFIG_SATA_PROMISE=m
 CONFIG_SATA_SX4=m
 CONFIG_SATA_SIL=m
-CONFIG_SATA_SIL24=m
 CONFIG_SATA_SIS=m
 CONFIG_SATA_ULI=m
 CONFIG_SATA_VIA=m
 CONFIG_SATA_VITESSE=m
 CONFIG_SATA_INIC162X=m
-CONFIG_PATA_ACPI=m
+# CONFIG_PATA_ACPI is not set
 # CONFIG_PATA_ALI is not set
 # CONFIG_PATA_AMD is not set
 # CONFIG_PATA_ARTOP is not set
@@ -1178,8 +1214,9 @@ CONFIG_PATA_MARVELL=m
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
 # CONFIG_PATA_NS87410 is not set
-CONFIG_PATA_NS87415=m
+# CONFIG_PATA_NS87415 is not set
 # CONFIG_PATA_OPTI is not set
 # CONFIG_PATA_OPTIDMA is not set
 # CONFIG_PATA_PCMCIA is not set
@@ -1189,10 +1226,11 @@ CONFIG_PATA_NS87415=m
 # CONFIG_PATA_SC1200 is not set
 # CONFIG_PATA_SERVERWORKS is not set
 CONFIG_PATA_PDC2027X=m
-# CONFIG_PATA_SIL680 is not set
+CONFIG_PATA_SIL680=m
 CONFIG_PATA_SIS=m
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
 CONFIG_ATA_INTEL_COMBINED=y
 
 #
@@ -1217,7 +1255,8 @@ CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
 CONFIG_DM_MULTIPATH_RDAC=m
 CONFIG_DM_MULTIPATH_HP=m
-# CONFIG_DM_UEVENT is not set
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
 
 #
 # Fusion MPT device support
@@ -1226,12 +1265,17 @@ CONFIG_FUSION=y
 CONFIG_FUSION_SPI=m
 CONFIG_FUSION_FC=m
 CONFIG_FUSION_SAS=m
-CONFIG_FUSION_MAX_SGE=40
+CONFIG_FUSION_MAX_SGE=128
 CONFIG_FUSION_CTL=m
 CONFIG_FUSION_LAN=m
-# CONFIG_FUSION_LOGGING is not set
+CONFIG_FUSION_LOGGING=y
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
 CONFIG_FIREWIRE=m
 CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
 CONFIG_FIREWIRE_SBP2=m
 
 #
@@ -1337,7 +1381,8 @@ CONFIG_8139TOO_8129=y
 # CONFIG_8139_OLD_RX_RESET is not set
 CONFIG_SIS900=m
 CONFIG_EPIC100=m
-# CONFIG_SUNDANCE is not set
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
 CONFIG_VIA_RHINE=m
 CONFIG_VIA_RHINE_MMIO=y
 CONFIG_VIA_RHINE_NAPI=y
@@ -1361,7 +1406,6 @@ CONFIG_NS83820=m
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 CONFIG_R8169=m
-CONFIG_R8169_NAPI=y
 CONFIG_R8169_VLAN=y
 CONFIG_SIS190=m
 CONFIG_SKGE=m
@@ -1376,17 +1420,18 @@ CONFIG_QLA3XXX=m
 # Ethernet (10000 Mbit)
 #
 CONFIG_CHELSIO_T1=m
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
 CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -1448,6 +1493,8 @@ CONFIG_PCMCIA_WL3501=m
 #
 CONFIG_PRISM54=m
 CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
 CONFIG_HOSTAP=m
 CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
@@ -1464,12 +1511,42 @@ CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
 CONFIG_ZD1211RW=m
 # CONFIG_ZD1211RW_DEBUG is not set
 CONFIG_NET_WIRELESS=y
-CONFIG_IWL4965=m
-# CONFIG_IWL4965_QOS is not set
-# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
-# CONFIG_IWL4965_SENSITIVITY is not set
-# CONFIG_IWL4965_DEBUG is not set
-# CONFIG_IWL3945 is not set
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+# CONFIG_IWL3945_RFKILL is not set
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWL3945_LEDS is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
 
 #
 # PCMCIA network device support
@@ -1538,6 +1615,7 @@ CONFIG_NETPOLL=y
 # CONFIG_NETPOLL_RX is not set
 CONFIG_NETPOLL_TRAP=y
 CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
 
 #
 # ISDN subsystem
@@ -1809,7 +1887,8 @@ CONFIG_PPDEV=m
 # IPMI
 #
 CONFIG_IPMI_HANDLER=m
-# CONFIG_IPMI_PANIC_EVENT is not set
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
 CONFIG_IPMI_DEVICE_INTERFACE=m
 CONFIG_IPMI_SI=m
 CONFIG_IPMI_WATCHDOG=m
@@ -1836,7 +1915,7 @@ CONFIG_IBMASR=m
 # CONFIG_WAFER_WDT is not set
 CONFIG_I6300ESB_WDT=m
 CONFIG_I8XX_TCO=m
-CONFIG_HP_WATCHDOG=m
+# CONFIG_HP_WATCHDOG is not set
 # CONFIG_SC1200_WDT is not set
 # CONFIG_60XX_WDT is not set
 # CONFIG_SBC8360_WDT is not set
@@ -1903,8 +1982,12 @@ CONFIG_HPET=y
 # CONFIG_HPET_RTC_IRQ is not set
 # CONFIG_HPET_MMAP is not set
 CONFIG_HANGCHECK_TIMER=m
-# CONFIG_TCG_TPM is not set
-# CONFIG_TELCLOCK is not set
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
 
 #
 # I2C support
@@ -1930,7 +2013,7 @@ CONFIG_I2C_AMD756_S4882=m
 CONFIG_I2C_AMD8111=m
 CONFIG_I2C_I801=m
 # CONFIG_I2C_I810 is not set
-# CONFIG_I2C_PIIX4 is not set
+CONFIG_I2C_PIIX4=m
 CONFIG_I2C_ISA=m
 CONFIG_I2C_NFORCE2=m
 # CONFIG_I2C_OCORES is not set
@@ -2025,6 +2108,8 @@ CONFIG_SENSORS_HDAPS=m
 # Misc devices
 #
 # CONFIG_IBM_ASM is not set
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
 
 #
 # Multimedia devices
@@ -2080,6 +2165,7 @@ CONFIG_VIDEO_UPD64083=m
 #
 # V4L USB devices
 #
+CONFIG_USB_VIDEO_CLASS=m
 CONFIG_VIDEO_PVRUSB2=m
 CONFIG_VIDEO_PVRUSB2_24XXX=y
 CONFIG_VIDEO_PVRUSB2_SYSFS=y
@@ -2219,6 +2305,7 @@ CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
 
 #
 # Generic devices
@@ -2276,6 +2363,8 @@ CONFIG_SND_ES1968=m
 CONFIG_SND_FM801=m
 CONFIG_SND_FM801_TEA575X_BOOL=y
 CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
 CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_HDSPM=m
@@ -2558,33 +2647,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -2668,8 +2731,14 @@ CONFIG_EXT3_FS=m
 CONFIG_EXT3_FS_XATTR=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
 CONFIG_JBD=m
 # CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
@@ -2794,7 +2863,9 @@ CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 # CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_DFS_UPCALL=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2909,6 +2980,9 @@ CONFIG_DEBUG_LIST=y
 # CONFIG_FORCED_INLINING is not set
 CONFIG_BOOT_DELAY=y
 # CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
 CONFIG_DEBUG_RODATA=y
 # CONFIG_IOMMU_DEBUG is not set
 CONFIG_DEBUG_STACKOVERFLOW=y
@@ -2940,11 +3014,13 @@ CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
 CONFIG_CRYPTO_ALGAPI=m
 CONFIG_CRYPTO_AEAD=m
 CONFIG_CRYPTO_BLKCIPHER=m
 CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
 CONFIG_CRYPTO_MANAGER=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_NHMAC=m
@@ -2976,26 +3052,38 @@ CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=m
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_CRC32C=y
-# CONFIG_CRYPTO_TEST is not set
+CONFIG_CRYPTO_TEST=m
 CONFIG_CRYPTO_AUTHENC=m
 CONFIG_CRYPTO_SIGNATURE=y
 CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
 
 #
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
 # Hardware crypto devices
 #
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+
+#
+# Xen PV-ON-HVM Configuration
+#
+CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
 #
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=y
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=m
-CONFIG_GENERIC_ALLOCATOR=y
 CONFIG_REED_SOLOMON=m
 CONFIG_REED_SOLOMON_DEC16=y
 CONFIG_TEXTSEARCH=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64.config
index b1785f3..1989337 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-x86_64.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.18-prep
-# Sat Nov 24 07:56:00 2007
+# Thu Jan 22 11:53:40 2009
 #
 CONFIG_X86_64=y
 CONFIG_64BIT=y
@@ -26,7 +26,7 @@ CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_BROKEN_ON_SMP=y
+CONFIG_LOCK_KERNEL=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
 #
@@ -44,6 +44,7 @@ CONFIG_TASK_DELAY_ACCT=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
 # CONFIG_IKCONFIG is not set
+CONFIG_CPUSETS=y
 CONFIG_RELAY=y
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -59,10 +60,14 @@ CONFIG_BUG=y
 CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
 CONFIG_EPOLL=y
 CONFIG_SHMEM=y
 CONFIG_SLAB=y
 CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
@@ -79,6 +84,7 @@ CONFIG_MODULE_SRCVERSION_ALL=y
 CONFIG_MODULE_SIG=y
 # CONFIG_MODULE_SIG_FORCE is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
 
 #
 # Process debugging support
@@ -123,21 +129,34 @@ CONFIG_X86_GOOD_APIC=y
 CONFIG_MICROCODE=m
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
+CONFIG_X86_HT=y
+# CONFIG_EFI is not set
 CONFIG_X86_IO_APIC=y
 CONFIG_X86_LOCAL_APIC=y
 CONFIG_MTRR=y
-# CONFIG_SMP is not set
+CONFIG_SMP=y
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
 CONFIG_PREEMPT_NONE=y
 # CONFIG_PREEMPT_VOLUNTARY is not set
 # CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_NUMA=y
+CONFIG_K8_NUMA=y
+CONFIG_NODES_SHIFT=6
+CONFIG_X86_64_ACPI_NUMA=y
+# CONFIG_NUMA_EMU is not set
+CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
+CONFIG_ARCH_DISCONTIGMEM_DEFAULT=y
 CONFIG_ARCH_SPARSEMEM_ENABLE=y
 CONFIG_ARCH_MEMORY_PROBE=y
-CONFIG_ARCH_FLATMEM_ENABLE=y
 CONFIG_SELECT_MEMORY_MODEL=y
 # CONFIG_FLATMEM_MANUAL is not set
 # CONFIG_DISCONTIGMEM_MANUAL is not set
 CONFIG_SPARSEMEM_MANUAL=y
 CONFIG_SPARSEMEM=y
+CONFIG_NEED_MULTIPLE_NODES=y
 CONFIG_HAVE_MEMORY_PRESENT=y
 # CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPARSEMEM_EXTREME=y
@@ -148,7 +167,11 @@ CONFIG_MEMORY_HOTPLUG=y
 #
 CONFIG_MEMORY_HOTPLUG_SPARSE=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_MIGRATION=y
 CONFIG_RESOURCES_64BIT=y
+CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
+CONFIG_NR_CPUS=255
+CONFIG_HOTPLUG_CPU=y
 CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
 CONFIG_TRACK_DIRTY_PAGES=y
 CONFIG_HPET_TIMER=y
@@ -157,6 +180,8 @@ CONFIG_TICK_DIVIDER=y
 CONFIG_IOMMU=y
 CONFIG_CALGARY_IOMMU=y
 # CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT is not set
+CONFIG_AMD_IOMMU=y
+CONFIG_IOMMU_HELPER=y
 CONFIG_SWIOTLB=y
 CONFIG_X86_MCE=y
 CONFIG_X86_MCE_INTEL=y
@@ -173,6 +198,7 @@ CONFIG_K8_NB=y
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_ISA_DMA_API=y
+CONFIG_GENERIC_PENDING_IRQ=y
 
 #
 # Power management options
@@ -182,6 +208,7 @@ CONFIG_PM_LEGACY=y
 # CONFIG_PM_DEBUG is not set
 CONFIG_SOFTWARE_SUSPEND=y
 CONFIG_PM_STD_PARTITION=""
+CONFIG_SUSPEND_SMP=y
 
 #
 # ACPI (Advanced Configuration and Power Interface) Support
@@ -199,10 +226,11 @@ CONFIG_ACPI_FAN=y
 CONFIG_ACPI_DOCK=y
 CONFIG_ACPI_BAY=y
 CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_HOTPLUG_CPU=y
 CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_NUMA=y
 CONFIG_ACPI_ASUS=m
-CONFIG_ACPI_IBM=m
-CONFIG_ACPI_IBM_BAY=y
+# CONFIG_ACPI_IBM is not set
 CONFIG_ACPI_TOSHIBA=m
 CONFIG_ACPI_BLACKLIST_YEAR=0
 # CONFIG_ACPI_DEBUG is not set
@@ -213,12 +241,17 @@ CONFIG_X86_PM_TIMER=y
 CONFIG_ACPI_CONTAINER=y
 CONFIG_ACPI_HOTPLUG_MEMORY=m
 CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
 
 #
 # CPU Frequency scaling
 #
 CONFIG_CPU_FREQ=y
-CONFIG_CPU_FREQ_TABLE=y
+CONFIG_CPU_FREQ_TABLE=m
 CONFIG_CPU_FREQ_DEBUG=y
 CONFIG_CPU_FREQ_STAT=m
 CONFIG_CPU_FREQ_STAT_DETAILS=y
@@ -233,9 +266,9 @@ CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
 #
 # CPUFreq processor drivers
 #
-CONFIG_X86_POWERNOW_K8=y
+CONFIG_X86_POWERNOW_K8=m
 CONFIG_X86_POWERNOW_K8_ACPI=y
-CONFIG_X86_SPEEDSTEP_CENTRINO=y
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
 CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
 CONFIG_X86_ACPI_CPUFREQ=m
 
@@ -251,9 +284,13 @@ CONFIG_X86_ACPI_CPUFREQ=m
 CONFIG_PCI=y
 CONFIG_PCI_DIRECT=y
 CONFIG_PCI_MMCONFIG=y
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
 CONFIG_PCIEPORTBUS=y
 CONFIG_HOTPLUG_PCI_PCIE=m
 # CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
 CONFIG_PCI_MSI=y
 # CONFIG_PCI_DEBUG is not set
 
@@ -361,6 +398,7 @@ CONFIG_TCP_CONG_VEGAS=m
 CONFIG_TCP_CONG_SCALABLE=m
 CONFIG_TCP_CONG_LP=m
 CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
 
 #
 # IP: Virtual Server Configuration
@@ -399,7 +437,7 @@ CONFIG_IPV6=m
 CONFIG_IPV6_PRIVACY=y
 CONFIG_IPV6_ROUTER_PREF=y
 CONFIG_IPV6_ROUTE_INFO=y
-# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_IPV6_OPTIMISTIC_DAD=y
 CONFIG_INET6_AH=m
 CONFIG_INET6_ESP=m
 CONFIG_INET6_IPCOMP=m
@@ -721,17 +759,27 @@ CONFIG_NL80211=y
 CONFIG_WIRELESS_EXT=y
 CONFIG_NET_WIRELESS_RTNETLINK=y
 CONFIG_MAC80211=m
-CONFIG_MAC80211_RCSIMPLE=y
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
 CONFIG_MAC80211_LEDS=y
 # CONFIG_MAC80211_DEBUGFS is not set
-CONFIG_MAC80211_DEBUG=y
-# CONFIG_MAC80211_HT_DEBUG is not set
-# CONFIG_MAC80211_VERBOSE_DEBUG is not set
-# CONFIG_MAC80211_LOWTX_FRAME_DUMP is not set
-# CONFIG_TKIP_DEBUG is not set
-# CONFIG_MAC80211_DEBUG_COUNTERS is not set
-# CONFIG_MAC80211_IBSS_DEBUG is not set
-# CONFIG_MAC80211_VERBOSE_PS_DEBUG is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
 CONFIG_IEEE80211=m
 # CONFIG_IEEE80211_DEBUG is not set
 CONFIG_IEEE80211_CRYPT_WEP=m
@@ -943,6 +991,7 @@ CONFIG_CDROM_PKTCDVD=m
 CONFIG_CDROM_PKTCDVD_BUFFERS=8
 # CONFIG_CDROM_PKTCDVD_WCACHE is not set
 CONFIG_ATA_OVER_ETH=m
+CONFIG_VIRTIO_BLK=m
 
 #
 # ATA/ATAPI/MFM/RLL support
@@ -1017,6 +1066,7 @@ CONFIG_IDEDMA_AUTO=y
 #
 CONFIG_RAID_ATTRS=m
 CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
 CONFIG_SCSI_NETLINK=y
 CONFIG_SCSI_PROC_FS=y
 
@@ -1047,12 +1097,14 @@ CONFIG_SCSI_FC_ATTRS=m
 # CONFIG_SCSI_ISCSI_ATTRS is not set
 CONFIG_SCSI_SAS_ATTRS=m
 CONFIG_SCSI_SAS_LIBSAS=m
-# CONFIG_SCSI_SAS_ATA is not set
+CONFIG_SCSI_SAS_ATA=y
 # CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
 
 #
 # SCSI low-level drivers
 #
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
 # CONFIG_ISCSI_TCP is not set
 CONFIG_BLK_DEV_3W_XXXX_RAID=m
 CONFIG_SCSI_3W_9XXX=m
@@ -1082,6 +1134,7 @@ CONFIG_MEGARAID_LEGACY=m
 CONFIG_MEGARAID_SAS=m
 CONFIG_SCSI_HPTIOP=m
 # CONFIG_SCSI_BUSLOGIC is not set
+CONFIG_FCOE_FNIC=m
 # CONFIG_SCSI_DMX3191D is not set
 # CONFIG_SCSI_EATA is not set
 # CONFIG_SCSI_FUTURE_DOMAIN is not set
@@ -1114,10 +1167,15 @@ CONFIG_SCSI_DC395x=m
 # CONFIG_PCMCIA_FDOMAIN is not set
 # CONFIG_PCMCIA_QLOGIC is not set
 # CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
 CONFIG_ATA=m
 # CONFIG_ATA_NONSTANDARD is not set
 CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
 CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
 CONFIG_SATA_SVW=m
 CONFIG_ATA_PIIX=m
 CONFIG_SATA_MV=m
@@ -1127,13 +1185,12 @@ CONFIG_SATA_QSTOR=m
 CONFIG_SATA_PROMISE=m
 CONFIG_SATA_SX4=m
 CONFIG_SATA_SIL=m
-CONFIG_SATA_SIL24=m
 CONFIG_SATA_SIS=m
 CONFIG_SATA_ULI=m
 CONFIG_SATA_VIA=m
 CONFIG_SATA_VITESSE=m
 CONFIG_SATA_INIC162X=m
-CONFIG_PATA_ACPI=m
+# CONFIG_PATA_ACPI is not set
 # CONFIG_PATA_ALI is not set
 # CONFIG_PATA_AMD is not set
 # CONFIG_PATA_ARTOP is not set
@@ -1157,8 +1214,9 @@ CONFIG_PATA_MARVELL=m
 # CONFIG_PATA_MPIIX is not set
 # CONFIG_PATA_OLDPIIX is not set
 # CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
 # CONFIG_PATA_NS87410 is not set
-CONFIG_PATA_NS87415=m
+# CONFIG_PATA_NS87415 is not set
 # CONFIG_PATA_OPTI is not set
 # CONFIG_PATA_OPTIDMA is not set
 # CONFIG_PATA_PCMCIA is not set
@@ -1168,10 +1226,11 @@ CONFIG_PATA_NS87415=m
 # CONFIG_PATA_SC1200 is not set
 # CONFIG_PATA_SERVERWORKS is not set
 CONFIG_PATA_PDC2027X=m
-# CONFIG_PATA_SIL680 is not set
+CONFIG_PATA_SIL680=m
 CONFIG_PATA_SIS=m
 # CONFIG_PATA_VIA is not set
 # CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
 CONFIG_ATA_INTEL_COMBINED=y
 
 #
@@ -1196,7 +1255,8 @@ CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
 CONFIG_DM_MULTIPATH_RDAC=m
 CONFIG_DM_MULTIPATH_HP=m
-# CONFIG_DM_UEVENT is not set
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
 
 #
 # Fusion MPT device support
@@ -1205,12 +1265,17 @@ CONFIG_FUSION=y
 CONFIG_FUSION_SPI=m
 CONFIG_FUSION_FC=m
 CONFIG_FUSION_SAS=m
-CONFIG_FUSION_MAX_SGE=40
+CONFIG_FUSION_MAX_SGE=128
 CONFIG_FUSION_CTL=m
 CONFIG_FUSION_LAN=m
-# CONFIG_FUSION_LOGGING is not set
+CONFIG_FUSION_LOGGING=y
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
 CONFIG_FIREWIRE=m
 CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
 CONFIG_FIREWIRE_SBP2=m
 
 #
@@ -1293,7 +1358,6 @@ CONFIG_WINBOND_840=m
 CONFIG_DM9102=m
 CONFIG_ULI526X=m
 CONFIG_PCMCIA_XIRCOM=m
-# CONFIG_PCMCIA_XIRTULIP is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 CONFIG_PCNET32=m
@@ -1317,7 +1381,8 @@ CONFIG_8139TOO_8129=y
 # CONFIG_8139_OLD_RX_RESET is not set
 CONFIG_SIS900=m
 CONFIG_EPIC100=m
-# CONFIG_SUNDANCE is not set
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
 CONFIG_VIA_RHINE=m
 CONFIG_VIA_RHINE_MMIO=y
 CONFIG_VIA_RHINE_NAPI=y
@@ -1341,7 +1406,6 @@ CONFIG_NS83820=m
 # CONFIG_HAMACHI is not set
 # CONFIG_YELLOWFIN is not set
 CONFIG_R8169=m
-CONFIG_R8169_NAPI=y
 CONFIG_R8169_VLAN=y
 CONFIG_SIS190=m
 CONFIG_SKGE=m
@@ -1356,17 +1420,18 @@ CONFIG_QLA3XXX=m
 # Ethernet (10000 Mbit)
 #
 CONFIG_CHELSIO_T1=m
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
 CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
 CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
+# CONFIG_MLX4_CORE is not set
 
 #
 # Token Ring devices
@@ -1428,6 +1493,8 @@ CONFIG_PCMCIA_WL3501=m
 #
 CONFIG_PRISM54=m
 CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
 CONFIG_HOSTAP=m
 CONFIG_HOSTAP_FIRMWARE=y
 CONFIG_HOSTAP_FIRMWARE_NVRAM=y
@@ -1444,12 +1511,42 @@ CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
 CONFIG_ZD1211RW=m
 # CONFIG_ZD1211RW_DEBUG is not set
 CONFIG_NET_WIRELESS=y
-CONFIG_IWL4965=m
-# CONFIG_IWL4965_QOS is not set
-# CONFIG_IWL4965_SPECTRUM_MEASUREMENT is not set
-# CONFIG_IWL4965_SENSITIVITY is not set
-# CONFIG_IWL4965_DEBUG is not set
-# CONFIG_IWL3945 is not set
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+# CONFIG_IWL3945_RFKILL is not set
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWL3945_LEDS is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
 
 #
 # PCMCIA network device support
@@ -1518,6 +1615,7 @@ CONFIG_NETPOLL=y
 # CONFIG_NETPOLL_RX is not set
 CONFIG_NETPOLL_TRAP=y
 CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
 
 #
 # ISDN subsystem
@@ -1539,7 +1637,6 @@ CONFIG_ISDN_TTY_FAX=y
 #
 # ISDN feature submodules
 #
-# CONFIG_ISDN_DRV_LOOP is not set
 CONFIG_ISDN_DIVERSION=m
 
 #
@@ -1606,7 +1703,6 @@ CONFIG_HISAX_HDLC=y
 #
 # Active cards
 #
-# CONFIG_HYSDN is not set
 
 #
 # Siemens Gigaset
@@ -1752,7 +1848,6 @@ CONFIG_SYNCLINK=m
 CONFIG_SYNCLINKMP=m
 CONFIG_SYNCLINK_GT=m
 CONFIG_N_HDLC=m
-# CONFIG_RISCOM8 is not set
 # CONFIG_SPECIALIX is not set
 # CONFIG_SX is not set
 # CONFIG_RIO is not set
@@ -1792,7 +1887,8 @@ CONFIG_PPDEV=m
 # IPMI
 #
 CONFIG_IPMI_HANDLER=m
-# CONFIG_IPMI_PANIC_EVENT is not set
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
 CONFIG_IPMI_DEVICE_INTERFACE=m
 CONFIG_IPMI_SI=m
 CONFIG_IPMI_WATCHDOG=m
@@ -1819,7 +1915,7 @@ CONFIG_IBMASR=m
 # CONFIG_WAFER_WDT is not set
 CONFIG_I6300ESB_WDT=m
 CONFIG_I8XX_TCO=m
-CONFIG_HP_WATCHDOG=m
+# CONFIG_HP_WATCHDOG is not set
 # CONFIG_SC1200_WDT is not set
 # CONFIG_60XX_WDT is not set
 # CONFIG_SBC8360_WDT is not set
@@ -1854,7 +1950,6 @@ CONFIG_DTLK=m
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 CONFIG_AGP=y
 CONFIG_AGP_AMD64=y
 CONFIG_AGP_INTEL=y
@@ -1887,8 +1982,12 @@ CONFIG_HPET=y
 # CONFIG_HPET_RTC_IRQ is not set
 # CONFIG_HPET_MMAP is not set
 CONFIG_HANGCHECK_TIMER=m
-# CONFIG_TCG_TPM is not set
-# CONFIG_TELCLOCK is not set
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
 
 #
 # I2C support
@@ -1914,7 +2013,7 @@ CONFIG_I2C_AMD756_S4882=m
 CONFIG_I2C_AMD8111=m
 CONFIG_I2C_I801=m
 # CONFIG_I2C_I810 is not set
-# CONFIG_I2C_PIIX4 is not set
+CONFIG_I2C_PIIX4=m
 CONFIG_I2C_ISA=m
 CONFIG_I2C_NFORCE2=m
 # CONFIG_I2C_OCORES is not set
@@ -2009,6 +2108,8 @@ CONFIG_SENSORS_HDAPS=m
 # Misc devices
 #
 # CONFIG_IBM_ASM is not set
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
 
 #
 # Multimedia devices
@@ -2064,6 +2165,7 @@ CONFIG_VIDEO_UPD64083=m
 #
 # V4L USB devices
 #
+CONFIG_USB_VIDEO_CLASS=m
 CONFIG_VIDEO_PVRUSB2=m
 CONFIG_VIDEO_PVRUSB2_24XXX=y
 CONFIG_VIDEO_PVRUSB2_SYSFS=y
@@ -2203,6 +2305,7 @@ CONFIG_SND_DYNAMIC_MINORS=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
 
 #
 # Generic devices
@@ -2260,6 +2363,8 @@ CONFIG_SND_ES1968=m
 CONFIG_SND_FM801=m
 CONFIG_SND_FM801_TEA575X_BOOL=y
 CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
 CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_HDSPM=m
@@ -2542,33 +2647,7 @@ CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_TIMER=m
 CONFIG_LEDS_TRIGGER_IDE_DISK=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=m
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_ISER=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC_STATS=y
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -2652,8 +2731,14 @@ CONFIG_EXT3_FS=m
 CONFIG_EXT3_FS_XATTR=y
 CONFIG_EXT3_FS_POSIX_ACL=y
 CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
 CONFIG_JBD=m
 # CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
@@ -2778,7 +2863,9 @@ CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
 # CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_DFS_UPCALL=y
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2893,6 +2980,9 @@ CONFIG_DEBUG_LIST=y
 # CONFIG_FORCED_INLINING is not set
 CONFIG_BOOT_DELAY=y
 # CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
 CONFIG_DEBUG_RODATA=y
 # CONFIG_IOMMU_DEBUG is not set
 CONFIG_DEBUG_STACKOVERFLOW=y
@@ -2924,11 +3014,13 @@ CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
 #
 CONFIG_CRYPTO=y
 CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
 CONFIG_CRYPTO_ALGAPI=m
 CONFIG_CRYPTO_AEAD=m
 CONFIG_CRYPTO_BLKCIPHER=m
 CONFIG_CRYPTO_SEQIV=m
 CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
 CONFIG_CRYPTO_MANAGER=m
 CONFIG_CRYPTO_HMAC=y
 CONFIG_CRYPTO_NHMAC=m
@@ -2960,26 +3052,38 @@ CONFIG_CRYPTO_ANUBIS=m
 CONFIG_CRYPTO_DEFLATE=m
 CONFIG_CRYPTO_MICHAEL_MIC=m
 CONFIG_CRYPTO_CRC32C=y
-# CONFIG_CRYPTO_TEST is not set
+CONFIG_CRYPTO_TEST=m
 CONFIG_CRYPTO_AUTHENC=m
 CONFIG_CRYPTO_SIGNATURE=y
 CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
 
 #
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
 # Hardware crypto devices
 #
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+
+#
+# Xen PV-ON-HVM Configuration
+#
+CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
 #
 CONFIG_CRC_CCITT=m
 CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
 CONFIG_LIBCRC32C=y
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=m
-CONFIG_GENERIC_ALLOCATOR=y
 CONFIG_REED_SOLOMON=m
 CONFIG_REED_SOLOMON_DEC16=y
 CONFIG_TEXTSEARCH=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-i686-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-i686-smp.config
new file mode 100644
index 0000000..f37a1b7
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-i686-smp.config
@@ -0,0 +1,3191 @@
+# i386
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.18-prep
+# Thu Feb 19 13:10:17 2009
+#
+CONFIG_X86_32=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_SEMAPHORE_SLEEPERS=y
+CONFIG_X86=y
+CONFIG_MMU=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_DMI=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+# CONFIG_IKCONFIG is not set
+CONFIG_CPUSETS=y
+CONFIG_RELAY=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_MODULE_SIG=y
+# CONFIG_MODULE_SIG_FORCE is not set
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+
+#
+# Process debugging support
+#
+CONFIG_PTRACE=y
+CONFIG_UTRACE=y
+
+#
+# Block layer
+#
+CONFIG_LBD=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_LSF=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+
+#
+# Processor type and features
+#
+CONFIG_SMP=y
+# CONFIG_X86_PC is not set
+CONFIG_X86_XEN=y
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_NUMAQ is not set
+# CONFIG_X86_SUMMIT is not set
+# CONFIG_X86_BIGSMP is not set
+# CONFIG_X86_VISWS is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_ES7000 is not set
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+CONFIG_M686=y
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_XADD=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_X86_PPRO_FENCE=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_CMPXCHG64=y
+CONFIG_X86_GOOD_APIC=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_USE_PPRO_CHECKSUM=y
+# CONFIG_TICK_DIVIDER is not set
+CONFIG_NR_CPUS=32
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_VM86=y
+CONFIG_TOSHIBA=m
+CONFIG_I8K=m
+# CONFIG_X86_REBOOTFIXUPS is not set
+CONFIG_MICROCODE=m
+CONFIG_X86_CPUID=m
+CONFIG_SWIOTLB=y
+
+#
+# Firmware Drivers
+#
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+# CONFIG_NOHIGHMEM is not set
+# CONFIG_HIGHMEM4G is not set
+CONFIG_HIGHMEM64G=y
+CONFIG_PAGE_OFFSET=0xC0000000
+CONFIG_HIGHMEM=y
+CONFIG_X86_PAE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+CONFIG_RESOURCES_64BIT=y
+CONFIG_MTRR=y
+CONFIG_REGPARM=y
+# CONFIG_SECCOMP is not set
+# CONFIG_VGA_NOPROBE is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+CONFIG_RELOCATABLE=y
+CONFIG_PHYSICAL_ALIGN=0x400000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+
+#
+# Power management options (ACPI, APM)
+#
+CONFIG_PM=y
+
+#
+# ACPI (Advanced Configuration and Power Interface) Support
+#
+CONFIG_ACPI=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+# CONFIG_ACPI_HOTKEY is not set
+CONFIG_ACPI_FAN=y
+CONFIG_ACPI_DOCK=y
+CONFIG_ACPI_BAY=y
+CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_ASUS=m
+# CONFIG_ACPI_IBM is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_BLACKLIST_YEAR=1999
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_ACPI_CONTAINER=y
+CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+CONFIG_CPU_FREQ_DEBUG=y
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+# CONFIG_X86_POWERNOW_K6 is not set
+CONFIG_X86_POWERNOW_K7=y
+CONFIG_X86_POWERNOW_K7_ACPI=y
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+# CONFIG_X86_GX_SUSPMOD is not set
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
+CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
+CONFIG_X86_SPEEDSTEP_ICH=y
+CONFIG_X86_SPEEDSTEP_SMI=y
+CONFIG_X86_P4_CLOCKMOD=m
+# CONFIG_X86_CPUFREQ_NFORCE2 is not set
+CONFIG_X86_LONGRUN=y
+# CONFIG_X86_LONGHAUL is not set
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+CONFIG_X86_SPEEDSTEP_LIB=y
+# CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_PCI=y
+# CONFIG_PCI_GOBIOS is not set
+# CONFIG_PCI_GOMMCONFIG is not set
+# CONFIG_PCI_GODIRECT is not set
+# CONFIG_PCI_GOXEN_FE is not set
+CONFIG_PCI_GOANY=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_XEN_PCIDEV_FRONTEND=y
+# CONFIG_XEN_PCIDEV_FE_DEBUG is not set
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_ISA_DMA_API=y
+# CONFIG_SCx200 is not set
+CONFIG_K8_NB=y
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=y
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+# CONFIG_I82092 is not set
+CONFIG_PCCARD_NONSTATIC=y
+
+#
+# PCI Hotplug Support
+#
+CONFIG_HOTPLUG_PCI=y
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+# CONFIG_HOTPLUG_PCI_CPCI is not set
+# CONFIG_HOTPLUG_PCI_SHPC is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_MISC=y
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_NALGO=m
+CONFIG_XFRM_USER=y
+CONFIG_NET_KEY=m
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_FWMARK=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+
+#
+# TCP congestion control
+#
+CONFIG_TCP_CONG_BIC=y
+CONFIG_TCP_CONG_CUBIC=m
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
+
+#
+# IP: Virtual Server Configuration
+#
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+# CONFIG_IPV6_SUBTREES is not set
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_ROUTE_FWMARK=y
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_CT_ACCT=y
+CONFIG_IP_NF_CONNTRACK_MARK=y
+CONFIG_IP_NF_CONNTRACK_SECMARK=y
+CONFIG_IP_NF_CONNTRACK_EVENTS=y
+CONFIG_IP_NF_CONNTRACK_NETLINK=m
+CONFIG_IP_NF_CT_PROTO_SCTP=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_NETBIOS_NS=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_PPTP=m
+CONFIG_IP_NF_H323=m
+CONFIG_IP_NF_SIP=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_NAT_PPTP=m
+CONFIG_IP_NF_NAT_H323=m
+CONFIG_IP_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration (EXPERIMENTAL)
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+CONFIG_IP_DCCP_CCID3=m
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+CONFIG_TIPC=m
+# CONFIG_TIPC_ADVANCED is not set
+# CONFIG_TIPC_DEBUG is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+# CONFIG_ATM_CLIP_NO_ICMP is not set
+CONFIG_ATM_LANE=m
+# CONFIG_ATM_MPOA is not set
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+# CONFIG_DECNET is not set
+CONFIG_LLC=y
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+CONFIG_NET_SCHED=y
+# CONFIG_NET_SCH_CLK_JIFFIES is not set
+CONFIG_NET_SCH_CLK_GETTIMEOFDAY=y
+# CONFIG_NET_SCH_CLK_CPU is not set
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+CONFIG_NET_EMATCH_CMP=m
+CONFIG_NET_EMATCH_NBYTE=m
+CONFIG_NET_EMATCH_U32=m
+CONFIG_NET_EMATCH_META=m
+CONFIG_NET_EMATCH_TEXT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_CLS_IND=y
+CONFIG_NET_ESTIMATOR=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIUSB=m
+CONFIG_BT_HCIUSB_SCO=y
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_TUX=m
+
+#
+# TUX options
+#
+CONFIG_TUX_EXTCGI=y
+CONFIG_TUX_EXTENDED_LOG=y
+# CONFIG_TUX_DEBUG is not set
+CONFIG_NETLABEL=y
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_NET_WIRELESS_RTNETLINK=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_IEEE80211_SOFTMAC=m
+CONFIG_IEEE80211_SOFTMAC_DEBUG=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLOCK=m
+CONFIG_MTD_BLOCK_RO=m
+CONFIG_FTL=m
+CONFIG_NFTL=m
+CONFIG_NFTL_RW=y
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+CONFIG_MTD_RAM=m
+CONFIG_MTD_ROM=m
+CONFIG_MTD_ABSENT=m
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PNC2000 is not set
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+# CONFIG_MTD_AMD76XROM is not set
+# CONFIG_MTD_ICHXROM is not set
+CONFIG_MTD_SCB2_FLASH=m
+# CONFIG_MTD_NETtel is not set
+# CONFIG_MTD_DILNETPC is not set
+# CONFIG_MTD_L440GX is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+# CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE is not set
+CONFIG_MTD_NAND_NANDSIM=m
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
+#
+# Parallel port support
+#
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+# CONFIG_PARPORT_PC_FIFO is not set
+# CONFIG_PARPORT_PC_SUPERIO is not set
+CONFIG_PARPORT_PC_PCMCIA=m
+CONFIG_PARPORT_NOT_PC=y
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
+
+#
+# Plug and Play support
+#
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_PNPACPI=y
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_FD=m
+CONFIG_PARIDE=m
+CONFIG_PARIDE_PARPORT=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_BPCK6=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=16384
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+CONFIG_ATA_OVER_ETH=m
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_IDECD=m
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_BLK_DEV_IDEFLOPPY=y
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_IDE_TASK_IOCTL=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+CONFIG_BLK_DEV_CMD640=y
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_RZ1000=y
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+CONFIG_BLK_DEV_AEC62XX=y
+CONFIG_BLK_DEV_ALI15X3=y
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+CONFIG_BLK_DEV_ATIIXP=y
+CONFIG_BLK_DEV_CMD64X=y
+CONFIG_BLK_DEV_TRIFLEX=y
+# CONFIG_BLK_DEV_CY82C693 is not set
+CONFIG_BLK_DEV_CS5520=y
+CONFIG_BLK_DEV_CS5530=y
+CONFIG_BLK_DEV_CS5535=y
+CONFIG_BLK_DEV_HPT34X=y
+# CONFIG_HPT34X_AUTODMA is not set
+CONFIG_BLK_DEV_HPT366=y
+# CONFIG_BLK_DEV_SC1200 is not set
+CONFIG_BLK_DEV_PIIX=y
+CONFIG_BLK_DEV_IT821X=y
+# CONFIG_BLK_DEV_NS87415 is not set
+CONFIG_BLK_DEV_PDC202XX_OLD=y
+# CONFIG_PDC202XX_BURST is not set
+CONFIG_BLK_DEV_PDC202XX_NEW=y
+CONFIG_BLK_DEV_SVWKS=y
+CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_BLK_DEV_SIS5513=y
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+
+#
+# SCSI Transport
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
+
+#
+# SCSI low-level drivers
+#
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_ISCSI_TCP=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=4
+CONFIG_AIC7XXX_RESET_DELAY_MS=15000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=4
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC94XX=m
+# CONFIG_AIC94XX_DEBUG is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ADVANSYS is not set
+CONFIG_SCSI_ARCMSR=m
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+# CONFIG_SCSI_INIA100 is not set
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+# CONFIG_SCSI_IPR is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_DC395x=m
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# PCMCIA SCSI adapter support
+#
+# CONFIG_PCMCIA_AHA152X is not set
+CONFIG_PCMCIA_FDOMAIN=m
+# CONFIG_PCMCIA_NINJA_SCSI is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+# CONFIG_PATA_ACPI is not set
+# CONFIG_PATA_ALI is not set
+# CONFIG_PATA_AMD is not set
+# CONFIG_PATA_ARTOP is not set
+# CONFIG_PATA_ATIIXP is not set
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_CMD64X is not set
+# CONFIG_PATA_CS5520 is not set
+# CONFIG_PATA_CS5530 is not set
+# CONFIG_PATA_CS5535 is not set
+# CONFIG_PATA_CS5536 is not set
+# CONFIG_PATA_CYPRESS is not set
+# CONFIG_PATA_EFAR is not set
+# CONFIG_ATA_GENERIC is not set
+# CONFIG_PATA_HPT366 is not set
+# CONFIG_PATA_HPT37X is not set
+# CONFIG_PATA_HPT3X2N is not set
+# CONFIG_PATA_HPT3X3 is not set
+# CONFIG_PATA_IT821X is not set
+# CONFIG_PATA_IT8213 is not set
+# CONFIG_PATA_JMICRON is not set
+# CONFIG_PATA_TRIFLEX is not set
+CONFIG_PATA_MARVELL=m
+# CONFIG_PATA_MPIIX is not set
+# CONFIG_PATA_OLDPIIX is not set
+# CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
+# CONFIG_PATA_NS87410 is not set
+# CONFIG_PATA_NS87415 is not set
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_OPTIDMA is not set
+# CONFIG_PATA_PCMCIA is not set
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_RADISYS is not set
+# CONFIG_PATA_RZ1000 is not set
+# CONFIG_PATA_SC1200 is not set
+# CONFIG_PATA_SERVERWORKS is not set
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+# CONFIG_PATA_VIA is not set
+# CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
+CONFIG_ATA_INTEL_COMBINED=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_MULTIPATH_EMC=m
+CONFIG_DM_MULTIPATH_RDAC=m
+CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+
+#
+# Fusion MPT device support
+#
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+CONFIG_FUSION_LOGGING=y
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+CONFIG_FIREWIRE=m
+CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
+CONFIG_FIREWIRE_SBP2=m
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+CONFIG_I2O=m
+# CONFIG_I2O_LCT_NOTIFY_ON_CHANGES is not set
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_EXT_ADAPTEC_DMA64=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+# CONFIG_NET_SB1000 is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# PHY device support
+#
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_FIXED_PHY=m
+CONFIG_FIXED_MII_10_FDX=y
+CONFIG_FIXED_MII_100_FDX=y
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+
+#
+# Tulip family network device support
+#
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+CONFIG_TULIP_MMIO=y
+# CONFIG_TULIP_NAPI is not set
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_AMD8111E_NAPI=y
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_B44=m
+CONFIG_FORCEDETH=m
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+CONFIG_VIA_RHINE_MMIO=y
+CONFIG_VIA_RHINE_NAPI=y
+CONFIG_NET_POCKET=y
+# CONFIG_ATP is not set
+# CONFIG_DE600 is not set
+# CONFIG_DE620 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IGB=m
+CONFIG_NS83820=m
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+CONFIG_SKY2=m
+# CONFIG_SK98LIN is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+
+#
+# Ethernet (10000 Mbit)
+#
+CONFIG_CHELSIO_T1=m
+# CONFIG_CHELSIO_T3 is not set
+CONFIG_IXGBE=m
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_BNX2X=m
+# CONFIG_MLX4_CORE is not set
+
+#
+# Token Ring devices
+#
+CONFIG_TR=y
+CONFIG_IBMOL=m
+CONFIG_IBMLS=m
+CONFIG_3C359=m
+# CONFIG_TMS380TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+CONFIG_NET_RADIO=y
+
+#
+# Obsolete Wireless cards support (pre-802.11)
+#
+# CONFIG_STRIP is not set
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+
+#
+# Wireless 802.11 Frequency Hopping cards support
+#
+# CONFIG_PCMCIA_RAYCS is not set
+
+#
+# Wireless 802.11b ISA/PCI cards support
+#
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+
+#
+# Wireless 802.11b Pcmcia/Cardbus cards support
+#
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_PCMCIA_WL3501=m
+
+#
+# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
+#
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_BCM43XX=m
+CONFIG_BCM43XX_DEBUG=y
+CONFIG_BCM43XX_DMA=y
+CONFIG_BCM43XX_PIO=y
+CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
+# CONFIG_BCM43XX_DMA_MODE is not set
+# CONFIG_BCM43XX_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_NET_WIRELESS=y
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+# CONFIG_IWL3945_RFKILL is not set
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWL3945_LEDS is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# PCMCIA network device support
+#
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_PCMCIA_IBMTR=m
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# ATM drivers
+#
+# CONFIG_ATM_DUMMY is not set
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+# CONFIG_ATM_ZATM is not set
+CONFIG_ATM_NICSTAR=m
+# CONFIG_ATM_NICSTAR_USE_SUNI is not set
+# CONFIG_ATM_NICSTAR_USE_IDT77105 is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+# CONFIG_ATM_IDT77252_RCV_ALL is not set
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+# CONFIG_ATM_IA is not set
+CONFIG_ATM_FORE200E_MAYBE=m
+# CONFIG_ATM_FORE200E_PCA is not set
+CONFIG_ATM_HE=m
+# CONFIG_ATM_HE_USE_SUNI is not set
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+# CONFIG_SKFP is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+# CONFIG_SLIP_MODE_SLIP6 is not set
+CONFIG_NET_FC=y
+# CONFIG_SHAPER is not set
+CONFIG_NETCONSOLE=m
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+
+#
+# ISDN subsystem
+#
+CONFIG_ISDN=m
+
+#
+# Old ISDN4Linux
+#
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+# CONFIG_ISDN_PPP_BSDCOMP is not set
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+CONFIG_HISAX_NO_SENDCOMPLETE=y
+CONFIG_HISAX_NO_LLC=y
+CONFIG_HISAX_NO_KEYPAD=y
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+# CONFIG_HISAX_DEBUG is not set
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+# CONFIG_HISAX_HFCUSB is not set
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+
+#
+# Siemens Gigaset
+#
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+# CONFIG_GIGASET_DEBUG is not set
+# CONFIG_GIGASET_UNDOCREQ is not set
+
+#
+# CAPI subsystem
+#
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+
+#
+# Active AVM cards
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+
+#
+# Active Eicon DIVA Server cards
+#
+CONFIG_CAPI_EICON=y
+CONFIG_ISDN_DIVAS=m
+CONFIG_ISDN_DIVAS_BRIPCI=y
+CONFIG_ISDN_DIVAS_PRIPCI=y
+CONFIG_ISDN_DIVAS_DIVACAPI=m
+CONFIG_ISDN_DIVAS_USERIDI=m
+CONFIG_ISDN_DIVAS_MAINT=m
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+# CONFIG_INPUT_TSDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_VSXXXAA=m
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_ANALOG is not set
+# CONFIG_JOYSTICK_A3D is not set
+# CONFIG_JOYSTICK_ADI is not set
+# CONFIG_JOYSTICK_COBRA is not set
+# CONFIG_JOYSTICK_GF2K is not set
+# CONFIG_JOYSTICK_GRIP is not set
+# CONFIG_JOYSTICK_GRIP_MP is not set
+# CONFIG_JOYSTICK_GUILLEMOT is not set
+# CONFIG_JOYSTICK_INTERACT is not set
+# CONFIG_JOYSTICK_SIDEWINDER is not set
+# CONFIG_JOYSTICK_TMDC is not set
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+CONFIG_JOYSTICK_TWIDJOY=m
+# CONFIG_JOYSTICK_DB9 is not set
+# CONFIG_JOYSTICK_GAMECON is not set
+# CONFIG_JOYSTICK_TURBOGRAFX is not set
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_WISTRON_BTNS=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_ISI is not set
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=m
+CONFIG_SERIAL_8250_PCI=m
+CONFIG_SERIAL_8250_PNP=m
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=32
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=m
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_CRASH=m
+CONFIG_PRINTER=m
+CONFIG_LP_CONSOLE=y
+CONFIG_PPDEV=m
+# CONFIG_TIPAR is not set
+
+#
+# IPMI
+#
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+# CONFIG_ACQUIRE_WDT is not set
+# CONFIG_ADVANTECH_WDT is not set
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+# CONFIG_SC520_WDT is not set
+# CONFIG_EUROTECH_WDT is not set
+# CONFIG_IB700_WDT is not set
+CONFIG_IBMASR=m
+# CONFIG_WAFER_WDT is not set
+CONFIG_I6300ESB_WDT=m
+CONFIG_I8XX_TCO=m
+CONFIG_HP_WATCHDOG=m
+# CONFIG_SC1200_WDT is not set
+# CONFIG_60XX_WDT is not set
+# CONFIG_SBC8360_WDT is not set
+# CONFIG_CPU5_WDT is not set
+CONFIG_W83627HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+# CONFIG_SBC_EPX_C3_WATCHDOG is not set
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_HW_RANDOM_GEODE=m
+CONFIG_HW_RANDOM_VIA=m
+CONFIG_NVRAM=y
+CONFIG_RTC=y
+CONFIG_DTLK=m
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+CONFIG_SONYPI=m
+
+#
+# Ftape, the floppy tape device driver
+#
+CONFIG_AGP=y
+CONFIG_AGP_ALI=y
+CONFIG_AGP_ATI=y
+CONFIG_AGP_AMD=y
+CONFIG_AGP_AMD64=y
+CONFIG_AGP_INTEL=y
+CONFIG_AGP_NVIDIA=y
+CONFIG_AGP_SIS=y
+CONFIG_AGP_SWORKS=y
+CONFIG_AGP_VIA=y
+CONFIG_AGP_EFFICEON=y
+CONFIG_DRM=m
+# CONFIG_DRM_TDFX is not set
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+# CONFIG_DRM_SIS is not set
+CONFIG_DRM_VIA=m
+CONFIG_DRM_SAVAGE=m
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+# CONFIG_MWAVE is not set
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_CS5535_GPIO=m
+CONFIG_RAW_DRIVER=y
+CONFIG_MAX_RAW_DEVS=8192
+CONFIG_HPET=y
+# CONFIG_HPET_RTC_IRQ is not set
+# CONFIG_HPET_MMAP is not set
+CONFIG_HANGCHECK_TIMER=m
+# CONFIG_TCG_TPM is not set
+CONFIG_TELCLOCK=m
+
+#
+# I2C support
+#
+CONFIG_I2C=m
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_I810=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_ISA=m
+CONFIG_I2C_NFORCE2=m
+# CONFIG_I2C_OCORES is not set
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_PROSAVAGE=m
+CONFIG_I2C_SAVAGE4=m
+# CONFIG_SCx200_ACB is not set
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_STUB=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+CONFIG_I2C_VOODOO3=m
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_SENSORS_DS1337=m
+CONFIG_SENSORS_DS1374=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_SENSORS_PCA9539=m
+CONFIG_SENSORS_PCF8591=m
+CONFIG_SENSORS_MAX6875=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Misc devices
+#
+CONFIG_IBM_ASM=m
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
+
+#
+# Video Capture Adapters
+#
+
+#
+# Video Capture Adapters
+#
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_VIVI is not set
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_SAA6588=m
+# CONFIG_VIDEO_BWQCAM is not set
+# CONFIG_VIDEO_CQCAM is not set
+# CONFIG_VIDEO_W9966 is not set
+# CONFIG_VIDEO_CPIA is not set
+CONFIG_VIDEO_CPIA2=m
+# CONFIG_VIDEO_SAA5246A is not set
+# CONFIG_VIDEO_SAA5249 is not set
+# CONFIG_TUNER_3036 is not set
+# CONFIG_VIDEO_STRADIS is not set
+# CONFIG_VIDEO_ZORAN is not set
+# CONFIG_VIDEO_MEYE is not set
+# CONFIG_VIDEO_SAA7134 is not set
+# CONFIG_VIDEO_MXB is not set
+# CONFIG_VIDEO_DPC is not set
+# CONFIG_VIDEO_HEXIUM_ORION is not set
+# CONFIG_VIDEO_HEXIUM_GEMINI is not set
+# CONFIG_VIDEO_CX88 is not set
+
+#
+# Encoders and Decoders
+#
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_TLV320AIC23B=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+
+#
+# V4L USB devices
+#
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_24XXX=y
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+
+#
+# Radio Adapters
+#
+# CONFIG_RADIO_GEMTEK_PCI is not set
+# CONFIG_RADIO_MAXIRADIO is not set
+# CONFIG_RADIO_MAESTRO is not set
+CONFIG_USB_DSBR=m
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_BUF=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+# CONFIG_FIRMWARE_EDID is not set
+CONFIG_FB=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ARC is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+CONFIG_FB_VGA16=m
+CONFIG_FB_VESA=y
+# CONFIG_FB_HGA is not set
+# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+CONFIG_FB_RIVA=m
+# CONFIG_FB_RIVA_I2C is not set
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_I810=m
+CONFIG_FB_I810_GTF=y
+CONFIG_FB_I810_I2C=y
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_RADEON is not set
+# CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+# CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
+CONFIG_FB_KYRO=m
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+CONFIG_FB_CYBLA=m
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_GEODE is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=m
+CONFIG_BACKLIGHT_DEVICE=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_DEVICE=y
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_RTCTIMER=m
+CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y
+CONFIG_SND_DYNAMIC_MINORS=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
+
+#
+# Generic devices
+#
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+# CONFIG_SND_MTS64 is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+CONFIG_SND_MPU401=m
+# CONFIG_SND_PORTMAN2X4 is not set
+
+#
+# PCI devices
+#
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS5535AUDIO=m
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+# CONFIG_SND_AC97_POWER_SAVE is not set
+
+#
+# USB devices
+#
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+
+#
+# PCMCIA devices
+#
+# CONFIG_SND_VXPOCKET is not set
+# CONFIG_SND_PDAUDIOCF is not set
+
+#
+# SoC audio support
+#
+# CONFIG_SND_SOC is not set
+
+#
+# Open Sound System
+#
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_SPLIT_ISO=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT=y
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_USB_HIDDEV=y
+CONFIG_USB_AIPTEK=m
+CONFIG_USB_WACOM=m
+CONFIG_USB_ACECAD=m
+CONFIG_USB_KBTAB=m
+CONFIG_USB_POWERMATE=m
+CONFIG_USB_TOUCHSCREEN=m
+CONFIG_USB_TOUCHSCREEN_EGALAX=y
+CONFIG_USB_TOUCHSCREEN_PANJIT=y
+CONFIG_USB_TOUCHSCREEN_3M=y
+CONFIG_USB_TOUCHSCREEN_ITM=y
+# CONFIG_USB_YEALINK is not set
+CONFIG_USB_XPAD=m
+CONFIG_USB_ATI_REMOTE=m
+CONFIG_USB_ATI_REMOTE2=m
+CONFIG_USB_KEYSPAN_REMOTE=m
+CONFIG_USB_APPLETOUCH=m
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+
+#
+# USB Serial Converter support
+#
+CONFIG_USB_SERIAL=m
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRPRIME=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_EZUSB=y
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_AUERSWALD=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_LED=m
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TEST=m
+
+#
+# USB DSL modem support
+#
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_WBSD=m
+
+#
+# LED devices
+#
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_AMD76X=m
+CONFIG_EDAC_E7XXX=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I82875P=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_I82860=m
+CONFIG_EDAC_K8=m
+CONFIG_EDAC_R82600=m
+CONFIG_EDAC_POLL=y
+
+#
+# Real Time Clock
+#
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=m
+CONFIG_RTC_INTF_PROC=m
+CONFIG_RTC_INTF_DEV=m
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+
+#
+# RTC drivers
+#
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_RS5C372=m
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_TEST is not set
+CONFIG_RTC_DRV_V3020=m
+
+#
+# DMA Engine support
+#
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT2_FS_XIP=y
+CONFIG_FS_XIP=y
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_NOLOCK=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+CONFIG_AUTOFS4_FS=m
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+CONFIG_FSCACHE=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+CONFIG_CACHEFILES=m
+CONFIG_CACHEFILES_DEBUG=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+CONFIG_JFFS2_SUMMARY=y
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+# CONFIG_SQUASHFS_VMALLOC is not set
+CONFIG_VXFS_FS=m
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_FSCACHE=y
+CONFIG_NFS_DIRECTIO=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_DFS_UPCALL=y
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+# CONFIG_ATARI_PARTITION is not set
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+# CONFIG_LDM_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Distributed Lock Manager
+#
+CONFIG_DLM=m
+CONFIG_DLM_DEBUG=y
+
+#
+# Instrumentation Support
+#
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=m
+CONFIG_KPROBES=y
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHEDSTATS=y
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_HIGHMEM=y
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_FS=y
+# CONFIG_DEBUG_VM is not set
+CONFIG_DEBUG_LIST=y
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_FORCED_INLINING is not set
+CONFIG_BOOT_DELAY=y
+# CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
+CONFIG_EARLY_PRINTK=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+CONFIG_DEBUG_STACK_USAGE=y
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_DEBUG_RODATA=y
+# CONFIG_4KSTACKS is not set
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_NETWORK_XFRM=y
+CONFIG_SECURITY_CAPABILITIES=y
+# CONFIG_SECURITY_ROOTPLUG is not set
+# CONFIG_SECURITY_SECLVL is not set
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
+CONFIG_CRYPTO_ALGAPI=m
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NHMAC=m
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_586=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_SIGNATURE=y
+CONFIG_CRYPTO_SIGNATURE_DSA=y
+CONFIG_CRYPTO_MPILIB=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
+# Hardware crypto devices
+#
+CONFIG_CRYPTO_DEV_PADLOCK=m
+CONFIG_CRYPTO_DEV_PADLOCK_AES=y
+CONFIG_XEN=y
+CONFIG_XEN_INTERFACE_VERSION=0x00030203
+
+#
+# XEN
+#
+CONFIG_XEN_PRIVILEGED_GUEST=y
+# CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_PRIVCMD=y
+CONFIG_XEN_XENBUS_DEV=y
+CONFIG_XEN_BACKEND=y
+CONFIG_XEN_BLKDEV_BACKEND=m
+CONFIG_XEN_BLKDEV_TAP=m
+CONFIG_XEN_NETDEV_BACKEND=m
+# CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=m
+CONFIG_XEN_PCIDEV_BACKEND=m
+CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
+# CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
+# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
+# CONFIG_XEN_PCIDEV_BE_DEBUG is not set
+# CONFIG_XEN_TPMDEV_BACKEND is not set
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
+CONFIG_XEN_SCRUB_PAGES=y
+# CONFIG_XEN_DISABLE_SERIAL is not set
+CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
+CONFIG_HAVE_ARCH_ALLOC_SKB=y
+CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
+CONFIG_HAVE_IRQ_IGNORE_UNHANDLED=y
+CONFIG_NO_IDLE_HZ=y
+CONFIG_XEN_UTIL=y
+CONFIG_XEN_BALLOON=y
+CONFIG_XEN_DEVMEM=y
+CONFIG_XEN_SKBUFF=y
+CONFIG_XEN_REBOOT=y
+CONFIG_XEN_SMPBOOT=y
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=y
+CONFIG_AUDIT_GENERIC=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
+CONFIG_X86_NO_TSS=y
+CONFIG_X86_NO_IDT=y
+CONFIG_KTIME_SCALAR=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-i686.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-i686.config
new file mode 100644
index 0000000..f37a1b7
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-i686.config
@@ -0,0 +1,3191 @@
+# i386
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.18-prep
+# Thu Feb 19 13:10:17 2009
+#
+CONFIG_X86_32=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_SEMAPHORE_SLEEPERS=y
+CONFIG_X86=y
+CONFIG_MMU=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_DMI=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+# CONFIG_IKCONFIG is not set
+CONFIG_CPUSETS=y
+CONFIG_RELAY=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_MODULE_SIG=y
+# CONFIG_MODULE_SIG_FORCE is not set
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+
+#
+# Process debugging support
+#
+CONFIG_PTRACE=y
+CONFIG_UTRACE=y
+
+#
+# Block layer
+#
+CONFIG_LBD=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_LSF=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+
+#
+# Processor type and features
+#
+CONFIG_SMP=y
+# CONFIG_X86_PC is not set
+CONFIG_X86_XEN=y
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_NUMAQ is not set
+# CONFIG_X86_SUMMIT is not set
+# CONFIG_X86_BIGSMP is not set
+# CONFIG_X86_VISWS is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_ES7000 is not set
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+CONFIG_M686=y
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_XADD=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_X86_PPRO_FENCE=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_CMPXCHG64=y
+CONFIG_X86_GOOD_APIC=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_USE_PPRO_CHECKSUM=y
+# CONFIG_TICK_DIVIDER is not set
+CONFIG_NR_CPUS=32
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_VM86=y
+CONFIG_TOSHIBA=m
+CONFIG_I8K=m
+# CONFIG_X86_REBOOTFIXUPS is not set
+CONFIG_MICROCODE=m
+CONFIG_X86_CPUID=m
+CONFIG_SWIOTLB=y
+
+#
+# Firmware Drivers
+#
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+# CONFIG_NOHIGHMEM is not set
+# CONFIG_HIGHMEM4G is not set
+CONFIG_HIGHMEM64G=y
+CONFIG_PAGE_OFFSET=0xC0000000
+CONFIG_HIGHMEM=y
+CONFIG_X86_PAE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+CONFIG_RESOURCES_64BIT=y
+CONFIG_MTRR=y
+CONFIG_REGPARM=y
+# CONFIG_SECCOMP is not set
+# CONFIG_VGA_NOPROBE is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+CONFIG_RELOCATABLE=y
+CONFIG_PHYSICAL_ALIGN=0x400000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+
+#
+# Power management options (ACPI, APM)
+#
+CONFIG_PM=y
+
+#
+# ACPI (Advanced Configuration and Power Interface) Support
+#
+CONFIG_ACPI=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+# CONFIG_ACPI_HOTKEY is not set
+CONFIG_ACPI_FAN=y
+CONFIG_ACPI_DOCK=y
+CONFIG_ACPI_BAY=y
+CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_ASUS=m
+# CONFIG_ACPI_IBM is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_BLACKLIST_YEAR=1999
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_ACPI_CONTAINER=y
+CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+CONFIG_CPU_FREQ_DEBUG=y
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+# CONFIG_X86_POWERNOW_K6 is not set
+CONFIG_X86_POWERNOW_K7=y
+CONFIG_X86_POWERNOW_K7_ACPI=y
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+# CONFIG_X86_GX_SUSPMOD is not set
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
+CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
+CONFIG_X86_SPEEDSTEP_ICH=y
+CONFIG_X86_SPEEDSTEP_SMI=y
+CONFIG_X86_P4_CLOCKMOD=m
+# CONFIG_X86_CPUFREQ_NFORCE2 is not set
+CONFIG_X86_LONGRUN=y
+# CONFIG_X86_LONGHAUL is not set
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+CONFIG_X86_SPEEDSTEP_LIB=y
+# CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK is not set
+
+#
+# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
+#
+CONFIG_PCI=y
+# CONFIG_PCI_GOBIOS is not set
+# CONFIG_PCI_GOMMCONFIG is not set
+# CONFIG_PCI_GODIRECT is not set
+# CONFIG_PCI_GOXEN_FE is not set
+CONFIG_PCI_GOANY=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_XEN_PCIDEV_FRONTEND=y
+# CONFIG_XEN_PCIDEV_FE_DEBUG is not set
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_ISA_DMA_API=y
+# CONFIG_SCx200 is not set
+CONFIG_K8_NB=y
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=y
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+# CONFIG_I82092 is not set
+CONFIG_PCCARD_NONSTATIC=y
+
+#
+# PCI Hotplug Support
+#
+CONFIG_HOTPLUG_PCI=y
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+# CONFIG_HOTPLUG_PCI_CPCI is not set
+# CONFIG_HOTPLUG_PCI_SHPC is not set
+
+#
+# Executable file formats
+#
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_MISC=y
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_NALGO=m
+CONFIG_XFRM_USER=y
+CONFIG_NET_KEY=m
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_FWMARK=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+
+#
+# TCP congestion control
+#
+CONFIG_TCP_CONG_BIC=y
+CONFIG_TCP_CONG_CUBIC=m
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
+
+#
+# IP: Virtual Server Configuration
+#
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+# CONFIG_IPV6_SUBTREES is not set
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_ROUTE_FWMARK=y
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_CT_ACCT=y
+CONFIG_IP_NF_CONNTRACK_MARK=y
+CONFIG_IP_NF_CONNTRACK_SECMARK=y
+CONFIG_IP_NF_CONNTRACK_EVENTS=y
+CONFIG_IP_NF_CONNTRACK_NETLINK=m
+CONFIG_IP_NF_CT_PROTO_SCTP=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_NETBIOS_NS=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_PPTP=m
+CONFIG_IP_NF_H323=m
+CONFIG_IP_NF_SIP=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_NAT_PPTP=m
+CONFIG_IP_NF_NAT_H323=m
+CONFIG_IP_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration (EXPERIMENTAL)
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+CONFIG_IP_DCCP_CCID3=m
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+CONFIG_TIPC=m
+# CONFIG_TIPC_ADVANCED is not set
+# CONFIG_TIPC_DEBUG is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+# CONFIG_ATM_CLIP_NO_ICMP is not set
+CONFIG_ATM_LANE=m
+# CONFIG_ATM_MPOA is not set
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+# CONFIG_DECNET is not set
+CONFIG_LLC=y
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+CONFIG_NET_SCHED=y
+# CONFIG_NET_SCH_CLK_JIFFIES is not set
+CONFIG_NET_SCH_CLK_GETTIMEOFDAY=y
+# CONFIG_NET_SCH_CLK_CPU is not set
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+CONFIG_NET_EMATCH_CMP=m
+CONFIG_NET_EMATCH_NBYTE=m
+CONFIG_NET_EMATCH_U32=m
+CONFIG_NET_EMATCH_META=m
+CONFIG_NET_EMATCH_TEXT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_CLS_IND=y
+CONFIG_NET_ESTIMATOR=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIUSB=m
+CONFIG_BT_HCIUSB_SCO=y
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_TUX=m
+
+#
+# TUX options
+#
+CONFIG_TUX_EXTCGI=y
+CONFIG_TUX_EXTENDED_LOG=y
+# CONFIG_TUX_DEBUG is not set
+CONFIG_NETLABEL=y
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_NET_WIRELESS_RTNETLINK=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_IEEE80211_SOFTMAC=m
+CONFIG_IEEE80211_SOFTMAC_DEBUG=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLOCK=m
+CONFIG_MTD_BLOCK_RO=m
+CONFIG_FTL=m
+CONFIG_NFTL=m
+CONFIG_NFTL_RW=y
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+CONFIG_MTD_RAM=m
+CONFIG_MTD_ROM=m
+CONFIG_MTD_ABSENT=m
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PNC2000 is not set
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+# CONFIG_MTD_AMD76XROM is not set
+# CONFIG_MTD_ICHXROM is not set
+CONFIG_MTD_SCB2_FLASH=m
+# CONFIG_MTD_NETtel is not set
+# CONFIG_MTD_DILNETPC is not set
+# CONFIG_MTD_L440GX is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+# CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE is not set
+CONFIG_MTD_NAND_NANDSIM=m
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
+#
+# Parallel port support
+#
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+# CONFIG_PARPORT_PC_FIFO is not set
+# CONFIG_PARPORT_PC_SUPERIO is not set
+CONFIG_PARPORT_PC_PCMCIA=m
+CONFIG_PARPORT_NOT_PC=y
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
+
+#
+# Plug and Play support
+#
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_PNPACPI=y
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_FD=m
+CONFIG_PARIDE=m
+CONFIG_PARIDE_PARPORT=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_BPCK6=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=16384
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+CONFIG_ATA_OVER_ETH=m
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_IDECD=m
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_BLK_DEV_IDEFLOPPY=y
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_IDE_TASK_IOCTL=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+CONFIG_BLK_DEV_CMD640=y
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_RZ1000=y
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+CONFIG_BLK_DEV_AEC62XX=y
+CONFIG_BLK_DEV_ALI15X3=y
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+CONFIG_BLK_DEV_ATIIXP=y
+CONFIG_BLK_DEV_CMD64X=y
+CONFIG_BLK_DEV_TRIFLEX=y
+# CONFIG_BLK_DEV_CY82C693 is not set
+CONFIG_BLK_DEV_CS5520=y
+CONFIG_BLK_DEV_CS5530=y
+CONFIG_BLK_DEV_CS5535=y
+CONFIG_BLK_DEV_HPT34X=y
+# CONFIG_HPT34X_AUTODMA is not set
+CONFIG_BLK_DEV_HPT366=y
+# CONFIG_BLK_DEV_SC1200 is not set
+CONFIG_BLK_DEV_PIIX=y
+CONFIG_BLK_DEV_IT821X=y
+# CONFIG_BLK_DEV_NS87415 is not set
+CONFIG_BLK_DEV_PDC202XX_OLD=y
+# CONFIG_PDC202XX_BURST is not set
+CONFIG_BLK_DEV_PDC202XX_NEW=y
+CONFIG_BLK_DEV_SVWKS=y
+CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_BLK_DEV_SIS5513=y
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+
+#
+# SCSI Transport
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
+
+#
+# SCSI low-level drivers
+#
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_ISCSI_TCP=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=4
+CONFIG_AIC7XXX_RESET_DELAY_MS=15000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=4
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC94XX=m
+# CONFIG_AIC94XX_DEBUG is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ADVANSYS is not set
+CONFIG_SCSI_ARCMSR=m
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+# CONFIG_SCSI_INIA100 is not set
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+# CONFIG_SCSI_IPR is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_DC395x=m
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# PCMCIA SCSI adapter support
+#
+# CONFIG_PCMCIA_AHA152X is not set
+CONFIG_PCMCIA_FDOMAIN=m
+# CONFIG_PCMCIA_NINJA_SCSI is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+# CONFIG_PATA_ACPI is not set
+# CONFIG_PATA_ALI is not set
+# CONFIG_PATA_AMD is not set
+# CONFIG_PATA_ARTOP is not set
+# CONFIG_PATA_ATIIXP is not set
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_CMD64X is not set
+# CONFIG_PATA_CS5520 is not set
+# CONFIG_PATA_CS5530 is not set
+# CONFIG_PATA_CS5535 is not set
+# CONFIG_PATA_CS5536 is not set
+# CONFIG_PATA_CYPRESS is not set
+# CONFIG_PATA_EFAR is not set
+# CONFIG_ATA_GENERIC is not set
+# CONFIG_PATA_HPT366 is not set
+# CONFIG_PATA_HPT37X is not set
+# CONFIG_PATA_HPT3X2N is not set
+# CONFIG_PATA_HPT3X3 is not set
+# CONFIG_PATA_IT821X is not set
+# CONFIG_PATA_IT8213 is not set
+# CONFIG_PATA_JMICRON is not set
+# CONFIG_PATA_TRIFLEX is not set
+CONFIG_PATA_MARVELL=m
+# CONFIG_PATA_MPIIX is not set
+# CONFIG_PATA_OLDPIIX is not set
+# CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
+# CONFIG_PATA_NS87410 is not set
+# CONFIG_PATA_NS87415 is not set
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_OPTIDMA is not set
+# CONFIG_PATA_PCMCIA is not set
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_RADISYS is not set
+# CONFIG_PATA_RZ1000 is not set
+# CONFIG_PATA_SC1200 is not set
+# CONFIG_PATA_SERVERWORKS is not set
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+# CONFIG_PATA_VIA is not set
+# CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
+CONFIG_ATA_INTEL_COMBINED=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_MULTIPATH_EMC=m
+CONFIG_DM_MULTIPATH_RDAC=m
+CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+
+#
+# Fusion MPT device support
+#
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+CONFIG_FUSION_LOGGING=y
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+CONFIG_FIREWIRE=m
+CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
+CONFIG_FIREWIRE_SBP2=m
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+CONFIG_I2O=m
+# CONFIG_I2O_LCT_NOTIFY_ON_CHANGES is not set
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_EXT_ADAPTEC_DMA64=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+# CONFIG_NET_SB1000 is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# PHY device support
+#
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_FIXED_PHY=m
+CONFIG_FIXED_MII_10_FDX=y
+CONFIG_FIXED_MII_100_FDX=y
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+
+#
+# Tulip family network device support
+#
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+CONFIG_TULIP_MMIO=y
+# CONFIG_TULIP_NAPI is not set
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_AMD8111E_NAPI=y
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_B44=m
+CONFIG_FORCEDETH=m
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+CONFIG_VIA_RHINE_MMIO=y
+CONFIG_VIA_RHINE_NAPI=y
+CONFIG_NET_POCKET=y
+# CONFIG_ATP is not set
+# CONFIG_DE600 is not set
+# CONFIG_DE620 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IGB=m
+CONFIG_NS83820=m
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+CONFIG_SKY2=m
+# CONFIG_SK98LIN is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+
+#
+# Ethernet (10000 Mbit)
+#
+CONFIG_CHELSIO_T1=m
+# CONFIG_CHELSIO_T3 is not set
+CONFIG_IXGBE=m
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_BNX2X=m
+# CONFIG_MLX4_CORE is not set
+
+#
+# Token Ring devices
+#
+CONFIG_TR=y
+CONFIG_IBMOL=m
+CONFIG_IBMLS=m
+CONFIG_3C359=m
+# CONFIG_TMS380TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+CONFIG_NET_RADIO=y
+
+#
+# Obsolete Wireless cards support (pre-802.11)
+#
+# CONFIG_STRIP is not set
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+
+#
+# Wireless 802.11 Frequency Hopping cards support
+#
+# CONFIG_PCMCIA_RAYCS is not set
+
+#
+# Wireless 802.11b ISA/PCI cards support
+#
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+
+#
+# Wireless 802.11b Pcmcia/Cardbus cards support
+#
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_PCMCIA_WL3501=m
+
+#
+# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
+#
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_BCM43XX=m
+CONFIG_BCM43XX_DEBUG=y
+CONFIG_BCM43XX_DMA=y
+CONFIG_BCM43XX_PIO=y
+CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
+# CONFIG_BCM43XX_DMA_MODE is not set
+# CONFIG_BCM43XX_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_NET_WIRELESS=y
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+# CONFIG_IWL3945_RFKILL is not set
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWL3945_LEDS is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# PCMCIA network device support
+#
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_PCMCIA_IBMTR=m
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# ATM drivers
+#
+# CONFIG_ATM_DUMMY is not set
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+# CONFIG_ATM_ZATM is not set
+CONFIG_ATM_NICSTAR=m
+# CONFIG_ATM_NICSTAR_USE_SUNI is not set
+# CONFIG_ATM_NICSTAR_USE_IDT77105 is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+# CONFIG_ATM_IDT77252_RCV_ALL is not set
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+# CONFIG_ATM_IA is not set
+CONFIG_ATM_FORE200E_MAYBE=m
+# CONFIG_ATM_FORE200E_PCA is not set
+CONFIG_ATM_HE=m
+# CONFIG_ATM_HE_USE_SUNI is not set
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+# CONFIG_SKFP is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+# CONFIG_SLIP_MODE_SLIP6 is not set
+CONFIG_NET_FC=y
+# CONFIG_SHAPER is not set
+CONFIG_NETCONSOLE=m
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+
+#
+# ISDN subsystem
+#
+CONFIG_ISDN=m
+
+#
+# Old ISDN4Linux
+#
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+# CONFIG_ISDN_PPP_BSDCOMP is not set
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+CONFIG_HISAX_NO_SENDCOMPLETE=y
+CONFIG_HISAX_NO_LLC=y
+CONFIG_HISAX_NO_KEYPAD=y
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+# CONFIG_HISAX_DEBUG is not set
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+# CONFIG_HISAX_HFCUSB is not set
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+
+#
+# Siemens Gigaset
+#
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+# CONFIG_GIGASET_DEBUG is not set
+# CONFIG_GIGASET_UNDOCREQ is not set
+
+#
+# CAPI subsystem
+#
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+
+#
+# Active AVM cards
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+
+#
+# Active Eicon DIVA Server cards
+#
+CONFIG_CAPI_EICON=y
+CONFIG_ISDN_DIVAS=m
+CONFIG_ISDN_DIVAS_BRIPCI=y
+CONFIG_ISDN_DIVAS_PRIPCI=y
+CONFIG_ISDN_DIVAS_DIVACAPI=m
+CONFIG_ISDN_DIVAS_USERIDI=m
+CONFIG_ISDN_DIVAS_MAINT=m
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+# CONFIG_INPUT_TSDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_VSXXXAA=m
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_ANALOG is not set
+# CONFIG_JOYSTICK_A3D is not set
+# CONFIG_JOYSTICK_ADI is not set
+# CONFIG_JOYSTICK_COBRA is not set
+# CONFIG_JOYSTICK_GF2K is not set
+# CONFIG_JOYSTICK_GRIP is not set
+# CONFIG_JOYSTICK_GRIP_MP is not set
+# CONFIG_JOYSTICK_GUILLEMOT is not set
+# CONFIG_JOYSTICK_INTERACT is not set
+# CONFIG_JOYSTICK_SIDEWINDER is not set
+# CONFIG_JOYSTICK_TMDC is not set
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+CONFIG_JOYSTICK_TWIDJOY=m
+# CONFIG_JOYSTICK_DB9 is not set
+# CONFIG_JOYSTICK_GAMECON is not set
+# CONFIG_JOYSTICK_TURBOGRAFX is not set
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_WISTRON_BTNS=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_ISI is not set
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=m
+CONFIG_SERIAL_8250_PCI=m
+CONFIG_SERIAL_8250_PNP=m
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=32
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=m
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_CRASH=m
+CONFIG_PRINTER=m
+CONFIG_LP_CONSOLE=y
+CONFIG_PPDEV=m
+# CONFIG_TIPAR is not set
+
+#
+# IPMI
+#
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+# CONFIG_ACQUIRE_WDT is not set
+# CONFIG_ADVANTECH_WDT is not set
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+# CONFIG_SC520_WDT is not set
+# CONFIG_EUROTECH_WDT is not set
+# CONFIG_IB700_WDT is not set
+CONFIG_IBMASR=m
+# CONFIG_WAFER_WDT is not set
+CONFIG_I6300ESB_WDT=m
+CONFIG_I8XX_TCO=m
+CONFIG_HP_WATCHDOG=m
+# CONFIG_SC1200_WDT is not set
+# CONFIG_60XX_WDT is not set
+# CONFIG_SBC8360_WDT is not set
+# CONFIG_CPU5_WDT is not set
+CONFIG_W83627HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+# CONFIG_SBC_EPX_C3_WATCHDOG is not set
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_HW_RANDOM_GEODE=m
+CONFIG_HW_RANDOM_VIA=m
+CONFIG_NVRAM=y
+CONFIG_RTC=y
+CONFIG_DTLK=m
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+CONFIG_SONYPI=m
+
+#
+# Ftape, the floppy tape device driver
+#
+CONFIG_AGP=y
+CONFIG_AGP_ALI=y
+CONFIG_AGP_ATI=y
+CONFIG_AGP_AMD=y
+CONFIG_AGP_AMD64=y
+CONFIG_AGP_INTEL=y
+CONFIG_AGP_NVIDIA=y
+CONFIG_AGP_SIS=y
+CONFIG_AGP_SWORKS=y
+CONFIG_AGP_VIA=y
+CONFIG_AGP_EFFICEON=y
+CONFIG_DRM=m
+# CONFIG_DRM_TDFX is not set
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+# CONFIG_DRM_SIS is not set
+CONFIG_DRM_VIA=m
+CONFIG_DRM_SAVAGE=m
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+# CONFIG_MWAVE is not set
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_CS5535_GPIO=m
+CONFIG_RAW_DRIVER=y
+CONFIG_MAX_RAW_DEVS=8192
+CONFIG_HPET=y
+# CONFIG_HPET_RTC_IRQ is not set
+# CONFIG_HPET_MMAP is not set
+CONFIG_HANGCHECK_TIMER=m
+# CONFIG_TCG_TPM is not set
+CONFIG_TELCLOCK=m
+
+#
+# I2C support
+#
+CONFIG_I2C=m
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_I810=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_ISA=m
+CONFIG_I2C_NFORCE2=m
+# CONFIG_I2C_OCORES is not set
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_PROSAVAGE=m
+CONFIG_I2C_SAVAGE4=m
+# CONFIG_SCx200_ACB is not set
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_STUB=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+CONFIG_I2C_VOODOO3=m
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_SENSORS_DS1337=m
+CONFIG_SENSORS_DS1374=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_SENSORS_PCA9539=m
+CONFIG_SENSORS_PCF8591=m
+CONFIG_SENSORS_MAX6875=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Misc devices
+#
+CONFIG_IBM_ASM=m
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
+
+#
+# Video Capture Adapters
+#
+
+#
+# Video Capture Adapters
+#
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_VIVI is not set
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_SAA6588=m
+# CONFIG_VIDEO_BWQCAM is not set
+# CONFIG_VIDEO_CQCAM is not set
+# CONFIG_VIDEO_W9966 is not set
+# CONFIG_VIDEO_CPIA is not set
+CONFIG_VIDEO_CPIA2=m
+# CONFIG_VIDEO_SAA5246A is not set
+# CONFIG_VIDEO_SAA5249 is not set
+# CONFIG_TUNER_3036 is not set
+# CONFIG_VIDEO_STRADIS is not set
+# CONFIG_VIDEO_ZORAN is not set
+# CONFIG_VIDEO_MEYE is not set
+# CONFIG_VIDEO_SAA7134 is not set
+# CONFIG_VIDEO_MXB is not set
+# CONFIG_VIDEO_DPC is not set
+# CONFIG_VIDEO_HEXIUM_ORION is not set
+# CONFIG_VIDEO_HEXIUM_GEMINI is not set
+# CONFIG_VIDEO_CX88 is not set
+
+#
+# Encoders and Decoders
+#
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_TLV320AIC23B=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+
+#
+# V4L USB devices
+#
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_24XXX=y
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+
+#
+# Radio Adapters
+#
+# CONFIG_RADIO_GEMTEK_PCI is not set
+# CONFIG_RADIO_MAXIRADIO is not set
+# CONFIG_RADIO_MAESTRO is not set
+CONFIG_USB_DSBR=m
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_BUF=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+# CONFIG_FIRMWARE_EDID is not set
+CONFIG_FB=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ARC is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+CONFIG_FB_VGA16=m
+CONFIG_FB_VESA=y
+# CONFIG_FB_HGA is not set
+# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+CONFIG_FB_RIVA=m
+# CONFIG_FB_RIVA_I2C is not set
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_I810=m
+CONFIG_FB_I810_GTF=y
+CONFIG_FB_I810_I2C=y
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_RADEON is not set
+# CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+# CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
+CONFIG_FB_KYRO=m
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+CONFIG_FB_CYBLA=m
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_GEODE is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=m
+CONFIG_BACKLIGHT_DEVICE=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_DEVICE=y
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_RTCTIMER=m
+CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y
+CONFIG_SND_DYNAMIC_MINORS=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
+
+#
+# Generic devices
+#
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+# CONFIG_SND_MTS64 is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+CONFIG_SND_MPU401=m
+# CONFIG_SND_PORTMAN2X4 is not set
+
+#
+# PCI devices
+#
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS5535AUDIO=m
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+# CONFIG_SND_AC97_POWER_SAVE is not set
+
+#
+# USB devices
+#
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+
+#
+# PCMCIA devices
+#
+# CONFIG_SND_VXPOCKET is not set
+# CONFIG_SND_PDAUDIOCF is not set
+
+#
+# SoC audio support
+#
+# CONFIG_SND_SOC is not set
+
+#
+# Open Sound System
+#
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_SPLIT_ISO=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT=y
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_USB_HIDDEV=y
+CONFIG_USB_AIPTEK=m
+CONFIG_USB_WACOM=m
+CONFIG_USB_ACECAD=m
+CONFIG_USB_KBTAB=m
+CONFIG_USB_POWERMATE=m
+CONFIG_USB_TOUCHSCREEN=m
+CONFIG_USB_TOUCHSCREEN_EGALAX=y
+CONFIG_USB_TOUCHSCREEN_PANJIT=y
+CONFIG_USB_TOUCHSCREEN_3M=y
+CONFIG_USB_TOUCHSCREEN_ITM=y
+# CONFIG_USB_YEALINK is not set
+CONFIG_USB_XPAD=m
+CONFIG_USB_ATI_REMOTE=m
+CONFIG_USB_ATI_REMOTE2=m
+CONFIG_USB_KEYSPAN_REMOTE=m
+CONFIG_USB_APPLETOUCH=m
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+
+#
+# USB Serial Converter support
+#
+CONFIG_USB_SERIAL=m
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRPRIME=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_EZUSB=y
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_AUERSWALD=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_LED=m
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TEST=m
+
+#
+# USB DSL modem support
+#
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_WBSD=m
+
+#
+# LED devices
+#
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_AMD76X=m
+CONFIG_EDAC_E7XXX=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I82875P=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_I82860=m
+CONFIG_EDAC_K8=m
+CONFIG_EDAC_R82600=m
+CONFIG_EDAC_POLL=y
+
+#
+# Real Time Clock
+#
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=m
+CONFIG_RTC_INTF_PROC=m
+CONFIG_RTC_INTF_DEV=m
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+
+#
+# RTC drivers
+#
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_RS5C372=m
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_TEST is not set
+CONFIG_RTC_DRV_V3020=m
+
+#
+# DMA Engine support
+#
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT2_FS_XIP=y
+CONFIG_FS_XIP=y
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_NOLOCK=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+CONFIG_AUTOFS4_FS=m
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+CONFIG_FSCACHE=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+CONFIG_CACHEFILES=m
+CONFIG_CACHEFILES_DEBUG=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+CONFIG_JFFS2_SUMMARY=y
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+# CONFIG_SQUASHFS_VMALLOC is not set
+CONFIG_VXFS_FS=m
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_FSCACHE=y
+CONFIG_NFS_DIRECTIO=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_DFS_UPCALL=y
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+# CONFIG_ATARI_PARTITION is not set
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+# CONFIG_LDM_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Distributed Lock Manager
+#
+CONFIG_DLM=m
+CONFIG_DLM_DEBUG=y
+
+#
+# Instrumentation Support
+#
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=m
+CONFIG_KPROBES=y
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHEDSTATS=y
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_HIGHMEM=y
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_FS=y
+# CONFIG_DEBUG_VM is not set
+CONFIG_DEBUG_LIST=y
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_FORCED_INLINING is not set
+CONFIG_BOOT_DELAY=y
+# CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
+CONFIG_EARLY_PRINTK=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+CONFIG_DEBUG_STACK_USAGE=y
+# CONFIG_DEBUG_PAGEALLOC is not set
+CONFIG_DEBUG_RODATA=y
+# CONFIG_4KSTACKS is not set
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_NETWORK_XFRM=y
+CONFIG_SECURITY_CAPABILITIES=y
+# CONFIG_SECURITY_ROOTPLUG is not set
+# CONFIG_SECURITY_SECLVL is not set
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
+CONFIG_CRYPTO_ALGAPI=m
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NHMAC=m
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_586=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_SIGNATURE=y
+CONFIG_CRYPTO_SIGNATURE_DSA=y
+CONFIG_CRYPTO_MPILIB=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
+# Hardware crypto devices
+#
+CONFIG_CRYPTO_DEV_PADLOCK=m
+CONFIG_CRYPTO_DEV_PADLOCK_AES=y
+CONFIG_XEN=y
+CONFIG_XEN_INTERFACE_VERSION=0x00030203
+
+#
+# XEN
+#
+CONFIG_XEN_PRIVILEGED_GUEST=y
+# CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_PRIVCMD=y
+CONFIG_XEN_XENBUS_DEV=y
+CONFIG_XEN_BACKEND=y
+CONFIG_XEN_BLKDEV_BACKEND=m
+CONFIG_XEN_BLKDEV_TAP=m
+CONFIG_XEN_NETDEV_BACKEND=m
+# CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=m
+CONFIG_XEN_PCIDEV_BACKEND=m
+CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
+# CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
+# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
+# CONFIG_XEN_PCIDEV_BE_DEBUG is not set
+# CONFIG_XEN_TPMDEV_BACKEND is not set
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
+CONFIG_XEN_SCRUB_PAGES=y
+# CONFIG_XEN_DISABLE_SERIAL is not set
+CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
+CONFIG_HAVE_ARCH_ALLOC_SKB=y
+CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
+CONFIG_HAVE_IRQ_IGNORE_UNHANDLED=y
+CONFIG_NO_IDLE_HZ=y
+CONFIG_XEN_UTIL=y
+CONFIG_XEN_BALLOON=y
+CONFIG_XEN_DEVMEM=y
+CONFIG_XEN_SKBUFF=y
+CONFIG_XEN_REBOOT=y
+CONFIG_XEN_SMPBOOT=y
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=y
+CONFIG_AUDIT_GENERIC=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
+CONFIG_X86_NO_TSS=y
+CONFIG_X86_NO_IDT=y
+CONFIG_KTIME_SCALAR=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-x86_64-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-x86_64-smp.config
new file mode 100644
index 0000000..9729ec7
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-x86_64-smp.config
@@ -0,0 +1,3079 @@
+# x86_64
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.18-prep
+# Wed Mar 25 15:13:26 2009
+#
+CONFIG_X86_64=y
+CONFIG_64BIT=y
+CONFIG_X86=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_SEMAPHORE_SLEEPERS=y
+CONFIG_MMU=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_DMI=y
+CONFIG_AUDIT_ARCH=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+# CONFIG_IKCONFIG is not set
+CONFIG_CPUSETS=y
+CONFIG_RELAY=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_MODULE_SIG=y
+# CONFIG_MODULE_SIG_FORCE is not set
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+
+#
+# Process debugging support
+#
+CONFIG_PTRACE=y
+CONFIG_UTRACE=y
+
+#
+# Block layer
+#
+CONFIG_LBD=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_LSF=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+
+#
+# Processor type and features
+#
+CONFIG_X86_PC=y
+# CONFIG_X86_VSMP is not set
+# CONFIG_MK8 is not set
+# CONFIG_MPSC is not set
+CONFIG_GENERIC_CPU=y
+CONFIG_X86_64_XEN=y
+CONFIG_X86_NO_TSS=y
+CONFIG_X86_NO_IDT=y
+CONFIG_X86_L1_CACHE_BYTES=128
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_INTERNODE_CACHE_BYTES=128
+CONFIG_X86_GOOD_APIC=y
+CONFIG_MICROCODE=m
+CONFIG_X86_MSR=y
+CONFIG_X86_CPUID=y
+# CONFIG_EFI is not set
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_XEN_GENAPIC=y
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_MTRR=y
+CONFIG_SMP=y
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+CONFIG_RESOURCES_64BIT=y
+CONFIG_NR_CPUS=255
+CONFIG_HOTPLUG_CPU=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_TRACK_DIRTY_PAGES=y
+# CONFIG_TICK_DIVIDER is not set
+# CONFIG_CALGARY_IOMMU is not set
+CONFIG_AMD_IOMMU=y
+CONFIG_IOMMU_HELPER=y
+CONFIG_SWIOTLB=y
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+# CONFIG_SECCOMP is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_REORDER=y
+CONFIG_K8_NB=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_ISA_DMA_API=y
+CONFIG_GENERIC_PENDING_IRQ=y
+
+#
+# Power management options
+#
+CONFIG_PM=y
+
+#
+# ACPI (Advanced Configuration and Power Interface) Support
+#
+CONFIG_ACPI=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+# CONFIG_ACPI_HOTKEY is not set
+CONFIG_ACPI_FAN=y
+CONFIG_ACPI_DOCK=y
+CONFIG_ACPI_BAY=y
+CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_ASUS=m
+# CONFIG_ACPI_IBM is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_BLACKLIST_YEAR=0
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_ACPI_CONTAINER=y
+CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=m
+CONFIG_CPU_FREQ_DEBUG=y
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
+CONFIG_X86_ACPI_CPUFREQ=m
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+# CONFIG_X86_SPEEDSTEP_LIB is not set
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_XEN_PCIDEV_FRONTEND=y
+# CONFIG_XEN_PCIDEV_FE_DEBUG is not set
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
+# CONFIG_PCI_DEBUG is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=y
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+# CONFIG_I82092 is not set
+CONFIG_PCCARD_NONSTATIC=y
+
+#
+# PCI Hotplug Support
+#
+CONFIG_HOTPLUG_PCI=y
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+# CONFIG_HOTPLUG_PCI_CPCI is not set
+CONFIG_HOTPLUG_PCI_SHPC=m
+# CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE is not set
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=y
+CONFIG_IA32_EMULATION=y
+# CONFIG_IA32_AOUT is not set
+CONFIG_COMPAT=y
+CONFIG_SYSVIPC_COMPAT=y
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_NALGO=m
+CONFIG_XFRM_USER=y
+CONFIG_NET_KEY=m
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_FWMARK=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+
+#
+# TCP congestion control
+#
+CONFIG_TCP_CONG_BIC=y
+CONFIG_TCP_CONG_CUBIC=m
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
+
+#
+# IP: Virtual Server Configuration
+#
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+# CONFIG_IPV6_SUBTREES is not set
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_ROUTE_FWMARK=y
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_CT_ACCT=y
+CONFIG_IP_NF_CONNTRACK_MARK=y
+CONFIG_IP_NF_CONNTRACK_SECMARK=y
+CONFIG_IP_NF_CONNTRACK_EVENTS=y
+CONFIG_IP_NF_CONNTRACK_NETLINK=m
+CONFIG_IP_NF_CT_PROTO_SCTP=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_NETBIOS_NS=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_PPTP=m
+CONFIG_IP_NF_H323=m
+CONFIG_IP_NF_SIP=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_NAT_PPTP=m
+CONFIG_IP_NF_NAT_H323=m
+CONFIG_IP_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration (EXPERIMENTAL)
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+CONFIG_IP_DCCP_CCID3=m
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+CONFIG_TIPC=m
+# CONFIG_TIPC_ADVANCED is not set
+# CONFIG_TIPC_DEBUG is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+# CONFIG_ATM_CLIP_NO_ICMP is not set
+CONFIG_ATM_LANE=m
+# CONFIG_ATM_MPOA is not set
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+# CONFIG_DECNET is not set
+CONFIG_LLC=y
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+CONFIG_NET_SCHED=y
+# CONFIG_NET_SCH_CLK_JIFFIES is not set
+CONFIG_NET_SCH_CLK_GETTIMEOFDAY=y
+# CONFIG_NET_SCH_CLK_CPU is not set
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+CONFIG_NET_EMATCH_CMP=m
+CONFIG_NET_EMATCH_NBYTE=m
+CONFIG_NET_EMATCH_U32=m
+CONFIG_NET_EMATCH_META=m
+CONFIG_NET_EMATCH_TEXT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_CLS_IND=y
+CONFIG_NET_ESTIMATOR=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIUSB=m
+CONFIG_BT_HCIUSB_SCO=y
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_TUX=m
+
+#
+# TUX options
+#
+CONFIG_TUX_EXTCGI=y
+CONFIG_TUX_EXTENDED_LOG=y
+# CONFIG_TUX_DEBUG is not set
+CONFIG_NETLABEL=y
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_NET_WIRELESS_RTNETLINK=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_IEEE80211_SOFTMAC=m
+CONFIG_IEEE80211_SOFTMAC_DEBUG=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLOCK=m
+CONFIG_MTD_BLOCK_RO=m
+CONFIG_FTL=m
+CONFIG_NFTL=m
+CONFIG_NFTL_RW=y
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+CONFIG_MTD_RAM=m
+CONFIG_MTD_ROM=m
+CONFIG_MTD_ABSENT=m
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PNC2000 is not set
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+# CONFIG_MTD_AMD76XROM is not set
+# CONFIG_MTD_ICHXROM is not set
+CONFIG_MTD_SCB2_FLASH=m
+# CONFIG_MTD_NETtel is not set
+# CONFIG_MTD_DILNETPC is not set
+# CONFIG_MTD_L440GX is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+# CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE is not set
+CONFIG_MTD_NAND_NANDSIM=m
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
+#
+# Parallel port support
+#
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+# CONFIG_PARPORT_PC_FIFO is not set
+# CONFIG_PARPORT_PC_SUPERIO is not set
+CONFIG_PARPORT_PC_PCMCIA=m
+CONFIG_PARPORT_NOT_PC=y
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
+
+#
+# Plug and Play support
+#
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_PNPACPI=y
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_FD=m
+CONFIG_PARIDE=m
+CONFIG_PARIDE_PARPORT=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=16384
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+CONFIG_ATA_OVER_ETH=m
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_IDECD=m
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_BLK_DEV_IDEFLOPPY=y
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_IDE_TASK_IOCTL=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_BLK_DEV_CMD640 is not set
+CONFIG_BLK_DEV_IDEPNP=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+# CONFIG_BLK_DEV_RZ1000 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+CONFIG_BLK_DEV_AEC62XX=y
+CONFIG_BLK_DEV_ALI15X3=y
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+CONFIG_BLK_DEV_ATIIXP=y
+CONFIG_BLK_DEV_CMD64X=y
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+CONFIG_BLK_DEV_HPT34X=y
+# CONFIG_HPT34X_AUTODMA is not set
+CONFIG_BLK_DEV_HPT366=y
+# CONFIG_BLK_DEV_SC1200 is not set
+CONFIG_BLK_DEV_PIIX=y
+CONFIG_BLK_DEV_IT821X=y
+# CONFIG_BLK_DEV_NS87415 is not set
+CONFIG_BLK_DEV_PDC202XX_OLD=y
+# CONFIG_PDC202XX_BURST is not set
+CONFIG_BLK_DEV_PDC202XX_NEW=y
+CONFIG_BLK_DEV_SVWKS=y
+CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_BLK_DEV_SIS5513=y
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+
+#
+# SCSI Transport
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
+
+#
+# SCSI low-level drivers
+#
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_ISCSI_TCP=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=4
+CONFIG_AIC7XXX_RESET_DELAY_MS=15000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=4
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC94XX=m
+# CONFIG_AIC94XX_DEBUG is not set
+CONFIG_SCSI_ARCMSR=m
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+# CONFIG_SCSI_BUSLOGIC is not set
+CONFIG_FCOE_FNIC=m
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+# CONFIG_SCSI_INIA100 is not set
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+# CONFIG_SCSI_IPR is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_DC395x=m
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# PCMCIA SCSI adapter support
+#
+# CONFIG_PCMCIA_FDOMAIN is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+# CONFIG_PATA_ACPI is not set
+# CONFIG_PATA_ALI is not set
+# CONFIG_PATA_AMD is not set
+# CONFIG_PATA_ARTOP is not set
+# CONFIG_PATA_ATIIXP is not set
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_CMD64X is not set
+# CONFIG_PATA_CS5520 is not set
+# CONFIG_PATA_CS5530 is not set
+# CONFIG_PATA_CYPRESS is not set
+# CONFIG_PATA_EFAR is not set
+# CONFIG_ATA_GENERIC is not set
+# CONFIG_PATA_HPT366 is not set
+# CONFIG_PATA_HPT37X is not set
+# CONFIG_PATA_HPT3X2N is not set
+# CONFIG_PATA_HPT3X3 is not set
+# CONFIG_PATA_IT821X is not set
+# CONFIG_PATA_IT8213 is not set
+# CONFIG_PATA_JMICRON is not set
+# CONFIG_PATA_TRIFLEX is not set
+CONFIG_PATA_MARVELL=m
+# CONFIG_PATA_MPIIX is not set
+# CONFIG_PATA_OLDPIIX is not set
+# CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
+# CONFIG_PATA_NS87410 is not set
+# CONFIG_PATA_NS87415 is not set
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_OPTIDMA is not set
+# CONFIG_PATA_PCMCIA is not set
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_RADISYS is not set
+# CONFIG_PATA_RZ1000 is not set
+# CONFIG_PATA_SC1200 is not set
+# CONFIG_PATA_SERVERWORKS is not set
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+# CONFIG_PATA_VIA is not set
+# CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
+CONFIG_ATA_INTEL_COMBINED=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_MULTIPATH_EMC=m
+CONFIG_DM_MULTIPATH_RDAC=m
+CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+
+#
+# Fusion MPT device support
+#
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+CONFIG_FUSION_LOGGING=y
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+CONFIG_FIREWIRE=m
+CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
+CONFIG_FIREWIRE_SBP2=m
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+CONFIG_I2O=m
+# CONFIG_I2O_LCT_NOTIFY_ON_CHANGES is not set
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_EXT_ADAPTEC_DMA64=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+# CONFIG_NET_SB1000 is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# PHY device support
+#
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_FIXED_PHY=m
+CONFIG_FIXED_MII_10_FDX=y
+CONFIG_FIXED_MII_100_FDX=y
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+
+#
+# Tulip family network device support
+#
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+CONFIG_TULIP_MMIO=y
+# CONFIG_TULIP_NAPI is not set
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_AMD8111E_NAPI=y
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_B44=m
+CONFIG_FORCEDETH=m
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_VIA_RHINE=m
+CONFIG_VIA_RHINE_MMIO=y
+CONFIG_VIA_RHINE_NAPI=y
+CONFIG_NET_POCKET=y
+# CONFIG_ATP is not set
+# CONFIG_DE600 is not set
+# CONFIG_DE620 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IGB=m
+CONFIG_NS83820=m
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+CONFIG_SKY2=m
+# CONFIG_SK98LIN is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+
+#
+# Ethernet (10000 Mbit)
+#
+CONFIG_CHELSIO_T1=m
+# CONFIG_CHELSIO_T3 is not set
+CONFIG_IXGBE=m
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_BNX2X=m
+# CONFIG_MLX4_CORE is not set
+
+#
+# Token Ring devices
+#
+CONFIG_TR=y
+CONFIG_IBMOL=m
+CONFIG_3C359=m
+# CONFIG_TMS380TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+CONFIG_NET_RADIO=y
+
+#
+# Obsolete Wireless cards support (pre-802.11)
+#
+# CONFIG_STRIP is not set
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+
+#
+# Wireless 802.11 Frequency Hopping cards support
+#
+# CONFIG_PCMCIA_RAYCS is not set
+
+#
+# Wireless 802.11b ISA/PCI cards support
+#
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+
+#
+# Wireless 802.11b Pcmcia/Cardbus cards support
+#
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_PCMCIA_WL3501=m
+
+#
+# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
+#
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_BCM43XX=m
+CONFIG_BCM43XX_DEBUG=y
+CONFIG_BCM43XX_DMA=y
+CONFIG_BCM43XX_PIO=y
+CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
+# CONFIG_BCM43XX_DMA_MODE is not set
+# CONFIG_BCM43XX_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_NET_WIRELESS=y
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+# CONFIG_IWL3945_RFKILL is not set
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWL3945_LEDS is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# PCMCIA network device support
+#
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# ATM drivers
+#
+# CONFIG_ATM_DUMMY is not set
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+# CONFIG_ATM_ZATM is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+# CONFIG_ATM_IDT77252_RCV_ALL is not set
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_FORE200E_MAYBE=m
+# CONFIG_ATM_FORE200E_PCA is not set
+CONFIG_ATM_HE=m
+# CONFIG_ATM_HE_USE_SUNI is not set
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+# CONFIG_SKFP is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+# CONFIG_SLIP_MODE_SLIP6 is not set
+CONFIG_NET_FC=y
+# CONFIG_SHAPER is not set
+CONFIG_NETCONSOLE=m
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+
+#
+# ISDN subsystem
+#
+CONFIG_ISDN=m
+
+#
+# Old ISDN4Linux
+#
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+# CONFIG_ISDN_PPP_BSDCOMP is not set
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+CONFIG_HISAX_NO_SENDCOMPLETE=y
+CONFIG_HISAX_NO_LLC=y
+CONFIG_HISAX_NO_KEYPAD=y
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+# CONFIG_HISAX_DEBUG is not set
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+# CONFIG_HISAX_HFCUSB is not set
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+
+#
+# Siemens Gigaset
+#
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+# CONFIG_GIGASET_DEBUG is not set
+# CONFIG_GIGASET_UNDOCREQ is not set
+
+#
+# CAPI subsystem
+#
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+
+#
+# Active AVM cards
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+
+#
+# Active Eicon DIVA Server cards
+#
+# CONFIG_CAPI_EICON is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+# CONFIG_INPUT_TSDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_VSXXXAA=m
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_ANALOG is not set
+# CONFIG_JOYSTICK_A3D is not set
+# CONFIG_JOYSTICK_ADI is not set
+# CONFIG_JOYSTICK_COBRA is not set
+# CONFIG_JOYSTICK_GF2K is not set
+# CONFIG_JOYSTICK_GRIP is not set
+# CONFIG_JOYSTICK_GRIP_MP is not set
+# CONFIG_JOYSTICK_GUILLEMOT is not set
+# CONFIG_JOYSTICK_INTERACT is not set
+# CONFIG_JOYSTICK_SIDEWINDER is not set
+# CONFIG_JOYSTICK_TMDC is not set
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+CONFIG_JOYSTICK_TWIDJOY=m
+# CONFIG_JOYSTICK_DB9 is not set
+# CONFIG_JOYSTICK_GAMECON is not set
+# CONFIG_JOYSTICK_TURBOGRAFX is not set
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_ISI is not set
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=m
+CONFIG_SERIAL_8250_PCI=m
+CONFIG_SERIAL_8250_PNP=m
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=32
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=m
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_CRASH=m
+CONFIG_PRINTER=m
+CONFIG_LP_CONSOLE=y
+CONFIG_PPDEV=m
+# CONFIG_TIPAR is not set
+
+#
+# IPMI
+#
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+# CONFIG_ACQUIRE_WDT is not set
+# CONFIG_ADVANTECH_WDT is not set
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+# CONFIG_SC520_WDT is not set
+# CONFIG_EUROTECH_WDT is not set
+# CONFIG_IB700_WDT is not set
+CONFIG_IBMASR=m
+# CONFIG_WAFER_WDT is not set
+CONFIG_I6300ESB_WDT=m
+CONFIG_I8XX_TCO=m
+CONFIG_HP_WATCHDOG=m
+# CONFIG_SC1200_WDT is not set
+# CONFIG_60XX_WDT is not set
+# CONFIG_SBC8360_WDT is not set
+# CONFIG_CPU5_WDT is not set
+CONFIG_W83627HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+# CONFIG_SBC_EPX_C3_WATCHDOG is not set
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+# CONFIG_HW_RANDOM_GEODE is not set
+CONFIG_NVRAM=y
+CONFIG_RTC=y
+CONFIG_DTLK=m
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+CONFIG_AGP=y
+CONFIG_AGP_AMD64=y
+CONFIG_AGP_INTEL=y
+CONFIG_AGP_SIS=y
+CONFIG_AGP_VIA=y
+CONFIG_DRM=m
+# CONFIG_DRM_TDFX is not set
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+# CONFIG_DRM_SIS is not set
+CONFIG_DRM_VIA=m
+CONFIG_DRM_SAVAGE=m
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+# CONFIG_MWAVE is not set
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_RAW_DRIVER=y
+CONFIG_MAX_RAW_DEVS=8192
+CONFIG_HPET=y
+# CONFIG_HPET_RTC_IRQ is not set
+# CONFIG_HPET_MMAP is not set
+CONFIG_HANGCHECK_TIMER=m
+# CONFIG_TCG_TPM is not set
+CONFIG_TELCLOCK=m
+
+#
+# I2C support
+#
+CONFIG_I2C=m
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+# CONFIG_I2C_ALI1535 is not set
+# CONFIG_I2C_ALI1563 is not set
+# CONFIG_I2C_ALI15X3 is not set
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+# CONFIG_I2C_I810 is not set
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_ISA=m
+CONFIG_I2C_NFORCE2=m
+# CONFIG_I2C_OCORES is not set
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_PROSAVAGE=m
+CONFIG_I2C_SAVAGE4=m
+# CONFIG_I2C_SIS5595 is not set
+# CONFIG_I2C_SIS630 is not set
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_STUB=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+CONFIG_I2C_VOODOO3=m
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_SENSORS_DS1337=m
+CONFIG_SENSORS_DS1374=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_SENSORS_PCA9539=m
+CONFIG_SENSORS_PCF8591=m
+CONFIG_SENSORS_MAX6875=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Misc devices
+#
+# CONFIG_IBM_ASM is not set
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
+
+#
+# Video Capture Adapters
+#
+
+#
+# Video Capture Adapters
+#
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_VIVI is not set
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_SAA6588=m
+# CONFIG_VIDEO_BWQCAM is not set
+# CONFIG_VIDEO_CQCAM is not set
+# CONFIG_VIDEO_W9966 is not set
+# CONFIG_VIDEO_CPIA is not set
+CONFIG_VIDEO_CPIA2=m
+# CONFIG_VIDEO_SAA5246A is not set
+# CONFIG_VIDEO_SAA5249 is not set
+# CONFIG_TUNER_3036 is not set
+# CONFIG_VIDEO_STRADIS is not set
+# CONFIG_VIDEO_ZORAN is not set
+# CONFIG_VIDEO_SAA7134 is not set
+# CONFIG_VIDEO_MXB is not set
+# CONFIG_VIDEO_DPC is not set
+# CONFIG_VIDEO_HEXIUM_ORION is not set
+# CONFIG_VIDEO_HEXIUM_GEMINI is not set
+# CONFIG_VIDEO_CX88 is not set
+
+#
+# Encoders and Decoders
+#
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_TLV320AIC23B=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+
+#
+# V4L USB devices
+#
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_24XXX=y
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+
+#
+# Radio Adapters
+#
+# CONFIG_RADIO_GEMTEK_PCI is not set
+# CONFIG_RADIO_MAXIRADIO is not set
+# CONFIG_RADIO_MAESTRO is not set
+CONFIG_USB_DSBR=m
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_BUF=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+# CONFIG_FIRMWARE_EDID is not set
+CONFIG_FB=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ARC is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+CONFIG_FB_VGA16=m
+CONFIG_FB_VESA=y
+# CONFIG_FB_HGA is not set
+# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+CONFIG_FB_RIVA=m
+# CONFIG_FB_RIVA_I2C is not set
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_RADEON is not set
+# CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+# CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
+CONFIG_FB_KYRO=m
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_GEODE is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=m
+CONFIG_BACKLIGHT_DEVICE=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_DEVICE=y
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_RTCTIMER=m
+CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y
+CONFIG_SND_DYNAMIC_MINORS=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
+
+#
+# Generic devices
+#
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+# CONFIG_SND_MTS64 is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+CONFIG_SND_MPU401=m
+# CONFIG_SND_PORTMAN2X4 is not set
+
+#
+# PCI devices
+#
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+# CONFIG_SND_AC97_POWER_SAVE is not set
+
+#
+# USB devices
+#
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+
+#
+# PCMCIA devices
+#
+# CONFIG_SND_VXPOCKET is not set
+# CONFIG_SND_PDAUDIOCF is not set
+
+#
+# SoC audio support
+#
+# CONFIG_SND_SOC is not set
+
+#
+# Open Sound System
+#
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_SPLIT_ISO=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT=y
+# CONFIG_USB_HIDINPUT_POWERBOOK is not set
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_USB_HIDDEV=y
+CONFIG_USB_AIPTEK=m
+CONFIG_USB_WACOM=m
+CONFIG_USB_ACECAD=m
+CONFIG_USB_KBTAB=m
+CONFIG_USB_POWERMATE=m
+CONFIG_USB_TOUCHSCREEN=m
+CONFIG_USB_TOUCHSCREEN_EGALAX=y
+CONFIG_USB_TOUCHSCREEN_PANJIT=y
+CONFIG_USB_TOUCHSCREEN_3M=y
+CONFIG_USB_TOUCHSCREEN_ITM=y
+# CONFIG_USB_YEALINK is not set
+CONFIG_USB_XPAD=m
+CONFIG_USB_ATI_REMOTE=m
+CONFIG_USB_ATI_REMOTE2=m
+CONFIG_USB_KEYSPAN_REMOTE=m
+CONFIG_USB_APPLETOUCH=m
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+
+#
+# USB Serial Converter support
+#
+CONFIG_USB_SERIAL=m
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRPRIME=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_EZUSB=y
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_AUERSWALD=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_LED=m
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TEST=m
+
+#
+# USB DSL modem support
+#
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_WBSD=m
+
+#
+# LED devices
+#
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_K8=m
+CONFIG_EDAC_POLL=y
+
+#
+# Real Time Clock
+#
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=m
+CONFIG_RTC_INTF_PROC=m
+CONFIG_RTC_INTF_DEV=m
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+
+#
+# RTC drivers
+#
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_RS5C372=m
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_TEST is not set
+CONFIG_RTC_DRV_V3020=m
+
+#
+# DMA Engine support
+#
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+
+#
+# Firmware Drivers
+#
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT2_FS_XIP=y
+CONFIG_FS_XIP=y
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_NOLOCK=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+CONFIG_AUTOFS4_FS=m
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+CONFIG_FSCACHE=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+CONFIG_CACHEFILES=m
+CONFIG_CACHEFILES_DEBUG=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+CONFIG_JFFS2_SUMMARY=y
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+# CONFIG_SQUASHFS_VMALLOC is not set
+CONFIG_VXFS_FS=m
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_FSCACHE=y
+CONFIG_NFS_DIRECTIO=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_DFS_UPCALL=y
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+# CONFIG_ATARI_PARTITION is not set
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+# CONFIG_LDM_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Distributed Lock Manager
+#
+CONFIG_DLM=m
+CONFIG_DLM_DEBUG=y
+
+#
+# Instrumentation Support
+#
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=m
+CONFIG_KPROBES=y
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHEDSTATS=y
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_FS=y
+# CONFIG_DEBUG_VM is not set
+CONFIG_DEBUG_LIST=y
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_FORCED_INLINING is not set
+CONFIG_BOOT_DELAY=y
+# CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
+CONFIG_DEBUG_RODATA=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_NETWORK_XFRM=y
+CONFIG_SECURITY_CAPABILITIES=y
+# CONFIG_SECURITY_ROOTPLUG is not set
+# CONFIG_SECURITY_SECLVL is not set
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
+CONFIG_CRYPTO_ALGAPI=m
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NHMAC=m
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_X86_64=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_SIGNATURE=y
+CONFIG_CRYPTO_SIGNATURE_DSA=y
+CONFIG_CRYPTO_MPILIB=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
+# Hardware crypto devices
+#
+CONFIG_XEN=y
+CONFIG_XEN_INTERFACE_VERSION=0x00030203
+
+#
+# XEN
+#
+CONFIG_XEN_PRIVILEGED_GUEST=y
+# CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_PRIVCMD=y
+CONFIG_XEN_XENBUS_DEV=y
+CONFIG_XEN_BACKEND=y
+CONFIG_XEN_BLKDEV_BACKEND=m
+CONFIG_XEN_BLKDEV_TAP=m
+CONFIG_XEN_NETDEV_BACKEND=m
+# CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=m
+CONFIG_XEN_PCIDEV_BACKEND=m
+CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
+# CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
+# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
+# CONFIG_XEN_PCIDEV_BE_DEBUG is not set
+# CONFIG_XEN_TPMDEV_BACKEND is not set
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
+CONFIG_XEN_SCRUB_PAGES=y
+# CONFIG_XEN_DISABLE_SERIAL is not set
+CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
+CONFIG_HAVE_ARCH_ALLOC_SKB=y
+CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
+CONFIG_HAVE_IRQ_IGNORE_UNHANDLED=y
+CONFIG_NO_IDLE_HZ=y
+CONFIG_XEN_UTIL=y
+CONFIG_XEN_BALLOON=y
+CONFIG_XEN_DEVMEM=y
+CONFIG_XEN_SKBUFF=y
+CONFIG_XEN_REBOOT=y
+CONFIG_XEN_SMPBOOT=y
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-x86_64.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-x86_64.config
new file mode 100644
index 0000000..9729ec7
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.18-2.6-rhel5-xen-x86_64.config
@@ -0,0 +1,3079 @@
+# x86_64
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.18-prep
+# Wed Mar 25 15:13:26 2009
+#
+CONFIG_X86_64=y
+CONFIG_64BIT=y
+CONFIG_X86=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_SEMAPHORE_SLEEPERS=y
+CONFIG_MMU=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_DMI=y
+CONFIG_AUDIT_ARCH=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+# CONFIG_IKCONFIG is not set
+CONFIG_CPUSETS=y
+CONFIG_RELAY=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_TRACEPOINTS=y
+CONFIG_MARKERS=y
+CONFIG_TRACEPROBES=m
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_MODULE_SIG=y
+# CONFIG_MODULE_SIG_FORCE is not set
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+
+#
+# Process debugging support
+#
+CONFIG_PTRACE=y
+CONFIG_UTRACE=y
+
+#
+# Block layer
+#
+CONFIG_LBD=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_LSF=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+
+#
+# Processor type and features
+#
+CONFIG_X86_PC=y
+# CONFIG_X86_VSMP is not set
+# CONFIG_MK8 is not set
+# CONFIG_MPSC is not set
+CONFIG_GENERIC_CPU=y
+CONFIG_X86_64_XEN=y
+CONFIG_X86_NO_TSS=y
+CONFIG_X86_NO_IDT=y
+CONFIG_X86_L1_CACHE_BYTES=128
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_INTERNODE_CACHE_BYTES=128
+CONFIG_X86_GOOD_APIC=y
+CONFIG_MICROCODE=m
+CONFIG_X86_MSR=y
+CONFIG_X86_CPUID=y
+# CONFIG_EFI is not set
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_XEN_GENAPIC=y
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_MTRR=y
+CONFIG_SMP=y
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_PREEMPT_BKL=y
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+CONFIG_RESOURCES_64BIT=y
+CONFIG_NR_CPUS=255
+CONFIG_HOTPLUG_CPU=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_TRACK_DIRTY_PAGES=y
+# CONFIG_TICK_DIVIDER is not set
+# CONFIG_CALGARY_IOMMU is not set
+CONFIG_AMD_IOMMU=y
+CONFIG_IOMMU_HELPER=y
+CONFIG_SWIOTLB=y
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+# CONFIG_SECCOMP is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_REORDER=y
+CONFIG_K8_NB=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_ISA_DMA_API=y
+CONFIG_GENERIC_PENDING_IRQ=y
+
+#
+# Power management options
+#
+CONFIG_PM=y
+
+#
+# ACPI (Advanced Configuration and Power Interface) Support
+#
+CONFIG_ACPI=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+# CONFIG_ACPI_HOTKEY is not set
+CONFIG_ACPI_FAN=y
+CONFIG_ACPI_DOCK=y
+CONFIG_ACPI_BAY=y
+CONFIG_ACPI_PROCESSOR=y
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_ASUS=m
+# CONFIG_ACPI_IBM is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_BLACKLIST_YEAR=0
+# CONFIG_ACPI_DEBUG is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_ACPI_CONTAINER=y
+CONFIG_ACPI_SBS=m
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=m
+CONFIG_CPU_FREQ_DEBUG=y
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_ACPI=y
+CONFIG_X86_ACPI_CPUFREQ=m
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+# CONFIG_X86_SPEEDSTEP_LIB is not set
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_XEN_PCIDEV_FRONTEND=y
+# CONFIG_XEN_PCIDEV_FE_DEBUG is not set
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+# CONFIG_HOTPLUG_PCI_PCIE_POLL_EVENT_MODE is not set
+CONFIG_PCI_DOMAINS=y
+# CONFIG_PCI_DEBUG is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=y
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+# CONFIG_I82092 is not set
+CONFIG_PCCARD_NONSTATIC=y
+
+#
+# PCI Hotplug Support
+#
+CONFIG_HOTPLUG_PCI=y
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+# CONFIG_HOTPLUG_PCI_CPCI is not set
+CONFIG_HOTPLUG_PCI_SHPC=m
+# CONFIG_HOTPLUG_PCI_SHPC_POLL_EVENT_MODE is not set
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=y
+CONFIG_IA32_EMULATION=y
+# CONFIG_IA32_AOUT is not set
+CONFIG_COMPAT=y
+CONFIG_SYSVIPC_COMPAT=y
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+# CONFIG_NETDEBUG is not set
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_NALGO=m
+CONFIG_XFRM_USER=y
+CONFIG_NET_KEY=m
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_FWMARK=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+
+#
+# TCP congestion control
+#
+CONFIG_TCP_CONG_BIC=y
+CONFIG_TCP_CONG_CUBIC=m
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_INET_LRO=y
+
+#
+# IP: Virtual Server Configuration
+#
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_IPV6_TUNNEL=m
+# CONFIG_IPV6_SUBTREES is not set
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_ROUTE_FWMARK=y
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_IP_NF_CONNTRACK=m
+CONFIG_IP_NF_CT_ACCT=y
+CONFIG_IP_NF_CONNTRACK_MARK=y
+CONFIG_IP_NF_CONNTRACK_SECMARK=y
+CONFIG_IP_NF_CONNTRACK_EVENTS=y
+CONFIG_IP_NF_CONNTRACK_NETLINK=m
+CONFIG_IP_NF_CT_PROTO_SCTP=m
+CONFIG_IP_NF_FTP=m
+CONFIG_IP_NF_IRC=m
+CONFIG_IP_NF_NETBIOS_NS=m
+CONFIG_IP_NF_TFTP=m
+CONFIG_IP_NF_AMANDA=m
+CONFIG_IP_NF_PPTP=m
+CONFIG_IP_NF_H323=m
+CONFIG_IP_NF_SIP=m
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_IPRANGE=m
+CONFIG_IP_NF_MATCH_TOS=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_DSCP=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_OWNER=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_HASHLIMIT=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_IP_NF_TARGET_TCPMSS=m
+CONFIG_IP_NF_NAT=m
+CONFIG_IP_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_IP_NF_TARGET_SAME=m
+CONFIG_IP_NF_NAT_SNMP_BASIC=m
+CONFIG_IP_NF_NAT_IRC=m
+CONFIG_IP_NF_NAT_FTP=m
+CONFIG_IP_NF_NAT_TFTP=m
+CONFIG_IP_NF_NAT_AMANDA=m
+CONFIG_IP_NF_NAT_PPTP=m
+CONFIG_IP_NF_NAT_H323=m
+CONFIG_IP_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_TOS=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_DSCP=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration (EXPERIMENTAL)
+#
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_OWNER=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+CONFIG_IP_DCCP_CCID3=m
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+CONFIG_TIPC=m
+# CONFIG_TIPC_ADVANCED is not set
+# CONFIG_TIPC_DEBUG is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+# CONFIG_ATM_CLIP_NO_ICMP is not set
+CONFIG_ATM_LANE=m
+# CONFIG_ATM_MPOA is not set
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+# CONFIG_DECNET is not set
+CONFIG_LLC=y
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+CONFIG_NET_SCHED=y
+# CONFIG_NET_SCH_CLK_JIFFIES is not set
+CONFIG_NET_SCH_CLK_GETTIMEOFDAY=y
+# CONFIG_NET_SCH_CLK_CPU is not set
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+CONFIG_NET_EMATCH_CMP=m
+CONFIG_NET_EMATCH_NBYTE=m
+CONFIG_NET_EMATCH_U32=m
+CONFIG_NET_EMATCH_META=m
+CONFIG_NET_EMATCH_TEXT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_CLS_IND=y
+CONFIG_NET_ESTIMATOR=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIUSB=m
+CONFIG_BT_HCIUSB_SCO=y
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_TUX=m
+
+#
+# TUX options
+#
+CONFIG_TUX_EXTCGI=y
+CONFIG_TUX_EXTENDED_LOG=y
+# CONFIG_TUX_DEBUG is not set
+CONFIG_NETLABEL=y
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_NET_WIRELESS_RTNETLINK=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+# CONFIG_MAC80211_RC_DEFAULT_NONE is not set
+
+#
+# Selecting 'y' for an algorithm will
+#
+
+#
+# build the algorithm into mac80211.
+#
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_RC_PID=y
+# CONFIG_MAC80211_MESH is not set
+CONFIG_MAC80211_LEDS=y
+# CONFIG_MAC80211_DEBUGFS is not set
+# CONFIG_MAC80211_DEBUG_PACKET_ALIGNMENT is not set
+# CONFIG_MAC80211_DEBUG is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_IEEE80211_SOFTMAC=m
+CONFIG_IEEE80211_SOFTMAC_DEBUG=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLOCK=m
+CONFIG_MTD_BLOCK_RO=m
+CONFIG_FTL=m
+CONFIG_NFTL=m
+CONFIG_NFTL_RW=y
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+CONFIG_MTD_RAM=m
+CONFIG_MTD_ROM=m
+CONFIG_MTD_ABSENT=m
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PNC2000 is not set
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+# CONFIG_MTD_AMD76XROM is not set
+# CONFIG_MTD_ICHXROM is not set
+CONFIG_MTD_SCB2_FLASH=m
+# CONFIG_MTD_NETtel is not set
+# CONFIG_MTD_DILNETPC is not set
+# CONFIG_MTD_L440GX is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+# CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE is not set
+CONFIG_MTD_NAND_NANDSIM=m
+
+#
+# OneNAND Flash Device Drivers
+#
+# CONFIG_MTD_ONENAND is not set
+
+#
+# Parallel port support
+#
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+# CONFIG_PARPORT_PC_FIFO is not set
+# CONFIG_PARPORT_PC_SUPERIO is not set
+CONFIG_PARPORT_PC_PCMCIA=m
+CONFIG_PARPORT_NOT_PC=y
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
+
+#
+# Plug and Play support
+#
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_PNPACPI=y
+
+#
+# Block devices
+#
+CONFIG_BLK_DEV_FD=m
+CONFIG_PARIDE=m
+CONFIG_PARIDE_PARPORT=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=16384
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=4096
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+CONFIG_ATA_OVER_ETH=m
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide.txt for help/info on IDE drives
+#
+# CONFIG_BLK_DEV_IDE_SATA is not set
+# CONFIG_BLK_DEV_HD_IDE is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_IDECD=m
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_BLK_DEV_IDEFLOPPY=y
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_IDE_TASK_IOCTL=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=y
+# CONFIG_BLK_DEV_CMD640 is not set
+CONFIG_BLK_DEV_IDEPNP=y
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_IDEPCI_SHARE_IRQ=y
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+# CONFIG_BLK_DEV_RZ1000 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
+CONFIG_IDEDMA_PCI_AUTO=y
+# CONFIG_IDEDMA_ONLYDISK is not set
+CONFIG_BLK_DEV_AEC62XX=y
+CONFIG_BLK_DEV_ALI15X3=y
+# CONFIG_WDC_ALI15X3 is not set
+CONFIG_BLK_DEV_AMD74XX=y
+CONFIG_BLK_DEV_ATIIXP=y
+CONFIG_BLK_DEV_CMD64X=y
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+CONFIG_BLK_DEV_HPT34X=y
+# CONFIG_HPT34X_AUTODMA is not set
+CONFIG_BLK_DEV_HPT366=y
+# CONFIG_BLK_DEV_SC1200 is not set
+CONFIG_BLK_DEV_PIIX=y
+CONFIG_BLK_DEV_IT821X=y
+# CONFIG_BLK_DEV_NS87415 is not set
+CONFIG_BLK_DEV_PDC202XX_OLD=y
+# CONFIG_PDC202XX_BURST is not set
+CONFIG_BLK_DEV_PDC202XX_NEW=y
+CONFIG_BLK_DEV_SVWKS=y
+CONFIG_BLK_DEV_SIIMAGE=y
+CONFIG_BLK_DEV_SIS5513=y
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=y
+# CONFIG_IDE_ARM is not set
+CONFIG_BLK_DEV_IDEDMA=y
+# CONFIG_IDEDMA_IVB is not set
+CONFIG_IDEDMA_AUTO=y
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+
+#
+# SCSI Transport
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+# CONFIG_SCSI_SAS_LIBSAS_DEBUG is not set
+
+#
+# SCSI low-level drivers
+#
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_ISCSI_TCP=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=4
+CONFIG_AIC7XXX_RESET_DELAY_MS=15000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+# CONFIG_AIC7XXX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=4
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
+CONFIG_SCSI_AIC94XX=m
+# CONFIG_AIC94XX_DEBUG is not set
+CONFIG_SCSI_ARCMSR=m
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+# CONFIG_SCSI_BUSLOGIC is not set
+CONFIG_FCOE_FNIC=m
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+# CONFIG_SCSI_INIA100 is not set
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+# CONFIG_SCSI_IPR is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_DC395x=m
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_DEBUG is not set
+
+#
+# PCMCIA SCSI adapter support
+#
+# CONFIG_PCMCIA_FDOMAIN is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+# CONFIG_PATA_ACPI is not set
+# CONFIG_PATA_ALI is not set
+# CONFIG_PATA_AMD is not set
+# CONFIG_PATA_ARTOP is not set
+# CONFIG_PATA_ATIIXP is not set
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_CMD64X is not set
+# CONFIG_PATA_CS5520 is not set
+# CONFIG_PATA_CS5530 is not set
+# CONFIG_PATA_CYPRESS is not set
+# CONFIG_PATA_EFAR is not set
+# CONFIG_ATA_GENERIC is not set
+# CONFIG_PATA_HPT366 is not set
+# CONFIG_PATA_HPT37X is not set
+# CONFIG_PATA_HPT3X2N is not set
+# CONFIG_PATA_HPT3X3 is not set
+# CONFIG_PATA_IT821X is not set
+# CONFIG_PATA_IT8213 is not set
+# CONFIG_PATA_JMICRON is not set
+# CONFIG_PATA_TRIFLEX is not set
+CONFIG_PATA_MARVELL=m
+# CONFIG_PATA_MPIIX is not set
+# CONFIG_PATA_OLDPIIX is not set
+# CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
+# CONFIG_PATA_NS87410 is not set
+# CONFIG_PATA_NS87415 is not set
+# CONFIG_PATA_OPTI is not set
+# CONFIG_PATA_OPTIDMA is not set
+# CONFIG_PATA_PCMCIA is not set
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_RADISYS is not set
+# CONFIG_PATA_RZ1000 is not set
+# CONFIG_PATA_SC1200 is not set
+# CONFIG_PATA_SERVERWORKS is not set
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+# CONFIG_PATA_VIA is not set
+# CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_SCH is not set
+CONFIG_ATA_INTEL_COMBINED=y
+
+#
+# Multi-device support (RAID and LVM)
+#
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_MULTIPATH_EMC=m
+CONFIG_DM_MULTIPATH_RDAC=m
+CONFIG_DM_MULTIPATH_HP=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+
+#
+# Fusion MPT device support
+#
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+CONFIG_FUSION_LOGGING=y
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+CONFIG_FIREWIRE=m
+CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
+CONFIG_FIREWIRE_SBP2=m
+
+#
+# IEEE 1394 (FireWire) support
+#
+# CONFIG_IEEE1394 is not set
+
+#
+# I2O device support
+#
+CONFIG_I2O=m
+# CONFIG_I2O_LCT_NOTIFY_ON_CHANGES is not set
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_EXT_ADAPTEC_DMA64=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=m
+# CONFIG_NET_SB1000 is not set
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+
+#
+# PHY device support
+#
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_FIXED_PHY=m
+CONFIG_FIXED_MII_10_FDX=y
+CONFIG_FIXED_MII_100_FDX=y
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+
+#
+# Tulip family network device support
+#
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+CONFIG_TULIP_MMIO=y
+# CONFIG_TULIP_NAPI is not set
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+# CONFIG_HP100 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_AMD8111E_NAPI=y
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+CONFIG_B44=m
+CONFIG_FORCEDETH=m
+# CONFIG_DGRS is not set
+# CONFIG_EEPRO100 is not set
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_VIA_RHINE=m
+CONFIG_VIA_RHINE_MMIO=y
+CONFIG_VIA_RHINE_NAPI=y
+CONFIG_NET_POCKET=y
+# CONFIG_ATP is not set
+# CONFIG_DE600 is not set
+# CONFIG_DE620 is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IGB=m
+CONFIG_NS83820=m
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+CONFIG_SKY2=m
+# CONFIG_SK98LIN is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+
+#
+# Ethernet (10000 Mbit)
+#
+CONFIG_CHELSIO_T1=m
+# CONFIG_CHELSIO_T3 is not set
+CONFIG_IXGBE=m
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+CONFIG_MYRI10GE=m
+CONFIG_ENIC=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_BNX2X=m
+# CONFIG_MLX4_CORE is not set
+
+#
+# Token Ring devices
+#
+CONFIG_TR=y
+CONFIG_IBMOL=m
+CONFIG_3C359=m
+# CONFIG_TMS380TR is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+CONFIG_NET_RADIO=y
+
+#
+# Obsolete Wireless cards support (pre-802.11)
+#
+# CONFIG_STRIP is not set
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+
+#
+# Wireless 802.11 Frequency Hopping cards support
+#
+# CONFIG_PCMCIA_RAYCS is not set
+
+#
+# Wireless 802.11b ISA/PCI cards support
+#
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+
+#
+# Wireless 802.11b Pcmcia/Cardbus cards support
+#
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_PCMCIA_WL3501=m
+
+#
+# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
+#
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_BCM43XX=m
+CONFIG_BCM43XX_DEBUG=y
+CONFIG_BCM43XX_DMA=y
+CONFIG_BCM43XX_PIO=y
+CONFIG_BCM43XX_DMA_AND_PIO_MODE=y
+# CONFIG_BCM43XX_DMA_MODE is not set
+# CONFIG_BCM43XX_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_NET_WIRELESS=y
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+# CONFIG_IWLWIFI_LEDS is not set
+# CONFIG_IWLWIFI_RFKILL is not set
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWLAGN_LEDS is not set
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+# CONFIG_IWL3945_RFKILL is not set
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+# CONFIG_IWL3945_LEDS is not set
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2400PCI=m
+# CONFIG_RT2400PCI_RFKILL is not set
+# CONFIG_RT2400PCI_LEDS is not set
+CONFIG_RT2500PCI=m
+# CONFIG_RT2500PCI_RFKILL is not set
+# CONFIG_RT2500PCI_LEDS is not set
+CONFIG_RT61PCI=m
+# CONFIG_RT61PCI_RFKILL is not set
+# CONFIG_RT61PCI_LEDS is not set
+CONFIG_RT2500USB=m
+# CONFIG_RT2500USB_LEDS is not set
+CONFIG_RT73USB=m
+# CONFIG_RT73USB_LEDS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# PCMCIA network device support
+#
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# ATM drivers
+#
+# CONFIG_ATM_DUMMY is not set
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+# CONFIG_ATM_ZATM is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+# CONFIG_ATM_IDT77252_RCV_ALL is not set
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_FORE200E_MAYBE=m
+# CONFIG_ATM_FORE200E_PCA is not set
+CONFIG_ATM_HE=m
+# CONFIG_ATM_HE_USE_SUNI is not set
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+# CONFIG_SKFP is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLIP_SMART=y
+# CONFIG_SLIP_MODE_SLIP6 is not set
+CONFIG_NET_FC=y
+# CONFIG_SHAPER is not set
+CONFIG_NETCONSOLE=m
+CONFIG_NETPOLL=y
+# CONFIG_NETPOLL_RX is not set
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+
+#
+# ISDN subsystem
+#
+CONFIG_ISDN=m
+
+#
+# Old ISDN4Linux
+#
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+# CONFIG_ISDN_PPP_BSDCOMP is not set
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+CONFIG_HISAX_NO_SENDCOMPLETE=y
+CONFIG_HISAX_NO_LLC=y
+CONFIG_HISAX_NO_KEYPAD=y
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+# CONFIG_HISAX_DEBUG is not set
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+# CONFIG_HISAX_HFCUSB is not set
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+
+#
+# Siemens Gigaset
+#
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+# CONFIG_GIGASET_DEBUG is not set
+# CONFIG_GIGASET_UNDOCREQ is not set
+
+#
+# CAPI subsystem
+#
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+
+#
+# Active AVM cards
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+
+#
+# Active Eicon DIVA Server cards
+#
+# CONFIG_CAPI_EICON is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+# CONFIG_INPUT_TSDEV is not set
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_VSXXXAA=m
+CONFIG_INPUT_JOYSTICK=y
+# CONFIG_JOYSTICK_ANALOG is not set
+# CONFIG_JOYSTICK_A3D is not set
+# CONFIG_JOYSTICK_ADI is not set
+# CONFIG_JOYSTICK_COBRA is not set
+# CONFIG_JOYSTICK_GF2K is not set
+# CONFIG_JOYSTICK_GRIP is not set
+# CONFIG_JOYSTICK_GRIP_MP is not set
+# CONFIG_JOYSTICK_GUILLEMOT is not set
+# CONFIG_JOYSTICK_INTERACT is not set
+# CONFIG_JOYSTICK_SIDEWINDER is not set
+# CONFIG_JOYSTICK_TMDC is not set
+# CONFIG_JOYSTICK_IFORCE is not set
+# CONFIG_JOYSTICK_WARRIOR is not set
+# CONFIG_JOYSTICK_MAGELLAN is not set
+# CONFIG_JOYSTICK_SPACEORB is not set
+# CONFIG_JOYSTICK_SPACEBALL is not set
+# CONFIG_JOYSTICK_STINGER is not set
+CONFIG_JOYSTICK_TWIDJOY=m
+# CONFIG_JOYSTICK_DB9 is not set
+# CONFIG_JOYSTICK_GAMECON is not set
+# CONFIG_JOYSTICK_TURBOGRAFX is not set
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_CT82C710 is not set
+# CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+# CONFIG_ROCKETPORT is not set
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_ISI is not set
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=m
+CONFIG_SERIAL_8250_PCI=m
+CONFIG_SERIAL_8250_PNP=m
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=32
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=m
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_CRASH=m
+CONFIG_PRINTER=m
+CONFIG_LP_CONSOLE=y
+CONFIG_PPDEV=m
+# CONFIG_TIPAR is not set
+
+#
+# IPMI
+#
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+# CONFIG_ACQUIRE_WDT is not set
+# CONFIG_ADVANTECH_WDT is not set
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+# CONFIG_SC520_WDT is not set
+# CONFIG_EUROTECH_WDT is not set
+# CONFIG_IB700_WDT is not set
+CONFIG_IBMASR=m
+# CONFIG_WAFER_WDT is not set
+CONFIG_I6300ESB_WDT=m
+CONFIG_I8XX_TCO=m
+CONFIG_HP_WATCHDOG=m
+# CONFIG_SC1200_WDT is not set
+# CONFIG_60XX_WDT is not set
+# CONFIG_SBC8360_WDT is not set
+# CONFIG_CPU5_WDT is not set
+CONFIG_W83627HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+# CONFIG_SBC_EPX_C3_WATCHDOG is not set
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+# CONFIG_HW_RANDOM_GEODE is not set
+CONFIG_NVRAM=y
+CONFIG_RTC=y
+CONFIG_DTLK=m
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+CONFIG_AGP=y
+CONFIG_AGP_AMD64=y
+CONFIG_AGP_INTEL=y
+CONFIG_AGP_SIS=y
+CONFIG_AGP_VIA=y
+CONFIG_DRM=m
+# CONFIG_DRM_TDFX is not set
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+# CONFIG_DRM_SIS is not set
+CONFIG_DRM_VIA=m
+CONFIG_DRM_SAVAGE=m
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+# CONFIG_MWAVE is not set
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_RAW_DRIVER=y
+CONFIG_MAX_RAW_DEVS=8192
+CONFIG_HPET=y
+# CONFIG_HPET_RTC_IRQ is not set
+# CONFIG_HPET_MMAP is not set
+CONFIG_HANGCHECK_TIMER=m
+# CONFIG_TCG_TPM is not set
+CONFIG_TELCLOCK=m
+
+#
+# I2C support
+#
+CONFIG_I2C=m
+CONFIG_I2C_CHARDEV=m
+
+#
+# I2C Algorithms
+#
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCF=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+# CONFIG_I2C_ALI1535 is not set
+# CONFIG_I2C_ALI1563 is not set
+# CONFIG_I2C_ALI15X3 is not set
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+# CONFIG_I2C_I810 is not set
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_ISA=m
+CONFIG_I2C_NFORCE2=m
+# CONFIG_I2C_OCORES is not set
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_PROSAVAGE=m
+CONFIG_I2C_SAVAGE4=m
+# CONFIG_I2C_SIS5595 is not set
+# CONFIG_I2C_SIS630 is not set
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_STUB=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+CONFIG_I2C_VOODOO3=m
+# CONFIG_I2C_PCA_ISA is not set
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_SENSORS_DS1337=m
+CONFIG_SENSORS_DS1374=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_SENSORS_PCA9539=m
+CONFIG_SENSORS_PCF8591=m
+CONFIG_SENSORS_MAX6875=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Misc devices
+#
+# CONFIG_IBM_ASM is not set
+CONFIG_EEPROM_93CX6=m
+CONFIG_HP_ILO=m
+
+#
+# Multimedia devices
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
+
+#
+# Video Capture Adapters
+#
+
+#
+# Video Capture Adapters
+#
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_VIVI is not set
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_SAA6588=m
+# CONFIG_VIDEO_BWQCAM is not set
+# CONFIG_VIDEO_CQCAM is not set
+# CONFIG_VIDEO_W9966 is not set
+# CONFIG_VIDEO_CPIA is not set
+CONFIG_VIDEO_CPIA2=m
+# CONFIG_VIDEO_SAA5246A is not set
+# CONFIG_VIDEO_SAA5249 is not set
+# CONFIG_TUNER_3036 is not set
+# CONFIG_VIDEO_STRADIS is not set
+# CONFIG_VIDEO_ZORAN is not set
+# CONFIG_VIDEO_SAA7134 is not set
+# CONFIG_VIDEO_MXB is not set
+# CONFIG_VIDEO_DPC is not set
+# CONFIG_VIDEO_HEXIUM_ORION is not set
+# CONFIG_VIDEO_HEXIUM_GEMINI is not set
+# CONFIG_VIDEO_CX88 is not set
+
+#
+# Encoders and Decoders
+#
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_TLV320AIC23B=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+
+#
+# V4L USB devices
+#
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_24XXX=y
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+
+#
+# Radio Adapters
+#
+# CONFIG_RADIO_GEMTEK_PCI is not set
+# CONFIG_RADIO_MAXIRADIO is not set
+# CONFIG_RADIO_MAESTRO is not set
+CONFIG_USB_DSBR=m
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_BUF=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+# CONFIG_FIRMWARE_EDID is not set
+CONFIG_FB=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+# CONFIG_FB_ARC is not set
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+CONFIG_FB_VGA16=m
+CONFIG_FB_VESA=y
+# CONFIG_FB_HGA is not set
+# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+CONFIG_FB_RIVA=m
+# CONFIG_FB_RIVA_I2C is not set
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+# CONFIG_FB_MATROX is not set
+# CONFIG_FB_RADEON is not set
+# CONFIG_FB_ATY128 is not set
+# CONFIG_FB_ATY is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+# CONFIG_FB_SIS is not set
+# CONFIG_FB_NEOMAGIC is not set
+CONFIG_FB_KYRO=m
+# CONFIG_FB_3DFX is not set
+# CONFIG_FB_VOODOO1 is not set
+# CONFIG_FB_TRIDENT is not set
+# CONFIG_FB_GEODE is not set
+# CONFIG_FB_VIRTUAL is not set
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+
+#
+# Logo configuration
+#
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=m
+CONFIG_BACKLIGHT_DEVICE=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_DEVICE=y
+
+#
+# Sound
+#
+CONFIG_SOUND=m
+
+#
+# Advanced Linux Sound Architecture
+#
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_RTCTIMER=m
+CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y
+CONFIG_SND_DYNAMIC_MINORS=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_VERBOSE_PROCFS=y
+# CONFIG_SND_VERBOSE_PRINTK is not set
+# CONFIG_SND_DEBUG is not set
+CONFIG_SND_VMASTER=y
+
+#
+# Generic devices
+#
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+# CONFIG_SND_MTS64 is not set
+# CONFIG_SND_SERIAL_U16550 is not set
+CONFIG_SND_MPU401=m
+# CONFIG_SND_PORTMAN2X4 is not set
+
+#
+# PCI devices
+#
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+# CONFIG_SND_AC97_POWER_SAVE is not set
+
+#
+# USB devices
+#
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+
+#
+# PCMCIA devices
+#
+# CONFIG_SND_VXPOCKET is not set
+# CONFIG_SND_PDAUDIOCF is not set
+
+#
+# SoC audio support
+#
+# CONFIG_SND_SOC is not set
+
+#
+# Open Sound System
+#
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+
+#
+# USB support
+#
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_SPLIT_ISO=y
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT=y
+# CONFIG_USB_HIDINPUT_POWERBOOK is not set
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_USB_HIDDEV=y
+CONFIG_USB_AIPTEK=m
+CONFIG_USB_WACOM=m
+CONFIG_USB_ACECAD=m
+CONFIG_USB_KBTAB=m
+CONFIG_USB_POWERMATE=m
+CONFIG_USB_TOUCHSCREEN=m
+CONFIG_USB_TOUCHSCREEN_EGALAX=y
+CONFIG_USB_TOUCHSCREEN_PANJIT=y
+CONFIG_USB_TOUCHSCREEN_3M=y
+CONFIG_USB_TOUCHSCREEN_ITM=y
+# CONFIG_USB_YEALINK is not set
+CONFIG_USB_XPAD=m
+CONFIG_USB_ATI_REMOTE=m
+CONFIG_USB_ATI_REMOTE2=m
+CONFIG_USB_KEYSPAN_REMOTE=m
+CONFIG_USB_APPLETOUCH=m
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+
+#
+# USB Serial Converter support
+#
+CONFIG_USB_SERIAL=m
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRPRIME=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_EZUSB=y
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_AUERSWALD=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_LED=m
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TEST=m
+
+#
+# USB DSL modem support
+#
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_WBSD=m
+
+#
+# LED devices
+#
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+# CONFIG_INFINIBAND is not set
+
+#
+# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
+#
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_K8=m
+CONFIG_EDAC_POLL=y
+
+#
+# Real Time Clock
+#
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=m
+CONFIG_RTC_INTF_PROC=m
+CONFIG_RTC_INTF_DEV=m
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+
+#
+# RTC drivers
+#
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_RS5C372=m
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_TEST is not set
+CONFIG_RTC_DRV_V3020=m
+
+#
+# DMA Engine support
+#
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+
+#
+# Firmware Drivers
+#
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT2_FS_XIP=y
+CONFIG_FS_XIP=y
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+# CONFIG_JBD2_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+CONFIG_FS_POSIX_ACL=y
+# CONFIG_XFS_FS is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_NOLOCK=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+CONFIG_AUTOFS4_FS=m
+# CONFIG_FUSE_FS is not set
+
+#
+# Caches
+#
+CONFIG_FSCACHE=m
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_ZISOFS_FS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+CONFIG_CACHEFILES=m
+CONFIG_CACHEFILES_DEBUG=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+CONFIG_JFFS2_SUMMARY=y
+# CONFIG_JFFS2_FS_XATTR is not set
+# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
+CONFIG_JFFS2_ZLIB=y
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+# CONFIG_SQUASHFS_VMALLOC is not set
+CONFIG_VXFS_FS=m
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_FSCACHE=y
+CONFIG_NFS_DIRECTIO=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_TCP=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_DFS_UPCALL=y
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+# CONFIG_ATARI_PARTITION is not set
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+# CONFIG_LDM_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+
+#
+# Distributed Lock Manager
+#
+CONFIG_DLM=m
+CONFIG_DLM_DEBUG=y
+
+#
+# Instrumentation Support
+#
+CONFIG_PROFILING=y
+CONFIG_OPROFILE=m
+CONFIG_KPROBES=y
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_UNUSED_SYMBOLS is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHEDSTATS=y
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_RWSEMS is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_FS=y
+# CONFIG_DEBUG_VM is not set
+CONFIG_DEBUG_LIST=y
+# CONFIG_FRAME_POINTER is not set
+# CONFIG_FORCED_INLINING is not set
+CONFIG_BOOT_DELAY=y
+# CONFIG_RCU_TORTURE_TEST is not set
+CONFIG_SAMPLES=y
+CONFIG_SAMPLE_MARKERS=m
+CONFIG_SAMPLE_TRACEPOINTS=m
+CONFIG_DEBUG_RODATA=y
+CONFIG_DEBUG_STACKOVERFLOW=y
+# CONFIG_DEBUG_STACK_USAGE is not set
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_NETWORK_XFRM=y
+CONFIG_SECURITY_CAPABILITIES=y
+# CONFIG_SECURITY_ROOTPLUG is not set
+# CONFIG_SECURITY_SECLVL is not set
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+
+#
+# Cryptographic options
+#
+CONFIG_CRYPTO=y
+CONFIG_CRYPTO_API=m
+CONFIG_CRYPTO_FIPS=y
+CONFIG_CRYPTO_ALGAPI=m
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_SEQIV=m
+CONFIG_CRYPTO_HASH=m
+CONFIG_CRYPTO_RNG=m
+CONFIG_CRYPTO_MANAGER=m
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_NHMAC=m
+CONFIG_CRYPTO_XCBC=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_WP512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_X86_64=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_TEST=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_SIGNATURE=y
+CONFIG_CRYPTO_SIGNATURE_DSA=y
+CONFIG_CRYPTO_MPILIB=y
+
+#
+# Random Number Generation
+#
+CONFIG_CRYPTO_ANSI_CPRNG=m
+
+#
+# Hardware crypto devices
+#
+CONFIG_XEN=y
+CONFIG_XEN_INTERFACE_VERSION=0x00030203
+
+#
+# XEN
+#
+CONFIG_XEN_PRIVILEGED_GUEST=y
+# CONFIG_XEN_UNPRIVILEGED_GUEST is not set
+CONFIG_XEN_PRIVCMD=y
+CONFIG_XEN_XENBUS_DEV=y
+CONFIG_XEN_BACKEND=y
+CONFIG_XEN_BLKDEV_BACKEND=m
+CONFIG_XEN_BLKDEV_TAP=m
+CONFIG_XEN_NETDEV_BACKEND=m
+# CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=m
+CONFIG_XEN_PCIDEV_BACKEND=m
+CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
+# CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
+# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
+# CONFIG_XEN_PCIDEV_BE_DEBUG is not set
+# CONFIG_XEN_TPMDEV_BACKEND is not set
+CONFIG_XEN_BLKDEV_FRONTEND=m
+CONFIG_XEN_NETDEV_FRONTEND=m
+CONFIG_XEN_FRAMEBUFFER=y
+CONFIG_XEN_KEYBOARD=y
+CONFIG_XEN_SCRUB_PAGES=y
+# CONFIG_XEN_DISABLE_SERIAL is not set
+CONFIG_XEN_SYSFS=y
+CONFIG_XEN_COMPAT_030002_AND_LATER=y
+# CONFIG_XEN_COMPAT_LATEST_ONLY is not set
+CONFIG_XEN_COMPAT_030002=y
+CONFIG_HAVE_ARCH_ALLOC_SKB=y
+CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y
+CONFIG_HAVE_IRQ_IGNORE_UNHANDLED=y
+CONFIG_NO_IDLE_HZ=y
+CONFIG_XEN_UTIL=y
+CONFIG_XEN_BALLOON=y
+CONFIG_XEN_DEVMEM=y
+CONFIG_XEN_SKBUFF=y
+CONFIG_XEN_REBOOT=y
+CONFIG_XEN_SMPBOOT=y
+
+#
+# Library routines
+#
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_LIBCRC32C=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-i686-default.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-i686-default.config
new file mode 100644
index 0000000..81bc07f
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-i686-default.config
@@ -0,0 +1,4409 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.27.21
+# Wed May 13 22:15:21 2009
+#
+# CONFIG_64BIT is not set
+CONFIG_X86_32=y
+# CONFIG_X86_64 is not set
+CONFIG_X86=y
+CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
+# CONFIG_GENERIC_LOCKBREAK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_CLOCKSOURCE_WATCHDOG=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_FAST_CMPXCHG_LOCAL=y
+CONFIG_MMU=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+# CONFIG_GENERIC_TIME_VSYSCALL is not set
+CONFIG_ARCH_HAS_CPU_RELAX=y
+CONFIG_ARCH_HAS_DEFAULT_IDLE=y
+CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
+CONFIG_HAVE_SETUP_PER_CPU_AREA=y
+# CONFIG_HAVE_CPUMASK_OF_CPU_MAP is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# CONFIG_ZONE_DMA32 is not set
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+# CONFIG_AUDIT_ARCH is not set
+CONFIG_ARCH_SUPPORTS_AOUT=y
+CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_32_SMP=y
+CONFIG_X86_HT=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
+CONFIG_KTIME_SCALAR=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-0.1-default"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SUSE_KERNEL=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_TREE=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_CGROUPS=y
+# CONFIG_CGROUP_DEBUG is not set
+CONFIG_CGROUP_NS=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_DEVICE=y
+CONFIG_CPUSETS=y
+CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+# CONFIG_USER_SCHED is not set
+CONFIG_CGROUP_SCHED=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_RESOURCE_COUNTERS=y
+CONFIG_MM_OWNER=y
+CONFIG_CGROUP_MEM_RES_CTLR=y
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_PROC_PID_CPUSET=y
+CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_IPC_NS=y
+CONFIG_USER_NS=y
+CONFIG_PID_NS=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_PCSPKR_PLATFORM=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+# CONFIG_TRACEPOINTS is not set
+CONFIG_MARKERS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_KRETPROBES=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+# CONFIG_HAVE_DMA_ATTRS is not set
+CONFIG_USE_GENERIC_SMP_HELPERS=y
+# CONFIG_HAVE_CLK is not set
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+# CONFIG_UTRACE is not set
+CONFIG_BLOCK=y
+CONFIG_LBD=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_LSF=y
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLK_DEV_INTEGRITY=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
+
+#
+# Processor type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SMP=y
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
+# CONFIG_X86_PC is not set
+# CONFIG_X86_XEN is not set
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+CONFIG_X86_GENERICARCH=y
+# CONFIG_X86_NUMAQ is not set
+CONFIG_X86_SUMMIT=y
+CONFIG_X86_ES7000=y
+CONFIG_X86_BIGSMP=y
+# CONFIG_X86_64_XEN is not set
+# CONFIG_X86_VSMP is not set
+# CONFIG_X86_RDC321X is not set
+# CONFIG_PARAVIRT_GUEST is not set
+CONFIG_MEMTEST=y
+CONFIG_X86_CYCLONE_TIMER=y
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+CONFIG_M586=y
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+# CONFIG_M686 is not set
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+# CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+# CONFIG_GENERIC_CPU is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CPU=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_XADD=y
+CONFIG_X86_PPRO_FENCE=y
+CONFIG_X86_F00F_BUG=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_ALIGNMENT_16=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=4
+CONFIG_HPET_TIMER=y
+CONFIG_HPET_EMULATE_RTC=y
+CONFIG_DMI=y
+# CONFIG_IOMMU_HELPER is not set
+CONFIG_NR_CPUS=32
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+# CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS is not set
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_MCE=y
+CONFIG_X86_MCE_NONFATAL=y
+CONFIG_X86_MCE_P4THERMAL=y
+CONFIG_VM86=y
+CONFIG_TOSHIBA=m
+CONFIG_I8K=m
+CONFIG_X86_REBOOTFIXUPS=y
+CONFIG_MICROCODE=m
+CONFIG_MICROCODE_OLD_INTERFACE=y
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+# CONFIG_NOHIGHMEM is not set
+CONFIG_HIGHMEM4G=y
+# CONFIG_HIGHMEM64G is not set
+CONFIG_PAGE_OFFSET=0xC0000000
+CONFIG_HIGHMEM=y
+
+#
+# NUMA (Summit) requires SMP, 64GB highmem support, ACPI
+#
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_MMU_NOTIFIER=y
+CONFIG_HIGHPTE=y
+CONFIG_X86_RESERVE_LOW_64K=y
+# CONFIG_MATH_EMULATION is not set
+CONFIG_MTRR=y
+# CONFIG_MTRR_SANITIZER is not set
+CONFIG_X86_PAT=y
+# CONFIG_EFI is not set
+# CONFIG_IRQBALANCE is not set
+CONFIG_SECCOMP=y
+# CONFIG_SECCOMP_DISABLE_TSC is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+# CONFIG_KEXEC_JUMP is not set
+CONFIG_PHYSICAL_START=0x100000
+CONFIG_RELOCATABLE=y
+CONFIG_PHYSICAL_ALIGN=0x100000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_COMPAT_VDSO=y
+
+#
+# Hardware Performance Monitoring support
+#
+CONFIG_PERFMON=y
+# CONFIG_PERFMON_DEBUG is not set
+CONFIG_PERFMON_DEBUG_FS=y
+CONFIG_X86_PERFMON_P6=m
+CONFIG_X86_PERFMON_P4=m
+CONFIG_X86_PERFMON_PEBS_P4=m
+CONFIG_X86_PERFMON_CORE=m
+CONFIG_X86_PERFMON_PEBS_CORE=m
+CONFIG_X86_PERFMON_INTEL_ATOM=m
+CONFIG_X86_PERFMON_INTEL_ARCH=m
+CONFIG_X86_PERFMON_AMD64=m
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+
+#
+# Power management options
+#
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP_SMP=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION=""
+CONFIG_ACPI=y
+CONFIG_ACPI_SLEEP=y
+CONFIG_ACPI_PROCFS=y
+CONFIG_ACPI_PROCFS_POWER=y
+CONFIG_ACPI_SYSFS_POWER=y
+CONFIG_ACPI_PROC_EVENT=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_DOCK=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_WMI=m
+# CONFIG_ACPI_ASUS is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_CUSTOM_DSDT_FILE=""
+# CONFIG_ACPI_CUSTOM_DSDT is not set
+CONFIG_ACPI_CUSTOM_DSDT_INITRD=y
+CONFIG_ACPI_BLACKLIST_YEAR=2001
+CONFIG_ACPI_DEBUG=y
+# CONFIG_ACPI_DEBUG_FUNC_TRACE is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_PCI_SLOT=m
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_X86_PM_TIMER=y
+CONFIG_ACPI_CONTAINER=m
+CONFIG_ACPI_SBS=m
+CONFIG_X86_APM_BOOT=y
+CONFIG_APM=m
+# CONFIG_APM_IGNORE_USER_SUSPEND is not set
+CONFIG_APM_DO_ENABLE=y
+# CONFIG_APM_CPU_IDLE is not set
+CONFIG_APM_DISPLAY_BLANK=y
+CONFIG_APM_ALLOW_INTS=y
+# CONFIG_APM_REAL_MODE_POWER_OFF is not set
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+CONFIG_X86_POWERNOW_K6=m
+CONFIG_X86_POWERNOW_K7=m
+CONFIG_X86_POWERNOW_K7_ACPI=y
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+CONFIG_X86_GX_SUSPMOD=m
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
+CONFIG_X86_SPEEDSTEP_ICH=m
+CONFIG_X86_SPEEDSTEP_SMI=m
+CONFIG_X86_P4_CLOCKMOD=m
+CONFIG_X86_CPUFREQ_NFORCE2=m
+CONFIG_X86_LONGRUN=m
+CONFIG_X86_LONGHAUL=m
+CONFIG_X86_E_POWERSAVER=m
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+CONFIG_X86_SPEEDSTEP_LIB=m
+CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK=y
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_GOV_LADDER=y
+CONFIG_CPU_IDLE_GOV_MENU=y
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+# CONFIG_PCI_GOBIOS is not set
+# CONFIG_PCI_GOMMCONFIG is not set
+# CONFIG_PCI_GODIRECT is not set
+# CONFIG_PCI_GOOLPC is not set
+# CONFIG_PCI_GOXEN_FE is not set
+CONFIG_PCI_GOANY=y
+CONFIG_PCI_BIOS=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_OLPC=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+CONFIG_PCIEAER=y
+CONFIG_PCIEASPM=y
+# CONFIG_PCIEASPM_DEBUG is not set
+CONFIG_ARCH_SUPPORTS_MSI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_HT_IRQ=y
+CONFIG_ISA_DMA_API=y
+CONFIG_ISA=y
+# CONFIG_EISA is not set
+# CONFIG_MCA is not set
+CONFIG_SCx200=m
+CONFIG_SCx200HR_TIMER=m
+CONFIG_OLPC=y
+CONFIG_K8_NB=y
+CONFIG_PCCARD=m
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=m
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=m
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+CONFIG_I82092=m
+CONFIG_I82365=m
+CONFIG_TCIC=m
+CONFIG_PCMCIA_PROBE=y
+CONFIG_PCCARD_NONSTATIC=m
+CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_COMPAQ=m
+CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM=y
+CONFIG_HOTPLUG_PCI_IBM=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+CONFIG_HOTPLUG_PCI_CPCI=y
+CONFIG_HOTPLUG_PCI_CPCI_ZT5550=m
+CONFIG_HOTPLUG_PCI_CPCI_GENERIC=m
+CONFIG_HOTPLUG_PCI_SHPC=m
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=m
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+CONFIG_XFRM_SUB_POLICY=y
+CONFIG_XFRM_MIGRATE=y
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=m
+CONFIG_NET_KEY=m
+CONFIG_NET_KEY_MIGRATE=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=m
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_TCP_CONG_YEAH=m
+CONFIG_TCP_CONG_ILLINOIS=m
+# CONFIG_DEFAULT_BIC is not set
+CONFIG_DEFAULT_CUBIC=y
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+# CONFIG_DEFAULT_RENO is not set
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_IPV6_MIP6=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_NDISC_NODETYPE=y
+CONFIG_IPV6_TUNNEL=m
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETLABEL is not set
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CT_ACCT=y
+CONFIG_NF_CONNTRACK_MARK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CT_PROTO_DCCP=m
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=m
+CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CONNTRACK_AMANDA=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_NETBIOS_NS=m
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SANE=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
+CONFIG_NF_CONNTRACK_SLP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_DSCP=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_RATEEST=m
+CONFIG_NETFILTER_XT_TARGET_TRACE=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_DSCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_OWNER=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_RATEEST=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_TIME=m
+CONFIG_NETFILTER_XT_MATCH_U32=m
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV4=m
+# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_IPV4OPTIONS=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_NF_NAT_SNMP_BASIC=m
+CONFIG_NF_NAT_PROTO_DCCP=m
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_PROTO_UDPLITE=m
+CONFIG_NF_NAT_PROTO_SCTP=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_TFTP=m
+CONFIG_NF_NAT_AMANDA=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_SECURITY=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_MH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_IP6_NF_SECURITY=m
+
+#
+# DECnet: Netfilter Configuration
+#
+CONFIG_DECNET_NF_GRABULATOR=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_IP6=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+CONFIG_BRIDGE_EBT_NFLOG=m
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+# CONFIG_IP_DCCP_CCID2_DEBUG is not set
+CONFIG_IP_DCCP_CCID3=m
+# CONFIG_IP_DCCP_CCID3_DEBUG is not set
+CONFIG_IP_DCCP_CCID3_RTO=100
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+# CONFIG_NET_DCCPPROBE is not set
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_TIPC is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+CONFIG_ATM_CLIP_NO_ICMP=y
+CONFIG_ATM_LANE=m
+CONFIG_ATM_MPOA=m
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_STP=m
+CONFIG_GARP=m
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+CONFIG_VLAN_8021Q_GVRP=y
+CONFIG_DECNET=m
+CONFIG_DECNET_ROUTER=y
+CONFIG_LLC=y
+CONFIG_LLC2=m
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=m
+CONFIG_LTPC=m
+CONFIG_COPS=m
+CONFIG_COPS_DAYNA=y
+CONFIG_COPS_TANGENT=y
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+CONFIG_X25=m
+CONFIG_LAPB=m
+CONFIG_ECONET=m
+# CONFIG_ECONET_AUNUDP is not set
+# CONFIG_ECONET_NATIVE is not set
+CONFIG_WAN_ROUTER=m
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_MULTIQ=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_CLS_FLOW=m
+# CONFIG_NET_EMATCH is not set
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_NAT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_ACT_SKBEDIT=m
+# CONFIG_NET_CLS_IND is not set
+CONFIG_NET_SCH_FIFO=y
+CONFIG_DCB=m
+CONFIG_DCBNL=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+CONFIG_NET_TCPPROBE=m
+CONFIG_HAMRADIO=y
+
+#
+# Packet Radio protocols
+#
+CONFIG_AX25=m
+CONFIG_AX25_DAMA_SLAVE=y
+CONFIG_NETROM=m
+CONFIG_ROSE=m
+
+#
+# AX.25 network device drivers
+#
+CONFIG_MKISS=m
+CONFIG_6PACK=m
+CONFIG_BPQETHER=m
+CONFIG_SCC=m
+CONFIG_SCC_DELAY=y
+CONFIG_SCC_TRXECHO=y
+CONFIG_BAYCOM_SER_FDX=m
+CONFIG_BAYCOM_SER_HDX=m
+CONFIG_BAYCOM_PAR=m
+CONFIG_BAYCOM_EPP=m
+CONFIG_YAM=m
+CONFIG_CAN=m
+CONFIG_CAN_RAW=m
+CONFIG_CAN_BCM=m
+
+#
+# CAN Device Drivers
+#
+CONFIG_CAN_VCAN=m
+# CONFIG_CAN_DEBUG_DEVICES is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+CONFIG_IRDA_ULTRA=y
+
+#
+# IrDA options
+#
+CONFIG_IRDA_CACHE_LAST_LSAP=y
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+CONFIG_DONGLE=y
+CONFIG_ESI_DONGLE=m
+CONFIG_ACTISYS_DONGLE=m
+CONFIG_TEKRAM_DONGLE=m
+CONFIG_TOIM3232_DONGLE=m
+CONFIG_LITELINK_DONGLE=m
+CONFIG_MA600_DONGLE=m
+CONFIG_GIRBIL_DONGLE=m
+CONFIG_MCP2120_DONGLE=m
+CONFIG_OLD_BELKIN_DONGLE=m
+CONFIG_ACT200L_DONGLE=m
+CONFIG_KINGSUN_DONGLE=m
+CONFIG_KSDAZZLE_DONGLE=m
+CONFIG_KS959_DONGLE=m
+
+#
+# FIR device drivers
+#
+CONFIG_USB_IRDA=m
+CONFIG_SIGMATEL_FIR=m
+CONFIG_NSC_FIR=m
+CONFIG_WINBOND_FIR=m
+CONFIG_TOSHIBA_FIR=m
+CONFIG_SMC_IRCC_FIR=m
+CONFIG_ALI_FIR=m
+CONFIG_VLSI_FIR=m
+CONFIG_VIA_FIR=m
+CONFIG_MCS_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIBTUSB=m
+CONFIG_BT_HCIBTSDIO=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_AF_RXRPC=m
+# CONFIG_AF_RXRPC_DEBUG is not set
+CONFIG_RXKAD=m
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_PID=y
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_MESH=y
+CONFIG_MAC80211_LEDS=y
+CONFIG_MAC80211_DEBUGFS=y
+# CONFIG_MAC80211_DEBUG_MENU is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_RFKILL=m
+CONFIG_RFKILL_INPUT=m
+CONFIG_RFKILL_LEDS=y
+CONFIG_NET_9P=m
+# CONFIG_NET_9P_VIRTIO is not set
+# CONFIG_NET_9P_DEBUG is not set
+CONFIG_NETVM=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH=""
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_AR7_PARTS=m
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLKDEVS=m
+CONFIG_MTD_BLOCK=m
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+# CONFIG_SSFDC is not set
+CONFIG_MTD_OOPS=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ABSENT=m
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=m
+CONFIG_MTD_PHYSMAP_START=0x8000000
+CONFIG_MTD_PHYSMAP_LEN=0x4000000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+CONFIG_MTD_SBC_GXX=m
+CONFIG_MTD_SCx200_DOCFLASH=m
+CONFIG_MTD_AMD76XROM=m
+CONFIG_MTD_ICHXROM=m
+CONFIG_MTD_ESB2ROM=m
+CONFIG_MTD_CK804XROM=m
+CONFIG_MTD_SCB2_FLASH=m
+CONFIG_MTD_NETtel=m
+CONFIG_MTD_DILNETPC=m
+CONFIG_MTD_DILNETPC_BOOTSIZE=0x80000
+CONFIG_MTD_L440GX=m
+CONFIG_MTD_PCI=m
+CONFIG_MTD_INTEL_VR_NOR=m
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_PMC551=m
+CONFIG_MTD_PMC551_BUGFIX=y
+# CONFIG_MTD_PMC551_DEBUG is not set
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+CONFIG_MTD_SLRAM=m
+CONFIG_MTD_PHRAM=m
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+CONFIG_MTD_DOC2000=m
+CONFIG_MTD_DOC2001=m
+CONFIG_MTD_DOC2001PLUS=m
+CONFIG_MTD_DOCPROBE=m
+CONFIG_MTD_DOCECC=m
+CONFIG_MTD_DOCPROBE_ADVANCED=y
+CONFIG_MTD_DOCPROBE_ADDRESS=0x0000
+CONFIG_MTD_DOCPROBE_HIGH=y
+CONFIG_MTD_DOCPROBE_55AA=y
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
+CONFIG_MTD_NAND_CAFE=m
+CONFIG_MTD_NAND_CS553X=m
+CONFIG_MTD_NAND_NANDSIM=m
+CONFIG_MTD_NAND_PLATFORM=m
+CONFIG_MTD_ALAUDA=m
+CONFIG_MTD_ONENAND=m
+# CONFIG_MTD_ONENAND_VERIFY_WRITE is not set
+CONFIG_MTD_ONENAND_OTP=y
+CONFIG_MTD_ONENAND_2X_PROGRAM=y
+CONFIG_MTD_ONENAND_SIM=m
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=m
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+CONFIG_PARPORT_PC_FIFO=y
+CONFIG_PARPORT_PC_SUPERIO=y
+CONFIG_PARPORT_PC_PCMCIA=m
+# CONFIG_PARPORT_GSC is not set
+CONFIG_PARPORT_AX88796=m
+CONFIG_PARPORT_1284=y
+CONFIG_PARPORT_NOT_PC=y
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_ISAPNP=y
+CONFIG_PNPBIOS=y
+CONFIG_PNPBIOS_PROC_FS=y
+CONFIG_PNPACPI=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_FD=m
+CONFIG_BLK_DEV_XD=m
+CONFIG_PARIDE=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_BPCK6=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=64000
+CONFIG_BLK_DEV_XIP=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+CONFIG_ATA_OVER_ETH=m
+CONFIG_CIPHER_TWOFISH=m
+CONFIG_VIRTIO_BLK=m
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+CONFIG_IBM_ASM=m
+CONFIG_PHANTOM=m
+CONFIG_EEPROM_93CX6=m
+# CONFIG_SGI_IOC4 is not set
+CONFIG_TIFM_CORE=m
+CONFIG_TIFM_7XX1=m
+CONFIG_ACER_WMI=m
+CONFIG_ASUS_LAPTOP=m
+CONFIG_FUJITSU_LAPTOP=m
+# CONFIG_FUJITSU_LAPTOP_DEBUG is not set
+CONFIG_TC1100_WMI=m
+CONFIG_HP_WMI=m
+CONFIG_MSI_LAPTOP=m
+CONFIG_PANASONIC_LAPTOP=m
+CONFIG_COMPAL_LAPTOP=m
+CONFIG_SONY_LAPTOP=m
+CONFIG_SONYPI_COMPAT=y
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+CONFIG_INTEL_MENLOW=m
+CONFIG_EEEPC_LAPTOP=m
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_HP_ILO=m
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=m
+CONFIG_BLK_DEV_IDE=m
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+CONFIG_IDE_TIMINGS=y
+CONFIG_IDE_ATAPI=y
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=m
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_DELKIN=m
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_BLK_DEV_IDEACPI=y
+# CONFIG_IDE_TASK_IOCTL is not set
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=m
+CONFIG_BLK_DEV_PLATFORM=m
+CONFIG_BLK_DEV_CMD640=m
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=m
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_BLK_DEV_OFFBOARD=y
+CONFIG_BLK_DEV_GENERIC=m
+CONFIG_BLK_DEV_OPTI621=m
+CONFIG_BLK_DEV_RZ1000=m
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_AEC62XX=m
+CONFIG_BLK_DEV_ALI15X3=m
+CONFIG_BLK_DEV_AMD74XX=m
+CONFIG_BLK_DEV_ATIIXP=m
+CONFIG_BLK_DEV_CMD64X=m
+CONFIG_BLK_DEV_TRIFLEX=m
+CONFIG_BLK_DEV_CS5520=m
+CONFIG_BLK_DEV_CS5530=m
+CONFIG_BLK_DEV_CS5535=m
+CONFIG_BLK_DEV_HPT366=m
+CONFIG_BLK_DEV_JMICRON=m
+CONFIG_BLK_DEV_SC1200=m
+CONFIG_BLK_DEV_PIIX=m
+CONFIG_BLK_DEV_IT8213=m
+CONFIG_BLK_DEV_IT821X=m
+CONFIG_BLK_DEV_NS87415=m
+CONFIG_BLK_DEV_PDC202XX_OLD=m
+CONFIG_BLK_DEV_PDC202XX_NEW=m
+CONFIG_BLK_DEV_SVWKS=m
+CONFIG_BLK_DEV_SIIMAGE=m
+CONFIG_BLK_DEV_SIS5513=m
+CONFIG_BLK_DEV_SLC90E66=m
+CONFIG_BLK_DEV_TRM290=m
+CONFIG_BLK_DEV_VIA82CXXX=m
+# CONFIG_BLK_DEV_TC86C001 is not set
+
+#
+# Other IDE chipsets support
+#
+
+#
+# Note: most of these also require special kernel boot parameters
+#
+CONFIG_BLK_DEV_4DRIVES=m
+CONFIG_BLK_DEV_ALI14XX=m
+CONFIG_BLK_DEV_DTC2278=m
+CONFIG_BLK_DEV_HT6560B=m
+CONFIG_BLK_DEV_QD65XX=m
+CONFIG_BLK_DEV_UMC8672=m
+CONFIG_BLK_DEV_IDEDMA=y
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_ENCLOSURE=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_FC_TGT_ATTRS=y
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+CONFIG_SCSI_SAS_HOST_SMP=y
+CONFIG_SCSI_SAS_LIBSAS_DEBUG=y
+CONFIG_SCSI_SRP_ATTRS=m
+CONFIG_SCSI_SRP_TGT_ATTRS=y
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ISCSI_TCP=m
+CONFIG_SCSI_CXGB3_ISCSI=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_7000FASST=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AHA152X=m
+CONFIG_SCSI_AHA1542=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
+CONFIG_AIC7XXX_RESET_DELAY_MS=5000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=32
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+CONFIG_AIC79XX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC94XX=m
+CONFIG_AIC94XX_DEBUG=y
+CONFIG_SCSI_DPT_I2O=m
+CONFIG_SCSI_ADVANSYS=m
+CONFIG_SCSI_IN2000=m
+CONFIG_SCSI_ARCMSR=m
+CONFIG_SCSI_ARCMSR_AER=y
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+CONFIG_SCSI_BUSLOGIC=m
+CONFIG_SCSI_FLASHPOINT=y
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_SCSI_DMX3191D=m
+CONFIG_SCSI_DTC3280=m
+CONFIG_SCSI_EATA=m
+CONFIG_SCSI_EATA_TAGGED_QUEUE=y
+CONFIG_SCSI_EATA_LINKED_COMMANDS=y
+CONFIG_SCSI_EATA_MAX_TAGS=16
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_GENERIC_NCR5380=m
+CONFIG_SCSI_GENERIC_NCR5380_MMIO=m
+CONFIG_SCSI_GENERIC_NCR53C400=y
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+CONFIG_SCSI_INIA100=m
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_MVSAS=m
+CONFIG_SCSI_NCR53C406A=m
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+CONFIG_SCSI_IPR=m
+CONFIG_SCSI_IPR_TRACE=y
+CONFIG_SCSI_IPR_DUMP=y
+CONFIG_SCSI_PAS16=m
+CONFIG_SCSI_QLOGIC_FAS=m
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_SYM53C416=m
+CONFIG_SCSI_DC395x=m
+CONFIG_SCSI_DC390T=m
+CONFIG_SCSI_T128=m
+CONFIG_SCSI_U14_34F=m
+CONFIG_SCSI_U14_34F_TAGGED_QUEUE=y
+CONFIG_SCSI_U14_34F_LINKED_COMMANDS=y
+CONFIG_SCSI_U14_34F_MAX_TAGS=8
+CONFIG_SCSI_ULTRASTOR=m
+CONFIG_SCSI_NSP32=m
+CONFIG_SCSI_DEBUG=m
+CONFIG_SCSI_SRP=m
+CONFIG_SCSI_LOWLEVEL_PCMCIA=y
+CONFIG_PCMCIA_AHA152X=m
+CONFIG_PCMCIA_FDOMAIN=m
+CONFIG_PCMCIA_NINJA_SCSI=m
+CONFIG_PCMCIA_QLOGIC=m
+CONFIG_PCMCIA_SYM53C500=m
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_SCSI_DH_HP_SW=m
+CONFIG_SCSI_DH_EMC=m
+CONFIG_SCSI_DH_ALUA=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+CONFIG_PATA_ACPI=m
+CONFIG_PATA_ALI=m
+CONFIG_PATA_AMD=m
+CONFIG_PATA_ARTOP=m
+CONFIG_PATA_ATIIXP=m
+CONFIG_PATA_CMD640_PCI=m
+CONFIG_PATA_CMD64X=m
+CONFIG_PATA_CS5520=m
+CONFIG_PATA_CS5530=m
+CONFIG_PATA_CS5535=m
+CONFIG_PATA_CS5536=m
+CONFIG_PATA_CYPRESS=m
+CONFIG_PATA_EFAR=m
+CONFIG_ATA_GENERIC=m
+CONFIG_PATA_HPT366=m
+CONFIG_PATA_HPT37X=m
+CONFIG_PATA_HPT3X2N=m
+CONFIG_PATA_HPT3X3=m
+# CONFIG_PATA_HPT3X3_DMA is not set
+CONFIG_PATA_ISAPNP=m
+CONFIG_PATA_IT821X=m
+CONFIG_PATA_IT8213=m
+CONFIG_PATA_JMICRON=m
+CONFIG_PATA_LEGACY=m
+CONFIG_PATA_TRIFLEX=m
+CONFIG_PATA_MARVELL=m
+CONFIG_PATA_MPIIX=m
+CONFIG_PATA_OLDPIIX=m
+CONFIG_PATA_NETCELL=m
+CONFIG_PATA_NINJA32=m
+CONFIG_PATA_NS87410=m
+CONFIG_PATA_NS87415=m
+CONFIG_PATA_OPTI=m
+CONFIG_PATA_OPTIDMA=m
+CONFIG_PATA_PCMCIA=m
+CONFIG_PATA_PDC_OLD=m
+CONFIG_PATA_QDI=m
+CONFIG_PATA_RADISYS=m
+CONFIG_PATA_RZ1000=m
+CONFIG_PATA_SC1200=m
+CONFIG_PATA_SERVERWORKS=m
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+CONFIG_PATA_VIA=m
+CONFIG_PATA_WINBOND=m
+CONFIG_PATA_WINBOND_VLB=m
+CONFIG_PATA_SCH=m
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_DELAY=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_MAX_FC_SGE=256
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+# CONFIG_FUSION_LOGGING is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+# CONFIG_FIREWIRE is not set
+CONFIG_IEEE1394=m
+CONFIG_IEEE1394_OHCI1394=m
+CONFIG_IEEE1394_PCILYNX=m
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y
+CONFIG_IEEE1394_ETH1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_IEEE1394_VIDEO1394=m
+CONFIG_IEEE1394_DV1394=m
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+CONFIG_I2O=m
+CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+# CONFIG_MACINTOSH_DRIVERS is not set
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+CONFIG_MACVLAN=m
+CONFIG_EQUALIZER=m
+CONFIG_TUN=m
+CONFIG_VETH=m
+CONFIG_NET_SB1000=m
+CONFIG_ARCNET=m
+CONFIG_ARCNET_1201=m
+CONFIG_ARCNET_1051=m
+CONFIG_ARCNET_RAW=m
+CONFIG_ARCNET_CAP=m
+CONFIG_ARCNET_COM90xx=m
+CONFIG_ARCNET_COM90xxIO=m
+CONFIG_ARCNET_RIM_I=m
+# CONFIG_ARCNET_COM20020 is not set
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_BROADCOM_PHY=m
+CONFIG_ICPLUS_PHY=m
+CONFIG_REALTEK_PHY=m
+CONFIG_MDIO_BITBANG=m
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_EL1=m
+CONFIG_EL2=m
+CONFIG_ELPLUS=m
+CONFIG_EL16=m
+CONFIG_EL3=m
+CONFIG_3C515=m
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_LANCE=m
+CONFIG_NET_VENDOR_SMC=y
+CONFIG_WD80x3=m
+CONFIG_ULTRA=m
+CONFIG_SMC9194=m
+CONFIG_ENC28J60=m
+# CONFIG_ENC28J60_WRITEVERIFY is not set
+CONFIG_NET_VENDOR_RACAL=y
+CONFIG_NI52=m
+CONFIG_NI65=m
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+CONFIG_TULIP_NAPI=y
+CONFIG_TULIP_NAPI_HW_MITIGATION=y
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+CONFIG_AT1700=m
+CONFIG_DEPCA=m
+CONFIG_HP100=m
+CONFIG_NET_ISA=y
+CONFIG_E2100=m
+CONFIG_EWRK3=m
+CONFIG_EEXPRESS=m
+CONFIG_EEXPRESS_PRO=m
+CONFIG_HPLAN_PLUS=m
+CONFIG_HPLAN=m
+CONFIG_LP486E=m
+CONFIG_ETH16I=m
+CONFIG_NE2000=m
+CONFIG_ZNET=m
+CONFIG_SEEQ8005=m
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_AC3200=m
+CONFIG_APRICOT=m
+CONFIG_B44=m
+CONFIG_B44_PCI_AUTOSELECT=y
+CONFIG_B44_PCICORE_AUTOSELECT=y
+CONFIG_B44_PCI=y
+CONFIG_FORCEDETH=m
+CONFIG_FORCEDETH_NAPI=y
+CONFIG_CS89x0=m
+CONFIG_EEPRO100=m
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_R6040=m
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+# CONFIG_VIA_RHINE_MMIO is not set
+CONFIG_SC92031=m
+CONFIG_NET_POCKET=y
+CONFIG_ATP=m
+CONFIG_DE600=m
+CONFIG_DE620=m
+CONFIG_ATL2=m
+CONFIG_NETDEV_1000=y
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IP1000=m
+CONFIG_IGB=m
+CONFIG_IGB_LRO=y
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+# CONFIG_SKGE_DEBUG is not set
+CONFIG_SKY2=m
+# CONFIG_SKY2_DEBUG is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+CONFIG_ATL1=m
+CONFIG_ATL1E=m
+CONFIG_NETDEV_10000=y
+CONFIG_CHELSIO_T1=m
+CONFIG_CHELSIO_T1_1G=y
+CONFIG_CHELSIO_T3=m
+CONFIG_IXGBE=m
+CONFIG_IXGBE_LRO=y
+CONFIG_IXGBE_DCB=y
+CONFIG_IXGB=m
+CONFIG_S2IO=m
+CONFIG_MYRI10GE=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_MLX4_CORE=m
+CONFIG_MLX4_DEBUG=y
+CONFIG_TEHUTI=m
+CONFIG_BNX2X=m
+CONFIG_SFC=m
+# CONFIG_SFC_RESOURCE is not set
+CONFIG_TR=y
+CONFIG_IBMTR=m
+CONFIG_IBMOL=m
+CONFIG_IBMLS=m
+CONFIG_3C359=m
+CONFIG_TMS380TR=m
+CONFIG_TMSPCI=m
+CONFIG_SKISA=m
+CONFIG_PROTEON=m
+CONFIG_ABYSS=m
+CONFIG_SMCTR=m
+
+#
+# Wireless LAN
+#
+CONFIG_WLAN_PRE80211=y
+CONFIG_STRIP=m
+# CONFIG_ARLAN is not set
+CONFIG_WAVELAN=m
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+CONFIG_WLAN_80211=y
+CONFIG_PCMCIA_RAYCS=m
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_LIBERTAS=m
+CONFIG_LIBERTAS_USB=m
+CONFIG_LIBERTAS_CS=m
+CONFIG_LIBERTAS_SDIO=m
+# CONFIG_LIBERTAS_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_WL3501=m
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_USB_NET_RNDIS_WLAN=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_ADM8211=m
+CONFIG_MAC80211_HWSIM=m
+CONFIG_P54_COMMON=m
+CONFIG_P54_USB=m
+CONFIG_P54_PCI=m
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_ATH9K=m
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+CONFIG_IWLWIFI_LEDS=y
+CONFIG_IWLWIFI_RFKILL=y
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+CONFIG_IWLAGN_LEDS=y
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+CONFIG_IWL3945_RFKILL=y
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+CONFIG_IWL3945_LEDS=y
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_B43=m
+CONFIG_B43_PCI_AUTOSELECT=y
+CONFIG_B43_PCICORE_AUTOSELECT=y
+CONFIG_B43_PCMCIA=y
+CONFIG_B43_PIO=y
+CONFIG_B43_LEDS=y
+CONFIG_B43_RFKILL=y
+# CONFIG_B43_DEBUG is not set
+CONFIG_B43LEGACY=m
+CONFIG_B43LEGACY_PCI_AUTOSELECT=y
+CONFIG_B43LEGACY_PCICORE_AUTOSELECT=y
+CONFIG_B43LEGACY_LEDS=y
+CONFIG_B43LEGACY_RFKILL=y
+# CONFIG_B43LEGACY_DEBUG is not set
+CONFIG_B43LEGACY_DMA=y
+CONFIG_B43LEGACY_PIO=y
+CONFIG_B43LEGACY_DMA_AND_PIO_MODE=y
+# CONFIG_B43LEGACY_DMA_MODE is not set
+# CONFIG_B43LEGACY_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2X00_LIB_RFKILL=y
+CONFIG_RT2X00_LIB_LEDS=y
+CONFIG_RT2400PCI=m
+CONFIG_RT2400PCI_RFKILL=y
+CONFIG_RT2400PCI_LEDS=y
+CONFIG_RT2500PCI=m
+CONFIG_RT2500PCI_RFKILL=y
+CONFIG_RT2500PCI_LEDS=y
+CONFIG_RT61PCI=m
+CONFIG_RT61PCI_RFKILL=y
+CONFIG_RT61PCI_LEDS=y
+CONFIG_RT2500USB=m
+CONFIG_RT2500USB_LEDS=y
+CONFIG_RT73USB=m
+CONFIG_RT73USB_LEDS=y
+# CONFIG_RT2X00_LIB_DEBUGFS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_KC2190=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_HSO=m
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_PCMCIA_IBMTR=m
+CONFIG_WAN=y
+CONFIG_HOSTESS_SV11=m
+# CONFIG_COSA is not set
+CONFIG_LANMEDIA=m
+CONFIG_SEALEVEL_4021=m
+CONFIG_HDLC=m
+CONFIG_HDLC_RAW=m
+CONFIG_HDLC_RAW_ETH=m
+CONFIG_HDLC_CISCO=m
+CONFIG_HDLC_FR=m
+CONFIG_HDLC_PPP=m
+CONFIG_HDLC_X25=m
+CONFIG_PCI200SYN=m
+CONFIG_WANXL=m
+# CONFIG_PC300 is not set
+CONFIG_PC300TOO=m
+CONFIG_N2=m
+CONFIG_C101=m
+CONFIG_FARSYNC=m
+# CONFIG_DSCC4 is not set
+CONFIG_DLCI=m
+CONFIG_DLCI_MAX=8
+CONFIG_SDLA=m
+# CONFIG_WAN_ROUTER_DRIVERS is not set
+CONFIG_LAPBETHER=m
+CONFIG_X25_ASY=m
+# CONFIG_SBNI is not set
+CONFIG_ATM_DRIVERS=y
+CONFIG_ATM_DUMMY=m
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+CONFIG_ATM_ZATM=m
+# CONFIG_ATM_ZATM_DEBUG is not set
+CONFIG_ATM_NICSTAR=m
+CONFIG_ATM_NICSTAR_USE_SUNI=y
+CONFIG_ATM_NICSTAR_USE_IDT77105=y
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+CONFIG_ATM_IDT77252_RCV_ALL=y
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_IA=m
+# CONFIG_ATM_IA_DEBUG is not set
+CONFIG_ATM_FORE200E=m
+CONFIG_ATM_FORE200E_USE_TASKLET=y
+CONFIG_ATM_FORE200E_TX_RETRY=16
+CONFIG_ATM_FORE200E_DEBUG=0
+CONFIG_ATM_HE=m
+CONFIG_ATM_HE_USE_SUNI=y
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+CONFIG_SKFP=m
+CONFIG_HIPPI=y
+CONFIG_ROADRUNNER=m
+CONFIG_ROADRUNNER_LARGE_RINGS=y
+CONFIG_PLIP=m
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_PPPOL2TP=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=m
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_NET_FC=y
+CONFIG_NETCONSOLE=m
+CONFIG_NETCONSOLE_DYNAMIC=y
+CONFIG_NETPOLL=y
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
+CONFIG_ISDN=y
+CONFIG_MISDN=m
+CONFIG_MISDN_DSP=m
+CONFIG_MISDN_L1OIP=m
+
+#
+# mISDN hardware drivers
+#
+CONFIG_MISDN_HFCPCI=m
+CONFIG_MISDN_HFCMULTI=m
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+CONFIG_ISDN_PPP_BSDCOMP=m
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+CONFIG_ISDN_X25=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+# CONFIG_HISAX_NO_SENDCOMPLETE is not set
+# CONFIG_HISAX_NO_LLC is not set
+# CONFIG_HISAX_NO_KEYPAD is not set
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_0=y
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_AVM_A1=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_IX1MICROR2=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_ASUSCOM=y
+CONFIG_HISAX_TELEINT=y
+CONFIG_HISAX_HFCS=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_SPORTSTER=y
+CONFIG_HISAX_MIC=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_ISURF=y
+CONFIG_HISAX_HSTSAPHIR=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+CONFIG_HISAX_DEBUG=y
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+CONFIG_HISAX_HFCUSB=m
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+CONFIG_ISDN_DRV_ICN=m
+CONFIG_ISDN_DRV_PCBIT=m
+CONFIG_ISDN_DRV_SC=m
+CONFIG_ISDN_DRV_ACT2000=m
+CONFIG_HYSDN=m
+CONFIG_HYSDN_CAPI=y
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+CONFIG_GIGASET_M101=m
+# CONFIG_GIGASET_DEBUG is not set
+CONFIG_GIGASET_UNDOCREQ=y
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_CAPI_TRACE=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1ISA=m
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_T1ISA=m
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+CONFIG_CAPI_EICON=y
+CONFIG_ISDN_DIVAS=m
+CONFIG_ISDN_DIVAS_BRIPCI=y
+CONFIG_ISDN_DIVAS_PRIPCI=y
+CONFIG_ISDN_DIVAS_DIVACAPI=m
+CONFIG_ISDN_DIVAS_USERIDI=m
+CONFIG_ISDN_DIVAS_MAINT=m
+CONFIG_PHONE=m
+CONFIG_PHONE_IXJ=m
+CONFIG_PHONE_IXJ_PCMCIA=m
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+CONFIG_INPUT_POLLDEV=m
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+CONFIG_KEYBOARD_SUNKBD=m
+# CONFIG_KEYBOARD_LKKBD is not set
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_KEYBOARD_NEWTON=m
+# CONFIG_KEYBOARD_STOWAWAY is not set
+CONFIG_KEYBOARD_GPIO=m
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_LIFEBOOK=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_APPLETOUCH=m
+CONFIG_MOUSE_BCM5974=m
+CONFIG_MOUSE_INPORT=m
+CONFIG_MOUSE_ATIXL=y
+CONFIG_MOUSE_LOGIBM=m
+CONFIG_MOUSE_PC110PAD=m
+# CONFIG_MOUSE_VSXXXAA is not set
+CONFIG_MOUSE_GPIO=m
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_USB=y
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_ZHENHUA=m
+CONFIG_JOYSTICK_DB9=m
+CONFIG_JOYSTICK_GAMECON=m
+CONFIG_JOYSTICK_TURBOGRAFX=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+CONFIG_INPUT_TABLET=y
+CONFIG_TABLET_USB_ACECAD=m
+CONFIG_TABLET_USB_AIPTEK=m
+CONFIG_TABLET_USB_GTCO=m
+CONFIG_TABLET_USB_KBTAB=m
+CONFIG_TABLET_USB_WACOM=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ADS7846=m
+CONFIG_TOUCHSCREEN_FUJITSU=m
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_ELOUSB=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_INEXIO=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_TOUCHSCREEN_HTCPEN=m
+CONFIG_TOUCHSCREEN_PENMOUNT=m
+CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
+CONFIG_TOUCHSCREEN_TOUCHWIN=m
+CONFIG_TOUCHSCREEN_UCB1400=m
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
+CONFIG_TOUCHSCREEN_USB_EGALAX=y
+CONFIG_TOUCHSCREEN_USB_PANJIT=y
+CONFIG_TOUCHSCREEN_USB_3M=y
+CONFIG_TOUCHSCREEN_USB_ITM=y
+CONFIG_TOUCHSCREEN_USB_ETURBO=y
+CONFIG_TOUCHSCREEN_USB_GUNZE=y
+CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y
+CONFIG_TOUCHSCREEN_USB_IRTOUCH=y
+CONFIG_TOUCHSCREEN_USB_IDEALTEK=y
+CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y
+CONFIG_TOUCHSCREEN_USB_GOTOP=y
+CONFIG_TOUCHSCREEN_TOUCHIT213=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_APANEL=m
+CONFIG_INPUT_WISTRON_BTNS=m
+CONFIG_INPUT_ATLAS_BTNS=m
+CONFIG_INPUT_ATI_REMOTE=m
+CONFIG_INPUT_ATI_REMOTE2=m
+CONFIG_INPUT_KEYSPAN_REMOTE=m
+CONFIG_INPUT_POWERMATE=m
+CONFIG_INPUT_YEALINK=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_CT82C710=m
+CONFIG_SERIO_PARKBD=m
+CONFIG_SERIO_PCIPS2=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_DEVKMEM=y
+CONFIG_SERIAL_NONSTANDARD=y
+CONFIG_COMPUTONE=m
+CONFIG_ROCKETPORT=m
+CONFIG_CYCLADES=m
+CONFIG_CYZ_INTR=y
+CONFIG_DIGIEPCA=m
+CONFIG_ESPSERIAL=m
+CONFIG_MOXA_INTELLIO=m
+CONFIG_MOXA_SMARTIO=m
+CONFIG_ISI=m
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+CONFIG_RISCOM8=m
+CONFIG_SPECIALIX=m
+CONFIG_SX=m
+CONFIG_RIO=m
+CONFIG_RIO_OLDPCI=y
+CONFIG_STALDRV=y
+CONFIG_NOZOMI=m
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_PNP=y
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=16
+CONFIG_SERIAL_8250_RUNTIME_UARTS=8
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_FOURPORT=m
+CONFIG_SERIAL_8250_ACCENT=m
+CONFIG_SERIAL_8250_BOCA=m
+CONFIG_SERIAL_8250_EXAR_ST16C554=m
+CONFIG_SERIAL_8250_HUB6=m
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=0
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+CONFIG_PPDEV=m
+CONFIG_HVC_DRIVER=y
+CONFIG_VIRTIO_CONSOLE=m
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_HW_RANDOM_GEODE=m
+CONFIG_HW_RANDOM_VIA=m
+CONFIG_HW_RANDOM_VIRTIO=m
+CONFIG_NVRAM=m
+CONFIG_DTLK=m
+CONFIG_R3964=m
+CONFIG_APPLICOM=m
+CONFIG_SONYPI=m
+
+#
+# PCMCIA character devices
+#
+CONFIG_SYNCLINK_CS=m
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+CONFIG_IPWIRELESS=m
+CONFIG_MWAVE=m
+CONFIG_SCx200_GPIO=m
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_CS5535_GPIO=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=4096
+CONFIG_HPET=y
+CONFIG_HPET_MMAP=y
+CONFIG_HANGCHECK_TIMER=m
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
+CONFIG_DEVPORT=y
+CONFIG_CRASHER=m
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# PC SMBus host controller drivers
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_ISCH=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_NFORCE2=m
+CONFIG_I2C_NFORCE2_S4985=m
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+CONFIG_I2C_GPIO=m
+CONFIG_I2C_OCORES=m
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_TAOS_EVM=m
+CONFIG_I2C_TINY_USB=m
+
+#
+# Graphics adapter I2C/DDC channel drivers
+#
+CONFIG_I2C_VOODOO3=m
+
+#
+# Other I2C/SMBus bus drivers
+#
+CONFIG_I2C_PCA_ISA=m
+CONFIG_I2C_PCA_PLATFORM=m
+CONFIG_I2C_STUB=m
+CONFIG_SCx200_I2C=m
+CONFIG_SCx200_I2C_SCL=12
+CONFIG_SCx200_I2C_SDA=13
+CONFIG_SCx200_ACB=m
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_DS1682=m
+CONFIG_AT24=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8591=m
+# CONFIG_TPS65010 is not set
+CONFIG_SENSORS_MAX6875=m
+CONFIG_SENSORS_TSL2550=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+CONFIG_SPI_DEBUG=y
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=m
+CONFIG_SPI_BUTTERFLY=m
+CONFIG_SPI_LM70_LLP=m
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_AT25=m
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_TLE62X0=m
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# I2C GPIO expanders:
+#
+CONFIG_GPIO_MAX732X=m
+CONFIG_GPIO_PCA953X=m
+CONFIG_GPIO_PCF857X=m
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+CONFIG_GPIO_MAX7301=m
+CONFIG_GPIO_MCP23S08=m
+CONFIG_W1=m
+CONFIG_W1_CON=y
+
+#
+# 1-wire Bus Masters
+#
+CONFIG_W1_MASTER_MATROX=m
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS2482=m
+CONFIG_W1_MASTER_GPIO=m
+
+#
+# 1-wire Slaves
+#
+CONFIG_W1_SLAVE_THERM=m
+CONFIG_W1_SLAVE_SMEM=m
+CONFIG_W1_SLAVE_DS2433=m
+CONFIG_W1_SLAVE_DS2433_CRC=y
+CONFIG_W1_SLAVE_DS2760=m
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+CONFIG_PDA_POWER=m
+CONFIG_BATTERY_DS2760=m
+CONFIG_BATTERY_OLPC=m
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ABITUGURU3=m
+CONFIG_SENSORS_AD7414=m
+CONFIG_SENSORS_AD7418=m
+CONFIG_SENSORS_ADCXX=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1029=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ADT7470=m
+CONFIG_SENSORS_ADT7473=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_I5K_AMB=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_F71882FG=m
+CONFIG_SENSORS_F75375S=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_FSCHMD=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_CORETEMP=m
+CONFIG_SENSORS_IBMAEM=m
+CONFIG_SENSORS_IBMPEX=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM70=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_MAX6650=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_PC87427=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_DME1737=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_ADS7828=m
+CONFIG_SENSORS_THMC50=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT1211=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83L786NG=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+CONFIG_SENSORS_APPLESMC=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+CONFIG_THERMAL=m
+CONFIG_THERMAL_HWMON=y
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+CONFIG_ACQUIRE_WDT=m
+CONFIG_ADVANTECH_WDT=m
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+CONFIG_SC520_WDT=m
+CONFIG_EUROTECH_WDT=m
+CONFIG_IB700_WDT=m
+CONFIG_IBMASR=m
+CONFIG_WAFER_WDT=m
+CONFIG_I6300ESB_WDT=m
+CONFIG_ITCO_WDT=m
+CONFIG_ITCO_VENDOR_SUPPORT=y
+CONFIG_IT8712F_WDT=m
+CONFIG_HP_WATCHDOG=m
+CONFIG_SC1200_WDT=m
+CONFIG_SCx200_WDT=m
+CONFIG_PC87413_WDT=m
+CONFIG_60XX_WDT=m
+CONFIG_SBC8360_WDT=m
+CONFIG_SBC7240_WDT=m
+CONFIG_CPU5_WDT=m
+CONFIG_SMSC37B787_WDT=m
+CONFIG_W83627HF_WDT=m
+CONFIG_W83697HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+CONFIG_SBC_EPX_C3_WATCHDOG=m
+
+#
+# ISA-based Watchdog Cards
+#
+CONFIG_PCWATCHDOG=m
+CONFIG_MIXCOMWD=m
+CONFIG_WDT=m
+CONFIG_WDT_501=y
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB_POSSIBLE=y
+CONFIG_SSB=m
+CONFIG_SSB_SPROM=y
+CONFIG_SSB_BLOCKIO=y
+CONFIG_SSB_PCIHOST_POSSIBLE=y
+CONFIG_SSB_PCIHOST=y
+CONFIG_SSB_B43_PCI_BRIDGE=y
+CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
+CONFIG_SSB_PCMCIAHOST=y
+# CONFIG_SSB_DEBUG is not set
+CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
+CONFIG_SSB_DRIVER_PCICORE=y
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+CONFIG_MFD_SM501=m
+CONFIG_MFD_SM501_GPIO=y
+CONFIG_HTC_PASIC3=m
+# CONFIG_MFD_TMIO is not set
+
+#
+# Multimedia devices
+#
+
+#
+# Multimedia core support
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_ALLOW_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_DVB_CORE=m
+CONFIG_VIDEO_MEDIA=m
+
+#
+# Multimedia drivers
+#
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_MEDIA_ATTACH=y
+CONFIG_MEDIA_TUNER=m
+# CONFIG_MEDIA_TUNER_CUSTOMIZE is not set
+CONFIG_MEDIA_TUNER_SIMPLE=m
+CONFIG_MEDIA_TUNER_TDA8290=m
+CONFIG_MEDIA_TUNER_TDA827X=m
+CONFIG_MEDIA_TUNER_TDA18271=m
+CONFIG_MEDIA_TUNER_TDA9887=m
+CONFIG_MEDIA_TUNER_TEA5761=m
+CONFIG_MEDIA_TUNER_TEA5767=m
+CONFIG_MEDIA_TUNER_MT20XX=m
+CONFIG_MEDIA_TUNER_MT2060=m
+CONFIG_MEDIA_TUNER_MT2266=m
+CONFIG_MEDIA_TUNER_MT2131=m
+CONFIG_MEDIA_TUNER_QT1010=m
+CONFIG_MEDIA_TUNER_XC2028=m
+CONFIG_MEDIA_TUNER_XC5000=m
+CONFIG_MEDIA_TUNER_MXL5005S=m
+CONFIG_MEDIA_TUNER_MXL5007T=m
+CONFIG_VIDEO_V4L2=m
+CONFIG_VIDEO_V4L1=m
+CONFIG_VIDEOBUF_GEN=m
+CONFIG_VIDEOBUF_DMA_SG=m
+CONFIG_VIDEOBUF_VMALLOC=m
+CONFIG_VIDEOBUF_DMA_CONTIG=m
+CONFIG_VIDEOBUF_DVB=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+CONFIG_VIDEO_IR_I2C=m
+CONFIG_VIDEO_TVAUDIO=m
+CONFIG_VIDEO_TDA7432=m
+CONFIG_VIDEO_TDA9840=m
+CONFIG_VIDEO_TDA9875=m
+CONFIG_VIDEO_TEA6415C=m
+CONFIG_VIDEO_TEA6420=m
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS5345=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_M52790=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_VP27SMPX=m
+CONFIG_VIDEO_BT819=m
+CONFIG_VIDEO_BT856=m
+CONFIG_VIDEO_KS0127=m
+CONFIG_VIDEO_OV7670=m
+CONFIG_VIDEO_SAA7110=m
+CONFIG_VIDEO_SAA7111=m
+CONFIG_VIDEO_SAA7114=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA717X=m
+CONFIG_VIDEO_TVP5150=m
+CONFIG_VIDEO_VPX3220=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_SAA7185=m
+CONFIG_VIDEO_ADV7170=m
+CONFIG_VIDEO_ADV7175=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+CONFIG_VIDEO_VIVI=m
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_BT848_DVB=y
+CONFIG_VIDEO_SAA6588=m
+CONFIG_VIDEO_PMS=m
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+CONFIG_VIDEO_W9966=m
+CONFIG_VIDEO_CPIA=m
+CONFIG_VIDEO_CPIA_PP=m
+CONFIG_VIDEO_CPIA_USB=m
+CONFIG_VIDEO_CPIA2=m
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+# CONFIG_TUNER_3036 is not set
+CONFIG_VIDEO_STRADIS=m
+CONFIG_VIDEO_ZORAN=m
+CONFIG_VIDEO_ZORAN_DC30=m
+CONFIG_VIDEO_ZORAN_ZR36060=m
+CONFIG_VIDEO_ZORAN_BUZ=m
+CONFIG_VIDEO_ZORAN_DC10=m
+CONFIG_VIDEO_ZORAN_LML33=m
+CONFIG_VIDEO_ZORAN_LML33R10=m
+CONFIG_VIDEO_ZORAN_AVS6EYES=m
+CONFIG_VIDEO_MEYE=m
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_SAA7134_ALSA=m
+CONFIG_VIDEO_SAA7134_DVB=m
+CONFIG_VIDEO_MXB=m
+# CONFIG_VIDEO_DPC is not set
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_CX88_ALSA=m
+CONFIG_VIDEO_CX88_BLACKBIRD=m
+CONFIG_VIDEO_CX88_DVB=m
+CONFIG_VIDEO_CX88_VP3054=m
+CONFIG_VIDEO_CX23885=m
+CONFIG_VIDEO_AU0828=m
+CONFIG_VIDEO_IVTV=m
+CONFIG_VIDEO_FB_IVTV=m
+CONFIG_VIDEO_CX18=m
+CONFIG_VIDEO_CAFE_CCIC=m
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
+CONFIG_USB_GSPCA=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+CONFIG_VIDEO_PVRUSB2_DVB=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_EM28XX_ALSA=m
+CONFIG_VIDEO_EM28XX_DVB=m
+CONFIG_VIDEO_USBVISION=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+CONFIG_USB_ZR364XX=m
+CONFIG_USB_STKWEBCAM=m
+CONFIG_USB_S2255=m
+CONFIG_SOC_CAMERA=m
+CONFIG_SOC_CAMERA_MT9M001=m
+CONFIG_MT9M001_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_MT9V022=m
+CONFIG_MT9V022_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_PLATFORM=m
+CONFIG_VIDEO_SH_MOBILE_CEU=m
+CONFIG_RADIO_ADAPTERS=y
+CONFIG_RADIO_CADET=m
+CONFIG_RADIO_RTRACK=m
+CONFIG_RADIO_RTRACK2=m
+CONFIG_RADIO_AZTECH=m
+CONFIG_RADIO_GEMTEK=m
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+CONFIG_RADIO_SF16FMI=m
+CONFIG_RADIO_SF16FMR2=m
+CONFIG_RADIO_TERRATEC=m
+CONFIG_RADIO_TRUST=m
+CONFIG_RADIO_TYPHOON=m
+CONFIG_RADIO_TYPHOON_PROC_FS=y
+CONFIG_RADIO_ZOLTRIX=m
+CONFIG_USB_DSBR=m
+CONFIG_USB_SI470X=m
+CONFIG_DVB_CAPTURE_DRIVERS=y
+
+#
+# Supported SAA7146 based PCI Adapters
+#
+CONFIG_TTPCI_EEPROM=m
+CONFIG_DVB_AV7110=m
+# CONFIG_DVB_AV7110_FIRMWARE is not set
+CONFIG_DVB_AV7110_OSD=y
+CONFIG_DVB_BUDGET_CORE=m
+CONFIG_DVB_BUDGET=m
+CONFIG_DVB_BUDGET_CI=m
+CONFIG_DVB_BUDGET_AV=m
+CONFIG_DVB_BUDGET_PATCH=m
+
+#
+# Supported USB Adapters
+#
+CONFIG_DVB_USB=m
+# CONFIG_DVB_USB_DEBUG is not set
+CONFIG_DVB_USB_A800=m
+CONFIG_DVB_USB_DIBUSB_MB=m
+# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
+CONFIG_DVB_USB_DIBUSB_MC=m
+CONFIG_DVB_USB_DIB0700=m
+CONFIG_DVB_USB_UMT_010=m
+# CONFIG_DVB_USB_CXUSB is not set
+CONFIG_DVB_USB_M920X=m
+CONFIG_DVB_USB_GL861=m
+CONFIG_DVB_USB_AU6610=m
+CONFIG_DVB_USB_DIGITV=m
+CONFIG_DVB_USB_VP7045=m
+CONFIG_DVB_USB_VP702X=m
+CONFIG_DVB_USB_GP8PSK=m
+CONFIG_DVB_USB_NOVA_T_USB2=m
+CONFIG_DVB_USB_TTUSB2=m
+CONFIG_DVB_USB_DTT200U=m
+CONFIG_DVB_USB_OPERA1=m
+CONFIG_DVB_USB_AF9005=m
+CONFIG_DVB_USB_AF9005_REMOTE=m
+CONFIG_DVB_USB_DW2102=m
+CONFIG_DVB_USB_ANYSEE=m
+CONFIG_DVB_TTUSB_BUDGET=m
+CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_CINERGYT2=m
+# CONFIG_DVB_CINERGYT2_TUNING is not set
+CONFIG_DVB_SIANO_SMS1XXX=m
+CONFIG_DVB_SIANO_SMS1XXX_SMS_IDS=y
+
+#
+# Supported FlexCopII (B2C2) Adapters
+#
+CONFIG_DVB_B2C2_FLEXCOP=m
+CONFIG_DVB_B2C2_FLEXCOP_PCI=m
+CONFIG_DVB_B2C2_FLEXCOP_USB=m
+# CONFIG_DVB_B2C2_FLEXCOP_DEBUG is not set
+
+#
+# Supported BT878 Adapters
+#
+CONFIG_DVB_BT8XX=m
+
+#
+# Supported Pluto2 Adapters
+#
+CONFIG_DVB_PLUTO2=m
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+# CONFIG_DVB_FE_CUSTOMISE is not set
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_CX24123=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_S5H1420=m
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_TDA10086=m
+CONFIG_DVB_VES1X93=m
+CONFIG_DVB_TUNER_ITD1000=m
+CONFIG_DVB_TDA826X=m
+CONFIG_DVB_TUA6100=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_DRX397XD=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_ZL10353=m
+CONFIG_DVB_DIB3000MB=m
+CONFIG_DVB_DIB3000MC=m
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+CONFIG_DVB_TDA10048=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_TDA10023=m
+CONFIG_DVB_STV0297=m
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+CONFIG_DVB_NXT200X=m
+CONFIG_DVB_OR51211=m
+CONFIG_DVB_OR51132=m
+CONFIG_DVB_BCM3510=m
+CONFIG_DVB_LGDT330X=m
+CONFIG_DVB_S5H1409=m
+CONFIG_DVB_AU8522=m
+CONFIG_DVB_S5H1411=m
+
+#
+# Digital terrestrial only tuners/PLL
+#
+CONFIG_DVB_PLL=m
+CONFIG_DVB_TUNER_DIB0070=m
+
+#
+# SEC control devices for DVB-S
+#
+CONFIG_DVB_LNBP21=m
+CONFIG_DVB_ISL6405=m
+CONFIG_DVB_ISL6421=m
+CONFIG_DAB=y
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+CONFIG_AGP=m
+CONFIG_AGP_ALI=m
+CONFIG_AGP_ATI=m
+CONFIG_AGP_AMD=m
+CONFIG_AGP_AMD64=m
+CONFIG_AGP_INTEL=m
+CONFIG_AGP_NVIDIA=m
+CONFIG_AGP_SIS=m
+CONFIG_AGP_SWORKS=m
+CONFIG_AGP_VIA=m
+CONFIG_AGP_EFFICEON=m
+CONFIG_DRM=m
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_DRM_VIA=m
+CONFIG_DRM_VIA_CHROME9=m
+CONFIG_DRM_SAVAGE=m
+CONFIG_VGASTATE=m
+CONFIG_VIDEO_OUTPUT_CONTROL=m
+CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+CONFIG_FB_DDC=m
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+CONFIG_FB_SYS_FILLRECT=m
+CONFIG_FB_SYS_COPYAREA=m
+CONFIG_FB_SYS_IMAGEBLIT=m
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+CONFIG_FB_SYS_FOPS=m
+CONFIG_FB_DEFERRED_IO=y
+CONFIG_FB_HECUBA=m
+CONFIG_FB_SVGALIB=m
+# CONFIG_FB_MACMODES is not set
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+
+#
+# Frame buffer hardware drivers
+#
+CONFIG_FB_CIRRUS=m
+CONFIG_FB_PM2=m
+CONFIG_FB_PM2_FIFO_DISCONNECT=y
+CONFIG_FB_CYBER2000=m
+CONFIG_FB_ARC=m
+# CONFIG_FB_ASILIANT is not set
+CONFIG_FB_IMSTT=y
+CONFIG_FB_VGA16=m
+CONFIG_FB_UVESA=m
+CONFIG_FB_VESA=y
+CONFIG_FB_EFI=y
+CONFIG_FB_N411=m
+CONFIG_FB_HGA=m
+CONFIG_FB_HGA_ACCEL=y
+CONFIG_FB_S1D13XXX=m
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+# CONFIG_FB_NVIDIA_DEBUG is not set
+CONFIG_FB_NVIDIA_BACKLIGHT=y
+CONFIG_FB_RIVA=m
+CONFIG_FB_RIVA_I2C=y
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_RIVA_BACKLIGHT=y
+CONFIG_FB_I810=m
+CONFIG_FB_I810_GTF=y
+CONFIG_FB_I810_I2C=y
+CONFIG_FB_LE80578=m
+CONFIG_FB_CARILLO_RANCH=m
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+CONFIG_FB_INTEL_I2C=y
+CONFIG_FB_MATROX=m
+CONFIG_FB_MATROX_MILLENIUM=y
+CONFIG_FB_MATROX_MYSTIQUE=y
+CONFIG_FB_MATROX_G=y
+# CONFIG_FB_MATROX_I2C is not set
+CONFIG_FB_MATROX_MULTIHEAD=y
+CONFIG_FB_RADEON=m
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+# CONFIG_FB_RADEON_DEBUG is not set
+# CONFIG_FB_ATY128 is not set
+CONFIG_FB_ATY=m
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+CONFIG_FB_S3=m
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+CONFIG_FB_SIS=m
+CONFIG_FB_SIS_300=y
+CONFIG_FB_SIS_315=y
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+CONFIG_FB_VT8623=m
+CONFIG_FB_CYBLA=m
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+CONFIG_FB_ARK=m
+CONFIG_FB_PM3=m
+CONFIG_FB_CARMINE=m
+CONFIG_FB_CARMINE_DRAM_EVAL=y
+# CONFIG_CARMINE_DRAM_CUSTOM is not set
+CONFIG_FB_GEODE=y
+CONFIG_FB_GEODE_LX=m
+CONFIG_FB_GEODE_GX=m
+CONFIG_FB_GEODE_GX1=m
+CONFIG_FB_SM501=m
+# CONFIG_FB_VIRTUAL is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_LTV350QV=m
+CONFIG_LCD_ILI9320=m
+CONFIG_LCD_VGG2432A4=m
+CONFIG_LCD_PLATFORM=m
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_CORGI=m
+CONFIG_BACKLIGHT_PROGEAR=m
+CONFIG_BACKLIGHT_CARILLO_RANCH=m
+CONFIG_BACKLIGHT_MBP_NVIDIA=m
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=m
+
+#
+# Display hardware drivers
+#
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_MDA_CONSOLE=m
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+# CONFIG_LOGO is not set
+
+#
+# Bootsplash configuration
+#
+CONFIG_BOOTSPLASH=y
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_DEBUG=y
+# CONFIG_SND_DEBUG_VERBOSE is not set
+# CONFIG_SND_PCM_XRUN_DEBUG is not set
+CONFIG_SND_VMASTER=y
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_OPL4_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DRIVERS=y
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_MTS64=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+CONFIG_SND_PORTMAN2X4=m
+CONFIG_SND_AC97_POWER_SAVE=y
+CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0
+CONFIG_SND_AD1848_LIB=m
+CONFIG_SND_CS4231_LIB=m
+CONFIG_SND_SB_COMMON=m
+CONFIG_SND_SB8_DSP=m
+CONFIG_SND_SB16_DSP=m
+CONFIG_SND_ISA=y
+CONFIG_SND_ADLIB=m
+CONFIG_SND_AD1816A=m
+CONFIG_SND_AD1848=m
+CONFIG_SND_ALS100=m
+CONFIG_SND_AZT2320=m
+CONFIG_SND_CMI8330=m
+CONFIG_SND_CS4231=m
+CONFIG_SND_CS4232=m
+CONFIG_SND_CS4236=m
+CONFIG_SND_DT019X=m
+CONFIG_SND_ES968=m
+CONFIG_SND_ES1688=m
+CONFIG_SND_ES18XX=m
+CONFIG_SND_SC6000=m
+CONFIG_SND_GUSCLASSIC=m
+CONFIG_SND_GUSEXTREME=m
+CONFIG_SND_GUSMAX=m
+CONFIG_SND_INTERWAVE=m
+CONFIG_SND_INTERWAVE_STB=m
+CONFIG_SND_OPL3SA2=m
+CONFIG_SND_OPTI92X_AD1848=m
+CONFIG_SND_OPTI92X_CS4231=m
+CONFIG_SND_OPTI93X=m
+CONFIG_SND_MIRO=m
+CONFIG_SND_SB8=m
+CONFIG_SND_SB16=m
+CONFIG_SND_SBAWE=m
+CONFIG_SND_SB16_CSP=y
+CONFIG_SND_SGALAXY=m
+CONFIG_SND_SSCAPE=m
+CONFIG_SND_WAVEFRONT=m
+# CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL is not set
+CONFIG_SND_PCI=y
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AW2=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_OXYGEN_LIB=m
+CONFIG_SND_OXYGEN=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS5530=m
+CONFIG_SND_CS5535AUDIO=m
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDA_HWDEP=y
+CONFIG_SND_HDA_INPUT_BEEP=y
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_CODEC_ANALOG=y
+CONFIG_SND_HDA_CODEC_SIGMATEL=y
+CONFIG_SND_HDA_CODEC_VIA=y
+CONFIG_SND_HDA_CODEC_ATIHDMI=y
+CONFIG_SND_HDA_CODEC_NVHDMI=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+CONFIG_SND_HDA_CODEC_CMEDIA=y
+CONFIG_SND_HDA_CODEC_SI3054=y
+CONFIG_SND_HDA_GENERIC=y
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_HIFIER=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SIS7019=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VIRTUOSO=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+CONFIG_SND_SPI=y
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+CONFIG_SND_USB_CAIAQ=m
+CONFIG_SND_USB_CAIAQ_INPUT=y
+CONFIG_SND_PCMCIA=y
+CONFIG_SND_VXPOCKET=m
+CONFIG_SND_PDAUDIOCF=m
+# CONFIG_SND_SOC is not set
+CONFIG_SOUND_PRIME=m
+# CONFIG_SOUND_MSNDCLAS is not set
+# CONFIG_SOUND_MSNDPIN is not set
+CONFIG_SOUND_OSS=m
+CONFIG_SOUND_TRACEINIT=y
+CONFIG_SOUND_DMAP=y
+CONFIG_SOUND_SSCAPE=m
+CONFIG_SOUND_VMIDI=m
+CONFIG_SOUND_TRIX=m
+CONFIG_SOUND_MSS=m
+CONFIG_SOUND_MPU401=m
+CONFIG_SOUND_PAS=m
+CONFIG_SOUND_PSS=m
+CONFIG_PSS_MIXER=y
+# CONFIG_PSS_HAVE_BOOT is not set
+CONFIG_SOUND_SB=m
+CONFIG_SOUND_YM3812=m
+CONFIG_SOUND_UART6850=m
+CONFIG_SOUND_AEDSP16=m
+CONFIG_SC6600=y
+CONFIG_SC6600_JOY=y
+CONFIG_SC6600_CDROM=4
+CONFIG_SC6600_CDROMBASE=0x0
+# CONFIG_AEDSP16_MSS is not set
+# CONFIG_AEDSP16_SBPRO is not set
+CONFIG_SOUND_KAHLUA=m
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=m
+# CONFIG_HID_DEBUG is not set
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=m
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+# CONFIG_LOGIRUMBLEPAD2_FF is not set
+CONFIG_PANTHERLORD_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_ZEROPLUS_FF=y
+CONFIG_USB_HIDDEV=y
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_OTG is not set
+CONFIG_USB_MON=y
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_C67X00_HCD=m
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_ISP1760_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_HCD_SSB is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+# CONFIG_USB_U132_HCD is not set
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+CONFIG_USB_R8A66597_HCD=m
+
+#
+# Enable Host or Gadget support to see Inventra options
+#
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+CONFIG_USB_WDM=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+CONFIG_USB_STORAGE_ONETOUCH=y
+CONFIG_USB_STORAGE_KARMA=y
+CONFIG_USB_STORAGE_CYPRESS_ATACB=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+CONFIG_USB_SERIAL=m
+CONFIG_USB_EZUSB=y
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRCABLE=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_CH341=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_IUU=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_MOS7720=m
+CONFIG_USB_SERIAL_MOS7840=m
+CONFIG_USB_SERIAL_MOTOROLA=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_OTI6858=m
+CONFIG_USB_SERIAL_QUALCOMM=m
+CONFIG_USB_SERIAL_SPCP8X5=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_SERIAL_DEBUG=m
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_ADUTUX=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_BERRY_CHARGE=m
+CONFIG_USB_LED=m
+CONFIG_USB_CYPRESS_CY7C63=m
+CONFIG_USB_CYTHERM=m
+CONFIG_USB_PHIDGET=m
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETMOTORCONTROL=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_FTDI_ELAN=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TRANCEVIBRATOR=m
+CONFIG_USB_IOWARRIOR=m
+# CONFIG_USB_TEST is not set
+CONFIG_USB_ISIGHTFW=m
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+# CONFIG_USB_GADGET is not set
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD Card Drivers
+#
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK_BOUNCE=y
+CONFIG_SDIO_UART=m
+CONFIG_MMC_TEST=m
+
+#
+# MMC/SD Host Controller Drivers
+#
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_SDHCI_PCI=m
+CONFIG_MMC_RICOH_MMC=m
+CONFIG_MMC_WBSD=m
+CONFIG_MMC_TIFM_SD=m
+CONFIG_MMC_SDRICOH_CS=m
+CONFIG_MEMSTICK=m
+# CONFIG_MEMSTICK_DEBUG is not set
+
+#
+# MemoryStick drivers
+#
+# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
+CONFIG_MSPRO_BLOCK=m
+
+#
+# MemoryStick Host Controller Drivers
+#
+CONFIG_MEMSTICK_TIFM_MS=m
+CONFIG_MEMSTICK_JMICRON_38X=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=m
+
+#
+# LED drivers
+#
+CONFIG_LEDS_NET48XX=m
+CONFIG_LEDS_WRAP=m
+CONFIG_LEDS_PCA9532=m
+CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_CLEVO_MAIL=m
+CONFIG_LEDS_PCA955X=m
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_INFINIBAND=m
+CONFIG_INFINIBAND_USER_MAD=m
+CONFIG_INFINIBAND_USER_ACCESS=m
+CONFIG_INFINIBAND_USER_MEM=y
+CONFIG_INFINIBAND_ADDR_TRANS=y
+CONFIG_INFINIBAND_MTHCA=m
+CONFIG_INFINIBAND_MTHCA_DEBUG=y
+CONFIG_INFINIBAND_AMSO1100=m
+# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
+CONFIG_INFINIBAND_CXGB3=m
+# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
+CONFIG_MLX4_INFINIBAND=m
+CONFIG_INFINIBAND_NES=m
+# CONFIG_INFINIBAND_NES_DEBUG is not set
+CONFIG_INFINIBAND_IPOIB=m
+CONFIG_INFINIBAND_IPOIB_CM=y
+CONFIG_INFINIBAND_IPOIB_DEBUG=y
+# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
+CONFIG_INFINIBAND_SRP=m
+CONFIG_INFINIBAND_ISER=m
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_AMD76X=m
+CONFIG_EDAC_E7XXX=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I82875P=m
+CONFIG_EDAC_I82975X=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I82860=m
+CONFIG_EDAC_R82600=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_I5100=m
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_INTF_DEV_UIE_EMUL=y
+CONFIG_RTC_DRV_TEST=m
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1374=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_MAX6900=m
+CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_M41T80=m
+CONFIG_RTC_DRV_M41T80_WDT=y
+CONFIG_RTC_DRV_S35390A=m
+CONFIG_RTC_DRV_FM3130=m
+
+#
+# SPI RTC drivers
+#
+CONFIG_RTC_DRV_M41T94=m
+CONFIG_RTC_DRV_DS1305=m
+CONFIG_RTC_DRV_MAX6902=m
+CONFIG_RTC_DRV_R9701=m
+CONFIG_RTC_DRV_RS5C348=m
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=m
+CONFIG_RTC_DRV_DS1511=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_STK17TA8=m
+CONFIG_RTC_DRV_M48T86=m
+CONFIG_RTC_DRV_M48T59=m
+CONFIG_RTC_DRV_V3020=m
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+CONFIG_DMATEST=m
+CONFIG_DCA=m
+CONFIG_AUXDISPLAY=y
+CONFIG_KS0108=m
+CONFIG_KS0108_PORT=0x378
+CONFIG_KS0108_DELAY=2
+CONFIG_CFAG12864B=m
+CONFIG_CFAG12864B_RATE=20
+CONFIG_UIO=m
+CONFIG_UIO_CIF=m
+CONFIG_UIO_PDRV=m
+CONFIG_UIO_PDRV_GENIRQ=m
+CONFIG_UIO_SMX=m
+CONFIG_STAGING=y
+CONFIG_ET131X=m
+# CONFIG_ET131X_DEBUG is not set
+CONFIG_SLICOSS=m
+CONFIG_SXG=m
+CONFIG_ME4000=m
+CONFIG_VIDEO_GO7007=m
+CONFIG_VIDEO_GO7007_USB=m
+CONFIG_USB_IP_COMMON=m
+CONFIG_USB_IP_VHCI_HCD=m
+CONFIG_USB_IP_HOST=m
+CONFIG_W35UND=m
+CONFIG_PRISM2_USB=m
+CONFIG_ECHO=m
+CONFIG_USB_ATMEL=m
+CONFIG_AGNX=m
+CONFIG_OTUS=m
+CONFIG_RT2860=m
+CONFIG_RT2870=m
+CONFIG_RT3070=m
+CONFIG_BENET=m
+CONFIG_RTL8187SE=m
+CONFIG_DRM_PSB=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+# CONFIG_EDD_OFF is not set
+CONFIG_FIRMWARE_MEMMAP=y
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_DMIID=y
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=m
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_NFS4ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+CONFIG_JBD_DEBUG=y
+CONFIG_JBD2=m
+CONFIG_JBD2_DEBUG=y
+CONFIG_FS_MBCACHE=m
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+CONFIG_JFS_FS=m
+CONFIG_JFS_POSIX_ACL=y
+CONFIG_JFS_SECURITY=y
+# CONFIG_JFS_DEBUG is not set
+CONFIG_JFS_STATISTICS=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_FS_NFS4ACL=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_DMAPI=m
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_XFS_RT=y
+# CONFIG_XFS_DEBUG is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+CONFIG_OCFS2_FS=m
+CONFIG_OCFS2_FS_O2CB=m
+CONFIG_OCFS2_FS_USERSPACE_CLUSTER=m
+CONFIG_OCFS2_FS_STATS=y
+# CONFIG_OCFS2_DEBUG_MASKLOG is not set
+# CONFIG_OCFS2_DEBUG_FS is not set
+# CONFIG_OCFS2_COMPAT_JBD is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_DMAPI=m
+# CONFIG_DMAPI_DEBUG is not set
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_PRINT_QUOTA_WARNING=y
+CONFIG_QUOTA_TREE=m
+CONFIG_QFMT_V1=m
+CONFIG_QFMT_V2=m
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+CONFIG_NTFS_RW=y
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+CONFIG_ADFS_FS=m
+# CONFIG_ADFS_FS_RW is not set
+CONFIG_AFFS_FS=m
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+CONFIG_BEFS_FS=m
+# CONFIG_BEFS_DEBUG is not set
+CONFIG_BFS_FS=m
+CONFIG_EFS_FS=m
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+CONFIG_JFFS2_SUMMARY=y
+CONFIG_JFFS2_FS_XATTR=y
+CONFIG_JFFS2_FS_POSIX_ACL=y
+CONFIG_JFFS2_FS_SECURITY=y
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+CONFIG_UBIFS_FS=m
+CONFIG_UBIFS_FS_XATTR=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_UBIFS_FS_DEBUG is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+CONFIG_VXFS_FS=m
+CONFIG_MINIX_FS=y
+CONFIG_OMFS_FS=m
+CONFIG_HPFS_FS=m
+CONFIG_QNX4FS_FS=m
+CONFIG_ROMFS_FS=m
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+CONFIG_UFS_FS_WRITE=y
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_SWAP=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_SUNRPC_XPRT_RDMA=m
+CONFIG_SUNRPC_SWAP=y
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+CONFIG_CIFS_STATS=y
+CONFIG_CIFS_STATS2=y
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_DFS_UPCALL=y
+CONFIG_NCP_FS=m
+CONFIG_NCPFS_PACKET_SIGNING=y
+CONFIG_NCPFS_IOCTL_LOCKING=y
+CONFIG_NCPFS_STRONG=y
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+CONFIG_NCPFS_SMALLDOS=y
+CONFIG_NCPFS_NLS=y
+CONFIG_NCPFS_EXTRAS=y
+CONFIG_CODA_FS=m
+CONFIG_AFS_FS=m
+# CONFIG_AFS_DEBUG is not set
+CONFIG_9P_FS=m
+CONFIG_NOVFS=m
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+# CONFIG_AMIGA_PARTITION is not set
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+# CONFIG_MINIX_SUBPARTITION is not set
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+# CONFIG_LDM_DEBUG is not set
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_SYSV68_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_DLM=m
+# CONFIG_DLM_DEBUG is not set
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+# CONFIG_DETECT_SOFTLOCKUP is not set
+CONFIG_SCHED_DEBUG=y
+CONFIG_SCHEDSTATS=y
+CONFIG_TIMER_STATS=y
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_HIGHMEM is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+CONFIG_DEBUG_MEMORY_INIT=y
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_FRAME_POINTER is not set
+CONFIG_UNWIND_INFO=y
+CONFIG_STACK_UNWIND=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+CONFIG_RCU_TORTURE_TEST=m
+# CONFIG_KPROBES_SANITY_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+CONFIG_LKDTM=m
+# CONFIG_FAULT_INJECTION is not set
+CONFIG_LATENCYTOP=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+CONFIG_HAVE_FTRACE=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+# CONFIG_FTRACE is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SYSPROF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+CONFIG_PROVIDE_OHCI1394_DMA_INIT=y
+CONFIG_DYNAMIC_PRINTK_DEBUG=y
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_STRICT_DEVMEM is not set
+# CONFIG_X86_VERBOSE_BOOTUP is not set
+CONFIG_EARLY_PRINTK=y
+CONFIG_EARLY_PRINTK_DBGP=y
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_DEBUG_PER_CPU_MAPS is not set
+# CONFIG_X86_PTDUMP is not set
+CONFIG_DEBUG_RODATA=y
+# CONFIG_DEBUG_RODATA_TEST is not set
+# CONFIG_DEBUG_NX_TEST is not set
+# CONFIG_4KSTACKS is not set
+CONFIG_DOUBLEFAULT=y
+# CONFIG_MMIOTRACE is not set
+CONFIG_IO_DELAY_TYPE_0X80=0
+CONFIG_IO_DELAY_TYPE_0XED=1
+CONFIG_IO_DELAY_TYPE_UDELAY=2
+CONFIG_IO_DELAY_TYPE_NONE=3
+CONFIG_IO_DELAY_0X80=y
+# CONFIG_IO_DELAY_0XED is not set
+# CONFIG_IO_DELAY_UDELAY is not set
+# CONFIG_IO_DELAY_NONE is not set
+CONFIG_DEFAULT_IO_DELAY_TYPE=0
+# CONFIG_DEBUG_BOOT_PARAMS is not set
+# CONFIG_CPA_DEBUG is not set
+# CONFIG_OPTIMIZE_INLINING is not set
+CONFIG_KDB=y
+CONFIG_KDB_MODULES=m
+CONFIG_KDB_OFF=y
+CONFIG_KDB_CONTINUE_CATASTROPHIC=0
+CONFIG_KDB_USB=y
+CONFIG_KDB_KDUMP=y
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_DEFAULT="apparmor"
+CONFIG_SECURITY_NETWORK=y
+# CONFIG_SECURITY_NETWORK_XFRM is not set
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+CONFIG_SECURITY_APPARMOR=y
+CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_APPARMOR_DISABLE=y
+CONFIG_XOR_BLOCKS=m
+CONFIG_ASYNC_CORE=m
+CONFIG_ASYNC_MEMCPY=m
+CONFIG_ASYNC_XOR=m
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Authenticated Encryption with Associated Data
+#
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_SEQIV=m
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_XTS=m
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_XCBC=m
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_RMD128=m
+CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_RMD256=m
+CONFIG_CRYPTO_RMD320=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_586=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_SALSA20=m
+CONFIG_CRYPTO_SALSA20_586=m
+CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TEA=m
+# CONFIG_CRYPTO_TWOFISH is not set
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_TWOFISH_586=m
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_DEV_PADLOCK=m
+CONFIG_CRYPTO_DEV_PADLOCK_AES=m
+CONFIG_CRYPTO_DEV_PADLOCK_SHA=m
+CONFIG_CRYPTO_DEV_GEODE=m
+CONFIG_CRYPTO_DEV_HIFN_795X=m
+CONFIG_CRYPTO_DEV_HIFN_795X_RNG=y
+CONFIG_HAVE_KVM=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM_KMP=y
+# CONFIG_KVM is not set
+# CONFIG_LGUEST is not set
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
+CONFIG_VIRTIO_BALLOON=m
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_FIRST_BIT=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_T10DIF=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_AUDIT_GENERIC=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_CHECK_SIGNATURE=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-i686.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-i686.config
new file mode 100644
index 0000000..81bc07f
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-i686.config
@@ -0,0 +1,4409 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.27.21
+# Wed May 13 22:15:21 2009
+#
+# CONFIG_64BIT is not set
+CONFIG_X86_32=y
+# CONFIG_X86_64 is not set
+CONFIG_X86=y
+CONFIG_ARCH_DEFCONFIG="arch/x86/configs/i386_defconfig"
+# CONFIG_GENERIC_LOCKBREAK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_CLOCKSOURCE_WATCHDOG=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_FAST_CMPXCHG_LOCAL=y
+CONFIG_MMU=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+# CONFIG_RWSEM_GENERIC_SPINLOCK is not set
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+# CONFIG_GENERIC_TIME_VSYSCALL is not set
+CONFIG_ARCH_HAS_CPU_RELAX=y
+CONFIG_ARCH_HAS_DEFAULT_IDLE=y
+CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
+CONFIG_HAVE_SETUP_PER_CPU_AREA=y
+# CONFIG_HAVE_CPUMASK_OF_CPU_MAP is not set
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# CONFIG_ZONE_DMA32 is not set
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+# CONFIG_AUDIT_ARCH is not set
+CONFIG_ARCH_SUPPORTS_AOUT=y
+CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_32_SMP=y
+CONFIG_X86_HT=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
+CONFIG_KTIME_SCALAR=y
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-0.1-default"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SUSE_KERNEL=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_TREE=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_CGROUPS=y
+# CONFIG_CGROUP_DEBUG is not set
+CONFIG_CGROUP_NS=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_DEVICE=y
+CONFIG_CPUSETS=y
+CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+# CONFIG_USER_SCHED is not set
+CONFIG_CGROUP_SCHED=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_RESOURCE_COUNTERS=y
+CONFIG_MM_OWNER=y
+CONFIG_CGROUP_MEM_RES_CTLR=y
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_PROC_PID_CPUSET=y
+CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_IPC_NS=y
+CONFIG_USER_NS=y
+CONFIG_PID_NS=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_PCSPKR_PLATFORM=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+# CONFIG_TRACEPOINTS is not set
+CONFIG_MARKERS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_KRETPROBES=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+# CONFIG_HAVE_DMA_ATTRS is not set
+CONFIG_USE_GENERIC_SMP_HELPERS=y
+# CONFIG_HAVE_CLK is not set
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_HAVE_GENERIC_DMA_COHERENT=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+# CONFIG_UTRACE is not set
+CONFIG_BLOCK=y
+CONFIG_LBD=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_LSF=y
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLK_DEV_INTEGRITY=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
+
+#
+# Processor type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SMP=y
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
+# CONFIG_X86_PC is not set
+# CONFIG_X86_XEN is not set
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+CONFIG_X86_GENERICARCH=y
+# CONFIG_X86_NUMAQ is not set
+CONFIG_X86_SUMMIT=y
+CONFIG_X86_ES7000=y
+CONFIG_X86_BIGSMP=y
+# CONFIG_X86_64_XEN is not set
+# CONFIG_X86_VSMP is not set
+# CONFIG_X86_RDC321X is not set
+# CONFIG_PARAVIRT_GUEST is not set
+CONFIG_MEMTEST=y
+CONFIG_X86_CYCLONE_TIMER=y
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+CONFIG_M586=y
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+# CONFIG_M686 is not set
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+# CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+# CONFIG_GENERIC_CPU is not set
+CONFIG_X86_GENERIC=y
+CONFIG_X86_CPU=y
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_XADD=y
+CONFIG_X86_PPRO_FENCE=y
+CONFIG_X86_F00F_BUG=y
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_INVLPG=y
+CONFIG_X86_BSWAP=y
+CONFIG_X86_POPAD_OK=y
+CONFIG_X86_ALIGNMENT_16=y
+CONFIG_X86_INTEL_USERCOPY=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=4
+CONFIG_HPET_TIMER=y
+CONFIG_HPET_EMULATE_RTC=y
+CONFIG_DMI=y
+# CONFIG_IOMMU_HELPER is not set
+CONFIG_NR_CPUS=32
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+# CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS is not set
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_MCE=y
+CONFIG_X86_MCE_NONFATAL=y
+CONFIG_X86_MCE_P4THERMAL=y
+CONFIG_VM86=y
+CONFIG_TOSHIBA=m
+CONFIG_I8K=m
+CONFIG_X86_REBOOTFIXUPS=y
+CONFIG_MICROCODE=m
+CONFIG_MICROCODE_OLD_INTERFACE=y
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+# CONFIG_NOHIGHMEM is not set
+CONFIG_HIGHMEM4G=y
+# CONFIG_HIGHMEM64G is not set
+CONFIG_PAGE_OFFSET=0xC0000000
+CONFIG_HIGHMEM=y
+
+#
+# NUMA (Summit) requires SMP, 64GB highmem support, ACPI
+#
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_MMU_NOTIFIER=y
+CONFIG_HIGHPTE=y
+CONFIG_X86_RESERVE_LOW_64K=y
+# CONFIG_MATH_EMULATION is not set
+CONFIG_MTRR=y
+# CONFIG_MTRR_SANITIZER is not set
+CONFIG_X86_PAT=y
+# CONFIG_EFI is not set
+# CONFIG_IRQBALANCE is not set
+CONFIG_SECCOMP=y
+# CONFIG_SECCOMP_DISABLE_TSC is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+# CONFIG_KEXEC_JUMP is not set
+CONFIG_PHYSICAL_START=0x100000
+CONFIG_RELOCATABLE=y
+CONFIG_PHYSICAL_ALIGN=0x100000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_COMPAT_VDSO=y
+
+#
+# Hardware Performance Monitoring support
+#
+CONFIG_PERFMON=y
+# CONFIG_PERFMON_DEBUG is not set
+CONFIG_PERFMON_DEBUG_FS=y
+CONFIG_X86_PERFMON_P6=m
+CONFIG_X86_PERFMON_P4=m
+CONFIG_X86_PERFMON_PEBS_P4=m
+CONFIG_X86_PERFMON_CORE=m
+CONFIG_X86_PERFMON_PEBS_CORE=m
+CONFIG_X86_PERFMON_INTEL_ATOM=m
+CONFIG_X86_PERFMON_INTEL_ARCH=m
+CONFIG_X86_PERFMON_AMD64=m
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+
+#
+# Power management options
+#
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP_SMP=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION=""
+CONFIG_ACPI=y
+CONFIG_ACPI_SLEEP=y
+CONFIG_ACPI_PROCFS=y
+CONFIG_ACPI_PROCFS_POWER=y
+CONFIG_ACPI_SYSFS_POWER=y
+CONFIG_ACPI_PROC_EVENT=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_DOCK=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_WMI=m
+# CONFIG_ACPI_ASUS is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_CUSTOM_DSDT_FILE=""
+# CONFIG_ACPI_CUSTOM_DSDT is not set
+CONFIG_ACPI_CUSTOM_DSDT_INITRD=y
+CONFIG_ACPI_BLACKLIST_YEAR=2001
+CONFIG_ACPI_DEBUG=y
+# CONFIG_ACPI_DEBUG_FUNC_TRACE is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_PCI_SLOT=m
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_X86_PM_TIMER=y
+CONFIG_ACPI_CONTAINER=m
+CONFIG_ACPI_SBS=m
+CONFIG_X86_APM_BOOT=y
+CONFIG_APM=m
+# CONFIG_APM_IGNORE_USER_SUSPEND is not set
+CONFIG_APM_DO_ENABLE=y
+# CONFIG_APM_CPU_IDLE is not set
+CONFIG_APM_DISPLAY_BLANK=y
+CONFIG_APM_ALLOW_INTS=y
+# CONFIG_APM_REAL_MODE_POWER_OFF is not set
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+CONFIG_X86_POWERNOW_K6=m
+CONFIG_X86_POWERNOW_K7=m
+CONFIG_X86_POWERNOW_K7_ACPI=y
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+CONFIG_X86_GX_SUSPMOD=m
+CONFIG_X86_SPEEDSTEP_CENTRINO=m
+CONFIG_X86_SPEEDSTEP_CENTRINO_TABLE=y
+CONFIG_X86_SPEEDSTEP_ICH=m
+CONFIG_X86_SPEEDSTEP_SMI=m
+CONFIG_X86_P4_CLOCKMOD=m
+CONFIG_X86_CPUFREQ_NFORCE2=m
+CONFIG_X86_LONGRUN=m
+CONFIG_X86_LONGHAUL=m
+CONFIG_X86_E_POWERSAVER=m
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+CONFIG_X86_SPEEDSTEP_LIB=m
+CONFIG_X86_SPEEDSTEP_RELAXED_CAP_CHECK=y
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_GOV_LADDER=y
+CONFIG_CPU_IDLE_GOV_MENU=y
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+# CONFIG_PCI_GOBIOS is not set
+# CONFIG_PCI_GOMMCONFIG is not set
+# CONFIG_PCI_GODIRECT is not set
+# CONFIG_PCI_GOOLPC is not set
+# CONFIG_PCI_GOXEN_FE is not set
+CONFIG_PCI_GOANY=y
+CONFIG_PCI_BIOS=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_OLPC=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+CONFIG_PCIEAER=y
+CONFIG_PCIEASPM=y
+# CONFIG_PCIEASPM_DEBUG is not set
+CONFIG_ARCH_SUPPORTS_MSI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_HT_IRQ=y
+CONFIG_ISA_DMA_API=y
+CONFIG_ISA=y
+# CONFIG_EISA is not set
+# CONFIG_MCA is not set
+CONFIG_SCx200=m
+CONFIG_SCx200HR_TIMER=m
+CONFIG_OLPC=y
+CONFIG_K8_NB=y
+CONFIG_PCCARD=m
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=m
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=m
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+CONFIG_I82092=m
+CONFIG_I82365=m
+CONFIG_TCIC=m
+CONFIG_PCMCIA_PROBE=y
+CONFIG_PCCARD_NONSTATIC=m
+CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_COMPAQ=m
+CONFIG_HOTPLUG_PCI_COMPAQ_NVRAM=y
+CONFIG_HOTPLUG_PCI_IBM=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+CONFIG_HOTPLUG_PCI_CPCI=y
+CONFIG_HOTPLUG_PCI_CPCI_ZT5550=m
+CONFIG_HOTPLUG_PCI_CPCI_GENERIC=m
+CONFIG_HOTPLUG_PCI_SHPC=m
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_AOUT=m
+CONFIG_BINFMT_MISC=m
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=m
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+CONFIG_XFRM_SUB_POLICY=y
+CONFIG_XFRM_MIGRATE=y
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=m
+CONFIG_NET_KEY=m
+CONFIG_NET_KEY_MIGRATE=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=m
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_TCP_CONG_YEAH=m
+CONFIG_TCP_CONG_ILLINOIS=m
+# CONFIG_DEFAULT_BIC is not set
+CONFIG_DEFAULT_CUBIC=y
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+# CONFIG_DEFAULT_RENO is not set
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_IPV6_MIP6=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_NDISC_NODETYPE=y
+CONFIG_IPV6_TUNNEL=m
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETLABEL is not set
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CT_ACCT=y
+CONFIG_NF_CONNTRACK_MARK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CT_PROTO_DCCP=m
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=m
+CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CONNTRACK_AMANDA=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_NETBIOS_NS=m
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SANE=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
+CONFIG_NF_CONNTRACK_SLP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_DSCP=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_RATEEST=m
+CONFIG_NETFILTER_XT_TARGET_TRACE=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_DSCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_OWNER=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_RATEEST=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_TIME=m
+CONFIG_NETFILTER_XT_MATCH_U32=m
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV4=m
+# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_IPV4OPTIONS=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_NF_NAT_SNMP_BASIC=m
+CONFIG_NF_NAT_PROTO_DCCP=m
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_PROTO_UDPLITE=m
+CONFIG_NF_NAT_PROTO_SCTP=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_TFTP=m
+CONFIG_NF_NAT_AMANDA=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_SECURITY=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_MH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_IP6_NF_SECURITY=m
+
+#
+# DECnet: Netfilter Configuration
+#
+CONFIG_DECNET_NF_GRABULATOR=m
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_IP6=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+CONFIG_BRIDGE_EBT_NFLOG=m
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+# CONFIG_IP_DCCP_CCID2_DEBUG is not set
+CONFIG_IP_DCCP_CCID3=m
+# CONFIG_IP_DCCP_CCID3_DEBUG is not set
+CONFIG_IP_DCCP_CCID3_RTO=100
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+# CONFIG_NET_DCCPPROBE is not set
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_TIPC is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+CONFIG_ATM_CLIP_NO_ICMP=y
+CONFIG_ATM_LANE=m
+CONFIG_ATM_MPOA=m
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_STP=m
+CONFIG_GARP=m
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+CONFIG_VLAN_8021Q_GVRP=y
+CONFIG_DECNET=m
+CONFIG_DECNET_ROUTER=y
+CONFIG_LLC=y
+CONFIG_LLC2=m
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=m
+CONFIG_LTPC=m
+CONFIG_COPS=m
+CONFIG_COPS_DAYNA=y
+CONFIG_COPS_TANGENT=y
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+CONFIG_X25=m
+CONFIG_LAPB=m
+CONFIG_ECONET=m
+# CONFIG_ECONET_AUNUDP is not set
+# CONFIG_ECONET_NATIVE is not set
+CONFIG_WAN_ROUTER=m
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_MULTIQ=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_CLS_FLOW=m
+# CONFIG_NET_EMATCH is not set
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_NAT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_ACT_SKBEDIT=m
+# CONFIG_NET_CLS_IND is not set
+CONFIG_NET_SCH_FIFO=y
+CONFIG_DCB=m
+CONFIG_DCBNL=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+CONFIG_NET_TCPPROBE=m
+CONFIG_HAMRADIO=y
+
+#
+# Packet Radio protocols
+#
+CONFIG_AX25=m
+CONFIG_AX25_DAMA_SLAVE=y
+CONFIG_NETROM=m
+CONFIG_ROSE=m
+
+#
+# AX.25 network device drivers
+#
+CONFIG_MKISS=m
+CONFIG_6PACK=m
+CONFIG_BPQETHER=m
+CONFIG_SCC=m
+CONFIG_SCC_DELAY=y
+CONFIG_SCC_TRXECHO=y
+CONFIG_BAYCOM_SER_FDX=m
+CONFIG_BAYCOM_SER_HDX=m
+CONFIG_BAYCOM_PAR=m
+CONFIG_BAYCOM_EPP=m
+CONFIG_YAM=m
+CONFIG_CAN=m
+CONFIG_CAN_RAW=m
+CONFIG_CAN_BCM=m
+
+#
+# CAN Device Drivers
+#
+CONFIG_CAN_VCAN=m
+# CONFIG_CAN_DEBUG_DEVICES is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+CONFIG_IRDA_ULTRA=y
+
+#
+# IrDA options
+#
+CONFIG_IRDA_CACHE_LAST_LSAP=y
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+CONFIG_DONGLE=y
+CONFIG_ESI_DONGLE=m
+CONFIG_ACTISYS_DONGLE=m
+CONFIG_TEKRAM_DONGLE=m
+CONFIG_TOIM3232_DONGLE=m
+CONFIG_LITELINK_DONGLE=m
+CONFIG_MA600_DONGLE=m
+CONFIG_GIRBIL_DONGLE=m
+CONFIG_MCP2120_DONGLE=m
+CONFIG_OLD_BELKIN_DONGLE=m
+CONFIG_ACT200L_DONGLE=m
+CONFIG_KINGSUN_DONGLE=m
+CONFIG_KSDAZZLE_DONGLE=m
+CONFIG_KS959_DONGLE=m
+
+#
+# FIR device drivers
+#
+CONFIG_USB_IRDA=m
+CONFIG_SIGMATEL_FIR=m
+CONFIG_NSC_FIR=m
+CONFIG_WINBOND_FIR=m
+CONFIG_TOSHIBA_FIR=m
+CONFIG_SMC_IRCC_FIR=m
+CONFIG_ALI_FIR=m
+CONFIG_VLSI_FIR=m
+CONFIG_VIA_FIR=m
+CONFIG_MCS_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIBTUSB=m
+CONFIG_BT_HCIBTSDIO=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_AF_RXRPC=m
+# CONFIG_AF_RXRPC_DEBUG is not set
+CONFIG_RXKAD=m
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_PID=y
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_MESH=y
+CONFIG_MAC80211_LEDS=y
+CONFIG_MAC80211_DEBUGFS=y
+# CONFIG_MAC80211_DEBUG_MENU is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_RFKILL=m
+CONFIG_RFKILL_INPUT=m
+CONFIG_RFKILL_LEDS=y
+CONFIG_NET_9P=m
+# CONFIG_NET_9P_VIRTIO is not set
+# CONFIG_NET_9P_DEBUG is not set
+CONFIG_NETVM=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH=""
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_AR7_PARTS=m
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLKDEVS=m
+CONFIG_MTD_BLOCK=m
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+# CONFIG_SSFDC is not set
+CONFIG_MTD_OOPS=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ABSENT=m
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=m
+CONFIG_MTD_PHYSMAP_START=0x8000000
+CONFIG_MTD_PHYSMAP_LEN=0x4000000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+CONFIG_MTD_SC520CDP=m
+CONFIG_MTD_NETSC520=m
+CONFIG_MTD_TS5500=m
+CONFIG_MTD_SBC_GXX=m
+CONFIG_MTD_SCx200_DOCFLASH=m
+CONFIG_MTD_AMD76XROM=m
+CONFIG_MTD_ICHXROM=m
+CONFIG_MTD_ESB2ROM=m
+CONFIG_MTD_CK804XROM=m
+CONFIG_MTD_SCB2_FLASH=m
+CONFIG_MTD_NETtel=m
+CONFIG_MTD_DILNETPC=m
+CONFIG_MTD_DILNETPC_BOOTSIZE=0x80000
+CONFIG_MTD_L440GX=m
+CONFIG_MTD_PCI=m
+CONFIG_MTD_INTEL_VR_NOR=m
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_PMC551=m
+CONFIG_MTD_PMC551_BUGFIX=y
+# CONFIG_MTD_PMC551_DEBUG is not set
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+CONFIG_MTD_SLRAM=m
+CONFIG_MTD_PHRAM=m
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+CONFIG_MTD_DOC2000=m
+CONFIG_MTD_DOC2001=m
+CONFIG_MTD_DOC2001PLUS=m
+CONFIG_MTD_DOCPROBE=m
+CONFIG_MTD_DOCECC=m
+CONFIG_MTD_DOCPROBE_ADVANCED=y
+CONFIG_MTD_DOCPROBE_ADDRESS=0x0000
+CONFIG_MTD_DOCPROBE_HIGH=y
+CONFIG_MTD_DOCPROBE_55AA=y
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
+CONFIG_MTD_NAND_CAFE=m
+CONFIG_MTD_NAND_CS553X=m
+CONFIG_MTD_NAND_NANDSIM=m
+CONFIG_MTD_NAND_PLATFORM=m
+CONFIG_MTD_ALAUDA=m
+CONFIG_MTD_ONENAND=m
+# CONFIG_MTD_ONENAND_VERIFY_WRITE is not set
+CONFIG_MTD_ONENAND_OTP=y
+CONFIG_MTD_ONENAND_2X_PROGRAM=y
+CONFIG_MTD_ONENAND_SIM=m
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=m
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+CONFIG_PARPORT_PC_FIFO=y
+CONFIG_PARPORT_PC_SUPERIO=y
+CONFIG_PARPORT_PC_PCMCIA=m
+# CONFIG_PARPORT_GSC is not set
+CONFIG_PARPORT_AX88796=m
+CONFIG_PARPORT_1284=y
+CONFIG_PARPORT_NOT_PC=y
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_ISAPNP=y
+CONFIG_PNPBIOS=y
+CONFIG_PNPBIOS_PROC_FS=y
+CONFIG_PNPACPI=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_FD=m
+CONFIG_BLK_DEV_XD=m
+CONFIG_PARIDE=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_BPCK6=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=64000
+CONFIG_BLK_DEV_XIP=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+CONFIG_ATA_OVER_ETH=m
+CONFIG_CIPHER_TWOFISH=m
+CONFIG_VIRTIO_BLK=m
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+CONFIG_IBM_ASM=m
+CONFIG_PHANTOM=m
+CONFIG_EEPROM_93CX6=m
+# CONFIG_SGI_IOC4 is not set
+CONFIG_TIFM_CORE=m
+CONFIG_TIFM_7XX1=m
+CONFIG_ACER_WMI=m
+CONFIG_ASUS_LAPTOP=m
+CONFIG_FUJITSU_LAPTOP=m
+# CONFIG_FUJITSU_LAPTOP_DEBUG is not set
+CONFIG_TC1100_WMI=m
+CONFIG_HP_WMI=m
+CONFIG_MSI_LAPTOP=m
+CONFIG_PANASONIC_LAPTOP=m
+CONFIG_COMPAL_LAPTOP=m
+CONFIG_SONY_LAPTOP=m
+CONFIG_SONYPI_COMPAT=y
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+CONFIG_INTEL_MENLOW=m
+CONFIG_EEEPC_LAPTOP=m
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_HP_ILO=m
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=m
+CONFIG_BLK_DEV_IDE=m
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+CONFIG_IDE_TIMINGS=y
+CONFIG_IDE_ATAPI=y
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=m
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_DELKIN=m
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_BLK_DEV_IDEACPI=y
+# CONFIG_IDE_TASK_IOCTL is not set
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=m
+CONFIG_BLK_DEV_PLATFORM=m
+CONFIG_BLK_DEV_CMD640=m
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=m
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_BLK_DEV_OFFBOARD=y
+CONFIG_BLK_DEV_GENERIC=m
+CONFIG_BLK_DEV_OPTI621=m
+CONFIG_BLK_DEV_RZ1000=m
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_AEC62XX=m
+CONFIG_BLK_DEV_ALI15X3=m
+CONFIG_BLK_DEV_AMD74XX=m
+CONFIG_BLK_DEV_ATIIXP=m
+CONFIG_BLK_DEV_CMD64X=m
+CONFIG_BLK_DEV_TRIFLEX=m
+CONFIG_BLK_DEV_CS5520=m
+CONFIG_BLK_DEV_CS5530=m
+CONFIG_BLK_DEV_CS5535=m
+CONFIG_BLK_DEV_HPT366=m
+CONFIG_BLK_DEV_JMICRON=m
+CONFIG_BLK_DEV_SC1200=m
+CONFIG_BLK_DEV_PIIX=m
+CONFIG_BLK_DEV_IT8213=m
+CONFIG_BLK_DEV_IT821X=m
+CONFIG_BLK_DEV_NS87415=m
+CONFIG_BLK_DEV_PDC202XX_OLD=m
+CONFIG_BLK_DEV_PDC202XX_NEW=m
+CONFIG_BLK_DEV_SVWKS=m
+CONFIG_BLK_DEV_SIIMAGE=m
+CONFIG_BLK_DEV_SIS5513=m
+CONFIG_BLK_DEV_SLC90E66=m
+CONFIG_BLK_DEV_TRM290=m
+CONFIG_BLK_DEV_VIA82CXXX=m
+# CONFIG_BLK_DEV_TC86C001 is not set
+
+#
+# Other IDE chipsets support
+#
+
+#
+# Note: most of these also require special kernel boot parameters
+#
+CONFIG_BLK_DEV_4DRIVES=m
+CONFIG_BLK_DEV_ALI14XX=m
+CONFIG_BLK_DEV_DTC2278=m
+CONFIG_BLK_DEV_HT6560B=m
+CONFIG_BLK_DEV_QD65XX=m
+CONFIG_BLK_DEV_UMC8672=m
+CONFIG_BLK_DEV_IDEDMA=y
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_ENCLOSURE=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_FC_TGT_ATTRS=y
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+CONFIG_SCSI_SAS_HOST_SMP=y
+CONFIG_SCSI_SAS_LIBSAS_DEBUG=y
+CONFIG_SCSI_SRP_ATTRS=m
+CONFIG_SCSI_SRP_TGT_ATTRS=y
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ISCSI_TCP=m
+CONFIG_SCSI_CXGB3_ISCSI=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_7000FASST=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AHA152X=m
+CONFIG_SCSI_AHA1542=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
+CONFIG_AIC7XXX_RESET_DELAY_MS=5000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=32
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+CONFIG_AIC79XX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC94XX=m
+CONFIG_AIC94XX_DEBUG=y
+CONFIG_SCSI_DPT_I2O=m
+CONFIG_SCSI_ADVANSYS=m
+CONFIG_SCSI_IN2000=m
+CONFIG_SCSI_ARCMSR=m
+CONFIG_SCSI_ARCMSR_AER=y
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+CONFIG_SCSI_BUSLOGIC=m
+CONFIG_SCSI_FLASHPOINT=y
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_SCSI_DMX3191D=m
+CONFIG_SCSI_DTC3280=m
+CONFIG_SCSI_EATA=m
+CONFIG_SCSI_EATA_TAGGED_QUEUE=y
+CONFIG_SCSI_EATA_LINKED_COMMANDS=y
+CONFIG_SCSI_EATA_MAX_TAGS=16
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_GENERIC_NCR5380=m
+CONFIG_SCSI_GENERIC_NCR5380_MMIO=m
+CONFIG_SCSI_GENERIC_NCR53C400=y
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+CONFIG_SCSI_INIA100=m
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_MVSAS=m
+CONFIG_SCSI_NCR53C406A=m
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+CONFIG_SCSI_IPR=m
+CONFIG_SCSI_IPR_TRACE=y
+CONFIG_SCSI_IPR_DUMP=y
+CONFIG_SCSI_PAS16=m
+CONFIG_SCSI_QLOGIC_FAS=m
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_SYM53C416=m
+CONFIG_SCSI_DC395x=m
+CONFIG_SCSI_DC390T=m
+CONFIG_SCSI_T128=m
+CONFIG_SCSI_U14_34F=m
+CONFIG_SCSI_U14_34F_TAGGED_QUEUE=y
+CONFIG_SCSI_U14_34F_LINKED_COMMANDS=y
+CONFIG_SCSI_U14_34F_MAX_TAGS=8
+CONFIG_SCSI_ULTRASTOR=m
+CONFIG_SCSI_NSP32=m
+CONFIG_SCSI_DEBUG=m
+CONFIG_SCSI_SRP=m
+CONFIG_SCSI_LOWLEVEL_PCMCIA=y
+CONFIG_PCMCIA_AHA152X=m
+CONFIG_PCMCIA_FDOMAIN=m
+CONFIG_PCMCIA_NINJA_SCSI=m
+CONFIG_PCMCIA_QLOGIC=m
+CONFIG_PCMCIA_SYM53C500=m
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_SCSI_DH_HP_SW=m
+CONFIG_SCSI_DH_EMC=m
+CONFIG_SCSI_DH_ALUA=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+CONFIG_PATA_ACPI=m
+CONFIG_PATA_ALI=m
+CONFIG_PATA_AMD=m
+CONFIG_PATA_ARTOP=m
+CONFIG_PATA_ATIIXP=m
+CONFIG_PATA_CMD640_PCI=m
+CONFIG_PATA_CMD64X=m
+CONFIG_PATA_CS5520=m
+CONFIG_PATA_CS5530=m
+CONFIG_PATA_CS5535=m
+CONFIG_PATA_CS5536=m
+CONFIG_PATA_CYPRESS=m
+CONFIG_PATA_EFAR=m
+CONFIG_ATA_GENERIC=m
+CONFIG_PATA_HPT366=m
+CONFIG_PATA_HPT37X=m
+CONFIG_PATA_HPT3X2N=m
+CONFIG_PATA_HPT3X3=m
+# CONFIG_PATA_HPT3X3_DMA is not set
+CONFIG_PATA_ISAPNP=m
+CONFIG_PATA_IT821X=m
+CONFIG_PATA_IT8213=m
+CONFIG_PATA_JMICRON=m
+CONFIG_PATA_LEGACY=m
+CONFIG_PATA_TRIFLEX=m
+CONFIG_PATA_MARVELL=m
+CONFIG_PATA_MPIIX=m
+CONFIG_PATA_OLDPIIX=m
+CONFIG_PATA_NETCELL=m
+CONFIG_PATA_NINJA32=m
+CONFIG_PATA_NS87410=m
+CONFIG_PATA_NS87415=m
+CONFIG_PATA_OPTI=m
+CONFIG_PATA_OPTIDMA=m
+CONFIG_PATA_PCMCIA=m
+CONFIG_PATA_PDC_OLD=m
+CONFIG_PATA_QDI=m
+CONFIG_PATA_RADISYS=m
+CONFIG_PATA_RZ1000=m
+CONFIG_PATA_SC1200=m
+CONFIG_PATA_SERVERWORKS=m
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+CONFIG_PATA_VIA=m
+CONFIG_PATA_WINBOND=m
+CONFIG_PATA_WINBOND_VLB=m
+CONFIG_PATA_SCH=m
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_DELAY=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_MAX_FC_SGE=256
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+# CONFIG_FUSION_LOGGING is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+# CONFIG_FIREWIRE is not set
+CONFIG_IEEE1394=m
+CONFIG_IEEE1394_OHCI1394=m
+CONFIG_IEEE1394_PCILYNX=m
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y
+CONFIG_IEEE1394_ETH1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_IEEE1394_VIDEO1394=m
+CONFIG_IEEE1394_DV1394=m
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+CONFIG_I2O=m
+CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+# CONFIG_MACINTOSH_DRIVERS is not set
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+CONFIG_MACVLAN=m
+CONFIG_EQUALIZER=m
+CONFIG_TUN=m
+CONFIG_VETH=m
+CONFIG_NET_SB1000=m
+CONFIG_ARCNET=m
+CONFIG_ARCNET_1201=m
+CONFIG_ARCNET_1051=m
+CONFIG_ARCNET_RAW=m
+CONFIG_ARCNET_CAP=m
+CONFIG_ARCNET_COM90xx=m
+CONFIG_ARCNET_COM90xxIO=m
+CONFIG_ARCNET_RIM_I=m
+# CONFIG_ARCNET_COM20020 is not set
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_BROADCOM_PHY=m
+CONFIG_ICPLUS_PHY=m
+CONFIG_REALTEK_PHY=m
+CONFIG_MDIO_BITBANG=m
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_EL1=m
+CONFIG_EL2=m
+CONFIG_ELPLUS=m
+CONFIG_EL16=m
+CONFIG_EL3=m
+CONFIG_3C515=m
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_LANCE=m
+CONFIG_NET_VENDOR_SMC=y
+CONFIG_WD80x3=m
+CONFIG_ULTRA=m
+CONFIG_SMC9194=m
+CONFIG_ENC28J60=m
+# CONFIG_ENC28J60_WRITEVERIFY is not set
+CONFIG_NET_VENDOR_RACAL=y
+CONFIG_NI52=m
+CONFIG_NI65=m
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+CONFIG_TULIP_NAPI=y
+CONFIG_TULIP_NAPI_HW_MITIGATION=y
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+CONFIG_AT1700=m
+CONFIG_DEPCA=m
+CONFIG_HP100=m
+CONFIG_NET_ISA=y
+CONFIG_E2100=m
+CONFIG_EWRK3=m
+CONFIG_EEXPRESS=m
+CONFIG_EEXPRESS_PRO=m
+CONFIG_HPLAN_PLUS=m
+CONFIG_HPLAN=m
+CONFIG_LP486E=m
+CONFIG_ETH16I=m
+CONFIG_NE2000=m
+CONFIG_ZNET=m
+CONFIG_SEEQ8005=m
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_AC3200=m
+CONFIG_APRICOT=m
+CONFIG_B44=m
+CONFIG_B44_PCI_AUTOSELECT=y
+CONFIG_B44_PCICORE_AUTOSELECT=y
+CONFIG_B44_PCI=y
+CONFIG_FORCEDETH=m
+CONFIG_FORCEDETH_NAPI=y
+CONFIG_CS89x0=m
+CONFIG_EEPRO100=m
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_R6040=m
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+# CONFIG_VIA_RHINE_MMIO is not set
+CONFIG_SC92031=m
+CONFIG_NET_POCKET=y
+CONFIG_ATP=m
+CONFIG_DE600=m
+CONFIG_DE620=m
+CONFIG_ATL2=m
+CONFIG_NETDEV_1000=y
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IP1000=m
+CONFIG_IGB=m
+CONFIG_IGB_LRO=y
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+# CONFIG_SKGE_DEBUG is not set
+CONFIG_SKY2=m
+# CONFIG_SKY2_DEBUG is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+CONFIG_ATL1=m
+CONFIG_ATL1E=m
+CONFIG_NETDEV_10000=y
+CONFIG_CHELSIO_T1=m
+CONFIG_CHELSIO_T1_1G=y
+CONFIG_CHELSIO_T3=m
+CONFIG_IXGBE=m
+CONFIG_IXGBE_LRO=y
+CONFIG_IXGBE_DCB=y
+CONFIG_IXGB=m
+CONFIG_S2IO=m
+CONFIG_MYRI10GE=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_MLX4_CORE=m
+CONFIG_MLX4_DEBUG=y
+CONFIG_TEHUTI=m
+CONFIG_BNX2X=m
+CONFIG_SFC=m
+# CONFIG_SFC_RESOURCE is not set
+CONFIG_TR=y
+CONFIG_IBMTR=m
+CONFIG_IBMOL=m
+CONFIG_IBMLS=m
+CONFIG_3C359=m
+CONFIG_TMS380TR=m
+CONFIG_TMSPCI=m
+CONFIG_SKISA=m
+CONFIG_PROTEON=m
+CONFIG_ABYSS=m
+CONFIG_SMCTR=m
+
+#
+# Wireless LAN
+#
+CONFIG_WLAN_PRE80211=y
+CONFIG_STRIP=m
+# CONFIG_ARLAN is not set
+CONFIG_WAVELAN=m
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+CONFIG_WLAN_80211=y
+CONFIG_PCMCIA_RAYCS=m
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_LIBERTAS=m
+CONFIG_LIBERTAS_USB=m
+CONFIG_LIBERTAS_CS=m
+CONFIG_LIBERTAS_SDIO=m
+# CONFIG_LIBERTAS_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_WL3501=m
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_USB_NET_RNDIS_WLAN=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_ADM8211=m
+CONFIG_MAC80211_HWSIM=m
+CONFIG_P54_COMMON=m
+CONFIG_P54_USB=m
+CONFIG_P54_PCI=m
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_ATH9K=m
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+CONFIG_IWLWIFI_LEDS=y
+CONFIG_IWLWIFI_RFKILL=y
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+CONFIG_IWLAGN_LEDS=y
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+CONFIG_IWL3945_RFKILL=y
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+CONFIG_IWL3945_LEDS=y
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_B43=m
+CONFIG_B43_PCI_AUTOSELECT=y
+CONFIG_B43_PCICORE_AUTOSELECT=y
+CONFIG_B43_PCMCIA=y
+CONFIG_B43_PIO=y
+CONFIG_B43_LEDS=y
+CONFIG_B43_RFKILL=y
+# CONFIG_B43_DEBUG is not set
+CONFIG_B43LEGACY=m
+CONFIG_B43LEGACY_PCI_AUTOSELECT=y
+CONFIG_B43LEGACY_PCICORE_AUTOSELECT=y
+CONFIG_B43LEGACY_LEDS=y
+CONFIG_B43LEGACY_RFKILL=y
+# CONFIG_B43LEGACY_DEBUG is not set
+CONFIG_B43LEGACY_DMA=y
+CONFIG_B43LEGACY_PIO=y
+CONFIG_B43LEGACY_DMA_AND_PIO_MODE=y
+# CONFIG_B43LEGACY_DMA_MODE is not set
+# CONFIG_B43LEGACY_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2X00_LIB_RFKILL=y
+CONFIG_RT2X00_LIB_LEDS=y
+CONFIG_RT2400PCI=m
+CONFIG_RT2400PCI_RFKILL=y
+CONFIG_RT2400PCI_LEDS=y
+CONFIG_RT2500PCI=m
+CONFIG_RT2500PCI_RFKILL=y
+CONFIG_RT2500PCI_LEDS=y
+CONFIG_RT61PCI=m
+CONFIG_RT61PCI_RFKILL=y
+CONFIG_RT61PCI_LEDS=y
+CONFIG_RT2500USB=m
+CONFIG_RT2500USB_LEDS=y
+CONFIG_RT73USB=m
+CONFIG_RT73USB_LEDS=y
+# CONFIG_RT2X00_LIB_DEBUGFS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_KC2190=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_HSO=m
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_PCMCIA_IBMTR=m
+CONFIG_WAN=y
+CONFIG_HOSTESS_SV11=m
+# CONFIG_COSA is not set
+CONFIG_LANMEDIA=m
+CONFIG_SEALEVEL_4021=m
+CONFIG_HDLC=m
+CONFIG_HDLC_RAW=m
+CONFIG_HDLC_RAW_ETH=m
+CONFIG_HDLC_CISCO=m
+CONFIG_HDLC_FR=m
+CONFIG_HDLC_PPP=m
+CONFIG_HDLC_X25=m
+CONFIG_PCI200SYN=m
+CONFIG_WANXL=m
+# CONFIG_PC300 is not set
+CONFIG_PC300TOO=m
+CONFIG_N2=m
+CONFIG_C101=m
+CONFIG_FARSYNC=m
+# CONFIG_DSCC4 is not set
+CONFIG_DLCI=m
+CONFIG_DLCI_MAX=8
+CONFIG_SDLA=m
+# CONFIG_WAN_ROUTER_DRIVERS is not set
+CONFIG_LAPBETHER=m
+CONFIG_X25_ASY=m
+# CONFIG_SBNI is not set
+CONFIG_ATM_DRIVERS=y
+CONFIG_ATM_DUMMY=m
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+CONFIG_ATM_FIRESTREAM=m
+CONFIG_ATM_ZATM=m
+# CONFIG_ATM_ZATM_DEBUG is not set
+CONFIG_ATM_NICSTAR=m
+CONFIG_ATM_NICSTAR_USE_SUNI=y
+CONFIG_ATM_NICSTAR_USE_IDT77105=y
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+CONFIG_ATM_IDT77252_RCV_ALL=y
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_IA=m
+# CONFIG_ATM_IA_DEBUG is not set
+CONFIG_ATM_FORE200E=m
+CONFIG_ATM_FORE200E_USE_TASKLET=y
+CONFIG_ATM_FORE200E_TX_RETRY=16
+CONFIG_ATM_FORE200E_DEBUG=0
+CONFIG_ATM_HE=m
+CONFIG_ATM_HE_USE_SUNI=y
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+CONFIG_SKFP=m
+CONFIG_HIPPI=y
+CONFIG_ROADRUNNER=m
+CONFIG_ROADRUNNER_LARGE_RINGS=y
+CONFIG_PLIP=m
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_PPPOL2TP=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=m
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_NET_FC=y
+CONFIG_NETCONSOLE=m
+CONFIG_NETCONSOLE_DYNAMIC=y
+CONFIG_NETPOLL=y
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
+CONFIG_ISDN=y
+CONFIG_MISDN=m
+CONFIG_MISDN_DSP=m
+CONFIG_MISDN_L1OIP=m
+
+#
+# mISDN hardware drivers
+#
+CONFIG_MISDN_HFCPCI=m
+CONFIG_MISDN_HFCMULTI=m
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+CONFIG_ISDN_PPP_BSDCOMP=m
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+CONFIG_ISDN_X25=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+# CONFIG_HISAX_NO_SENDCOMPLETE is not set
+# CONFIG_HISAX_NO_LLC is not set
+# CONFIG_HISAX_NO_KEYPAD is not set
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_0=y
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_AVM_A1=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_IX1MICROR2=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_ASUSCOM=y
+CONFIG_HISAX_TELEINT=y
+CONFIG_HISAX_HFCS=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_SPORTSTER=y
+CONFIG_HISAX_MIC=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_ISURF=y
+CONFIG_HISAX_HSTSAPHIR=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+CONFIG_HISAX_DEBUG=y
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+CONFIG_HISAX_HFCUSB=m
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+CONFIG_ISDN_DRV_ICN=m
+CONFIG_ISDN_DRV_PCBIT=m
+CONFIG_ISDN_DRV_SC=m
+CONFIG_ISDN_DRV_ACT2000=m
+CONFIG_HYSDN=m
+CONFIG_HYSDN_CAPI=y
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+CONFIG_GIGASET_M101=m
+# CONFIG_GIGASET_DEBUG is not set
+CONFIG_GIGASET_UNDOCREQ=y
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_CAPI_TRACE=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1ISA=m
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_T1ISA=m
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+CONFIG_CAPI_EICON=y
+CONFIG_ISDN_DIVAS=m
+CONFIG_ISDN_DIVAS_BRIPCI=y
+CONFIG_ISDN_DIVAS_PRIPCI=y
+CONFIG_ISDN_DIVAS_DIVACAPI=m
+CONFIG_ISDN_DIVAS_USERIDI=m
+CONFIG_ISDN_DIVAS_MAINT=m
+CONFIG_PHONE=m
+CONFIG_PHONE_IXJ=m
+CONFIG_PHONE_IXJ_PCMCIA=m
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+CONFIG_INPUT_POLLDEV=m
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+CONFIG_KEYBOARD_SUNKBD=m
+# CONFIG_KEYBOARD_LKKBD is not set
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_KEYBOARD_NEWTON=m
+# CONFIG_KEYBOARD_STOWAWAY is not set
+CONFIG_KEYBOARD_GPIO=m
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_LIFEBOOK=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_APPLETOUCH=m
+CONFIG_MOUSE_BCM5974=m
+CONFIG_MOUSE_INPORT=m
+CONFIG_MOUSE_ATIXL=y
+CONFIG_MOUSE_LOGIBM=m
+CONFIG_MOUSE_PC110PAD=m
+# CONFIG_MOUSE_VSXXXAA is not set
+CONFIG_MOUSE_GPIO=m
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_USB=y
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_ZHENHUA=m
+CONFIG_JOYSTICK_DB9=m
+CONFIG_JOYSTICK_GAMECON=m
+CONFIG_JOYSTICK_TURBOGRAFX=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+CONFIG_INPUT_TABLET=y
+CONFIG_TABLET_USB_ACECAD=m
+CONFIG_TABLET_USB_AIPTEK=m
+CONFIG_TABLET_USB_GTCO=m
+CONFIG_TABLET_USB_KBTAB=m
+CONFIG_TABLET_USB_WACOM=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ADS7846=m
+CONFIG_TOUCHSCREEN_FUJITSU=m
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_ELOUSB=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_INEXIO=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_TOUCHSCREEN_HTCPEN=m
+CONFIG_TOUCHSCREEN_PENMOUNT=m
+CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
+CONFIG_TOUCHSCREEN_TOUCHWIN=m
+CONFIG_TOUCHSCREEN_UCB1400=m
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
+CONFIG_TOUCHSCREEN_USB_EGALAX=y
+CONFIG_TOUCHSCREEN_USB_PANJIT=y
+CONFIG_TOUCHSCREEN_USB_3M=y
+CONFIG_TOUCHSCREEN_USB_ITM=y
+CONFIG_TOUCHSCREEN_USB_ETURBO=y
+CONFIG_TOUCHSCREEN_USB_GUNZE=y
+CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y
+CONFIG_TOUCHSCREEN_USB_IRTOUCH=y
+CONFIG_TOUCHSCREEN_USB_IDEALTEK=y
+CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y
+CONFIG_TOUCHSCREEN_USB_GOTOP=y
+CONFIG_TOUCHSCREEN_TOUCHIT213=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_APANEL=m
+CONFIG_INPUT_WISTRON_BTNS=m
+CONFIG_INPUT_ATLAS_BTNS=m
+CONFIG_INPUT_ATI_REMOTE=m
+CONFIG_INPUT_ATI_REMOTE2=m
+CONFIG_INPUT_KEYSPAN_REMOTE=m
+CONFIG_INPUT_POWERMATE=m
+CONFIG_INPUT_YEALINK=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_CT82C710=m
+CONFIG_SERIO_PARKBD=m
+CONFIG_SERIO_PCIPS2=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_DEVKMEM=y
+CONFIG_SERIAL_NONSTANDARD=y
+CONFIG_COMPUTONE=m
+CONFIG_ROCKETPORT=m
+CONFIG_CYCLADES=m
+CONFIG_CYZ_INTR=y
+CONFIG_DIGIEPCA=m
+CONFIG_ESPSERIAL=m
+CONFIG_MOXA_INTELLIO=m
+CONFIG_MOXA_SMARTIO=m
+CONFIG_ISI=m
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+CONFIG_RISCOM8=m
+CONFIG_SPECIALIX=m
+CONFIG_SX=m
+CONFIG_RIO=m
+CONFIG_RIO_OLDPCI=y
+CONFIG_STALDRV=y
+CONFIG_NOZOMI=m
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_PNP=y
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=16
+CONFIG_SERIAL_8250_RUNTIME_UARTS=8
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+CONFIG_SERIAL_8250_FOURPORT=m
+CONFIG_SERIAL_8250_ACCENT=m
+CONFIG_SERIAL_8250_BOCA=m
+CONFIG_SERIAL_8250_EXAR_ST16C554=m
+CONFIG_SERIAL_8250_HUB6=m
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=0
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+CONFIG_PPDEV=m
+CONFIG_HVC_DRIVER=y
+CONFIG_VIRTIO_CONSOLE=m
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+CONFIG_IPMI_PANIC_STRING=y
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_HW_RANDOM_GEODE=m
+CONFIG_HW_RANDOM_VIA=m
+CONFIG_HW_RANDOM_VIRTIO=m
+CONFIG_NVRAM=m
+CONFIG_DTLK=m
+CONFIG_R3964=m
+CONFIG_APPLICOM=m
+CONFIG_SONYPI=m
+
+#
+# PCMCIA character devices
+#
+CONFIG_SYNCLINK_CS=m
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+CONFIG_IPWIRELESS=m
+CONFIG_MWAVE=m
+CONFIG_SCx200_GPIO=m
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_CS5535_GPIO=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=4096
+CONFIG_HPET=y
+CONFIG_HPET_MMAP=y
+CONFIG_HANGCHECK_TIMER=m
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
+CONFIG_DEVPORT=y
+CONFIG_CRASHER=m
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# PC SMBus host controller drivers
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_ISCH=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_NFORCE2=m
+CONFIG_I2C_NFORCE2_S4985=m
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+CONFIG_I2C_GPIO=m
+CONFIG_I2C_OCORES=m
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_TAOS_EVM=m
+CONFIG_I2C_TINY_USB=m
+
+#
+# Graphics adapter I2C/DDC channel drivers
+#
+CONFIG_I2C_VOODOO3=m
+
+#
+# Other I2C/SMBus bus drivers
+#
+CONFIG_I2C_PCA_ISA=m
+CONFIG_I2C_PCA_PLATFORM=m
+CONFIG_I2C_STUB=m
+CONFIG_SCx200_I2C=m
+CONFIG_SCx200_I2C_SCL=12
+CONFIG_SCx200_I2C_SDA=13
+CONFIG_SCx200_ACB=m
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_DS1682=m
+CONFIG_AT24=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8591=m
+# CONFIG_TPS65010 is not set
+CONFIG_SENSORS_MAX6875=m
+CONFIG_SENSORS_TSL2550=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+CONFIG_SPI_DEBUG=y
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=m
+CONFIG_SPI_BUTTERFLY=m
+CONFIG_SPI_LM70_LLP=m
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_AT25=m
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_TLE62X0=m
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# I2C GPIO expanders:
+#
+CONFIG_GPIO_MAX732X=m
+CONFIG_GPIO_PCA953X=m
+CONFIG_GPIO_PCF857X=m
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+CONFIG_GPIO_MAX7301=m
+CONFIG_GPIO_MCP23S08=m
+CONFIG_W1=m
+CONFIG_W1_CON=y
+
+#
+# 1-wire Bus Masters
+#
+CONFIG_W1_MASTER_MATROX=m
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS2482=m
+CONFIG_W1_MASTER_GPIO=m
+
+#
+# 1-wire Slaves
+#
+CONFIG_W1_SLAVE_THERM=m
+CONFIG_W1_SLAVE_SMEM=m
+CONFIG_W1_SLAVE_DS2433=m
+CONFIG_W1_SLAVE_DS2433_CRC=y
+CONFIG_W1_SLAVE_DS2760=m
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+CONFIG_PDA_POWER=m
+CONFIG_BATTERY_DS2760=m
+CONFIG_BATTERY_OLPC=m
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ABITUGURU3=m
+CONFIG_SENSORS_AD7414=m
+CONFIG_SENSORS_AD7418=m
+CONFIG_SENSORS_ADCXX=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1029=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ADT7470=m
+CONFIG_SENSORS_ADT7473=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_I5K_AMB=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_F71882FG=m
+CONFIG_SENSORS_F75375S=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_FSCHMD=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_CORETEMP=m
+CONFIG_SENSORS_IBMAEM=m
+CONFIG_SENSORS_IBMPEX=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM70=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_MAX6650=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_PC87427=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_DME1737=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_ADS7828=m
+CONFIG_SENSORS_THMC50=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT1211=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83L786NG=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+CONFIG_SENSORS_APPLESMC=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+CONFIG_THERMAL=m
+CONFIG_THERMAL_HWMON=y
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+CONFIG_ACQUIRE_WDT=m
+CONFIG_ADVANTECH_WDT=m
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+CONFIG_SC520_WDT=m
+CONFIG_EUROTECH_WDT=m
+CONFIG_IB700_WDT=m
+CONFIG_IBMASR=m
+CONFIG_WAFER_WDT=m
+CONFIG_I6300ESB_WDT=m
+CONFIG_ITCO_WDT=m
+CONFIG_ITCO_VENDOR_SUPPORT=y
+CONFIG_IT8712F_WDT=m
+CONFIG_HP_WATCHDOG=m
+CONFIG_SC1200_WDT=m
+CONFIG_SCx200_WDT=m
+CONFIG_PC87413_WDT=m
+CONFIG_60XX_WDT=m
+CONFIG_SBC8360_WDT=m
+CONFIG_SBC7240_WDT=m
+CONFIG_CPU5_WDT=m
+CONFIG_SMSC37B787_WDT=m
+CONFIG_W83627HF_WDT=m
+CONFIG_W83697HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+CONFIG_SBC_EPX_C3_WATCHDOG=m
+
+#
+# ISA-based Watchdog Cards
+#
+CONFIG_PCWATCHDOG=m
+CONFIG_MIXCOMWD=m
+CONFIG_WDT=m
+CONFIG_WDT_501=y
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB_POSSIBLE=y
+CONFIG_SSB=m
+CONFIG_SSB_SPROM=y
+CONFIG_SSB_BLOCKIO=y
+CONFIG_SSB_PCIHOST_POSSIBLE=y
+CONFIG_SSB_PCIHOST=y
+CONFIG_SSB_B43_PCI_BRIDGE=y
+CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
+CONFIG_SSB_PCMCIAHOST=y
+# CONFIG_SSB_DEBUG is not set
+CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
+CONFIG_SSB_DRIVER_PCICORE=y
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+CONFIG_MFD_SM501=m
+CONFIG_MFD_SM501_GPIO=y
+CONFIG_HTC_PASIC3=m
+# CONFIG_MFD_TMIO is not set
+
+#
+# Multimedia devices
+#
+
+#
+# Multimedia core support
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_ALLOW_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_DVB_CORE=m
+CONFIG_VIDEO_MEDIA=m
+
+#
+# Multimedia drivers
+#
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_MEDIA_ATTACH=y
+CONFIG_MEDIA_TUNER=m
+# CONFIG_MEDIA_TUNER_CUSTOMIZE is not set
+CONFIG_MEDIA_TUNER_SIMPLE=m
+CONFIG_MEDIA_TUNER_TDA8290=m
+CONFIG_MEDIA_TUNER_TDA827X=m
+CONFIG_MEDIA_TUNER_TDA18271=m
+CONFIG_MEDIA_TUNER_TDA9887=m
+CONFIG_MEDIA_TUNER_TEA5761=m
+CONFIG_MEDIA_TUNER_TEA5767=m
+CONFIG_MEDIA_TUNER_MT20XX=m
+CONFIG_MEDIA_TUNER_MT2060=m
+CONFIG_MEDIA_TUNER_MT2266=m
+CONFIG_MEDIA_TUNER_MT2131=m
+CONFIG_MEDIA_TUNER_QT1010=m
+CONFIG_MEDIA_TUNER_XC2028=m
+CONFIG_MEDIA_TUNER_XC5000=m
+CONFIG_MEDIA_TUNER_MXL5005S=m
+CONFIG_MEDIA_TUNER_MXL5007T=m
+CONFIG_VIDEO_V4L2=m
+CONFIG_VIDEO_V4L1=m
+CONFIG_VIDEOBUF_GEN=m
+CONFIG_VIDEOBUF_DMA_SG=m
+CONFIG_VIDEOBUF_VMALLOC=m
+CONFIG_VIDEOBUF_DMA_CONTIG=m
+CONFIG_VIDEOBUF_DVB=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+CONFIG_VIDEO_IR_I2C=m
+CONFIG_VIDEO_TVAUDIO=m
+CONFIG_VIDEO_TDA7432=m
+CONFIG_VIDEO_TDA9840=m
+CONFIG_VIDEO_TDA9875=m
+CONFIG_VIDEO_TEA6415C=m
+CONFIG_VIDEO_TEA6420=m
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS5345=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_M52790=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_VP27SMPX=m
+CONFIG_VIDEO_BT819=m
+CONFIG_VIDEO_BT856=m
+CONFIG_VIDEO_KS0127=m
+CONFIG_VIDEO_OV7670=m
+CONFIG_VIDEO_SAA7110=m
+CONFIG_VIDEO_SAA7111=m
+CONFIG_VIDEO_SAA7114=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA717X=m
+CONFIG_VIDEO_TVP5150=m
+CONFIG_VIDEO_VPX3220=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_SAA7185=m
+CONFIG_VIDEO_ADV7170=m
+CONFIG_VIDEO_ADV7175=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+CONFIG_VIDEO_VIVI=m
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_BT848_DVB=y
+CONFIG_VIDEO_SAA6588=m
+CONFIG_VIDEO_PMS=m
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+CONFIG_VIDEO_W9966=m
+CONFIG_VIDEO_CPIA=m
+CONFIG_VIDEO_CPIA_PP=m
+CONFIG_VIDEO_CPIA_USB=m
+CONFIG_VIDEO_CPIA2=m
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+# CONFIG_TUNER_3036 is not set
+CONFIG_VIDEO_STRADIS=m
+CONFIG_VIDEO_ZORAN=m
+CONFIG_VIDEO_ZORAN_DC30=m
+CONFIG_VIDEO_ZORAN_ZR36060=m
+CONFIG_VIDEO_ZORAN_BUZ=m
+CONFIG_VIDEO_ZORAN_DC10=m
+CONFIG_VIDEO_ZORAN_LML33=m
+CONFIG_VIDEO_ZORAN_LML33R10=m
+CONFIG_VIDEO_ZORAN_AVS6EYES=m
+CONFIG_VIDEO_MEYE=m
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_SAA7134_ALSA=m
+CONFIG_VIDEO_SAA7134_DVB=m
+CONFIG_VIDEO_MXB=m
+# CONFIG_VIDEO_DPC is not set
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_CX88_ALSA=m
+CONFIG_VIDEO_CX88_BLACKBIRD=m
+CONFIG_VIDEO_CX88_DVB=m
+CONFIG_VIDEO_CX88_VP3054=m
+CONFIG_VIDEO_CX23885=m
+CONFIG_VIDEO_AU0828=m
+CONFIG_VIDEO_IVTV=m
+CONFIG_VIDEO_FB_IVTV=m
+CONFIG_VIDEO_CX18=m
+CONFIG_VIDEO_CAFE_CCIC=m
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
+CONFIG_USB_GSPCA=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+CONFIG_VIDEO_PVRUSB2_DVB=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_EM28XX_ALSA=m
+CONFIG_VIDEO_EM28XX_DVB=m
+CONFIG_VIDEO_USBVISION=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+CONFIG_USB_ZR364XX=m
+CONFIG_USB_STKWEBCAM=m
+CONFIG_USB_S2255=m
+CONFIG_SOC_CAMERA=m
+CONFIG_SOC_CAMERA_MT9M001=m
+CONFIG_MT9M001_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_MT9V022=m
+CONFIG_MT9V022_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_PLATFORM=m
+CONFIG_VIDEO_SH_MOBILE_CEU=m
+CONFIG_RADIO_ADAPTERS=y
+CONFIG_RADIO_CADET=m
+CONFIG_RADIO_RTRACK=m
+CONFIG_RADIO_RTRACK2=m
+CONFIG_RADIO_AZTECH=m
+CONFIG_RADIO_GEMTEK=m
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+CONFIG_RADIO_SF16FMI=m
+CONFIG_RADIO_SF16FMR2=m
+CONFIG_RADIO_TERRATEC=m
+CONFIG_RADIO_TRUST=m
+CONFIG_RADIO_TYPHOON=m
+CONFIG_RADIO_TYPHOON_PROC_FS=y
+CONFIG_RADIO_ZOLTRIX=m
+CONFIG_USB_DSBR=m
+CONFIG_USB_SI470X=m
+CONFIG_DVB_CAPTURE_DRIVERS=y
+
+#
+# Supported SAA7146 based PCI Adapters
+#
+CONFIG_TTPCI_EEPROM=m
+CONFIG_DVB_AV7110=m
+# CONFIG_DVB_AV7110_FIRMWARE is not set
+CONFIG_DVB_AV7110_OSD=y
+CONFIG_DVB_BUDGET_CORE=m
+CONFIG_DVB_BUDGET=m
+CONFIG_DVB_BUDGET_CI=m
+CONFIG_DVB_BUDGET_AV=m
+CONFIG_DVB_BUDGET_PATCH=m
+
+#
+# Supported USB Adapters
+#
+CONFIG_DVB_USB=m
+# CONFIG_DVB_USB_DEBUG is not set
+CONFIG_DVB_USB_A800=m
+CONFIG_DVB_USB_DIBUSB_MB=m
+# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
+CONFIG_DVB_USB_DIBUSB_MC=m
+CONFIG_DVB_USB_DIB0700=m
+CONFIG_DVB_USB_UMT_010=m
+# CONFIG_DVB_USB_CXUSB is not set
+CONFIG_DVB_USB_M920X=m
+CONFIG_DVB_USB_GL861=m
+CONFIG_DVB_USB_AU6610=m
+CONFIG_DVB_USB_DIGITV=m
+CONFIG_DVB_USB_VP7045=m
+CONFIG_DVB_USB_VP702X=m
+CONFIG_DVB_USB_GP8PSK=m
+CONFIG_DVB_USB_NOVA_T_USB2=m
+CONFIG_DVB_USB_TTUSB2=m
+CONFIG_DVB_USB_DTT200U=m
+CONFIG_DVB_USB_OPERA1=m
+CONFIG_DVB_USB_AF9005=m
+CONFIG_DVB_USB_AF9005_REMOTE=m
+CONFIG_DVB_USB_DW2102=m
+CONFIG_DVB_USB_ANYSEE=m
+CONFIG_DVB_TTUSB_BUDGET=m
+CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_CINERGYT2=m
+# CONFIG_DVB_CINERGYT2_TUNING is not set
+CONFIG_DVB_SIANO_SMS1XXX=m
+CONFIG_DVB_SIANO_SMS1XXX_SMS_IDS=y
+
+#
+# Supported FlexCopII (B2C2) Adapters
+#
+CONFIG_DVB_B2C2_FLEXCOP=m
+CONFIG_DVB_B2C2_FLEXCOP_PCI=m
+CONFIG_DVB_B2C2_FLEXCOP_USB=m
+# CONFIG_DVB_B2C2_FLEXCOP_DEBUG is not set
+
+#
+# Supported BT878 Adapters
+#
+CONFIG_DVB_BT8XX=m
+
+#
+# Supported Pluto2 Adapters
+#
+CONFIG_DVB_PLUTO2=m
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+# CONFIG_DVB_FE_CUSTOMISE is not set
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_CX24123=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_S5H1420=m
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_TDA10086=m
+CONFIG_DVB_VES1X93=m
+CONFIG_DVB_TUNER_ITD1000=m
+CONFIG_DVB_TDA826X=m
+CONFIG_DVB_TUA6100=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_DRX397XD=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_ZL10353=m
+CONFIG_DVB_DIB3000MB=m
+CONFIG_DVB_DIB3000MC=m
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+CONFIG_DVB_TDA10048=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_TDA10023=m
+CONFIG_DVB_STV0297=m
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+CONFIG_DVB_NXT200X=m
+CONFIG_DVB_OR51211=m
+CONFIG_DVB_OR51132=m
+CONFIG_DVB_BCM3510=m
+CONFIG_DVB_LGDT330X=m
+CONFIG_DVB_S5H1409=m
+CONFIG_DVB_AU8522=m
+CONFIG_DVB_S5H1411=m
+
+#
+# Digital terrestrial only tuners/PLL
+#
+CONFIG_DVB_PLL=m
+CONFIG_DVB_TUNER_DIB0070=m
+
+#
+# SEC control devices for DVB-S
+#
+CONFIG_DVB_LNBP21=m
+CONFIG_DVB_ISL6405=m
+CONFIG_DVB_ISL6421=m
+CONFIG_DAB=y
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+CONFIG_AGP=m
+CONFIG_AGP_ALI=m
+CONFIG_AGP_ATI=m
+CONFIG_AGP_AMD=m
+CONFIG_AGP_AMD64=m
+CONFIG_AGP_INTEL=m
+CONFIG_AGP_NVIDIA=m
+CONFIG_AGP_SIS=m
+CONFIG_AGP_SWORKS=m
+CONFIG_AGP_VIA=m
+CONFIG_AGP_EFFICEON=m
+CONFIG_DRM=m
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+CONFIG_DRM_I830=m
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_DRM_VIA=m
+CONFIG_DRM_VIA_CHROME9=m
+CONFIG_DRM_SAVAGE=m
+CONFIG_VGASTATE=m
+CONFIG_VIDEO_OUTPUT_CONTROL=m
+CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+CONFIG_FB_DDC=m
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+CONFIG_FB_SYS_FILLRECT=m
+CONFIG_FB_SYS_COPYAREA=m
+CONFIG_FB_SYS_IMAGEBLIT=m
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+CONFIG_FB_SYS_FOPS=m
+CONFIG_FB_DEFERRED_IO=y
+CONFIG_FB_HECUBA=m
+CONFIG_FB_SVGALIB=m
+# CONFIG_FB_MACMODES is not set
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+
+#
+# Frame buffer hardware drivers
+#
+CONFIG_FB_CIRRUS=m
+CONFIG_FB_PM2=m
+CONFIG_FB_PM2_FIFO_DISCONNECT=y
+CONFIG_FB_CYBER2000=m
+CONFIG_FB_ARC=m
+# CONFIG_FB_ASILIANT is not set
+CONFIG_FB_IMSTT=y
+CONFIG_FB_VGA16=m
+CONFIG_FB_UVESA=m
+CONFIG_FB_VESA=y
+CONFIG_FB_EFI=y
+CONFIG_FB_N411=m
+CONFIG_FB_HGA=m
+CONFIG_FB_HGA_ACCEL=y
+CONFIG_FB_S1D13XXX=m
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+# CONFIG_FB_NVIDIA_DEBUG is not set
+CONFIG_FB_NVIDIA_BACKLIGHT=y
+CONFIG_FB_RIVA=m
+CONFIG_FB_RIVA_I2C=y
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_RIVA_BACKLIGHT=y
+CONFIG_FB_I810=m
+CONFIG_FB_I810_GTF=y
+CONFIG_FB_I810_I2C=y
+CONFIG_FB_LE80578=m
+CONFIG_FB_CARILLO_RANCH=m
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+CONFIG_FB_INTEL_I2C=y
+CONFIG_FB_MATROX=m
+CONFIG_FB_MATROX_MILLENIUM=y
+CONFIG_FB_MATROX_MYSTIQUE=y
+CONFIG_FB_MATROX_G=y
+# CONFIG_FB_MATROX_I2C is not set
+CONFIG_FB_MATROX_MULTIHEAD=y
+CONFIG_FB_RADEON=m
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+# CONFIG_FB_RADEON_DEBUG is not set
+# CONFIG_FB_ATY128 is not set
+CONFIG_FB_ATY=m
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+CONFIG_FB_S3=m
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+CONFIG_FB_SIS=m
+CONFIG_FB_SIS_300=y
+CONFIG_FB_SIS_315=y
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+CONFIG_FB_VT8623=m
+CONFIG_FB_CYBLA=m
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+CONFIG_FB_ARK=m
+CONFIG_FB_PM3=m
+CONFIG_FB_CARMINE=m
+CONFIG_FB_CARMINE_DRAM_EVAL=y
+# CONFIG_CARMINE_DRAM_CUSTOM is not set
+CONFIG_FB_GEODE=y
+CONFIG_FB_GEODE_LX=m
+CONFIG_FB_GEODE_GX=m
+CONFIG_FB_GEODE_GX1=m
+CONFIG_FB_SM501=m
+# CONFIG_FB_VIRTUAL is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_LTV350QV=m
+CONFIG_LCD_ILI9320=m
+CONFIG_LCD_VGG2432A4=m
+CONFIG_LCD_PLATFORM=m
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_CORGI=m
+CONFIG_BACKLIGHT_PROGEAR=m
+CONFIG_BACKLIGHT_CARILLO_RANCH=m
+CONFIG_BACKLIGHT_MBP_NVIDIA=m
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=m
+
+#
+# Display hardware drivers
+#
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_MDA_CONSOLE=m
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+# CONFIG_LOGO is not set
+
+#
+# Bootsplash configuration
+#
+CONFIG_BOOTSPLASH=y
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_DEBUG=y
+# CONFIG_SND_DEBUG_VERBOSE is not set
+# CONFIG_SND_PCM_XRUN_DEBUG is not set
+CONFIG_SND_VMASTER=y
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_OPL4_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DRIVERS=y
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_MTS64=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+CONFIG_SND_PORTMAN2X4=m
+CONFIG_SND_AC97_POWER_SAVE=y
+CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0
+CONFIG_SND_AD1848_LIB=m
+CONFIG_SND_CS4231_LIB=m
+CONFIG_SND_SB_COMMON=m
+CONFIG_SND_SB8_DSP=m
+CONFIG_SND_SB16_DSP=m
+CONFIG_SND_ISA=y
+CONFIG_SND_ADLIB=m
+CONFIG_SND_AD1816A=m
+CONFIG_SND_AD1848=m
+CONFIG_SND_ALS100=m
+CONFIG_SND_AZT2320=m
+CONFIG_SND_CMI8330=m
+CONFIG_SND_CS4231=m
+CONFIG_SND_CS4232=m
+CONFIG_SND_CS4236=m
+CONFIG_SND_DT019X=m
+CONFIG_SND_ES968=m
+CONFIG_SND_ES1688=m
+CONFIG_SND_ES18XX=m
+CONFIG_SND_SC6000=m
+CONFIG_SND_GUSCLASSIC=m
+CONFIG_SND_GUSEXTREME=m
+CONFIG_SND_GUSMAX=m
+CONFIG_SND_INTERWAVE=m
+CONFIG_SND_INTERWAVE_STB=m
+CONFIG_SND_OPL3SA2=m
+CONFIG_SND_OPTI92X_AD1848=m
+CONFIG_SND_OPTI92X_CS4231=m
+CONFIG_SND_OPTI93X=m
+CONFIG_SND_MIRO=m
+CONFIG_SND_SB8=m
+CONFIG_SND_SB16=m
+CONFIG_SND_SBAWE=m
+CONFIG_SND_SB16_CSP=y
+CONFIG_SND_SGALAXY=m
+CONFIG_SND_SSCAPE=m
+CONFIG_SND_WAVEFRONT=m
+# CONFIG_SND_WAVEFRONT_FIRMWARE_IN_KERNEL is not set
+CONFIG_SND_PCI=y
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AW2=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_OXYGEN_LIB=m
+CONFIG_SND_OXYGEN=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS5530=m
+CONFIG_SND_CS5535AUDIO=m
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDA_HWDEP=y
+CONFIG_SND_HDA_INPUT_BEEP=y
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_CODEC_ANALOG=y
+CONFIG_SND_HDA_CODEC_SIGMATEL=y
+CONFIG_SND_HDA_CODEC_VIA=y
+CONFIG_SND_HDA_CODEC_ATIHDMI=y
+CONFIG_SND_HDA_CODEC_NVHDMI=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+CONFIG_SND_HDA_CODEC_CMEDIA=y
+CONFIG_SND_HDA_CODEC_SI3054=y
+CONFIG_SND_HDA_GENERIC=y
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_HIFIER=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SIS7019=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VIRTUOSO=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+CONFIG_SND_SPI=y
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+CONFIG_SND_USB_CAIAQ=m
+CONFIG_SND_USB_CAIAQ_INPUT=y
+CONFIG_SND_PCMCIA=y
+CONFIG_SND_VXPOCKET=m
+CONFIG_SND_PDAUDIOCF=m
+# CONFIG_SND_SOC is not set
+CONFIG_SOUND_PRIME=m
+# CONFIG_SOUND_MSNDCLAS is not set
+# CONFIG_SOUND_MSNDPIN is not set
+CONFIG_SOUND_OSS=m
+CONFIG_SOUND_TRACEINIT=y
+CONFIG_SOUND_DMAP=y
+CONFIG_SOUND_SSCAPE=m
+CONFIG_SOUND_VMIDI=m
+CONFIG_SOUND_TRIX=m
+CONFIG_SOUND_MSS=m
+CONFIG_SOUND_MPU401=m
+CONFIG_SOUND_PAS=m
+CONFIG_SOUND_PSS=m
+CONFIG_PSS_MIXER=y
+# CONFIG_PSS_HAVE_BOOT is not set
+CONFIG_SOUND_SB=m
+CONFIG_SOUND_YM3812=m
+CONFIG_SOUND_UART6850=m
+CONFIG_SOUND_AEDSP16=m
+CONFIG_SC6600=y
+CONFIG_SC6600_JOY=y
+CONFIG_SC6600_CDROM=4
+CONFIG_SC6600_CDROMBASE=0x0
+# CONFIG_AEDSP16_MSS is not set
+# CONFIG_AEDSP16_SBPRO is not set
+CONFIG_SOUND_KAHLUA=m
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=m
+# CONFIG_HID_DEBUG is not set
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=m
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+# CONFIG_LOGIRUMBLEPAD2_FF is not set
+CONFIG_PANTHERLORD_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_ZEROPLUS_FF=y
+CONFIG_USB_HIDDEV=y
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_OTG is not set
+CONFIG_USB_MON=y
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_C67X00_HCD=m
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_ISP1760_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_HCD_SSB is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+# CONFIG_USB_U132_HCD is not set
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+CONFIG_USB_R8A66597_HCD=m
+
+#
+# Enable Host or Gadget support to see Inventra options
+#
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+CONFIG_USB_WDM=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+CONFIG_USB_STORAGE_ONETOUCH=y
+CONFIG_USB_STORAGE_KARMA=y
+CONFIG_USB_STORAGE_CYPRESS_ATACB=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+CONFIG_USB_SERIAL=m
+CONFIG_USB_EZUSB=y
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRCABLE=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_CH341=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_IUU=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_MOS7720=m
+CONFIG_USB_SERIAL_MOS7840=m
+CONFIG_USB_SERIAL_MOTOROLA=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_OTI6858=m
+CONFIG_USB_SERIAL_QUALCOMM=m
+CONFIG_USB_SERIAL_SPCP8X5=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_SERIAL_DEBUG=m
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_ADUTUX=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_BERRY_CHARGE=m
+CONFIG_USB_LED=m
+CONFIG_USB_CYPRESS_CY7C63=m
+CONFIG_USB_CYTHERM=m
+CONFIG_USB_PHIDGET=m
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETMOTORCONTROL=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_FTDI_ELAN=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TRANCEVIBRATOR=m
+CONFIG_USB_IOWARRIOR=m
+# CONFIG_USB_TEST is not set
+CONFIG_USB_ISIGHTFW=m
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+# CONFIG_USB_GADGET is not set
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD Card Drivers
+#
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK_BOUNCE=y
+CONFIG_SDIO_UART=m
+CONFIG_MMC_TEST=m
+
+#
+# MMC/SD Host Controller Drivers
+#
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_SDHCI_PCI=m
+CONFIG_MMC_RICOH_MMC=m
+CONFIG_MMC_WBSD=m
+CONFIG_MMC_TIFM_SD=m
+CONFIG_MMC_SDRICOH_CS=m
+CONFIG_MEMSTICK=m
+# CONFIG_MEMSTICK_DEBUG is not set
+
+#
+# MemoryStick drivers
+#
+# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
+CONFIG_MSPRO_BLOCK=m
+
+#
+# MemoryStick Host Controller Drivers
+#
+CONFIG_MEMSTICK_TIFM_MS=m
+CONFIG_MEMSTICK_JMICRON_38X=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=m
+
+#
+# LED drivers
+#
+CONFIG_LEDS_NET48XX=m
+CONFIG_LEDS_WRAP=m
+CONFIG_LEDS_PCA9532=m
+CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_CLEVO_MAIL=m
+CONFIG_LEDS_PCA955X=m
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_INFINIBAND=m
+CONFIG_INFINIBAND_USER_MAD=m
+CONFIG_INFINIBAND_USER_ACCESS=m
+CONFIG_INFINIBAND_USER_MEM=y
+CONFIG_INFINIBAND_ADDR_TRANS=y
+CONFIG_INFINIBAND_MTHCA=m
+CONFIG_INFINIBAND_MTHCA_DEBUG=y
+CONFIG_INFINIBAND_AMSO1100=m
+# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
+CONFIG_INFINIBAND_CXGB3=m
+# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
+CONFIG_MLX4_INFINIBAND=m
+CONFIG_INFINIBAND_NES=m
+# CONFIG_INFINIBAND_NES_DEBUG is not set
+CONFIG_INFINIBAND_IPOIB=m
+CONFIG_INFINIBAND_IPOIB_CM=y
+CONFIG_INFINIBAND_IPOIB_DEBUG=y
+# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
+CONFIG_INFINIBAND_SRP=m
+CONFIG_INFINIBAND_ISER=m
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_AMD76X=m
+CONFIG_EDAC_E7XXX=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I82875P=m
+CONFIG_EDAC_I82975X=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I82860=m
+CONFIG_EDAC_R82600=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_I5100=m
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_INTF_DEV_UIE_EMUL=y
+CONFIG_RTC_DRV_TEST=m
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1374=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_MAX6900=m
+CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_M41T80=m
+CONFIG_RTC_DRV_M41T80_WDT=y
+CONFIG_RTC_DRV_S35390A=m
+CONFIG_RTC_DRV_FM3130=m
+
+#
+# SPI RTC drivers
+#
+CONFIG_RTC_DRV_M41T94=m
+CONFIG_RTC_DRV_DS1305=m
+CONFIG_RTC_DRV_MAX6902=m
+CONFIG_RTC_DRV_R9701=m
+CONFIG_RTC_DRV_RS5C348=m
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=m
+CONFIG_RTC_DRV_DS1511=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_STK17TA8=m
+CONFIG_RTC_DRV_M48T86=m
+CONFIG_RTC_DRV_M48T59=m
+CONFIG_RTC_DRV_V3020=m
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+CONFIG_DMATEST=m
+CONFIG_DCA=m
+CONFIG_AUXDISPLAY=y
+CONFIG_KS0108=m
+CONFIG_KS0108_PORT=0x378
+CONFIG_KS0108_DELAY=2
+CONFIG_CFAG12864B=m
+CONFIG_CFAG12864B_RATE=20
+CONFIG_UIO=m
+CONFIG_UIO_CIF=m
+CONFIG_UIO_PDRV=m
+CONFIG_UIO_PDRV_GENIRQ=m
+CONFIG_UIO_SMX=m
+CONFIG_STAGING=y
+CONFIG_ET131X=m
+# CONFIG_ET131X_DEBUG is not set
+CONFIG_SLICOSS=m
+CONFIG_SXG=m
+CONFIG_ME4000=m
+CONFIG_VIDEO_GO7007=m
+CONFIG_VIDEO_GO7007_USB=m
+CONFIG_USB_IP_COMMON=m
+CONFIG_USB_IP_VHCI_HCD=m
+CONFIG_USB_IP_HOST=m
+CONFIG_W35UND=m
+CONFIG_PRISM2_USB=m
+CONFIG_ECHO=m
+CONFIG_USB_ATMEL=m
+CONFIG_AGNX=m
+CONFIG_OTUS=m
+CONFIG_RT2860=m
+CONFIG_RT2870=m
+CONFIG_RT3070=m
+CONFIG_BENET=m
+CONFIG_RTL8187SE=m
+CONFIG_DRM_PSB=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+# CONFIG_EDD_OFF is not set
+CONFIG_FIRMWARE_MEMMAP=y
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_DMIID=y
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=m
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_NFS4ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+CONFIG_JBD_DEBUG=y
+CONFIG_JBD2=m
+CONFIG_JBD2_DEBUG=y
+CONFIG_FS_MBCACHE=m
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+CONFIG_JFS_FS=m
+CONFIG_JFS_POSIX_ACL=y
+CONFIG_JFS_SECURITY=y
+# CONFIG_JFS_DEBUG is not set
+CONFIG_JFS_STATISTICS=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_FS_NFS4ACL=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_DMAPI=m
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_XFS_RT=y
+# CONFIG_XFS_DEBUG is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+CONFIG_OCFS2_FS=m
+CONFIG_OCFS2_FS_O2CB=m
+CONFIG_OCFS2_FS_USERSPACE_CLUSTER=m
+CONFIG_OCFS2_FS_STATS=y
+# CONFIG_OCFS2_DEBUG_MASKLOG is not set
+# CONFIG_OCFS2_DEBUG_FS is not set
+# CONFIG_OCFS2_COMPAT_JBD is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_DMAPI=m
+# CONFIG_DMAPI_DEBUG is not set
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_PRINT_QUOTA_WARNING=y
+CONFIG_QUOTA_TREE=m
+CONFIG_QFMT_V1=m
+CONFIG_QFMT_V2=m
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+CONFIG_NTFS_RW=y
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+CONFIG_ADFS_FS=m
+# CONFIG_ADFS_FS_RW is not set
+CONFIG_AFFS_FS=m
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+CONFIG_BEFS_FS=m
+# CONFIG_BEFS_DEBUG is not set
+CONFIG_BFS_FS=m
+CONFIG_EFS_FS=m
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+CONFIG_JFFS2_SUMMARY=y
+CONFIG_JFFS2_FS_XATTR=y
+CONFIG_JFFS2_FS_POSIX_ACL=y
+CONFIG_JFFS2_FS_SECURITY=y
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+CONFIG_UBIFS_FS=m
+CONFIG_UBIFS_FS_XATTR=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_UBIFS_FS_DEBUG is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+CONFIG_VXFS_FS=m
+CONFIG_MINIX_FS=y
+CONFIG_OMFS_FS=m
+CONFIG_HPFS_FS=m
+CONFIG_QNX4FS_FS=m
+CONFIG_ROMFS_FS=m
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+CONFIG_UFS_FS_WRITE=y
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_SWAP=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_SUNRPC_XPRT_RDMA=m
+CONFIG_SUNRPC_SWAP=y
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+CONFIG_CIFS_STATS=y
+CONFIG_CIFS_STATS2=y
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_DFS_UPCALL=y
+CONFIG_NCP_FS=m
+CONFIG_NCPFS_PACKET_SIGNING=y
+CONFIG_NCPFS_IOCTL_LOCKING=y
+CONFIG_NCPFS_STRONG=y
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+CONFIG_NCPFS_SMALLDOS=y
+CONFIG_NCPFS_NLS=y
+CONFIG_NCPFS_EXTRAS=y
+CONFIG_CODA_FS=m
+CONFIG_AFS_FS=m
+# CONFIG_AFS_DEBUG is not set
+CONFIG_9P_FS=m
+CONFIG_NOVFS=m
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+# CONFIG_AMIGA_PARTITION is not set
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+# CONFIG_MINIX_SUBPARTITION is not set
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+# CONFIG_LDM_DEBUG is not set
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_SYSV68_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_DLM=m
+# CONFIG_DLM_DEBUG is not set
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+# CONFIG_DETECT_SOFTLOCKUP is not set
+CONFIG_SCHED_DEBUG=y
+CONFIG_SCHEDSTATS=y
+CONFIG_TIMER_STATS=y
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_HIGHMEM is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+CONFIG_DEBUG_MEMORY_INIT=y
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_FRAME_POINTER is not set
+CONFIG_UNWIND_INFO=y
+CONFIG_STACK_UNWIND=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+CONFIG_RCU_TORTURE_TEST=m
+# CONFIG_KPROBES_SANITY_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+CONFIG_LKDTM=m
+# CONFIG_FAULT_INJECTION is not set
+CONFIG_LATENCYTOP=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+CONFIG_HAVE_FTRACE=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+# CONFIG_FTRACE is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SYSPROF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+CONFIG_PROVIDE_OHCI1394_DMA_INIT=y
+CONFIG_DYNAMIC_PRINTK_DEBUG=y
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_STRICT_DEVMEM is not set
+# CONFIG_X86_VERBOSE_BOOTUP is not set
+CONFIG_EARLY_PRINTK=y
+CONFIG_EARLY_PRINTK_DBGP=y
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_DEBUG_PER_CPU_MAPS is not set
+# CONFIG_X86_PTDUMP is not set
+CONFIG_DEBUG_RODATA=y
+# CONFIG_DEBUG_RODATA_TEST is not set
+# CONFIG_DEBUG_NX_TEST is not set
+# CONFIG_4KSTACKS is not set
+CONFIG_DOUBLEFAULT=y
+# CONFIG_MMIOTRACE is not set
+CONFIG_IO_DELAY_TYPE_0X80=0
+CONFIG_IO_DELAY_TYPE_0XED=1
+CONFIG_IO_DELAY_TYPE_UDELAY=2
+CONFIG_IO_DELAY_TYPE_NONE=3
+CONFIG_IO_DELAY_0X80=y
+# CONFIG_IO_DELAY_0XED is not set
+# CONFIG_IO_DELAY_UDELAY is not set
+# CONFIG_IO_DELAY_NONE is not set
+CONFIG_DEFAULT_IO_DELAY_TYPE=0
+# CONFIG_DEBUG_BOOT_PARAMS is not set
+# CONFIG_CPA_DEBUG is not set
+# CONFIG_OPTIMIZE_INLINING is not set
+CONFIG_KDB=y
+CONFIG_KDB_MODULES=m
+CONFIG_KDB_OFF=y
+CONFIG_KDB_CONTINUE_CATASTROPHIC=0
+CONFIG_KDB_USB=y
+CONFIG_KDB_KDUMP=y
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_DEFAULT="apparmor"
+CONFIG_SECURITY_NETWORK=y
+# CONFIG_SECURITY_NETWORK_XFRM is not set
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+CONFIG_SECURITY_APPARMOR=y
+CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_APPARMOR_DISABLE=y
+CONFIG_XOR_BLOCKS=m
+CONFIG_ASYNC_CORE=m
+CONFIG_ASYNC_MEMCPY=m
+CONFIG_ASYNC_XOR=m
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Authenticated Encryption with Associated Data
+#
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_SEQIV=m
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_XTS=m
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_XCBC=m
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_RMD128=m
+CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_RMD256=m
+CONFIG_CRYPTO_RMD320=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_586=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_SALSA20=m
+CONFIG_CRYPTO_SALSA20_586=m
+CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TEA=m
+# CONFIG_CRYPTO_TWOFISH is not set
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_TWOFISH_586=m
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_DEV_PADLOCK=m
+CONFIG_CRYPTO_DEV_PADLOCK_AES=m
+CONFIG_CRYPTO_DEV_PADLOCK_SHA=m
+CONFIG_CRYPTO_DEV_GEODE=m
+CONFIG_CRYPTO_DEV_HIFN_795X=m
+CONFIG_CRYPTO_DEV_HIFN_795X_RNG=y
+CONFIG_HAVE_KVM=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM_KMP=y
+# CONFIG_KVM is not set
+# CONFIG_LGUEST is not set
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
+CONFIG_VIRTIO_BALLOON=m
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_FIRST_BIT=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_T10DIF=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_AUDIT_GENERIC=y
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_CHECK_SIGNATURE=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-x86_64-default.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-x86_64-default.config
new file mode 100644
index 0000000..69bca9a
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-x86_64-default.config
@@ -0,0 +1,4143 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.27.21
+# Wed May 13 22:02:04 2009
+#
+CONFIG_64BIT=y
+# CONFIG_X86_32 is not set
+CONFIG_X86_64=y
+CONFIG_X86=y
+CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
+# CONFIG_GENERIC_LOCKBREAK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_CLOCKSOURCE_WATCHDOG=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_FAST_CMPXCHG_LOCAL=y
+CONFIG_MMU=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_ARCH_HAS_CPU_RELAX=y
+CONFIG_ARCH_HAS_DEFAULT_IDLE=y
+CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
+CONFIG_HAVE_SETUP_PER_CPU_AREA=y
+CONFIG_HAVE_CPUMASK_OF_CPU_MAP=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ZONE_DMA32=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_AUDIT_ARCH=y
+CONFIG_ARCH_SUPPORTS_AOUT=y
+CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_64_SMP=y
+CONFIG_X86_HT=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
+# CONFIG_KTIME_SCALAR is not set
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-0.1-default"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SUSE_KERNEL=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_TREE=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=18
+CONFIG_CGROUPS=y
+# CONFIG_CGROUP_DEBUG is not set
+CONFIG_CGROUP_NS=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_DEVICE=y
+CONFIG_CPUSETS=y
+CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+# CONFIG_USER_SCHED is not set
+CONFIG_CGROUP_SCHED=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_RESOURCE_COUNTERS=y
+CONFIG_MM_OWNER=y
+CONFIG_CGROUP_MEM_RES_CTLR=y
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_PROC_PID_CPUSET=y
+CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_IPC_NS=y
+CONFIG_USER_NS=y
+CONFIG_PID_NS=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_PCSPKR_PLATFORM=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+# CONFIG_TRACEPOINTS is not set
+CONFIG_MARKERS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_KRETPROBES=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+# CONFIG_HAVE_DMA_ATTRS is not set
+CONFIG_USE_GENERIC_SMP_HELPERS=y
+# CONFIG_HAVE_CLK is not set
+CONFIG_PROC_PAGE_MONITOR=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+# CONFIG_UTRACE is not set
+CONFIG_BLOCK=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_BLOCK_COMPAT=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
+
+#
+# Processor type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SMP=y
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
+CONFIG_X86_PC=y
+# CONFIG_X86_XEN is not set
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_64_XEN is not set
+# CONFIG_X86_VSMP is not set
+# CONFIG_PARAVIRT_GUEST is not set
+CONFIG_MEMTEST=y
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+# CONFIG_M686 is not set
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+# CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+CONFIG_GENERIC_CPU=y
+CONFIG_X86_CPU=y
+CONFIG_X86_L1_CACHE_BYTES=128
+CONFIG_X86_INTERNODE_CACHE_BYTES=128
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_TSC=y
+CONFIG_X86_CMPXCHG64=y
+CONFIG_X86_CMOV=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=64
+CONFIG_X86_DEBUGCTLMSR=y
+CONFIG_HPET_TIMER=y
+CONFIG_HPET_EMULATE_RTC=y
+CONFIG_DMI=y
+CONFIG_GART_IOMMU=y
+CONFIG_CALGARY_IOMMU=y
+# CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT is not set
+CONFIG_AMD_IOMMU=y
+CONFIG_SWIOTLB=y
+CONFIG_IOMMU_HELPER=y
+CONFIG_MAXSMP=y
+CONFIG_NR_CPUS=512
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+# CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS is not set
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_MCE=y
+CONFIG_X86_MCE_INTEL=y
+CONFIG_X86_MCE_AMD=y
+CONFIG_I8K=m
+CONFIG_MICROCODE=m
+CONFIG_MICROCODE_OLD_INTERFACE=y
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+CONFIG_DIRECT_GBPAGES=y
+CONFIG_NUMA=y
+CONFIG_K8_NUMA=y
+CONFIG_X86_64_ACPI_NUMA=y
+CONFIG_NODES_SPAN_OTHER_NODES=y
+CONFIG_NUMA_EMU=y
+CONFIG_NODES_SHIFT=9
+CONFIG_ARCH_SPARSEMEM_DEFAULT=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+CONFIG_ARCH_SELECT_MEMORY_MODEL=y
+CONFIG_ARCH_MEMORY_PROBE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM=y
+CONFIG_NEED_MULTIPLE_NODES=y
+CONFIG_HAVE_MEMORY_PRESENT=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPARSEMEM_EXTREME=y
+CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
+CONFIG_SPARSEMEM_VMEMMAP=y
+CONFIG_MEMORY_HOTPLUG=y
+CONFIG_MEMORY_HOTPLUG_SPARSE=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_MIGRATION=y
+CONFIG_RESOURCES_64BIT=y
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_MMU_NOTIFIER=y
+CONFIG_X86_RESERVE_LOW_64K=y
+CONFIG_MTRR=y
+# CONFIG_MTRR_SANITIZER is not set
+CONFIG_X86_PAT=y
+CONFIG_EFI=y
+CONFIG_SECCOMP=y
+# CONFIG_SECCOMP_DISABLE_TSC is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+CONFIG_PHYSICAL_START=0x200000
+CONFIG_RELOCATABLE=y
+CONFIG_PHYSICAL_ALIGN=0x200000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_COMPAT_VDSO=y
+
+#
+# Hardware Performance Monitoring support
+#
+CONFIG_PERFMON=y
+# CONFIG_PERFMON_DEBUG is not set
+CONFIG_PERFMON_DEBUG_FS=y
+CONFIG_X86_PERFMON_P4=m
+CONFIG_X86_PERFMON_PEBS_P4=m
+CONFIG_X86_PERFMON_CORE=m
+CONFIG_X86_PERFMON_PEBS_CORE=m
+CONFIG_X86_PERFMON_INTEL_ATOM=m
+CONFIG_X86_PERFMON_INTEL_ARCH=m
+CONFIG_X86_PERFMON_AMD64=m
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
+
+#
+# Power management options
+#
+CONFIG_ARCH_HIBERNATION_HEADER=y
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP_SMP=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION=""
+CONFIG_ACPI=y
+CONFIG_ACPI_SLEEP=y
+CONFIG_ACPI_PROCFS=y
+CONFIG_ACPI_PROCFS_POWER=y
+CONFIG_ACPI_SYSFS_POWER=y
+CONFIG_ACPI_PROC_EVENT=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_DOCK=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_NUMA=y
+CONFIG_ACPI_WMI=m
+# CONFIG_ACPI_ASUS is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_CUSTOM_DSDT_FILE=""
+# CONFIG_ACPI_CUSTOM_DSDT is not set
+CONFIG_ACPI_CUSTOM_DSDT_INITRD=y
+CONFIG_ACPI_BLACKLIST_YEAR=0
+CONFIG_ACPI_DEBUG=y
+# CONFIG_ACPI_DEBUG_FUNC_TRACE is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_PCI_SLOT=m
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_X86_PM_TIMER=y
+CONFIG_ACPI_CONTAINER=m
+CONFIG_ACPI_HOTPLUG_MEMORY=m
+CONFIG_ACPI_SBS=m
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+# CONFIG_X86_SPEEDSTEP_CENTRINO is not set
+# CONFIG_X86_P4_CLOCKMOD is not set
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+# CONFIG_X86_SPEEDSTEP_LIB is not set
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_GOV_LADDER=y
+CONFIG_CPU_IDLE_GOV_MENU=y
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_DOMAINS=y
+# CONFIG_DMAR is not set
+CONFIG_INTR_REMAP=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+CONFIG_PCIEAER=y
+CONFIG_PCIEASPM=y
+# CONFIG_PCIEASPM_DEBUG is not set
+CONFIG_ARCH_SUPPORTS_MSI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_HT_IRQ=y
+CONFIG_ISA_DMA_API=y
+CONFIG_K8_NB=y
+CONFIG_PCCARD=m
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=m
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=m
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+CONFIG_I82092=m
+CONFIG_PCCARD_NONSTATIC=m
+CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+CONFIG_HOTPLUG_PCI_CPCI=y
+CONFIG_HOTPLUG_PCI_CPCI_ZT5550=m
+CONFIG_HOTPLUG_PCI_CPCI_GENERIC=m
+CONFIG_HOTPLUG_PCI_SHPC=m
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_COMPAT_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=m
+CONFIG_IA32_EMULATION=y
+CONFIG_IA32_AOUT=y
+CONFIG_COMPAT=y
+CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
+CONFIG_SYSVIPC_COMPAT=y
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=m
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+CONFIG_XFRM_SUB_POLICY=y
+CONFIG_XFRM_MIGRATE=y
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=m
+CONFIG_NET_KEY=m
+CONFIG_NET_KEY_MIGRATE=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=m
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_TCP_CONG_YEAH=m
+CONFIG_TCP_CONG_ILLINOIS=m
+# CONFIG_DEFAULT_BIC is not set
+CONFIG_DEFAULT_CUBIC=y
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+# CONFIG_DEFAULT_RENO is not set
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_IPV6_MIP6=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_NDISC_NODETYPE=y
+CONFIG_IPV6_TUNNEL=m
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETLABEL is not set
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CT_ACCT=y
+CONFIG_NF_CONNTRACK_MARK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CT_PROTO_DCCP=m
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=m
+CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CONNTRACK_AMANDA=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_NETBIOS_NS=m
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SANE=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
+CONFIG_NF_CONNTRACK_SLP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_DSCP=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_RATEEST=m
+CONFIG_NETFILTER_XT_TARGET_TRACE=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_DSCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_OWNER=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_RATEEST=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_TIME=m
+CONFIG_NETFILTER_XT_MATCH_U32=m
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV4=m
+# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_IPV4OPTIONS=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_NF_NAT_SNMP_BASIC=m
+CONFIG_NF_NAT_PROTO_DCCP=m
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_PROTO_UDPLITE=m
+CONFIG_NF_NAT_PROTO_SCTP=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_TFTP=m
+CONFIG_NF_NAT_AMANDA=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_SECURITY=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_MH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_IP6_NF_SECURITY=m
+
+#
+# DECnet: Netfilter Configuration
+#
+# CONFIG_DECNET_NF_GRABULATOR is not set
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_IP6=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+CONFIG_BRIDGE_EBT_NFLOG=m
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+# CONFIG_IP_DCCP_CCID2_DEBUG is not set
+CONFIG_IP_DCCP_CCID3=m
+# CONFIG_IP_DCCP_CCID3_DEBUG is not set
+CONFIG_IP_DCCP_CCID3_RTO=100
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+# CONFIG_NET_DCCPPROBE is not set
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_TIPC is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+# CONFIG_ATM_CLIP_NO_ICMP is not set
+CONFIG_ATM_LANE=m
+CONFIG_ATM_MPOA=m
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_STP=m
+CONFIG_GARP=m
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+CONFIG_VLAN_8021Q_GVRP=y
+CONFIG_DECNET=m
+# CONFIG_DECNET_ROUTER is not set
+CONFIG_LLC=y
+CONFIG_LLC2=m
+CONFIG_IPX=m
+CONFIG_IPX_INTERN=y
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=m
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+CONFIG_X25=m
+CONFIG_LAPB=m
+CONFIG_ECONET=m
+# CONFIG_ECONET_AUNUDP is not set
+# CONFIG_ECONET_NATIVE is not set
+CONFIG_WAN_ROUTER=m
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_MULTIQ=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_CLS_FLOW=m
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+CONFIG_NET_EMATCH_CMP=m
+CONFIG_NET_EMATCH_NBYTE=m
+CONFIG_NET_EMATCH_U32=m
+CONFIG_NET_EMATCH_META=m
+CONFIG_NET_EMATCH_TEXT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_NAT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_ACT_SKBEDIT=m
+# CONFIG_NET_CLS_IND is not set
+CONFIG_NET_SCH_FIFO=y
+CONFIG_DCB=m
+CONFIG_DCBNL=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+CONFIG_NET_TCPPROBE=m
+CONFIG_HAMRADIO=y
+
+#
+# Packet Radio protocols
+#
+CONFIG_AX25=m
+CONFIG_AX25_DAMA_SLAVE=y
+CONFIG_NETROM=m
+CONFIG_ROSE=m
+
+#
+# AX.25 network device drivers
+#
+CONFIG_MKISS=m
+CONFIG_6PACK=m
+CONFIG_BPQETHER=m
+CONFIG_BAYCOM_SER_FDX=m
+CONFIG_BAYCOM_SER_HDX=m
+CONFIG_BAYCOM_PAR=m
+CONFIG_YAM=m
+CONFIG_CAN=m
+CONFIG_CAN_RAW=m
+CONFIG_CAN_BCM=m
+
+#
+# CAN Device Drivers
+#
+CONFIG_CAN_VCAN=m
+# CONFIG_CAN_DEBUG_DEVICES is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+CONFIG_IRDA_ULTRA=y
+
+#
+# IrDA options
+#
+CONFIG_IRDA_CACHE_LAST_LSAP=y
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+CONFIG_DONGLE=y
+CONFIG_ESI_DONGLE=m
+CONFIG_ACTISYS_DONGLE=m
+CONFIG_TEKRAM_DONGLE=m
+CONFIG_TOIM3232_DONGLE=m
+CONFIG_LITELINK_DONGLE=m
+CONFIG_MA600_DONGLE=m
+CONFIG_GIRBIL_DONGLE=m
+CONFIG_MCP2120_DONGLE=m
+CONFIG_OLD_BELKIN_DONGLE=m
+CONFIG_ACT200L_DONGLE=m
+CONFIG_KINGSUN_DONGLE=m
+CONFIG_KSDAZZLE_DONGLE=m
+CONFIG_KS959_DONGLE=m
+
+#
+# FIR device drivers
+#
+CONFIG_USB_IRDA=m
+CONFIG_SIGMATEL_FIR=m
+CONFIG_NSC_FIR=m
+CONFIG_WINBOND_FIR=m
+CONFIG_SMC_IRCC_FIR=m
+CONFIG_ALI_FIR=m
+CONFIG_VLSI_FIR=m
+CONFIG_VIA_FIR=m
+CONFIG_MCS_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIBTUSB=m
+CONFIG_BT_HCIBTSDIO=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_AF_RXRPC=m
+# CONFIG_AF_RXRPC_DEBUG is not set
+CONFIG_RXKAD=m
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_PID=y
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_MESH=y
+CONFIG_MAC80211_LEDS=y
+CONFIG_MAC80211_DEBUGFS=y
+# CONFIG_MAC80211_DEBUG_MENU is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_RFKILL=m
+CONFIG_RFKILL_INPUT=m
+CONFIG_RFKILL_LEDS=y
+CONFIG_NET_9P=m
+CONFIG_NET_9P_VIRTIO=m
+# CONFIG_NET_9P_DEBUG is not set
+CONFIG_NETVM=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH=""
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_AR7_PARTS=m
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLKDEVS=m
+CONFIG_MTD_BLOCK=m
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+# CONFIG_SSFDC is not set
+CONFIG_MTD_OOPS=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ABSENT=m
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=m
+CONFIG_MTD_PHYSMAP_START=0x8000000
+CONFIG_MTD_PHYSMAP_LEN=0x4000000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_SC520CDP is not set
+# CONFIG_MTD_NETSC520 is not set
+CONFIG_MTD_TS5500=m
+# CONFIG_MTD_SBC_GXX is not set
+CONFIG_MTD_AMD76XROM=m
+CONFIG_MTD_ICHXROM=m
+CONFIG_MTD_ESB2ROM=m
+CONFIG_MTD_CK804XROM=m
+CONFIG_MTD_SCB2_FLASH=m
+# CONFIG_MTD_NETtel is not set
+# CONFIG_MTD_DILNETPC is not set
+# CONFIG_MTD_L440GX is not set
+CONFIG_MTD_PCI=m
+CONFIG_MTD_INTEL_VR_NOR=m
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_PMC551=m
+CONFIG_MTD_PMC551_BUGFIX=y
+# CONFIG_MTD_PMC551_DEBUG is not set
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+CONFIG_MTD_SLRAM=m
+CONFIG_MTD_PHRAM=m
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+CONFIG_MTD_DOC2000=m
+CONFIG_MTD_DOC2001=m
+CONFIG_MTD_DOC2001PLUS=m
+CONFIG_MTD_DOCPROBE=m
+CONFIG_MTD_DOCECC=m
+CONFIG_MTD_DOCPROBE_ADVANCED=y
+CONFIG_MTD_DOCPROBE_ADDRESS=0x0000
+CONFIG_MTD_DOCPROBE_HIGH=y
+CONFIG_MTD_DOCPROBE_55AA=y
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
+CONFIG_MTD_NAND_CAFE=m
+CONFIG_MTD_NAND_NANDSIM=m
+CONFIG_MTD_NAND_PLATFORM=m
+CONFIG_MTD_ALAUDA=m
+CONFIG_MTD_ONENAND=m
+# CONFIG_MTD_ONENAND_VERIFY_WRITE is not set
+CONFIG_MTD_ONENAND_OTP=y
+CONFIG_MTD_ONENAND_2X_PROGRAM=y
+CONFIG_MTD_ONENAND_SIM=m
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=m
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+CONFIG_PARPORT_PC_FIFO=y
+CONFIG_PARPORT_PC_SUPERIO=y
+CONFIG_PARPORT_PC_PCMCIA=m
+# CONFIG_PARPORT_GSC is not set
+CONFIG_PARPORT_AX88796=m
+CONFIG_PARPORT_1284=y
+CONFIG_PARPORT_NOT_PC=y
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_PNPACPI=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_FD=m
+CONFIG_PARIDE=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=128000
+CONFIG_BLK_DEV_XIP=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+CONFIG_ATA_OVER_ETH=m
+CONFIG_CIPHER_TWOFISH=m
+CONFIG_VIRTIO_BLK=m
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+CONFIG_IBM_ASM=m
+CONFIG_PHANTOM=m
+CONFIG_EEPROM_93CX6=m
+CONFIG_SGI_IOC4=m
+CONFIG_TIFM_CORE=m
+CONFIG_TIFM_7XX1=m
+CONFIG_ACER_WMI=m
+CONFIG_ASUS_LAPTOP=m
+CONFIG_FUJITSU_LAPTOP=m
+# CONFIG_FUJITSU_LAPTOP_DEBUG is not set
+CONFIG_HP_WMI=m
+CONFIG_MSI_LAPTOP=m
+CONFIG_PANASONIC_LAPTOP=m
+CONFIG_COMPAL_LAPTOP=m
+CONFIG_SONY_LAPTOP=m
+CONFIG_SONYPI_COMPAT=y
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+CONFIG_INTEL_MENLOW=m
+CONFIG_EEEPC_LAPTOP=m
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_SGI_XP=m
+CONFIG_HP_ILO=m
+CONFIG_SGI_GRU=m
+# CONFIG_SGI_GRU_DEBUG is not set
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=m
+CONFIG_BLK_DEV_IDE=m
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+CONFIG_IDE_TIMINGS=y
+CONFIG_IDE_ATAPI=y
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=m
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_DELKIN=m
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_BLK_DEV_IDEACPI=y
+# CONFIG_IDE_TASK_IOCTL is not set
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=m
+CONFIG_BLK_DEV_PLATFORM=m
+CONFIG_BLK_DEV_CMD640=m
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=m
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_BLK_DEV_OFFBOARD=y
+CONFIG_BLK_DEV_GENERIC=m
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_RZ1000=m
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_AEC62XX=m
+CONFIG_BLK_DEV_ALI15X3=m
+CONFIG_BLK_DEV_AMD74XX=m
+CONFIG_BLK_DEV_ATIIXP=m
+CONFIG_BLK_DEV_CMD64X=m
+CONFIG_BLK_DEV_TRIFLEX=m
+CONFIG_BLK_DEV_CS5520=m
+CONFIG_BLK_DEV_CS5530=m
+CONFIG_BLK_DEV_HPT366=m
+CONFIG_BLK_DEV_JMICRON=m
+CONFIG_BLK_DEV_SC1200=m
+CONFIG_BLK_DEV_PIIX=m
+CONFIG_BLK_DEV_IT8213=m
+CONFIG_BLK_DEV_IT821X=m
+CONFIG_BLK_DEV_NS87415=m
+CONFIG_BLK_DEV_PDC202XX_OLD=m
+CONFIG_BLK_DEV_PDC202XX_NEW=m
+CONFIG_BLK_DEV_SVWKS=m
+CONFIG_BLK_DEV_SIIMAGE=m
+CONFIG_BLK_DEV_SIS5513=m
+CONFIG_BLK_DEV_SLC90E66=m
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=m
+# CONFIG_BLK_DEV_TC86C001 is not set
+CONFIG_BLK_DEV_IDEDMA=y
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_ENCLOSURE=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_FC_TGT_ATTRS=y
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+CONFIG_SCSI_SAS_HOST_SMP=y
+CONFIG_SCSI_SAS_LIBSAS_DEBUG=y
+CONFIG_SCSI_SRP_ATTRS=m
+CONFIG_SCSI_SRP_TGT_ATTRS=y
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ISCSI_TCP=m
+CONFIG_SCSI_CXGB3_ISCSI=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
+CONFIG_AIC7XXX_RESET_DELAY_MS=5000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=32
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+CONFIG_AIC79XX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC94XX=m
+CONFIG_AIC94XX_DEBUG=y
+CONFIG_SCSI_DPT_I2O=m
+CONFIG_SCSI_ADVANSYS=m
+CONFIG_SCSI_ARCMSR=m
+CONFIG_SCSI_ARCMSR_AER=y
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+CONFIG_SCSI_BUSLOGIC=m
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_SCSI_DMX3191D=m
+CONFIG_SCSI_EATA=m
+CONFIG_SCSI_EATA_TAGGED_QUEUE=y
+CONFIG_SCSI_EATA_LINKED_COMMANDS=y
+CONFIG_SCSI_EATA_MAX_TAGS=16
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+# CONFIG_SCSI_INIA100 is not set
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_MVSAS=m
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+# CONFIG_SCSI_IPR is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_DC395x=m
+CONFIG_SCSI_DC390T=m
+CONFIG_SCSI_DEBUG=m
+CONFIG_SCSI_SRP=m
+CONFIG_SCSI_LOWLEVEL_PCMCIA=y
+CONFIG_PCMCIA_FDOMAIN=m
+CONFIG_PCMCIA_QLOGIC=m
+CONFIG_PCMCIA_SYM53C500=m
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_SCSI_DH_HP_SW=m
+CONFIG_SCSI_DH_EMC=m
+CONFIG_SCSI_DH_ALUA=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+CONFIG_PATA_ACPI=m
+CONFIG_PATA_ALI=m
+CONFIG_PATA_AMD=m
+CONFIG_PATA_ARTOP=m
+CONFIG_PATA_ATIIXP=m
+CONFIG_PATA_CMD640_PCI=m
+CONFIG_PATA_CMD64X=m
+CONFIG_PATA_CS5520=m
+CONFIG_PATA_CS5530=m
+CONFIG_PATA_CYPRESS=m
+CONFIG_PATA_EFAR=m
+CONFIG_ATA_GENERIC=m
+CONFIG_PATA_HPT366=m
+CONFIG_PATA_HPT37X=m
+CONFIG_PATA_HPT3X2N=m
+CONFIG_PATA_HPT3X3=m
+# CONFIG_PATA_HPT3X3_DMA is not set
+CONFIG_PATA_IT821X=m
+CONFIG_PATA_IT8213=m
+CONFIG_PATA_JMICRON=m
+CONFIG_PATA_TRIFLEX=m
+CONFIG_PATA_MARVELL=m
+CONFIG_PATA_MPIIX=m
+CONFIG_PATA_OLDPIIX=m
+CONFIG_PATA_NETCELL=m
+CONFIG_PATA_NINJA32=m
+CONFIG_PATA_NS87410=m
+CONFIG_PATA_NS87415=m
+CONFIG_PATA_OPTI=m
+CONFIG_PATA_OPTIDMA=m
+CONFIG_PATA_PCMCIA=m
+CONFIG_PATA_PDC_OLD=m
+CONFIG_PATA_RADISYS=m
+CONFIG_PATA_RZ1000=m
+CONFIG_PATA_SC1200=m
+CONFIG_PATA_SERVERWORKS=m
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+CONFIG_PATA_VIA=m
+CONFIG_PATA_WINBOND=m
+CONFIG_PATA_SCH=m
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_DELAY=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_MAX_FC_SGE=256
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+# CONFIG_FUSION_LOGGING is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+# CONFIG_FIREWIRE is not set
+CONFIG_IEEE1394=m
+CONFIG_IEEE1394_OHCI1394=m
+CONFIG_IEEE1394_PCILYNX=m
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y
+CONFIG_IEEE1394_ETH1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_IEEE1394_VIDEO1394=m
+CONFIG_IEEE1394_DV1394=m
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+CONFIG_I2O=m
+CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_EXT_ADAPTEC_DMA64=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+# CONFIG_MACINTOSH_DRIVERS is not set
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+CONFIG_MACVLAN=m
+CONFIG_EQUALIZER=m
+CONFIG_TUN=m
+CONFIG_VETH=m
+# CONFIG_NET_SB1000 is not set
+CONFIG_ARCNET=m
+CONFIG_ARCNET_1201=m
+CONFIG_ARCNET_1051=m
+CONFIG_ARCNET_RAW=m
+CONFIG_ARCNET_CAP=m
+CONFIG_ARCNET_COM90xx=m
+CONFIG_ARCNET_COM90xxIO=m
+CONFIG_ARCNET_RIM_I=m
+# CONFIG_ARCNET_COM20020 is not set
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_BROADCOM_PHY=m
+CONFIG_ICPLUS_PHY=m
+CONFIG_REALTEK_PHY=m
+CONFIG_MDIO_BITBANG=m
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_ENC28J60=m
+# CONFIG_ENC28J60_WRITEVERIFY is not set
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+CONFIG_TULIP_NAPI=y
+CONFIG_TULIP_NAPI_HW_MITIGATION=y
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+CONFIG_HP100=m
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_B44=m
+CONFIG_B44_PCI_AUTOSELECT=y
+CONFIG_B44_PCICORE_AUTOSELECT=y
+CONFIG_B44_PCI=y
+CONFIG_FORCEDETH=m
+CONFIG_FORCEDETH_NAPI=y
+CONFIG_EEPRO100=m
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_R6040=m
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+# CONFIG_VIA_RHINE_MMIO is not set
+CONFIG_SC92031=m
+# CONFIG_NET_POCKET is not set
+CONFIG_ATL2=m
+CONFIG_NETDEV_1000=y
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IP1000=m
+CONFIG_IGB=m
+CONFIG_IGB_LRO=y
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+# CONFIG_SKGE_DEBUG is not set
+CONFIG_SKY2=m
+# CONFIG_SKY2_DEBUG is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+CONFIG_ATL1=m
+CONFIG_ATL1E=m
+CONFIG_NETDEV_10000=y
+CONFIG_CHELSIO_T1=m
+CONFIG_CHELSIO_T1_1G=y
+CONFIG_CHELSIO_T3=m
+CONFIG_IXGBE=m
+CONFIG_IXGBE_LRO=y
+CONFIG_IXGBE_DCB=y
+CONFIG_IXGB=m
+CONFIG_S2IO=m
+CONFIG_MYRI10GE=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_MLX4_CORE=m
+CONFIG_MLX4_DEBUG=y
+CONFIG_TEHUTI=m
+CONFIG_BNX2X=m
+CONFIG_SFC=m
+# CONFIG_SFC_RESOURCE is not set
+CONFIG_TR=y
+CONFIG_IBMOL=m
+CONFIG_3C359=m
+CONFIG_TMS380TR=m
+CONFIG_TMSPCI=m
+CONFIG_ABYSS=m
+
+#
+# Wireless LAN
+#
+CONFIG_WLAN_PRE80211=y
+CONFIG_STRIP=m
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+CONFIG_WLAN_80211=y
+CONFIG_PCMCIA_RAYCS=m
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_LIBERTAS=m
+CONFIG_LIBERTAS_USB=m
+CONFIG_LIBERTAS_CS=m
+CONFIG_LIBERTAS_SDIO=m
+# CONFIG_LIBERTAS_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_WL3501=m
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_USB_NET_RNDIS_WLAN=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_ADM8211=m
+CONFIG_MAC80211_HWSIM=m
+CONFIG_P54_COMMON=m
+CONFIG_P54_USB=m
+CONFIG_P54_PCI=m
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_ATH9K=m
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+CONFIG_IWLWIFI_LEDS=y
+CONFIG_IWLWIFI_RFKILL=y
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+CONFIG_IWLAGN_LEDS=y
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+CONFIG_IWL3945_RFKILL=y
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+CONFIG_IWL3945_LEDS=y
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_B43=m
+CONFIG_B43_PCI_AUTOSELECT=y
+CONFIG_B43_PCICORE_AUTOSELECT=y
+CONFIG_B43_PCMCIA=y
+CONFIG_B43_PIO=y
+CONFIG_B43_LEDS=y
+CONFIG_B43_RFKILL=y
+# CONFIG_B43_DEBUG is not set
+CONFIG_B43LEGACY=m
+CONFIG_B43LEGACY_PCI_AUTOSELECT=y
+CONFIG_B43LEGACY_PCICORE_AUTOSELECT=y
+CONFIG_B43LEGACY_LEDS=y
+CONFIG_B43LEGACY_RFKILL=y
+# CONFIG_B43LEGACY_DEBUG is not set
+CONFIG_B43LEGACY_DMA=y
+CONFIG_B43LEGACY_PIO=y
+CONFIG_B43LEGACY_DMA_AND_PIO_MODE=y
+# CONFIG_B43LEGACY_DMA_MODE is not set
+# CONFIG_B43LEGACY_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2X00_LIB_RFKILL=y
+CONFIG_RT2X00_LIB_LEDS=y
+CONFIG_RT2400PCI=m
+CONFIG_RT2400PCI_RFKILL=y
+CONFIG_RT2400PCI_LEDS=y
+CONFIG_RT2500PCI=m
+CONFIG_RT2500PCI_RFKILL=y
+CONFIG_RT2500PCI_LEDS=y
+CONFIG_RT61PCI=m
+CONFIG_RT61PCI_RFKILL=y
+CONFIG_RT61PCI_LEDS=y
+CONFIG_RT2500USB=m
+CONFIG_RT2500USB_LEDS=y
+CONFIG_RT73USB=m
+CONFIG_RT73USB_LEDS=y
+# CONFIG_RT2X00_LIB_DEBUGFS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_KC2190=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_HSO=m
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_WAN=y
+CONFIG_LANMEDIA=m
+CONFIG_HDLC=m
+CONFIG_HDLC_RAW=m
+CONFIG_HDLC_RAW_ETH=m
+CONFIG_HDLC_CISCO=m
+CONFIG_HDLC_FR=m
+CONFIG_HDLC_PPP=m
+CONFIG_HDLC_X25=m
+CONFIG_PCI200SYN=m
+CONFIG_WANXL=m
+# CONFIG_PC300 is not set
+CONFIG_PC300TOO=m
+CONFIG_FARSYNC=m
+# CONFIG_DSCC4 is not set
+CONFIG_DLCI=m
+CONFIG_DLCI_MAX=8
+# CONFIG_WAN_ROUTER_DRIVERS is not set
+CONFIG_LAPBETHER=m
+CONFIG_X25_ASY=m
+# CONFIG_SBNI is not set
+CONFIG_ATM_DRIVERS=y
+CONFIG_ATM_DUMMY=m
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+CONFIG_ATM_ENI_TUNE_BURST=y
+# CONFIG_ATM_ENI_BURST_TX_16W is not set
+CONFIG_ATM_ENI_BURST_TX_8W=y
+CONFIG_ATM_ENI_BURST_TX_4W=y
+CONFIG_ATM_ENI_BURST_TX_2W=y
+# CONFIG_ATM_ENI_BURST_RX_16W is not set
+# CONFIG_ATM_ENI_BURST_RX_8W is not set
+CONFIG_ATM_ENI_BURST_RX_4W=y
+CONFIG_ATM_ENI_BURST_RX_2W=y
+CONFIG_ATM_FIRESTREAM=m
+CONFIG_ATM_ZATM=m
+# CONFIG_ATM_ZATM_DEBUG is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+# CONFIG_ATM_IDT77252_RCV_ALL is not set
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_IA=m
+# CONFIG_ATM_IA_DEBUG is not set
+CONFIG_ATM_FORE200E=m
+CONFIG_ATM_FORE200E_USE_TASKLET=y
+CONFIG_ATM_FORE200E_TX_RETRY=16
+CONFIG_ATM_FORE200E_DEBUG=0
+CONFIG_ATM_HE=m
+CONFIG_ATM_HE_USE_SUNI=y
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+CONFIG_SKFP=m
+CONFIG_HIPPI=y
+CONFIG_ROADRUNNER=m
+CONFIG_ROADRUNNER_LARGE_RINGS=y
+CONFIG_PLIP=m
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_PPPOL2TP=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=m
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_NET_FC=y
+CONFIG_NETCONSOLE=m
+CONFIG_NETCONSOLE_DYNAMIC=y
+CONFIG_NETPOLL=y
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
+CONFIG_ISDN=y
+CONFIG_MISDN=m
+CONFIG_MISDN_DSP=m
+CONFIG_MISDN_L1OIP=m
+
+#
+# mISDN hardware drivers
+#
+CONFIG_MISDN_HFCPCI=m
+CONFIG_MISDN_HFCMULTI=m
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+CONFIG_ISDN_PPP_BSDCOMP=m
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+CONFIG_ISDN_X25=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+# CONFIG_HISAX_NO_SENDCOMPLETE is not set
+# CONFIG_HISAX_NO_LLC is not set
+# CONFIG_HISAX_NO_KEYPAD is not set
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+CONFIG_HISAX_DEBUG=y
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+CONFIG_HISAX_HFCUSB=m
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+CONFIG_HYSDN=m
+CONFIG_HYSDN_CAPI=y
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+CONFIG_GIGASET_M101=m
+# CONFIG_GIGASET_DEBUG is not set
+CONFIG_GIGASET_UNDOCREQ=y
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_CAPI_TRACE=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+# CONFIG_CAPI_EICON is not set
+CONFIG_PHONE=m
+CONFIG_PHONE_IXJ=m
+CONFIG_PHONE_IXJ_PCMCIA=m
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+CONFIG_INPUT_POLLDEV=m
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+CONFIG_KEYBOARD_SUNKBD=m
+# CONFIG_KEYBOARD_LKKBD is not set
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_KEYBOARD_NEWTON=m
+# CONFIG_KEYBOARD_STOWAWAY is not set
+CONFIG_KEYBOARD_GPIO=m
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_LIFEBOOK=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_APPLETOUCH=m
+CONFIG_MOUSE_BCM5974=m
+# CONFIG_MOUSE_VSXXXAA is not set
+CONFIG_MOUSE_GPIO=m
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_USB=y
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_ZHENHUA=m
+CONFIG_JOYSTICK_DB9=m
+CONFIG_JOYSTICK_GAMECON=m
+CONFIG_JOYSTICK_TURBOGRAFX=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+CONFIG_INPUT_TABLET=y
+CONFIG_TABLET_USB_ACECAD=m
+CONFIG_TABLET_USB_AIPTEK=m
+CONFIG_TABLET_USB_GTCO=m
+CONFIG_TABLET_USB_KBTAB=m
+CONFIG_TABLET_USB_WACOM=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ADS7846=m
+CONFIG_TOUCHSCREEN_FUJITSU=m
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_ELOUSB=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_INEXIO=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_TOUCHSCREEN_PENMOUNT=m
+CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
+CONFIG_TOUCHSCREEN_TOUCHWIN=m
+CONFIG_TOUCHSCREEN_UCB1400=m
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
+CONFIG_TOUCHSCREEN_USB_EGALAX=y
+CONFIG_TOUCHSCREEN_USB_PANJIT=y
+CONFIG_TOUCHSCREEN_USB_3M=y
+CONFIG_TOUCHSCREEN_USB_ITM=y
+CONFIG_TOUCHSCREEN_USB_ETURBO=y
+CONFIG_TOUCHSCREEN_USB_GUNZE=y
+CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y
+CONFIG_TOUCHSCREEN_USB_IRTOUCH=y
+CONFIG_TOUCHSCREEN_USB_IDEALTEK=y
+CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y
+CONFIG_TOUCHSCREEN_USB_GOTOP=y
+CONFIG_TOUCHSCREEN_TOUCHIT213=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_APANEL=m
+CONFIG_INPUT_ATLAS_BTNS=m
+CONFIG_INPUT_ATI_REMOTE=m
+CONFIG_INPUT_ATI_REMOTE2=m
+CONFIG_INPUT_KEYSPAN_REMOTE=m
+CONFIG_INPUT_POWERMATE=m
+CONFIG_INPUT_YEALINK=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_CT82C710=m
+CONFIG_SERIO_PARKBD=m
+CONFIG_SERIO_PCIPS2=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_DEVKMEM=y
+CONFIG_SERIAL_NONSTANDARD=y
+CONFIG_COMPUTONE=m
+CONFIG_ROCKETPORT=m
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+CONFIG_DIGIEPCA=m
+CONFIG_MOXA_INTELLIO=m
+CONFIG_MOXA_SMARTIO=m
+CONFIG_ISI=m
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+CONFIG_RISCOM8=m
+CONFIG_SPECIALIX=m
+CONFIG_SX=m
+CONFIG_RIO=m
+CONFIG_RIO_OLDPCI=y
+CONFIG_STALDRV=y
+CONFIG_NOZOMI=m
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_PNP=y
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=16
+CONFIG_SERIAL_8250_RUNTIME_UARTS=8
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=0
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+CONFIG_PPDEV=m
+CONFIG_HVC_DRIVER=y
+CONFIG_VIRTIO_CONSOLE=m
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+# CONFIG_IPMI_PANIC_STRING is not set
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_HW_RANDOM_VIRTIO=m
+CONFIG_NVRAM=y
+CONFIG_R3964=m
+CONFIG_APPLICOM=m
+
+#
+# PCMCIA character devices
+#
+CONFIG_SYNCLINK_CS=m
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+CONFIG_IPWIRELESS=m
+# CONFIG_MWAVE is not set
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=4096
+CONFIG_HPET=y
+CONFIG_HPET_MMAP=y
+CONFIG_HANGCHECK_TIMER=m
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
+CONFIG_DEVPORT=y
+CONFIG_CRASHER=m
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# PC SMBus host controller drivers
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_ISCH=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_NFORCE2=m
+CONFIG_I2C_NFORCE2_S4985=m
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+CONFIG_I2C_GPIO=m
+CONFIG_I2C_OCORES=m
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_TAOS_EVM=m
+CONFIG_I2C_TINY_USB=m
+
+#
+# Graphics adapter I2C/DDC channel drivers
+#
+CONFIG_I2C_VOODOO3=m
+
+#
+# Other I2C/SMBus bus drivers
+#
+CONFIG_I2C_PCA_PLATFORM=m
+CONFIG_I2C_STUB=m
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_DS1682=m
+CONFIG_AT24=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8591=m
+# CONFIG_TPS65010 is not set
+CONFIG_SENSORS_MAX6875=m
+CONFIG_SENSORS_TSL2550=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+CONFIG_SPI_DEBUG=y
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=m
+CONFIG_SPI_BUTTERFLY=m
+CONFIG_SPI_LM70_LLP=m
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_AT25=m
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_TLE62X0=m
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# I2C GPIO expanders:
+#
+CONFIG_GPIO_MAX732X=m
+CONFIG_GPIO_PCA953X=m
+CONFIG_GPIO_PCF857X=m
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+CONFIG_GPIO_MAX7301=m
+CONFIG_GPIO_MCP23S08=m
+CONFIG_W1=m
+CONFIG_W1_CON=y
+
+#
+# 1-wire Bus Masters
+#
+CONFIG_W1_MASTER_MATROX=m
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS2482=m
+CONFIG_W1_MASTER_GPIO=m
+
+#
+# 1-wire Slaves
+#
+CONFIG_W1_SLAVE_THERM=m
+CONFIG_W1_SLAVE_SMEM=m
+CONFIG_W1_SLAVE_DS2433=m
+CONFIG_W1_SLAVE_DS2433_CRC=y
+CONFIG_W1_SLAVE_DS2760=m
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+CONFIG_PDA_POWER=m
+CONFIG_BATTERY_DS2760=m
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ABITUGURU3=m
+CONFIG_SENSORS_AD7414=m
+CONFIG_SENSORS_AD7418=m
+CONFIG_SENSORS_ADCXX=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1029=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ADT7470=m
+CONFIG_SENSORS_ADT7473=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_I5K_AMB=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_F71882FG=m
+CONFIG_SENSORS_F75375S=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_FSCHMD=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_CORETEMP=m
+CONFIG_SENSORS_IBMAEM=m
+CONFIG_SENSORS_IBMPEX=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM70=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_MAX6650=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_PC87427=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_DME1737=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_ADS7828=m
+CONFIG_SENSORS_THMC50=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT1211=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83L786NG=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+CONFIG_SENSORS_APPLESMC=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+CONFIG_THERMAL=m
+CONFIG_THERMAL_HWMON=y
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+CONFIG_ACQUIRE_WDT=m
+CONFIG_ADVANTECH_WDT=m
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+CONFIG_SC520_WDT=m
+CONFIG_EUROTECH_WDT=m
+CONFIG_IB700_WDT=m
+CONFIG_IBMASR=m
+CONFIG_WAFER_WDT=m
+CONFIG_I6300ESB_WDT=m
+CONFIG_ITCO_WDT=m
+CONFIG_ITCO_VENDOR_SUPPORT=y
+CONFIG_IT8712F_WDT=m
+CONFIG_HP_WATCHDOG=m
+CONFIG_SC1200_WDT=m
+CONFIG_PC87413_WDT=m
+CONFIG_60XX_WDT=m
+CONFIG_SBC8360_WDT=m
+CONFIG_CPU5_WDT=m
+CONFIG_SMSC37B787_WDT=m
+CONFIG_W83627HF_WDT=m
+CONFIG_W83697HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+CONFIG_SBC_EPX_C3_WATCHDOG=m
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB_POSSIBLE=y
+CONFIG_SSB=m
+CONFIG_SSB_SPROM=y
+CONFIG_SSB_BLOCKIO=y
+CONFIG_SSB_PCIHOST_POSSIBLE=y
+CONFIG_SSB_PCIHOST=y
+CONFIG_SSB_B43_PCI_BRIDGE=y
+CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
+CONFIG_SSB_PCMCIAHOST=y
+# CONFIG_SSB_DEBUG is not set
+CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
+CONFIG_SSB_DRIVER_PCICORE=y
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+CONFIG_MFD_SM501=m
+CONFIG_MFD_SM501_GPIO=y
+CONFIG_HTC_PASIC3=m
+# CONFIG_MFD_TMIO is not set
+
+#
+# Multimedia devices
+#
+
+#
+# Multimedia core support
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_ALLOW_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_DVB_CORE=m
+CONFIG_VIDEO_MEDIA=m
+
+#
+# Multimedia drivers
+#
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_MEDIA_ATTACH=y
+CONFIG_MEDIA_TUNER=m
+# CONFIG_MEDIA_TUNER_CUSTOMIZE is not set
+CONFIG_MEDIA_TUNER_SIMPLE=m
+CONFIG_MEDIA_TUNER_TDA8290=m
+CONFIG_MEDIA_TUNER_TDA827X=m
+CONFIG_MEDIA_TUNER_TDA18271=m
+CONFIG_MEDIA_TUNER_TDA9887=m
+CONFIG_MEDIA_TUNER_TEA5761=m
+CONFIG_MEDIA_TUNER_TEA5767=m
+CONFIG_MEDIA_TUNER_MT20XX=m
+CONFIG_MEDIA_TUNER_MT2060=m
+CONFIG_MEDIA_TUNER_MT2266=m
+CONFIG_MEDIA_TUNER_MT2131=m
+CONFIG_MEDIA_TUNER_QT1010=m
+CONFIG_MEDIA_TUNER_XC2028=m
+CONFIG_MEDIA_TUNER_XC5000=m
+CONFIG_MEDIA_TUNER_MXL5005S=m
+CONFIG_MEDIA_TUNER_MXL5007T=m
+CONFIG_VIDEO_V4L2=m
+CONFIG_VIDEO_V4L1=m
+CONFIG_VIDEOBUF_GEN=m
+CONFIG_VIDEOBUF_DMA_SG=m
+CONFIG_VIDEOBUF_VMALLOC=m
+CONFIG_VIDEOBUF_DMA_CONTIG=m
+CONFIG_VIDEOBUF_DVB=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+CONFIG_VIDEO_IR_I2C=m
+CONFIG_VIDEO_TVAUDIO=m
+CONFIG_VIDEO_TDA7432=m
+CONFIG_VIDEO_TDA9840=m
+CONFIG_VIDEO_TDA9875=m
+CONFIG_VIDEO_TEA6415C=m
+CONFIG_VIDEO_TEA6420=m
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS5345=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_M52790=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_VP27SMPX=m
+CONFIG_VIDEO_BT819=m
+CONFIG_VIDEO_BT856=m
+CONFIG_VIDEO_KS0127=m
+CONFIG_VIDEO_OV7670=m
+CONFIG_VIDEO_SAA7110=m
+CONFIG_VIDEO_SAA7111=m
+CONFIG_VIDEO_SAA7114=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA717X=m
+CONFIG_VIDEO_TVP5150=m
+CONFIG_VIDEO_VPX3220=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_SAA7185=m
+CONFIG_VIDEO_ADV7170=m
+CONFIG_VIDEO_ADV7175=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+CONFIG_VIDEO_VIVI=m
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_BT848_DVB=y
+CONFIG_VIDEO_SAA6588=m
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+CONFIG_VIDEO_W9966=m
+CONFIG_VIDEO_CPIA=m
+CONFIG_VIDEO_CPIA_PP=m
+CONFIG_VIDEO_CPIA_USB=m
+CONFIG_VIDEO_CPIA2=m
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+# CONFIG_TUNER_3036 is not set
+CONFIG_VIDEO_STRADIS=m
+CONFIG_VIDEO_ZORAN=m
+CONFIG_VIDEO_ZORAN_DC30=m
+CONFIG_VIDEO_ZORAN_ZR36060=m
+CONFIG_VIDEO_ZORAN_BUZ=m
+CONFIG_VIDEO_ZORAN_DC10=m
+CONFIG_VIDEO_ZORAN_LML33=m
+CONFIG_VIDEO_ZORAN_LML33R10=m
+CONFIG_VIDEO_ZORAN_AVS6EYES=m
+CONFIG_VIDEO_MEYE=m
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_SAA7134_ALSA=m
+CONFIG_VIDEO_SAA7134_DVB=m
+CONFIG_VIDEO_MXB=m
+# CONFIG_VIDEO_DPC is not set
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_CX88_ALSA=m
+CONFIG_VIDEO_CX88_BLACKBIRD=m
+CONFIG_VIDEO_CX88_DVB=m
+CONFIG_VIDEO_CX88_VP3054=m
+CONFIG_VIDEO_CX23885=m
+CONFIG_VIDEO_AU0828=m
+CONFIG_VIDEO_IVTV=m
+CONFIG_VIDEO_FB_IVTV=m
+CONFIG_VIDEO_CX18=m
+CONFIG_VIDEO_CAFE_CCIC=m
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
+CONFIG_USB_GSPCA=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+CONFIG_VIDEO_PVRUSB2_DVB=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_EM28XX_ALSA=m
+CONFIG_VIDEO_EM28XX_DVB=m
+CONFIG_VIDEO_USBVISION=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+CONFIG_USB_ZR364XX=m
+CONFIG_USB_STKWEBCAM=m
+CONFIG_USB_S2255=m
+CONFIG_SOC_CAMERA=m
+CONFIG_SOC_CAMERA_MT9M001=m
+CONFIG_MT9M001_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_MT9V022=m
+CONFIG_MT9V022_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_PLATFORM=m
+CONFIG_VIDEO_SH_MOBILE_CEU=m
+CONFIG_RADIO_ADAPTERS=y
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+CONFIG_USB_DSBR=m
+CONFIG_USB_SI470X=m
+CONFIG_DVB_CAPTURE_DRIVERS=y
+
+#
+# Supported SAA7146 based PCI Adapters
+#
+CONFIG_TTPCI_EEPROM=m
+CONFIG_DVB_AV7110=m
+# CONFIG_DVB_AV7110_FIRMWARE is not set
+CONFIG_DVB_AV7110_OSD=y
+CONFIG_DVB_BUDGET_CORE=m
+CONFIG_DVB_BUDGET=m
+CONFIG_DVB_BUDGET_CI=m
+CONFIG_DVB_BUDGET_AV=m
+CONFIG_DVB_BUDGET_PATCH=m
+
+#
+# Supported USB Adapters
+#
+CONFIG_DVB_USB=m
+# CONFIG_DVB_USB_DEBUG is not set
+CONFIG_DVB_USB_A800=m
+CONFIG_DVB_USB_DIBUSB_MB=m
+# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
+CONFIG_DVB_USB_DIBUSB_MC=m
+CONFIG_DVB_USB_DIB0700=m
+CONFIG_DVB_USB_UMT_010=m
+CONFIG_DVB_USB_CXUSB=m
+CONFIG_DVB_USB_M920X=m
+CONFIG_DVB_USB_GL861=m
+CONFIG_DVB_USB_AU6610=m
+CONFIG_DVB_USB_DIGITV=m
+CONFIG_DVB_USB_VP7045=m
+CONFIG_DVB_USB_VP702X=m
+CONFIG_DVB_USB_GP8PSK=m
+CONFIG_DVB_USB_NOVA_T_USB2=m
+CONFIG_DVB_USB_TTUSB2=m
+CONFIG_DVB_USB_DTT200U=m
+CONFIG_DVB_USB_OPERA1=m
+CONFIG_DVB_USB_AF9005=m
+CONFIG_DVB_USB_AF9005_REMOTE=m
+CONFIG_DVB_USB_DW2102=m
+CONFIG_DVB_USB_ANYSEE=m
+CONFIG_DVB_TTUSB_BUDGET=m
+CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_CINERGYT2=m
+# CONFIG_DVB_CINERGYT2_TUNING is not set
+CONFIG_DVB_SIANO_SMS1XXX=m
+CONFIG_DVB_SIANO_SMS1XXX_SMS_IDS=y
+
+#
+# Supported FlexCopII (B2C2) Adapters
+#
+CONFIG_DVB_B2C2_FLEXCOP=m
+CONFIG_DVB_B2C2_FLEXCOP_PCI=m
+CONFIG_DVB_B2C2_FLEXCOP_USB=m
+# CONFIG_DVB_B2C2_FLEXCOP_DEBUG is not set
+
+#
+# Supported BT878 Adapters
+#
+CONFIG_DVB_BT8XX=m
+
+#
+# Supported Pluto2 Adapters
+#
+CONFIG_DVB_PLUTO2=m
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+# CONFIG_DVB_FE_CUSTOMISE is not set
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_CX24123=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_S5H1420=m
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_TDA10086=m
+CONFIG_DVB_VES1X93=m
+CONFIG_DVB_TUNER_ITD1000=m
+CONFIG_DVB_TDA826X=m
+CONFIG_DVB_TUA6100=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_DRX397XD=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_ZL10353=m
+CONFIG_DVB_DIB3000MB=m
+CONFIG_DVB_DIB3000MC=m
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+CONFIG_DVB_TDA10048=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_TDA10023=m
+CONFIG_DVB_STV0297=m
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+CONFIG_DVB_NXT200X=m
+CONFIG_DVB_OR51211=m
+CONFIG_DVB_OR51132=m
+CONFIG_DVB_BCM3510=m
+CONFIG_DVB_LGDT330X=m
+CONFIG_DVB_S5H1409=m
+CONFIG_DVB_AU8522=m
+CONFIG_DVB_S5H1411=m
+
+#
+# Digital terrestrial only tuners/PLL
+#
+CONFIG_DVB_PLL=m
+CONFIG_DVB_TUNER_DIB0070=m
+
+#
+# SEC control devices for DVB-S
+#
+CONFIG_DVB_LNBP21=m
+CONFIG_DVB_ISL6405=m
+CONFIG_DVB_ISL6421=m
+CONFIG_DAB=y
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+CONFIG_AGP=y
+CONFIG_AGP_AMD64=y
+CONFIG_AGP_INTEL=m
+CONFIG_AGP_SIS=m
+CONFIG_AGP_VIA=m
+CONFIG_DRM=m
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+# CONFIG_DRM_I830 is not set
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_DRM_VIA=m
+CONFIG_DRM_VIA_CHROME9=m
+CONFIG_DRM_SAVAGE=m
+CONFIG_VGASTATE=m
+CONFIG_VIDEO_OUTPUT_CONTROL=m
+CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+CONFIG_FB_DDC=m
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+CONFIG_FB_SYS_FILLRECT=m
+CONFIG_FB_SYS_COPYAREA=m
+CONFIG_FB_SYS_IMAGEBLIT=m
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+CONFIG_FB_SYS_FOPS=m
+CONFIG_FB_DEFERRED_IO=y
+CONFIG_FB_HECUBA=m
+CONFIG_FB_SVGALIB=m
+# CONFIG_FB_MACMODES is not set
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+
+#
+# Frame buffer hardware drivers
+#
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+CONFIG_FB_CYBER2000=m
+CONFIG_FB_ARC=m
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+CONFIG_FB_VGA16=m
+CONFIG_FB_UVESA=m
+CONFIG_FB_VESA=y
+CONFIG_FB_EFI=y
+CONFIG_FB_IMAC=y
+CONFIG_FB_N411=m
+CONFIG_FB_HGA=m
+CONFIG_FB_HGA_ACCEL=y
+CONFIG_FB_S1D13XXX=m
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+# CONFIG_FB_NVIDIA_DEBUG is not set
+CONFIG_FB_NVIDIA_BACKLIGHT=y
+CONFIG_FB_RIVA=m
+CONFIG_FB_RIVA_I2C=y
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_RIVA_BACKLIGHT=y
+CONFIG_FB_LE80578=m
+CONFIG_FB_CARILLO_RANCH=m
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+CONFIG_FB_INTEL_I2C=y
+CONFIG_FB_MATROX=m
+CONFIG_FB_MATROX_MILLENIUM=y
+CONFIG_FB_MATROX_MYSTIQUE=y
+CONFIG_FB_MATROX_G=y
+CONFIG_FB_MATROX_I2C=m
+CONFIG_FB_MATROX_MAVEN=m
+CONFIG_FB_MATROX_MULTIHEAD=y
+CONFIG_FB_RADEON=m
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+# CONFIG_FB_RADEON_DEBUG is not set
+CONFIG_FB_ATY128=m
+CONFIG_FB_ATY128_BACKLIGHT=y
+CONFIG_FB_ATY=m
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+# CONFIG_FB_S3 is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+CONFIG_FB_SIS=m
+CONFIG_FB_SIS_300=y
+CONFIG_FB_SIS_315=y
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+CONFIG_FB_VT8623=m
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+CONFIG_FB_ARK=m
+CONFIG_FB_PM3=m
+CONFIG_FB_CARMINE=m
+CONFIG_FB_CARMINE_DRAM_EVAL=y
+# CONFIG_CARMINE_DRAM_CUSTOM is not set
+CONFIG_FB_GEODE=y
+CONFIG_FB_GEODE_LX=m
+CONFIG_FB_GEODE_GX=m
+CONFIG_FB_GEODE_GX1=m
+CONFIG_FB_SM501=m
+CONFIG_FB_VIRTUAL=m
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_LTV350QV=m
+CONFIG_LCD_ILI9320=m
+CONFIG_LCD_VGG2432A4=m
+CONFIG_LCD_PLATFORM=m
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_CORGI=m
+CONFIG_BACKLIGHT_PROGEAR=m
+CONFIG_BACKLIGHT_CARILLO_RANCH=m
+CONFIG_BACKLIGHT_MBP_NVIDIA=m
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=m
+
+#
+# Display hardware drivers
+#
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+# CONFIG_LOGO is not set
+
+#
+# Bootsplash configuration
+#
+CONFIG_BOOTSPLASH=y
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_DEBUG=y
+# CONFIG_SND_DEBUG_VERBOSE is not set
+# CONFIG_SND_PCM_XRUN_DEBUG is not set
+CONFIG_SND_VMASTER=y
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DRIVERS=y
+# CONFIG_SND_PCSP is not set
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_MTS64=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+CONFIG_SND_PORTMAN2X4=m
+CONFIG_SND_AC97_POWER_SAVE=y
+CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0
+CONFIG_SND_SB_COMMON=m
+CONFIG_SND_PCI=y
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AW2=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_OXYGEN_LIB=m
+CONFIG_SND_OXYGEN=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+# CONFIG_SND_CS5530 is not set
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDA_HWDEP=y
+CONFIG_SND_HDA_INPUT_BEEP=y
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_CODEC_ANALOG=y
+CONFIG_SND_HDA_CODEC_SIGMATEL=y
+CONFIG_SND_HDA_CODEC_VIA=y
+CONFIG_SND_HDA_CODEC_ATIHDMI=y
+CONFIG_SND_HDA_CODEC_NVHDMI=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+CONFIG_SND_HDA_CODEC_CMEDIA=y
+CONFIG_SND_HDA_CODEC_SI3054=y
+CONFIG_SND_HDA_GENERIC=y
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_HIFIER=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VIRTUOSO=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+CONFIG_SND_SPI=y
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+CONFIG_SND_USB_CAIAQ=m
+CONFIG_SND_USB_CAIAQ_INPUT=y
+CONFIG_SND_PCMCIA=y
+CONFIG_SND_VXPOCKET=m
+CONFIG_SND_PDAUDIOCF=m
+# CONFIG_SND_SOC is not set
+CONFIG_SOUND_PRIME=m
+CONFIG_SOUND_OSS=m
+CONFIG_SOUND_TRACEINIT=y
+CONFIG_SOUND_DMAP=y
+CONFIG_SOUND_SSCAPE=m
+CONFIG_SOUND_VMIDI=m
+CONFIG_SOUND_TRIX=m
+CONFIG_SOUND_MSS=m
+CONFIG_SOUND_MPU401=m
+CONFIG_SOUND_PAS=m
+CONFIG_SOUND_PSS=m
+CONFIG_PSS_MIXER=y
+# CONFIG_PSS_HAVE_BOOT is not set
+# CONFIG_SOUND_SB is not set
+CONFIG_SOUND_YM3812=m
+CONFIG_SOUND_UART6850=m
+CONFIG_SOUND_AEDSP16=m
+CONFIG_SC6600=y
+CONFIG_SC6600_JOY=y
+CONFIG_SC6600_CDROM=4
+CONFIG_SC6600_CDROMBASE=0x0
+CONFIG_AEDSP16_MSS=y
+# CONFIG_AEDSP16_SBPRO is not set
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=m
+# CONFIG_HID_DEBUG is not set
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=m
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+# CONFIG_LOGIRUMBLEPAD2_FF is not set
+CONFIG_PANTHERLORD_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_ZEROPLUS_FF=y
+CONFIG_USB_HIDDEV=y
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_OTG is not set
+CONFIG_USB_MON=y
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_C67X00_HCD=m
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_ISP1760_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_HCD_SSB is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+# CONFIG_USB_U132_HCD is not set
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+CONFIG_USB_R8A66597_HCD=m
+
+#
+# Enable Host or Gadget support to see Inventra options
+#
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+CONFIG_USB_WDM=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+CONFIG_USB_STORAGE_ONETOUCH=y
+CONFIG_USB_STORAGE_KARMA=y
+CONFIG_USB_STORAGE_CYPRESS_ATACB=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+CONFIG_USB_SERIAL=m
+CONFIG_USB_EZUSB=y
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRCABLE=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_CH341=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_IUU=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_MOS7720=m
+CONFIG_USB_SERIAL_MOS7840=m
+CONFIG_USB_SERIAL_MOTOROLA=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_OTI6858=m
+CONFIG_USB_SERIAL_QUALCOMM=m
+CONFIG_USB_SERIAL_SPCP8X5=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_SERIAL_DEBUG=m
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_ADUTUX=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_BERRY_CHARGE=m
+CONFIG_USB_LED=m
+CONFIG_USB_CYPRESS_CY7C63=m
+CONFIG_USB_CYTHERM=m
+CONFIG_USB_PHIDGET=m
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETMOTORCONTROL=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_FTDI_ELAN=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TRANCEVIBRATOR=m
+CONFIG_USB_IOWARRIOR=m
+# CONFIG_USB_TEST is not set
+CONFIG_USB_ISIGHTFW=m
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+# CONFIG_USB_GADGET is not set
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD Card Drivers
+#
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK_BOUNCE=y
+CONFIG_SDIO_UART=m
+CONFIG_MMC_TEST=m
+
+#
+# MMC/SD Host Controller Drivers
+#
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_SDHCI_PCI=m
+CONFIG_MMC_RICOH_MMC=m
+CONFIG_MMC_WBSD=m
+CONFIG_MMC_TIFM_SD=m
+CONFIG_MMC_SPI=m
+CONFIG_MMC_SDRICOH_CS=m
+CONFIG_MEMSTICK=m
+# CONFIG_MEMSTICK_DEBUG is not set
+
+#
+# MemoryStick drivers
+#
+# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
+CONFIG_MSPRO_BLOCK=m
+
+#
+# MemoryStick Host Controller Drivers
+#
+CONFIG_MEMSTICK_TIFM_MS=m
+CONFIG_MEMSTICK_JMICRON_38X=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=m
+
+#
+# LED drivers
+#
+CONFIG_LEDS_PCA9532=m
+CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_CLEVO_MAIL=m
+CONFIG_LEDS_PCA955X=m
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_INFINIBAND=m
+CONFIG_INFINIBAND_USER_MAD=m
+CONFIG_INFINIBAND_USER_ACCESS=m
+CONFIG_INFINIBAND_USER_MEM=y
+CONFIG_INFINIBAND_ADDR_TRANS=y
+CONFIG_INFINIBAND_MTHCA=m
+CONFIG_INFINIBAND_MTHCA_DEBUG=y
+CONFIG_INFINIBAND_IPATH=m
+CONFIG_INFINIBAND_AMSO1100=m
+# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
+CONFIG_INFINIBAND_CXGB3=m
+# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
+CONFIG_MLX4_INFINIBAND=m
+CONFIG_INFINIBAND_NES=m
+# CONFIG_INFINIBAND_NES_DEBUG is not set
+CONFIG_INFINIBAND_IPOIB=m
+CONFIG_INFINIBAND_IPOIB_CM=y
+CONFIG_INFINIBAND_IPOIB_DEBUG=y
+# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
+CONFIG_INFINIBAND_SRP=m
+CONFIG_INFINIBAND_ISER=m
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I82975X=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_I5100=m
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_INTF_DEV_UIE_EMUL=y
+CONFIG_RTC_DRV_TEST=m
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1374=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_MAX6900=m
+CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_M41T80=m
+CONFIG_RTC_DRV_M41T80_WDT=y
+CONFIG_RTC_DRV_S35390A=m
+CONFIG_RTC_DRV_FM3130=m
+
+#
+# SPI RTC drivers
+#
+CONFIG_RTC_DRV_M41T94=m
+CONFIG_RTC_DRV_DS1305=m
+CONFIG_RTC_DRV_MAX6902=m
+CONFIG_RTC_DRV_R9701=m
+CONFIG_RTC_DRV_RS5C348=m
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=m
+CONFIG_RTC_DRV_DS1511=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_STK17TA8=m
+CONFIG_RTC_DRV_M48T86=m
+CONFIG_RTC_DRV_M48T59=m
+CONFIG_RTC_DRV_V3020=m
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+CONFIG_DMATEST=m
+CONFIG_DCA=m
+CONFIG_AUXDISPLAY=y
+# CONFIG_KS0108 is not set
+CONFIG_UIO=m
+CONFIG_UIO_CIF=m
+CONFIG_UIO_PDRV=m
+CONFIG_UIO_PDRV_GENIRQ=m
+CONFIG_UIO_SMX=m
+CONFIG_STAGING=y
+CONFIG_ET131X=m
+# CONFIG_ET131X_DEBUG is not set
+CONFIG_SLICOSS=m
+CONFIG_SXG=m
+CONFIG_ME4000=m
+CONFIG_VIDEO_GO7007=m
+CONFIG_VIDEO_GO7007_USB=m
+CONFIG_USB_IP_COMMON=m
+CONFIG_USB_IP_VHCI_HCD=m
+CONFIG_USB_IP_HOST=m
+CONFIG_W35UND=m
+CONFIG_PRISM2_USB=m
+CONFIG_ECHO=m
+CONFIG_USB_ATMEL=m
+CONFIG_AGNX=m
+CONFIG_OTUS=m
+CONFIG_RT2860=m
+CONFIG_RT2870=m
+CONFIG_RT3070=m
+CONFIG_BENET=m
+CONFIG_RTL8187SE=m
+CONFIG_DRM_PSB=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+# CONFIG_EDD_OFF is not set
+CONFIG_FIRMWARE_MEMMAP=y
+CONFIG_EFI_VARS=m
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_DMIID=y
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=m
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_NFS4ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+CONFIG_JBD_DEBUG=y
+CONFIG_JBD2=m
+CONFIG_JBD2_DEBUG=y
+CONFIG_FS_MBCACHE=m
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+CONFIG_JFS_FS=m
+CONFIG_JFS_POSIX_ACL=y
+CONFIG_JFS_SECURITY=y
+# CONFIG_JFS_DEBUG is not set
+CONFIG_JFS_STATISTICS=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_FS_NFS4ACL=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_DMAPI=m
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_XFS_RT=y
+# CONFIG_XFS_DEBUG is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+CONFIG_OCFS2_FS=m
+CONFIG_OCFS2_FS_O2CB=m
+CONFIG_OCFS2_FS_USERSPACE_CLUSTER=m
+CONFIG_OCFS2_FS_STATS=y
+# CONFIG_OCFS2_DEBUG_MASKLOG is not set
+# CONFIG_OCFS2_DEBUG_FS is not set
+# CONFIG_OCFS2_COMPAT_JBD is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_DMAPI=m
+# CONFIG_DMAPI_DEBUG is not set
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_PRINT_QUOTA_WARNING=y
+CONFIG_QUOTA_TREE=m
+CONFIG_QFMT_V1=m
+CONFIG_QFMT_V2=m
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+CONFIG_NTFS_RW=y
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+CONFIG_ADFS_FS=m
+# CONFIG_ADFS_FS_RW is not set
+CONFIG_AFFS_FS=m
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+CONFIG_BEFS_FS=m
+# CONFIG_BEFS_DEBUG is not set
+CONFIG_BFS_FS=m
+CONFIG_EFS_FS=m
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+CONFIG_JFFS2_SUMMARY=y
+CONFIG_JFFS2_FS_XATTR=y
+CONFIG_JFFS2_FS_POSIX_ACL=y
+CONFIG_JFFS2_FS_SECURITY=y
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+CONFIG_UBIFS_FS=m
+CONFIG_UBIFS_FS_XATTR=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_UBIFS_FS_DEBUG is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+CONFIG_VXFS_FS=m
+CONFIG_MINIX_FS=y
+CONFIG_OMFS_FS=m
+CONFIG_HPFS_FS=m
+CONFIG_QNX4FS_FS=m
+CONFIG_ROMFS_FS=m
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+CONFIG_UFS_FS_WRITE=y
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_SWAP=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_SUNRPC_XPRT_RDMA=m
+CONFIG_SUNRPC_SWAP=y
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+CONFIG_CIFS_STATS=y
+CONFIG_CIFS_STATS2=y
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_DFS_UPCALL=y
+CONFIG_NCP_FS=m
+CONFIG_NCPFS_PACKET_SIGNING=y
+CONFIG_NCPFS_IOCTL_LOCKING=y
+CONFIG_NCPFS_STRONG=y
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+CONFIG_NCPFS_SMALLDOS=y
+CONFIG_NCPFS_NLS=y
+CONFIG_NCPFS_EXTRAS=y
+CONFIG_CODA_FS=m
+CONFIG_AFS_FS=m
+# CONFIG_AFS_DEBUG is not set
+CONFIG_9P_FS=m
+CONFIG_NOVFS=m
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+# CONFIG_AMIGA_PARTITION is not set
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+# CONFIG_MINIX_SUBPARTITION is not set
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+# CONFIG_LDM_DEBUG is not set
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_SYSV68_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_DLM=m
+# CONFIG_DLM_DEBUG is not set
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+# CONFIG_DETECT_SOFTLOCKUP is not set
+CONFIG_SCHED_DEBUG=y
+CONFIG_SCHEDSTATS=y
+CONFIG_TIMER_STATS=y
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+CONFIG_DEBUG_MEMORY_INIT=y
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_FRAME_POINTER is not set
+CONFIG_UNWIND_INFO=y
+CONFIG_STACK_UNWIND=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+CONFIG_RCU_TORTURE_TEST=m
+# CONFIG_KPROBES_SANITY_TEST is not set
+CONFIG_BACKTRACE_SELF_TEST=m
+CONFIG_LKDTM=m
+# CONFIG_FAULT_INJECTION is not set
+CONFIG_LATENCYTOP=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+CONFIG_HAVE_FTRACE=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+# CONFIG_FTRACE is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SYSPROF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+CONFIG_PROVIDE_OHCI1394_DMA_INIT=y
+CONFIG_DYNAMIC_PRINTK_DEBUG=y
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_STRICT_DEVMEM is not set
+# CONFIG_X86_VERBOSE_BOOTUP is not set
+CONFIG_EARLY_PRINTK=y
+CONFIG_EARLY_PRINTK_DBGP=y
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_DEBUG_PER_CPU_MAPS is not set
+# CONFIG_X86_PTDUMP is not set
+CONFIG_DEBUG_RODATA=y
+# CONFIG_DEBUG_RODATA_TEST is not set
+# CONFIG_DEBUG_NX_TEST is not set
+# CONFIG_IOMMU_DEBUG is not set
+# CONFIG_MMIOTRACE is not set
+CONFIG_IO_DELAY_TYPE_0X80=0
+CONFIG_IO_DELAY_TYPE_0XED=1
+CONFIG_IO_DELAY_TYPE_UDELAY=2
+CONFIG_IO_DELAY_TYPE_NONE=3
+CONFIG_IO_DELAY_0X80=y
+# CONFIG_IO_DELAY_0XED is not set
+# CONFIG_IO_DELAY_UDELAY is not set
+# CONFIG_IO_DELAY_NONE is not set
+CONFIG_DEFAULT_IO_DELAY_TYPE=0
+# CONFIG_DEBUG_BOOT_PARAMS is not set
+# CONFIG_CPA_DEBUG is not set
+# CONFIG_OPTIMIZE_INLINING is not set
+CONFIG_KDB=y
+CONFIG_KDB_MODULES=m
+CONFIG_KDB_OFF=y
+CONFIG_KDB_CONTINUE_CATASTROPHIC=0
+CONFIG_KDB_USB=y
+CONFIG_KDB_KDUMP=y
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_DEFAULT="apparmor"
+CONFIG_SECURITY_NETWORK=y
+# CONFIG_SECURITY_NETWORK_XFRM is not set
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+CONFIG_SECURITY_APPARMOR=y
+CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_APPARMOR_DISABLE=y
+CONFIG_XOR_BLOCKS=m
+CONFIG_ASYNC_CORE=m
+CONFIG_ASYNC_MEMCPY=m
+CONFIG_ASYNC_XOR=m
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Authenticated Encryption with Associated Data
+#
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_SEQIV=m
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_XTS=m
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_XCBC=m
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_RMD128=m
+CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_RMD256=m
+CONFIG_CRYPTO_RMD320=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_X86_64=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_SALSA20=m
+CONFIG_CRYPTO_SALSA20_X86_64=m
+CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TEA=m
+# CONFIG_CRYPTO_TWOFISH is not set
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_TWOFISH_X86_64=m
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_DEV_HIFN_795X=m
+CONFIG_CRYPTO_DEV_HIFN_795X_RNG=y
+CONFIG_HAVE_KVM=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM_KMP=y
+# CONFIG_KVM is not set
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
+CONFIG_VIRTIO_BALLOON=m
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_FIRST_BIT=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_T10DIF=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_CHECK_SIGNATURE=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-x86_64.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-x86_64.config
new file mode 100644
index 0000000..69bca9a
--- /dev/null
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.27-2.6-sles11-x86_64.config
@@ -0,0 +1,4143 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.27.21
+# Wed May 13 22:02:04 2009
+#
+CONFIG_64BIT=y
+# CONFIG_X86_32 is not set
+CONFIG_X86_64=y
+CONFIG_X86=y
+CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
+# CONFIG_GENERIC_LOCKBREAK is not set
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_CLOCKSOURCE_WATCHDOG=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_FAST_CMPXCHG_LOCAL=y
+CONFIG_MMU=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_GENERIC_IOMAP=y
+CONFIG_GENERIC_BUG=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_GPIO=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_ARCH_HAS_CPU_RELAX=y
+CONFIG_ARCH_HAS_DEFAULT_IDLE=y
+CONFIG_ARCH_HAS_CACHE_LINE_SIZE=y
+CONFIG_HAVE_SETUP_PER_CPU_AREA=y
+CONFIG_HAVE_CPUMASK_OF_CPU_MAP=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+CONFIG_ZONE_DMA32=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_AUDIT_ARCH=y
+CONFIG_ARCH_SUPPORTS_AOUT=y
+CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_GENERIC_IRQ_PROBE=y
+CONFIG_GENERIC_PENDING_IRQ=y
+CONFIG_X86_SMP=y
+CONFIG_X86_64_SMP=y
+CONFIG_X86_HT=y
+CONFIG_X86_BIOS_REBOOT=y
+CONFIG_X86_TRAMPOLINE=y
+# CONFIG_KTIME_SCALAR is not set
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_LOCK_KERNEL=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION="-0.1-default"
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SUSE_KERNEL=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_TREE=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=18
+CONFIG_CGROUPS=y
+# CONFIG_CGROUP_DEBUG is not set
+CONFIG_CGROUP_NS=y
+CONFIG_CGROUP_FREEZER=y
+CONFIG_CGROUP_DEVICE=y
+CONFIG_CPUSETS=y
+CONFIG_HAVE_UNSTABLE_SCHED_CLOCK=y
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+# CONFIG_RT_GROUP_SCHED is not set
+# CONFIG_USER_SCHED is not set
+CONFIG_CGROUP_SCHED=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_RESOURCE_COUNTERS=y
+CONFIG_MM_OWNER=y
+CONFIG_CGROUP_MEM_RES_CTLR=y
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_PROC_PID_CPUSET=y
+CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_IPC_NS=y
+CONFIG_USER_NS=y
+CONFIG_PID_NS=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_PCSPKR_PLATFORM=y
+CONFIG_COMPAT_BRK=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLAB=y
+# CONFIG_SLUB is not set
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+# CONFIG_TRACEPOINTS is not set
+CONFIG_MARKERS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
+CONFIG_KRETPROBES=y
+CONFIG_HAVE_IOREMAP_PROT=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_ARCH_TRACEHOOK=y
+# CONFIG_HAVE_DMA_ATTRS is not set
+CONFIG_USE_GENERIC_SMP_HELPERS=y
+# CONFIG_HAVE_CLK is not set
+CONFIG_PROC_PAGE_MONITOR=y
+# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
+# CONFIG_UTRACE is not set
+CONFIG_BLOCK=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLK_DEV_INTEGRITY=y
+CONFIG_BLOCK_COMPAT=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="deadline"
+CONFIG_PREEMPT_NOTIFIERS=y
+CONFIG_CLASSIC_RCU=y
+CONFIG_FREEZER=y
+
+#
+# Processor type and features
+#
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+CONFIG_SMP=y
+CONFIG_X86_FIND_SMP_CONFIG=y
+CONFIG_X86_MPPARSE=y
+CONFIG_X86_PC=y
+# CONFIG_X86_XEN is not set
+# CONFIG_X86_ELAN is not set
+# CONFIG_X86_VOYAGER is not set
+# CONFIG_X86_GENERICARCH is not set
+# CONFIG_X86_64_XEN is not set
+# CONFIG_X86_VSMP is not set
+# CONFIG_PARAVIRT_GUEST is not set
+CONFIG_MEMTEST=y
+# CONFIG_M386 is not set
+# CONFIG_M486 is not set
+# CONFIG_M586 is not set
+# CONFIG_M586TSC is not set
+# CONFIG_M586MMX is not set
+# CONFIG_M686 is not set
+# CONFIG_MPENTIUMII is not set
+# CONFIG_MPENTIUMIII is not set
+# CONFIG_MPENTIUMM is not set
+# CONFIG_MPENTIUM4 is not set
+# CONFIG_MK6 is not set
+# CONFIG_MK7 is not set
+# CONFIG_MK8 is not set
+# CONFIG_MCRUSOE is not set
+# CONFIG_MEFFICEON is not set
+# CONFIG_MWINCHIPC6 is not set
+# CONFIG_MWINCHIP2 is not set
+# CONFIG_MWINCHIP3D is not set
+# CONFIG_MGEODEGX1 is not set
+# CONFIG_MGEODE_LX is not set
+# CONFIG_MCYRIXIII is not set
+# CONFIG_MVIAC3_2 is not set
+# CONFIG_MVIAC7 is not set
+# CONFIG_MPSC is not set
+# CONFIG_MCORE2 is not set
+CONFIG_GENERIC_CPU=y
+CONFIG_X86_CPU=y
+CONFIG_X86_L1_CACHE_BYTES=128
+CONFIG_X86_INTERNODE_CACHE_BYTES=128
+CONFIG_X86_CMPXCHG=y
+CONFIG_X86_L1_CACHE_SHIFT=7
+CONFIG_X86_WP_WORKS_OK=y
+CONFIG_X86_TSC=y
+CONFIG_X86_CMPXCHG64=y
+CONFIG_X86_CMOV=y
+CONFIG_X86_MINIMUM_CPU_FAMILY=64
+CONFIG_X86_DEBUGCTLMSR=y
+CONFIG_HPET_TIMER=y
+CONFIG_HPET_EMULATE_RTC=y
+CONFIG_DMI=y
+CONFIG_GART_IOMMU=y
+CONFIG_CALGARY_IOMMU=y
+# CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT is not set
+CONFIG_AMD_IOMMU=y
+CONFIG_SWIOTLB=y
+CONFIG_IOMMU_HELPER=y
+CONFIG_MAXSMP=y
+CONFIG_NR_CPUS=512
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+# CONFIG_X86_REROUTE_FOR_BROKEN_BOOT_IRQS is not set
+CONFIG_X86_LOCAL_APIC=y
+CONFIG_X86_IO_APIC=y
+CONFIG_X86_MCE=y
+CONFIG_X86_MCE_INTEL=y
+CONFIG_X86_MCE_AMD=y
+CONFIG_I8K=m
+CONFIG_MICROCODE=m
+CONFIG_MICROCODE_OLD_INTERFACE=y
+CONFIG_X86_MSR=m
+CONFIG_X86_CPUID=m
+CONFIG_DIRECT_GBPAGES=y
+CONFIG_NUMA=y
+CONFIG_K8_NUMA=y
+CONFIG_X86_64_ACPI_NUMA=y
+CONFIG_NODES_SPAN_OTHER_NODES=y
+CONFIG_NUMA_EMU=y
+CONFIG_NODES_SHIFT=9
+CONFIG_ARCH_SPARSEMEM_DEFAULT=y
+CONFIG_ARCH_SPARSEMEM_ENABLE=y
+CONFIG_ARCH_SELECT_MEMORY_MODEL=y
+CONFIG_ARCH_MEMORY_PROBE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+# CONFIG_FLATMEM_MANUAL is not set
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+CONFIG_SPARSEMEM_MANUAL=y
+CONFIG_SPARSEMEM=y
+CONFIG_NEED_MULTIPLE_NODES=y
+CONFIG_HAVE_MEMORY_PRESENT=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPARSEMEM_EXTREME=y
+CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
+CONFIG_SPARSEMEM_VMEMMAP=y
+CONFIG_MEMORY_HOTPLUG=y
+CONFIG_MEMORY_HOTPLUG_SPARSE=y
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_MIGRATION=y
+CONFIG_RESOURCES_64BIT=y
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_MMU_NOTIFIER=y
+CONFIG_X86_RESERVE_LOW_64K=y
+CONFIG_MTRR=y
+# CONFIG_MTRR_SANITIZER is not set
+CONFIG_X86_PAT=y
+CONFIG_EFI=y
+CONFIG_SECCOMP=y
+# CONFIG_SECCOMP_DISABLE_TSC is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_300 is not set
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_SCHED_HRTICK=y
+CONFIG_KEXEC=y
+CONFIG_CRASH_DUMP=y
+CONFIG_PHYSICAL_START=0x200000
+CONFIG_RELOCATABLE=y
+CONFIG_PHYSICAL_ALIGN=0x200000
+CONFIG_HOTPLUG_CPU=y
+CONFIG_COMPAT_VDSO=y
+
+#
+# Hardware Performance Monitoring support
+#
+CONFIG_PERFMON=y
+# CONFIG_PERFMON_DEBUG is not set
+CONFIG_PERFMON_DEBUG_FS=y
+CONFIG_X86_PERFMON_P4=m
+CONFIG_X86_PERFMON_PEBS_P4=m
+CONFIG_X86_PERFMON_CORE=m
+CONFIG_X86_PERFMON_PEBS_CORE=m
+CONFIG_X86_PERFMON_INTEL_ATOM=m
+CONFIG_X86_PERFMON_INTEL_ARCH=m
+CONFIG_X86_PERFMON_AMD64=m
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
+
+#
+# Power management options
+#
+CONFIG_ARCH_HIBERNATION_HEADER=y
+CONFIG_PM=y
+# CONFIG_PM_DEBUG is not set
+CONFIG_PM_SLEEP_SMP=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION=""
+CONFIG_ACPI=y
+CONFIG_ACPI_SLEEP=y
+CONFIG_ACPI_PROCFS=y
+CONFIG_ACPI_PROCFS_POWER=y
+CONFIG_ACPI_SYSFS_POWER=y
+CONFIG_ACPI_PROC_EVENT=y
+CONFIG_ACPI_AC=m
+CONFIG_ACPI_BATTERY=m
+CONFIG_ACPI_BUTTON=m
+CONFIG_ACPI_VIDEO=m
+CONFIG_ACPI_FAN=m
+CONFIG_ACPI_DOCK=m
+CONFIG_ACPI_PROCESSOR=m
+CONFIG_ACPI_HOTPLUG_CPU=y
+CONFIG_ACPI_THERMAL=m
+CONFIG_ACPI_NUMA=y
+CONFIG_ACPI_WMI=m
+# CONFIG_ACPI_ASUS is not set
+CONFIG_ACPI_TOSHIBA=m
+CONFIG_ACPI_CUSTOM_DSDT_FILE=""
+# CONFIG_ACPI_CUSTOM_DSDT is not set
+CONFIG_ACPI_CUSTOM_DSDT_INITRD=y
+CONFIG_ACPI_BLACKLIST_YEAR=0
+CONFIG_ACPI_DEBUG=y
+# CONFIG_ACPI_DEBUG_FUNC_TRACE is not set
+CONFIG_ACPI_EC=y
+CONFIG_ACPI_PCI_SLOT=m
+CONFIG_ACPI_POWER=y
+CONFIG_ACPI_SYSTEM=y
+CONFIG_X86_PM_TIMER=y
+CONFIG_ACPI_CONTAINER=m
+CONFIG_ACPI_HOTPLUG_MEMORY=m
+CONFIG_ACPI_SBS=m
+
+#
+# CPU Frequency scaling
+#
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+# CONFIG_CPU_FREQ_DEBUG is not set
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=m
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPUFreq processor drivers
+#
+CONFIG_X86_ACPI_CPUFREQ=m
+CONFIG_X86_POWERNOW_K8=m
+CONFIG_X86_POWERNOW_K8_ACPI=y
+# CONFIG_X86_SPEEDSTEP_CENTRINO is not set
+# CONFIG_X86_P4_CLOCKMOD is not set
+
+#
+# shared options
+#
+# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
+# CONFIG_X86_SPEEDSTEP_LIB is not set
+CONFIG_CPU_IDLE=y
+CONFIG_CPU_IDLE_GOV_LADDER=y
+CONFIG_CPU_IDLE_GOV_MENU=y
+
+#
+# Bus options (PCI etc.)
+#
+CONFIG_PCI=y
+CONFIG_PCI_DIRECT=y
+CONFIG_PCI_MMCONFIG=y
+CONFIG_PCI_DOMAINS=y
+# CONFIG_DMAR is not set
+CONFIG_INTR_REMAP=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_HOTPLUG_PCI_PCIE=m
+CONFIG_PCIEAER=y
+CONFIG_PCIEASPM=y
+# CONFIG_PCIEASPM_DEBUG is not set
+CONFIG_ARCH_SUPPORTS_MSI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_HT_IRQ=y
+CONFIG_ISA_DMA_API=y
+CONFIG_K8_NB=y
+CONFIG_PCCARD=m
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=m
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=m
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+CONFIG_I82092=m
+CONFIG_PCCARD_NONSTATIC=m
+CONFIG_HOTPLUG_PCI=m
+CONFIG_HOTPLUG_PCI_FAKE=m
+CONFIG_HOTPLUG_PCI_ACPI=m
+CONFIG_HOTPLUG_PCI_ACPI_IBM=m
+CONFIG_HOTPLUG_PCI_CPCI=y
+CONFIG_HOTPLUG_PCI_CPCI_ZT5550=m
+CONFIG_HOTPLUG_PCI_CPCI_GENERIC=m
+CONFIG_HOTPLUG_PCI_SHPC=m
+
+#
+# Executable file formats / Emulations
+#
+CONFIG_BINFMT_ELF=y
+CONFIG_COMPAT_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=m
+CONFIG_IA32_EMULATION=y
+CONFIG_IA32_AOUT=y
+CONFIG_COMPAT=y
+CONFIG_COMPAT_FOR_U64_ALIGNMENT=y
+CONFIG_SYSVIPC_COMPAT=y
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=m
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=m
+CONFIG_XFRM_SUB_POLICY=y
+CONFIG_XFRM_MIGRATE=y
+# CONFIG_XFRM_STATISTICS is not set
+CONFIG_XFRM_IPCOMP=m
+CONFIG_NET_KEY=m
+CONFIG_NET_KEY_MIGRATE=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=m
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_TCP_CONG_YEAH=m
+CONFIG_TCP_CONG_ILLINOIS=m
+# CONFIG_DEFAULT_BIC is not set
+CONFIG_DEFAULT_CUBIC=y
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+# CONFIG_DEFAULT_RENO is not set
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
+CONFIG_IP_VS=m
+# CONFIG_IP_VS_DEBUG is not set
+CONFIG_IP_VS_TAB_BITS=12
+
+#
+# IPVS transport protocol load balancing support
+#
+CONFIG_IP_VS_PROTO_TCP=y
+CONFIG_IP_VS_PROTO_UDP=y
+CONFIG_IP_VS_PROTO_ESP=y
+CONFIG_IP_VS_PROTO_AH=y
+
+#
+# IPVS scheduler
+#
+CONFIG_IP_VS_RR=m
+CONFIG_IP_VS_WRR=m
+CONFIG_IP_VS_LC=m
+CONFIG_IP_VS_WLC=m
+CONFIG_IP_VS_LBLC=m
+CONFIG_IP_VS_LBLCR=m
+CONFIG_IP_VS_DH=m
+CONFIG_IP_VS_SH=m
+CONFIG_IP_VS_SED=m
+CONFIG_IP_VS_NQ=m
+
+#
+# IPVS application helper
+#
+CONFIG_IP_VS_FTP=m
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+# CONFIG_IPV6_OPTIMISTIC_DAD is not set
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_IPV6_MIP6=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_NDISC_NODETYPE=y
+CONFIG_IPV6_TUNNEL=m
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+# CONFIG_IPV6_MROUTE is not set
+# CONFIG_NETLABEL is not set
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CT_ACCT=y
+CONFIG_NF_CONNTRACK_MARK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CT_PROTO_DCCP=m
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=m
+CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CONNTRACK_AMANDA=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_NETBIOS_NS=m
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SANE=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
+CONFIG_NF_CONNTRACK_SLP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_DSCP=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_RATEEST=m
+CONFIG_NETFILTER_XT_TARGET_TRACE=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_DSCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_OWNER=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_RATEEST=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_TIME=m
+CONFIG_NETFILTER_XT_MATCH_U32=m
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV4=m
+# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_MATCH_IPV4OPTIONS=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_NF_NAT_SNMP_BASIC=m
+CONFIG_NF_NAT_PROTO_DCCP=m
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_PROTO_UDPLITE=m
+CONFIG_NF_NAT_PROTO_SCTP=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_TFTP=m
+CONFIG_NF_NAT_AMANDA=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_SECURITY=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_MH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+CONFIG_IP6_NF_SECURITY=m
+
+#
+# DECnet: Netfilter Configuration
+#
+# CONFIG_DECNET_NF_GRABULATOR is not set
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_IP6=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+CONFIG_BRIDGE_EBT_NFLOG=m
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+# CONFIG_IP_DCCP_CCID2_DEBUG is not set
+CONFIG_IP_DCCP_CCID3=m
+# CONFIG_IP_DCCP_CCID3_DEBUG is not set
+CONFIG_IP_DCCP_CCID3_RTO=100
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+# CONFIG_NET_DCCPPROBE is not set
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+# CONFIG_TIPC is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+# CONFIG_ATM_CLIP_NO_ICMP is not set
+CONFIG_ATM_LANE=m
+CONFIG_ATM_MPOA=m
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_STP=m
+CONFIG_GARP=m
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+CONFIG_VLAN_8021Q_GVRP=y
+CONFIG_DECNET=m
+# CONFIG_DECNET_ROUTER is not set
+CONFIG_LLC=y
+CONFIG_LLC2=m
+CONFIG_IPX=m
+CONFIG_IPX_INTERN=y
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=m
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+CONFIG_X25=m
+CONFIG_LAPB=m
+CONFIG_ECONET=m
+# CONFIG_ECONET_AUNUDP is not set
+# CONFIG_ECONET_NATIVE is not set
+CONFIG_WAN_ROUTER=m
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_MULTIQ=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_CLS_FLOW=m
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+CONFIG_NET_EMATCH_CMP=m
+CONFIG_NET_EMATCH_NBYTE=m
+CONFIG_NET_EMATCH_U32=m
+CONFIG_NET_EMATCH_META=m
+CONFIG_NET_EMATCH_TEXT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_NAT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_ACT_SKBEDIT=m
+# CONFIG_NET_CLS_IND is not set
+CONFIG_NET_SCH_FIFO=y
+CONFIG_DCB=m
+CONFIG_DCBNL=y
+
+#
+# Network testing
+#
+CONFIG_NET_PKTGEN=m
+CONFIG_NET_TCPPROBE=m
+CONFIG_HAMRADIO=y
+
+#
+# Packet Radio protocols
+#
+CONFIG_AX25=m
+CONFIG_AX25_DAMA_SLAVE=y
+CONFIG_NETROM=m
+CONFIG_ROSE=m
+
+#
+# AX.25 network device drivers
+#
+CONFIG_MKISS=m
+CONFIG_6PACK=m
+CONFIG_BPQETHER=m
+CONFIG_BAYCOM_SER_FDX=m
+CONFIG_BAYCOM_SER_HDX=m
+CONFIG_BAYCOM_PAR=m
+CONFIG_YAM=m
+CONFIG_CAN=m
+CONFIG_CAN_RAW=m
+CONFIG_CAN_BCM=m
+
+#
+# CAN Device Drivers
+#
+CONFIG_CAN_VCAN=m
+# CONFIG_CAN_DEBUG_DEVICES is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+CONFIG_IRDA_ULTRA=y
+
+#
+# IrDA options
+#
+CONFIG_IRDA_CACHE_LAST_LSAP=y
+# CONFIG_IRDA_FAST_RR is not set
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+CONFIG_DONGLE=y
+CONFIG_ESI_DONGLE=m
+CONFIG_ACTISYS_DONGLE=m
+CONFIG_TEKRAM_DONGLE=m
+CONFIG_TOIM3232_DONGLE=m
+CONFIG_LITELINK_DONGLE=m
+CONFIG_MA600_DONGLE=m
+CONFIG_GIRBIL_DONGLE=m
+CONFIG_MCP2120_DONGLE=m
+CONFIG_OLD_BELKIN_DONGLE=m
+CONFIG_ACT200L_DONGLE=m
+CONFIG_KINGSUN_DONGLE=m
+CONFIG_KSDAZZLE_DONGLE=m
+CONFIG_KS959_DONGLE=m
+
+#
+# FIR device drivers
+#
+CONFIG_USB_IRDA=m
+CONFIG_SIGMATEL_FIR=m
+CONFIG_NSC_FIR=m
+CONFIG_WINBOND_FIR=m
+CONFIG_SMC_IRCC_FIR=m
+CONFIG_ALI_FIR=m
+CONFIG_VLSI_FIR=m
+CONFIG_VIA_FIR=m
+CONFIG_MCS_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_CMTP=m
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIBTUSB=m
+CONFIG_BT_HCIBTSDIO=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+CONFIG_AF_RXRPC=m
+# CONFIG_AF_RXRPC_DEBUG is not set
+CONFIG_RXKAD=m
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+CONFIG_MAC80211=m
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_PID=y
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_MESH=y
+CONFIG_MAC80211_LEDS=y
+CONFIG_MAC80211_DEBUGFS=y
+# CONFIG_MAC80211_DEBUG_MENU is not set
+CONFIG_IEEE80211=m
+# CONFIG_IEEE80211_DEBUG is not set
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+CONFIG_RFKILL=m
+CONFIG_RFKILL_INPUT=m
+CONFIG_RFKILL_LEDS=y
+CONFIG_NET_9P=m
+CONFIG_NET_9P_VIRTIO=m
+# CONFIG_NET_9P_DEBUG is not set
+CONFIG_NETVM=y
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH=""
+# CONFIG_STANDALONE is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+CONFIG_FIRMWARE_IN_KERNEL=y
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+CONFIG_MTD=m
+# CONFIG_MTD_DEBUG is not set
+CONFIG_MTD_CONCAT=m
+CONFIG_MTD_PARTITIONS=y
+CONFIG_MTD_REDBOOT_PARTS=m
+CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
+CONFIG_MTD_AR7_PARTS=m
+
+#
+# User Modules And Translation Layers
+#
+CONFIG_MTD_CHAR=m
+CONFIG_MTD_BLKDEVS=m
+CONFIG_MTD_BLOCK=m
+# CONFIG_MTD_BLOCK_RO is not set
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+CONFIG_RFD_FTL=m
+# CONFIG_SSFDC is not set
+CONFIG_MTD_OOPS=m
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=m
+CONFIG_MTD_JEDECPROBE=m
+CONFIG_MTD_GEN_PROBE=m
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
+CONFIG_MTD_CFI_INTELEXT=m
+CONFIG_MTD_CFI_AMDSTD=m
+CONFIG_MTD_CFI_STAA=m
+CONFIG_MTD_CFI_UTIL=m
+# CONFIG_MTD_RAM is not set
+# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ABSENT=m
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_COMPLEX_MAPPINGS=y
+CONFIG_MTD_PHYSMAP=m
+CONFIG_MTD_PHYSMAP_START=0x8000000
+CONFIG_MTD_PHYSMAP_LEN=0x4000000
+CONFIG_MTD_PHYSMAP_BANKWIDTH=2
+# CONFIG_MTD_SC520CDP is not set
+# CONFIG_MTD_NETSC520 is not set
+CONFIG_MTD_TS5500=m
+# CONFIG_MTD_SBC_GXX is not set
+CONFIG_MTD_AMD76XROM=m
+CONFIG_MTD_ICHXROM=m
+CONFIG_MTD_ESB2ROM=m
+CONFIG_MTD_CK804XROM=m
+CONFIG_MTD_SCB2_FLASH=m
+# CONFIG_MTD_NETtel is not set
+# CONFIG_MTD_DILNETPC is not set
+# CONFIG_MTD_L440GX is not set
+CONFIG_MTD_PCI=m
+CONFIG_MTD_INTEL_VR_NOR=m
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+CONFIG_MTD_PMC551=m
+CONFIG_MTD_PMC551_BUGFIX=y
+# CONFIG_MTD_PMC551_DEBUG is not set
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
+CONFIG_MTD_SLRAM=m
+CONFIG_MTD_PHRAM=m
+CONFIG_MTD_MTDRAM=m
+CONFIG_MTDRAM_TOTAL_SIZE=4096
+CONFIG_MTDRAM_ERASE_SIZE=128
+CONFIG_MTD_BLOCK2MTD=m
+
+#
+# Disk-On-Chip Device Drivers
+#
+CONFIG_MTD_DOC2000=m
+CONFIG_MTD_DOC2001=m
+CONFIG_MTD_DOC2001PLUS=m
+CONFIG_MTD_DOCPROBE=m
+CONFIG_MTD_DOCECC=m
+CONFIG_MTD_DOCPROBE_ADVANCED=y
+CONFIG_MTD_DOCPROBE_ADDRESS=0x0000
+CONFIG_MTD_DOCPROBE_HIGH=y
+CONFIG_MTD_DOCPROBE_55AA=y
+CONFIG_MTD_NAND=m
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_ECC_SMC=y
+# CONFIG_MTD_NAND_MUSEUM_IDS is not set
+CONFIG_MTD_NAND_IDS=m
+CONFIG_MTD_NAND_DISKONCHIP=m
+# CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADVANCED is not set
+CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDRESS=0
+CONFIG_MTD_NAND_DISKONCHIP_BBTWRITE=y
+CONFIG_MTD_NAND_CAFE=m
+CONFIG_MTD_NAND_NANDSIM=m
+CONFIG_MTD_NAND_PLATFORM=m
+CONFIG_MTD_ALAUDA=m
+CONFIG_MTD_ONENAND=m
+# CONFIG_MTD_ONENAND_VERIFY_WRITE is not set
+CONFIG_MTD_ONENAND_OTP=y
+CONFIG_MTD_ONENAND_2X_PROGRAM=y
+CONFIG_MTD_ONENAND_SIM=m
+
+#
+# UBI - Unsorted block images
+#
+CONFIG_MTD_UBI=m
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTD_UBI_BEB_RESERVE=1
+# CONFIG_MTD_UBI_GLUEBI is not set
+
+#
+# UBI debugging options
+#
+# CONFIG_MTD_UBI_DEBUG is not set
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+CONFIG_PARPORT_PC_FIFO=y
+CONFIG_PARPORT_PC_SUPERIO=y
+CONFIG_PARPORT_PC_PCMCIA=m
+# CONFIG_PARPORT_GSC is not set
+CONFIG_PARPORT_AX88796=m
+CONFIG_PARPORT_1284=y
+CONFIG_PARPORT_NOT_PC=y
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_PNPACPI=y
+CONFIG_BLK_DEV=y
+CONFIG_BLK_DEV_FD=m
+CONFIG_PARIDE=m
+
+#
+# Parallel IDE high-level drivers
+#
+CONFIG_PARIDE_PD=m
+CONFIG_PARIDE_PCD=m
+CONFIG_PARIDE_PF=m
+CONFIG_PARIDE_PT=m
+CONFIG_PARIDE_PG=m
+
+#
+# Parallel IDE protocol modules
+#
+CONFIG_PARIDE_ATEN=m
+CONFIG_PARIDE_BPCK=m
+CONFIG_PARIDE_COMM=m
+CONFIG_PARIDE_DSTR=m
+CONFIG_PARIDE_FIT2=m
+CONFIG_PARIDE_FIT3=m
+CONFIG_PARIDE_EPAT=m
+CONFIG_PARIDE_EPATC8=y
+CONFIG_PARIDE_EPIA=m
+CONFIG_PARIDE_FRIQ=m
+CONFIG_PARIDE_FRPW=m
+CONFIG_PARIDE_KBIC=m
+CONFIG_PARIDE_KTTI=m
+CONFIG_PARIDE_ON20=m
+CONFIG_PARIDE_ON26=m
+CONFIG_BLK_CPQ_DA=m
+CONFIG_BLK_CPQ_CISS_DA=m
+CONFIG_CISS_SCSI_TAPE=y
+CONFIG_BLK_DEV_DAC960=m
+CONFIG_BLK_DEV_UMEM=m
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+CONFIG_BLK_DEV_SX8=m
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=m
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=128000
+CONFIG_BLK_DEV_XIP=y
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+CONFIG_CDROM_PKTCDVD_WCACHE=y
+CONFIG_ATA_OVER_ETH=m
+CONFIG_CIPHER_TWOFISH=m
+CONFIG_VIRTIO_BLK=m
+# CONFIG_BLK_DEV_HD is not set
+CONFIG_MISC_DEVICES=y
+CONFIG_IBM_ASM=m
+CONFIG_PHANTOM=m
+CONFIG_EEPROM_93CX6=m
+CONFIG_SGI_IOC4=m
+CONFIG_TIFM_CORE=m
+CONFIG_TIFM_7XX1=m
+CONFIG_ACER_WMI=m
+CONFIG_ASUS_LAPTOP=m
+CONFIG_FUJITSU_LAPTOP=m
+# CONFIG_FUJITSU_LAPTOP_DEBUG is not set
+CONFIG_HP_WMI=m
+CONFIG_MSI_LAPTOP=m
+CONFIG_PANASONIC_LAPTOP=m
+CONFIG_COMPAL_LAPTOP=m
+CONFIG_SONY_LAPTOP=m
+CONFIG_SONYPI_COMPAT=y
+CONFIG_THINKPAD_ACPI=m
+# CONFIG_THINKPAD_ACPI_DEBUG is not set
+CONFIG_THINKPAD_ACPI_BAY=y
+CONFIG_THINKPAD_ACPI_VIDEO=y
+CONFIG_THINKPAD_ACPI_HOTKEY_POLL=y
+CONFIG_INTEL_MENLOW=m
+CONFIG_EEEPC_LAPTOP=m
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_SGI_XP=m
+CONFIG_HP_ILO=m
+CONFIG_SGI_GRU=m
+# CONFIG_SGI_GRU_DEBUG is not set
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=m
+CONFIG_BLK_DEV_IDE=m
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+CONFIG_IDE_TIMINGS=y
+CONFIG_IDE_ATAPI=y
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=m
+CONFIG_IDEDISK_MULTI_MODE=y
+CONFIG_BLK_DEV_IDECS=m
+CONFIG_BLK_DEV_DELKIN=m
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
+CONFIG_BLK_DEV_IDETAPE=m
+CONFIG_BLK_DEV_IDEFLOPPY=m
+CONFIG_BLK_DEV_IDESCSI=m
+CONFIG_BLK_DEV_IDEACPI=y
+# CONFIG_IDE_TASK_IOCTL is not set
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+CONFIG_IDE_GENERIC=m
+CONFIG_BLK_DEV_PLATFORM=m
+CONFIG_BLK_DEV_CMD640=m
+CONFIG_BLK_DEV_CMD640_ENHANCED=y
+CONFIG_BLK_DEV_IDEPNP=m
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+CONFIG_BLK_DEV_OFFBOARD=y
+CONFIG_BLK_DEV_GENERIC=m
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_RZ1000=m
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+CONFIG_BLK_DEV_AEC62XX=m
+CONFIG_BLK_DEV_ALI15X3=m
+CONFIG_BLK_DEV_AMD74XX=m
+CONFIG_BLK_DEV_ATIIXP=m
+CONFIG_BLK_DEV_CMD64X=m
+CONFIG_BLK_DEV_TRIFLEX=m
+CONFIG_BLK_DEV_CS5520=m
+CONFIG_BLK_DEV_CS5530=m
+CONFIG_BLK_DEV_HPT366=m
+CONFIG_BLK_DEV_JMICRON=m
+CONFIG_BLK_DEV_SC1200=m
+CONFIG_BLK_DEV_PIIX=m
+CONFIG_BLK_DEV_IT8213=m
+CONFIG_BLK_DEV_IT821X=m
+CONFIG_BLK_DEV_NS87415=m
+CONFIG_BLK_DEV_PDC202XX_OLD=m
+CONFIG_BLK_DEV_PDC202XX_NEW=m
+CONFIG_BLK_DEV_SVWKS=m
+CONFIG_BLK_DEV_SIIMAGE=m
+CONFIG_BLK_DEV_SIS5513=m
+CONFIG_BLK_DEV_SLC90E66=m
+# CONFIG_BLK_DEV_TRM290 is not set
+CONFIG_BLK_DEV_VIA82CXXX=m
+# CONFIG_BLK_DEV_TC86C001 is not set
+CONFIG_BLK_DEV_IDEDMA=y
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=m
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+CONFIG_SCSI_NETLINK=y
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=m
+CONFIG_SD_IOSTATS=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+# CONFIG_BLK_DEV_SR_VENDOR is not set
+CONFIG_CHR_DEV_SG=m
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_ENCLOSURE=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+# CONFIG_SCSI_SCAN_ASYNC is not set
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+CONFIG_SCSI_FC_ATTRS=m
+CONFIG_SCSI_FC_TGT_ATTRS=y
+CONFIG_SCSI_ISCSI_ATTRS=m
+CONFIG_SCSI_SAS_ATTRS=m
+CONFIG_SCSI_SAS_LIBSAS=m
+CONFIG_SCSI_SAS_ATA=y
+CONFIG_SCSI_SAS_HOST_SMP=y
+CONFIG_SCSI_SAS_LIBSAS_DEBUG=y
+CONFIG_SCSI_SRP_ATTRS=m
+CONFIG_SCSI_SRP_TGT_ATTRS=y
+CONFIG_SCSI_LOWLEVEL=y
+CONFIG_ISCSI_TCP=m
+CONFIG_SCSI_CXGB3_ISCSI=m
+CONFIG_BLK_DEV_3W_XXXX_RAID=m
+CONFIG_SCSI_3W_9XXX=m
+CONFIG_SCSI_ACARD=m
+CONFIG_SCSI_AACRAID=m
+CONFIG_SCSI_AIC7XXX=m
+CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
+CONFIG_AIC7XXX_RESET_DELAY_MS=5000
+# CONFIG_AIC7XXX_DEBUG_ENABLE is not set
+CONFIG_AIC7XXX_DEBUG_MASK=0
+CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC7XXX_OLD=m
+CONFIG_SCSI_AIC79XX=m
+CONFIG_AIC79XX_CMDS_PER_DEVICE=32
+CONFIG_AIC79XX_RESET_DELAY_MS=15000
+# CONFIG_AIC79XX_DEBUG_ENABLE is not set
+CONFIG_AIC79XX_DEBUG_MASK=0
+CONFIG_AIC79XX_REG_PRETTY_PRINT=y
+CONFIG_SCSI_AIC94XX=m
+CONFIG_AIC94XX_DEBUG=y
+CONFIG_SCSI_DPT_I2O=m
+CONFIG_SCSI_ADVANSYS=m
+CONFIG_SCSI_ARCMSR=m
+CONFIG_SCSI_ARCMSR_AER=y
+CONFIG_MEGARAID_NEWGEN=y
+CONFIG_MEGARAID_MM=m
+CONFIG_MEGARAID_MAILBOX=m
+CONFIG_MEGARAID_LEGACY=m
+CONFIG_MEGARAID_SAS=m
+CONFIG_SCSI_HPTIOP=m
+CONFIG_SCSI_BUSLOGIC=m
+CONFIG_LIBFC=m
+CONFIG_FCOE=m
+CONFIG_SCSI_DMX3191D=m
+CONFIG_SCSI_EATA=m
+CONFIG_SCSI_EATA_TAGGED_QUEUE=y
+CONFIG_SCSI_EATA_LINKED_COMMANDS=y
+CONFIG_SCSI_EATA_MAX_TAGS=16
+CONFIG_SCSI_FUTURE_DOMAIN=m
+CONFIG_SCSI_GDTH=m
+CONFIG_SCSI_IPS=m
+CONFIG_SCSI_INITIO=m
+# CONFIG_SCSI_INIA100 is not set
+CONFIG_SCSI_PPA=m
+CONFIG_SCSI_IMM=m
+# CONFIG_SCSI_IZIP_EPP16 is not set
+# CONFIG_SCSI_IZIP_SLOW_CTR is not set
+CONFIG_SCSI_MVSAS=m
+CONFIG_SCSI_STEX=m
+CONFIG_SCSI_SYM53C8XX_2=m
+CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=1
+CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
+CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
+CONFIG_SCSI_SYM53C8XX_MMIO=y
+# CONFIG_SCSI_IPR is not set
+CONFIG_SCSI_QLOGIC_1280=m
+CONFIG_SCSI_QLA_FC=m
+CONFIG_SCSI_QLA_ISCSI=m
+CONFIG_SCSI_LPFC=m
+CONFIG_SCSI_DC395x=m
+CONFIG_SCSI_DC390T=m
+CONFIG_SCSI_DEBUG=m
+CONFIG_SCSI_SRP=m
+CONFIG_SCSI_LOWLEVEL_PCMCIA=y
+CONFIG_PCMCIA_FDOMAIN=m
+CONFIG_PCMCIA_QLOGIC=m
+CONFIG_PCMCIA_SYM53C500=m
+CONFIG_SCSI_DH=m
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_SCSI_DH_HP_SW=m
+CONFIG_SCSI_DH_EMC=m
+CONFIG_SCSI_DH_ALUA=m
+CONFIG_ATA=m
+# CONFIG_ATA_NONSTANDARD is not set
+CONFIG_ATA_ACPI=y
+CONFIG_SATA_PMP=y
+CONFIG_SATA_AHCI=m
+CONFIG_SATA_SIL24=m
+CONFIG_ATA_SFF=y
+CONFIG_SATA_SVW=m
+CONFIG_ATA_PIIX=m
+CONFIG_SATA_MV=m
+CONFIG_SATA_NV=m
+CONFIG_PDC_ADMA=m
+CONFIG_SATA_QSTOR=m
+CONFIG_SATA_PROMISE=m
+CONFIG_SATA_SX4=m
+CONFIG_SATA_SIL=m
+CONFIG_SATA_SIS=m
+CONFIG_SATA_ULI=m
+CONFIG_SATA_VIA=m
+CONFIG_SATA_VITESSE=m
+CONFIG_SATA_INIC162X=m
+CONFIG_PATA_ACPI=m
+CONFIG_PATA_ALI=m
+CONFIG_PATA_AMD=m
+CONFIG_PATA_ARTOP=m
+CONFIG_PATA_ATIIXP=m
+CONFIG_PATA_CMD640_PCI=m
+CONFIG_PATA_CMD64X=m
+CONFIG_PATA_CS5520=m
+CONFIG_PATA_CS5530=m
+CONFIG_PATA_CYPRESS=m
+CONFIG_PATA_EFAR=m
+CONFIG_ATA_GENERIC=m
+CONFIG_PATA_HPT366=m
+CONFIG_PATA_HPT37X=m
+CONFIG_PATA_HPT3X2N=m
+CONFIG_PATA_HPT3X3=m
+# CONFIG_PATA_HPT3X3_DMA is not set
+CONFIG_PATA_IT821X=m
+CONFIG_PATA_IT8213=m
+CONFIG_PATA_JMICRON=m
+CONFIG_PATA_TRIFLEX=m
+CONFIG_PATA_MARVELL=m
+CONFIG_PATA_MPIIX=m
+CONFIG_PATA_OLDPIIX=m
+CONFIG_PATA_NETCELL=m
+CONFIG_PATA_NINJA32=m
+CONFIG_PATA_NS87410=m
+CONFIG_PATA_NS87415=m
+CONFIG_PATA_OPTI=m
+CONFIG_PATA_OPTIDMA=m
+CONFIG_PATA_PCMCIA=m
+CONFIG_PATA_PDC_OLD=m
+CONFIG_PATA_RADISYS=m
+CONFIG_PATA_RZ1000=m
+CONFIG_PATA_SC1200=m
+CONFIG_PATA_SERVERWORKS=m
+CONFIG_PATA_PDC2027X=m
+CONFIG_PATA_SIL680=m
+CONFIG_PATA_SIS=m
+CONFIG_PATA_VIA=m
+CONFIG_PATA_WINBOND=m
+CONFIG_PATA_SCH=m
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+# CONFIG_DM_DEBUG is not set
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_DELAY=m
+CONFIG_DM_RAID45=m
+CONFIG_DM_UEVENT=y
+CONFIG_FUSION=y
+CONFIG_FUSION_SPI=m
+CONFIG_FUSION_FC=m
+CONFIG_FUSION_SAS=m
+CONFIG_FUSION_MAX_SGE=128
+CONFIG_FUSION_MAX_FC_SGE=256
+CONFIG_FUSION_CTL=m
+CONFIG_FUSION_LAN=m
+# CONFIG_FUSION_LOGGING is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+# CONFIG_FIREWIRE is not set
+CONFIG_IEEE1394=m
+CONFIG_IEEE1394_OHCI1394=m
+CONFIG_IEEE1394_PCILYNX=m
+CONFIG_IEEE1394_SBP2=m
+# CONFIG_IEEE1394_SBP2_PHYS_DMA is not set
+CONFIG_IEEE1394_ETH1394_ROM_ENTRY=y
+CONFIG_IEEE1394_ETH1394=m
+CONFIG_IEEE1394_RAWIO=m
+CONFIG_IEEE1394_VIDEO1394=m
+CONFIG_IEEE1394_DV1394=m
+# CONFIG_IEEE1394_VERBOSEDEBUG is not set
+CONFIG_I2O=m
+CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y
+CONFIG_I2O_EXT_ADAPTEC=y
+CONFIG_I2O_EXT_ADAPTEC_DMA64=y
+CONFIG_I2O_CONFIG=m
+CONFIG_I2O_CONFIG_OLD_IOCTL=y
+CONFIG_I2O_BUS=m
+CONFIG_I2O_BLOCK=m
+CONFIG_I2O_SCSI=m
+CONFIG_I2O_PROC=m
+# CONFIG_MACINTOSH_DRIVERS is not set
+CONFIG_NETDEVICES=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+CONFIG_MACVLAN=m
+CONFIG_EQUALIZER=m
+CONFIG_TUN=m
+CONFIG_VETH=m
+# CONFIG_NET_SB1000 is not set
+CONFIG_ARCNET=m
+CONFIG_ARCNET_1201=m
+CONFIG_ARCNET_1051=m
+CONFIG_ARCNET_RAW=m
+CONFIG_ARCNET_CAP=m
+CONFIG_ARCNET_COM90xx=m
+CONFIG_ARCNET_COM90xxIO=m
+CONFIG_ARCNET_RIM_I=m
+# CONFIG_ARCNET_COM20020 is not set
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_BROADCOM_PHY=m
+CONFIG_ICPLUS_PHY=m
+CONFIG_REALTEK_PHY=m
+CONFIG_MDIO_BITBANG=m
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+CONFIG_ENC28J60=m
+# CONFIG_ENC28J60_WRITEVERIFY is not set
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+# CONFIG_TULIP_MMIO is not set
+CONFIG_TULIP_NAPI=y
+CONFIG_TULIP_NAPI_HW_MITIGATION=y
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+CONFIG_HP100=m
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_B44=m
+CONFIG_B44_PCI_AUTOSELECT=y
+CONFIG_B44_PCICORE_AUTOSELECT=y
+CONFIG_B44_PCI=y
+CONFIG_FORCEDETH=m
+CONFIG_FORCEDETH_NAPI=y
+CONFIG_EEPRO100=m
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_R6040=m
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+# CONFIG_VIA_RHINE_MMIO is not set
+CONFIG_SC92031=m
+# CONFIG_NET_POCKET is not set
+CONFIG_ATL2=m
+CONFIG_NETDEV_1000=y
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_IP1000=m
+CONFIG_IGB=m
+CONFIG_IGB_LRO=y
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+# CONFIG_SKGE_DEBUG is not set
+CONFIG_SKY2=m
+# CONFIG_SKY2_DEBUG is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_QLA3XXX=m
+CONFIG_ATL1=m
+CONFIG_ATL1E=m
+CONFIG_NETDEV_10000=y
+CONFIG_CHELSIO_T1=m
+CONFIG_CHELSIO_T1_1G=y
+CONFIG_CHELSIO_T3=m
+CONFIG_IXGBE=m
+CONFIG_IXGBE_LRO=y
+CONFIG_IXGBE_DCB=y
+CONFIG_IXGB=m
+CONFIG_S2IO=m
+CONFIG_MYRI10GE=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+CONFIG_MLX4_CORE=m
+CONFIG_MLX4_DEBUG=y
+CONFIG_TEHUTI=m
+CONFIG_BNX2X=m
+CONFIG_SFC=m
+# CONFIG_SFC_RESOURCE is not set
+CONFIG_TR=y
+CONFIG_IBMOL=m
+CONFIG_3C359=m
+CONFIG_TMS380TR=m
+CONFIG_TMSPCI=m
+CONFIG_ABYSS=m
+
+#
+# Wireless LAN
+#
+CONFIG_WLAN_PRE80211=y
+CONFIG_STRIP=m
+CONFIG_PCMCIA_WAVELAN=m
+CONFIG_PCMCIA_NETWAVE=m
+CONFIG_WLAN_80211=y
+CONFIG_PCMCIA_RAYCS=m
+CONFIG_IPW2100=m
+CONFIG_IPW2100_MONITOR=y
+# CONFIG_IPW2100_DEBUG is not set
+CONFIG_IPW2200=m
+CONFIG_IPW2200_MONITOR=y
+CONFIG_IPW2200_RADIOTAP=y
+CONFIG_IPW2200_PROMISCUOUS=y
+CONFIG_IPW2200_QOS=y
+# CONFIG_IPW2200_DEBUG is not set
+CONFIG_LIBERTAS=m
+CONFIG_LIBERTAS_USB=m
+CONFIG_LIBERTAS_CS=m
+CONFIG_LIBERTAS_SDIO=m
+# CONFIG_LIBERTAS_DEBUG is not set
+CONFIG_AIRO=m
+CONFIG_HERMES=m
+CONFIG_PLX_HERMES=m
+CONFIG_TMD_HERMES=m
+CONFIG_NORTEL_HERMES=m
+CONFIG_PCI_HERMES=m
+CONFIG_PCMCIA_HERMES=m
+CONFIG_PCMCIA_SPECTRUM=m
+CONFIG_ATMEL=m
+CONFIG_PCI_ATMEL=m
+CONFIG_PCMCIA_ATMEL=m
+CONFIG_AIRO_CS=m
+CONFIG_PCMCIA_WL3501=m
+CONFIG_PRISM54=m
+CONFIG_USB_ZD1201=m
+CONFIG_USB_NET_RNDIS_WLAN=m
+CONFIG_RTL8180=m
+CONFIG_RTL8187=m
+CONFIG_ADM8211=m
+CONFIG_MAC80211_HWSIM=m
+CONFIG_P54_COMMON=m
+CONFIG_P54_USB=m
+CONFIG_P54_PCI=m
+CONFIG_ATH5K=m
+# CONFIG_ATH5K_DEBUG is not set
+CONFIG_ATH9K=m
+CONFIG_IWLWIFI=m
+CONFIG_IWLCORE=m
+CONFIG_IWLWIFI_LEDS=y
+CONFIG_IWLWIFI_RFKILL=y
+# CONFIG_IWLWIFI_DEBUG is not set
+CONFIG_IWLAGN=m
+CONFIG_IWLAGN_SPECTRUM_MEASUREMENT=y
+CONFIG_IWLAGN_LEDS=y
+CONFIG_IWL4965=y
+CONFIG_IWL5000=y
+CONFIG_IWL3945=m
+CONFIG_IWL3945_RFKILL=y
+CONFIG_IWL3945_SPECTRUM_MEASUREMENT=y
+CONFIG_IWL3945_LEDS=y
+# CONFIG_IWL3945_DEBUG is not set
+CONFIG_HOSTAP=m
+CONFIG_HOSTAP_FIRMWARE=y
+CONFIG_HOSTAP_FIRMWARE_NVRAM=y
+CONFIG_HOSTAP_PLX=m
+CONFIG_HOSTAP_PCI=m
+CONFIG_HOSTAP_CS=m
+CONFIG_B43=m
+CONFIG_B43_PCI_AUTOSELECT=y
+CONFIG_B43_PCICORE_AUTOSELECT=y
+CONFIG_B43_PCMCIA=y
+CONFIG_B43_PIO=y
+CONFIG_B43_LEDS=y
+CONFIG_B43_RFKILL=y
+# CONFIG_B43_DEBUG is not set
+CONFIG_B43LEGACY=m
+CONFIG_B43LEGACY_PCI_AUTOSELECT=y
+CONFIG_B43LEGACY_PCICORE_AUTOSELECT=y
+CONFIG_B43LEGACY_LEDS=y
+CONFIG_B43LEGACY_RFKILL=y
+# CONFIG_B43LEGACY_DEBUG is not set
+CONFIG_B43LEGACY_DMA=y
+CONFIG_B43LEGACY_PIO=y
+CONFIG_B43LEGACY_DMA_AND_PIO_MODE=y
+# CONFIG_B43LEGACY_DMA_MODE is not set
+# CONFIG_B43LEGACY_PIO_MODE is not set
+CONFIG_ZD1211RW=m
+# CONFIG_ZD1211RW_DEBUG is not set
+CONFIG_RT2X00=m
+CONFIG_RT2X00_LIB=m
+CONFIG_RT2X00_LIB_PCI=m
+CONFIG_RT2X00_LIB_USB=m
+CONFIG_RT2X00_LIB_FIRMWARE=y
+CONFIG_RT2X00_LIB_RFKILL=y
+CONFIG_RT2X00_LIB_LEDS=y
+CONFIG_RT2400PCI=m
+CONFIG_RT2400PCI_RFKILL=y
+CONFIG_RT2400PCI_LEDS=y
+CONFIG_RT2500PCI=m
+CONFIG_RT2500PCI_RFKILL=y
+CONFIG_RT2500PCI_LEDS=y
+CONFIG_RT61PCI=m
+CONFIG_RT61PCI_RFKILL=y
+CONFIG_RT61PCI_LEDS=y
+CONFIG_RT2500USB=m
+CONFIG_RT2500USB_LEDS=y
+CONFIG_RT73USB=m
+CONFIG_RT73USB_LEDS=y
+# CONFIG_RT2X00_LIB_DEBUGFS is not set
+# CONFIG_RT2X00_DEBUG is not set
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_KC2190=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_USB_HSO=m
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+CONFIG_WAN=y
+CONFIG_LANMEDIA=m
+CONFIG_HDLC=m
+CONFIG_HDLC_RAW=m
+CONFIG_HDLC_RAW_ETH=m
+CONFIG_HDLC_CISCO=m
+CONFIG_HDLC_FR=m
+CONFIG_HDLC_PPP=m
+CONFIG_HDLC_X25=m
+CONFIG_PCI200SYN=m
+CONFIG_WANXL=m
+# CONFIG_PC300 is not set
+CONFIG_PC300TOO=m
+CONFIG_FARSYNC=m
+# CONFIG_DSCC4 is not set
+CONFIG_DLCI=m
+CONFIG_DLCI_MAX=8
+# CONFIG_WAN_ROUTER_DRIVERS is not set
+CONFIG_LAPBETHER=m
+CONFIG_X25_ASY=m
+# CONFIG_SBNI is not set
+CONFIG_ATM_DRIVERS=y
+CONFIG_ATM_DUMMY=m
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+CONFIG_ATM_ENI_TUNE_BURST=y
+# CONFIG_ATM_ENI_BURST_TX_16W is not set
+CONFIG_ATM_ENI_BURST_TX_8W=y
+CONFIG_ATM_ENI_BURST_TX_4W=y
+CONFIG_ATM_ENI_BURST_TX_2W=y
+# CONFIG_ATM_ENI_BURST_RX_16W is not set
+# CONFIG_ATM_ENI_BURST_RX_8W is not set
+CONFIG_ATM_ENI_BURST_RX_4W=y
+CONFIG_ATM_ENI_BURST_RX_2W=y
+CONFIG_ATM_FIRESTREAM=m
+CONFIG_ATM_ZATM=m
+# CONFIG_ATM_ZATM_DEBUG is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+# CONFIG_ATM_IDT77252_RCV_ALL is not set
+CONFIG_ATM_IDT77252_USE_SUNI=y
+CONFIG_ATM_AMBASSADOR=m
+# CONFIG_ATM_AMBASSADOR_DEBUG is not set
+CONFIG_ATM_HORIZON=m
+# CONFIG_ATM_HORIZON_DEBUG is not set
+CONFIG_ATM_IA=m
+# CONFIG_ATM_IA_DEBUG is not set
+CONFIG_ATM_FORE200E=m
+CONFIG_ATM_FORE200E_USE_TASKLET=y
+CONFIG_ATM_FORE200E_TX_RETRY=16
+CONFIG_ATM_FORE200E_DEBUG=0
+CONFIG_ATM_HE=m
+CONFIG_ATM_HE_USE_SUNI=y
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+CONFIG_SKFP=m
+CONFIG_HIPPI=y
+CONFIG_ROADRUNNER=m
+CONFIG_ROADRUNNER_LARGE_RINGS=y
+CONFIG_PLIP=m
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+CONFIG_PPP_BSDCOMP=m
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_PPPOL2TP=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=m
+CONFIG_SLIP_SMART=y
+CONFIG_SLIP_MODE_SLIP6=y
+CONFIG_NET_FC=y
+CONFIG_NETCONSOLE=m
+CONFIG_NETCONSOLE_DYNAMIC=y
+CONFIG_NETPOLL=y
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
+CONFIG_ISDN=y
+CONFIG_MISDN=m
+CONFIG_MISDN_DSP=m
+CONFIG_MISDN_L1OIP=m
+
+#
+# mISDN hardware drivers
+#
+CONFIG_MISDN_HFCPCI=m
+CONFIG_MISDN_HFCMULTI=m
+CONFIG_ISDN_I4L=m
+CONFIG_ISDN_PPP=y
+CONFIG_ISDN_PPP_VJ=y
+CONFIG_ISDN_MPP=y
+CONFIG_IPPP_FILTER=y
+CONFIG_ISDN_PPP_BSDCOMP=m
+CONFIG_ISDN_AUDIO=y
+CONFIG_ISDN_TTY_FAX=y
+CONFIG_ISDN_X25=y
+
+#
+# ISDN feature submodules
+#
+CONFIG_ISDN_DIVERSION=m
+
+#
+# ISDN4Linux hardware drivers
+#
+
+#
+# Passive cards
+#
+CONFIG_ISDN_DRV_HISAX=m
+
+#
+# D-channel protocol features
+#
+CONFIG_HISAX_EURO=y
+CONFIG_DE_AOC=y
+# CONFIG_HISAX_NO_SENDCOMPLETE is not set
+# CONFIG_HISAX_NO_LLC is not set
+# CONFIG_HISAX_NO_KEYPAD is not set
+CONFIG_HISAX_1TR6=y
+CONFIG_HISAX_NI1=y
+CONFIG_HISAX_MAX_CARDS=8
+
+#
+# HiSax supported cards
+#
+CONFIG_HISAX_16_3=y
+CONFIG_HISAX_TELESPCI=y
+CONFIG_HISAX_S0BOX=y
+CONFIG_HISAX_FRITZPCI=y
+CONFIG_HISAX_AVM_A1_PCMCIA=y
+CONFIG_HISAX_ELSA=y
+CONFIG_HISAX_DIEHLDIVA=y
+CONFIG_HISAX_SEDLBAUER=y
+CONFIG_HISAX_NETJET=y
+CONFIG_HISAX_NETJET_U=y
+CONFIG_HISAX_NICCY=y
+CONFIG_HISAX_BKM_A4T=y
+CONFIG_HISAX_SCT_QUADRO=y
+CONFIG_HISAX_GAZEL=y
+CONFIG_HISAX_HFC_PCI=y
+CONFIG_HISAX_W6692=y
+CONFIG_HISAX_HFC_SX=y
+CONFIG_HISAX_ENTERNOW_PCI=y
+CONFIG_HISAX_DEBUG=y
+
+#
+# HiSax PCMCIA card service modules
+#
+CONFIG_HISAX_SEDLBAUER_CS=m
+CONFIG_HISAX_ELSA_CS=m
+CONFIG_HISAX_AVM_A1_CS=m
+CONFIG_HISAX_TELES_CS=m
+
+#
+# HiSax sub driver modules
+#
+CONFIG_HISAX_ST5481=m
+CONFIG_HISAX_HFCUSB=m
+CONFIG_HISAX_HFC4S8S=m
+CONFIG_HISAX_FRITZ_PCIPNP=m
+CONFIG_HISAX_HDLC=y
+
+#
+# Active cards
+#
+CONFIG_HYSDN=m
+CONFIG_HYSDN_CAPI=y
+CONFIG_ISDN_DRV_GIGASET=m
+CONFIG_GIGASET_BASE=m
+CONFIG_GIGASET_M105=m
+CONFIG_GIGASET_M101=m
+# CONFIG_GIGASET_DEBUG is not set
+CONFIG_GIGASET_UNDOCREQ=y
+CONFIG_ISDN_CAPI=m
+CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON=y
+CONFIG_CAPI_TRACE=y
+CONFIG_ISDN_CAPI_MIDDLEWARE=y
+CONFIG_ISDN_CAPI_CAPI20=m
+CONFIG_ISDN_CAPI_CAPIFS_BOOL=y
+CONFIG_ISDN_CAPI_CAPIFS=m
+CONFIG_ISDN_CAPI_CAPIDRV=m
+
+#
+# CAPI hardware drivers
+#
+CONFIG_CAPI_AVM=y
+CONFIG_ISDN_DRV_AVMB1_B1PCI=m
+CONFIG_ISDN_DRV_AVMB1_B1PCIV4=y
+CONFIG_ISDN_DRV_AVMB1_B1PCMCIA=m
+CONFIG_ISDN_DRV_AVMB1_AVM_CS=m
+CONFIG_ISDN_DRV_AVMB1_T1PCI=m
+CONFIG_ISDN_DRV_AVMB1_C4=m
+# CONFIG_CAPI_EICON is not set
+CONFIG_PHONE=m
+CONFIG_PHONE_IXJ=m
+CONFIG_PHONE_IXJ_PCMCIA=m
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=m
+CONFIG_INPUT_POLLDEV=m
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+CONFIG_INPUT_MOUSEDEV_PSAUX=y
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+CONFIG_KEYBOARD_SUNKBD=m
+# CONFIG_KEYBOARD_LKKBD is not set
+CONFIG_KEYBOARD_XTKBD=m
+CONFIG_KEYBOARD_NEWTON=m
+# CONFIG_KEYBOARD_STOWAWAY is not set
+CONFIG_KEYBOARD_GPIO=m
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_LIFEBOOK=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_APPLETOUCH=m
+CONFIG_MOUSE_BCM5974=m
+# CONFIG_MOUSE_VSXXXAA is not set
+CONFIG_MOUSE_GPIO=m
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_USB=y
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_ZHENHUA=m
+CONFIG_JOYSTICK_DB9=m
+CONFIG_JOYSTICK_GAMECON=m
+CONFIG_JOYSTICK_TURBOGRAFX=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+CONFIG_INPUT_TABLET=y
+CONFIG_TABLET_USB_ACECAD=m
+CONFIG_TABLET_USB_AIPTEK=m
+CONFIG_TABLET_USB_GTCO=m
+CONFIG_TABLET_USB_KBTAB=m
+CONFIG_TABLET_USB_WACOM=m
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ADS7846=m
+CONFIG_TOUCHSCREEN_FUJITSU=m
+CONFIG_TOUCHSCREEN_GUNZE=m
+CONFIG_TOUCHSCREEN_ELO=m
+CONFIG_TOUCHSCREEN_ELOUSB=m
+CONFIG_TOUCHSCREEN_MTOUCH=m
+CONFIG_TOUCHSCREEN_INEXIO=m
+CONFIG_TOUCHSCREEN_MK712=m
+CONFIG_TOUCHSCREEN_PENMOUNT=m
+CONFIG_TOUCHSCREEN_TOUCHRIGHT=m
+CONFIG_TOUCHSCREEN_TOUCHWIN=m
+CONFIG_TOUCHSCREEN_UCB1400=m
+CONFIG_TOUCHSCREEN_WM97XX=m
+CONFIG_TOUCHSCREEN_WM9705=y
+CONFIG_TOUCHSCREEN_WM9712=y
+CONFIG_TOUCHSCREEN_WM9713=y
+CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
+CONFIG_TOUCHSCREEN_USB_EGALAX=y
+CONFIG_TOUCHSCREEN_USB_PANJIT=y
+CONFIG_TOUCHSCREEN_USB_3M=y
+CONFIG_TOUCHSCREEN_USB_ITM=y
+CONFIG_TOUCHSCREEN_USB_ETURBO=y
+CONFIG_TOUCHSCREEN_USB_GUNZE=y
+CONFIG_TOUCHSCREEN_USB_DMC_TSC10=y
+CONFIG_TOUCHSCREEN_USB_IRTOUCH=y
+CONFIG_TOUCHSCREEN_USB_IDEALTEK=y
+CONFIG_TOUCHSCREEN_USB_GENERAL_TOUCH=y
+CONFIG_TOUCHSCREEN_USB_GOTOP=y
+CONFIG_TOUCHSCREEN_TOUCHIT213=m
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_APANEL=m
+CONFIG_INPUT_ATLAS_BTNS=m
+CONFIG_INPUT_ATI_REMOTE=m
+CONFIG_INPUT_ATI_REMOTE2=m
+CONFIG_INPUT_KEYSPAN_REMOTE=m
+CONFIG_INPUT_POWERMATE=m
+CONFIG_INPUT_YEALINK=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=m
+CONFIG_SERIO_CT82C710=m
+CONFIG_SERIO_PARKBD=m
+CONFIG_SERIO_PCIPS2=m
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_CONSOLE_TRANSLATIONS=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_DEVKMEM=y
+CONFIG_SERIAL_NONSTANDARD=y
+CONFIG_COMPUTONE=m
+CONFIG_ROCKETPORT=m
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+CONFIG_DIGIEPCA=m
+CONFIG_MOXA_INTELLIO=m
+CONFIG_MOXA_SMARTIO=m
+CONFIG_ISI=m
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+CONFIG_RISCOM8=m
+CONFIG_SPECIALIX=m
+CONFIG_SX=m
+CONFIG_RIO=m
+CONFIG_RIO_OLDPCI=y
+CONFIG_STALDRV=y
+CONFIG_NOZOMI=m
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_FIX_EARLYCON_MEM=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_PNP=y
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=16
+CONFIG_SERIAL_8250_RUNTIME_UARTS=8
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_JSM=m
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=0
+CONFIG_PRINTER=m
+# CONFIG_LP_CONSOLE is not set
+CONFIG_PPDEV=m
+CONFIG_HVC_DRIVER=y
+CONFIG_VIRTIO_CONSOLE=m
+CONFIG_IPMI_HANDLER=m
+CONFIG_IPMI_PANIC_EVENT=y
+# CONFIG_IPMI_PANIC_STRING is not set
+CONFIG_IPMI_DEVICE_INTERFACE=m
+CONFIG_IPMI_SI=m
+CONFIG_IPMI_WATCHDOG=m
+CONFIG_IPMI_POWEROFF=m
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_INTEL=m
+CONFIG_HW_RANDOM_AMD=m
+CONFIG_HW_RANDOM_VIRTIO=m
+CONFIG_NVRAM=y
+CONFIG_R3964=m
+CONFIG_APPLICOM=m
+
+#
+# PCMCIA character devices
+#
+CONFIG_SYNCLINK_CS=m
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+CONFIG_IPWIRELESS=m
+# CONFIG_MWAVE is not set
+CONFIG_PC8736x_GPIO=m
+CONFIG_NSC_GPIO=m
+CONFIG_RAW_DRIVER=m
+CONFIG_MAX_RAW_DEVS=4096
+CONFIG_HPET=y
+CONFIG_HPET_MMAP=y
+CONFIG_HANGCHECK_TIMER=m
+CONFIG_TCG_TPM=m
+CONFIG_TCG_TIS=m
+CONFIG_TCG_NSC=m
+CONFIG_TCG_ATMEL=m
+CONFIG_TCG_INFINEON=m
+CONFIG_TELCLOCK=m
+CONFIG_DEVPORT=y
+CONFIG_CRASHER=m
+CONFIG_I2C=m
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_HELPER_AUTO=y
+CONFIG_I2C_ALGOBIT=m
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# PC SMBus host controller drivers
+#
+CONFIG_I2C_ALI1535=m
+CONFIG_I2C_ALI1563=m
+CONFIG_I2C_ALI15X3=m
+CONFIG_I2C_AMD756=m
+CONFIG_I2C_AMD756_S4882=m
+CONFIG_I2C_AMD8111=m
+CONFIG_I2C_I801=m
+CONFIG_I2C_ISCH=m
+CONFIG_I2C_PIIX4=m
+CONFIG_I2C_NFORCE2=m
+CONFIG_I2C_NFORCE2_S4985=m
+CONFIG_I2C_SIS5595=m
+CONFIG_I2C_SIS630=m
+CONFIG_I2C_SIS96X=m
+CONFIG_I2C_VIA=m
+CONFIG_I2C_VIAPRO=m
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+CONFIG_I2C_GPIO=m
+CONFIG_I2C_OCORES=m
+# CONFIG_I2C_SIMTEC is not set
+
+#
+# External I2C/SMBus adapter drivers
+#
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+CONFIG_I2C_TAOS_EVM=m
+CONFIG_I2C_TINY_USB=m
+
+#
+# Graphics adapter I2C/DDC channel drivers
+#
+CONFIG_I2C_VOODOO3=m
+
+#
+# Other I2C/SMBus bus drivers
+#
+CONFIG_I2C_PCA_PLATFORM=m
+CONFIG_I2C_STUB=m
+
+#
+# Miscellaneous I2C Chip support
+#
+CONFIG_DS1682=m
+CONFIG_AT24=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8591=m
+# CONFIG_TPS65010 is not set
+CONFIG_SENSORS_MAX6875=m
+CONFIG_SENSORS_TSL2550=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_SPI=y
+CONFIG_SPI_DEBUG=y
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=m
+CONFIG_SPI_BUTTERFLY=m
+CONFIG_SPI_LM70_LLP=m
+
+#
+# SPI Protocol Masters
+#
+CONFIG_SPI_AT25=m
+CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_TLE62X0=m
+CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
+CONFIG_GPIOLIB=y
+# CONFIG_DEBUG_GPIO is not set
+CONFIG_GPIO_SYSFS=y
+
+#
+# I2C GPIO expanders:
+#
+CONFIG_GPIO_MAX732X=m
+CONFIG_GPIO_PCA953X=m
+CONFIG_GPIO_PCF857X=m
+
+#
+# PCI GPIO expanders:
+#
+
+#
+# SPI GPIO expanders:
+#
+CONFIG_GPIO_MAX7301=m
+CONFIG_GPIO_MCP23S08=m
+CONFIG_W1=m
+CONFIG_W1_CON=y
+
+#
+# 1-wire Bus Masters
+#
+CONFIG_W1_MASTER_MATROX=m
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS2482=m
+CONFIG_W1_MASTER_GPIO=m
+
+#
+# 1-wire Slaves
+#
+CONFIG_W1_SLAVE_THERM=m
+CONFIG_W1_SLAVE_SMEM=m
+CONFIG_W1_SLAVE_DS2433=m
+CONFIG_W1_SLAVE_DS2433_CRC=y
+CONFIG_W1_SLAVE_DS2760=m
+CONFIG_POWER_SUPPLY=y
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+CONFIG_PDA_POWER=m
+CONFIG_BATTERY_DS2760=m
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_ABITUGURU=m
+CONFIG_SENSORS_ABITUGURU3=m
+CONFIG_SENSORS_AD7414=m
+CONFIG_SENSORS_AD7418=m
+CONFIG_SENSORS_ADCXX=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1029=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ADT7470=m
+CONFIG_SENSORS_ADT7473=m
+CONFIG_SENSORS_K8TEMP=m
+CONFIG_SENSORS_ASB100=m
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+CONFIG_SENSORS_I5K_AMB=m
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_F71882FG=m
+CONFIG_SENSORS_F75375S=m
+CONFIG_SENSORS_FSCHER=m
+CONFIG_SENSORS_FSCPOS=m
+CONFIG_SENSORS_FSCHMD=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_CORETEMP=m
+CONFIG_SENSORS_IBMAEM=m
+CONFIG_SENSORS_IBMPEX=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM70=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_MAX6650=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_PC87427=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_DME1737=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_ADS7828=m
+CONFIG_SENSORS_THMC50=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT1211=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83L786NG=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+CONFIG_SENSORS_HDAPS=m
+CONFIG_SENSORS_APPLESMC=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+CONFIG_THERMAL=m
+CONFIG_THERMAL_HWMON=y
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+CONFIG_ACQUIRE_WDT=m
+CONFIG_ADVANTECH_WDT=m
+CONFIG_ALIM1535_WDT=m
+CONFIG_ALIM7101_WDT=m
+CONFIG_SC520_WDT=m
+CONFIG_EUROTECH_WDT=m
+CONFIG_IB700_WDT=m
+CONFIG_IBMASR=m
+CONFIG_WAFER_WDT=m
+CONFIG_I6300ESB_WDT=m
+CONFIG_ITCO_WDT=m
+CONFIG_ITCO_VENDOR_SUPPORT=y
+CONFIG_IT8712F_WDT=m
+CONFIG_HP_WATCHDOG=m
+CONFIG_SC1200_WDT=m
+CONFIG_PC87413_WDT=m
+CONFIG_60XX_WDT=m
+CONFIG_SBC8360_WDT=m
+CONFIG_CPU5_WDT=m
+CONFIG_SMSC37B787_WDT=m
+CONFIG_W83627HF_WDT=m
+CONFIG_W83697HF_WDT=m
+CONFIG_W83877F_WDT=m
+CONFIG_W83977F_WDT=m
+CONFIG_MACHZ_WDT=m
+CONFIG_SBC_EPX_C3_WATCHDOG=m
+
+#
+# PCI-based Watchdog Cards
+#
+CONFIG_PCIPCWATCHDOG=m
+CONFIG_WDTPCI=m
+CONFIG_WDT_501_PCI=y
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB_POSSIBLE=y
+CONFIG_SSB=m
+CONFIG_SSB_SPROM=y
+CONFIG_SSB_BLOCKIO=y
+CONFIG_SSB_PCIHOST_POSSIBLE=y
+CONFIG_SSB_PCIHOST=y
+CONFIG_SSB_B43_PCI_BRIDGE=y
+CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
+CONFIG_SSB_PCMCIAHOST=y
+# CONFIG_SSB_DEBUG is not set
+CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
+CONFIG_SSB_DRIVER_PCICORE=y
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_CORE is not set
+CONFIG_MFD_SM501=m
+CONFIG_MFD_SM501_GPIO=y
+CONFIG_HTC_PASIC3=m
+# CONFIG_MFD_TMIO is not set
+
+#
+# Multimedia devices
+#
+
+#
+# Multimedia core support
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_ALLOW_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_DVB_CORE=m
+CONFIG_VIDEO_MEDIA=m
+
+#
+# Multimedia drivers
+#
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_MEDIA_ATTACH=y
+CONFIG_MEDIA_TUNER=m
+# CONFIG_MEDIA_TUNER_CUSTOMIZE is not set
+CONFIG_MEDIA_TUNER_SIMPLE=m
+CONFIG_MEDIA_TUNER_TDA8290=m
+CONFIG_MEDIA_TUNER_TDA827X=m
+CONFIG_MEDIA_TUNER_TDA18271=m
+CONFIG_MEDIA_TUNER_TDA9887=m
+CONFIG_MEDIA_TUNER_TEA5761=m
+CONFIG_MEDIA_TUNER_TEA5767=m
+CONFIG_MEDIA_TUNER_MT20XX=m
+CONFIG_MEDIA_TUNER_MT2060=m
+CONFIG_MEDIA_TUNER_MT2266=m
+CONFIG_MEDIA_TUNER_MT2131=m
+CONFIG_MEDIA_TUNER_QT1010=m
+CONFIG_MEDIA_TUNER_XC2028=m
+CONFIG_MEDIA_TUNER_XC5000=m
+CONFIG_MEDIA_TUNER_MXL5005S=m
+CONFIG_MEDIA_TUNER_MXL5007T=m
+CONFIG_VIDEO_V4L2=m
+CONFIG_VIDEO_V4L1=m
+CONFIG_VIDEOBUF_GEN=m
+CONFIG_VIDEOBUF_DMA_SG=m
+CONFIG_VIDEOBUF_VMALLOC=m
+CONFIG_VIDEOBUF_DMA_CONTIG=m
+CONFIG_VIDEOBUF_DVB=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
+CONFIG_VIDEO_IR_I2C=m
+CONFIG_VIDEO_TVAUDIO=m
+CONFIG_VIDEO_TDA7432=m
+CONFIG_VIDEO_TDA9840=m
+CONFIG_VIDEO_TDA9875=m
+CONFIG_VIDEO_TEA6415C=m
+CONFIG_VIDEO_TEA6420=m
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS5345=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_M52790=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_VP27SMPX=m
+CONFIG_VIDEO_BT819=m
+CONFIG_VIDEO_BT856=m
+CONFIG_VIDEO_KS0127=m
+CONFIG_VIDEO_OV7670=m
+CONFIG_VIDEO_SAA7110=m
+CONFIG_VIDEO_SAA7111=m
+CONFIG_VIDEO_SAA7114=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA717X=m
+CONFIG_VIDEO_TVP5150=m
+CONFIG_VIDEO_VPX3220=m
+CONFIG_VIDEO_CX25840=m
+CONFIG_VIDEO_CX2341X=m
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_SAA7185=m
+CONFIG_VIDEO_ADV7170=m
+CONFIG_VIDEO_ADV7175=m
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+CONFIG_VIDEO_VIVI=m
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_BT848_DVB=y
+CONFIG_VIDEO_SAA6588=m
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+CONFIG_VIDEO_W9966=m
+CONFIG_VIDEO_CPIA=m
+CONFIG_VIDEO_CPIA_PP=m
+CONFIG_VIDEO_CPIA_USB=m
+CONFIG_VIDEO_CPIA2=m
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+# CONFIG_TUNER_3036 is not set
+CONFIG_VIDEO_STRADIS=m
+CONFIG_VIDEO_ZORAN=m
+CONFIG_VIDEO_ZORAN_DC30=m
+CONFIG_VIDEO_ZORAN_ZR36060=m
+CONFIG_VIDEO_ZORAN_BUZ=m
+CONFIG_VIDEO_ZORAN_DC10=m
+CONFIG_VIDEO_ZORAN_LML33=m
+CONFIG_VIDEO_ZORAN_LML33R10=m
+CONFIG_VIDEO_ZORAN_AVS6EYES=m
+CONFIG_VIDEO_MEYE=m
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_SAA7134_ALSA=m
+CONFIG_VIDEO_SAA7134_DVB=m
+CONFIG_VIDEO_MXB=m
+# CONFIG_VIDEO_DPC is not set
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_CX88_ALSA=m
+CONFIG_VIDEO_CX88_BLACKBIRD=m
+CONFIG_VIDEO_CX88_DVB=m
+CONFIG_VIDEO_CX88_VP3054=m
+CONFIG_VIDEO_CX23885=m
+CONFIG_VIDEO_AU0828=m
+CONFIG_VIDEO_IVTV=m
+CONFIG_VIDEO_FB_IVTV=m
+CONFIG_VIDEO_CX18=m
+CONFIG_VIDEO_CAFE_CCIC=m
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
+CONFIG_USB_GSPCA=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+CONFIG_VIDEO_PVRUSB2_DVB=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_EM28XX_ALSA=m
+CONFIG_VIDEO_EM28XX_DVB=m
+CONFIG_VIDEO_USBVISION=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+CONFIG_USB_ZR364XX=m
+CONFIG_USB_STKWEBCAM=m
+CONFIG_USB_S2255=m
+CONFIG_SOC_CAMERA=m
+CONFIG_SOC_CAMERA_MT9M001=m
+CONFIG_MT9M001_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_MT9V022=m
+CONFIG_MT9V022_PCA9536_SWITCH=y
+CONFIG_SOC_CAMERA_PLATFORM=m
+CONFIG_VIDEO_SH_MOBILE_CEU=m
+CONFIG_RADIO_ADAPTERS=y
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+CONFIG_USB_DSBR=m
+CONFIG_USB_SI470X=m
+CONFIG_DVB_CAPTURE_DRIVERS=y
+
+#
+# Supported SAA7146 based PCI Adapters
+#
+CONFIG_TTPCI_EEPROM=m
+CONFIG_DVB_AV7110=m
+# CONFIG_DVB_AV7110_FIRMWARE is not set
+CONFIG_DVB_AV7110_OSD=y
+CONFIG_DVB_BUDGET_CORE=m
+CONFIG_DVB_BUDGET=m
+CONFIG_DVB_BUDGET_CI=m
+CONFIG_DVB_BUDGET_AV=m
+CONFIG_DVB_BUDGET_PATCH=m
+
+#
+# Supported USB Adapters
+#
+CONFIG_DVB_USB=m
+# CONFIG_DVB_USB_DEBUG is not set
+CONFIG_DVB_USB_A800=m
+CONFIG_DVB_USB_DIBUSB_MB=m
+# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
+CONFIG_DVB_USB_DIBUSB_MC=m
+CONFIG_DVB_USB_DIB0700=m
+CONFIG_DVB_USB_UMT_010=m
+CONFIG_DVB_USB_CXUSB=m
+CONFIG_DVB_USB_M920X=m
+CONFIG_DVB_USB_GL861=m
+CONFIG_DVB_USB_AU6610=m
+CONFIG_DVB_USB_DIGITV=m
+CONFIG_DVB_USB_VP7045=m
+CONFIG_DVB_USB_VP702X=m
+CONFIG_DVB_USB_GP8PSK=m
+CONFIG_DVB_USB_NOVA_T_USB2=m
+CONFIG_DVB_USB_TTUSB2=m
+CONFIG_DVB_USB_DTT200U=m
+CONFIG_DVB_USB_OPERA1=m
+CONFIG_DVB_USB_AF9005=m
+CONFIG_DVB_USB_AF9005_REMOTE=m
+CONFIG_DVB_USB_DW2102=m
+CONFIG_DVB_USB_ANYSEE=m
+CONFIG_DVB_TTUSB_BUDGET=m
+CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_CINERGYT2=m
+# CONFIG_DVB_CINERGYT2_TUNING is not set
+CONFIG_DVB_SIANO_SMS1XXX=m
+CONFIG_DVB_SIANO_SMS1XXX_SMS_IDS=y
+
+#
+# Supported FlexCopII (B2C2) Adapters
+#
+CONFIG_DVB_B2C2_FLEXCOP=m
+CONFIG_DVB_B2C2_FLEXCOP_PCI=m
+CONFIG_DVB_B2C2_FLEXCOP_USB=m
+# CONFIG_DVB_B2C2_FLEXCOP_DEBUG is not set
+
+#
+# Supported BT878 Adapters
+#
+CONFIG_DVB_BT8XX=m
+
+#
+# Supported Pluto2 Adapters
+#
+CONFIG_DVB_PLUTO2=m
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+# CONFIG_DVB_FE_CUSTOMISE is not set
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_CX24123=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_S5H1420=m
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_TDA10086=m
+CONFIG_DVB_VES1X93=m
+CONFIG_DVB_TUNER_ITD1000=m
+CONFIG_DVB_TDA826X=m
+CONFIG_DVB_TUA6100=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_DRX397XD=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_ZL10353=m
+CONFIG_DVB_DIB3000MB=m
+CONFIG_DVB_DIB3000MC=m
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+CONFIG_DVB_TDA10048=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_TDA10023=m
+CONFIG_DVB_STV0297=m
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+CONFIG_DVB_NXT200X=m
+CONFIG_DVB_OR51211=m
+CONFIG_DVB_OR51132=m
+CONFIG_DVB_BCM3510=m
+CONFIG_DVB_LGDT330X=m
+CONFIG_DVB_S5H1409=m
+CONFIG_DVB_AU8522=m
+CONFIG_DVB_S5H1411=m
+
+#
+# Digital terrestrial only tuners/PLL
+#
+CONFIG_DVB_PLL=m
+CONFIG_DVB_TUNER_DIB0070=m
+
+#
+# SEC control devices for DVB-S
+#
+CONFIG_DVB_LNBP21=m
+CONFIG_DVB_ISL6405=m
+CONFIG_DVB_ISL6421=m
+CONFIG_DAB=y
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+CONFIG_AGP=y
+CONFIG_AGP_AMD64=y
+CONFIG_AGP_INTEL=m
+CONFIG_AGP_SIS=m
+CONFIG_AGP_VIA=m
+CONFIG_DRM=m
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_I810=m
+# CONFIG_DRM_I830 is not set
+CONFIG_DRM_I915=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_DRM_VIA=m
+CONFIG_DRM_VIA_CHROME9=m
+CONFIG_DRM_SAVAGE=m
+CONFIG_VGASTATE=m
+CONFIG_VIDEO_OUTPUT_CONTROL=m
+CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+CONFIG_FB_DDC=m
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+CONFIG_FB_SYS_FILLRECT=m
+CONFIG_FB_SYS_COPYAREA=m
+CONFIG_FB_SYS_IMAGEBLIT=m
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+CONFIG_FB_SYS_FOPS=m
+CONFIG_FB_DEFERRED_IO=y
+CONFIG_FB_HECUBA=m
+CONFIG_FB_SVGALIB=m
+# CONFIG_FB_MACMODES is not set
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+
+#
+# Frame buffer hardware drivers
+#
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+CONFIG_FB_CYBER2000=m
+CONFIG_FB_ARC=m
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+CONFIG_FB_VGA16=m
+CONFIG_FB_UVESA=m
+CONFIG_FB_VESA=y
+CONFIG_FB_EFI=y
+CONFIG_FB_IMAC=y
+CONFIG_FB_N411=m
+CONFIG_FB_HGA=m
+CONFIG_FB_HGA_ACCEL=y
+CONFIG_FB_S1D13XXX=m
+CONFIG_FB_NVIDIA=m
+CONFIG_FB_NVIDIA_I2C=y
+# CONFIG_FB_NVIDIA_DEBUG is not set
+CONFIG_FB_NVIDIA_BACKLIGHT=y
+CONFIG_FB_RIVA=m
+CONFIG_FB_RIVA_I2C=y
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_RIVA_BACKLIGHT=y
+CONFIG_FB_LE80578=m
+CONFIG_FB_CARILLO_RANCH=m
+CONFIG_FB_INTEL=m
+# CONFIG_FB_INTEL_DEBUG is not set
+CONFIG_FB_INTEL_I2C=y
+CONFIG_FB_MATROX=m
+CONFIG_FB_MATROX_MILLENIUM=y
+CONFIG_FB_MATROX_MYSTIQUE=y
+CONFIG_FB_MATROX_G=y
+CONFIG_FB_MATROX_I2C=m
+CONFIG_FB_MATROX_MAVEN=m
+CONFIG_FB_MATROX_MULTIHEAD=y
+CONFIG_FB_RADEON=m
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+# CONFIG_FB_RADEON_DEBUG is not set
+CONFIG_FB_ATY128=m
+CONFIG_FB_ATY128_BACKLIGHT=y
+CONFIG_FB_ATY=m
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+# CONFIG_FB_S3 is not set
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+CONFIG_FB_SIS=m
+CONFIG_FB_SIS_300=y
+CONFIG_FB_SIS_315=y
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+CONFIG_FB_VT8623=m
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+CONFIG_FB_ARK=m
+CONFIG_FB_PM3=m
+CONFIG_FB_CARMINE=m
+CONFIG_FB_CARMINE_DRAM_EVAL=y
+# CONFIG_CARMINE_DRAM_CUSTOM is not set
+CONFIG_FB_GEODE=y
+CONFIG_FB_GEODE_LX=m
+CONFIG_FB_GEODE_GX=m
+CONFIG_FB_GEODE_GX1=m
+CONFIG_FB_SM501=m
+CONFIG_FB_VIRTUAL=m
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_LCD_LTV350QV=m
+CONFIG_LCD_ILI9320=m
+CONFIG_LCD_VGG2432A4=m
+CONFIG_LCD_PLATFORM=m
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_CORGI=m
+CONFIG_BACKLIGHT_PROGEAR=m
+CONFIG_BACKLIGHT_CARILLO_RANCH=m
+CONFIG_BACKLIGHT_MBP_NVIDIA=m
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=m
+
+#
+# Display hardware drivers
+#
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+CONFIG_VIDEO_SELECT=y
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY is not set
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+# CONFIG_LOGO is not set
+
+#
+# Bootsplash configuration
+#
+CONFIG_BOOTSPLASH=y
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_DYNAMIC_MINORS=y
+CONFIG_SND_SUPPORT_OLD_API=y
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_DEBUG=y
+# CONFIG_SND_DEBUG_VERBOSE is not set
+# CONFIG_SND_PCM_XRUN_DEBUG is not set
+CONFIG_SND_VMASTER=y
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DRIVERS=y
+# CONFIG_SND_PCSP is not set
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_MTS64=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+CONFIG_SND_PORTMAN2X4=m
+CONFIG_SND_AC97_POWER_SAVE=y
+CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0
+CONFIG_SND_SB_COMMON=m
+CONFIG_SND_PCI=y
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AW2=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_OXYGEN_LIB=m
+CONFIG_SND_OXYGEN=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+# CONFIG_SND_CS5530 is not set
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+CONFIG_SND_HDA_INTEL=m
+CONFIG_SND_HDA_HWDEP=y
+CONFIG_SND_HDA_INPUT_BEEP=y
+CONFIG_SND_HDA_CODEC_REALTEK=y
+CONFIG_SND_HDA_CODEC_ANALOG=y
+CONFIG_SND_HDA_CODEC_SIGMATEL=y
+CONFIG_SND_HDA_CODEC_VIA=y
+CONFIG_SND_HDA_CODEC_ATIHDMI=y
+CONFIG_SND_HDA_CODEC_NVHDMI=y
+CONFIG_SND_HDA_CODEC_CONEXANT=y
+CONFIG_SND_HDA_CODEC_CMEDIA=y
+CONFIG_SND_HDA_CODEC_SI3054=y
+CONFIG_SND_HDA_GENERIC=y
+CONFIG_SND_HDA_POWER_SAVE=y
+CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_HIFIER=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+CONFIG_SND_INTEL8X0=m
+CONFIG_SND_INTEL8X0M=m
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VIRTUOSO=m
+CONFIG_SND_VX222=m
+CONFIG_SND_YMFPCI=m
+CONFIG_SND_SPI=y
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+CONFIG_SND_USB_CAIAQ=m
+CONFIG_SND_USB_CAIAQ_INPUT=y
+CONFIG_SND_PCMCIA=y
+CONFIG_SND_VXPOCKET=m
+CONFIG_SND_PDAUDIOCF=m
+# CONFIG_SND_SOC is not set
+CONFIG_SOUND_PRIME=m
+CONFIG_SOUND_OSS=m
+CONFIG_SOUND_TRACEINIT=y
+CONFIG_SOUND_DMAP=y
+CONFIG_SOUND_SSCAPE=m
+CONFIG_SOUND_VMIDI=m
+CONFIG_SOUND_TRIX=m
+CONFIG_SOUND_MSS=m
+CONFIG_SOUND_MPU401=m
+CONFIG_SOUND_PAS=m
+CONFIG_SOUND_PSS=m
+CONFIG_PSS_MIXER=y
+# CONFIG_PSS_HAVE_BOOT is not set
+# CONFIG_SOUND_SB is not set
+CONFIG_SOUND_YM3812=m
+CONFIG_SOUND_UART6850=m
+CONFIG_SOUND_AEDSP16=m
+CONFIG_SC6600=y
+CONFIG_SC6600_JOY=y
+CONFIG_SC6600_CDROM=4
+CONFIG_SC6600_CDROMBASE=0x0
+CONFIG_AEDSP16_MSS=y
+# CONFIG_AEDSP16_SBPRO is not set
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=m
+# CONFIG_HID_DEBUG is not set
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=m
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+# CONFIG_LOGIRUMBLEPAD2_FF is not set
+CONFIG_PANTHERLORD_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_ZEROPLUS_FF=y
+CONFIG_USB_HIDDEV=y
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=m
+# CONFIG_USB_DEBUG is not set
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_OTG is not set
+CONFIG_USB_MON=y
+
+#
+# USB Host Controller Drivers
+#
+CONFIG_USB_C67X00_HCD=m
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_ISP116X_HCD=m
+CONFIG_USB_ISP1760_HCD=m
+CONFIG_USB_OHCI_HCD=m
+# CONFIG_USB_OHCI_HCD_SSB is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+# CONFIG_USB_U132_HCD is not set
+CONFIG_USB_SL811_HCD=m
+CONFIG_USB_SL811_CS=m
+CONFIG_USB_R8A66597_HCD=m
+
+#
+# Enable Host or Gadget support to see Inventra options
+#
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+CONFIG_USB_WDM=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+CONFIG_USB_STORAGE_ISD200=y
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+CONFIG_USB_STORAGE_ONETOUCH=y
+CONFIG_USB_STORAGE_KARMA=y
+CONFIG_USB_STORAGE_CYPRESS_ATACB=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+CONFIG_USB_SERIAL=m
+CONFIG_USB_EZUSB=y
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRCABLE=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_CH341=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+CONFIG_USB_SERIAL_GARMIN=m
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_IUU=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KEYSPAN_MPR=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
+CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19=y
+CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
+CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
+CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_MOS7720=m
+CONFIG_USB_SERIAL_MOS7840=m
+CONFIG_USB_SERIAL_MOTOROLA=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_OTI6858=m
+CONFIG_USB_SERIAL_QUALCOMM=m
+CONFIG_USB_SERIAL_SPCP8X5=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_SERIAL_DEBUG=m
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_ADUTUX=m
+CONFIG_USB_RIO500=m
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_BERRY_CHARGE=m
+CONFIG_USB_LED=m
+CONFIG_USB_CYPRESS_CY7C63=m
+CONFIG_USB_CYTHERM=m
+CONFIG_USB_PHIDGET=m
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETMOTORCONTROL=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_FTDI_ELAN=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TRANCEVIBRATOR=m
+CONFIG_USB_IOWARRIOR=m
+# CONFIG_USB_TEST is not set
+CONFIG_USB_ISIGHTFW=m
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+# CONFIG_USB_GADGET is not set
+CONFIG_MMC=m
+# CONFIG_MMC_DEBUG is not set
+# CONFIG_MMC_UNSAFE_RESUME is not set
+
+#
+# MMC/SD Card Drivers
+#
+CONFIG_MMC_BLOCK=m
+CONFIG_MMC_BLOCK_BOUNCE=y
+CONFIG_SDIO_UART=m
+CONFIG_MMC_TEST=m
+
+#
+# MMC/SD Host Controller Drivers
+#
+CONFIG_MMC_SDHCI=m
+CONFIG_MMC_SDHCI_PCI=m
+CONFIG_MMC_RICOH_MMC=m
+CONFIG_MMC_WBSD=m
+CONFIG_MMC_TIFM_SD=m
+CONFIG_MMC_SPI=m
+CONFIG_MMC_SDRICOH_CS=m
+CONFIG_MEMSTICK=m
+# CONFIG_MEMSTICK_DEBUG is not set
+
+#
+# MemoryStick drivers
+#
+# CONFIG_MEMSTICK_UNSAFE_RESUME is not set
+CONFIG_MSPRO_BLOCK=m
+
+#
+# MemoryStick Host Controller Drivers
+#
+CONFIG_MEMSTICK_TIFM_MS=m
+CONFIG_MEMSTICK_JMICRON_38X=m
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=m
+
+#
+# LED drivers
+#
+CONFIG_LEDS_PCA9532=m
+CONFIG_LEDS_GPIO=m
+CONFIG_LEDS_CLEVO_MAIL=m
+CONFIG_LEDS_PCA955X=m
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+# CONFIG_ACCESSIBILITY is not set
+CONFIG_INFINIBAND=m
+CONFIG_INFINIBAND_USER_MAD=m
+CONFIG_INFINIBAND_USER_ACCESS=m
+CONFIG_INFINIBAND_USER_MEM=y
+CONFIG_INFINIBAND_ADDR_TRANS=y
+CONFIG_INFINIBAND_MTHCA=m
+CONFIG_INFINIBAND_MTHCA_DEBUG=y
+CONFIG_INFINIBAND_IPATH=m
+CONFIG_INFINIBAND_AMSO1100=m
+# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
+CONFIG_INFINIBAND_CXGB3=m
+# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
+CONFIG_MLX4_INFINIBAND=m
+CONFIG_INFINIBAND_NES=m
+# CONFIG_INFINIBAND_NES_DEBUG is not set
+CONFIG_INFINIBAND_IPOIB=m
+CONFIG_INFINIBAND_IPOIB_CM=y
+CONFIG_INFINIBAND_IPOIB_DEBUG=y
+# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
+CONFIG_INFINIBAND_SRP=m
+CONFIG_INFINIBAND_ISER=m
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_EDAC_E752X=m
+CONFIG_EDAC_I82975X=m
+CONFIG_EDAC_I3000=m
+CONFIG_EDAC_I5000=m
+CONFIG_EDAC_I5100=m
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+CONFIG_RTC_INTF_DEV_UIE_EMUL=y
+CONFIG_RTC_DRV_TEST=m
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1374=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_MAX6900=m
+CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_M41T80=m
+CONFIG_RTC_DRV_M41T80_WDT=y
+CONFIG_RTC_DRV_S35390A=m
+CONFIG_RTC_DRV_FM3130=m
+
+#
+# SPI RTC drivers
+#
+CONFIG_RTC_DRV_M41T94=m
+CONFIG_RTC_DRV_DS1305=m
+CONFIG_RTC_DRV_MAX6902=m
+CONFIG_RTC_DRV_R9701=m
+CONFIG_RTC_DRV_RS5C348=m
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=m
+CONFIG_RTC_DRV_DS1511=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_STK17TA8=m
+CONFIG_RTC_DRV_M48T86=m
+CONFIG_RTC_DRV_M48T59=m
+CONFIG_RTC_DRV_V3020=m
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+CONFIG_INTEL_IOATDMA=m
+CONFIG_DMA_ENGINE=y
+
+#
+# DMA Clients
+#
+CONFIG_NET_DMA=y
+CONFIG_DMATEST=m
+CONFIG_DCA=m
+CONFIG_AUXDISPLAY=y
+# CONFIG_KS0108 is not set
+CONFIG_UIO=m
+CONFIG_UIO_CIF=m
+CONFIG_UIO_PDRV=m
+CONFIG_UIO_PDRV_GENIRQ=m
+CONFIG_UIO_SMX=m
+CONFIG_STAGING=y
+CONFIG_ET131X=m
+# CONFIG_ET131X_DEBUG is not set
+CONFIG_SLICOSS=m
+CONFIG_SXG=m
+CONFIG_ME4000=m
+CONFIG_VIDEO_GO7007=m
+CONFIG_VIDEO_GO7007_USB=m
+CONFIG_USB_IP_COMMON=m
+CONFIG_USB_IP_VHCI_HCD=m
+CONFIG_USB_IP_HOST=m
+CONFIG_W35UND=m
+CONFIG_PRISM2_USB=m
+CONFIG_ECHO=m
+CONFIG_USB_ATMEL=m
+CONFIG_AGNX=m
+CONFIG_OTUS=m
+CONFIG_RT2860=m
+CONFIG_RT2870=m
+CONFIG_RT3070=m
+CONFIG_BENET=m
+CONFIG_RTL8187SE=m
+CONFIG_DRM_PSB=m
+
+#
+# Firmware Drivers
+#
+CONFIG_EDD=m
+# CONFIG_EDD_OFF is not set
+CONFIG_FIRMWARE_MEMMAP=y
+CONFIG_EFI_VARS=m
+CONFIG_DELL_RBU=m
+CONFIG_DCDBAS=m
+CONFIG_DMIID=y
+CONFIG_ISCSI_IBFT_FIND=y
+CONFIG_ISCSI_IBFT=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=m
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_NFS4ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+CONFIG_JBD_DEBUG=y
+CONFIG_JBD2=m
+CONFIG_JBD2_DEBUG=y
+CONFIG_FS_MBCACHE=m
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+CONFIG_JFS_FS=m
+CONFIG_JFS_POSIX_ACL=y
+CONFIG_JFS_SECURITY=y
+# CONFIG_JFS_DEBUG is not set
+CONFIG_JFS_STATISTICS=y
+CONFIG_FS_POSIX_ACL=y
+CONFIG_FS_NFS4ACL=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_DMAPI=m
+CONFIG_XFS_POSIX_ACL=y
+CONFIG_XFS_RT=y
+# CONFIG_XFS_DEBUG is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+CONFIG_OCFS2_FS=m
+CONFIG_OCFS2_FS_O2CB=m
+CONFIG_OCFS2_FS_USERSPACE_CLUSTER=m
+CONFIG_OCFS2_FS_STATS=y
+# CONFIG_OCFS2_DEBUG_MASKLOG is not set
+# CONFIG_OCFS2_DEBUG_FS is not set
+# CONFIG_OCFS2_COMPAT_JBD is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_DMAPI=m
+# CONFIG_DMAPI_DEBUG is not set
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+CONFIG_PRINT_QUOTA_WARNING=y
+CONFIG_QUOTA_TREE=m
+CONFIG_QFMT_V1=m
+CONFIG_QFMT_V2=m
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+CONFIG_NTFS_FS=m
+# CONFIG_NTFS_DEBUG is not set
+CONFIG_NTFS_RW=y
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_VMCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+CONFIG_ADFS_FS=m
+# CONFIG_ADFS_FS_RW is not set
+CONFIG_AFFS_FS=m
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+CONFIG_BEFS_FS=m
+# CONFIG_BEFS_DEBUG is not set
+CONFIG_BFS_FS=m
+CONFIG_EFS_FS=m
+CONFIG_JFFS2_FS=m
+CONFIG_JFFS2_FS_DEBUG=0
+CONFIG_JFFS2_FS_WRITEBUFFER=y
+# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
+CONFIG_JFFS2_SUMMARY=y
+CONFIG_JFFS2_FS_XATTR=y
+CONFIG_JFFS2_FS_POSIX_ACL=y
+CONFIG_JFFS2_FS_SECURITY=y
+CONFIG_JFFS2_COMPRESSION_OPTIONS=y
+CONFIG_JFFS2_ZLIB=y
+# CONFIG_JFFS2_LZO is not set
+CONFIG_JFFS2_RTIME=y
+# CONFIG_JFFS2_RUBIN is not set
+# CONFIG_JFFS2_CMODE_NONE is not set
+CONFIG_JFFS2_CMODE_PRIORITY=y
+# CONFIG_JFFS2_CMODE_SIZE is not set
+# CONFIG_JFFS2_CMODE_FAVOURLZO is not set
+CONFIG_UBIFS_FS=m
+CONFIG_UBIFS_FS_XATTR=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_ZLIB=y
+# CONFIG_UBIFS_FS_DEBUG is not set
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+CONFIG_VXFS_FS=m
+CONFIG_MINIX_FS=y
+CONFIG_OMFS_FS=m
+CONFIG_HPFS_FS=m
+CONFIG_QNX4FS_FS=m
+CONFIG_ROMFS_FS=m
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+CONFIG_UFS_FS_WRITE=y
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_SWAP=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_SUNRPC_XPRT_RDMA=m
+CONFIG_SUNRPC_SWAP=y
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+CONFIG_CIFS_STATS=y
+CONFIG_CIFS_STATS2=y
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_DFS_UPCALL=y
+CONFIG_NCP_FS=m
+CONFIG_NCPFS_PACKET_SIGNING=y
+CONFIG_NCPFS_IOCTL_LOCKING=y
+CONFIG_NCPFS_STRONG=y
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+CONFIG_NCPFS_SMALLDOS=y
+CONFIG_NCPFS_NLS=y
+CONFIG_NCPFS_EXTRAS=y
+CONFIG_CODA_FS=m
+CONFIG_AFS_FS=m
+# CONFIG_AFS_DEBUG is not set
+CONFIG_9P_FS=m
+CONFIG_NOVFS=m
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+# CONFIG_AMIGA_PARTITION is not set
+CONFIG_ATARI_PARTITION=y
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+# CONFIG_MINIX_SUBPARTITION is not set
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+CONFIG_LDM_PARTITION=y
+# CONFIG_LDM_DEBUG is not set
+CONFIG_SGI_PARTITION=y
+CONFIG_ULTRIX_PARTITION=y
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+CONFIG_SYSV68_PARTITION=y
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=m
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=m
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_DLM=m
+# CONFIG_DLM_DEBUG is not set
+
+#
+# Kernel hacking
+#
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+# CONFIG_PRINTK_TIME is not set
+CONFIG_ENABLE_WARN_DEPRECATED=y
+# CONFIG_ENABLE_MUST_CHECK is not set
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
+# CONFIG_DETECT_SOFTLOCKUP is not set
+CONFIG_SCHED_DEBUG=y
+CONFIG_SCHEDSTATS=y
+CONFIG_TIMER_STATS=y
+# CONFIG_DEBUG_OBJECTS is not set
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
+# CONFIG_DEBUG_LOCK_ALLOC is not set
+# CONFIG_PROVE_LOCKING is not set
+# CONFIG_LOCK_STAT is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_WRITECOUNT is not set
+CONFIG_DEBUG_MEMORY_INIT=y
+# CONFIG_DEBUG_LIST is not set
+# CONFIG_DEBUG_SG is not set
+# CONFIG_FRAME_POINTER is not set
+CONFIG_UNWIND_INFO=y
+CONFIG_STACK_UNWIND=y
+# CONFIG_BOOT_PRINTK_DELAY is not set
+CONFIG_RCU_TORTURE_TEST=m
+# CONFIG_KPROBES_SANITY_TEST is not set
+CONFIG_BACKTRACE_SELF_TEST=m
+CONFIG_LKDTM=m
+# CONFIG_FAULT_INJECTION is not set
+CONFIG_LATENCYTOP=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+CONFIG_HAVE_FTRACE=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+# CONFIG_FTRACE is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SYSPROF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
+CONFIG_PROVIDE_OHCI1394_DMA_INIT=y
+CONFIG_DYNAMIC_PRINTK_DEBUG=y
+# CONFIG_SAMPLES is not set
+CONFIG_HAVE_ARCH_KGDB=y
+# CONFIG_KGDB is not set
+# CONFIG_STRICT_DEVMEM is not set
+# CONFIG_X86_VERBOSE_BOOTUP is not set
+CONFIG_EARLY_PRINTK=y
+CONFIG_EARLY_PRINTK_DBGP=y
+# CONFIG_DEBUG_STACKOVERFLOW is not set
+# CONFIG_DEBUG_STACK_USAGE is not set
+# CONFIG_DEBUG_PAGEALLOC is not set
+# CONFIG_DEBUG_PER_CPU_MAPS is not set
+# CONFIG_X86_PTDUMP is not set
+CONFIG_DEBUG_RODATA=y
+# CONFIG_DEBUG_RODATA_TEST is not set
+# CONFIG_DEBUG_NX_TEST is not set
+# CONFIG_IOMMU_DEBUG is not set
+# CONFIG_MMIOTRACE is not set
+CONFIG_IO_DELAY_TYPE_0X80=0
+CONFIG_IO_DELAY_TYPE_0XED=1
+CONFIG_IO_DELAY_TYPE_UDELAY=2
+CONFIG_IO_DELAY_TYPE_NONE=3
+CONFIG_IO_DELAY_0X80=y
+# CONFIG_IO_DELAY_0XED is not set
+# CONFIG_IO_DELAY_UDELAY is not set
+# CONFIG_IO_DELAY_NONE is not set
+CONFIG_DEFAULT_IO_DELAY_TYPE=0
+# CONFIG_DEBUG_BOOT_PARAMS is not set
+# CONFIG_CPA_DEBUG is not set
+# CONFIG_OPTIMIZE_INLINING is not set
+CONFIG_KDB=y
+CONFIG_KDB_MODULES=m
+CONFIG_KDB_OFF=y
+CONFIG_KDB_CONTINUE_CATASTROPHIC=0
+CONFIG_KDB_USB=y
+CONFIG_KDB_KDUMP=y
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_DEFAULT="apparmor"
+CONFIG_SECURITY_NETWORK=y
+# CONFIG_SECURITY_NETWORK_XFRM is not set
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=0
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=0
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+CONFIG_SECURITY_APPARMOR=y
+CONFIG_SECURITY_APPARMOR_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_APPARMOR_DISABLE=y
+CONFIG_XOR_BLOCKS=m
+CONFIG_ASYNC_CORE=m
+CONFIG_ASYNC_MEMCPY=m
+CONFIG_ASYNC_XOR=m
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_NULL=m
+CONFIG_CRYPTO_CRYPTD=m
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Authenticated Encryption with Associated Data
+#
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_SEQIV=m
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_XTS=m
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_XCBC=m
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=m
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_RMD128=m
+CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_RMD256=m
+CONFIG_CRYPTO_RMD320=m
+CONFIG_CRYPTO_SHA1=m
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_AES_X86_64=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_SALSA20=m
+CONFIG_CRYPTO_SALSA20_X86_64=m
+CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TEA=m
+# CONFIG_CRYPTO_TWOFISH is not set
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+CONFIG_CRYPTO_TWOFISH_X86_64=m
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_DEV_HIFN_795X=m
+CONFIG_CRYPTO_DEV_HIFN_795X_RNG=y
+CONFIG_HAVE_KVM=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_KVM_KMP=y
+# CONFIG_KVM is not set
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
+CONFIG_VIRTIO_BALLOON=m
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+CONFIG_GENERIC_FIND_FIRST_BIT=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_T10DIF=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+CONFIG_CRC7=m
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_GENERIC_ALLOCATOR=y
+CONFIG_REED_SOLOMON=m
+CONFIG_REED_SOLOMON_DEC16=y
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_CHECK_SIGNATURE=y
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686-smp.config
index 8ca1c72..00c421f 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686-smp.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.9-prep.qp3.5.34.4qsnet
-# Mon May 11 23:03:25 2009
+# Sat Nov 24 21:29:36 2007
 #
 CONFIG_X86=y
 CONFIG_MMU=y
@@ -24,7 +24,6 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-# CONFIG_TASK_IO_ACCOUNTING is not set
 CONFIG_SYSCTL=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
@@ -113,7 +112,6 @@ CONFIG_X86_USE_PPRO_CHECKSUM=y
 # CONFIG_X86_HIGH_ENTRY is not set
 CONFIG_HPET_TIMER=y
 CONFIG_HPET_EMULATE_RTC=y
-CONFIG_TICK_DIVIDER=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=32
 CONFIG_SCHED_SMT=y
@@ -543,7 +541,7 @@ CONFIG_SCSI_LOGGING=y
 #
 CONFIG_SCSI_SPI_ATTRS=m
 CONFIG_SCSI_FC_ATTRS=m
-CONFIG_SCSI_ISCSI_ATTRS=m
+# CONFIG_SCSI_ISCSI_ATTRS is not set
 
 #
 # SCSI low-level drivers
@@ -590,7 +588,7 @@ CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
 # CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_ISCSI_SFNET=m
+# CONFIG_SCSI_ISCSI_SFNET is not set
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
 # CONFIG_SCSI_IZIP_EPP16 is not set
@@ -617,7 +615,6 @@ CONFIG_SCSI_QLA2300=m
 CONFIG_SCSI_QLA2322=m
 CONFIG_SCSI_QLA6312=m
 CONFIG_SCSI_QLA24XX=m
-CONFIG_SCSI_QLA25XX=m
 CONFIG_SCSI_QLA4XXX=m
 # CONFIG_SCSI_SYM53C416 is not set
 # CONFIG_SCSI_DC395x is not set
@@ -684,7 +681,6 @@ CONFIG_DM_MIRROR=m
 CONFIG_DM_ZERO=m
 CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
-CONFIG_DM_MULTIPATH_HP=m
 
 #
 # Fusion MPT device support
@@ -771,7 +767,6 @@ CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
 CONFIG_INET_TUNNEL=m
-CONFIG_INET_LRO=m
 
 #
 # IP: Virtual Server Configuration
@@ -1159,16 +1154,12 @@ CONFIG_QLA3XXX=m
 #
 # Ethernet (10000 Mbit)
 #
-CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_NETXEN_NIC=m
-CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
 
 #
 # Token Ring devices
@@ -1934,6 +1925,7 @@ CONFIG_SND_AU8810=m
 CONFIG_SND_AU8820=m
 CONFIG_SND_AU8830=m
 CONFIG_SND_AZT3328=m
+CONFIG_SND_AZX=m
 CONFIG_SND_BT87X=m
 CONFIG_SND_CS46XX=m
 CONFIG_SND_CS46XX_NEW_DSP=y
@@ -1945,7 +1937,6 @@ CONFIG_SND_NM256=m
 CONFIG_SND_RME32=m
 CONFIG_SND_RME96=m
 CONFIG_SND_RME9652=m
-CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_TRIDENT=m
 CONFIG_SND_YMFPCI=m
@@ -2177,31 +2168,7 @@ CONFIG_USB_SPEEDTOUCH=m
 #
 # InfiniBand support
 #
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-# CONFIG_INFINIBAND_QLGC_VNIC_STATS is not set
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS)
@@ -2217,8 +2184,6 @@ CONFIG_EDAC_AMD76X=m
 CONFIG_EDAC_E7XXX=m
 CONFIG_EDAC_E752X=m
 CONFIG_EDAC_I82875P=m
-CONFIG_EDAC_I3000=m
-CONFIG_EDAC_I5000=m
 CONFIG_EDAC_I82860=m
 CONFIG_EDAC_K8=m
 CONFIG_EDAC_R82600=m
@@ -2340,11 +2305,8 @@ CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
-# CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2487,13 +2449,6 @@ CONFIG_CRYPTO_CRC32C=m
 CONFIG_CRYPTO_SIGNATURE=y
 CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
-CONFIG_XEN_BLKDEV_FRONTEND=m
-CONFIG_XEN_NETDEV_FRONTEND=m
-
-#
-# Xen PV-ON-HVM Configuration
-#
-CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686.config
index 19759cb..6a51a21 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-i686.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.9-prep.qp3.5.34.4qsnet
-# Mon May 11 23:04:01 2009
+# Sat Nov 24 21:30:07 2007
 #
 CONFIG_X86=y
 CONFIG_MMU=y
@@ -25,7 +25,6 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-# CONFIG_TASK_IO_ACCOUNTING is not set
 CONFIG_SYSCTL=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
@@ -111,7 +110,6 @@ CONFIG_X86_USE_PPRO_CHECKSUM=y
 # CONFIG_X86_HIGH_ENTRY is not set
 CONFIG_HPET_TIMER=y
 CONFIG_HPET_EMULATE_RTC=y
-CONFIG_TICK_DIVIDER=y
 # CONFIG_SMP is not set
 # CONFIG_PREEMPT is not set
 CONFIG_PREEMPT_VOLUNTARY=y
@@ -132,10 +130,9 @@ CONFIG_EDD=m
 CONFIG_DELL_RBU=m
 CONFIG_DCDBAS=m
 # CONFIG_NOHIGHMEM is not set
-# CONFIG_HIGHMEM4G is not set
-CONFIG_HIGHMEM64G=y
+CONFIG_HIGHMEM4G=y
+# CONFIG_HIGHMEM64G is not set
 CONFIG_HIGHMEM=y
-CONFIG_X86_PAE=y
 CONFIG_HIGHPTE=y
 # CONFIG_MATH_EMULATION is not set
 CONFIG_MTRR=y
@@ -530,7 +527,7 @@ CONFIG_SCSI_LOGGING=y
 #
 CONFIG_SCSI_SPI_ATTRS=m
 CONFIG_SCSI_FC_ATTRS=m
-CONFIG_SCSI_ISCSI_ATTRS=m
+# CONFIG_SCSI_ISCSI_ATTRS is not set
 
 #
 # SCSI low-level drivers
@@ -577,7 +574,7 @@ CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
 # CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_ISCSI_SFNET=m
+# CONFIG_SCSI_ISCSI_SFNET is not set
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
 # CONFIG_SCSI_IZIP_EPP16 is not set
@@ -604,7 +601,6 @@ CONFIG_SCSI_QLA2300=m
 CONFIG_SCSI_QLA2322=m
 CONFIG_SCSI_QLA6312=m
 CONFIG_SCSI_QLA24XX=m
-CONFIG_SCSI_QLA25XX=m
 CONFIG_SCSI_QLA4XXX=m
 # CONFIG_SCSI_SYM53C416 is not set
 # CONFIG_SCSI_DC395x is not set
@@ -671,7 +667,6 @@ CONFIG_DM_MIRROR=m
 CONFIG_DM_ZERO=m
 CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
-CONFIG_DM_MULTIPATH_HP=m
 
 #
 # Fusion MPT device support
@@ -758,7 +753,6 @@ CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
 CONFIG_INET_TUNNEL=m
-CONFIG_INET_LRO=m
 
 #
 # IP: Virtual Server Configuration
@@ -1148,16 +1142,12 @@ CONFIG_QLA3XXX=m
 #
 # Ethernet (10000 Mbit)
 #
-CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_NETXEN_NIC=m
-CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
 
 #
 # Token Ring devices
@@ -1315,7 +1305,7 @@ CONFIG_ISDN_TTY_FAX=y
 #
 # ISDN feature submodules
 #
-# CONFIG_ISDN_DRV_LOOP is not set
+CONFIG_ISDN_DRV_LOOP=m
 
 #
 # ISDN4Linux hardware drivers
@@ -1395,7 +1385,8 @@ CONFIG_ISDN_DRV_PCBIT=m
 CONFIG_ISDN_DRV_SC=m
 CONFIG_ISDN_DRV_ACT2000=m
 CONFIG_ISDN_DRV_TPAM=m
-# CONFIG_HYSDN is not set
+CONFIG_HYSDN=m
+CONFIG_HYSDN_CAPI=y
 
 #
 # CAPI subsystem
@@ -1782,6 +1773,7 @@ CONFIG_VIDEO_BT848=m
 # CONFIG_TUNER_3036 is not set
 # CONFIG_VIDEO_STRADIS is not set
 # CONFIG_VIDEO_ZORAN is not set
+# CONFIG_VIDEO_MEYE is not set
 # CONFIG_VIDEO_SAA7134 is not set
 # CONFIG_VIDEO_MXB is not set
 # CONFIG_VIDEO_DPC is not set
@@ -1940,6 +1932,7 @@ CONFIG_SND_AU8810=m
 CONFIG_SND_AU8820=m
 CONFIG_SND_AU8830=m
 CONFIG_SND_AZT3328=m
+CONFIG_SND_AZX=m
 CONFIG_SND_BT87X=m
 CONFIG_SND_CS46XX=m
 CONFIG_SND_CS46XX_NEW_DSP=y
@@ -1951,7 +1944,6 @@ CONFIG_SND_NM256=m
 CONFIG_SND_RME32=m
 CONFIG_SND_RME96=m
 CONFIG_SND_RME9652=m
-CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_TRIDENT=m
 CONFIG_SND_YMFPCI=m
@@ -2121,7 +2113,7 @@ CONFIG_USB_USS720=m
 CONFIG_USB_SERIAL=m
 CONFIG_USB_SERIAL_GENERIC=y
 CONFIG_USB_SERIAL_BELKIN=m
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
+CONFIG_USB_SERIAL_WHITEHEAT=m
 CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
 CONFIG_USB_SERIAL_EMPEG=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
@@ -2184,31 +2176,7 @@ CONFIG_USB_SPEEDTOUCH=m
 #
 # InfiniBand support
 #
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-# CONFIG_INFINIBAND_QLGC_VNIC_STATS is not set
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS)
@@ -2224,8 +2192,6 @@ CONFIG_EDAC_AMD76X=m
 CONFIG_EDAC_E7XXX=m
 CONFIG_EDAC_E752X=m
 CONFIG_EDAC_I82875P=m
-CONFIG_EDAC_I3000=m
-CONFIG_EDAC_I5000=m
 CONFIG_EDAC_I82860=m
 CONFIG_EDAC_K8=m
 CONFIG_EDAC_R82600=m
@@ -2347,11 +2313,8 @@ CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
-# CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2492,13 +2455,6 @@ CONFIG_CRYPTO_CRC32C=m
 CONFIG_CRYPTO_SIGNATURE=y
 CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
-CONFIG_XEN_BLKDEV_FRONTEND=m
-CONFIG_XEN_NETDEV_FRONTEND=m
-
-#
-# Xen PV-ON-HVM Configuration
-#
-CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64-smp.config
index 66aeb31..525a396 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64-smp.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.9-prep.qp3.5.34.4qsnet
-# Mon May 11 23:04:35 2009
+# Sat Nov 24 21:28:15 2007
 #
 
 #
@@ -19,7 +19,6 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-# CONFIG_TASK_IO_ACCOUNTING is not set
 CONFIG_SYSCTL=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
@@ -313,7 +312,7 @@ CONFIG_SCSI_LOGGING=y
 #
 CONFIG_SCSI_SPI_ATTRS=m
 CONFIG_SCSI_FC_ATTRS=m
-CONFIG_SCSI_ISCSI_ATTRS=m
+# CONFIG_SCSI_ISCSI_ATTRS is not set
 
 #
 # SCSI low-level drivers
@@ -352,7 +351,7 @@ CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
 # CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_ISCSI_SFNET=m
+# CONFIG_SCSI_ISCSI_SFNET is not set
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
 # CONFIG_SCSI_IZIP_EPP16 is not set
@@ -375,7 +374,6 @@ CONFIG_SCSI_QLA2300=m
 CONFIG_SCSI_QLA2322=m
 CONFIG_SCSI_QLA6312=m
 CONFIG_SCSI_QLA24XX=m
-CONFIG_SCSI_QLA25XX=m
 CONFIG_SCSI_QLA4XXX=m
 # CONFIG_SCSI_DC395x is not set
 # CONFIG_SCSI_DC390T is not set
@@ -430,7 +428,6 @@ CONFIG_DM_MIRROR=m
 CONFIG_DM_ZERO=m
 CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
-CONFIG_DM_MULTIPATH_HP=m
 
 #
 # Fusion MPT device support
@@ -513,7 +510,6 @@ CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
 CONFIG_INET_TUNNEL=m
-CONFIG_INET_LRO=m
 
 #
 # IP: Virtual Server Configuration
@@ -875,16 +871,12 @@ CONFIG_QLA3XXX=m
 #
 # Ethernet (10000 Mbit)
 #
-CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_NETXEN_NIC=m
-CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
 
 #
 # Token Ring devices
@@ -1316,7 +1308,6 @@ CONFIG_I2C_ISA=m
 CONFIG_I2C_NFORCE2=m
 # CONFIG_I2C_PARPORT is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-CONFIG_I2C_PIIX4=m
 CONFIG_I2C_PROSAVAGE=m
 CONFIG_I2C_SAVAGE4=m
 # CONFIG_SCx200_ACB is not set
@@ -1520,6 +1511,7 @@ CONFIG_SND_AU8810=m
 CONFIG_SND_AU8820=m
 CONFIG_SND_AU8830=m
 CONFIG_SND_AZT3328=m
+CONFIG_SND_AZX=m
 CONFIG_SND_BT87X=m
 CONFIG_SND_CS46XX=m
 CONFIG_SND_CS46XX_NEW_DSP=y
@@ -1531,7 +1523,6 @@ CONFIG_SND_NM256=m
 CONFIG_SND_RME32=m
 CONFIG_SND_RME96=m
 CONFIG_SND_RME9652=m
-CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_TRIDENT=m
 CONFIG_SND_YMFPCI=m
@@ -1760,32 +1751,7 @@ CONFIG_USB_SPEEDTOUCH=m
 #
 # InfiniBand support
 #
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-# CONFIG_INFINIBAND_QLGC_VNIC_STATS is not set
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS)
@@ -1900,11 +1866,8 @@ CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
-# CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64.config
index be12f36..bfa15ba 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-ia64.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.9-prep.qp3.5.34.4qsnet
-# Mon May 11 23:05:07 2009
+# Sat Nov 24 21:28:54 2007
 #
 
 #
@@ -9,7 +9,6 @@
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
@@ -20,7 +19,6 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-# CONFIG_TASK_IO_ACCOUNTING is not set
 CONFIG_SYSCTL=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
@@ -53,6 +51,7 @@ CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SIG=y
 # CONFIG_MODULE_SIG_FORCE is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
 
 #
 # Processor type and features
@@ -83,8 +82,12 @@ CONFIG_IA64_CYCLONE=y
 CONFIG_IOSAPIC=y
 CONFIG_IA64_LOCAL_APIC_INFO_MOD=m
 CONFIG_FORCE_MAX_ZONEORDER=18
-# CONFIG_SMP is not set
+CONFIG_SMP=y
+CONFIG_NR_CPUS=64
+# CONFIG_HOTPLUG_CPU is not set
+CONFIG_SCHED_SMT=y
 # CONFIG_PREEMPT is not set
+CONFIG_HAVE_DEC_LOCK=y
 # CONFIG_IA32_SUPPORT is not set
 CONFIG_IA64_MCA_RECOVERY=m
 CONFIG_PERFMON=y
@@ -309,7 +312,7 @@ CONFIG_SCSI_LOGGING=y
 #
 CONFIG_SCSI_SPI_ATTRS=m
 CONFIG_SCSI_FC_ATTRS=m
-CONFIG_SCSI_ISCSI_ATTRS=m
+# CONFIG_SCSI_ISCSI_ATTRS is not set
 
 #
 # SCSI low-level drivers
@@ -348,7 +351,7 @@ CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
 # CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_ISCSI_SFNET=m
+# CONFIG_SCSI_ISCSI_SFNET is not set
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
 # CONFIG_SCSI_IZIP_EPP16 is not set
@@ -371,7 +374,6 @@ CONFIG_SCSI_QLA2300=m
 CONFIG_SCSI_QLA2322=m
 CONFIG_SCSI_QLA6312=m
 CONFIG_SCSI_QLA24XX=m
-CONFIG_SCSI_QLA25XX=m
 CONFIG_SCSI_QLA4XXX=m
 # CONFIG_SCSI_DC395x is not set
 # CONFIG_SCSI_DC390T is not set
@@ -426,7 +428,6 @@ CONFIG_DM_MIRROR=m
 CONFIG_DM_ZERO=m
 CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
-CONFIG_DM_MULTIPATH_HP=m
 
 #
 # Fusion MPT device support
@@ -509,7 +510,6 @@ CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
 CONFIG_INET_TUNNEL=m
-CONFIG_INET_LRO=m
 
 #
 # IP: Virtual Server Configuration
@@ -816,7 +816,6 @@ CONFIG_DE4X5=m
 CONFIG_WINBOND_840=m
 CONFIG_DM9102=m
 CONFIG_PCMCIA_XIRCOM=m
-# CONFIG_PCMCIA_XIRTULIP is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 CONFIG_PCNET32=m
@@ -872,16 +871,12 @@ CONFIG_QLA3XXX=m
 #
 # Ethernet (10000 Mbit)
 #
-CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_NETXEN_NIC=m
-CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
 
 #
 # Token Ring devices
@@ -1017,7 +1012,6 @@ CONFIG_ISDN_TTY_FAX=y
 #
 # ISDN feature submodules
 #
-# CONFIG_ISDN_DRV_LOOP is not set
 
 #
 # ISDN4Linux hardware drivers
@@ -1083,7 +1077,6 @@ CONFIG_HISAX_HDLC=y
 # Active cards
 #
 CONFIG_ISDN_DRV_TPAM=m
-# CONFIG_HYSDN is not set
 
 #
 # CAPI subsystem
@@ -1187,24 +1180,12 @@ CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
 CONFIG_SERIAL_NONSTANDARD=y
-# CONFIG_COMPUTONE is not set
 # CONFIG_ROCKETPORT is not set
 # CONFIG_CYCLADES is not set
-# CONFIG_DIGIEPCA is not set
-# CONFIG_DIGI is not set
-# CONFIG_MOXA_INTELLIO is not set
-# CONFIG_MOXA_SMARTIO is not set
-# CONFIG_ISI is not set
 # CONFIG_SYNCLINK is not set
 # CONFIG_SYNCLINKMP is not set
 CONFIG_N_HDLC=m
-# CONFIG_RISCOM8 is not set
-# CONFIG_SPECIALIX is not set
-# CONFIG_SX is not set
-# CONFIG_RIO is not set
 CONFIG_STALDRV=y
-# CONFIG_STALLION is not set
-# CONFIG_ISTALLION is not set
 CONFIG_SGI_SNSC=y
 CONFIG_SGI_TIOCX=y
 # CONFIG_SGI_MBCS is not set
@@ -1327,7 +1308,6 @@ CONFIG_I2C_ISA=m
 CONFIG_I2C_NFORCE2=m
 # CONFIG_I2C_PARPORT is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-CONFIG_I2C_PIIX4=m
 CONFIG_I2C_PROSAVAGE=m
 CONFIG_I2C_SAVAGE4=m
 # CONFIG_SCx200_ACB is not set
@@ -1380,7 +1360,7 @@ CONFIG_SENSORS_RTC8564=m
 #
 # Hardware Monitoring support
 #
-CONFIG_HWMON=m
+CONFIG_HWMON=y
 CONFIG_HWMON_VID=m
 CONFIG_SENSORS_ADM1026=m
 CONFIG_SENSORS_LM87=m
@@ -1531,6 +1511,7 @@ CONFIG_SND_AU8810=m
 CONFIG_SND_AU8820=m
 CONFIG_SND_AU8830=m
 CONFIG_SND_AZT3328=m
+CONFIG_SND_AZX=m
 CONFIG_SND_BT87X=m
 CONFIG_SND_CS46XX=m
 CONFIG_SND_CS46XX_NEW_DSP=y
@@ -1542,7 +1523,6 @@ CONFIG_SND_NM256=m
 CONFIG_SND_RME32=m
 CONFIG_SND_RME96=m
 CONFIG_SND_RME9652=m
-CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_TRIDENT=m
 CONFIG_SND_YMFPCI=m
@@ -1709,7 +1689,6 @@ CONFIG_USB_USS720=m
 CONFIG_USB_SERIAL=m
 CONFIG_USB_SERIAL_GENERIC=y
 CONFIG_USB_SERIAL_BELKIN=m
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
 CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
 CONFIG_USB_SERIAL_EMPEG=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
@@ -1772,32 +1751,7 @@ CONFIG_USB_SPEEDTOUCH=m
 #
 # InfiniBand support
 #
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-# CONFIG_INFINIBAND_QLGC_VNIC_STATS is not set
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS)
@@ -1912,11 +1866,8 @@ CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
-# CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64-smp.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64-smp.config
index 6cbeb0b..47daf08 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64-smp.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64-smp.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.9-prep.qp3.5.34.4qsnet
-# Mon May 11 22:59:53 2009
+# Sat Nov 24 21:26:14 2007
 #
 CONFIG_X86_64=y
 CONFIG_64BIT=y
@@ -13,7 +13,6 @@ CONFIG_EARLY_PRINTK=y
 CONFIG_HPET_TIMER=y
 CONFIG_X86_PM_TIMER=y
 CONFIG_HPET_EMULATE_RTC=y
-CONFIG_TICK_DIVIDER=y
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_IOMAP=y
 
@@ -32,7 +31,6 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-# CONFIG_TASK_IO_ACCOUNTING is not set
 CONFIG_SYSCTL=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
@@ -447,7 +445,7 @@ CONFIG_SCSI_LOGGING=y
 #
 CONFIG_SCSI_SPI_ATTRS=m
 CONFIG_SCSI_FC_ATTRS=m
-CONFIG_SCSI_ISCSI_ATTRS=m
+# CONFIG_SCSI_ISCSI_ATTRS is not set
 
 #
 # SCSI low-level drivers
@@ -486,7 +484,7 @@ CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
 # CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_ISCSI_SFNET=m
+# CONFIG_SCSI_ISCSI_SFNET is not set
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
 # CONFIG_SCSI_IZIP_EPP16 is not set
@@ -509,7 +507,6 @@ CONFIG_SCSI_QLA2300=m
 CONFIG_SCSI_QLA2322=m
 CONFIG_SCSI_QLA6312=m
 CONFIG_SCSI_QLA24XX=m
-CONFIG_SCSI_QLA25XX=m
 CONFIG_SCSI_QLA4XXX=m
 # CONFIG_SCSI_DC395x is not set
 # CONFIG_SCSI_DC390T is not set
@@ -564,7 +561,6 @@ CONFIG_DM_MIRROR=m
 CONFIG_DM_ZERO=m
 CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
-CONFIG_DM_MULTIPATH_HP=m
 
 #
 # Fusion MPT device support
@@ -651,7 +647,6 @@ CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
 CONFIG_INET_TUNNEL=m
-CONFIG_INET_LRO=m
 
 #
 # IP: Virtual Server Configuration
@@ -1013,16 +1008,12 @@ CONFIG_QLA3XXX=m
 #
 # Ethernet (10000 Mbit)
 #
-CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_NETXEN_NIC=m
-CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
 
 #
 # Token Ring devices
@@ -1481,7 +1472,6 @@ CONFIG_I2C_ISA=m
 CONFIG_I2C_NFORCE2=m
 # CONFIG_I2C_PARPORT is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-CONFIG_I2C_PIIX4=m
 CONFIG_I2C_PROSAVAGE=m
 CONFIG_I2C_SAVAGE4=m
 # CONFIG_SCx200_ACB is not set
@@ -1692,6 +1682,7 @@ CONFIG_SND_AU8810=m
 CONFIG_SND_AU8820=m
 CONFIG_SND_AU8830=m
 CONFIG_SND_AZT3328=m
+CONFIG_SND_AZX=m
 CONFIG_SND_BT87X=m
 CONFIG_SND_CS46XX=m
 CONFIG_SND_CS46XX_NEW_DSP=y
@@ -1703,7 +1694,6 @@ CONFIG_SND_NM256=m
 CONFIG_SND_RME32=m
 CONFIG_SND_RME96=m
 CONFIG_SND_RME9652=m
-CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_TRIDENT=m
 CONFIG_SND_YMFPCI=m
@@ -1932,32 +1922,7 @@ CONFIG_USB_SPEEDTOUCH=m
 #
 # InfiniBand support
 #
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-# CONFIG_INFINIBAND_QLGC_VNIC_STATS is not set
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS)
@@ -1973,8 +1938,6 @@ CONFIG_EDAC_AMD76X=m
 CONFIG_EDAC_E7XXX=m
 CONFIG_EDAC_E752X=m
 CONFIG_EDAC_I82875P=m
-CONFIG_EDAC_I3000=m
-CONFIG_EDAC_I5000=m
 CONFIG_EDAC_I82860=m
 CONFIG_EDAC_K8=m
 CONFIG_EDAC_R82600=m
@@ -2103,11 +2066,8 @@ CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
-# CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2242,13 +2202,6 @@ CONFIG_CRYPTO_CRC32C=m
 CONFIG_CRYPTO_SIGNATURE=y
 CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
-CONFIG_XEN_BLKDEV_FRONTEND=m
-CONFIG_XEN_NETDEV_FRONTEND=m
-
-#
-# Xen PV-ON-HVM Configuration
-#
-CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
diff --git a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64.config b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64.config
index 5d50282..7808716 100644
--- a/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64.config
+++ b/lustre/kernel_patches/kernel_configs/kernel-2.6.9-2.6-rhel4-x86_64.config
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.9-prep.qp3.5.34.4qsnet
-# Mon May 11 23:00:58 2009
+# Sat Nov 24 21:27:28 2007
 #
 CONFIG_X86_64=y
 CONFIG_64BIT=y
@@ -13,7 +13,6 @@ CONFIG_EARLY_PRINTK=y
 CONFIG_HPET_TIMER=y
 CONFIG_X86_PM_TIMER=y
 CONFIG_HPET_EMULATE_RTC=y
-CONFIG_TICK_DIVIDER=y
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_GENERIC_IOMAP=y
 
@@ -22,7 +21,6 @@ CONFIG_GENERIC_IOMAP=y
 #
 CONFIG_EXPERIMENTAL=y
 CONFIG_CLEAN_COMPILE=y
-CONFIG_BROKEN_ON_SMP=y
 
 #
 # General setup
@@ -33,7 +31,6 @@ CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_BSD_PROCESS_ACCT=y
 # CONFIG_BSD_PROCESS_ACCT_V3 is not set
-# CONFIG_TASK_IO_ACCOUNTING is not set
 CONFIG_SYSCTL=y
 CONFIG_AUDIT=y
 CONFIG_AUDITSYSCALL=y
@@ -66,6 +63,7 @@ CONFIG_MODVERSIONS=y
 CONFIG_MODULE_SIG=y
 # CONFIG_MODULE_SIG_FORCE is not set
 CONFIG_KMOD=y
+CONFIG_STOP_MACHINE=y
 
 #
 # Processor type and features
@@ -82,12 +80,19 @@ CONFIG_X86_GOOD_APIC=y
 CONFIG_MICROCODE=m
 CONFIG_X86_MSR=y
 CONFIG_X86_CPUID=y
+CONFIG_X86_HT=y
 CONFIG_X86_IO_APIC=y
 CONFIG_X86_LOCAL_APIC=y
-CONFIG_X86_LOCAL_APIC_INFO_MOD=m
 CONFIG_MTRR=y
-# CONFIG_SMP is not set
+CONFIG_SMP=y
 # CONFIG_PREEMPT is not set
+CONFIG_SCHED_SMT=y
+CONFIG_SCHED_MC=y
+CONFIG_K8_NUMA=y
+CONFIG_DISCONTIGMEM=y
+CONFIG_NUMA=y
+CONFIG_HAVE_DEC_LOCK=y
+CONFIG_NR_CPUS=32
 CONFIG_GART_IOMMU=y
 CONFIG_SWIOTLB=y
 CONFIG_X86_MCE=y
@@ -116,6 +121,7 @@ CONFIG_ACPI_BUTTON=m
 CONFIG_ACPI_FAN=y
 CONFIG_ACPI_PROCESSOR=y
 CONFIG_ACPI_THERMAL=y
+CONFIG_ACPI_NUMA=y
 CONFIG_ACPI_ASUS=m
 CONFIG_ACPI_TOSHIBA=m
 CONFIG_ACPI_BLACKLIST_YEAR=2001
@@ -156,6 +162,7 @@ CONFIG_PCI=y
 CONFIG_PCI_DIRECT=y
 CONFIG_PCI_MMCONFIG=y
 # CONFIG_UNORDERED_IO is not set
+# CONFIG_HOTPLUG_CPU is not set
 CONFIG_PCI_MSI=y
 CONFIG_PCI_LEGACY_PROC=y
 # CONFIG_PCI_NAMES is not set
@@ -438,7 +445,7 @@ CONFIG_SCSI_LOGGING=y
 #
 CONFIG_SCSI_SPI_ATTRS=m
 CONFIG_SCSI_FC_ATTRS=m
-CONFIG_SCSI_ISCSI_ATTRS=m
+# CONFIG_SCSI_ISCSI_ATTRS is not set
 
 #
 # SCSI low-level drivers
@@ -477,7 +484,7 @@ CONFIG_SCSI_GDTH=m
 CONFIG_SCSI_IPS=m
 CONFIG_SCSI_INITIO=m
 # CONFIG_SCSI_INIA100 is not set
-CONFIG_SCSI_ISCSI_SFNET=m
+# CONFIG_SCSI_ISCSI_SFNET is not set
 CONFIG_SCSI_PPA=m
 CONFIG_SCSI_IMM=m
 # CONFIG_SCSI_IZIP_EPP16 is not set
@@ -500,7 +507,6 @@ CONFIG_SCSI_QLA2300=m
 CONFIG_SCSI_QLA2322=m
 CONFIG_SCSI_QLA6312=m
 CONFIG_SCSI_QLA24XX=m
-CONFIG_SCSI_QLA25XX=m
 CONFIG_SCSI_QLA4XXX=m
 # CONFIG_SCSI_DC395x is not set
 # CONFIG_SCSI_DC390T is not set
@@ -555,7 +561,6 @@ CONFIG_DM_MIRROR=m
 CONFIG_DM_ZERO=m
 CONFIG_DM_MULTIPATH=m
 CONFIG_DM_MULTIPATH_EMC=m
-CONFIG_DM_MULTIPATH_HP=m
 
 #
 # Fusion MPT device support
@@ -642,7 +647,6 @@ CONFIG_INET_AH=m
 CONFIG_INET_ESP=m
 CONFIG_INET_IPCOMP=m
 CONFIG_INET_TUNNEL=m
-CONFIG_INET_LRO=m
 
 #
 # IP: Virtual Server Configuration
@@ -949,7 +953,6 @@ CONFIG_DE4X5=m
 CONFIG_WINBOND_840=m
 CONFIG_DM9102=m
 CONFIG_PCMCIA_XIRCOM=m
-# CONFIG_PCMCIA_XIRTULIP is not set
 # CONFIG_HP100 is not set
 CONFIG_NET_PCI=y
 CONFIG_PCNET32=m
@@ -1005,16 +1008,12 @@ CONFIG_QLA3XXX=m
 #
 # Ethernet (10000 Mbit)
 #
-CONFIG_IXGBE=m
 CONFIG_IXGB=m
 CONFIG_IXGB_NAPI=y
-CONFIG_CHELSIO_T3=m
+# CONFIG_CHELSIO_T3 is not set
 CONFIG_S2IO=m
 CONFIG_S2IO_NAPI=y
 CONFIG_NETXEN_NIC=m
-CONFIG_BNX2X=m
-CONFIG_MLX4_CORE=m
-CONFIG_MLX4_DEBUG=y
 
 #
 # Token Ring devices
@@ -1159,7 +1158,6 @@ CONFIG_ISDN_TTY_FAX=y
 #
 # ISDN feature submodules
 #
-# CONFIG_ISDN_DRV_LOOP is not set
 
 #
 # ISDN4Linux hardware drivers
@@ -1225,7 +1223,6 @@ CONFIG_HISAX_HDLC=y
 # Active cards
 #
 CONFIG_ISDN_DRV_TPAM=m
-# CONFIG_HYSDN is not set
 
 #
 # CAPI subsystem
@@ -1330,24 +1327,12 @@ CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
 CONFIG_SERIAL_NONSTANDARD=y
-# CONFIG_COMPUTONE is not set
 # CONFIG_ROCKETPORT is not set
 # CONFIG_CYCLADES is not set
-# CONFIG_DIGIEPCA is not set
-# CONFIG_DIGI is not set
-# CONFIG_MOXA_INTELLIO is not set
-# CONFIG_MOXA_SMARTIO is not set
-# CONFIG_ISI is not set
 # CONFIG_SYNCLINK is not set
 # CONFIG_SYNCLINKMP is not set
 CONFIG_N_HDLC=m
-# CONFIG_RISCOM8 is not set
-# CONFIG_SPECIALIX is not set
-# CONFIG_SX is not set
-# CONFIG_RIO is not set
 CONFIG_STALDRV=y
-# CONFIG_STALLION is not set
-# CONFIG_ISTALLION is not set
 
 #
 # Serial drivers
@@ -1436,7 +1421,6 @@ CONFIG_DTLK=m
 #
 # Ftape, the floppy tape device driver
 #
-# CONFIG_FTAPE is not set
 CONFIG_AGP=y
 CONFIG_AGP_AMD64=y
 CONFIG_AGP_INTEL=y
@@ -1488,7 +1472,6 @@ CONFIG_I2C_ISA=m
 CONFIG_I2C_NFORCE2=m
 # CONFIG_I2C_PARPORT is not set
 # CONFIG_I2C_PARPORT_LIGHT is not set
-CONFIG_I2C_PIIX4=m
 CONFIG_I2C_PROSAVAGE=m
 CONFIG_I2C_SAVAGE4=m
 # CONFIG_SCx200_ACB is not set
@@ -1699,6 +1682,7 @@ CONFIG_SND_AU8810=m
 CONFIG_SND_AU8820=m
 CONFIG_SND_AU8830=m
 CONFIG_SND_AZT3328=m
+CONFIG_SND_AZX=m
 CONFIG_SND_BT87X=m
 CONFIG_SND_CS46XX=m
 CONFIG_SND_CS46XX_NEW_DSP=y
@@ -1710,7 +1694,6 @@ CONFIG_SND_NM256=m
 CONFIG_SND_RME32=m
 CONFIG_SND_RME96=m
 CONFIG_SND_RME9652=m
-CONFIG_SND_HDA_INTEL=m
 CONFIG_SND_HDSP=m
 CONFIG_SND_TRIDENT=m
 CONFIG_SND_YMFPCI=m
@@ -1877,7 +1860,6 @@ CONFIG_USB_USS720=m
 CONFIG_USB_SERIAL=m
 CONFIG_USB_SERIAL_GENERIC=y
 CONFIG_USB_SERIAL_BELKIN=m
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
 CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
 CONFIG_USB_SERIAL_EMPEG=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
@@ -1940,32 +1922,7 @@ CONFIG_USB_SPEEDTOUCH=m
 #
 # InfiniBand support
 #
-CONFIG_INFINIBAND=m
-CONFIG_INFINIBAND_USER_MAD=m
-CONFIG_INFINIBAND_USER_ACCESS=m
-CONFIG_INFINIBAND_USER_MEM=y
-CONFIG_INFINIBAND_ADDR_TRANS=y
-CONFIG_INFINIBAND_MTHCA=m
-CONFIG_INFINIBAND_MTHCA_DEBUG=y
-CONFIG_INFINIBAND_IPATH=m
-CONFIG_INFINIBAND_AMSO1100=m
-# CONFIG_INFINIBAND_AMSO1100_DEBUG is not set
-CONFIG_INFINIBAND_CXGB3=m
-# CONFIG_INFINIBAND_CXGB3_DEBUG is not set
-CONFIG_INFINIBAND_NES=m
-# CONFIG_INFINIBAND_NES_DEBUG is not set
-CONFIG_MLX4_INFINIBAND=m
-CONFIG_INFINIBAND_IPOIB=m
-CONFIG_INFINIBAND_IPOIB_CM=y
-CONFIG_INFINIBAND_IPOIB_DEBUG=y
-# CONFIG_INFINIBAND_IPOIB_DEBUG_DATA is not set
-CONFIG_INFINIBAND_SRP=m
-CONFIG_INFINIBAND_SDP=m
-# CONFIG_INFINIBAND_SDP_DEBUG is not set
-CONFIG_INFINIBAND_QLGC_VNIC=m
-# CONFIG_INFINIBAND_QLGC_VNIC_DEBUG is not set
-# CONFIG_INFINIBAND_QLGC_VNIC_STATS is not set
-CONFIG_INFINIBAND_MADEYE=m
+# CONFIG_INFINIBAND is not set
 
 #
 # EDAC - error detection and reporting (RAS)
@@ -1981,8 +1938,6 @@ CONFIG_EDAC_AMD76X=m
 CONFIG_EDAC_E7XXX=m
 CONFIG_EDAC_E752X=m
 CONFIG_EDAC_I82875P=m
-CONFIG_EDAC_I3000=m
-CONFIG_EDAC_I5000=m
 CONFIG_EDAC_I82860=m
 CONFIG_EDAC_K8=m
 CONFIG_EDAC_R82600=m
@@ -2111,11 +2066,8 @@ CONFIG_SMB_FS=m
 # CONFIG_SMB_NLS_DEFAULT is not set
 CONFIG_CIFS=m
 # CONFIG_CIFS_STATS is not set
-CONFIG_CIFS_WEAK_PW_HASH=y
 CONFIG_CIFS_XATTR=y
 CONFIG_CIFS_POSIX=y
-# CONFIG_CIFS_DEBUG2 is not set
-# CONFIG_CIFS_EXPERIMENTAL is not set
 # CONFIG_NCP_FS is not set
 # CONFIG_CODA_FS is not set
 # CONFIG_AFS_FS is not set
@@ -2199,7 +2151,6 @@ CONFIG_MAGIC_SYSRQ=y
 CONFIG_DEBUG_SPINLOCK=y
 CONFIG_DEBUG_SPINLOCK_SLEEP=y
 CONFIG_DEBUG_INFO=y
-# CONFIG_CHECKING is not set
 CONFIG_INIT_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_IOMMU_DEBUG is not set
@@ -2251,13 +2202,6 @@ CONFIG_CRYPTO_CRC32C=m
 CONFIG_CRYPTO_SIGNATURE=y
 CONFIG_CRYPTO_SIGNATURE_DSA=y
 CONFIG_CRYPTO_MPILIB=y
-CONFIG_XEN_BLKDEV_FRONTEND=m
-CONFIG_XEN_NETDEV_FRONTEND=m
-
-#
-# Xen PV-ON-HVM Configuration
-#
-CONFIG_XEN_PV_ON_HVM=y
 
 #
 # Library routines
diff --git a/lustre/kernel_patches/patches/dev_read_only-2.6-fc5.patch b/lustre/kernel_patches/patches/dev_read_only-2.6-fc5.patch
index 51c7f66..8969f25 100644
--- a/lustre/kernel_patches/patches/dev_read_only-2.6-fc5.patch
+++ b/lustre/kernel_patches/patches/dev_read_only-2.6-fc5.patch
@@ -130,16 +130,17 @@ Index: linux-2.6.16.i686/fs/block_dev.c
  	up(&bdev->bd_sem);
 Index: linux-2.6.16.i686/include/linux/fs.h
 ===================================================================
---- linux-2.6.16.i686.orig/include/linux/fs.h
-+++ linux-2.6.16.i686/include/linux/fs.h
-@@ -1595,6 +1595,10 @@ extern void file_kill(struct file *f);
- struct bio;
- extern void submit_bio(int, struct bio *);
- extern int bdev_read_only(struct block_device *);
+--- linux-2.6.16.i686.orig/include/linux/blkdev.h
++++ linux-2.6.16.i686/include/linux/blkdev.h
+@@ -1595,6 +1595,11 @@ extern void file_kill(struct file *f);
+ } \
+ )
+ #endif 
++
 +#define HAVE_CLEAR_RDONLY_ON_PUT
 +void dev_set_rdonly(struct block_device *bdev);
 +int dev_check_rdonly(struct block_device *bdev);
 +void dev_clear_rdonly(struct block_device *bdev);
- extern int set_blocksize(struct block_device *, int);
- extern int sb_set_blocksize(struct super_block *, int);
- extern int sb_min_blocksize(struct super_block *, int);
+ 
+ #define MODULE_ALIAS_BLOCKDEV(major,minor) \
+ 	MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
diff --git a/lustre/kernel_patches/patches/dev_read_only-2.6.27-vanilla.patch b/lustre/kernel_patches/patches/dev_read_only-2.6.27-vanilla.patch
new file mode 100644
index 0000000..579614f
--- /dev/null
+++ b/lustre/kernel_patches/patches/dev_read_only-2.6.27-vanilla.patch
@@ -0,0 +1,145 @@
+Index: linux-2.6.27.21-0.1/block/blk-core.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/block/blk-core.c	2009-04-23 02:12:51.000000000 -0600
++++ linux-2.6.27.21-0.1/block/blk-core.c	2009-05-22 08:38:02.000000000 -0600
+@@ -1335,6 +1335,8 @@
+ 
+ #endif /* CONFIG_FAIL_MAKE_REQUEST */
+ 
++int dev_check_rdonly(struct block_device *bdev);
++
+ /*
+  * Check whether this bio extends beyond the end of the device.
+  */
+@@ -1436,6 +1438,12 @@
+ 
+ 		if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
+ 			goto end_io;
++		/* this is cfs's dev_rdonly check */
++		if (bio->bi_rw == WRITE &&
++				dev_check_rdonly(bio->bi_bdev)) {
++			bio_endio(bio, 0);
++			break;
++		}
+ 
+ 		if (should_fail_request(bio))
+ 			goto end_io;
+@@ -2189,6 +2197,91 @@
+ }
+ EXPORT_SYMBOL(kblockd_flush_work);
+ 
++ /*
++ * Debug code for turning block devices "read-only" (will discard writes
++ * silently).  This is for filesystem crash/recovery testing.
++ */
++struct deventry {
++	dev_t dev;
++	struct deventry *next;
++};
++
++static struct deventry *devlist = NULL;
++static spinlock_t devlock = SPIN_LOCK_UNLOCKED; 
++
++int dev_check_rdonly(struct block_device *bdev) 
++{
++	struct deventry *cur;
++	if (!bdev) return 0;
++	spin_lock(&devlock);
++	cur = devlist;
++	while(cur) {
++		if (bdev->bd_dev == cur->dev) {
++			spin_unlock(&devlock);
++			return 1;
++	}
++		cur = cur->next;
++	}
++	spin_unlock(&devlock);
++	return 0;
++}
++
++void dev_set_rdonly(struct block_device *bdev)
++{
++	struct deventry *newdev, *cur;
++
++	if (!bdev) 
++		return;
++	newdev = kmalloc(sizeof(struct deventry), GFP_KERNEL);
++	if (!newdev) 
++		return;
++	
++	spin_lock(&devlock);
++	cur = devlist;
++	while(cur) {
++		if (bdev->bd_dev == cur->dev) {
++			spin_unlock(&devlock);
++			kfree(newdev);
++			return;
++		}
++		cur = cur->next;
++	}
++	newdev->dev = bdev->bd_dev;
++	newdev->next = devlist;
++	devlist = newdev;
++	spin_unlock(&devlock);
++	printk(KERN_WARNING "Turning device %s (%#x) read-only\n",
++	       bdev->bd_disk ? bdev->bd_disk->disk_name : "", bdev->bd_dev);
++}
++
++void dev_clear_rdonly(struct block_device *bdev) 
++{
++	struct deventry *cur, *last = NULL;
++	if (!bdev) return;
++	spin_lock(&devlock);
++	cur = devlist;
++	while(cur) {
++		if (bdev->bd_dev == cur->dev) {
++			if (last) 
++				last->next = cur->next;
++			else
++				devlist = cur->next;
++			spin_unlock(&devlock);
++			kfree(cur);
++			printk(KERN_WARNING "Removing read-only on %s (%#x)\n",
++			       bdev->bd_disk ? bdev->bd_disk->disk_name :
++					       "unknown block", bdev->bd_dev);
++			return;
++		}
++		last = cur;
++		cur = cur->next;
++	}
++	spin_unlock(&devlock);
++}
++
++EXPORT_SYMBOL(dev_set_rdonly);
++EXPORT_SYMBOL(dev_clear_rdonly);
++EXPORT_SYMBOL(dev_check_rdonly);
+ int __init blk_dev_init(void)
+ {
+ 	kblockd_workqueue = create_workqueue("kblockd");
+Index: linux-2.6.27.21-0.1/fs/block_dev.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/block_dev.c	2009-04-23 02:12:56.000000000 -0600
++++ linux-2.6.27.21-0.1/fs/block_dev.c	2009-05-22 08:38:02.000000000 -0600
+@@ -1208,6 +1208,7 @@
+ 		if (bdev != bdev->bd_contains)
+ 			victim = bdev->bd_contains;
+ 		bdev->bd_contains = NULL;
++		dev_clear_rdonly(bdev);
+ 	}
+ 	unlock_kernel();
+ 	mutex_unlock(&bdev->bd_mutex);
+Index: linux-2.6.27.21-0.1/include/linux/fs.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/include/linux/fs.h	2009-05-22 08:38:00.000000000 -0600
++++ linux-2.6.27.21-0.1/include/linux/fs.h	2009-05-22 08:38:02.000000000 -0600
+@@ -1898,6 +1898,10 @@
+ extern void submit_bio(int, struct bio *);
+ extern int bdev_read_only(struct block_device *);
+ #endif
++#define HAVE_CLEAR_RDONLY_ON_PUT
++extern void dev_set_rdonly(struct block_device *bdev);
++extern int dev_check_rdonly(struct block_device *bdev);
++extern void dev_clear_rdonly(struct block_device *bdev);
+ extern int set_blocksize(struct block_device *, int);
+ extern int sb_set_blocksize(struct super_block *, int);
+ extern int sb_min_blocksize(struct super_block *, int);
diff --git a/lustre/kernel_patches/patches/export-2.6.27-vanilla.patch b/lustre/kernel_patches/patches/export-2.6.27-vanilla.patch
new file mode 100644
index 0000000..0a979c3
--- /dev/null
+++ b/lustre/kernel_patches/patches/export-2.6.27-vanilla.patch
@@ -0,0 +1,37 @@
+Index: linux-2.6/fs/jbd/journal.c
+===================================================================
+--- linux-2.6.orig/fs/jbd2/journal.c	2006-07-15 16:13:50.000000000 +0800
++++ linux-2.6/fs/jbd2/journal.c	2006-07-15 16:22:04.000000000 +0800
+@@ -74,6 +74,7 @@ EXPORT_SYMBOL(journal_abort);
+ 	spin_unlock(&journal->j_state_lock);
+ 	return ret;
+ }
++EXPORT_SYMBOL(jbd2_log_start_commit);
+ 
+ /*
+  * Force and wait upon a commit if the calling process is not within
+Index: linux-2.6/kernel/sys.c
+===================================================================
+--- linux-2.6.orig/kernel/sys.c	2006-07-15 16:13:50.000000000 +0800
++++ linux-2.6/kernel/sys.c	2006-07-15 16:22:04.000000000 +0800
+@@ -74,6 +74,8 @@
+ EXPORT_SYMBOL(in_egroup_p);
+ 
+ DECLARE_RWSEM(uts_sem);
++
++EXPORT_SYMBOL(uts_sem);
+ 
+ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
+ {
+Index: linux-2.6/kernel/sys.c
+===================================================================
+--- linux-2.6.orig/security/security.c
++++ linux-2.6/security/security.c
+@@ -74,6 +74,7 @@
+ 		return 0;
+ 	return security_ops->inode_unlink(dir, dentry, mnt);
+ }
++EXPORT_SYMBOL(security_inode_unlink);
+ 
+ int security_inode_symlink(struct inode *dir, struct dentry *dentry,
+ 			   struct vfsmount *mnt, const char *old_name)
diff --git a/lustre/kernel_patches/patches/export-log-2.6-rhel4.patch b/lustre/kernel_patches/patches/export-log-2.6-rhel4.patch
index 6fa27b3..5bfc154 100644
--- a/lustre/kernel_patches/patches/export-log-2.6-rhel4.patch
+++ b/lustre/kernel_patches/patches/export-log-2.6-rhel4.patch
@@ -1,12 +1,12 @@
-Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
+Index: linux-2.6.3/fs/jbd/journal.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/jbd/journal.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/jbd/journal.c	2009-05-11 23:21:16.000000000 -0600
-@@ -72,6 +72,7 @@
+--- linux-2.6.3.orig/fs/jbd/journal.c	2004-01-08 22:59:10.000000000 -0800
++++ linux-2.6.3/fs/jbd/journal.c	2004-02-23 20:09:34.000000000 -0800
+@@ -71,6 +71,7 @@
  EXPORT_SYMBOL(journal_errno);
  EXPORT_SYMBOL(journal_ack_err);
  EXPORT_SYMBOL(journal_clear_err);
 +EXPORT_SYMBOL(log_start_commit);
  EXPORT_SYMBOL(log_wait_commit);
  EXPORT_SYMBOL(journal_start_commit);
- EXPORT_SYMBOL(journal_force_commit_nested);
+ EXPORT_SYMBOL(journal_wipe);
diff --git a/lustre/kernel_patches/patches/export-show_task-2.6.27-vanilla.patch b/lustre/kernel_patches/patches/export-show_task-2.6.27-vanilla.patch
new file mode 100644
index 0000000..d9b287e
--- /dev/null
+++ b/lustre/kernel_patches/patches/export-show_task-2.6.27-vanilla.patch
@@ -0,0 +1,12 @@
+Index: linux-2.6/kernel/sched.c
+===================================================================
+--- linux-2.6.orig/kernel/sched.c	2006-07-15 11:51:46.000000000 +0800
++++ linux-2.6/kernel/sched.c	2006-07-15 16:24:35.000000000 +0800
+@@ -4652,6 +4652,7 @@ static inline struct task_struct *younge
+ 
+	show_stack(p, NULL);
+ }
++EXPORT_SYMBOL(sched_show_task);
+ 
+ void show_state_filter(unsigned long state_filter)
+ {
diff --git a/lustre/kernel_patches/patches/export-truncate-2.6.18-vanilla.patch b/lustre/kernel_patches/patches/export-truncate-2.6.18-vanilla.patch
index f956ef4..c8005ef 100644
--- a/lustre/kernel_patches/patches/export-truncate-2.6.18-vanilla.patch
+++ b/lustre/kernel_patches/patches/export-truncate-2.6.18-vanilla.patch
@@ -2,11 +2,11 @@
  mm/truncate.c      |    4 ++--
  2 files changed, 4 insertions(+), 2 deletions(-)
 
-Index: linux-2.6/include/linux/mm.h
+Index: linux-2.6.27.21-0.1/include/linux/mm.h
 ===================================================================
---- linux-2.6.orig/include/linux/mm.h	2006-07-06 23:41:48.000000000 +0800
-+++ linux-2.6/include/linux/mm.h	2006-07-15 12:55:07.000000000 +0800
-@@ -529,6 +529,8 @@ static __always_inline void *lowmem_page
+--- linux-2.6.27.21-0.1.orig/include/linux/mm.h
++++ linux-2.6.27.21-0.1/include/linux/mm.h
+@@ -602,6 +602,8 @@ static __always_inline void *lowmem_page
  {
  	return __va(page_to_pfn(page) << PAGE_SHIFT);
  }
@@ -15,12 +15,12 @@ Index: linux-2.6/include/linux/mm.h
  
  #if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL)
  #define HASHED_PAGE_VIRTUAL
-Index: linux-2.6/mm/truncate.c
+Index: linux-2.6.27.21-0.1/mm/truncate.c
 ===================================================================
---- linux-2.6.orig/mm/truncate.c	2006-06-24 14:22:39.000000000 +0800
-+++ linux-2.6/mm/truncate.c	2006-07-15 12:55:07.000000000 +0800
-@@ -33,7 +33,7 @@ static inline void truncate_partial_page
-  * its lock, b) when a concurrent invalidate_inode_pages got there first and
+--- linux-2.6.27.21-0.1.orig/mm/truncate.c
++++ linux-2.6.27.21-0.1/mm/truncate.c
+@@ -92,7 +92,7 @@ EXPORT_SYMBOL(cancel_dirty_page);
+  * its lock, b) when a concurrent invalidate_mapping_pages got there first and
   * c) when tmpfs swizzles a page between a tmpfs inode and swapper_space.
   */
 -static void
@@ -28,12 +28,12 @@ Index: linux-2.6/mm/truncate.c
  truncate_complete_page(struct address_space *mapping, struct page *page)
  {
  	if (page->mapping != mapping)
-@@ -48,7 +48,7 @@ truncate_complete_page(struct address_sp
- 	remove_from_page_cache(page);
+@@ -107,7 +107,7 @@ truncate_complete_page(struct address_sp
+ 	ClearPageMappedToDisk(page);
  	page_cache_release(page);	/* pagecache ref */
  }
 -
 +EXPORT_SYMBOL_GPL(truncate_complete_page);
  /*
-  * This is for invalidate_inode_pages().  That function can be called at
+  * This is for invalidate_mapping_pages().  That function can be called at
   * any time, and is not supposed to throw away dirty pages.  But pages can
diff --git a/lustre/kernel_patches/patches/export_symbols-2.6.12.patch b/lustre/kernel_patches/patches/export_symbols-2.6.12.patch
index e21fcf4..73f4555 100644
--- a/lustre/kernel_patches/patches/export_symbols-2.6.12.patch
+++ b/lustre/kernel_patches/patches/export_symbols-2.6.12.patch
@@ -1,55 +1,3 @@
-Index: linux-2.6.12-rc6/fs/filesystems.c
-===================================================================
---- linux-2.6.12-rc6.orig/fs/filesystems.c	2005-06-06 17:22:29.000000000 +0200
-+++ linux-2.6.12-rc6/fs/filesystems.c	2005-06-14 15:53:58.298522852 +0200
-@@ -28,7 +28,9 @@
-  */
- 
- static struct file_system_type *file_systems;
--static DEFINE_RWLOCK(file_systems_lock);
-+DEFINE_RWLOCK(file_systems_lock);
-+
-+EXPORT_SYMBOL(file_systems_lock);
- 
- /* WARNING: This can be used only if we _already_ own a reference */
- void get_filesystem(struct file_system_type *fs)
-Index: linux-2.6.12-rc6/include/linux/fs.h
-===================================================================
---- linux-2.6.12-rc6.orig/include/linux/fs.h	2005-06-14 15:53:18.356140529 +0200
-+++ linux-2.6.12-rc6/include/linux/fs.h	2005-06-14 15:53:58.309265039 +0200
-@@ -1563,6 +1563,7 @@
- 
- extern struct file_operations generic_ro_fops;
- 
-+extern rwlock_t file_systems_lock;
- #define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
- 
- extern int vfs_readlink(struct dentry *, char __user *, int, const char *);
-Index: linux-2.6.12-rc6/fs/namespace.c
-===================================================================
---- linux-2.6.12-rc6.orig/fs/namespace.c	2005-06-14 15:53:17.868835847 +0200
-+++ linux-2.6.12-rc6/fs/namespace.c	2005-06-14 15:53:58.361022851 +0200
-@@ -1240,6 +1240,7 @@
- 		mntput(old_pwdmnt);
- 	}
- }
-+EXPORT_SYMBOL(set_fs_pwd);
- 
- static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
- {
-Index: linux-2.6.12.5/kernel/exit.c
-===================================================================
---- linux-2.6.12.5.orig/kernel/exit.c	2005-08-17 17:51:28.000000000 +0200
-+++ linux-2.6.12.5/kernel/exit.c	2005-08-17 17:51:44.000000000 +0200
-@@ -250,6 +250,8 @@
- 	switch_uid(INIT_USER);
- }
- 
-+EXPORT_SYMBOL(reparent_to_init);
-+
- void __set_special_pids(pid_t session, pid_t pgrp)
- {
- 	struct task_struct *curr = current;
 Index: linux-2.6.12-rc6/fs/dcache.c
 ===================================================================
 --- linux-2.6.12-rc6.orig/fs/dcache.c	2005-06-14 15:53:19.812195198 +0200
diff --git a/lustre/kernel_patches/patches/export_symbols-2.6.22-vanilla.patch b/lustre/kernel_patches/patches/export_symbols-2.6.22-vanilla.patch
index 9dbf6c5..477874c 100644
--- a/lustre/kernel_patches/patches/export_symbols-2.6.22-vanilla.patch
+++ b/lustre/kernel_patches/patches/export_symbols-2.6.22-vanilla.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.22.5/fs/filesystems.c
+Index: linux-2.6.27.21-0.1/fs/filesystems.c
 ===================================================================
---- linux-2.6.22.5.orig/fs/filesystems.c	2007-08-22 17:23:54.000000000 -0600
-+++ linux-2.6.22.5/fs/filesystems.c	2008-02-21 00:58:18.000000000 -0700
+--- linux-2.6.27.21-0.1.orig/fs/filesystems.c
++++ linux-2.6.27.21-0.1/fs/filesystems.c
 @@ -28,7 +28,9 @@
   */
  
@@ -13,23 +13,23 @@ Index: linux-2.6.22.5/fs/filesystems.c
  
  /* WARNING: This can be used only if we _already_ own a reference */
  void get_filesystem(struct file_system_type *fs)
-Index: linux-2.6.22.5/fs/namespace.c
+Index: linux-2.6.27.21-0.1/fs/namespace.c
 ===================================================================
---- linux-2.6.22.5.orig/fs/namespace.c	2007-08-22 17:23:54.000000000 -0600
-+++ linux-2.6.22.5/fs/namespace.c	2008-02-21 00:58:18.000000000 -0700
-@@ -1617,6 +1617,7 @@
- 		mntput(old_pwdmnt);
- 	}
+--- linux-2.6.27.21-0.1.orig/fs/namespace.c
++++ linux-2.6.27.21-0.1/fs/namespace.c
+@@ -1617,6 +1617,7 @@ static noinline int do_new_mount(struct 
+ 
+ 	return do_add_mount(mnt, &nd->path, mnt_flags, NULL);
  }
 +EXPORT_SYMBOL(set_fs_pwd);
  
- static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
- {
-Index: linux-2.6.22.5/fs/dcache.c
+ /*
+  * add a mount into a namespace's mount tree
+Index: linux-2.6.27.21-0.1/fs/dcache.c
 ===================================================================
---- linux-2.6.22.5.orig/fs/dcache.c	2008-02-21 00:57:02.000000000 -0700
-+++ linux-2.6.22.5/fs/dcache.c	2008-02-21 00:58:18.000000000 -0700
-@@ -2027,6 +2027,7 @@
+--- linux-2.6.27.21-0.1.orig/fs/dcache.c
++++ linux-2.6.27.21-0.1/fs/dcache.c
+@@ -2212,6 +2212,7 @@ int is_subdir(struct dentry * new_dentry
  
  	return result;
  }
@@ -37,11 +37,11 @@ Index: linux-2.6.22.5/fs/dcache.c
  
  void d_genocide(struct dentry *root)
  {
-Index: linux-2.6.22.5/include/linux/fs.h
+Index: linux-2.6.27.21-0.1/include/linux/fs.h
 ===================================================================
---- linux-2.6.22.5.orig/include/linux/fs.h	2008-02-21 00:56:39.000000000 -0700
-+++ linux-2.6.22.5/include/linux/fs.h	2008-02-21 00:58:18.000000000 -0700
-@@ -1861,6 +1861,7 @@
+--- linux-2.6.27.21-0.1.orig/include/linux/fs.h
++++ linux-2.6.27.21-0.1/include/linux/fs.h
+@@ -1997,6 +1997,7 @@ static inline ssize_t blockdev_direct_IO
  
  extern const struct file_operations generic_ro_fops;
  
diff --git a/lustre/kernel_patches/patches/i_filter_data.patch b/lustre/kernel_patches/patches/i_filter_data.patch
index 8a21a9e..516d57f 100644
--- a/lustre/kernel_patches/patches/i_filter_data.patch
+++ b/lustre/kernel_patches/patches/i_filter_data.patch
@@ -1,10 +1,10 @@
-Index: linux-2.6.18.8/include/linux/fs.h
+Index: linux-2.6.18-128.1.14/include/linux/fs.h
 ===================================================================
---- linux-2.6.18.8.orig/include/linux/fs.h	2007-06-05 12:55:19.000000000 +0200
-+++ linux-2.6.18.8/include/linux/fs.h	2007-06-05 12:55:44.000000000 +0200
-@@ -533,6 +533,7 @@ struct inode {
- 	struct block_device	*i_bdev;
- 	struct cdev		*i_cdev;
+--- linux-2.6.18-128.1.14.orig/include/linux/fs.h	2009-06-19 12:33:13.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/fs.h	2009-06-19 12:33:26.000000000 -0600
+@@ -580,6 +580,7 @@
+ 		struct cdev		*i_cdev;
+ 	};
  	int			i_cindex;
 +	void                    *i_filterdata;
  
diff --git a/lustre/kernel_patches/patches/jbd-2.6.10-jcberr.patch b/lustre/kernel_patches/patches/jbd-2.6.10-jcberr.patch
index 64085b9..c4b253a 100644
--- a/lustre/kernel_patches/patches/jbd-2.6.10-jcberr.patch
+++ b/lustre/kernel_patches/patches/jbd-2.6.10-jcberr.patch
@@ -76,7 +76,7 @@
  
  /**
 @@ -881,6 +921,10 @@
- extern int	 journal_try_to_free_buffers(journal_t *, struct page *, int);
+ extern int	 journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
  extern int	 journal_stop(handle_t *);
  extern int	 journal_flush (journal_t *);
 +extern void	 journal_callback_set(handle_t *handle,
@@ -100,8 +100,8 @@
 --- 1.53/fs/jbd/commit.c	2004-10-19 03:40:17 -06:00
 +++ 1.54/fs/jbd/commit.c	2004-11-07 19:13:24 -07:00
 @@ -686,6 +686,30 @@
- 	if (err)
- 		__journal_abort_hard(journal);
+            transaction can be removed from any checkpoint list it was on
+            before. */
  
 +	/*
 +	 * Call any callbacks that had been registered for handles in this
diff --git a/lustre/kernel_patches/patches/jbd-commit-timer-no-jiffies-rounding.diff b/lustre/kernel_patches/patches/jbd-commit-timer-no-jiffies-rounding.diff
new file mode 100644
index 0000000..d0b7e7a
--- /dev/null
+++ b/lustre/kernel_patches/patches/jbd-commit-timer-no-jiffies-rounding.diff
@@ -0,0 +1,13 @@
+Index: linux-2.6/fs/jbd/transaction.c
+===================================================================
+--- linux-2.6.orig/fs/jbd/transaction.c	2009-06-10 20:07:51.000000000 +0400
++++ linux-2.6/fs/jbd/transaction.c	2009-06-10 20:08:03.000000000 +0400
+@@ -56,7 +56,7 @@ get_transaction(journal_t *journal, tran
+ 	spin_lock_init(&transaction->t_handle_lock);
+ 
+ 	/* Set up the commit timer for the new transaction. */
+-	journal->j_commit_timer.expires = round_jiffies(transaction->t_expires);
++	journal->j_commit_timer.expires = transaction->t_expires;
+ 	add_timer(&journal->j_commit_timer);
+ 
+ 	J_ASSERT(journal->j_running_transaction == NULL);
diff --git a/lustre/kernel_patches/patches/jbd-journal-chksum-2.6-sles10.patch b/lustre/kernel_patches/patches/jbd-journal-chksum-2.6-sles10.patch
index 0ca7676..1a6f326 100644
--- a/lustre/kernel_patches/patches/jbd-journal-chksum-2.6-sles10.patch
+++ b/lustre/kernel_patches/patches/jbd-journal-chksum-2.6-sles10.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
+Index: linux-2.6.16.53-0.16/fs/jbd/commit.c
 ===================================================================
---- linux-2.6.16.60-0.27.orig/fs/jbd/commit.c
-+++ linux-2.6.16.60-0.27/fs/jbd/commit.c
+--- linux-2.6.16.53-0.16.orig/fs/jbd/commit.c
++++ linux-2.6.16.53-0.16/fs/jbd/commit.c
 @@ -22,6 +22,7 @@
  #include <linux/pagemap.h>
  #include <linux/smp_lock.h>
@@ -73,27 +73,30 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
 +	if (journal->j_flags & JFS_BARRIER &&
 +		!JFS_HAS_INCOMPAT_FEATURE(journal,
 +					 JFS_FEATURE_INCOMPAT_ASYNC_COMMIT)) {
++
  		set_buffer_ordered(bh);
  		barrier_done = 1;
  	}
 -	ret = sync_dirty_buffer(bh);
-+
 +	ret = submit_bh(WRITE, bh);
 +
- 	if (barrier_done)
- 		clear_buffer_ordered(bh);
  	/* is it possible for another commit to fail at roughly
-@@ -154,12 +173,84 @@ static int journal_write_commit_record(j
- 		/* And try again, without the barrier */
+ 	 * the same time as this one?  If so, we don't want to
+ 	 * trust the barrier flag in the super, but instead want
+@@ -153,12 +172,84 @@ static int journal_write_commit_record(j
+ 		clear_buffer_ordered(bh);
  		set_buffer_uptodate(bh);
  		set_buffer_dirty(bh);
 -		ret = sync_dirty_buffer(bh);
 +		ret = submit_bh(WRITE, bh);
-+	}
+ 	}
+-	put_bh(bh);		/* One for getblk() */
+-	journal_put_journal_head(descriptor);
 +	*cbh = bh;
 +	return ret;
 +}
-+
+ 
+-	return (ret == -EIO);
 +/*
 + * This function along with journal_submit_commit_record
 + * allows to write the commit record asynchronously.
@@ -150,13 +153,10 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
 +		}
 +		put_bh(bh);
 +		cond_resched_lock(&journal->j_list_lock);
- 	}
--	put_bh(bh);		/* One for getblk() */
--	journal_put_journal_head(descriptor);
++	}
 +	return ret;
 +}
- 
--	return (ret == -EIO);
++
 +static inline __u32 jbd_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
 +{
 +	struct page *page = bh->b_page;
@@ -171,8 +171,8 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
 +	return checksum;
  }
  
- void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
-@@ -296,6 +387,8 @@ void journal_commit_transaction(journal_
+ /*
+@@ -184,6 +275,8 @@ void journal_commit_transaction(journal_
  	int first_tag = 0;
  	int tag_flag;
  	int i;
@@ -181,17 +181,20 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
  
  	/*
  	 * First job: lock down the current transaction and wait for
-@@ -439,38 +532,16 @@ void journal_commit_transaction(journal_
- 	journal_submit_data_buffers(journal, commit_transaction);
+@@ -395,37 +488,14 @@ write_out_data:
+ 	}
  
  	/*
 -	 * Wait for all previously submitted IO to complete.
 +	 * Wait for all previously submitted IO to complete if commit
 +	 * record is to be written synchronously.
  	 */
- 	spin_lock(&journal->j_list_lock);
 -	while (commit_transaction->t_locked_list) {
 -		struct buffer_head *bh;
++	if (!JFS_HAS_INCOMPAT_FEATURE(journal,
++		JFS_FEATURE_INCOMPAT_ASYNC_COMMIT))
++		err = journal_wait_on_locked_list(journal,
++						  commit_transaction);
  
 -		jh = commit_transaction->t_locked_list->b_tprev;
 -		bh = jh2bh(jh);
@@ -219,15 +222,10 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
 -		put_bh(bh);
 -		cond_resched_lock(&journal->j_list_lock);
 -	}
-+	if (!JFS_HAS_INCOMPAT_FEATURE(journal,
-+		JFS_FEATURE_INCOMPAT_ASYNC_COMMIT))
-+		err = journal_wait_on_locked_list(journal,
-+						  commit_transaction);
-+
  	spin_unlock(&journal->j_list_lock);
  
  	if (err)
-@@ -643,6 +714,16 @@ void journal_commit_transaction(journal_
+@@ -598,6 +668,16 @@ write_out_data:
  start_journal_io:
  			for (i = 0; i < bufs; i++) {
  				struct buffer_head *bh = wbuf[i];
@@ -244,7 +242,7 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
  				lock_buffer(bh);
  				clear_buffer_dirty(bh);
  				set_buffer_uptodate(bh);
-@@ -659,6 +740,23 @@ start_journal_io:
+@@ -614,6 +694,23 @@ start_journal_io:
  		}
  	}
  
@@ -268,7 +266,7 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
  	/* Lo and behold: we have just managed to send a transaction to
             the log.  Before we can commit it, wait for the IO so far to
             complete.  Control buffers being written are on the
-@@ -757,9 +855,15 @@ wait_for_iobuf:
+@@ -712,9 +809,15 @@ wait_for_iobuf:
  	}
  
  	jbd_debug(3, "JBD: commit phase 6\n");
@@ -287,10 +285,10 @@ Index: linux-2.6.16.60-0.27/fs/jbd/commit.c
  
  	if (err)
  		__journal_abort_hard(journal);
-Index: linux-2.6.16.60-0.27/include/linux/jbd.h
+Index: linux-2.6.16.53-0.16/include/linux/jbd.h
 ===================================================================
---- linux-2.6.16.60-0.27.orig/include/linux/jbd.h
-+++ linux-2.6.16.60-0.27/include/linux/jbd.h
+--- linux-2.6.16.53-0.16.orig/include/linux/jbd.h
++++ linux-2.6.16.53-0.16/include/linux/jbd.h
 @@ -142,6 +142,29 @@ typedef struct journal_header_s
  	__be32		h_sequence;
  } journal_header_t;
@@ -350,10 +348,10 @@ Index: linux-2.6.16.60-0.27/include/linux/jbd.h
  extern int	   journal_create     (journal_t *);
  extern int	   journal_load       (journal_t *journal);
  extern void	   journal_destroy    (journal_t *);
-Index: linux-2.6.16.60-0.27/fs/jbd/recovery.c
+Index: linux-2.6.16.53-0.16/fs/jbd/recovery.c
 ===================================================================
---- linux-2.6.16.60-0.27.orig/fs/jbd/recovery.c
-+++ linux-2.6.16.60-0.27/fs/jbd/recovery.c
+--- linux-2.6.16.53-0.16.orig/fs/jbd/recovery.c
++++ linux-2.6.16.53-0.16/fs/jbd/recovery.c
 @@ -21,6 +21,7 @@
  #include <linux/jbd.h>
  #include <linux/errno.h>
@@ -550,10 +548,10 @@ Index: linux-2.6.16.60-0.27/fs/jbd/recovery.c
  		/* It's really bad news if different passes end up at
  		 * different places (but possible due to IO errors). */
  		if (info->end_transaction != next_commit_ID) {
-Index: linux-2.6.16.60-0.27/fs/jbd/journal.c
+Index: linux-2.6.16.53-0.16/fs/jbd/journal.c
 ===================================================================
---- linux-2.6.16.60-0.27.orig/fs/jbd/journal.c
-+++ linux-2.6.16.60-0.27/fs/jbd/journal.c
+--- linux-2.6.16.53-0.16.orig/fs/jbd/journal.c
++++ linux-2.6.16.53-0.16/fs/jbd/journal.c
 @@ -64,6 +64,7 @@ EXPORT_SYMBOL(journal_update_format);
  EXPORT_SYMBOL(journal_check_used_features);
  EXPORT_SYMBOL(journal_check_available_features);
@@ -596,10 +594,10 @@ Index: linux-2.6.16.60-0.27/fs/jbd/journal.c
  
  /**
   * int journal_update_format () - Update on-disk journal structure.
-Index: linux-2.6.16.60-0.27/fs/Kconfig
+Index: linux-2.6.16.53-0.16/fs/Kconfig
 ===================================================================
---- linux-2.6.16.60-0.27.orig/fs/Kconfig
-+++ linux-2.6.16.60-0.27/fs/Kconfig
+--- linux-2.6.16.53-0.16.orig/fs/Kconfig
++++ linux-2.6.16.53-0.16/fs/Kconfig
 @@ -140,6 +140,7 @@ config EXT3_FS_SECURITY
  
  config JBD
@@ -608,10 +606,10 @@ Index: linux-2.6.16.60-0.27/fs/Kconfig
  	help
  	  This is a generic journaling layer for block devices.  It is
  	  currently used by the ext3 and OCFS2 file systems, but it could
-Index: linux-2.6.16.60-0.27/Documentation/filesystems/ext3.txt
+Index: linux-2.6.16.53-0.16/Documentation/filesystems/ext3.txt
 ===================================================================
---- linux-2.6.16.60-0.27.orig/Documentation/filesystems/ext3.txt
-+++ linux-2.6.16.60-0.27/Documentation/filesystems/ext3.txt
+--- linux-2.6.16.53-0.16.orig/Documentation/filesystems/ext3.txt
++++ linux-2.6.16.53-0.16/Documentation/filesystems/ext3.txt
 @@ -14,6 +14,16 @@ Options
  When mounting an ext3 filesystem, the following option are accepted:
  (*) == default
diff --git a/lustre/kernel_patches/patches/jbd-journal-chksum-2.6.18-vanilla.patch b/lustre/kernel_patches/patches/jbd-journal-chksum-2.6.18-vanilla.patch
index c224061..a132395 100644
--- a/lustre/kernel_patches/patches/jbd-journal-chksum-2.6.18-vanilla.patch
+++ b/lustre/kernel_patches/patches/jbd-journal-chksum-2.6.18-vanilla.patch
@@ -1,7 +1,7 @@
-Index: linux-2.6.18.8/fs/jbd/commit.c
+Index: linux-2.6.18-128.1.14/fs/jbd/commit.c
 ===================================================================
---- linux-2.6.18.8.orig/fs/jbd/commit.c
-+++ linux-2.6.18.8/fs/jbd/commit.c
+--- linux-2.6.18-128.1.14.orig/fs/jbd/commit.c	2009-06-19 12:34:22.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/jbd/commit.c	2009-06-19 12:35:11.000000000 -0600
 @@ -22,6 +22,7 @@
  #include <linux/mm.h>
  #include <linux/pagemap.h>
@@ -10,7 +10,7 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  
  
  /*
-@@ -95,19 +96,23 @@ static int inverted_lock(journal_t *jour
+@@ -95,19 +96,23 @@
  	return 1;
  }
  
@@ -38,7 +38,7 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  	int barrier_done = 0;
  
  	if (is_journal_aborted(journal))
-@@ -119,21 +124,35 @@ static int journal_write_commit_record(j
+@@ -119,21 +124,35 @@
  
  	bh = jh2bh(descriptor);
  
@@ -83,7 +83,7 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  	/* is it possible for another commit to fail at roughly
  	 * the same time as this one?  If so, we don't want to
  	 * trust the barrier flag in the super, but instead want
-@@ -154,12 +173,70 @@ static int journal_write_commit_record(j
+@@ -154,12 +173,70 @@
  		clear_buffer_ordered(bh);
  		set_buffer_uptodate(bh);
  		set_buffer_dirty(bh);
@@ -158,8 +158,8 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  }
  
  void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
-@@ -273,6 +350,20 @@ write_out_data:
- 	journal_do_submit_data(wbuf, bufs);
+@@ -282,6 +359,20 @@
+ 	return err;
  }
  
 +static inline __u32 jbd_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
@@ -179,7 +179,7 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  /*
   * journal_commit_transaction
   *
-@@ -296,6 +387,8 @@ void journal_commit_transaction(journal_
+@@ -305,6 +396,8 @@
  	int first_tag = 0;
  	int tag_flag;
  	int i;
@@ -188,8 +188,8 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  
  	/*
  	 * First job: lock down the current transaction and wait for
-@@ -439,38 +532,14 @@ void journal_commit_transaction(journal_
- 	journal_submit_data_buffers(journal, commit_transaction);
+@@ -431,39 +524,14 @@
+ 	err = journal_submit_data_buffers(journal, commit_transaction);
  
  	/*
 -	 * Wait for all previously submitted IO to complete.
@@ -206,10 +206,11 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
 -		if (buffer_locked(bh)) {
 -			spin_unlock(&journal->j_list_lock);
 -			wait_on_buffer(bh);
--			if (unlikely(!buffer_uptodate(bh)))
--				err = -EIO;
 -			spin_lock(&journal->j_list_lock);
 -		}
+-		if (unlikely(!buffer_uptodate(bh)))
+-			err = -EIO;
+-
 -		if (!inverted_lock(journal, bh)) {
 -			put_bh(bh);
 -			spin_lock(&journal->j_list_lock);
@@ -233,7 +234,7 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  	spin_unlock(&journal->j_list_lock);
  
  	if (err)
-@@ -643,6 +712,16 @@ void journal_commit_transaction(journal_
+@@ -642,6 +710,16 @@
  start_journal_io:
  			for (i = 0; i < bufs; i++) {
  				struct buffer_head *bh = wbuf[i];
@@ -250,7 +251,7 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  				lock_buffer(bh);
  				clear_buffer_dirty(bh);
  				set_buffer_uptodate(bh);
-@@ -659,6 +738,23 @@ start_journal_io:
+@@ -658,6 +736,23 @@
  		}
  	}
  
@@ -274,8 +275,8 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
  	/* Lo and behold: we have just managed to send a transaction to
             the log.  Before we can commit it, wait for the IO so far to
             complete.  Control buffers being written are on the
-@@ -757,9 +853,15 @@ wait_for_iobuf:
- 	}
+@@ -759,9 +854,15 @@
+ 		journal_abort(journal, err);
  
  	jbd_debug(3, "JBD: commit phase 6\n");
 -
@@ -292,12 +293,12 @@ Index: linux-2.6.18.8/fs/jbd/commit.c
 +	err = journal_wait_on_commit_record(cbh);
  
  	if (err)
- 		__journal_abort_hard(journal);
-Index: linux-2.6.18.8/include/linux/jbd.h
+ 		journal_abort(journal, err);
+Index: linux-2.6.18-128.1.14/include/linux/jbd.h
 ===================================================================
---- linux-2.6.18.8.orig/include/linux/jbd.h
-+++ linux-2.6.18.8/include/linux/jbd.h
-@@ -148,6 +148,29 @@ typedef struct journal_header_s
+--- linux-2.6.18-128.1.14.orig/include/linux/jbd.h	2009-06-19 12:34:22.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/jbd.h	2009-06-19 12:35:11.000000000 -0600
+@@ -148,6 +148,29 @@
  	__be32		h_sequence;
  } journal_header_t;
  
@@ -327,7 +328,7 @@ Index: linux-2.6.18.8/include/linux/jbd.h
  
  /* 
   * The block tag: used to describe a single buffer in the journal 
-@@ -234,12 +257,16 @@ typedef struct journal_superblock_s
+@@ -234,12 +257,16 @@
  	((j)->j_format_version >= 2 &&					\
  	 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
  
@@ -347,7 +348,7 @@ Index: linux-2.6.18.8/include/linux/jbd.h
  
  #ifdef __KERNEL__
  
-@@ -1053,6 +1080,8 @@ extern int	   journal_check_available_fe
+@@ -1053,6 +1080,8 @@
  		   (journal_t *, unsigned long, unsigned long, unsigned long);
  extern int	   journal_set_features 
  		   (journal_t *, unsigned long, unsigned long, unsigned long);
@@ -355,11 +356,11 @@ Index: linux-2.6.18.8/include/linux/jbd.h
 +		   (journal_t *, unsigned long, unsigned long, unsigned long);
  extern int	   journal_create     (journal_t *);
  extern int	   journal_load       (journal_t *journal);
- extern void	   journal_destroy    (journal_t *);
-Index: linux-2.6.18.8/fs/jbd/recovery.c
+ #ifndef __GENKSYMS__
+Index: linux-2.6.18-128.1.14/fs/jbd/recovery.c
 ===================================================================
---- linux-2.6.18.8.orig/fs/jbd/recovery.c
-+++ linux-2.6.18.8/fs/jbd/recovery.c
+--- linux-2.6.18-128.1.14.orig/fs/jbd/recovery.c	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/jbd/recovery.c	2009-06-19 12:35:11.000000000 -0600
 @@ -21,6 +21,7 @@
  #include <linux/jbd.h>
  #include <linux/errno.h>
@@ -368,7 +369,7 @@ Index: linux-2.6.18.8/fs/jbd/recovery.c
  #endif
  
  /*
-@@ -307,6 +308,38 @@ int journal_skip_recovery(journal_t *jou
+@@ -310,6 +311,38 @@
  	return err;
  }
  
@@ -407,7 +408,7 @@ Index: linux-2.6.18.8/fs/jbd/recovery.c
  static int do_one_pass(journal_t *journal,
  			struct recovery_info *info, enum passtype pass)
  {
-@@ -318,6 +351,7 @@ static int do_one_pass(journal_t *journa
+@@ -321,6 +354,7 @@
  	struct buffer_head *	bh;
  	unsigned int		sequence;
  	int			blocktype;
@@ -415,7 +416,7 @@ Index: linux-2.6.18.8/fs/jbd/recovery.c
  
  	/* Precompute the maximum metadata descriptors in a descriptor block */
  	int			MAX_BLOCKS_PER_DESC;
-@@ -409,9 +443,24 @@ static int do_one_pass(journal_t *journa
+@@ -412,9 +446,24 @@
  		switch(blocktype) {
  		case JFS_DESCRIPTOR_BLOCK:
  			/* If it is a valid descriptor block, replay it
@@ -442,7 +443,7 @@ Index: linux-2.6.18.8/fs/jbd/recovery.c
  				next_log_block +=
  					count_tags(bh, journal->j_blocksize);
  				wrap(journal, next_log_block);
-@@ -506,9 +555,97 @@ static int do_one_pass(journal_t *journa
+@@ -509,9 +558,97 @@
  			continue;
  
  		case JFS_COMMIT_BLOCK:
@@ -542,7 +543,7 @@ Index: linux-2.6.18.8/fs/jbd/recovery.c
  			brelse(bh);
  			next_commit_ID++;
  			continue;
-@@ -544,9 +681,10 @@ static int do_one_pass(journal_t *journa
+@@ -547,9 +684,10 @@
  	 * transaction marks the end of the valid log.
  	 */
  
@@ -556,11 +557,11 @@ Index: linux-2.6.18.8/fs/jbd/recovery.c
  		/* It's really bad news if different passes end up at
  		 * different places (but possible due to IO errors). */
  		if (info->end_transaction != next_commit_ID) {
-Index: linux-2.6.18.8/fs/jbd/journal.c
+Index: linux-2.6.18-128.1.14/fs/jbd/journal.c
 ===================================================================
---- linux-2.6.18.8.orig/fs/jbd/journal.c
-+++ linux-2.6.18.8/fs/jbd/journal.c
-@@ -67,6 +67,7 @@ EXPORT_SYMBOL(journal_update_format);
+--- linux-2.6.18-128.1.14.orig/fs/jbd/journal.c	2009-06-19 12:34:22.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/jbd/journal.c	2009-06-19 12:35:11.000000000 -0600
+@@ -67,6 +67,7 @@
  EXPORT_SYMBOL(journal_check_used_features);
  EXPORT_SYMBOL(journal_check_available_features);
  EXPORT_SYMBOL(journal_set_features);
@@ -568,7 +569,7 @@ Index: linux-2.6.18.8/fs/jbd/journal.c
  EXPORT_SYMBOL(journal_create);
  EXPORT_SYMBOL(journal_load);
  EXPORT_SYMBOL(journal_destroy);
-@@ -1573,6 +1574,33 @@ int journal_set_features (journal_t *jou
+@@ -1583,6 +1584,33 @@
  	return 1;
  }
  
@@ -602,11 +603,11 @@ Index: linux-2.6.18.8/fs/jbd/journal.c
  
  /**
   * int journal_update_format () - Update on-disk journal structure.
-Index: linux-2.6.18.8/fs/Kconfig
+Index: linux-2.6.18-128.1.14/fs/Kconfig
 ===================================================================
---- linux-2.6.18.8.orig/fs/Kconfig
-+++ linux-2.6.18.8/fs/Kconfig
-@@ -140,6 +140,7 @@ config EXT3_FS_SECURITY
+--- linux-2.6.18-128.1.14.orig/fs/Kconfig	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/Kconfig	2009-06-19 12:35:11.000000000 -0600
+@@ -206,6 +206,7 @@
  
  config JBD
  	tristate
@@ -614,11 +615,11 @@ Index: linux-2.6.18.8/fs/Kconfig
  	help
  	  This is a generic journaling layer for block devices.  It is
  	  currently used by the ext3 and OCFS2 file systems, but it could
-Index: linux-2.6.18.8/Documentation/filesystems/ext3.txt
+Index: linux-2.6.18-128.1.14/Documentation/filesystems/ext3.txt
 ===================================================================
---- linux-2.6.18.8.orig/Documentation/filesystems/ext3.txt
-+++ linux-2.6.18.8/Documentation/filesystems/ext3.txt
-@@ -14,6 +14,16 @@ Options
+--- linux-2.6.18-128.1.14.orig/Documentation/filesystems/ext3.txt	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/Documentation/filesystems/ext3.txt	2009-06-19 12:35:11.000000000 -0600
+@@ -14,6 +14,16 @@
  When mounting an ext3 filesystem, the following option are accepted:
  (*) == default
  
diff --git a/lustre/kernel_patches/patches/jbd-slab-race-2.6-rhel5.patch b/lustre/kernel_patches/patches/jbd-slab-race-2.6-rhel5.patch
new file mode 100644
index 0000000..0a11f74
--- /dev/null
+++ b/lustre/kernel_patches/patches/jbd-slab-race-2.6-rhel5.patch
@@ -0,0 +1,101 @@
+kmem_cache_create: duplicate cache jbd_4k
+
+The jbd slab cache creation/deletion is racey.  If multiple jbd based
+filesystems are mounted concurrently, and there are no other jbd based
+filesystems already mounted.  Then we can race creating the slab caches
+since jbd_slab[] is not locked.  This is not commonly observed because
+typically /root is mounted early with a jbd based filesystem making the
+race impossible.  On our diskless systems /root does not use the jbd
+but we do have attached storage which does, and which is mounted in
+parallel.  Basically our setup is similiar to what may be found in a
+NAS style appliance.
+
+This patch wraps all modifications to jbd_slab[] in the jbd_slab_lock
+to prevent this above race.
+
+LLNL Bug 291
+Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
+
+Index: linux+rh+chaos/fs/jbd/journal.c
+===================================================================
+--- linux+rh+chaos.orig/fs/jbd/journal.c
++++ linux+rh+chaos/fs/jbd/journal.c
+@@ -1979,6 +1979,7 @@ void * __jbd_kmalloc (const char *where,
+ #define JBD_MAX_SLABS 5
+ #define JBD_SLAB_INDEX(size)  (size >> 11)
+ 
++static DECLARE_RWSEM(jbd_slab_lock); /* protect jbd_slab[] */
+ static kmem_cache_t *jbd_slab[JBD_MAX_SLABS];
+ static const char *jbd_slab_names[JBD_MAX_SLABS] = {
+ 	"jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k"
+@@ -1988,24 +1989,27 @@ static void journal_destroy_jbd_slabs(vo
+ {
+ 	int i;
+ 
++	down_write(&jbd_slab_lock);
+ 	for (i = 0; i < JBD_MAX_SLABS; i++) {
+ 		if (jbd_slab[i])
+ 			kmem_cache_destroy(jbd_slab[i]);
+ 		jbd_slab[i] = NULL;
+ 	}
++	up_write(&jbd_slab_lock);
+ }
+ 
+ static int journal_create_jbd_slab(size_t slab_size)
+ {
+-	int i = JBD_SLAB_INDEX(slab_size);
++	int rc = 0, i = JBD_SLAB_INDEX(slab_size);
+ 
+ 	BUG_ON(i >= JBD_MAX_SLABS);
+ 
+ 	/*
+ 	 * Check if we already have a slab created for this size
+ 	 */
++	down_write(&jbd_slab_lock);
+ 	if (jbd_slab[i])
+-		return 0;
++		goto out_lock;
+ 
+ 	/*
+ 	 * Create a slab and force alignment to be same as slabsize -
+@@ -2016,27 +2020,36 @@ static int journal_create_jbd_slab(size_
+ 				slab_size, slab_size, 0, NULL, NULL);
+ 	if (!jbd_slab[i]) {
+ 		printk(KERN_EMERG "JBD: no memory for jbd_slab cache\n");
+-		return -ENOMEM;
++		rc = -ENOMEM;
+ 	}
+-	return 0;
++out_lock:
++	up_write(&jbd_slab_lock);
++	return rc;
+ }
+ 
+ void * jbd_slab_alloc(size_t size, gfp_t flags)
+ {
++	void *ptr;
+ 	int idx;
+ 
++	down_read(&jbd_slab_lock);
+ 	idx = JBD_SLAB_INDEX(size);
+ 	BUG_ON(jbd_slab[idx] == NULL);
+-	return kmem_cache_alloc(jbd_slab[idx], flags | __GFP_NOFAIL);
++	ptr = kmem_cache_alloc(jbd_slab[idx], flags | __GFP_NOFAIL);
++	up_read(&jbd_slab_lock);
++
++	return ptr;
+ }
+ 
+ void jbd_slab_free(void *ptr,  size_t size)
+ {
+ 	int idx;
+ 
++	down_read(&jbd_slab_lock);
+ 	idx = JBD_SLAB_INDEX(size);
+ 	BUG_ON(jbd_slab[idx] == NULL);
+ 	kmem_cache_free(jbd_slab[idx], ptr);
++	up_read(&jbd_slab_lock);
+ }
+ 
+ /*
+
diff --git a/lustre/kernel_patches/patches/jbd-stats-2.6-rhel5.patch b/lustre/kernel_patches/patches/jbd-stats-2.6-rhel5.patch
index e7c178d..e3de36f 100644
--- a/lustre/kernel_patches/patches/jbd-stats-2.6-rhel5.patch
+++ b/lustre/kernel_patches/patches/jbd-stats-2.6-rhel5.patch
@@ -1,8 +1,8 @@
-Index: linux-2.6.18-8.1.8/include/linux/jbd.h
+Index: linux-2.6.18-128.1.14/include/linux/jbd.h
 ===================================================================
---- linux-2.6.18-8.1.8.orig/include/linux/jbd.h	2007-08-28 22:22:10.000000000 +0200
-+++ linux-2.6.18-8.1.8/include/linux/jbd.h	2007-08-28 22:22:29.000000000 +0200
-@@ -455,6 +455,16 @@ struct handle_s 
+--- linux-2.6.18-128.1.14.orig/include/linux/jbd.h	2009-06-19 12:33:38.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/jbd.h	2009-06-19 12:34:22.000000000 -0600
+@@ -428,6 +428,16 @@
  };
  
  
@@ -19,7 +19,7 @@ Index: linux-2.6.18-8.1.8/include/linux/jbd.h
  /* The transaction_t type is the guts of the journaling mechanism.  It
   * tracks a compound transaction through its various states:
   *
-@@ -592,6 +602,21 @@ struct transaction_s 
+@@ -565,6 +575,21 @@
  	spinlock_t		t_handle_lock;
  
  	/*
@@ -41,7 +41,7 @@ Index: linux-2.6.18-8.1.8/include/linux/jbd.h
  	 * Number of outstanding updates running on this transaction
  	 * [t_handle_lock]
  	 */
-@@ -631,6 +656,57 @@ struct transaction_s 
+@@ -604,6 +629,57 @@
  	struct list_head	t_jcb;
  };
  
@@ -99,7 +99,7 @@ Index: linux-2.6.18-8.1.8/include/linux/jbd.h
  /**
   * struct journal_s - The journal_s type is the concrete type associated with
   *     journal_t.
-@@ -884,6 +960,16 @@ struct journal_s
+@@ -857,6 +933,16 @@
  	pid_t			j_last_sync_writer;
  
  	/*
@@ -116,11 +116,11 @@ Index: linux-2.6.18-8.1.8/include/linux/jbd.h
  	 * An opaque pointer to fs-private information.  ext3 puts its
  	 * superblock pointer here
  	 */
-Index: linux-2.6.18-8.1.8/fs/jbd/transaction.c
+Index: linux-2.6.18-128.1.14/fs/jbd/transaction.c
 ===================================================================
---- linux-2.6.18-8.1.8.orig/fs/jbd/transaction.c	2007-08-28 22:22:10.000000000 +0200
-+++ linux-2.6.18-8.1.8/fs/jbd/transaction.c	2007-08-28 22:22:29.000000000 +0200
-@@ -60,6 +60,8 @@ get_transaction(journal_t *journal, tran
+--- linux-2.6.18-128.1.14.orig/fs/jbd/transaction.c	2009-06-19 12:33:38.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/jbd/transaction.c	2009-06-19 12:34:22.000000000 -0600
+@@ -60,6 +60,8 @@
  
  	J_ASSERT(journal->j_running_transaction == NULL);
  	journal->j_running_transaction = transaction;
@@ -129,7 +129,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/transaction.c
  
  	return transaction;
  }
-@@ -86,6 +88,7 @@ static int start_this_handle(journal_t *
+@@ -86,6 +88,7 @@
  	int nblocks = handle->h_buffer_credits;
  	transaction_t *new_transaction = NULL;
  	int ret = 0;
@@ -137,7 +137,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/transaction.c
  
  	if (nblocks > journal->j_max_transaction_buffers) {
  		printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n",
-@@ -219,6 +222,12 @@ repeat_locked:
+@@ -219,6 +222,12 @@
  	/* OK, account for the buffers that this operation expects to
  	 * use and add the handle to the running transaction. */
  
@@ -150,10 +150,10 @@ Index: linux-2.6.18-8.1.8/fs/jbd/transaction.c
  	handle->h_transaction = transaction;
  	transaction->t_outstanding_credits += nblocks;
  	transaction->t_updates++;
-Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
+Index: linux-2.6.18-128.1.14/fs/jbd/journal.c
 ===================================================================
---- linux-2.6.18-8.1.8.orig/fs/jbd/journal.c	2007-08-28 22:22:10.000000000 +0200
-+++ linux-2.6.18-8.1.8/fs/jbd/journal.c	2007-08-28 22:22:29.000000000 +0200
+--- linux-2.6.18-128.1.14.orig/fs/jbd/journal.c	2009-06-19 12:33:58.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/jbd/journal.c	2009-06-19 12:34:22.000000000 -0600
 @@ -36,6 +36,7 @@
  #include <linux/kthread.h>
  #include <linux/poison.h>
@@ -162,7 +162,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  
  #include <asm/uaccess.h>
  #include <asm/page.h>
-@@ -639,6 +640,300 @@ struct journal_head *journal_get_descrip
+@@ -638,6 +639,300 @@
  	return journal_add_journal_head(bh);
  }
  
@@ -463,7 +463,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  /*
   * Management for journal control blocks: functions to create and
   * destroy journal_t structures, and to initialise and read existing
-@@ -681,6 +976,9 @@ static journal_t * journal_init_common (
+@@ -680,6 +975,9 @@
  		kfree(journal);
  		goto fail;
  	}
@@ -473,7 +473,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  	return journal;
  fail:
  	return NULL;
-@@ -724,6 +1022,7 @@ journal_t * journal_init_dev(struct bloc
+@@ -723,6 +1021,7 @@
  	journal->j_blk_offset = start;
  	journal->j_maxlen = len;
  	journal->j_blocksize = blocksize;
@@ -481,7 +481,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  
  	bh = __getblk(journal->j_dev, start, journal->j_blocksize);
  	J_ASSERT(bh != NULL);
-@@ -773,6 +1072,7 @@ journal_t * journal_init_inode (struct i
+@@ -772,6 +1071,7 @@
  
  	journal->j_maxlen = inode->i_size >> inode->i_sb->s_blocksize_bits;
  	journal->j_blocksize = inode->i_sb->s_blocksize;
@@ -489,7 +489,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  
  	/* journal descriptor can store up to n blocks -bzzz */
  	n = journal->j_blocksize / sizeof(journal_block_tag_t);
-@@ -1161,6 +1461,8 @@ void journal_destroy(journal_t *journal)
+@@ -1168,6 +1468,8 @@
  		brelse(journal->j_sb_buffer);
  	}
  
@@ -498,7 +498,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  	if (journal->j_inode)
  		iput(journal->j_inode);
  	if (journal->j_revoke)
-@@ -2027,6 +2329,28 @@ static void __exit remove_jbd_proc_entry
+@@ -2015,6 +2317,28 @@
  
  #endif
  
@@ -527,7 +527,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  kmem_cache_t *jbd_handle_cache;
  
  static int __init journal_init_handle_cache(void)
-@@ -2090,6 +2414,7 @@ static int __init journal_init(void)
+@@ -2078,6 +2402,7 @@
  	if (ret != 0)
  		journal_destroy_caches();
  	create_jbd_proc_entry();
@@ -535,7 +535,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  	return ret;
  }
  
-@@ -2101,6 +2426,7 @@ static void __exit journal_exit(void)
+@@ -2089,6 +2414,7 @@
  		printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n);
  #endif
  	remove_jbd_proc_entry();
@@ -543,11 +543,11 @@ Index: linux-2.6.18-8.1.8/fs/jbd/journal.c
  	journal_destroy_caches();
  }
  
-Index: linux-2.6.18-8.1.8/fs/jbd/checkpoint.c
+Index: linux-2.6.18-128.1.14/fs/jbd/checkpoint.c
 ===================================================================
---- linux-2.6.18-8.1.8.orig/fs/jbd/checkpoint.c	2007-08-28 22:22:10.000000000 +0200
-+++ linux-2.6.18-8.1.8/fs/jbd/checkpoint.c	2007-08-28 22:23:23.000000000 +0200
-@@ -231,7 +231,7 @@ __flush_batch(journal_t *journal, struct
+--- linux-2.6.18-128.1.14.orig/fs/jbd/checkpoint.c	2009-06-19 12:33:38.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/jbd/checkpoint.c	2009-06-19 12:34:22.000000000 -0600
+@@ -242,7 +242,7 @@
   * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it
   */
  static int __process_buffer(journal_t *journal, struct journal_head *jh,
@@ -556,7 +556,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/checkpoint.c
  {
  	struct buffer_head *bh = jh2bh(jh);
  	int ret = 0;
-@@ -249,6 +249,7 @@ static int __process_buffer(journal_t *j
+@@ -260,6 +260,7 @@
  		transaction_t *t = jh->b_transaction;
  		tid_t tid = t->t_tid;
  
@@ -564,7 +564,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/checkpoint.c
  		spin_unlock(&journal->j_list_lock);
  		jbd_unlock_bh_state(bh);
  		log_start_commit(journal, tid);
-@@ -278,6 +279,7 @@ static int __process_buffer(journal_t *j
+@@ -291,6 +292,7 @@
  		bhs[*batch_count] = bh;
  		__buffer_relink_io(jh);
  		jbd_unlock_bh_state(bh);
@@ -572,7 +572,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/checkpoint.c
  		(*batch_count)++;
  		if (*batch_count == NR_BATCH) {
  			spin_unlock(&journal->j_list_lock);
-@@ -321,6 +323,8 @@ int log_do_checkpoint(journal_t *journal
+@@ -336,6 +338,8 @@
  	if (!journal->j_checkpoint_transactions)
  		goto out;
  	transaction = journal->j_checkpoint_transactions;
@@ -581,17 +581,17 @@ Index: linux-2.6.18-8.1.8/fs/jbd/checkpoint.c
  	this_tid = transaction->t_tid;
  restart:
  	/*
-@@ -345,7 +349,8 @@ restart:
+@@ -360,7 +364,8 @@
  				retry = 1;
  				break;
  			}
 -			retry = __process_buffer(journal, jh, bhs,&batch_count);
 +			retry = __process_buffer(journal, jh, bhs,&batch_count,
 +						 transaction);
+ 			if (retry < 0 && !result)
+ 				result = retry;
  			if (!retry && lock_need_resched(&journal->j_list_lock)){
- 				spin_unlock(&journal->j_list_lock);
- 				retry = 1;
-@@ -667,6 +672,8 @@ void __journal_insert_checkpoint(struct 
+@@ -692,6 +697,8 @@
  
  void __journal_drop_transaction(journal_t *journal, transaction_t *transaction)
  {
@@ -600,7 +600,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/checkpoint.c
  	assert_spin_locked(&journal->j_list_lock);
  	if (transaction->t_cpnext) {
  		transaction->t_cpnext->t_cpprev = transaction->t_cpprev;
-@@ -693,5 +700,25 @@ void __journal_drop_transaction(journal_
+@@ -718,5 +725,25 @@
  	J_ASSERT(journal->j_running_transaction != transaction);
  
  	jbd_debug(1, "Dropping transaction %d, all done\n", transaction->t_tid);
@@ -626,10 +626,10 @@ Index: linux-2.6.18-8.1.8/fs/jbd/checkpoint.c
 +
  	kfree(transaction);
  }
-Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
+Index: linux-2.6.18-128.1.14/fs/jbd/commit.c
 ===================================================================
---- linux-2.6.18-8.1.8.orig/fs/jbd/commit.c	2007-08-28 22:22:10.000000000 +0200
-+++ linux-2.6.18-8.1.8/fs/jbd/commit.c	2007-08-28 22:22:29.000000000 +0200
+--- linux-2.6.18-128.1.14.orig/fs/jbd/commit.c	2009-06-19 12:33:38.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/jbd/commit.c	2009-06-19 12:34:22.000000000 -0600
 @@ -13,6 +13,7 @@
   * part of the ext2fs journaling system.
   */
@@ -638,15 +638,15 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  #include <linux/time.h>
  #include <linux/fs.h>
  #include <linux/jbd.h>
-@@ -23,6 +24,7 @@
+@@ -22,6 +23,7 @@
+ #include <linux/pagemap.h>
  #include <linux/smp_lock.h>
- #include <linux/crc32.h>
  
 +
  /*
   * Default IO end handler for temporary BJ_IO buffer_heads.
   */
-@@ -355,6 +357,7 @@ write_out_data:
+@@ -288,6 +290,7 @@
   */
  void journal_commit_transaction(journal_t *journal)
  {
@@ -654,7 +654,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  	transaction_t *commit_transaction;
  	struct journal_head *jh, *new_jh, *descriptor;
  	struct buffer_head **wbuf = journal->j_wbuf;
-@@ -403,6 +406,11 @@ void journal_commit_transaction(journal_
+@@ -334,6 +337,11 @@
  	spin_lock(&journal->j_state_lock);
  	commit_transaction->t_state = T_LOCKED;
  
@@ -666,7 +666,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  	spin_lock(&commit_transaction->t_handle_lock);
  	while (commit_transaction->t_updates) {
  		DEFINE_WAIT(wait);
-@@ -473,6 +481,9 @@ void journal_commit_transaction(journal_
+@@ -404,6 +412,9 @@
  	 */
  	journal_switch_revoke_table(journal);
  
@@ -676,9 +676,9 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  	commit_transaction->t_state = T_FLUSH;
  	journal->j_committing_transaction = commit_transaction;
  	journal->j_running_transaction = NULL;
-@@ -540,6 +551,11 @@ void journal_commit_transaction(journal_
- 	 */
- 	commit_transaction->t_state = T_COMMIT;
+@@ -484,6 +495,11 @@
+ 	J_ASSERT(commit_transaction->t_nr_buffers <=
+ 		 commit_transaction->t_outstanding_credits);
  
 +	stats.ts_logging = CURRENT_MSECS;
 +	stats.ts_flushing = jbd_time_diff(stats.ts_flushing, stats.ts_logging);
@@ -688,7 +688,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  	descriptor = NULL;
  	bufs = 0;
  	while (commit_transaction->t_buffers) {
-@@ -698,6 +714,7 @@ start_journal_io:
+@@ -633,6 +649,7 @@
  				submit_bh(WRITE, bh);
  			}
  			cond_resched();
@@ -696,7 +696,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  
  			/* Force a new descriptor to be generated next
                             time round the loop. */
-@@ -915,6 +932,7 @@ restart_loop:
+@@ -830,6 +847,7 @@
  		cp_transaction = jh->b_cp_transaction;
  		if (cp_transaction) {
  			JBUFFER_TRACE(jh, "remove from old cp transaction");
@@ -704,7 +704,7 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  			__journal_remove_checkpoint(jh);
  		}
  
-@@ -989,6 +1007,36 @@ restart_loop:
+@@ -906,6 +924,36 @@
  
  	J_ASSERT(commit_transaction->t_state == T_COMMIT);
  
@@ -741,4 +741,3 @@ Index: linux-2.6.18-8.1.8/fs/jbd/commit.c
  	commit_transaction->t_state = T_FINISHED;
  	J_ASSERT(commit_transaction == journal->j_committing_transaction);
  	journal->j_commit_sequence = commit_transaction->t_tid;
-
diff --git a/lustre/kernel_patches/patches/jbd-stats-2.6.9.patch b/lustre/kernel_patches/patches/jbd-stats-2.6.9.patch
index 4edb117..3e38108 100644
--- a/lustre/kernel_patches/patches/jbd-stats-2.6.9.patch
+++ b/lustre/kernel_patches/patches/jbd-stats-2.6.9.patch
@@ -1,8 +1,8 @@
-Index: linux-2.6.9-78.0.22/include/linux/jbd.h
+Index: linux-2.6.9/include/linux/jbd.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/jbd.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/jbd.h	2009-05-11 23:24:21.000000000 -0600
-@@ -422,6 +422,16 @@
+--- linux-2.6.9.orig/include/linux/jbd.h
++++ linux-2.6.9/include/linux/jbd.h
+@@ -422,6 +422,16 @@ struct handle_s 
  };
  
  
@@ -19,10 +19,10 @@ Index: linux-2.6.9-78.0.22/include/linux/jbd.h
  /* The transaction_t type is the guts of the journaling mechanism.  It
   * tracks a compound transaction through its various states:
   *
-@@ -553,6 +563,21 @@
- 	spinlock_t		t_handle_lock;
- 
- 	/*
+@@ -553,6 +563,21 @@ struct transaction_s 
+	spinlock_t		t_handle_lock;
+
+	/*
 +	 * Longest time some handle had to wait for running transaction
 +	 */
 +	unsigned long		t_max_wait;
@@ -41,10 +41,10 @@ Index: linux-2.6.9-78.0.22/include/linux/jbd.h
  	 * Number of outstanding updates running on this transaction
  	 * [t_handle_lock]
  	 */
-@@ -600,6 +625,57 @@
+@@ -592,6 +617,57 @@ struct transaction_s 
  #endif
  };
- 
+
 +struct transaction_run_stats_s {
 +	unsigned long		rs_wait;
 +	unsigned long		rs_running;
@@ -99,7 +99,7 @@ Index: linux-2.6.9-78.0.22/include/linux/jbd.h
  /**
   * struct journal_s - The journal_s type is the concrete type associated with
   *     journal_t.
-@@ -836,6 +912,16 @@
+@@ -828,6 +904,16 @@ struct journal_s
  	struct jbd_revoke_table_s *j_revoke_table[2];
  
  	/*
@@ -116,80 +116,80 @@ Index: linux-2.6.9-78.0.22/include/linux/jbd.h
  	 * An opaque pointer to fs-private information.  ext3 puts its
  	 * superblock pointer here
  	 */
-Index: linux-2.6.9-78.0.22/fs/jbd/commit.c
+Index: linux-2.6.9/fs/jbd/commit.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/jbd/commit.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/jbd/commit.c	2009-05-11 23:24:21.000000000 -0600
+--- linux-2.6.9.orig/fs/jbd/commit.c
++++ linux-2.6.9/fs/jbd/commit.c
 @@ -21,6 +21,7 @@
  #include <linux/mm.h>
  #include <linux/pagemap.h>
  #include <linux/smp_lock.h>
 +#include <linux/jiffies.h>
- 
+
  /*
   * Default IO end handler for temporary BJ_IO buffer_heads.
-@@ -101,6 +102,7 @@
+@@ -101,6 +102,7 @@ static int inverted_lock(journal_t *jour
   */
  void journal_commit_transaction(journal_t *journal)
  {
 +	struct transaction_stats_s stats;
- 	transaction_t *commit_transaction;
- 	struct journal_head *jh, *new_jh, *descriptor;
- 	struct buffer_head *wbuf[64];
-@@ -147,6 +149,11 @@
- 	spin_lock(&journal->j_state_lock);
- 	commit_transaction->t_state = T_LOCKED;
- 
+	transaction_t *commit_transaction;
+	struct journal_head *jh, *new_jh, *descriptor;
+	struct buffer_head *wbuf[64];
+@@ -147,6 +149,11 @@ void journal_commit_transaction(journal_
+	spin_lock(&journal->j_state_lock);
+	commit_transaction->t_state = T_LOCKED;
+
 +	stats.ts_wait = commit_transaction->t_max_wait;
 +	stats.ts_locked = CURRENT_MSECS;
 +	stats.ts_running = jbd_time_diff(commit_transaction->t_start,
 +						stats.ts_locked);
 +	
- 	spin_lock(&commit_transaction->t_handle_lock);
- 	while (commit_transaction->t_updates) {
- 		DEFINE_WAIT(wait);
-@@ -219,6 +226,9 @@
- 	 */
- 	journal_switch_revoke_table(journal);
- 
+	spin_lock(&commit_transaction->t_handle_lock);
+	while (commit_transaction->t_updates) {
+		DEFINE_WAIT(wait);
+@@ -219,6 +226,9 @@ void journal_commit_transaction(journal_
+	 */
+	journal_switch_revoke_table(journal);
+
 +	stats.ts_flushing = CURRENT_MSECS;
 +	stats.ts_locked = jbd_time_diff(stats.ts_locked, stats.ts_flushing);
 +
- 	commit_transaction->t_state = T_FLUSH;
- 	journal->j_committing_transaction = commit_transaction;
- 	journal->j_running_transaction = NULL;
-@@ -368,6 +378,11 @@
- 	J_ASSERT(commit_transaction->t_nr_buffers <=
- 		 commit_transaction->t_outstanding_credits);
- 
+	commit_transaction->t_state = T_FLUSH;
+	journal->j_committing_transaction = commit_transaction;
+	journal->j_running_transaction = NULL;
+@@ -365,6 +375,11 @@ write_out_data:
+	 */
+	commit_transaction->t_state = T_COMMIT;
+
 +	stats.ts_logging = CURRENT_MSECS;
 +	stats.ts_flushing = jbd_time_diff(stats.ts_flushing, stats.ts_logging);
 +	stats.ts_blocks = commit_transaction->t_outstanding_credits;
 +	stats.ts_blocks_logged = 0;
 +
- 	descriptor = NULL;
- 	bufs = 0;
- 	while (commit_transaction->t_buffers) {
-@@ -516,6 +531,7 @@
- 				submit_bh(WRITE, bh);
- 			}
- 			cond_resched();
+	descriptor = NULL;
+	bufs = 0;
+	while (commit_transaction->t_buffers) {
+@@ -513,6 +528,7 @@ start_journal_io:
+				submit_bh(WRITE, bh);
+			}
+			cond_resched();
 +			stats.ts_blocks_logged += bufs;
- 
- 			/* Force a new descriptor to be generated next
+
+			/* Force a new descriptor to be generated next
                             time round the loop. */
-@@ -770,6 +786,7 @@
- 		cp_transaction = jh->b_cp_transaction;
- 		if (cp_transaction) {
- 			JBUFFER_TRACE(jh, "remove from old cp transaction");
+@@ -767,6 +783,7 @@ restart_loop:
+		cp_transaction = jh->b_cp_transaction;
+		if (cp_transaction) {
+			JBUFFER_TRACE(jh, "remove from old cp transaction");
 +			cp_transaction->t_chp_stats.cs_dropped++;
- 			__journal_remove_checkpoint(jh);
- 		}
- 
-@@ -819,6 +836,37 @@
- 		}
- 		cond_resched_lock(&journal->j_list_lock);
- 	}
+			__journal_remove_checkpoint(jh);
+		}
+
+@@ -816,6 +833,37 @@ restart_loop:
+		}
+		cond_resched_lock(&journal->j_list_lock);
+	}
 +
 +	commit_transaction->t_start = CURRENT_MSECS;
 +	stats.ts_logging = jbd_time_diff(stats.ts_logging,
@@ -221,14 +221,14 @@ Index: linux-2.6.9-78.0.22/fs/jbd/commit.c
 +	journal->j_stats.ts_blocks_logged += stats.ts_blocks_logged;
 +	spin_unlock(&journal->j_history_lock);
 +
- 	spin_unlock(&journal->j_list_lock);
- 	/*
- 	 * This is a bit sleazy.  We borrow j_list_lock to protect
-Index: linux-2.6.9-78.0.22/fs/jbd/checkpoint.c
+	spin_unlock(&journal->j_list_lock);
+	/*
+	 * This is a bit sleazy.  We borrow j_list_lock to protect
+Index: linux-2.6.9/fs/jbd/checkpoint.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/jbd/checkpoint.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/jbd/checkpoint.c	2009-05-11 23:24:21.000000000 -0600
-@@ -233,7 +233,8 @@
+--- linux-2.6.9.orig/fs/jbd/checkpoint.c
++++ linux-2.6.9/fs/jbd/checkpoint.c
+@@ -126,7 +127,8 @@
   * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it
   */
  static int __process_buffer(journal_t *journal, struct journal_head *jh,
@@ -236,56 +236,56 @@ Index: linux-2.6.9-78.0.22/fs/jbd/checkpoint.c
 +			struct buffer_head **bhs, int *batch_count,
 +			transaction_t *transaction)
  {
- 	struct buffer_head *bh = jh2bh(jh);
- 	int ret = 0;
-@@ -251,6 +252,7 @@
- 		transaction_t *t = jh->b_transaction;
- 		tid_t tid = t->t_tid;
- 
+	struct buffer_head *bh = jh2bh(jh);
+	int ret = 0;
+@@ -166,6 +166,7 @@
+		transaction_t *t = jh->b_transaction;
+		tid_t tid = t->t_tid;
+
 +		transaction->t_chp_stats.cs_forced_to_close++;
- 		spin_unlock(&journal->j_list_lock);
- 		jbd_unlock_bh_state(bh);
- 		log_start_commit(journal, tid);
-@@ -280,6 +282,7 @@
- 		bhs[*batch_count] = bh;
- 		__buffer_relink_io(jh);
- 		jbd_unlock_bh_state(bh);
+		spin_unlock(&journal->j_list_lock);
+		jbd_unlock_bh_state(bh);
+		log_start_commit(journal, tid);
+@@ -247,6 +248,7 @@
+		bhs[*batch_count] = bh;
+		__buffer_relink_io(jh);
+		jbd_unlock_bh_state(bh);
 +		transaction->t_chp_stats.cs_written++;
- 		(*batch_count)++;
- 		if (*batch_count == NR_BATCH) {
- 			spin_unlock(&journal->j_list_lock);
-@@ -323,6 +326,8 @@
- 	if (!journal->j_checkpoint_transactions)
- 		goto out;
- 	transaction = journal->j_checkpoint_transactions;
+		(*batch_count)++;
+		if (*batch_count == NR_BATCH) {
+			spin_unlock(&journal->j_list_lock);
+@@ -315,6 +317,8 @@ int log_do_checkpoint(journal_t *journal
+	if (!journal->j_checkpoint_transactions)
+		goto out;
+	transaction = journal->j_checkpoint_transactions;
 +	if (transaction->t_chp_stats.cs_chp_time == 0)
 +		transaction->t_chp_stats.cs_chp_time = CURRENT_MSECS;
- 	this_tid = transaction->t_tid;
+	this_tid = transaction->t_tid;
  restart:
- 	/*
-@@ -347,7 +352,8 @@
- 				retry = 1;
- 				break;
- 			}
+	/*
+@@ -331,7 +335,8 @@ int log_do_checkpoint(journal_t *journal
+				retry = 1;
+				break;
+			}
 -			retry = __process_buffer(journal, jh, bhs,&batch_count);
 +			retry = __process_buffer(journal, jh, bhs,&batch_count,
 +					transaction);
- 		}
- 
- 		if (batch_count) {
-@@ -664,6 +670,8 @@
- 
+		}
+
+		if (batch_count) {
+@@ -597,6 +602,8 @@ void __journal_insert_checkpoint(struct 
+
  void __journal_drop_transaction(journal_t *journal, transaction_t *transaction)
  {
 +	struct transaction_stats_s stats;
 +
- 	assert_spin_locked(&journal->j_list_lock);
- 	if (transaction->t_cpnext) {
- 		transaction->t_cpnext->t_cpprev = transaction->t_cpprev;
-@@ -690,5 +698,25 @@
- 	J_ASSERT(journal->j_running_transaction != transaction);
- 
- 	jbd_debug(1, "Dropping transaction %d, all done\n", transaction->t_tid);
+	assert_spin_locked(&journal->j_list_lock);
+	if (transaction->t_cpnext) {
+		transaction->t_cpnext->t_cpprev = transaction->t_cpprev;
+@@ -622,5 +629,25 @@ void __journal_drop_transaction(journal_
+	J_ASSERT(journal->j_running_transaction != transaction);
+
+	jbd_debug(1, "Dropping transaction %d, all done\n", transaction->t_tid);
 +
 +	/*
 +	 * File the transaction for history
@@ -306,13 +306,13 @@ Index: linux-2.6.9-78.0.22/fs/jbd/checkpoint.c
 +		spin_unlock(&journal->j_history_lock);
 +	}
 +
- 	kfree(transaction);
+	kfree(transaction);
  }
-Index: linux-2.6.9-78.0.22/fs/jbd/transaction.c
+Index: linux-2.6.9/fs/jbd/transaction.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/jbd/transaction.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/jbd/transaction.c	2009-05-11 23:24:21.000000000 -0600
-@@ -60,6 +60,8 @@
+--- linux-2.6.9.orig/fs/jbd/transaction.c
++++ linux-2.6.9/fs/jbd/transaction.c
+@@ -60,6 +60,8 @@ get_transaction(journal_t *journal, tran
  
  	J_ASSERT(journal->j_running_transaction == NULL);
  	journal->j_running_transaction = transaction;
@@ -321,7 +321,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/transaction.c
  
  	return transaction;
  }
-@@ -86,6 +88,7 @@
+@@ -86,6 +88,7 @@ static int start_this_handle(journal_t *
  	int nblocks = handle->h_buffer_credits;
  	transaction_t *new_transaction = NULL;
  	int ret = 0;
@@ -329,7 +329,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/transaction.c
  
  	if (nblocks > journal->j_max_transaction_buffers) {
  		printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n",
-@@ -219,6 +222,12 @@
+@@ -219,6 +222,12 @@ repeat_locked:
  	/* OK, account for the buffers that this operation expects to
  	 * use and add the handle to the running transaction. */
  
@@ -342,10 +342,10 @@ Index: linux-2.6.9-78.0.22/fs/jbd/transaction.c
  	handle->h_transaction = transaction;
  	transaction->t_outstanding_credits += nblocks;
  	transaction->t_updates++;
-Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
+Index: linux-2.6.9/fs/jbd/journal.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/jbd/journal.c	2009-05-11 23:21:16.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/jbd/journal.c	2009-05-11 23:24:21.000000000 -0600
+--- linux-2.6.9.orig/fs/jbd/journal.c
++++ linux-2.6.9/fs/jbd/journal.c
 @@ -36,6 +36,7 @@
  #include <asm/uaccess.h>
  #include <asm/page.h>
@@ -354,7 +354,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  
  EXPORT_SYMBOL(journal_start);
  EXPORT_SYMBOL(journal_restart);
-@@ -649,6 +650,300 @@
+@@ -649,6 +650,300 @@ struct journal_head *journal_get_descrip
  	return journal_add_journal_head(bh);
  }
  
@@ -655,7 +655,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  /*
   * Management for journal control blocks: functions to create and
   * destroy journal_t structures, and to initialise and read existing
-@@ -691,6 +986,9 @@
+@@ -691,6 +986,9 @@ static journal_t * journal_init_common (
  		kfree(journal);
  		goto fail;
  	}
@@ -665,7 +665,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  	return journal;
  fail:
  	return NULL;
-@@ -733,6 +1031,7 @@
+@@ -733,6 +1031,7 @@ journal_t * journal_init_dev(struct bloc
  	journal->j_blk_offset = start;
  	journal->j_maxlen = len;
  	journal->j_blocksize = blocksize;
@@ -673,7 +673,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  
  	bh = __getblk(journal->j_dev, start, journal->j_blocksize);
  	J_ASSERT(bh != NULL);
-@@ -770,6 +1069,7 @@
+@@ -770,6 +1069,7 @@ journal_t * journal_init_inode (struct i
  
  	journal->j_maxlen = inode->i_size >> inode->i_sb->s_blocksize_bits;
  	journal->j_blocksize = inode->i_sb->s_blocksize;
@@ -681,7 +681,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  
  	err = journal_bmap(journal, 0, &blocknr);
  	/* If that failed, give up */
-@@ -1140,6 +1440,8 @@
+@@ -1140,6 +1440,8 @@ void journal_destroy(journal_t *journal)
  		brelse(journal->j_sb_buffer);
  	}
  
@@ -690,7 +690,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  	if (journal->j_inode)
  		iput(journal->j_inode);
  	if (journal->j_revoke)
-@@ -1896,6 +2198,28 @@
+@@ -1896,6 +2198,28 @@ static void __exit remove_jbd_proc_entry
  
  #endif
  
@@ -719,7 +719,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  kmem_cache_t *jbd_handle_cache;
  
  static int __init journal_init_handle_cache(void)
-@@ -1950,6 +2274,7 @@
+@@ -1950,6 +2274,7 @@ static int __init journal_init(void)
  	if (ret != 0)
  		journal_destroy_caches();
  	create_jbd_proc_entry();
@@ -727,7 +727,7 @@ Index: linux-2.6.9-78.0.22/fs/jbd/journal.c
  	return ret;
  }
  
-@@ -1961,6 +2286,7 @@
+@@ -1961,6 +2286,7 @@ static void __exit journal_exit(void)
  		printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n);
  #endif
  	remove_jbd_proc_entry();
diff --git a/lustre/kernel_patches/patches/jbd2-commit-timer-no-jiffies-rounding.diff b/lustre/kernel_patches/patches/jbd2-commit-timer-no-jiffies-rounding.diff
new file mode 100644
index 0000000..e809572
--- /dev/null
+++ b/lustre/kernel_patches/patches/jbd2-commit-timer-no-jiffies-rounding.diff
@@ -0,0 +1,13 @@
+Index: linux-2.6.27.21-0.1/fs/jbd2/transaction.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/jbd2/transaction.c	2009-06-10 11:11:41.000000000 -0600
++++ linux-2.6.27.21-0.1/fs/jbd2/transaction.c	2009-06-10 11:12:32.000000000 -0600
+@@ -54,7 +54,7 @@
+ 	INIT_LIST_HEAD(&transaction->t_inode_list);
+ 
+ 	/* Set up the commit timer for the new transaction. */
+-	journal->j_commit_timer.expires = round_jiffies(transaction->t_expires);
++	journal->j_commit_timer.expires = transaction->t_expires;
+ 	add_timer(&journal->j_commit_timer);
+ 
+ 	J_ASSERT(journal->j_running_transaction == NULL);
diff --git a/lustre/kernel_patches/patches/jbd2-jcberr-2.6-rhel5.patch b/lustre/kernel_patches/patches/jbd2-jcberr-2.6-rhel5.patch
new file mode 100644
index 0000000..476e06f
--- /dev/null
+++ b/lustre/kernel_patches/patches/jbd2-jcberr-2.6-rhel5.patch
@@ -0,0 +1,221 @@
+Index: linux-2.6.18-128.1.6/include/linux/jbd2.h
+===================================================================
+--- linux-2.6.18-128.1.6.orig/include/linux/jbd2.h	2009-04-15 08:35:28.000000000 +0530
++++ linux-2.6.18-128.1.6/include/linux/jbd2.h	2009-05-28 15:10:18.000000000 +0530
+@@ -381,6 +381,27 @@
+ 	bit_spin_unlock(BH_JournalHead, &bh->b_state);
+ }
+ 
++#define HAVE_JOURNAL_CALLBACK_STATUS
++/**
++ *   struct journal_callback - Base structure for callback information.
++ *   @jcb_list: list information for other callbacks attached to the same handle.
++ *   @jcb_func: Function to call with this callback structure.
++ *
++ *   This struct is a 'seed' structure for a using with your own callback
++ *   structs. If you are using callbacks you must allocate one of these
++ *   or another struct of your own definition which has this struct
++ *   as it's first element and pass it to journal_callback_set().
++ *
++ *   This is used internally by jbd2 to maintain callback information.
++ *
++ *   See journal_callback_set for more information.
++ **/
++struct journal_callback {
++	struct list_head jcb_list;		/* t_jcb_lock */
++	void (*jcb_func)(struct journal_callback *jcb, int error);
++	/* user data goes here */
++};
++
+ struct jbd2_revoke_table_s;
+ 
+ /**
+@@ -389,6 +410,7 @@
+  * @h_transaction: Which compound transaction is this update a part of?
+  * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
+  * @h_ref: Reference count on this handle
++ * @h_jcb: List of application registered callbacks for this handle.
+  * @h_err: Field for caller's use to track errors through large fs operations
+  * @h_sync: flag for sync-on-close
+  * @h_jdata: flag to force data journaling
+@@ -414,6 +436,13 @@
+ 	/* operations */
+ 	int			h_err;
+ 
++	/*
++	 * List of application registered callbacks for this handle. The
++	 * function(s) will be called after the transaction that this handle is
++	 * part of has been committed to disk. [t_jcb_lock]
++	 */
++	struct list_head	h_jcb;
++
+ 	/* Flags [no locking] */
+ 	unsigned int	h_sync:		1;	/* sync-on-close */
+ 	unsigned int	h_jdata:	1;	/* force data journaling */
+@@ -469,6 +498,8 @@
+  *    j_state_lock
+  *    ->j_list_lock			(journal_unmap_buffer)
+  *
++ *    t_handle_lock
++ *    ->t_jcb_lock
+  */
+ 
+ struct transaction_s
+@@ -615,6 +646,15 @@
+ 	 */
+ 	int t_handle_count;
+ 
++	/*
++	 * Protects the callback list
++	 */
++	spinlock_t		t_jcb_lock;
++	/*
++	 * List of registered callback functions for this transaction.
++	 * Called when the transaction is committed. [t_jcb_lock]
++	 */
++	struct list_head	t_jcb;
+ };
+ 
+ struct transaction_run_stats_s {
+@@ -1018,6 +1058,9 @@
+ extern int	 jbd2_journal_flush (journal_t *);
+ extern void	 jbd2_journal_lock_updates (journal_t *);
+ extern void	 jbd2_journal_unlock_updates (journal_t *);
++extern void	 jbd2_journal_callback_set(handle_t *handle,
++                                      void (*fn)(struct journal_callback *,int),
++                                      struct journal_callback *jcb);
+ 
+ extern journal_t * jbd2_journal_init_dev(struct block_device *bdev,
+ 				struct block_device *fs_dev,
+Index: linux-2.6.18-128.1.6/fs/jbd2/checkpoint.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/jbd2/checkpoint.c	2009-04-15 08:35:28.000000000 +0530
++++ linux-2.6.18-128.1.6/fs/jbd2/checkpoint.c	2009-05-28 15:10:18.000000000 +0530
+@@ -695,6 +695,7 @@
+ 	J_ASSERT(transaction->t_checkpoint_list == NULL);
+ 	J_ASSERT(transaction->t_checkpoint_io_list == NULL);
+ 	J_ASSERT(transaction->t_updates == 0);
++	J_ASSERT(list_empty(&transaction->t_jcb));
+ 	J_ASSERT(journal->j_committing_transaction != transaction);
+ 	J_ASSERT(journal->j_running_transaction != transaction);
+ 
+Index: linux-2.6.18-128.1.6/fs/jbd2/commit.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/jbd2/commit.c	2009-04-15 08:35:28.000000000 +0530
++++ linux-2.6.18-128.1.6/fs/jbd2/commit.c	2009-05-28 15:12:45.000000000 +0530
+@@ -898,6 +898,30 @@
+            transaction can be removed from any checkpoint list it was on
+            before. */
+ 
++	/*
++	 * Call any callbacks that had been registered for handles in this
++	 * transaction.  It is up to the callback to free any allocated
++	 * memory.
++	 *
++	 * The spinlocking (t_jcb_lock) here is surely unnecessary...
++	 */
++	spin_lock(&commit_transaction->t_jcb_lock);
++	if (!list_empty(&commit_transaction->t_jcb)) {
++		struct list_head *p, *n;
++		int error = is_journal_aborted(journal);
++
++		list_for_each_safe(p, n, &commit_transaction->t_jcb) {
++			struct journal_callback *jcb;
++
++			jcb = list_entry(p, struct journal_callback, jcb_list);
++			list_del(p);
++			spin_unlock(&commit_transaction->t_jcb_lock);
++			jcb->jcb_func(jcb, error);
++			spin_lock(&commit_transaction->t_jcb_lock);
++		}
++	}
++	spin_unlock(&commit_transaction->t_jcb_lock);
++
+ 	jbd_debug(3, "JBD: commit phase 7\n");
+ 
+ 	J_ASSERT(commit_transaction->t_sync_datalist == NULL);
+Index: linux-2.6.18-128.1.6/fs/jbd2/journal.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/jbd2/journal.c	2009-04-15 08:35:28.000000000 +0530
++++ linux-2.6.18-128.1.6/fs/jbd2/journal.c	2009-05-28 17:13:35.000000000 +0530
+@@ -80,6 +80,9 @@
+ EXPORT_SYMBOL(jbd2_journal_invalidatepage);
+ EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
+ EXPORT_SYMBOL(jbd2_journal_force_commit);
++EXPORT_SYMBOL(jbd2_journal_callback_set);
++EXPORT_SYMBOL(jbd2_journal_bmap);
++EXPORT_SYMBOL(jbd2_log_start_commit);
+ 
+ static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
+ static void __journal_abort_soft (journal_t *journal, int errno);
+Index: linux-2.6.18-128.1.6/fs/jbd2/transaction.c
+===================================================================
+--- linux-2.6.18-128.1.6.orig/fs/jbd2/transaction.c	2009-04-15 08:35:28.000000000 +0530
++++ linux-2.6.18-128.1.6/fs/jbd2/transaction.c	2009-05-28 15:11:28.000000000 +0530
+@@ -51,6 +51,9 @@
+ 	transaction->t_tid = journal->j_transaction_sequence++;
+ 	transaction->t_expires = jiffies + journal->j_commit_interval;
+ 	spin_lock_init(&transaction->t_handle_lock);
++	INIT_LIST_HEAD(&transaction->t_jcb);
++	spin_lock_init(&transaction->t_jcb_lock);
++
+ 
+ 	/* Set up the commit timer for the new transaction. */
+ 	journal->j_commit_timer.expires = round_jiffies(transaction->t_expires);
+@@ -251,6 +254,7 @@
+ 	memset(handle, 0, sizeof(*handle));
+ 	handle->h_buffer_credits = nblocks;
+ 	handle->h_ref = 1;
++	INIT_LIST_HEAD(&handle->h_jcb);
+ 
+ 	lockdep_init_map(&handle->h_lockdep_map, "jbd2_handle",
+ 						&jbd2_handle_key, 0);
+@@ -1349,6 +1353,36 @@
+ }
+ 
+ /**
++ * void jbd2_journal_callback_set() -  Register a callback function for this handle.
++ * @handle: handle to attach the callback to.
++ * @func: function to callback.
++ * @jcb:  structure with additional information required by func() , and
++ *	some space for jbd2 internal information.
++ *
++ * The function will be
++ * called when the transaction that this handle is part of has been
++ * committed to disk with the original callback data struct and the
++ * error status of the journal as parameters.  There is no guarantee of
++ * ordering between handles within a single transaction, nor between
++ * callbacks registered on the same handle.
++ *
++ * The caller is responsible for allocating the journal_callback struct.
++ * This is to allow the caller to add as much extra data to the callback
++ * as needed, but reduce the overhead of multiple allocations.  The caller
++ * allocated struct must start with a struct journal_callback at offset 0,
++ * and has the caller-specific data afterwards.
++ */
++void jbd2_journal_callback_set(handle_t *handle,
++		      void (*func)(struct journal_callback *jcb, int error),
++		      struct journal_callback *jcb)
++{
++	spin_lock(&handle->h_transaction->t_jcb_lock);
++	list_add_tail(&jcb->jcb_list, &handle->h_jcb);
++	spin_unlock(&handle->h_transaction->t_jcb_lock);
++	jcb->jcb_func = func;
++}
++
++/**
+  * int jbd2_journal_stop() - complete a transaction
+  * @handle: tranaction to complete.
+  *
+@@ -1422,6 +1456,11 @@
+ 			wake_up(&journal->j_wait_transaction_locked);
+ 	}
+ 
++	/* Move callbacks from the handle to the transaction. */
++	spin_lock(&transaction->t_jcb_lock);
++	list_splice(&handle->h_jcb, &transaction->t_jcb);
++	spin_unlock(&transaction->t_jcb_lock);
++
+ 	/*
+ 	 * If the handle is marked SYNC, we need to set another commit
+ 	 * going!  We also want to force a commit if the current
diff --git a/lustre/kernel_patches/patches/jbd2-jcberr-2.6-sles11.patch b/lustre/kernel_patches/patches/jbd2-jcberr-2.6-sles11.patch
new file mode 100644
index 0000000..18ba3e0
--- /dev/null
+++ b/lustre/kernel_patches/patches/jbd2-jcberr-2.6-sles11.patch
@@ -0,0 +1,220 @@
+Index: linux-2.6.27.21-0.1/include/linux/jbd2.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/include/linux/jbd2.h
++++ linux-2.6.27.21-0.1/include/linux/jbd2.h
+@@ -413,6 +413,27 @@ struct jbd2_inode {
+ 	unsigned int i_flags;
+ };
+ 
++#define HAVE_JOURNAL_CALLBACK_STATUS
++/**
++ *   struct journal_callback - Base structure for callback information.
++ *   @jcb_list: list information for other callbacks attached to the same handle.
++ *   @jcb_func: Function to call with this callback structure.
++ *
++ *   This struct is a 'seed' structure for a using with your own callback
++ *   structs. If you are using callbacks you must allocate one of these
++ *   or another struct of your own definition which has this struct
++ *   as it's first element and pass it to journal_callback_set().
++ *
++ *   This is used internally by jbd2 to maintain callback information.
++ *
++ *   See journal_callback_set for more information.
++ **/
++struct journal_callback {
++	struct list_head jcb_list;		/* t_jcb_lock */
++	void (*jcb_func)(struct journal_callback *jcb, int error);
++	/* user data goes here */
++};
++
+ struct jbd2_revoke_table_s;
+ 
+ /**
+@@ -421,6 +442,7 @@ struct jbd2_revoke_table_s;
+  * @h_transaction: Which compound transaction is this update a part of?
+  * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
+  * @h_ref: Reference count on this handle
++ * @h_jcb: List of application registered callbacks for this handle.
+  * @h_err: Field for caller's use to track errors through large fs operations
+  * @h_sync: flag for sync-on-close
+  * @h_jdata: flag to force data journaling
+@@ -446,6 +468,13 @@ struct handle_s
+ 	/* operations */
+ 	int			h_err;
+ 
++	/*
++	 * List of application registered callbacks for this handle. The
++	 * function(s) will be called after the transaction that this handle is
++	 * part of has been committed to disk. [t_jcb_lock]
++	 */
++	struct list_head	h_jcb;
++
+ 	/* Flags [no locking] */
+ 	unsigned int	h_sync:		1;	/* sync-on-close */
+ 	unsigned int	h_jdata:	1;	/* force data journaling */
+@@ -501,6 +530,8 @@ struct transaction_chp_stats_s {
+  *    j_state_lock
+  *    ->j_list_lock			(journal_unmap_buffer)
+  *
++ *    t_handle_lock
++ *    ->t_jcb_lock
+  */
+ 
+ struct transaction_s
+@@ -641,6 +672,15 @@ struct transaction_s
+ 	 */
+ 	int t_handle_count;
+ 
++	/*
++	 * Protects the callback list
++	 */
++	spinlock_t		t_jcb_lock;
++	/*
++	 * List of registered callback functions for this transaction.
++	 * Called when the transaction is committed. [t_jcb_lock]
++	 */
++	struct list_head	t_jcb;
+ };
+ 
+ struct transaction_run_stats_s {
+@@ -1044,6 +1084,9 @@ extern int	 jbd2_journal_stop(handle_t *
+ extern int	 jbd2_journal_flush (journal_t *);
+ extern void	 jbd2_journal_lock_updates (journal_t *);
+ extern void	 jbd2_journal_unlock_updates (journal_t *);
++extern void	 jbd2_journal_callback_set(handle_t *handle,
++                                      void (*fn)(struct journal_callback *,int),
++                                      struct journal_callback *jcb);
+ 
+ extern journal_t * jbd2_journal_init_dev(struct block_device *bdev,
+ 				struct block_device *fs_dev,
+Index: linux-2.6.27.21-0.1/fs/jbd2/checkpoint.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/jbd2/checkpoint.c
++++ linux-2.6.27.21-0.1/fs/jbd2/checkpoint.c
+@@ -728,6 +728,7 @@ void __jbd2_journal_drop_transaction(jou
+ 	J_ASSERT(transaction->t_checkpoint_list == NULL);
+ 	J_ASSERT(transaction->t_checkpoint_io_list == NULL);
+ 	J_ASSERT(transaction->t_updates == 0);
++	J_ASSERT(list_empty(&transaction->t_jcb));
+ 	J_ASSERT(journal->j_committing_transaction != transaction);
+ 	J_ASSERT(journal->j_running_transaction != transaction);
+ 
+Index: linux-2.6.27.21-0.1/fs/jbd2/commit.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/jbd2/commit.c
++++ linux-2.6.27.21-0.1/fs/jbd2/commit.c
+@@ -805,6 +805,30 @@ wait_for_iobuf:
+            transaction can be removed from any checkpoint list it was on
+            before. */
+ 
++	/*
++	 * Call any callbacks that had been registered for handles in this
++	 * transaction.  It is up to the callback to free any allocated
++	 * memory.
++	 *
++	 * The spinlocking (t_jcb_lock) here is surely unnecessary...
++	 */
++	spin_lock(&commit_transaction->t_jcb_lock);
++	if (!list_empty(&commit_transaction->t_jcb)) {
++		struct list_head *p, *n;
++		int error = is_journal_aborted(journal);
++
++		list_for_each_safe(p, n, &commit_transaction->t_jcb) {
++			struct journal_callback *jcb;
++
++			jcb = list_entry(p, struct journal_callback, jcb_list);
++			list_del(p);
++			spin_unlock(&commit_transaction->t_jcb_lock);
++			jcb->jcb_func(jcb, error);
++			spin_lock(&commit_transaction->t_jcb_lock);
++		}
++	}
++	spin_unlock(&commit_transaction->t_jcb_lock);
++
+ 	jbd_debug(3, "JBD: commit phase 6\n");
+ 
+ 	J_ASSERT(list_empty(&commit_transaction->t_inode_list));
+Index: linux-2.6.27.21-0.1/fs/jbd2/journal.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/jbd2/journal.c
++++ linux-2.6.27.21-0.1/fs/jbd2/journal.c
+@@ -84,6 +84,8 @@ EXPORT_SYMBOL(jbd2_journal_file_inode);
+ EXPORT_SYMBOL(jbd2_journal_init_jbd_inode);
+ EXPORT_SYMBOL(jbd2_journal_release_jbd_inode);
+ EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate);
++EXPORT_SYMBOL(jbd2_journal_callback_set);
++EXPORT_SYMBOL(jbd2_journal_bmap);
+ 
+ static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
+ static void __journal_abort_soft (journal_t *journal, int errno);
+Index: linux-2.6.27.21-0.1/fs/jbd2/transaction.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/jbd2/transaction.c
++++ linux-2.6.27.21-0.1/fs/jbd2/transaction.c
+@@ -50,7 +50,9 @@ jbd2_get_transaction(journal_t *journal,
+ 	transaction->t_state = T_RUNNING;
+ 	transaction->t_tid = journal->j_transaction_sequence++;
+ 	transaction->t_expires = jiffies + journal->j_commit_interval;
++	INIT_LIST_HEAD(&transaction->t_jcb);
+ 	spin_lock_init(&transaction->t_handle_lock);
++	spin_lock_init(&transaction->t_jcb_lock);
+ 	INIT_LIST_HEAD(&transaction->t_inode_list);
+ 
+ 	/* Set up the commit timer for the new transaction. */
+@@ -252,6 +254,7 @@ static handle_t *new_handle(int nblocks)
+ 	memset(handle, 0, sizeof(*handle));
+ 	handle->h_buffer_credits = nblocks;
+ 	handle->h_ref = 1;
++	INIT_LIST_HEAD(&handle->h_jcb);
+ 
+ 	lockdep_init_map(&handle->h_lockdep_map, "jbd2_handle",
+ 						&jbd2_handle_key, 0);
+@@ -1173,6 +1176,36 @@ drop:
+ }
+ 
+ /**
++ * void jbd2_journal_callback_set() -  Register a callback function for this handle.
++ * @handle: handle to attach the callback to.
++ * @func: function to callback.
++ * @jcb:  structure with additional information required by func() , and
++ *	some space for jbd2 internal information.
++ *
++ * The function will be
++ * called when the transaction that this handle is part of has been
++ * committed to disk with the original callback data struct and the
++ * error status of the journal as parameters.  There is no guarantee of
++ * ordering between handles within a single transaction, nor between
++ * callbacks registered on the same handle.
++ *
++ * The caller is responsible for allocating the journal_callback struct.
++ * This is to allow the caller to add as much extra data to the callback
++ * as needed, but reduce the overhead of multiple allocations.  The caller
++ * allocated struct must start with a struct journal_callback at offset 0,
++ * and has the caller-specific data afterwards.
++ */
++void jbd2_journal_callback_set(handle_t *handle,
++		      void (*func)(struct journal_callback *jcb, int error),
++		      struct journal_callback *jcb)
++{
++	spin_lock(&handle->h_transaction->t_jcb_lock);
++	list_add_tail(&jcb->jcb_list, &handle->h_jcb);
++	spin_unlock(&handle->h_transaction->t_jcb_lock);
++	jcb->jcb_func = func;
++}
++
++/**
+  * int jbd2_journal_stop() - complete a transaction
+  * @handle: tranaction to complete.
+  *
+@@ -1246,6 +1279,11 @@ int jbd2_journal_stop(handle_t *handle)
+ 			wake_up(&journal->j_wait_transaction_locked);
+ 	}
+ 
++	/* Move callbacks from the handle to the transaction. */
++	spin_lock(&transaction->t_jcb_lock);
++	list_splice(&handle->h_jcb, &transaction->t_jcb);
++	spin_unlock(&transaction->t_jcb_lock);
++
+ 	/*
+ 	 * If the handle is marked SYNC, we need to set another commit
+ 	 * going!  We also want to force a commit if the current
diff --git a/lustre/kernel_patches/patches/md-mmp-unplug-dev-sles10.patch b/lustre/kernel_patches/patches/md-mmp-unplug-dev-sles10.patch
index 3ea4c6b..8bfdef3 100644
--- a/lustre/kernel_patches/patches/md-mmp-unplug-dev-sles10.patch
+++ b/lustre/kernel_patches/patches/md-mmp-unplug-dev-sles10.patch
@@ -1,9 +1,9 @@
-Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
+Index: linux-2.6.16.60-0.33/drivers/md/raid5.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/md/raid5.c	2009-05-11 23:23:39.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/md/raid5.c	2009-05-11 23:25:08.000000000 -0600
-@@ -928,6 +928,8 @@
- #endif
+--- linux-2.6.16.60-0.33.orig/drivers/md/raid5.c
++++ linux-2.6.16.60-0.33/drivers/md/raid5.c
+@@ -900,6 +900,8 @@ static int add_stripe_bio(struct stripe_
+ 		bi->bi_next = *bip;
  	*bip = bi;
  	bi->bi_phys_segments ++;
 +	if (bio_sync(bi) && !forwrite)
@@ -11,7 +11,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  	spin_unlock_irq(&conf->device_lock);
  	spin_unlock(&sh->lock);
  
-@@ -1676,6 +1678,8 @@
+@@ -1617,6 +1619,8 @@ static int make_request (request_queue_t
  		bi->bi_end_io(bi, bytes, 0);
  	}
  	spin_unlock_irq(&conf->device_lock);
diff --git a/lustre/kernel_patches/patches/md-mmp-unplug-dev-sles11.patch b/lustre/kernel_patches/patches/md-mmp-unplug-dev-sles11.patch
new file mode 100644
index 0000000..ecb9f54
--- /dev/null
+++ b/lustre/kernel_patches/patches/md-mmp-unplug-dev-sles11.patch
@@ -0,0 +1,22 @@
+Index: linux-2.6.27.21-0.1/drivers/md/raid5.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/drivers/md/raid5.c	2009-04-23 02:12:52.000000000 -0600
++++ linux-2.6.27.21-0.1/drivers/md/raid5.c	2009-05-22 08:38:38.000000000 -0600
+@@ -1760,6 +1760,8 @@
+ 		bi->bi_next = *bip;
+ 	*bip = bi;
+ 	bi->bi_phys_segments++;
++	if (bio_sync(bi) && !forwrite)
++		clear_bit(R5_UPTODATE, &sh->dev[dd_idx].flags); /* force to read from disk. */
+ 	spin_unlock_irq(&conf->device_lock);
+ 	spin_unlock(&sh->lock);
+ 
+@@ -3513,6 +3515,8 @@
+ 
+ 		bio_endio(bi, 0);
+ 	}
++	if (bio_sync(bi))
++		raid5_unplug_device(q);
+ 	return 0;
+ }
+ 
diff --git a/lustre/kernel_patches/patches/md-mmp-unplug-dev.patch b/lustre/kernel_patches/patches/md-mmp-unplug-dev.patch
index 0334abd..9397766 100644
--- a/lustre/kernel_patches/patches/md-mmp-unplug-dev.patch
+++ b/lustre/kernel_patches/patches/md-mmp-unplug-dev.patch
@@ -1,8 +1,8 @@
-Index: linux-2.6.22.14/drivers/md/raid5.c
+Index: linux-2.6.18-128.1.14/drivers/md/raid5.c
 ===================================================================
---- linux-2.6.22.14.orig/drivers/md/raid5.c
-+++ linux-2.6.22.14/drivers/md/raid5.c
-@@ -1268,6 +1268,8 @@ static int add_stripe_bio(struct stripe_
+--- linux-2.6.18-128.1.14.orig/drivers/md/raid5.c	2009-06-19 12:35:07.000000000 -0600
++++ linux-2.6.18-128.1.14/drivers/md/raid5.c	2009-06-19 12:35:26.000000000 -0600
+@@ -1456,6 +1456,8 @@
  		bi->bi_next = *bip;
  	*bip = bi;
  	bi->bi_phys_segments ++;
@@ -11,9 +11,9 @@ Index: linux-2.6.22.14/drivers/md/raid5.c
  	spin_unlock_irq(&conf->device_lock);
  	spin_unlock(&sh->lock);
  
-@@ -2972,6 +2974,8 @@ static int make_request(request_queue_t 
- 			      test_bit(BIO_UPTODATE, &bi->bi_flags)
- 			        ? 0 : -EIO);
+@@ -3012,6 +3014,8 @@
+ 		bi->bi_size = 0;
+ 		bi->bi_end_io(bi, bytes, 0);
  	}
 +	if (bio_sync(bi))
 +		raid5_unplug_device(q);
diff --git a/lustre/kernel_patches/patches/md-rebuild-policy.patch b/lustre/kernel_patches/patches/md-rebuild-policy.patch
index 62bb484..9d441c0 100644
--- a/lustre/kernel_patches/patches/md-rebuild-policy.patch
+++ b/lustre/kernel_patches/patches/md-rebuild-policy.patch
@@ -1,7 +1,8 @@
-diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
---- linux-2.6.18-53.orig/drivers/md/md.c	2008-02-13 17:34:25.000000000 +0800
-+++ linux-2.6.18-53/drivers/md/md.c	2008-02-13 17:39:28.000000000 +0800
-@@ -90,6 +90,8 @@ static void md_print_devices(void);
+Index: linux-2.6.18-128.1.14/drivers/md/md.c
+===================================================================
+--- linux-2.6.18-128.1.14.orig/drivers/md/md.c	2009-06-19 12:33:11.000000000 -0600
++++ linux-2.6.18-128.1.14/drivers/md/md.c	2009-06-19 12:35:02.000000000 -0600
+@@ -90,6 +90,8 @@
  
  static int sysctl_speed_limit_min = 1000;
  static int sysctl_speed_limit_max = 200000;
@@ -10,7 +11,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  static inline int speed_min(mddev_t *mddev)
  {
  	return mddev->sync_speed_min ?
-@@ -121,6 +123,22 @@ static ctl_table raid_table[] = {
+@@ -121,6 +123,22 @@
  		.mode		= S_IRUGO|S_IWUSR,
  		.proc_handler	= &proc_dointvec,
  	},
@@ -33,7 +34,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  	{ .ctl_name = 0 }
  };
  
-@@ -4980,15 +4998,16 @@ static int is_mddev_idle(mddev_t *mddev)
+@@ -5009,15 +5027,16 @@
  {
  	mdk_rdev_t * rdev;
  	int idle;
@@ -41,8 +42,8 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
 +	unsigned long rw, sync;
  
  	idle = 1;
-	rcu_read_lock();
-	rdev_for_each_rcu(rdev, mddev) {
+ 	rcu_read_lock();
+ 	rdev_for_each_rcu(rdev, mddev) {
  		struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
 -		curr_events = disk_stat_read(disk, sectors[0]) + 
 -				disk_stat_read(disk, sectors[1]) - 
@@ -54,7 +55,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  		/* The difference between curr_events and last_events
  		 * will be affected by any new non-sync IO (making
  		 * curr_events bigger) and any difference in the amount of
-@@ -5001,9 +5020,9 @@ static int is_mddev_idle(mddev_t *mddev)
+@@ -5031,9 +5050,9 @@
  		 *
  		 * Note: the following is an unsigned comparison.
  		 */
@@ -65,8 +66,8 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
 +			rdev->last_events = rw - sync;
  		}
  	}
- 	return idle;
-@@ -5069,8 +5088,7 @@ static DECLARE_WAIT_QUEUE_HEAD(resync_wa
+ 	rcu_read_unlock();
+@@ -5100,8 +5119,7 @@
  void md_do_sync(mddev_t *mddev)
  {
  	mddev_t *mddev2;
@@ -76,7 +77,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  	sector_t max_sectors,j, io_sectors;
  	unsigned long mark[SYNC_MARKS];
  	sector_t mark_cnt[SYNC_MARKS];
-@@ -5190,9 +5208,8 @@ void md_do_sync(mddev_t *mddev)
+@@ -5221,9 +5239,8 @@
  	/*
  	 * Tune reconstruction:
  	 */
@@ -87,7 +88,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  
  	atomic_set(&mddev->recovery_active, 0);
  	init_waitqueue_head(&mddev->recovery_wait);
-@@ -5230,7 +5247,7 @@ void md_do_sync(mddev_t *mddev)
+@@ -5261,7 +5278,7 @@
  			 */
  			md_new_event(mddev);
  
@@ -96,7 +97,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  			continue;
  
  		last_check = io_sectors;
-@@ -5251,7 +5268,6 @@ void md_do_sync(mddev_t *mddev)
+@@ -5282,7 +5299,6 @@
  			last_mark = next;
  		}
  
@@ -104,7 +105,7 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  		if (kthread_should_stop()) {
  			/*
  			 * got a signal, exit.
-@@ -5275,10 +5291,16 @@ void md_do_sync(mddev_t *mddev)
+@@ -5306,10 +5322,16 @@
  
  		currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2
  			/((jiffies-mddev->resync_mark)/HZ +1) +1;
@@ -122,10 +123,11 @@ diff -pur linux-2.6.18-53.orig/drivers/md/md.c linux-2.6.18-53/drivers/md/md.c
  				msleep(500);
  				goto repeat;
  			}
-diff -pur linux-2.6.18-53.orig/include/linux/sysctl.h linux-2.6.18-53/include/linux/sysctl.h
---- linux-2.6.18-53.orig/include/linux/sysctl.h	2008-02-13 17:35:25.000000000 +0800
-+++ linux-2.6.18-53/include/linux/sysctl.h	2008-02-13 17:36:22.000000000 +0800
-@@ -903,7 +903,9 @@ enum {
+Index: linux-2.6.18-128.1.14/include/linux/sysctl.h
+===================================================================
+--- linux-2.6.18-128.1.14.orig/include/linux/sysctl.h	2009-06-19 12:33:11.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/sysctl.h	2009-06-19 12:35:02.000000000 -0600
+@@ -928,7 +928,9 @@
  /* /proc/sys/dev/raid */
  enum {
  	DEV_RAID_SPEED_LIMIT_MIN=1,
diff --git a/lustre/kernel_patches/patches/mpt-fusion-downgrade-to-3_02_73-rhel4.patch b/lustre/kernel_patches/patches/mpt-fusion-downgrade-to-3_02_73-rhel4.patch
index 7cd5824..7bb3440 100644
--- a/lustre/kernel_patches/patches/mpt-fusion-downgrade-to-3_02_73-rhel4.patch
+++ b/lustre/kernel_patches/patches/mpt-fusion-downgrade-to-3_02_73-rhel4.patch
@@ -1,53 +1,7 @@
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/csmi/csmisas.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c	2009-04-18 06:33:31.404506136 -0600
-@@ -1,5755 +0,0 @@
--/*
-- *  linux/drivers/message/fusion/csmi/csmisas.c
-- *      For use with LSI Logic PCI chip/adapter(s)
-- *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
-- *
-- *  Copyright (c) 1999-2007 LSI Logic Corporation
-- *  (mailto:mpt_linux_developer at lsi.com)
-- */
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*
--    This program is free software; you can redistribute it and/or modify
--    it under the terms of the GNU General Public License as published by
--    the Free Software Foundation; version 2 of the License.
--
--    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 for more details.
--
--    NO WARRANTY
--    THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
--    CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
--    LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
--    MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
--    solely responsible for determining the appropriateness of using and
--    distributing the Program and assumes all risks associated with its
--    exercise of rights under this Agreement, including but not limited to
--    the risks and costs of program errors, damage to or loss of data,
--    programs or equipment, and unavailability or interruption of operations.
--
--    DISCLAIMER OF LIABILITY
--    NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
--    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
--    DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
--    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
--    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
--    USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
--    HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
--
--    You should have received a copy of the GNU General Public License
--    along with this program; if not, write to the Free Software
--    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--*/
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/csmi/csmisas.c linux-2.6.9-55.0.12/drivers/message/fusion/csmi/csmisas.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/csmi/csmisas.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/csmi/csmisas.c	1970-01-01 01:00:00.000000000 +0100
+@@ -1,5894 +0,0 @@
 -#define MPT_CSMI_DESCRIPTION "LSI Logic Corporation: Fusion MPT Driver "MPT_LINUX_VERSION_COMMON
 -#define csmisas_is_this_sas_cntr(ioc) (ioc->bus_type == SAS) ? 1 : 0
 -
@@ -281,8 +235,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	down(&ioc->sas_device_info_mutex);
 -	list_for_each_entry(p, &ioc->sas_device_info_list, list) {
+-		dcsmisasprintk((KERN_ERR
+-		    ":%s()"
+-		    " looking for SASAddress=%llX entry SASAddress=%llX\n",
+-		    __FUNCTION__, sas_address, p->sas_address));
 -		if (p->sas_address == sas_address) {
 -			sas_info = p;
+-			dcsmisasprintk((KERN_ERR
+-				":%s()"
+-				" found SASAddress=%llX\n",
+-				__FUNCTION__, sas_address));
 -			goto out;
 -		}
 -	}
@@ -305,26 +267,41 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 - *	non-zero, failure
 - **/
 -static int
--csmisas_send_command_wait(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, unsigned long timeout)
+-csmisas_send_command_wait(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, int timeout)
 -{
 -	int rc;
--	unsigned long timeleft;
+-	int mf_timeout;
 -
--	timeout = max_t(unsigned long, MPT_IOCTL_DEFAULT_TIMEOUT, timeout);
+-	mf_timeout = max_t(int, MPT_IOCTL_DEFAULT_TIMEOUT, timeout);
+-	INITIALIZE_IOCTL_STATUS(ioc->ioctl->status)
+-	ioc->ioctl->wait_done = 0;
 -	rc = 0;
--	timeleft = 0;
 -
--	INITIALIZE_IOCTL_STATUS(ioc->ioctl_cmds.status)
--	ioc->ioctl_cmds.wait_done = 0;
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+-	ioc->ioctl->timer.expires = jiffies + (MPT_JIFFY * mf_timeout);
+-	ioc->ioctl->status |= MPT_IOCTL_STATUS_TIMER_ACTIVE;
+-	ADD_TIMER(&ioc->ioctl->timer);
+-#endif
+-
 -	mpt_put_msg_frame(mptctl_id, ioc, mf);
 -
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+-	WAIT_EVENT(mptctl_wait, ioc->ioctl->wait_done);
+-#else
 -	if ((wait_event_timeout(mptctl_wait,
--	    ioc->ioctl_cmds.wait_done == 1, HZ * timeout) <=0) &&
--	    ioc->ioctl_cmds.wait_done != 1 ) {
--		mptctl_timeout_expired(ioc,mf);
+-	    ioc->ioctl->wait_done == 1, HZ * mf_timeout) <=0) &&
+-	    ioc->ioctl->wait_done != 1 ) {
 -		mpt_free_msg_frame(ioc, mf);
+-		mptctl_timeout_expired(ioc->ioctl);
 -		rc = -1;
 -	}
+-#endif
+-
+-	if (rc != 0)
+-		dfailprintk((KERN_ERR "%s@%d::%s() - "
+-		    "%s IOCTL timeout (%d)\n",
+-		    __FILE__, __LINE__, __FUNCTION__,
+-		    ioc->name, mf_timeout));
 -
 -	return rc;
 -}
@@ -343,28 +320,125 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 - *	non-zero, failure
 - **/
 -static int
--csmisas_send_handshake_wait(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, unsigned long timeout)
+-csmisas_send_handshake_wait(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, int timeout)
 -{
 -	int rc;
--	unsigned long timeleft;
+-	int mf_timeout;
 -
--	timeout = max_t(unsigned long, MPT_IOCTL_DEFAULT_TIMEOUT, timeout);
+-	mf_timeout = max_t(int, MPT_IOCTL_DEFAULT_TIMEOUT, timeout);
+-	INITIALIZE_IOCTL_STATUS(ioc->ioctl->status)
+-	ioc->ioctl->wait_done = 0;
 -	rc = 0;
--	timeleft = 0;
 -
--	INITIALIZE_IOCTL_STATUS(ioc->taskmgmt_cmds.status)
--	ioc->taskmgmt_cmds.wait_done = 0;
--	rc = mpt_send_handshake_request(mptctl_taskmgmt_id, ioc,
--	    sizeof(SCSITaskMgmt_t), (u32*)mf, timeout, CAN_SLEEP);
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+-	ioc->ioctl->timer.expires = jiffies + (MPT_JIFFY * mf_timeout);
+-	ioc->ioctl->status |= MPT_IOCTL_STATUS_TIMER_ACTIVE;
+-	ADD_TIMER(&ioc->ioctl->timer);
+-#endif
+-
+-	rc = mpt_send_handshake_request(mptctl_id, ioc,
+-	    sizeof(SCSITaskMgmt_t), (u32*)mf,timeout, CAN_SLEEP);
 -	if (rc != 0)
 -		return rc;
--	if ((wait_event_timeout(mptctl_taskmgmt_wait,
--	    ioc->taskmgmt_cmds.wait_done == 1, HZ * timeout) <=0) &&
--	    ioc->taskmgmt_cmds.wait_done != 1 ) {
--		mptctl_timeout_expired(ioc, mf);
+-
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+-	WAIT_EVENT(mptctl_wait, ioc->ioctl->wait_done);
+-#else
+-	if ((wait_event_timeout(mptctl_wait,
+-	    ioc->ioctl->wait_done == 1, HZ * mf_timeout) <=0) &&
+-	    ioc->ioctl->wait_done != 1 ) {
 -		mpt_free_msg_frame(ioc, mf);
+-		mptctl_timeout_expired(ioc->ioctl);
 -		rc = -1;
 -	}
+-#endif
+-
+-	if (rc != 0)
+-		dfailprintk((KERN_ERR "%s@%d::%s() - "
+-		    "%s IOCTL timeout (%d)\n", __FILE__, __LINE__,
+-		    __FUNCTION__, ioc->name, mf_timeout));
+-
+-	return rc;
+-}
+-
+-/**
+- *	csmisas_get_manufacture_pg0 - Manufacturing Page 0.
+- *	@ioc: Pointer to MPT_ADAPTER structure
+- *	@mfgPage0: read only info set at manufacturing time
+- *
+- *	Return: 0 for success
+- *	-ENOMEM if no memory available
+- *		-EPERM if not allowed due to ISR context
+- *		-EAGAIN if no msg frames currently available
+- *		-EFAULT for non-successful reply or no reply (timeout)
+- **/
+-static int
+-csmisas_get_manufacture_pg0(MPT_ADAPTER *ioc, ManufacturingPage0_t *mfgPage0)
+-{
+-
+-	ConfigPageHeader_t	 hdr;
+-	CONFIGPARMS		 cfg;
+-	ManufacturingPage0_t	 *buffer = NULL;
+-	dma_addr_t		 dma_handle;
+-	int			 data_sz;
+-	int			 rc;
+-
+-	/*
+-	 * Get Manufacturing Page 0 header
+-	 */
+-	data_sz = 0;
+-	hdr.PageVersion = MPI_MANUFACTURING0_PAGEVERSION;
+-	hdr.PageLength = 0;
+-	hdr.PageNumber = 0;
+-	hdr.PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING;
+-	cfg.cfghdr.hdr = &hdr;
+-	cfg.physAddr = -1;
+-	cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
+-	cfg.dir = 0;
+-	cfg.pageAddr = 0;
+-	cfg.timeout = 0;
+-
+-	if ((rc = mpt_config(ioc, &cfg)) != 0)
+-		goto get_manufacture_pg0_out;
+-
+-	if (hdr.PageLength == 0) {
+-		rc = -EFAULT;
+-		goto get_manufacture_pg0_out;
+-	}
+-
+-	data_sz = hdr.PageLength * 4;
+-	buffer = (ManufacturingPage0_t *) pci_alloc_consistent(ioc->pcidev,
+-		data_sz, &dma_handle);
+-	if (!buffer) {
+-		rc = -ENOMEM;
+-		goto get_manufacture_pg0_out;
+-	}
+-
+-	memset((u8 *)buffer, 0, data_sz);
+-	cfg.physAddr = dma_handle;
+-	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
+-
+-	if ((rc = mpt_config(ioc, &cfg)) != 0)
+-		goto get_manufacture_pg0_out;
+-
+-	strncpy(mfgPage0->ChipName, buffer->ChipName, 16);
+-	strncpy(mfgPage0->ChipRevision, buffer->ChipRevision, 8);
+-	strncpy(mfgPage0->BoardName, buffer->BoardName, 16);
+-	strncpy(mfgPage0->BoardAssembly, buffer->BoardAssembly, 16);
+-	strncpy(mfgPage0->BoardTracerNumber, buffer->BoardTracerNumber, 16);
+-
+-	dcsmisasprintk(("ChipName=%s\n",buffer->ChipName));
+-	dcsmisasprintk(("ChipRevision=%s\n",buffer->ChipRevision));
+-	dcsmisasprintk(("BoardName=%s\n",buffer->BoardName));
+-	dcsmisasprintk(("BoardAssembly=%s\n",buffer->BoardAssembly));
+-	dcsmisasprintk(("BoardTracerNumber=%s\n",buffer->BoardTracerNumber));
+-
+- get_manufacture_pg0_out:
+-
+-	if (buffer)
+-		pci_free_consistent(ioc->pcidev, data_sz,
+-		    (u8 *) buffer, dma_handle);
+-
 -
 -	return rc;
 -}
@@ -597,6 +671,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	MPT_ADAPTER	*ioc = NULL;
 -	int		iocnum;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_DRIVER_INFO_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s - "
 -	      "Unable to read in csmi_sas_get_driver_info_buffer struct @ %p\n",
@@ -606,19 +682,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Fill in the data and return the structure to the calling
 -	 * program
 -	 */
@@ -647,7 +723,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -667,7 +743,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	CSMI_SAS_CNTLR_CONFIG_BUFFER	karg;
 -	MPT_ADAPTER	*ioc = NULL;
 -	int		iocnum;
--	u64		mem_phys;
+-	int		ii,msize,psize;
+-	unsigned int 	reg;
+-	u32      	l;
+-	ManufacturingPage0_t mfgPage0;
+-
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
 -
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_CNTLR_CONFIG_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s - "
@@ -678,20 +759,20 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-	      "%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_INVALID_PARAMETER;
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Clear the struct before filling in data. */
 -	memset( &karg.Configuration, 0, sizeof(CSMI_SAS_CNTLR_CONFIG));
 -
@@ -699,12 +780,38 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	 * program
 -	 */
 -
--	karg.Configuration.uBaseIoAddress = ioc->pio_mem_phys;
--	karg.Configuration.BaseMemoryAddress.uLowPart = ioc->mem_phys;
--	if (sizeof(ioc->mem_phys) == sizeof(u64)) {
--		mem_phys = ioc->mem_phys;
--		karg.Configuration.BaseMemoryAddress.uHighPart =
--		    (u32)(mem_phys >> 32);
+-	/* Get Base IO and Mem Mapped Addresses. */
+-msize = psize = 0;
+-for(ii=0; ii < DEVICE_COUNT_RESOURCE; ii++) {
+-		reg = PCI_BASE_ADDRESS_0 + (ii << 2);
+-		pci_read_config_dword(ioc->pcidev, reg, &l);
+-
+-		if ((l & PCI_BASE_ADDRESS_SPACE) ==
+-                       PCI_BASE_ADDRESS_SPACE_MEMORY) {
+-		    if(msize)
+-                         continue;
+-	            msize=1;
+-		karg.Configuration.BaseMemoryAddress.uLowPart =
+-			    l & PCI_BASE_ADDRESS_MEM_MASK;
+-
+-		if ((l & (PCI_BASE_ADDRESS_SPACE |
+-                   PCI_BASE_ADDRESS_MEM_TYPE_MASK))
+-                   == (PCI_BASE_ADDRESS_SPACE_MEMORY |
+-                   PCI_BASE_ADDRESS_MEM_TYPE_64)) {
+-                     pci_read_config_dword(ioc->pcidev, reg+4, &l);
+-                     karg.Configuration.BaseMemoryAddress.uHighPart = l;
+-                  }
+-               }
+-
+-
+-                  else {
+-		        if(psize)
+-                       continue;
+-                       psize=1;
+-			karg.Configuration.uBaseIoAddress =
+-			    l & PCI_BASE_ADDRESS_IO_MASK;
+-		}
+-
 -	}
 -
 -	karg.Configuration.uBoardID = (ioc->pcidev->subsystem_device << 16) |
@@ -722,7 +829,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	karg.Configuration.BusAddress.PciAddress.bFunctionNumber =
 -	    PCI_FUNC(ioc->pcidev->devfn);
 -	karg.Configuration.BusAddress.PciAddress.bReserved = 0;
--	memcpy( &karg.Configuration.szSerialNumber, ioc->board_tracer, 16 );
+-	if (!csmisas_get_manufacture_pg0(ioc, &mfgPage0))
+-		memcpy( &karg.Configuration.szSerialNumber,
+-		    mfgPage0.BoardTracerNumber, 16 );
 -	karg.Configuration.usMajorRevision = ioc->facts.FWVersion.Struct.Major;
 -	karg.Configuration.usMinorRevision = ioc->facts.FWVersion.Struct.Minor;
 -	karg.Configuration.usBuildRevision = ioc->facts.FWVersion.Struct.Unit;
@@ -759,7 +868,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -781,6 +890,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int			iocnum;
 -	int			rc;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_CNTLR_STATUS_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s - "
 -	     "Unable to read in csmi_sas_get_cntlr_status_buffer struct @ %p\n",
@@ -790,19 +901,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Fill in the data and return the structure to the calling
 -	 * program
 -	 */
@@ -842,7 +953,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -858,7 +969,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -csmisas_get_phy_info(unsigned long arg)
 -{
 -	CSMI_SAS_PHY_INFO_BUFFER __user *uarg = (void __user *) arg;
--	CSMI_SAS_PHY_INFO_BUFFER  *karg;
+-	CSMI_SAS_PHY_INFO_BUFFER  karg;
 -	MPT_ADAPTER		*ioc = NULL;
 -	ConfigExtendedPageHeader_t  hdr;
 -	CONFIGPARMS		cfg;
@@ -874,55 +985,39 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int			ii;
 -	u64			sas_address;
 -	struct mptsas_devinfo	device_info;
--	int			memory_pages;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
 -	sasIoUnitPg0=NULL;
 -	sasPhyPg0=NULL;
 -	sasIoUnitPg0_data_sz=0;
 -	sasPhyPg0_data_sz=0;
 -
--	memory_pages = get_order(sizeof(CSMI_SAS_PHY_INFO_BUFFER));
--	karg = (CSMI_SAS_PHY_INFO_BUFFER *)__get_free_pages(
--		GFP_KERNEL, memory_pages);
--	if (!karg){
--		printk(KERN_ERR "%s@%d::%s() - "
--			"Unable to malloc CSMI_SAS_PHY_INFO_BUFFER "
--			"malloc_data_sz=%d memory_pages=%d\n",
--			__FILE__, __LINE__, __FUNCTION__,
--			(int)sizeof(CSMI_SAS_PHY_INFO_BUFFER), memory_pages);
--		return -ENOMEM;
--	}
--
--	memset(karg, 0, sizeof(*karg));
--
--	if (copy_from_user(karg, uarg, sizeof(CSMI_SAS_PHY_INFO_BUFFER))) {
+-	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_PHY_INFO_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s - "
 -		"Unable to read in csmisas_get_phy_info_buffer struct @ %p\n",
 -		    __FILE__, __LINE__, __FUNCTION__, uarg);
--		free_pages((unsigned long)karg, memory_pages);
 -		return -EFAULT;
 -	}
 -
--	if (((iocnum = mpt_verify_adapter(karg->IoctlHeader.IOControllerNumber,
+-	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
--		free_pages((unsigned long)karg, memory_pages);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
--		free_pages((unsigned long)karg, memory_pages);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Fill in the data and return the structure to the calling
 -	 * program
 -	 */
+-	memset(&karg.Information, 0, sizeof(CSMI_SAS_PHY_INFO));
 -
 -	/* Issue a config request to get the number of phys
 -	 */
@@ -945,10 +1040,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((
 -		    ": FAILED: MPI_SASIOUNITPAGE0_PAGEVERSION: HEADER\n"));
--		dcsmisasprintk(ioc, printk(": rc=%x\n",rc));
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-		dcsmisasprintk((": rc=%x\n",rc));
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto sas_get_phy_info_exit;
 -	}
 -
@@ -956,8 +1051,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR ": hdr.ExtPageLength == 0\n"));
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-		dcsmisasprintk((": hdr.ExtPageLength == 0\n"));
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto sas_get_phy_info_exit;
 -	}
 -
@@ -968,8 +1063,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    sasIoUnitPg0_data_sz, &sasIoUnitPg0_dma);
 -
 -	if (!sasIoUnitPg0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto sas_get_phy_info_exit;
 -	}
 -
@@ -982,54 +1077,54 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((
 -		    ": FAILED: MPI_SASIOUNITPAGE0_PAGEVERSION: PAGE\n"));
--		dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-		dcsmisasprintk((": rc=%x\n",rc));
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto sas_get_phy_info_exit;
 -	}
 -
 -	/* Number of Phys. */
--	karg->Information.bNumberOfPhys = sasIoUnitPg0->NumPhys;
+-	karg.Information.bNumberOfPhys = sasIoUnitPg0->NumPhys;
 -
 -	/* Fill in information for each phy. */
--	for (ii = 0; ii < karg->Information.bNumberOfPhys; ii++) {
+-	for (ii = 0; ii < karg.Information.bNumberOfPhys; ii++) {
 -
 -/* EDM : dump IO Unit Page 0 data*/
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "---- IO UNIT PAGE 0 ------------\n"));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n",
+-		dcsmisasprintk(("---- IO UNIT PAGE 0 ------------\n"));
+-		dcsmisasprintk(("Handle=0x%X\n",
 -		    le16_to_cpu(sasIoUnitPg0->PhyData[ii].AttachedDeviceHandle)));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Controller Handle=0x%X\n",
+-		dcsmisasprintk(("Controller Handle=0x%X\n",
 -		    le16_to_cpu(sasIoUnitPg0->PhyData[ii].ControllerDevHandle)));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Port=0x%X\n",
+-		dcsmisasprintk(("Port=0x%X\n",
 -		    sasIoUnitPg0->PhyData[ii].Port));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Port Flags=0x%X\n",
+-		dcsmisasprintk(("Port Flags=0x%X\n",
 -		    sasIoUnitPg0->PhyData[ii].PortFlags));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "PHY Flags=0x%X\n",
+-		dcsmisasprintk(("PHY Flags=0x%X\n",
 -		    sasIoUnitPg0->PhyData[ii].PhyFlags));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Negotiated Link Rate=0x%X\n",
+-		dcsmisasprintk(("Negotiated Link Rate=0x%X\n",
 -		    sasIoUnitPg0->PhyData[ii].NegotiatedLinkRate));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Controller PHY Device Info=0x%X\n",
+-		dcsmisasprintk(("Controller PHY Device Info=0x%X\n",
 -		    le32_to_cpu(sasIoUnitPg0->PhyData[ii].ControllerPhyDeviceInfo)));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "DiscoveryStatus=0x%X\n",
+-		dcsmisasprintk(("DiscoveryStatus=0x%X\n",
 -		    le32_to_cpu(sasIoUnitPg0->PhyData[ii].DiscoveryStatus)));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "\n"));
+-		dcsmisasprintk(("\n"));
 -/* EDM : debug data */
 -
 -		/* PHY stuff. */
--		karg->Information.Phy[ii].bPortIdentifier =
+-		karg.Information.Phy[ii].bPortIdentifier =
 -		    sasIoUnitPg0->PhyData[ii].Port;
 -
 -		/* Get the negotiated link rate for the phy. */
 -		switch (sasIoUnitPg0->PhyData[ii].NegotiatedLinkRate) {
 -
 -		case MPI_SAS_IOUNIT0_RATE_PHY_DISABLED:
--			karg->Information.Phy[ii].bNegotiatedLinkRate =
+-			karg.Information.Phy[ii].bNegotiatedLinkRate =
 -			    CSMI_SAS_PHY_DISABLED;
 -			break;
 -
 -		case MPI_SAS_IOUNIT0_RATE_FAILED_SPEED_NEGOTIATION:
--			karg->Information.Phy[ii].bNegotiatedLinkRate =
+-			karg.Information.Phy[ii].bNegotiatedLinkRate =
 -			    CSMI_SAS_LINK_RATE_FAILED;
 -			break;
 -
@@ -1037,28 +1132,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			break;
 -
 -		case MPI_SAS_IOUNIT0_RATE_1_5:
--			karg->Information.Phy[ii].bNegotiatedLinkRate =
+-			karg.Information.Phy[ii].bNegotiatedLinkRate =
 -			    CSMI_SAS_LINK_RATE_1_5_GBPS;
 -			break;
 -
 -		case MPI_SAS_IOUNIT0_RATE_3_0:
--			karg->Information.Phy[ii].bNegotiatedLinkRate =
+-			karg.Information.Phy[ii].bNegotiatedLinkRate =
 -			    CSMI_SAS_LINK_RATE_3_0_GBPS;
 -			break;
 -
 -		case MPI_SAS_IOUNIT0_RATE_UNKNOWN:
 -		default:
--			karg->Information.Phy[ii].bNegotiatedLinkRate =
+-			karg.Information.Phy[ii].bNegotiatedLinkRate =
 -			    CSMI_SAS_LINK_RATE_UNKNOWN;
 -			break;
 -		}
 -
 -		if (sasIoUnitPg0->PhyData[ii].PortFlags &
 -		    MPI_SAS_IOUNIT0_PORT_FLAGS_DISCOVERY_IN_PROGRESS) {
--			karg->Information.Phy[ii].bAutoDiscover =
+-			karg.Information.Phy[ii].bAutoDiscover =
 -			    CSMI_SAS_DISCOVER_IN_PROGRESS;
 -		} else {
--			karg->Information.Phy[ii].bAutoDiscover =
+-			karg.Information.Phy[ii].bAutoDiscover =
 -			    CSMI_SAS_DISCOVER_COMPLETE;
 -		}
 -
@@ -1081,16 +1176,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		cfg.timeout = MPT_IOCTL_DEFAULT_TIMEOUT;
 -
 -		if ((rc = mpt_config(ioc, &cfg)) != 0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR
+-			dcsmisasprintk((
 -			    ": FAILED: MPI_SASPHY0_PAGEVERSION: HEADER\n"));
--			dcsmisasprintk(ioc, printk(": rc=%x\n",rc));
--			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-			dcsmisasprintk((": rc=%x\n",rc));
+-			karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto sas_get_phy_info_exit;
 -		}
 -
 -		if (hdr.ExtPageLength == 0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
--			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-			dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
+-			karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto sas_get_phy_info_exit;
 -		}
 -
@@ -1101,8 +1196,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    ioc->pcidev, sasPhyPg0_data_sz, &sasPhyPg0_dma);
 -
 -		if (! sasPhyPg0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
--			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-			dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
+-			karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto sas_get_phy_info_exit;
 -		}
 -
@@ -1111,10 +1206,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
 -
 -		if ((rc = mpt_config(ioc, &cfg)) != 0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR
+-			dcsmisasprintk((
 -			    ": FAILED: MPI_SASPHY0_PAGEVERSION: PAGE\n"));
--			dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
--			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-			dcsmisasprintk((": rc=%x\n",rc));
+-			karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			pci_free_consistent(ioc->pcidev, sasPhyPg0_data_sz,
 -			    (u8 *) sasPhyPg0, sasPhyPg0_dma);
 -			goto sas_get_phy_info_exit;
@@ -1122,24 +1217,24 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -/* EDM : dump PHY Page 0 data*/
 -		memcpy(&sas_address, &sasPhyPg0->SASAddress, sizeof(u64));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 0 ------------\n"));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n",
+-		dcsmisasprintk(("---- SAS PHY PAGE 0 ------------\n"));
+-		dcsmisasprintk(("Handle=0x%X\n",
 -		    le16_to_cpu(sasPhyPg0->AttachedDevHandle)));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n",
+-		dcsmisasprintk(("SAS Address=0x%llX\n",
 -		    (unsigned long long)sas_address));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Attached PHY Identifier=0x%X\n",
+-		dcsmisasprintk(("Attached PHY Identifier=0x%X\n",
 -		    sasPhyPg0->AttachedPhyIdentifier));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Attached Device Info=0x%X\n",
+-		dcsmisasprintk(("Attached Device Info=0x%X\n",
 -		    le32_to_cpu(sasPhyPg0->AttachedDeviceInfo)));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Programmed Link Rate=0x%X\n",
+-		dcsmisasprintk(("Programmed Link Rate=0x%X\n",
 -		    sasPhyPg0->ProgrammedLinkRate));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Hardware Link Rate=0x%X\n",
+-		dcsmisasprintk(("Hardware Link Rate=0x%X\n",
 -		    sasPhyPg0->HwLinkRate));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "Change Count=0x%X\n",
+-		dcsmisasprintk(("Change Count=0x%X\n",
 -		    sasPhyPg0->ChangeCount));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "PHY Info=0x%X\n",
+-		dcsmisasprintk(("PHY Info=0x%X\n",
 -		    le32_to_cpu(sasPhyPg0->PhyInfo)));
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "\n"));
+-		dcsmisasprintk(("\n"));
 -/* EDM : debug data */
 -
 -		/* save the data */
@@ -1156,12 +1251,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
 -
 -		case MPI_SAS_PHY0_HWRATE_MAX_RATE_1_5:
--			karg->Information.Phy[ii].bMaximumLinkRate =
+-			karg.Information.Phy[ii].bMaximumLinkRate =
 -			    CSMI_SAS_LINK_RATE_1_5_GBPS;
 -			break;
 -
 -		case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
--			karg->Information.Phy[ii].bMaximumLinkRate =
+-			karg.Information.Phy[ii].bMaximumLinkRate =
 -			    CSMI_SAS_LINK_RATE_3_0_GBPS;
 -			break;
 -		default:
@@ -1173,12 +1268,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    MPI_SAS_PHY0_PRATE_MAX_RATE_MASK) {
 -
 -		case MPI_SAS_PHY0_PRATE_MAX_RATE_1_5:
--			karg->Information.Phy[ii].bMaximumLinkRate |=
+-			karg.Information.Phy[ii].bMaximumLinkRate |=
 -			    (CSMI_SAS_PROGRAMMED_LINK_RATE_1_5_GBPS << 4);
 -			break;
 -
 -		case MPI_SAS_PHY0_PRATE_MAX_RATE_3_0:
--			karg->Information.Phy[ii].bMaximumLinkRate |=
+-			karg.Information.Phy[ii].bMaximumLinkRate |=
 -			    (CSMI_SAS_PROGRAMMED_LINK_RATE_3_0_GBPS << 4);
 -			break;
 -		default:
@@ -1190,12 +1285,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    MPI_SAS_PHY0_HWRATE_MIN_RATE_MASK) {
 -
 -		case MPI_SAS_PHY0_HWRATE_MIN_RATE_1_5:
--			karg->Information.Phy[ii].bMinimumLinkRate =
+-			karg.Information.Phy[ii].bMinimumLinkRate =
 -			    CSMI_SAS_LINK_RATE_1_5_GBPS;
 -			break;
 -
 -		case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
--			karg->Information.Phy[ii].bMinimumLinkRate =
+-			karg.Information.Phy[ii].bMinimumLinkRate =
 -			    CSMI_SAS_LINK_RATE_3_0_GBPS;
 -			break;
 -		default:
@@ -1207,21 +1302,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    MPI_SAS_PHY0_PRATE_MIN_RATE_MASK) {
 -
 -		case MPI_SAS_PHY0_PRATE_MIN_RATE_1_5:
--			karg->Information.Phy[ii].bMinimumLinkRate |=
+-			karg.Information.Phy[ii].bMinimumLinkRate |=
 -			    (CSMI_SAS_PROGRAMMED_LINK_RATE_1_5_GBPS << 4);
 -			break;
 -
 -		case MPI_SAS_PHY0_PRATE_MIN_RATE_3_0:
--			karg->Information.Phy[ii].bMinimumLinkRate |=
+-			karg.Information.Phy[ii].bMinimumLinkRate |=
 -			    (CSMI_SAS_PROGRAMMED_LINK_RATE_3_0_GBPS << 4);
 -			break;
 -		default:
 -			break;
 -		}
 -
--		karg->Information.Phy[ii].bPhyChangeCount = sasPhyPg0->ChangeCount;
+-		karg.Information.Phy[ii].bPhyChangeCount = sasPhyPg0->ChangeCount;
 -		if( sasPhyPg0->PhyInfo & MPI_SAS_PHY0_PHYINFO_VIRTUAL_PHY )
--			karg->Information.Phy[ii].bPhyFeatures = CSMI_SAS_PHY_VIRTUAL_SMP;
+-			karg.Information.Phy[ii].bPhyFeatures = CSMI_SAS_PHY_VIRTUAL_SMP;
 -
 -		/* Fill in Attached Device
 -		 * Initiator Port Protocol.
@@ -1229,18 +1324,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		 * More than one bit can be set.
 -		 */
 -		protocol = le32_to_cpu(sasPhyPg0->AttachedDeviceInfo) & 0x78;
--		karg->Information.Phy[ii].Attached.bInitiatorPortProtocol = 0;
+-		karg.Information.Phy[ii].Attached.bInitiatorPortProtocol = 0;
 -		if (protocol & MPI_SAS_DEVICE_INFO_SSP_INITIATOR)
--		      karg->Information.Phy[ii].Attached.bInitiatorPortProtocol =
+-		      karg.Information.Phy[ii].Attached.bInitiatorPortProtocol =
 -			    CSMI_SAS_PROTOCOL_SSP;
 -		if (protocol & MPI_SAS_DEVICE_INFO_STP_INITIATOR)
--		     karg->Information.Phy[ii].Attached.bInitiatorPortProtocol |=
+-		     karg.Information.Phy[ii].Attached.bInitiatorPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_STP;
 -		if (protocol & MPI_SAS_DEVICE_INFO_SMP_INITIATOR)
--		     karg->Information.Phy[ii].Attached.bInitiatorPortProtocol |=
+-		     karg.Information.Phy[ii].Attached.bInitiatorPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SMP;
 -		if (protocol & MPI_SAS_DEVICE_INFO_SATA_HOST)
--		     karg->Information.Phy[ii].Attached.bInitiatorPortProtocol |=
+-		     karg.Information.Phy[ii].Attached.bInitiatorPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SATA;
 -
 -		/* Fill in Phy Target Port
@@ -1248,18 +1343,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		 * More than one bit can be set.
 -		 */
 -		protocol = le32_to_cpu(sasPhyPg0->AttachedDeviceInfo) & 0x780;
--		karg->Information.Phy[ii].Attached.bTargetPortProtocol = 0;
+-		karg.Information.Phy[ii].Attached.bTargetPortProtocol = 0;
 -		if (protocol & MPI_SAS_DEVICE_INFO_SSP_TARGET)
--			karg->Information.Phy[ii].Attached.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Attached.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SSP;
 -		if (protocol & MPI_SAS_DEVICE_INFO_STP_TARGET)
--			karg->Information.Phy[ii].Attached.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Attached.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_STP;
 -		if (protocol & MPI_SAS_DEVICE_INFO_SMP_TARGET)
--			karg->Information.Phy[ii].Attached.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Attached.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SMP;
 -		if (protocol & MPI_SAS_DEVICE_INFO_SATA_DEVICE)
--			karg->Information.Phy[ii].Attached.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Attached.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SATA;
 -
 -
@@ -1268,22 +1363,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    MPI_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) {
 -
 -		case MPI_SAS_DEVICE_INFO_NO_DEVICE:
--			karg->Information.Phy[ii].Attached.bDeviceType =
+-			karg.Information.Phy[ii].Attached.bDeviceType =
 -			    CSMI_SAS_NO_DEVICE_ATTACHED;
 -			break;
 -
 -		case MPI_SAS_DEVICE_INFO_END_DEVICE:
--			karg->Information.Phy[ii].Attached.bDeviceType =
+-			karg.Information.Phy[ii].Attached.bDeviceType =
 -			    CSMI_SAS_END_DEVICE;
 -			break;
 -
 -		case MPI_SAS_DEVICE_INFO_EDGE_EXPANDER:
--			karg->Information.Phy[ii].Attached.bDeviceType =
+-			karg.Information.Phy[ii].Attached.bDeviceType =
 -			    CSMI_SAS_EDGE_EXPANDER_DEVICE;
 -			break;
 -
 -		case MPI_SAS_DEVICE_INFO_FANOUT_EXPANDER:
--			karg->Information.Phy[ii].Attached.bDeviceType =
+-			karg.Information.Phy[ii].Attached.bDeviceType =
 -			    CSMI_SAS_FANOUT_EXPANDER_DEVICE;
 -			break;
 -		}
@@ -1293,22 +1388,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    MPI_SAS_DEVICE_INFO_MASK_DEVICE_TYPE) {
 -
 -		case MPI_SAS_DEVICE_INFO_NO_DEVICE:
--			karg->Information.Phy[ii].Identify.bDeviceType =
+-			karg.Information.Phy[ii].Identify.bDeviceType =
 -			    CSMI_SAS_NO_DEVICE_ATTACHED;
 -			break;
 -
 -		case MPI_SAS_DEVICE_INFO_END_DEVICE:
--			karg->Information.Phy[ii].Identify.bDeviceType =
+-			karg.Information.Phy[ii].Identify.bDeviceType =
 -			    CSMI_SAS_END_DEVICE;
 -			break;
 -
 -		case MPI_SAS_DEVICE_INFO_EDGE_EXPANDER:
--			karg->Information.Phy[ii].Identify.bDeviceType =
+-			karg.Information.Phy[ii].Identify.bDeviceType =
 -			    CSMI_SAS_EDGE_EXPANDER_DEVICE;
 -			break;
 -
 -		case MPI_SAS_DEVICE_INFO_FANOUT_EXPANDER:
--			karg->Information.Phy[ii].Identify.bDeviceType =
+-			karg.Information.Phy[ii].Identify.bDeviceType =
 -			    CSMI_SAS_FANOUT_EXPANDER_DEVICE;
 -			break;
 -		}
@@ -1318,18 +1413,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		 */
 -		protocol = le32_to_cpu(
 -		    sasIoUnitPg0->PhyData[ii].ControllerPhyDeviceInfo) & 0x78;
--		karg->Information.Phy[ii].Identify.bInitiatorPortProtocol = 0;
+-		karg.Information.Phy[ii].Identify.bInitiatorPortProtocol = 0;
 -		if( protocol & MPI_SAS_DEVICE_INFO_SSP_INITIATOR )
--		     karg->Information.Phy[ii].Identify.bInitiatorPortProtocol |=
+-		     karg.Information.Phy[ii].Identify.bInitiatorPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SSP;
 -		if( protocol & MPI_SAS_DEVICE_INFO_STP_INITIATOR )
--		     karg->Information.Phy[ii].Identify.bInitiatorPortProtocol |=
+-		     karg.Information.Phy[ii].Identify.bInitiatorPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_STP;
 -		if( protocol & MPI_SAS_DEVICE_INFO_SMP_INITIATOR )
--		     karg->Information.Phy[ii].Identify.bInitiatorPortProtocol |=
+-		     karg.Information.Phy[ii].Identify.bInitiatorPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SMP;
 -		if( protocol & MPI_SAS_DEVICE_INFO_SATA_HOST )
--		     karg->Information.Phy[ii].Identify.bInitiatorPortProtocol |=
+-		     karg.Information.Phy[ii].Identify.bInitiatorPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SATA;
 -
 -		/* Fill in Phy Target Port Protocol. Bits 10:7
@@ -1337,26 +1432,26 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		 */
 -		protocol = le32_to_cpu(
 -		    sasIoUnitPg0->PhyData[ii].ControllerPhyDeviceInfo) & 0x780;
--		karg->Information.Phy[ii].Identify.bTargetPortProtocol = 0;
+-		karg.Information.Phy[ii].Identify.bTargetPortProtocol = 0;
 -		if( protocol & MPI_SAS_DEVICE_INFO_SSP_TARGET )
--			karg->Information.Phy[ii].Identify.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Identify.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SSP;
 -		if( protocol & MPI_SAS_DEVICE_INFO_STP_TARGET )
--			karg->Information.Phy[ii].Identify.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Identify.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_STP;
 -		if( protocol & MPI_SAS_DEVICE_INFO_SMP_TARGET )
--			karg->Information.Phy[ii].Identify.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Identify.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SMP;
 -		if( protocol & MPI_SAS_DEVICE_INFO_SATA_DEVICE )
--			karg->Information.Phy[ii].Identify.bTargetPortProtocol |=
+-			karg.Information.Phy[ii].Identify.bTargetPortProtocol |=
 -			    CSMI_SAS_PROTOCOL_SATA;
 -
 -		/* Setup SAS Address for the attached device */
 -		if (sasPhyPg0->AttachedDevHandle) {
 -			sas_address = reverse_byte_order64(sas_address);
--			memcpy(karg->Information.Phy[ii].Attached.bSASAddress,
+-			memcpy(karg.Information.Phy[ii].Attached.bSASAddress,
 -			    &sas_address, sizeof(u64));
--			karg->Information.Phy[ii].Attached.bPhyIdentifier =
+-			karg.Information.Phy[ii].Attached.bPhyIdentifier =
 -			    sasPhyPg0->AttachedPhyIdentifier;
 -		}
 -
@@ -1366,9 +1461,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
 -		    sasIoUnitPg0->PhyData[ii].ControllerDevHandle);
 -		sas_address = reverse_byte_order64(device_info.sas_address);
--		memcpy(karg->Information.Phy[ii].Identify.bSASAddress,
+-		memcpy(karg.Information.Phy[ii].Identify.bSASAddress,
 -		    &sas_address, sizeof(u64));
--		karg->Information.Phy[ii].Identify.bPhyIdentifier = ii;
+-		karg.Information.Phy[ii].Identify.bPhyIdentifier = ii;
 -
 -		pci_free_consistent(ioc->pcidev, sasPhyPg0_data_sz,
 -		    (u8 *) sasPhyPg0, sasPhyPg0_dma);
@@ -1382,17 +1477,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	/* Copy the data from kernel memory to user memory
 -	 */
--	if (copy_to_user((char *)arg, karg,
+-	if (copy_to_user((char *)arg, &karg,
 -	    sizeof(CSMI_SAS_PHY_INFO_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s - "
 -		    "Unable to write out csmisas_get_phy_info_buffer @ %p\n",
 -		    __FILE__, __LINE__, __FUNCTION__, uarg);
--		free_pages((unsigned long)karg, memory_pages);
 -		return -EFAULT;
 -	}
 -
--	free_pages((unsigned long)karg, memory_pages);
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -1412,6 +1505,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	MPT_ADAPTER			*ioc = NULL;
 -	int				iocnum;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_SET_PHY_INFO_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmi_sas_set_phy_info struct @ %p\n",
@@ -1421,22 +1516,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -/* TODO - implement IOCTL here */
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_BAD_CNTL_CODE;
--	dcsmisasprintk(ioc, printk(KERN_DEBUG ": not implemented\n"));
+-	dcsmisasprintk((": not implemented\n"));
 -
 -// cim_set_phy_info_exit:
 -
@@ -1450,7 +1545,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -
 -}
@@ -1473,6 +1568,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	u64			sas_address;
 -	struct sas_device_info	*sas_info;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg,
 -	    sizeof(CSMI_SAS_GET_SCSI_ADDRESS_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
@@ -1483,19 +1580,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-	      "%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* reverse byte order the sas address */
 -	memcpy(&sas_address, karg.bSASAddress, sizeof(u64));
 -	sas_address = reverse_byte_order64(sas_address);
@@ -1526,7 +1623,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -1555,8 +1652,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	dma_addr_t			sasDevicePg1_dma;
 -	int				sasDevicePg1_data_sz;
 -	u8				phyId;
--	u64				sas_address;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
 -	sasPhyPg0=NULL;
 -	sasPhyPg0_data_sz=0;
 -	sasDevicePg1=NULL;
@@ -1572,22 +1669,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		     __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-	    "%s::%s() @%d - ioc%d not found!\n",
+-		     __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
 -	phyId = karg.Signature.bPhyIdentifier;
 -	if (phyId >= ioc->num_ports) {
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_PHY_DOES_NOT_EXIST;
--		dcsmisasprintk(ioc, printk(KERN_WARNING ": phyId >= ioc->num_ports\n"));
+-		dcsmisasprintk((": phyId >= ioc->num_ports\n"));
 -		goto cim_sata_signature_exit;
 -	}
 -
@@ -1617,9 +1715,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR
--		    ": FAILED: MPI_SASPHY0_PAGEVERSION: HEADER\n"));
--		dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
+-		dcsmisasprintk((": FAILED: MPI_SASPHY0_PAGEVERSION: HEADER\n"));
+-		dcsmisasprintk((": rc=%x\n",rc));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
@@ -1628,7 +1725,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR ": hdr.ExtPageLength == 0\n"));
+-		dcsmisasprintk((": hdr.ExtPageLength == 0\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
@@ -1641,7 +1738,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    sasPhyPg0_data_sz, &sasPhyPg0_dma);
 -
 -	if (! sasPhyPg0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
@@ -1654,9 +1751,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR
--		    ": FAILED: MPI_SASPHY0_PAGEVERSION: PAGE\n"));
--		dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
+-		dcsmisasprintk((": FAILED: MPI_SASPHY0_PAGEVERSION: PAGE\n"));
+-		dcsmisasprintk((": rc=%x\n",rc));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
@@ -1664,7 +1760,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Make sure a SATA device is attached. */
 -	if ((le32_to_cpu(sasPhyPg0->AttachedDeviceInfo) &
 -	    MPI_SAS_DEVICE_INFO_SATA_DEVICE) == 0) {
--		dcsmisasprintk(ioc, printk(KERN_WARNING ": NOT A SATA DEVICE\n"));
+-		dcsmisasprintk((": NOT A SATA DEVICE\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_NO_SATA_DEVICE;
 -		goto cim_sata_signature_exit;
 -	}
@@ -1689,15 +1785,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	cfg.timeout = MPT_IOCTL_DEFAULT_TIMEOUT;
 -
 -	if ((rc = mpt_config(ioc, &cfg)) != 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR
--		    ": FAILED: MPI_SASDEVICE1_PAGEVERSION: HEADER\n"));
--		dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
+-		dcsmisasprintk((": FAILED: MPI_SASDEVICE1_PAGEVERSION: HEADER\n"));
+-		dcsmisasprintk((": rc=%x\n",rc));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
 -
 -	if (hdr.ExtPageLength == 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": hdr.ExtPageLength == 0\n"));
+-		dcsmisasprintk((": hdr.ExtPageLength == 0\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
@@ -1709,7 +1804,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    (ioc->pcidev, sasDevicePg1_data_sz, &sasDevicePg1_dma);
 -
 -	if (! sasDevicePg1) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
@@ -1719,27 +1814,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
 -
 -	if ((rc = mpt_config(ioc, &cfg)) != 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR
--		    ": FAILED: MPI_SASDEVICE1_PAGEVERSION: PAGE\n"));
--		dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
+-		dcsmisasprintk((": FAILED: MPI_SASDEVICE1_PAGEVERSION: PAGE\n"));
+-		dcsmisasprintk((": rc=%x\n",rc));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sata_signature_exit;
 -	}
 -
 -/* EDM : dump Device Page 1 data*/
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "---- SAS DEVICE PAGE 1 ---------\n"));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "Handle=0x%x\n",sasDevicePg1->DevHandle));
--	memcpy(&sas_address, &sasDevicePg1->SASAddress, sizeof(u64));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n",
--	    (unsigned long long)sas_address));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\n"));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "Target ID=0x%x\n",sasDevicePg1->TargetID));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "Bus=0x%x\n",sasDevicePg1->Bus));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "Initial Reg Device FIS="));
+-	dcsmisasprintk(("---- SAS DEVICE PAGE 1 ---------\n"));
+-	dcsmisasprintk(("Handle=0x%x\n",sasDevicePg1->DevHandle));
+-	dcsmisasprintk(("SAS Address="));
+-	for(jj=0;jj<8;jj++)
+-		dcsmisasprintk(("%02x ",
+-		((u8 *)&sasDevicePg1->SASAddress)[jj]));
+-	dcsmisasprintk(("\n"));
+-	dcsmisasprintk(("Target ID=0x%x\n",sasDevicePg1->TargetID));
+-	dcsmisasprintk(("Bus=0x%x\n",sasDevicePg1->Bus));
+-	dcsmisasprintk(("Initial Reg Device FIS="));
 -	for(jj=0;jj<20;jj++)
--		dcsmisasprintk(ioc, printk("%02x ",
+-		dcsmisasprintk(("%02x ",
 -		((u8 *)&sasDevicePg1->InitialRegDeviceFIS)[jj]));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\n\n"));
+-	dcsmisasprintk(("\n\n"));
 -/* EDM : debug data */
 -
 -	memcpy(karg.Signature.bSignatureFIS,
@@ -1765,7 +1860,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -1787,6 +1882,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	struct sas_device_info	*sas_info;
 -	u64			sas_address;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg,
 -	    sizeof(CSMI_SAS_GET_DEVICE_ADDRESS_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
@@ -1797,19 +1894,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-	    "%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_NO_DEVICE_ADDRESS;
 -	memset(karg.bSASAddress, 0, sizeof(u64));
 -	memset(karg.bSASLun, 0, sizeof(karg.bSASLun));
@@ -1836,7 +1933,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -1868,6 +1965,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	u8				phyId;
 -	u16				ioc_status;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
 -	sasPhyPage1=NULL;
 -	sasPhyPage1_data_sz=0;
 -
@@ -1881,22 +1979,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		     __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-	    "%s::%s() @%d - ioc%d not found!\n",
+-		     __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
 -	phyId = karg.Information.bPhyIdentifier;
 -	if (phyId >= ioc->num_ports) {
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_PHY_DOES_NOT_EXIST;
--		dcsmisasprintk(ioc, printk(KERN_WARNING ": phyId >= ioc->num_ports\n"));
+-		dcsmisasprintk((": phyId >= ioc->num_ports\n"));
 -		goto cim_get_link_errors_exit;
 -	}
 -
@@ -1926,9 +2025,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR
--		    ": FAILED: MPI_SASPHY1_PAGEVERSION: HEADER\n"));
--		dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
+-		dcsmisasprintk((": FAILED: MPI_SASPHY1_PAGEVERSION: HEADER\n"));
+-		dcsmisasprintk((": rc=%x\n",rc));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_get_link_errors_exit;
 -	}
@@ -1937,7 +2035,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR ": hdr.ExtPageLength == 0\n"));
+-		dcsmisasprintk((": hdr.ExtPageLength == 0\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_get_link_errors_exit;
 -	}
@@ -1950,7 +2048,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    sasPhyPage1_data_sz, &sasPhyPage1_dma);
 -
 -	if (! sasPhyPage1) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_get_link_errors_exit;
 -	}
@@ -1963,23 +2061,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/* Don't check if this failed.  Already in a
 -		 * failure case.
 -		 */
--		dcsmisasprintk(ioc, printk(KERN_ERR ": FAILED: MPI_SASPHY1_PAGEVERSION: PAGE\n"));
--		dcsmisasprintk(ioc, printk(KERN_ERR ": rc=%x\n",rc));
+-		dcsmisasprintk((": FAILED: MPI_SASPHY1_PAGEVERSION: PAGE\n"));
+-		dcsmisasprintk((": rc=%x\n",rc));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_get_link_errors_exit;
 -	}
 -
 -/* EDM : dump PHY Page 1 data*/
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 1 ------------\n"));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "Invalid Dword Count=0x%x\n",
+-	dcsmisasprintk(("---- SAS PHY PAGE 1 ------------\n"));
+-	dcsmisasprintk(("Invalid Dword Count=0x%x\n",
 -	    sasPhyPage1->InvalidDwordCount));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "Running Disparity Error Count=0x%x\n",
+-	dcsmisasprintk(("Running Disparity Error Count=0x%x\n",
 -	    sasPhyPage1->RunningDisparityErrorCount));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "Loss Dword Synch Count=0x%x\n",
+-	dcsmisasprintk(("Loss Dword Synch Count=0x%x\n",
 -	    sasPhyPage1->LossDwordSynchCount));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "PHY Reset Problem Count=0x%x\n",
+-	dcsmisasprintk(("PHY Reset Problem Count=0x%x\n",
 -	    sasPhyPage1->PhyResetProblemCount));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\n\n"));
+-	dcsmisasprintk(("\n\n"));
 -/* EDM : debug data */
 -
 -	karg.Information.uInvalidDwordCount =
@@ -2004,7 +2102,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Get a MF for this command.
 -	 */
 -	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
+-		dcsmisasprintk((": no msg frames!\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_get_link_errors_exit;
 -        }
@@ -2023,16 +2121,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	}
 -
 -	/* process the completed Reply Message Frame */
--	if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) {
+-	if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) {
 -
 -		sasIoUnitCntrReply =
--		    (SasIoUnitControlReply_t *)ioc->ioctl_cmds.reply;
+-		    (SasIoUnitControlReply_t *)ioc->ioctl->ReplyFrame;
 -		ioc_status = le16_to_cpu(sasIoUnitCntrReply->IOCStatus)
 -		    & MPI_IOCSTATUS_MASK;
 -
 -		if (ioc_status != MPI_IOCSTATUS_SUCCESS) {
--			dcsmisasprintk(ioc, printk(KERN_DEBUG ": SAS IO Unit Control: "));
--			dcsmisasprintk(ioc, printk("IOCStatus=0x%X IOCLogInfo=0x%X\n",
+-			dcsmisasprintk((": SAS IO Unit Control: "));
+-			dcsmisasprintk(("IOCStatus=0x%X IOCLogInfo=0x%X\n",
 -			    sasIoUnitCntrReply->IOCStatus,
 -			    sasIoUnitCntrReply->IOCLogInfo));
 -		}
@@ -2054,7 +2152,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -
 -}
@@ -2088,6 +2186,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	u16				ioc_status;
 -	u64				sas_address;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_SMP_PASSTHRU_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmi_sas_smp_passthru struct @ %p\n",
@@ -2102,26 +2202,32 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
+-		return -ENODEV;
+-	}
+-
+-	if (!csmisas_is_this_sas_cntr(ioc)) {
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	if (ioc->ioc_reset_in_progress) {
+-	/* Make sure the adapter is not being reset. */
+-	if (!ioc->ioctl) {
+-		printk(KERN_ERR "%s@%d::%s - "
+-		    "No memory available during driver init.\n",
+-		    __FILE__, __LINE__,__FUNCTION__);
+-		return -ENOMEM;
+-	} else if (ioc->ioctl->status & MPT_IOCTL_STATUS_DID_IOCRESET) {
 -		printk(KERN_ERR "%s@%d::%s - "
 -		    "Busy with IOC Reset \n",
 -		    __FILE__, __LINE__,__FUNCTION__);
 -		return -EBUSY;
 -	}
 -
--	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
--		return -ENODEV;
--	}
--
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Default to success.*/
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
 -
@@ -2139,7 +2245,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Get a free request frame and save the message context.
 -	 */
 -	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
+-		dcsmisasprintk((": no msg frames!\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_smp_passthru_exit;
 -        }
@@ -2187,13 +2293,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    ioc->pcidev, request_data_sz, &request_data_dma);
 -
 -	if (!request_data) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		mpt_free_msg_frame(ioc, mf);
 -		goto cim_smp_passthru_exit;
 -	}
 -
--	ioc->add_sge(psge, flagsLength, request_data_dma);
+-	mpt_add_sge(psge, flagsLength, request_data_dma);
 -	psge += (sizeof(u32) + sizeof(dma_addr_t));
 -
 -	memcpy(request_data,&karg.Parameters.Request,request_data_sz);
@@ -2203,7 +2309,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    ioc->pcidev, response_data_sz, &response_data_dma);
 -
 -	if (!response_data) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		mpt_free_msg_frame(ioc, mf);
 -		goto cim_smp_passthru_exit;
@@ -2222,28 +2328,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	flagsLength = flagsLength << MPI_SGE_FLAGS_SHIFT;
 -	flagsLength |= response_data_sz;
 -
--	ioc->add_sge(psge, flagsLength, response_data_dma);
+-	mpt_add_sge(psge, flagsLength, response_data_dma);
 -
 -	if (csmisas_send_command_wait(ioc, mf, karg.IoctlHeader.Timeout) != 0) {
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_smp_passthru_exit;
 -	}
 -
--	if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) == 0) {
--		dcsmisasprintk(ioc, printk(KERN_DEBUG ": SMP Passthru: oh no, there is no reply!!"));
+-	if ((ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) == 0) {
+-		dcsmisasprintk((": SMP Passthru: oh no, there is no reply!!"));
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_smp_passthru_exit;
 -	}
 -
 -	/* process the completed Reply Message Frame */
--	smpReply = (pSmpPassthroughReply_t )ioc->ioctl_cmds.reply;
+-	smpReply = (pSmpPassthroughReply_t )ioc->ioctl->ReplyFrame;
 -	ioc_status = le16_to_cpu(smpReply->IOCStatus) & MPI_IOCSTATUS_MASK;
 -
 -	if ((ioc_status != MPI_IOCSTATUS_SUCCESS) &&
 -	    (ioc_status != MPI_IOCSTATUS_SCSI_DATA_UNDERRUN)) {
 -		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
--		dcsmisasprintk(ioc, printk(KERN_DEBUG ": SMP Passthru: "));
--		dcsmisasprintk(ioc, printk("IOCStatus=0x%X IOCLogInfo=0x%X SASStatus=0x%X\n",
+-		dcsmisasprintk((": SMP Passthru: "));
+-		dcsmisasprintk(("IOCStatus=0x%X IOCLogInfo=0x%X SASStatus=0x%X\n",
 -		    le16_to_cpu(smpReply->IOCStatus),
 -		    le32_to_cpu(smpReply->IOCLogInfo),
 -		    smpReply->SASStatus));
@@ -2281,7 +2387,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG ": %s exit.\n",__FUNCTION__));
+-	dcsmisasprintk((": %s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -2319,7 +2425,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	u8				channel;
 -	u8				id;
 -	struct sas_device_info		*sas_info;
--	u8				skey, asc, ascq;
+-
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
 -
 -	if (copy_from_user(&karg_hdr, uarg, sizeof(CSMI_SAS_SSP_PASSTHRU_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
@@ -2337,7 +2444,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	is_hidden_raid_component = 0;
 -
 -	malloc_data_sz = (request_data_sz +
--	    offsetof(CSMI_SAS_SSP_PASSTHRU_BUFFER, bDataBuffer));
+-	    offsetof(CSMI_SAS_SSP_PASSTHRU_BUFFER,bDataBuffer));
 -	memory_pages = get_order(malloc_data_sz);
 -	karg = (CSMI_SAS_SSP_PASSTHRU_BUFFER *)__get_free_pages(
 -		GFP_KERNEL, memory_pages);
@@ -2350,6 +2457,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -ENOMEM;
 -	}
 -
+-	dcsmisasprintk((KERN_ERR "%s@%d::%s() - "
+-			"malloc'ed SAS_SSP_PASSTHRU_BUFFER "
+-			"malloc_data_sz=%d memory_pages=%d\n",
+-			__FILE__, __LINE__, __FUNCTION__,
+-			malloc_data_sz, memory_pages));
+-
 -	memset(karg, 0, sizeof(*karg));
 -
 -	if (copy_from_user(karg, uarg, request_data_sz +
@@ -2368,7 +2481,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    request_data_sz - sizeof(IOCTL_HEADER) >
 -	    karg->IoctlHeader.Length ) {
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_INVALID_PARAMETER;
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((KERN_ERR
 -		    "%s::%s()"
 -		    " @%d - expected datalen incorrect!\n",
 -		    __FILE__, __FUNCTION__, __LINE__));
@@ -2378,27 +2491,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	if (((iocnum = mpt_verify_adapter(karg->IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_INVALID_PARAMETER;
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		goto cim_ssp_passthru_exit;
 -	}
 -
--	if (ioc->ioc_reset_in_progress) {
--		printk(KERN_ERR "%s@%d::%s - "
--		    "Busy with IOC Reset \n",
--		    __FILE__, __LINE__,__FUNCTION__);
--		return -EBUSY;
--	}
--
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_INVALID_PARAMETER;
--		printk(KERN_ERR "%s::%s()@%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s()"
+-		    " @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		goto cim_ssp_passthru_exit;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Default to success.
 -	 */
 -	karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
@@ -2408,7 +2515,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	if ((karg->Parameters.bPhyIdentifier == CSMI_SAS_USE_PORT_IDENTIFIER) &&
 -		(karg->Parameters.bPortIdentifier == CSMI_SAS_IGNORE_PORT)) {
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_SELECT_PHY_OR_PORT;
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((KERN_ERR
 -		    "%s::%s()"
 -		    " @%d - incorrect bPhyIdentifier and bPortIdentifier!\n",
 -		    __FILE__, __FUNCTION__, __LINE__));
@@ -2421,7 +2528,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -		/* Is the phy in range? */
 -		if (karg->Parameters.bPhyIdentifier >= ioc->num_ports) {
--			dcsmisasprintk(ioc, printk(KERN_WARNING ": phyId >= ioc->num_ports (%d %d)\n",
+-			dcsmisasprintk((": phyId >= ioc->num_ports (%d %d)\n",
 -			    karg->Parameters.bPhyIdentifier,
 -			    ioc->num_ports));
 -			karg->IoctlHeader.ReturnCode =
@@ -2433,10 +2540,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	if(karg->Parameters.bAdditionalCDBLength) {
 -	/* TODO - SCSI IO (32) Request Message support
 -	 */
--		dcsmisasprintk(ioc, printk(KERN_DEBUG ": greater than 16-byte cdb "
--		    "is not supported!\n"));
--		    karg->IoctlHeader.ReturnCode =
--			CSMI_SAS_STATUS_INVALID_PARAMETER;
+-		dcsmisasprintk((": greater than 16-byte cdb is not supported!\n"));
+-		karg->IoctlHeader.ReturnCode =
+-		    CSMI_SAS_STATUS_INVALID_PARAMETER;
 -		goto cim_ssp_passthru_exit;
 -	}
 -
@@ -2455,10 +2561,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		 */
 -		karg->IoctlHeader.ReturnCode =
 -		    CSMI_SAS_STATUS_INVALID_PARAMETER;
--		dcsmisasprintk(ioc, printk(KERN_ERR
--		    "%s::%s() @%d - couldn't find associated "
--		    "SASAddress=%llX!\n", __FILE__, __FUNCTION__, __LINE__,
--		    (unsigned long long)sas_address));
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s()"
+-		    " @%d - couldn't find associated SASAddress=%llX!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, sas_address));
 -		goto cim_ssp_passthru_exit;
 -	}
 -
@@ -2474,7 +2580,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Get a free request frame and save the message context.
 -	 */
 -	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
+-		dcsmisasprintk((": no msg frames!\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_ssp_passthru_exit;
 -        }
@@ -2499,17 +2605,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	memcpy(pScsiRequest->CDB, karg->Parameters.bCDB,
 -	    pScsiRequest->CDBLength);
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\tchannel = %d id = %d ",
--	    sas_info->fw.channel, sas_info->fw.id));
--	dcsmisasprintk(ioc, if(is_hidden_raid_component)
--	    printk(KERN_DEBUG "num_id = %d ", id));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\n"));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\tcdb_len = %d request_len = %d\n",
--	    pScsiRequest->CDBLength, request_data_sz));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\t"));
--	dcsmisasprintk(ioc, for (ii = 0; ii < pScsiRequest->CDBLength; ++ii)
--	    printk(" %02x", pScsiRequest->CDB[ii]));
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "\n"));
+-	#if defined(MPT_DEBUG_CSMISAS)
+-	{
+-	int k;
+-		printk("\tchannel=%d id=%d ", sas_info->fw.channel,
+-		    sas_info->fw.id);
+-		if (is_hidden_raid_component)
+-			printk("num_id=%d ", id);
+-		printk("\n");
+-		printk("\tcdb_len = %d data_len=%d\n",
+-		    pScsiRequest->CDBLength, request_data_sz);
+-		printk("\t");
+-		for (k = 0; k < pScsiRequest->CDBLength; ++k)
+-			printk(" %02x", pScsiRequest->CDB[k]);
+-		printk("\n");
+-	}
+-	#endif
 -
 -	/* direction
 -	 */
@@ -2575,18 +2686,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    ioc->pcidev, request_data_sz, &request_data_dma);
 -
 -		if (request_data == NULL) {
--			dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED "
+-			dcsmisasprintk((": pci_alloc_consistent: FAILED "
 -			    "request_data_sz=%d\n", request_data_sz));
 -			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			mpt_free_msg_frame(ioc, mf);
 -			goto cim_ssp_passthru_exit;
 -		}
 -
--		ioc->add_sge(psge, flagsLength, request_data_dma);
+-		mpt_add_sge(psge, flagsLength, request_data_dma);
 -		if (karg->Parameters.uFlags & CSMI_SAS_SSP_WRITE)
 -			memcpy(request_data, karg->bDataBuffer, request_data_sz);
 -	} else {
--		ioc->add_sge(psge, flagsLength, (dma_addr_t) -1);
+-		mpt_add_sge(psge, flagsLength, (dma_addr_t) -1);
 -	}
 -
 -	if (csmisas_send_command_wait(ioc, mf, karg->IoctlHeader.Timeout) != 0) {
@@ -2603,9 +2714,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	karg->Status.uDataBytes = request_data_sz;
 -
 -	/* process the completed Reply Message Frame */
--	if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) {
+-	if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) {
 -
--		pScsiReply = (pSCSIIOReply_t ) ioc->ioctl_cmds.reply;
+-		pScsiReply = (pSCSIIOReply_t ) ioc->ioctl->ReplyFrame;
 -		karg->Status.bStatus = pScsiReply->SCSIStatus;
 -		karg->Status.uDataBytes = min(le32_to_cpu(pScsiReply->TransferCount),
 -		    request_data_sz);
@@ -2618,16 +2729,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			karg->Status.bResponseLength[0] =
 -				(u8)le32_to_cpu(pScsiReply->SenseCount) & 0xFF;
 -			memcpy(karg->Status.bResponse,
--			    ioc->ioctl_cmds.sense, le32_to_cpu(pScsiReply->SenseCount));
--
--			skey = ioc->ioctl_cmds.sense[2] & 0x0F;
--			asc = ioc->ioctl_cmds.sense[12];
--			ascq = ioc->ioctl_cmds.sense[13];
--
--			dcsmisasprintk(ioc, printk(KERN_DEBUG "\t [sense_key,asc,ascq]: "
--			    "[0x%02x,0x%02x,0x%02x]\n",
--			    skey, asc, ascq));
--
+-			    ioc->ioctl->sense, le32_to_cpu(pScsiReply->SenseCount));
 -		} else if(pScsiReply->SCSIState ==
 -		    MPI_SCSI_STATE_RESPONSE_INFO_VALID) {
 -			karg->Status.bDataPresent =
@@ -2643,8 +2745,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    (ioc_status !=  MPI_IOCSTATUS_SCSI_RECOVERED_ERROR) &&
 -		    (ioc_status != MPI_IOCSTATUS_SCSI_DATA_UNDERRUN)) {
 -			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
--			dcsmisasprintk(ioc, printk(KERN_DEBUG ": SCSI IO : "));
--			dcsmisasprintk(ioc, printk("IOCStatus=0x%X IOCLogInfo=0x%X\n",
+-			dcsmisasprintk((": SCSI IO : "));
+-			dcsmisasprintk(("IOCStatus=0x%X IOCLogInfo=0x%X\n",
 -			    pScsiReply->IOCStatus,
 -			    pScsiReply->IOCLogInfo));
 -		}
@@ -2680,7 +2782,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	free_pages((unsigned long)karg, memory_pages);
 -	return 0;
 -}
@@ -2697,7 +2799,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -csmisas_stp_passthru(unsigned long arg)
 -{
 -	CSMI_SAS_STP_PASSTHRU_BUFFER __user *uarg = (void __user *) arg;
--	CSMI_SAS_STP_PASSTHRU_BUFFER	karg_hdr, *karg;
+-	CSMI_SAS_STP_PASSTHRU_BUFFER	 karg;
 -	MPT_ADAPTER			*ioc = NULL;
 -	pSataPassthroughRequest_t  	pSataRequest;
 -	pSataPassthroughReply_t		pSataReply;
@@ -2712,8 +2814,6 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	void *				request_data;
 -	dma_addr_t			request_data_dma;
 -	u32				request_data_sz;
--	int				malloc_data_sz;
--	int				memory_pages;
 -	u8				channel;
 -	u8				id;
 -	u8 				volume_id;
@@ -2721,7 +2821,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	struct sas_device_info		*sas_info;
 -	u16				ioc_status;
 -
--	if (copy_from_user(&karg_hdr, uarg, sizeof(CSMI_SAS_STP_PASSTHRU_BUFFER))) {
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
+-	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_STP_PASSTHRU_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read struct @ %p\n",
 -		    __FILE__, __LINE__, __FUNCTION__, uarg);
@@ -2729,71 +2831,37 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	}
 -
 -	request_data=NULL;
--	request_data_sz = karg_hdr.Parameters.uDataLength;
+-	request_data_sz = karg.Parameters.uDataLength;
 -	volume_id = 0;
 -	volume_bus = 0;
 -	channel = 0;
 -	id = 0;
 -
--	malloc_data_sz = (request_data_sz +
--	    offsetof(CSMI_SAS_STP_PASSTHRU_BUFFER, bDataBuffer));
--	memory_pages = get_order(malloc_data_sz);
--	karg = (CSMI_SAS_STP_PASSTHRU_BUFFER *)__get_free_pages(
--		GFP_KERNEL, memory_pages);
--	if (!karg){
--		printk(KERN_ERR "%s@%d::%s() - "
--			"Unable to malloc CSMI_SAS_STP_PASSTHRU_BUFFER "
--			"malloc_data_sz=%d memory_pages=%d\n",
--			__FILE__, __LINE__, __FUNCTION__, 
--			malloc_data_sz, memory_pages);
--		return -ENOMEM;
--	}
--
--	memset(karg, 0, sizeof(*karg));
--
--	if (copy_from_user(karg, uarg, malloc_data_sz)) {
--		printk(KERN_ERR "%s@%d::%s() - "
--		    "Unable to read in csmi_sas_ssp_passthru struct @ %p\n",
--		    __FILE__, __LINE__, __FUNCTION__, uarg);
--		free_pages((unsigned long)karg, memory_pages);
--		return -EFAULT;
--	}
--
--	if (((iocnum = mpt_verify_adapter(karg->IoctlHeader.IOControllerNumber,
+-	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
--		free_pages((unsigned long)karg, memory_pages);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	if (ioc->ioc_reset_in_progress) {
--		printk(KERN_ERR "%s@%d::%s - "
--		    "Busy with IOC Reset \n",
--		    __FILE__, __LINE__,__FUNCTION__);
--		free_pages((unsigned long)karg, memory_pages);
--		return -EBUSY;
--	}
--
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
--		free_pages((unsigned long)karg, memory_pages);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Default to success.
 -	 */
--	karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
+-	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
 -
 -	/* Neither a phy nor a port has been selected.
 -	 */
--	if ((karg->Parameters.bPhyIdentifier == CSMI_SAS_USE_PORT_IDENTIFIER) &&
--		(karg->Parameters.bPortIdentifier == CSMI_SAS_IGNORE_PORT)) {
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_SELECT_PHY_OR_PORT;
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-	if ((karg.Parameters.bPhyIdentifier == CSMI_SAS_USE_PORT_IDENTIFIER) &&
+-		(karg.Parameters.bPortIdentifier == CSMI_SAS_IGNORE_PORT)) {
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_SELECT_PHY_OR_PORT;
+-		dcsmisasprintk((KERN_ERR
 -		    "%s::%s() @%d - incorrect bPhyIdentifier and bPortIdentifier!\n",
 -		    __FILE__,__FUNCTION__, __LINE__));
 -		goto cim_stp_passthru_exit;
@@ -2801,24 +2869,34 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	/* A phy has been selected. Verify that it's valid.
 -	 */
--	if (karg->Parameters.bPortIdentifier == CSMI_SAS_IGNORE_PORT) {
+-	if (karg.Parameters.bPortIdentifier == CSMI_SAS_IGNORE_PORT) {
 -
 -		/* Is the phy in range? */
--		if (karg->Parameters.bPhyIdentifier >= ioc->num_ports) {
--			karg->IoctlHeader.ReturnCode =
+-		if (karg.Parameters.bPhyIdentifier >= ioc->num_ports) {
+-			karg.IoctlHeader.ReturnCode =
 -			    CSMI_SAS_PHY_DOES_NOT_EXIST;
 -			goto cim_stp_passthru_exit;
 -		}
 -	}
 -
+-	/* some checks of the incoming frame
+-	 */
+-	if (request_data_sz > 0xFFFF) {
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - uDataLength > 0xFFFF!\n",
+-		    __FILE__, __FUNCTION__, __LINE__));
+-		goto cim_stp_passthru_exit;
+-	}
+-
 -	data_sz = sizeof(CSMI_SAS_STP_PASSTHRU_BUFFER) -
 -	    sizeof(IOCTL_HEADER) - sizeof(u8*) +
 -	    request_data_sz;
 -
--	if ( data_sz > karg->IoctlHeader.Length ) {
--		karg->IoctlHeader.ReturnCode =
+-	if ( data_sz > karg.IoctlHeader.Length ) {
+-		karg.IoctlHeader.ReturnCode =
 -		    CSMI_SAS_STATUS_INVALID_PARAMETER;
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((KERN_ERR
 -		    "%s::%s() @%d - expected datalen incorrect!\n",
 -		    __FILE__, __FUNCTION__,__LINE__));
 -		goto cim_stp_passthru_exit;
@@ -2827,7 +2905,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	/* we will use SAS address to resolve the scsi adddressing
 -	 */
--	memcpy(&sas_address, karg->Parameters.bDestinationSASAddress,
+-	memcpy(&sas_address, karg.Parameters.bDestinationSASAddress,
 -	    sizeof(u64));
 -	sas_address = reverse_byte_order64(sas_address);
 -
@@ -2838,12 +2916,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		/*
 -		 *Invalid SAS address
 -		 */
--		karg->IoctlHeader.ReturnCode =
+-		karg.IoctlHeader.ReturnCode =
 -		    CSMI_SAS_STATUS_INVALID_PARAMETER;
--		dcsmisasprintk(ioc, printk(KERN_ERR
--		    "%s::%s() @%d - couldn't find associated "
--		    "SASAddress=%llX!\n", __FILE__, __FUNCTION__, __LINE__,
--		    (unsigned long long)sas_address));
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s()"
+-		    " @%d - couldn't find associated SASAddress=%llX!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, sas_address));
 -		goto cim_stp_passthru_exit;
 -	}
 -
@@ -2854,7 +2932,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	 */
 -	if ( !(sas_info->device_info & MPI_SAS_DEVICE_INFO_STP_TARGET ) &&
 -	     !(sas_info->device_info & MPI_SAS_DEVICE_INFO_SATA_DEVICE )) {
--		karg->IoctlHeader.ReturnCode =
+-		karg.IoctlHeader.ReturnCode =
 -		    CSMI_SAS_STATUS_INVALID_PARAMETER;
 -		goto cim_stp_passthru_exit;
 -	}
@@ -2862,8 +2940,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Get a free request frame and save the message context.
 -	 */
 -	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-		dcsmisasprintk((": no msg frames!\n"));
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_stp_passthru_exit;
 -        }
 -
@@ -2876,17 +2954,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	pSataRequest->TargetID = id;
 -	pSataRequest->Bus = channel;
 -	pSataRequest->Function = MPI_FUNCTION_SATA_PASSTHROUGH;
--	pSataRequest->PassthroughFlags = cpu_to_le16(karg->Parameters.uFlags);
--	pSataRequest->ConnectionRate = karg->Parameters.bConnectionRate;
+-	pSataRequest->PassthroughFlags = cpu_to_le16(karg.Parameters.uFlags);
+-	pSataRequest->ConnectionRate = karg.Parameters.bConnectionRate;
 -	pSataRequest->MsgContext = mpi_hdr->MsgContext;
 -	pSataRequest->DataLength = cpu_to_le32(request_data_sz);
 -	pSataRequest->MsgFlags = 0;
--	memcpy( pSataRequest->CommandFIS,karg->Parameters.bCommandFIS, 20);
+-	memcpy( pSataRequest->CommandFIS,karg.Parameters.bCommandFIS, 20);
 -
 -	psge = (char *)&pSataRequest->SGL;
--	if (karg->Parameters.uFlags & CSMI_SAS_STP_WRITE) {
+-	if (karg.Parameters.uFlags & CSMI_SAS_STP_WRITE) {
 -		flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE;
--	} else if (karg->Parameters.uFlags & CSMI_SAS_STP_READ) {
+-	} else if (karg.Parameters.uFlags & CSMI_SAS_STP_READ) {
 -		flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ;
 -	}else {
 -		flagsLength = ( MPI_SGE_FLAGS_SIMPLE_ELEMENT |
@@ -2901,70 +2979,82 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    ioc->pcidev, request_data_sz, &request_data_dma);
 -
 -		if (request_data == NULL) {
--			dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
--			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-			dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
+-			karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			mpt_free_msg_frame(ioc, mf);
 -			goto cim_stp_passthru_exit;
 -		}
 -
--		ioc->add_sge(psge, flagsLength, request_data_dma);
--		if (karg->Parameters.uFlags & CSMI_SAS_SSP_WRITE)
--			memcpy(request_data, karg->bDataBuffer, request_data_sz);
+-		mpt_add_sge(psge, flagsLength, request_data_dma);
+-		if (karg.Parameters.uFlags & CSMI_SAS_STP_WRITE) {
+-			if (copy_from_user(request_data,
+-			    karg.bDataBuffer,
+-			    request_data_sz)) {
+-				printk(KERN_ERR
+-				    "%s::%s() @%d - Unable to read user data "
+-				    "struct @ %p\n",
+-				    __FILE__, __FUNCTION__, __LINE__,
+-				    (void*)karg.bDataBuffer);
+-				karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-				mpt_free_msg_frame(ioc, mf);
+-				goto cim_stp_passthru_exit;
+-			}
+-		}
 -	} else {
--		ioc->add_sge(psge, flagsLength, (dma_addr_t) -1);
+-		mpt_add_sge(psge, flagsLength, (dma_addr_t) -1);
 -	}
 -
--	if (csmisas_send_command_wait(ioc, mf, karg->IoctlHeader.Timeout) != 0) {
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-	if (csmisas_send_command_wait(ioc, mf, karg.IoctlHeader.Timeout) != 0) {
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_stp_passthru_exit;
 -	}
 -
--	memset(&karg->Status,0,sizeof(CSMI_SAS_STP_PASSTHRU_STATUS));
+-	memset(&karg.Status,0,sizeof(CSMI_SAS_STP_PASSTHRU_STATUS));
 -
--	if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) == 0) {
--		dcsmisasprintk(ioc, printk(KERN_DEBUG  ": STP Passthru: oh no, there is no reply!!"));
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-	if ((ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) == 0) {
+-		dcsmisasprintk((": STP Passthru: oh no, there is no reply!!"));
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_stp_passthru_exit;
 -	}
 -
 -	/* process the completed Reply Message Frame */
--	pSataReply = (pSataPassthroughReply_t ) ioc->ioctl_cmds.reply;
+-	pSataReply = (pSataPassthroughReply_t ) ioc->ioctl->ReplyFrame;
 -	ioc_status = le16_to_cpu(pSataReply->IOCStatus) & MPI_IOCSTATUS_MASK;
 -
 -	if (ioc_status != MPI_IOCSTATUS_SUCCESS &&
 -	    ioc_status != MPI_IOCSTATUS_SCSI_DATA_UNDERRUN) {
--		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
--		dcsmisasprintk(ioc, printk(KERN_DEBUG ": STP Passthru: "));
--		dcsmisasprintk(ioc, printk("IOCStatus=0x%X IOCLogInfo=0x%X SASStatus=0x%X\n",
+-		karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-		dcsmisasprintk((": STP Passthru: "));
+-		dcsmisasprintk(("IOCStatus=0x%X IOCLogInfo=0x%X SASStatus=0x%X\n",
 -		    le16_to_cpu(pSataReply->IOCStatus),
 -		    le32_to_cpu(pSataReply->IOCLogInfo),
 -		    pSataReply->SASStatus));
 -	}
 -
--	karg->Status.bConnectionStatus =
+-	karg.Status.bConnectionStatus =
 -	    map_sas_status_to_csmi(pSataReply->SASStatus);
 -
--	memcpy(karg->Status.bStatusFIS,pSataReply->StatusFIS, 20);
+-	memcpy(karg.Status.bStatusFIS,pSataReply->StatusFIS, 20);
 -
 -	/*
 -	 * for now, just zero out uSCR array,
 -	 * then copy the one dword returned
 -	 * in the reply frame into uSCR[0]
 -	 */
--	memset( karg->Status.uSCR, 0, 64);
--	karg->Status.uSCR[0] = le32_to_cpu(pSataReply->StatusControlRegisters);
+-	memset( karg.Status.uSCR, 0, 64);
+-	karg.Status.uSCR[0] = le32_to_cpu(pSataReply->StatusControlRegisters);
 -
 -	if((le32_to_cpu(pSataReply->TransferCount)) && (request_data) &&
--	    (karg->Parameters.uFlags & CSMI_SAS_STP_READ)) {
--		karg->Status.uDataBytes =
+-	    (karg.Parameters.uFlags & CSMI_SAS_STP_READ)) {
+-		karg.Status.uDataBytes =
 -		    min(le32_to_cpu(pSataReply->TransferCount),request_data_sz);
 -		if (copy_to_user((char *)uarg->bDataBuffer,
--		    request_data, karg->Status.uDataBytes)) {
+-		    request_data, karg.Status.uDataBytes)) {
 -			printk(KERN_ERR "%s::%s() @%d - "
 -			    "Unable to write data to user %p\n",
 -			    __FILE__, __FUNCTION__, __LINE__,
--			    (void*)karg->bDataBuffer);
--			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
+-			    (void*)karg.bDataBuffer);
+-			karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		}
 -	}
 -
@@ -2976,17 +3066,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	/* Copy th data from kernel memory to user memory
 -	 */
--	if (copy_to_user((char *)arg, karg,
--	    offsetof(CSMI_SAS_STP_PASSTHRU_BUFFER, bDataBuffer))) {
+-	if (copy_to_user((char *)arg, &karg,
+-	    offsetof(CSMI_SAS_STP_PASSTHRU_BUFFER,bDataBuffer))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -			"Unable to write out csmi_sas_ssp_passthru @ %p\n",
 -				__FILE__, __LINE__, __FUNCTION__, uarg);
--		free_pages((unsigned long)karg, memory_pages);
 -		return -EFAULT;
 -	}
 -
--	free_pages((unsigned long)karg, memory_pages);
--	dcsmisasprintk(ioc, printk(KERN_DEBUG ": %s exit.\n",__FUNCTION__));
+-	dcsmisasprintk((": %s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -3007,6 +3095,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int				iocnum;
 -	pMpiFwHeader_t			pFwHeader=NULL;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg,
 -		sizeof(CSMI_SAS_FIRMWARE_DOWNLOAD_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
@@ -3017,19 +3107,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	/* Default to success.*/
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
 -	karg.Information.usStatus = CSMI_SAS_FWD_SUCCESS;
@@ -3116,7 +3206,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -3139,6 +3229,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	u8				maxRaidTypes;
 -	u8				maxDrivesPerSet;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_RAID_INFO_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmi_sas_get_raid_info struct @ %p\n",
@@ -3148,19 +3240,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -	if (!ioc->raid_data.pIocPg2)
 -		goto csmisas_get_raid_info_out;
@@ -3212,7 +3304,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -3239,7 +3331,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Get and Populate a free Frame
 -	 */
 -	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
+-		dcsmisasprintk((": no msg frames!\n"));
 -		return -EAGAIN;
 -	}
 -	pReq = (MpiRaidActionRequest_t *)mf;
@@ -3255,15 +3347,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	pReq->ActionDataWord = 0; /* Reserved for this action */
 -	//pReq->ActionDataSGE = 0;
 -
--	ioc->add_sge((char *)&pReq->ActionDataSGE,
+-	mpt_add_sge((char *)&pReq->ActionDataSGE,
 -		MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
 -
 -	if (csmisas_send_command_wait(ioc, mf, MPT_IOCTL_DEFAULT_TIMEOUT) != 0)
 -		return -ENODATA;
 -
--	if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) &&
+-	if ((ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) &&
 -	    (reply != NULL)){
--		pReply = (MpiRaidActionReply_t *)&(ioc->ioctl_cmds.reply);
+-		pReply = (MpiRaidActionReply_t *)&(ioc->ioctl->ReplyFrame);
 -		memcpy(reply, pReply,
 -			min(ioc->reply_sz,
 -			4*pReply->MsgLength));
@@ -3314,7 +3406,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Get a free request frame and save the message context.
 -	 */
 -	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
+-		dcsmisasprintk((": no msg frames!\n"));
 -		goto csmisas_raid_inq_exit;
 -	}
 -
@@ -3351,7 +3443,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	memset(request_data,0,request_data_sz);
 -	psge = (char *)&pScsiRequest->SGL;
--	ioc->add_sge(psge, (MPT_SGE_FLAGS_SSIMPLE_READ | 0xFC) ,
+-	mpt_add_sge(psge, (MPT_SGE_FLAGS_SSIMPLE_READ | 0xFC) ,
 -	    request_data_dma);
 -
 -	if (csmisas_send_command_wait(ioc, mf, MPT_IOCTL_DEFAULT_TIMEOUT) != 0) {
@@ -3406,6 +3498,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	u64				sas_address;
 -	struct sas_device_info		*sas_info;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(IOCTL_HEADER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmisas_get_raid_config struct @ %p\n",
@@ -3421,7 +3515,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to malloc RAID_CONFIG_BUFFER "
 -			"csmi_sas_raid_config_buffer_sz=%d memory_pages=%d\n",
--			__FILE__, __LINE__, __FUNCTION__, 
+-			__FILE__, __LINE__, __FUNCTION__,
 -			csmi_sas_raid_config_buffer_sz, memory_pages);
 -		return -ENOMEM;
 -	}
@@ -3437,21 +3531,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(pKarg->IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)pKarg, memory_pages);
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)pKarg, memory_pages);
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	if (pKarg->Configuration.uChangeCount != 0 &&
 -		pKarg->Configuration.uChangeCount != ioc->csmi_change_count ) {
 -		pKarg->IoctlHeader.ReturnCode =
@@ -3521,7 +3615,6 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    ((u64)le32_to_cpu(pVolume0->MaxLBAHigh)) << 32;
 -	tmpTotalMaxLBA = totalMaxLBA + 1;
 -	do_div(tmpTotalMaxLBA, 2048);
--	pKarg->Configuration.bDriveCount = 0;
 -	pKarg->Configuration.uCapacity = tmpTotalMaxLBA;
 -	pKarg->Configuration.uStripeSize =
 -		le32_to_cpu(pVolume0->StripeSize)/2;
@@ -3643,6 +3736,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    (pKarg->Configuration.Data->uNumberOfHeads *
 -		     pKarg->Configuration.Data->uSectorsPerTrack));
 -		pKarg->Configuration.Data->uNumberOfTracks = tmpTotalMaxLBA;
+-		pKarg->Configuration.bDriveCount = 1;
 -	} else if ( pKarg->Configuration.bDataType ==
 -	    CSMI_SAS_RAID_DATA_DEVICE_ID ) {
 -		/* Send inquiry to get VPD Page 0x83 */
@@ -3656,13 +3750,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			pKarg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto cim_get_raid_config_exit;
 -		}
--	} else {
--		/* suppress drive information */
--		if (pKarg->Configuration.bDriveCount ==
--			CSMI_SAS_RAID_DRIVE_COUNT_SUPRESSED) {
--			pKarg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
--			goto cim_get_raid_config_exit;
--		}
+-		pKarg->Configuration.bDriveCount = 1;
+-	}
+-
+-	if (pKarg->Configuration.bDataType != CSMI_SAS_RAID_DATA_DRIVES) {
+-		pKarg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
+-		goto cim_get_raid_config_exit;
+-	}
+-
+-	/* suppress drive information */
+-	if (pKarg->Configuration.bDriveCount ==
+-		CSMI_SAS_RAID_DRIVE_COUNT_SUPRESSED) {
+-		pKarg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
+-		goto cim_get_raid_config_exit;
 -	}
 -
 -	/* get hotspare info, used later in this function */
@@ -3730,18 +3830,20 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    offsetof(CSMI_SAS_RAID_CONFIG,Drives))
 -	    / sizeof(CSMI_SAS_RAID_DRIVES);
 -
+-	pKarg->Configuration.bDriveCount=0;
+-
 -	tmpTotalMaxLBA = totalMaxLBA;
 -	if (pVolume0->VolumeType == MPI_RAID_VOL_TYPE_IS) {
 -		do_div(tmpTotalMaxLBA, pVolume0->NumPhysDisks);
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "IS Volume tmpTotalMaxLBA=%llX\n",
+-		dcsmisasprintk(("IS Volume tmpTotalMaxLBA=%llX\n",
 -		(unsigned long long)tmpTotalMaxLBA));
 -	}
 -	else if (pVolume0->VolumeType == MPI_RAID_VOL_TYPE_IME) {
 -		do_div(tmpTotalMaxLBA, pVolume0->NumPhysDisks * 2);
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "IME Volume tmpTotalMaxLBA=%llX\n",
+-		dcsmisasprintk(("IME Volume tmpTotalMaxLBA=%llX\n",
 -		(unsigned long long)tmpTotalMaxLBA));
 -	} else {
--		dcsmisasprintk(ioc, printk(KERN_DEBUG "IM Volume tmpTotalMaxLBA=%llX\n",
+-		dcsmisasprintk(("IM Volume tmpTotalMaxLBA=%llX\n",
 -		(unsigned long long)tmpTotalMaxLBA));
 -	}
 -
@@ -3755,20 +3857,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			goto cim_get_raid_config_exit;
 -		}
 -
--	        pKarg->Configuration.bDriveCount++;
--		if (pKarg->Configuration.bDataType != CSMI_SAS_RAID_DATA_DRIVES)
--			continue;
--
 -		/* Search the list for the matching SAS address. */
 -		sas_info = csmisas_get_device_component_by_fw(ioc, pPhysDisk0->PhysDiskBus,
 -		    pPhysDisk0->PhysDiskID);
--		if (sas_info) {
--			sas_address = reverse_byte_order64(sas_info->sas_address);
--			memcpy(pKarg->Configuration.Drives[i].bSASAddress,
--			   &sas_address,sizeof(u64));
--			if (!device_info)
--				device_info = sas_info->device_info;
--		}
+-
+-		if (!sas_info)
+-			continue;
+-
+-		sas_address = reverse_byte_order64(sas_info->sas_address);
+-		memcpy(pKarg->Configuration.Drives[i].bSASAddress,
+-		   &sas_address,sizeof(u64));
+-		if (!device_info)
+-			device_info = sas_info->device_info;
 -
 -		memcpy(pKarg->Configuration.Drives[i].bModel,
 -		    pPhysDisk0->InquiryData.VendorID,
@@ -3836,6 +3936,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		    (u32)tmpTotalMaxLBA;
 -		pKarg->Configuration.Drives[i].ulTotalUserBlocks.uHighPart =
 -		    (u32)(tmpTotalMaxLBA >> 32);
+-	        pKarg->Configuration.bDriveCount++;
 -	}
 -
 -	/* adding hot spare info at the end */
@@ -3857,6 +3958,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			if (mpt_config(ioc, &cfg) != 0)
 -				continue;
 -
+-			/* Search the list for the matching SAS address. */
+-			sas_info = csmisas_get_device_component_by_fw(ioc,
+-			    pPhysDisk0->PhysDiskBus, pPhysDisk0->PhysDiskID);
+-
+-			if (!sas_info)
+-				continue;
+-
+-			sas_address = reverse_byte_order64(sas_info->sas_address);
+-			memcpy(pKarg->Configuration.Drives[i].bSASAddress,
+-			   &sas_address,sizeof(u64));
+-
 -			/* don't mix SSP hot spare
 -			 * in SATA volume
 -			 */
@@ -3885,6 +3997,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			do_div(tmpTotalMaxLBA, pVolume0->NumPhysDisks);
 -			/* capacity check for IME volumes*/
 -			if ((pVolume0->VolumeType ==
+-				MPI_RAID_VOL_TYPE_IME) &&
+-			    ((tmpTotalMaxLBA * 2) +
+-			     (64*2*1024 ) /*metadata = 64MB*/ >
+-			    le32_to_cpu(pPhysDisk0->MaxLBA)))
+-				break;
+-
+-			/* capacity check for IME volumes*/
+-			if ((pVolume0->VolumeType ==
 -			    MPI_RAID_VOL_TYPE_IME) &&
 -			    (((totalMaxLBA +
 -			    pVolume0->NumPhysDisks) * 2) +
@@ -3892,22 +4012,6 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			    le32_to_cpu(pPhysDisk0->MaxLBA)))
 -				continue;
 -
--		        pKarg->Configuration.bDriveCount++;
--			if (pKarg->Configuration.bDataType !=
--			    CSMI_SAS_RAID_DATA_DRIVES) {
--				i++;
--				continue;
--			}
--
--			/* Search the list for the matching SAS address. */
--			sas_info = csmisas_get_device_component_by_fw(ioc,
--			    pPhysDisk0->PhysDiskBus, pPhysDisk0->PhysDiskID);
--			if (sas_info) {
--				sas_address = reverse_byte_order64(sas_info->sas_address);
--				memcpy(pKarg->Configuration.Drives[i].bSASAddress,
--				   &sas_address,sizeof(u64));
--			}
--
 -			memcpy(pKarg->Configuration.Drives[i].bModel,
 -			    pPhysDisk0->InquiryData.VendorID,
 -			    offsetof(RAID_PHYS_DISK0_INQUIRY_DATA,ProductRevLevel));
@@ -3946,7 +4050,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -				pKarg->Configuration.Drives[i].bDriveType =
 -					CSMI_SAS_DRIVE_TYPE_SINGLE_PORT_SAS;
 -			}
+-
 -			i++;
+-			pKarg->Configuration.bDriveCount++;
 -		}
 -	}
 -
@@ -4000,12 +4106,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	if (copy_to_user((char *)arg, pKarg, copy_buffer_sz)) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		       "Unable to write out csmi_sas_get_raid_config @ %p\n",
--		   	   __FILE__, __LINE__, __FUNCTION__, uarg);
+-			   __FILE__, __LINE__, __FUNCTION__, uarg);
 -		free_pages((unsigned long)pKarg, memory_pages);
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	free_pages((unsigned long)pKarg, memory_pages);
 -	return 0;
 -}
@@ -4027,6 +4133,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int				memory_pages;
 -	MPT_ADAPTER		*ioc = NULL;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(IOCTL_HEADER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmi_sas_get_raid_features struct @ %p\n",
@@ -4042,7 +4150,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to malloc RAID_FEATURES_BUFFER "
 -			"csmi_sas_raid_features_buffer_sz=%d memory_pages=%d\n",
--			__FILE__, __LINE__, __FUNCTION__, 
+-			__FILE__, __LINE__, __FUNCTION__,
 -			csmi_sas_raid_features_buffer_sz, memory_pages);
 -		return -ENOMEM;
 -	}
@@ -4058,21 +4166,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(pKarg->IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)pKarg, memory_pages);
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)pKarg, memory_pages);
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	if (pKarg->Information.uChangeCount != 0 &&
 -	    pKarg->Information.uChangeCount != ioc->csmi_change_count ) {
 -		pKarg->IoctlHeader.ReturnCode =
@@ -4126,7 +4234,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	free_pages((unsigned long)pKarg, memory_pages);
 -	return 0;
 -}
@@ -4148,6 +4256,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int				memory_pages;
 -	MPT_ADAPTER	*ioc = NULL;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(IOCTL_HEADER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmi_sas_set_raid_control struct @ %p\n",
@@ -4163,7 +4273,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to malloc RAID_CONTROL_BUFFER "
 -			"csmi_sas_raid_control_buffer_sz=%d memory_pages=%d\n",
--			__FILE__, __LINE__, __FUNCTION__, 
+-			__FILE__, __LINE__, __FUNCTION__,
 -			csmi_sas_raid_control_buffer_sz, memory_pages);
 -		return -ENOMEM;
 -	}
@@ -4179,21 +4289,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(pKarg->IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)pKarg, memory_pages);
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)pKarg, memory_pages);
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	if (pKarg->Information.uChangeCount != 0 &&
 -		pKarg->Information.uChangeCount != ioc->csmi_change_count ) {
 -		pKarg->IoctlHeader.ReturnCode =
@@ -4257,7 +4367,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	free_pages((unsigned long)pKarg, memory_pages);
 -	return 0;
 -}
@@ -4278,6 +4388,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	MPT_ADAPTER			*ioc = NULL;
 -	int				iocnum;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_RAID_ELEMENT_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmisas_get_raid_element struct @ %p\n",
@@ -4287,22 +4399,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -/* TODO - implement IOCTL here */
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_BAD_CNTL_CODE;
--	dcsmisasprintk(ioc, printk(KERN_DEBUG ": not implemented\n"));
+-	dcsmisasprintk((": not implemented\n"));
 -
 -// csmisas_get_raid_element_exit:
 -
@@ -4316,7 +4428,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -
 -}
@@ -4337,6 +4449,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	MPT_ADAPTER			*ioc = NULL;
 -	int				iocnum;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_RAID_SET_OPERATION_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmi_set_raid_operation struct @ %p\n",
@@ -4346,22 +4460,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -/* TODO - implement IOCTL here */
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_BAD_CNTL_CODE;
--	dcsmisasprintk(ioc, printk(KERN_DEBUG ": not implemented\n"));
+-	dcsmisasprintk((": not implemented\n"));
 -
 -// cim_set_raid_operation:
 -
@@ -4375,7 +4489,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -
 -}
@@ -4411,6 +4525,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	struct sas_device_info		*sas_info;
 -	u16				ioc_status;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg, sizeof(CSMI_SAS_SSP_TASK_IU_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in csmi_sas_task_managment struct @ %p\n",
@@ -4420,19 +4536,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_INVALID_PARAMETER;
 -
 -	sas_info = csmisas_get_device_component_by_os(ioc,
@@ -4478,16 +4594,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	switch (karg.Parameters.uInformation) {
 -		case CSMI_SAS_SSP_TEST:
--			dcsmisasprintk(ioc, printk(KERN_DEBUG "TM request for test purposes\n"));
+-			dcsmisasprintk(("TM request for test purposes\n"));
 -			break;
 -		case CSMI_SAS_SSP_EXCEEDED:
--			dcsmisasprintk(ioc, printk(KERN_DEBUG "TM request due to timeout\n"));
+-			dcsmisasprintk(("TM request due to timeout\n"));
 -			break;
 -		case CSMI_SAS_SSP_DEMAND:
--			dcsmisasprintk(ioc, printk(KERN_DEBUG "TM request demanded by app\n"));
+-			dcsmisasprintk(("TM request demanded by app\n"));
 -			break;
 -		case CSMI_SAS_SSP_TRIGGER:
--			dcsmisasprintk(ioc, printk(KERN_DEBUG "TM request sent to trigger event\n"));
+-			dcsmisasprintk(("TM request sent to trigger event\n"));
 -			break;
 -	}
 -
@@ -4498,8 +4614,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	 * look up qtag in the ScsiLookup[] table
 -	 */
 -		for (i = 0, found_qtag = 0; i < hd->ioc->req_depth; i++) {
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
+-			if ((hd->ScsiLookup[i]) &&
+-			    (hd->ScsiLookup[i]->tag == queueTag)) {
+-#else
 -			if ((ioc->ScsiLookup[i]) &&
 -			    (ioc->ScsiLookup[i]->tag == queueTag)) {
+-#endif
 -				mf = MPT_INDEX_2_MFPTR(hd->ioc, i);
 -				msgContext =
 -				    mf->u.frame.hwhdr.msgctxu.MsgContext;
@@ -4520,16 +4641,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -		/* Single threading ....
 -		 */
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
 -		if (mptctl_set_tm_flags(hd) != 0) {
 -			karg.IoctlHeader.ReturnCode =
 -			    CSMI_SAS_STATUS_FAILED;
 -			goto cim_get_task_managment_exit;
 -		}
+-#endif
+-
 -		/* Send request
 -		 */
--		if ((mf = mpt_get_msg_frame(mptctl_taskmgmt_id, ioc)) == NULL) {
--			dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
+-		if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
+-			dcsmisasprintk((": no msg frames!\n"));
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0))
 -			mptctl_free_tm_flags(ioc);
+-#endif
 -			karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto cim_get_task_managment_exit;
 -		}
@@ -4541,7 +4667,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		pScsiTm->TaskType = taskType;
 -		pScsiTm->Bus = channel;
 -		pScsiTm->TargetID = id;
+-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15))
+-		int_to_scsilun(karg.Parameters.bLun,
+-		    (struct scsi_lun *)pScsiTm->LUN);
+-#else
 -		pScsiTm->LUN[1] = karg.Parameters.bLun;
+-#endif
 -		pScsiTm->MsgContext = mpi_hdr->MsgContext;
 -		pScsiTm->TaskMsgContext = msgContext;
 -		pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
@@ -4552,10 +4683,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			goto cim_get_task_managment_exit;
 -		}
 -
--		if (ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) {
+-		if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) {
 -
 -			pScsiTmReply =
--			    (pSCSITaskMgmtReply_t ) ioc->ioctl_cmds.reply;
+-			    (pSCSITaskMgmtReply_t ) ioc->ioctl->ReplyFrame;
 -
 -			ioc_status = le16_to_cpu(pScsiTmReply->IOCStatus)
 -			    & MPI_IOCSTATUS_MASK;
@@ -4589,6 +4720,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		break;
 -	}
 -
+-
 - cim_get_task_managment_exit:
 -
 -	/* Copy the data from kernel memory to user memory
@@ -4601,7 +4733,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -4705,7 +4837,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	/* Get a MF for this command.
 -	 */
 -	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": no msg frames!\n"));
+-		dcsmisasprintk((": no msg frames!\n"));
 -		return -1;
 -        }
 -
@@ -4720,15 +4852,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	if (csmisas_send_command_wait(ioc, mf, MPT_IOCTL_DEFAULT_TIMEOUT) != 0)
 -		return -1;
 -
--	if ((ioc->ioctl_cmds.status & MPT_MGMT_STATUS_RF_VALID) == 0)
+-	if ((ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) == 0)
 -		return -1;
 -
 -	/* process the completed Reply Message Frame */
--	sasIoUnitCntrReply = (SasIoUnitControlReply_t *)ioc->ioctl_cmds.reply;
+-	sasIoUnitCntrReply = (SasIoUnitControlReply_t *)ioc->ioctl->ReplyFrame;
 -	ioc_status = le16_to_cpu(sasIoUnitCntrReply->IOCStatus)
 -	    & MPI_IOCSTATUS_MASK;
 -	if (ioc_status != MPI_IOCSTATUS_SUCCESS) {
--		printk(KERN_DEBUG "%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
+-		printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
 -		    __FUNCTION__,
 -		    sasIoUnitCntrReply->IOCStatus,
 -		    sasIoUnitCntrReply->IOCLogInfo);
@@ -4763,6 +4895,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int 				csmi_sas_phy_control_buffer_sz;
 -	int				memory_pages;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&ioctl_header, uarg, sizeof(IOCTL_HEADER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in IOCTL_HEADER"
@@ -4778,7 +4912,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to malloc SAS_PHY_CONTROL_BUFFER "
 -			"csmi_sas_phy_control_buffer_sz=%d memory_pages=%d\n",
--			__FILE__, __LINE__, __FUNCTION__, 
+-			__FILE__, __LINE__, __FUNCTION__,
 -			csmi_sas_phy_control_buffer_sz, memory_pages);
 -		return -ENOMEM;
 -	}
@@ -4794,21 +4928,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(ioctl_header.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)karg, memory_pages);
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)karg, memory_pages);
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	if (karg->bPhyIdentifier >= ioc->num_ports) {
 -		karg->IoctlHeader.ReturnCode =
 -		   CSMI_SAS_STATUS_INVALID_PARAMETER;
@@ -4835,14 +4969,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	cfg.timeout = MPT_IOCTL_DEFAULT_TIMEOUT;
 -
 -	if (mpt_config(ioc, &cfg) != 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((
 -		    ": FAILED: READ MPI_SASIOUNITPAGE0: HEADER\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
 -	}
 -
 -	if (hdr.ExtPageLength == 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": hdr.ExtPageLength == 0\n"));
+-		dcsmisasprintk((": hdr.ExtPageLength == 0\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
 -	}
@@ -4852,7 +4986,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    sasIoUnitPg0_data_sz, &sasIoUnitPg0_dma);
 -
 -	if (!sasIoUnitPg0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
 -	}
@@ -4862,7 +4996,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
 -
 -	if (mpt_config(ioc, &cfg) != 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((
 -		    ": FAILED: READ MPI_SASIOUNITPAGE0: CURRENT\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
@@ -4888,14 +5022,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	cfg.timeout = MPT_IOCTL_DEFAULT_TIMEOUT;
 -
 -	if (mpt_config(ioc, &cfg) != 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((
 -		    ": FAILED: READ MPI_SASIOUNITPAGE1: HEADER\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
 -	}
 -
 -	if (hdr.ExtPageLength == 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": hdr.ExtPageLength == 0\n"));
+-		dcsmisasprintk((": hdr.ExtPageLength == 0\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
 -	}
@@ -4905,7 +5039,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	    sasIoUnitPg1_data_sz, &sasIoUnitPg1_dma);
 -
 -	if (!sasIoUnitPg1) {
--		dcsmisasprintk(ioc, printk(KERN_ERR ": pci_alloc_consistent: FAILED\n"));
+-		dcsmisasprintk((": pci_alloc_consistent: FAILED\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
 -	}
@@ -4915,7 +5049,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
 -
 -	if (mpt_config(ioc, &cfg) != 0) {
--		dcsmisasprintk(ioc, printk(KERN_ERR
+-		dcsmisasprintk((
 -		    ": FAILED:  READ MPI_SASIOUNITPAGE1: CURRENT\n"));
 -		karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -		goto cim_sas_phy_control_exit;
@@ -4949,7 +5083,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			cfg.dir = 1;
 -			cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_NVRAM;
 -			if (mpt_config(ioc, &cfg) != 0) {
--				dcsmisasprintk(ioc, printk(KERN_ERR
+-				dcsmisasprintk((
 -			    ": FAILED: WRITE MPI_SASIOUNITPAGE1 NVRAM\n"));
 -				karg->IoctlHeader.ReturnCode =
 -				   CSMI_SAS_STATUS_FAILED;
@@ -4957,7 +5091,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -			}
 -			cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
 -			if (mpt_config(ioc, &cfg) != 0) {
--				dcsmisasprintk(ioc, printk(KERN_ERR
+-				dcsmisasprintk((
 -			 ": FAILED: WRITE MPI_SASIOUNITPAGE1 CURRENT\n"));
 -				karg->IoctlHeader.ReturnCode =
 -				   CSMI_SAS_STATUS_FAILED;
@@ -4966,7 +5100,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		}
 -		if (csmisas_phy_reset(ioc,
 -		    karg->bPhyIdentifier, opcode) != 0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR
+-			dcsmisasprintk((
 -			    ": FAILED: csmisas_phy_reset\n"));
 -			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto cim_sas_phy_control_exit;
@@ -4985,21 +5119,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		cfg.dir = 1;
 -		cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_NVRAM;
 -		if (mpt_config(ioc, &cfg) != 0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR
+-			dcsmisasprintk((
 -			    ": FAILED: WRITE MPI_SASIOUNITPAGE1 NVRAM\n"));
 -			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto cim_sas_phy_control_exit;
 -		}
 -		cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
 -		if (mpt_config(ioc, &cfg) != 0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR
+-			dcsmisasprintk((
 -			    ": FAILED: WRITE MPI_SASIOUNITPAGE1 CURRENT\n"));
 -			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto cim_sas_phy_control_exit;
 -		}
 -		if (csmisas_phy_reset(ioc,
 -		    karg->bPhyIdentifier, MPI_SAS_OP_PHY_HARD_RESET) != 0) {
--			dcsmisasprintk(ioc, printk(KERN_ERR
+-			dcsmisasprintk((
 -			    ": FAILED: csmisas_phy_reset\n"));
 -			karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_FAILED;
 -			goto cim_sas_phy_control_exit;
@@ -5055,7 +5189,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	free_pages((unsigned long)karg, memory_pages);
 -	return 0;
 -}
@@ -5148,6 +5282,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int				iocnum;
 -	int				i;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&karg, uarg,
 -		sizeof(CSMI_SAS_CONNECTOR_INFO_BUFFER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
@@ -5159,19 +5295,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg.IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	karg.IoctlHeader.ReturnCode = CSMI_SAS_STATUS_SUCCESS;
 -
 -	/* `32` is the sizeof MPI_MANPAGE7_CONNECTOR_INFO */
@@ -5217,7 +5353,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return 0;
 -}
 -
@@ -5242,7 +5378,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int				sasEnclosurePg0_data_sz=0;
 -	u64				sas_address;
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
 -	memset (location_ident, 0, sizeof(*location_ident));
 -
 -	/* SAS Device Page 0 */
@@ -5283,7 +5419,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
 -	cfg.pageAddr = (bus << 8) + id
 -	    + (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
--	       	MPI_SAS_DEVICE_PGAD_FORM_SHIFT);
+-			MPI_SAS_DEVICE_PGAD_FORM_SHIFT);
 -
 -	if ((rc = mpt_config(ioc, &cfg)) != 0) {
 -		rc=-1;
@@ -5399,7 +5535,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		pci_free_consistent(ioc->pcidev, sasEnclosurePg0_data_sz,
 -		    sasEnclosurePg0, sasEnclosurePg0_dma);
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	return rc;
 -}
 -
@@ -5648,6 +5784,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -	int				memory_pages;
 -	struct sas_device_info		*sas_info;
 -
+-	dcsmisasprintk(("%s enter.\n",__FUNCTION__));
+-
 -	if (copy_from_user(&ioctl_header, uarg, sizeof(IOCTL_HEADER))) {
 -		printk(KERN_ERR "%s@%d::%s() - "
 -		    "Unable to read in IOCTL_HEADER"
@@ -5663,7 +5801,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		printk(KERN_ERR "%s@%d::%s() - "
 -			"Unable to malloc GET_LOCATION_BUFFER "
 -			"csmi_sas_get_location_sz=%d memory_pages=%d\n",
--			__FILE__, __LINE__, __FUNCTION__, 
+-			__FILE__, __LINE__, __FUNCTION__,
 -			csmi_sas_get_location_sz, memory_pages);
 -		return -ENOMEM;
 -	}
@@ -5679,21 +5817,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -
 -	if (((iocnum = mpt_verify_adapter(karg->IoctlHeader.IOControllerNumber,
 -	    &ioc)) < 0) || (ioc == NULL)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not found!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		"%s::%s() @%d - ioc%d not found!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)karg, memory_pages);
 -		return -ENODEV;
 -	}
 -
 -	if (!csmisas_is_this_sas_cntr(ioc)) {
--		printk(KERN_ERR "%s::%s() @%d - ioc%d not SAS controller!\n",
--		    __FILE__, __FUNCTION__, __LINE__, iocnum);
+-		dcsmisasprintk((KERN_ERR
+-		    "%s::%s() @%d - ioc%d not SAS controller!\n",
+-		    __FILE__, __FUNCTION__, __LINE__, iocnum));
 -		free_pages((unsigned long)karg, memory_pages);
 -		return -ENODEV;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s enter.\n",__FUNCTION__));
--
 -	karg->IoctlHeader.ReturnCode = CSMI_SAS_STATUS_INVALID_PARAMETER;
 -	if(karg->bLengthOfLocationIdentifier !=
 -	    sizeof(CSMI_SAS_LOCATION_IDENTIFIER))
@@ -5754,14 +5892,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.c
 -		return -EFAULT;
 -	}
 -
--	dcsmisasprintk(ioc, printk(KERN_DEBUG "%s exit.\n",__FUNCTION__));
+-	dcsmisasprintk(("%s exit.\n",__FUNCTION__));
 -	free_pages((unsigned long)karg, memory_pages);
 -	return 0;
 -}
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/csmi/csmisas.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.h	2009-04-18 06:33:31.404506136 -0600
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/csmi/csmisas.h linux-2.6.9-55.0.12/drivers/message/fusion/csmi/csmisas.h
+--- linux-2.6.9-67.0.1/drivers/message/fusion/csmi/csmisas.h	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/csmi/csmisas.h	1970-01-01 01:00:00.000000000 +0100
 @@ -1,1854 +0,0 @@
 -/**************************************************************************
 -
@@ -7617,10 +7754,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmi/csmisas.h
 -#pragma pack()
 -
 -#endif // _CSMI_SAS_H_
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmisas.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/csmisas.c	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/csmisas.c	2009-05-11 23:24:42.000000000 -0600
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/csmisas.c linux-2.6.9-55.0.12/drivers/message/fusion/csmisas.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/csmisas.c	1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/csmisas.c	2007-11-02 09:10:23.000000000 +0100
 @@ -0,0 +1,5095 @@
 +#define mptctl_is_this_sas_cntr(ioc) (ioc->bus_type == SAS) ? 1 : 0
 +
@@ -12717,10 +12853,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmisas.c
 +	kfree(karg);
 +	return 0;
 +}
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmisas.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/csmisas.h	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/csmisas.h	2009-05-11 23:24:42.000000000 -0600
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/csmisas.h linux-2.6.9-55.0.12/drivers/message/fusion/csmisas.h
+--- linux-2.6.9-67.0.1/drivers/message/fusion/csmisas.h	1970-01-01 01:00:00.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/csmisas.h	2007-11-02 09:10:23.000000000 +0100
 @@ -0,0 +1,1796 @@
 +/**************************************************************************
 +
@@ -14518,1898 +14653,50 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/csmisas.h
 +#pragma pack()
 +
 +#endif // _CSMI_SAS_H_
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/linux_compat.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/linux_compat.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/linux_compat.h	2009-05-11 23:24:42.000000000 -0600
-@@ -8,11 +8,20 @@
- #include <linux/sched.h>
- #include <scsi/scsi_device.h>
- #include <scsi/scsi_cmnd.h>
--#include <scsi/scsi_dbg.h>
- 
- /* define pm_message_t which came in lk 2.6.11
-  * to be backward compatible to older variants of lk 2.6
-  */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- typedef u32 pm_message_t;
-+#endif
-+
-+/* exporting of pci_disable_msi which came in lk 2.6.8
-+ * to be backward compatible to older variants of lk 2.6
-+ */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8))
-+static inline void pci_disable_msi(struct pci_dev* dev) {}
-+#endif
-+
- /*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- #endif /* _LINUX_COMPAT_H */
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_cnfg.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_cnfg.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_cnfg.h	2009-05-11 23:24:42.000000000 -0600
-@@ -1,12 +1,12 @@
- /*
-- *  Copyright (c) 2000-2007 LSI Logic Corporation.
-+ *  Copyright (c) 2000-2005 LSI Logic Corporation.
-  *
-  *
-  *           Name:  mpi_cnfg.h
-  *          Title:  MPI Config message, structures, and Pages
-  *  Creation Date:  July 27, 2000
-  *
-- *    mpi_cnfg.h Version:  01.05.16
-+ *    mpi_cnfg.h Version:  01.05.12
-  *
-  *  Version History
-  *  ---------------
-@@ -276,43 +276,6 @@
-  *                      Added AdditionalControlFlags, MaxTargetPortConnectTime,
-  *                      ReportDeviceMissingDelay, and IODeviceMissingDelay
-  *                      fields to SAS IO Unit Page 1.
-- *  10-11-06  01.05.13  Added NumForceWWID field and ForceWWID array to
-- *                      Manufacturing Page 5.
-- *                      Added Manufacturing pages 8 through 10.
-- *                      Added defines for supported metadata size bits in
-- *                      CapabilitiesFlags field of IOC Page 6.
-- *                      Added defines for metadata size bits in VolumeSettings
-- *                      field of RAID Volume Page 0.
-- *                      Added SATA Link Reset settings, Enable SATA Asynchronous
-- *                      Notification bit, and HideNonZeroAttachedPhyIdentifiers
-- *                      bit to AdditionalControlFlags field of SAS IO Unit
-- *                      Page 1.
-- *                      Added defines for Enclosure Devices Unmapped and
-- *                      Device Limit Exceeded bits in Status field of SAS IO
-- *                      Unit Page 2.
-- *                      Added more AccessStatus values for SAS Device Page 0.
-- *                      Added bit for SATA Asynchronous Notification Support in
-- *                      Flags field of SAS Device Page 0.
-- *  02-28-07  01.05.14  Added ExtFlags field to Manufacturing Page 4.
-- *                      Added Disable SMART Polling for CapabilitiesFlags of
-- *                      IOC Page 6.
-- *                      Added Disable SMART Polling to DeviceSettings of BIOS
-- *                      Page 1.
-- *                      Added Multi-Port Domain bit for DiscoveryStatus field
-- *                      of SAS IO Unit Page.
-- *                      Added Multi-Port Domain Illegal flag for SAS IO Unit
-- *                      Page 1 AdditionalControlFlags field.
-- *  05-24-07  01.05.15  Added Hide Physical Disks with Non-Integrated RAID
-- *                      Metadata bit to Manufacturing Page 4 ExtFlags field.
-- *                      Added Internal Connector to End Device Present bit to
-- *                      Expander Page 0 Flags field.
-- *                      Fixed define for
-- *                      MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED.
-- *  08-07-07  01.05.16  Added MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT
-- *                      define.
-- *                      Added BIOS Page 4 structure.
-- *                      Added MPI_RAID_PHYS_DISK1_PATH_MAX define for RAID
-- *                      Physcial Disk Page 1.
-  *  --------------------------------------------------------------------------
-  */
- 
-@@ -659,7 +622,7 @@
-     U8                              InfoSize1;          /* 0Bh */
-     U8                              InquirySize;        /* 0Ch */
-     U8                              Flags;              /* 0Dh */
--    U16                             ExtFlags;           /* 0Eh */
-+    U16                             Reserved2;          /* 0Eh */
-     U8                              InquiryData[56];    /* 10h */
-     U32                             ISVolumeSettings;   /* 48h */
-     U32                             IMEVolumeSettings;  /* 4Ch */
-@@ -678,7 +641,7 @@
- } CONFIG_PAGE_MANUFACTURING_4, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_4,
-   ManufacturingPage4_t, MPI_POINTER pManufacturingPage4_t;
- 
--#define MPI_MANUFACTURING4_PAGEVERSION                  (0x05)
-+#define MPI_MANUFACTURING4_PAGEVERSION                  (0x04)
- 
- /* defines for the Flags field */
- #define MPI_MANPAGE4_FORCE_BAD_BLOCK_TABLE              (0x80)
-@@ -690,31 +653,18 @@
- #define MPI_MANPAGE4_IM_RESYNC_CACHE_ENABLE             (0x02)
- #define MPI_MANPAGE4_IR_NO_MIX_SAS_SATA                 (0x01)
- 
--/* defines for the ExtFlags field */
--#define MPI_MANPAGE4_EXTFLAGS_HIDE_NON_IR_METADATA      (0x0008)
--#define MPI_MANPAGE4_EXTFLAGS_SAS_CACHE_DISABLE         (0x0004)
--#define MPI_MANPAGE4_EXTFLAGS_SATA_CACHE_DISABLE        (0x0002)
--#define MPI_MANPAGE4_EXTFLAGS_LEGACY_MODE               (0x0001)
--
--
--#ifndef MPI_MANPAGE5_NUM_FORCEWWID
--#define MPI_MANPAGE5_NUM_FORCEWWID      (1)
--#endif
- 
- typedef struct _CONFIG_PAGE_MANUFACTURING_5
- {
-     CONFIG_PAGE_HEADER              Header;             /* 00h */
-     U64                             BaseWWID;           /* 04h */
-     U8                              Flags;              /* 0Ch */
--    U8                              NumForceWWID;       /* 0Dh */
-+    U8                              Reserved1;          /* 0Dh */
-     U16                             Reserved2;          /* 0Eh */
--    U32                             Reserved3;          /* 10h */
--    U32                             Reserved4;          /* 14h */
--    U64                             ForceWWID[MPI_MANPAGE5_NUM_FORCEWWID]; /* 18h */
- } CONFIG_PAGE_MANUFACTURING_5, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_5,
-   ManufacturingPage5_t, MPI_POINTER pManufacturingPage5_t;
- 
--#define MPI_MANUFACTURING5_PAGEVERSION                  (0x02)
-+#define MPI_MANUFACTURING5_PAGEVERSION                  (0x01)
- 
- /* defines for the Flags field */
- #define MPI_MANPAGE5_TWO_WWID_PER_PHY                   (0x01)
-@@ -790,36 +740,6 @@
- #define MPI_MANPAGE7_FLAG_USE_SLOT_INFO                 (0x00000001)
- 
- 
--typedef struct _CONFIG_PAGE_MANUFACTURING_8
--{
--    CONFIG_PAGE_HEADER              Header;             /* 00h */
--    U32                             ProductSpecificInfo;/* 04h */
--} CONFIG_PAGE_MANUFACTURING_8, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_8,
--  ManufacturingPage8_t, MPI_POINTER pManufacturingPage8_t;
--
--#define MPI_MANUFACTURING8_PAGEVERSION                  (0x00)
--
--
--typedef struct _CONFIG_PAGE_MANUFACTURING_9
--{
--    CONFIG_PAGE_HEADER              Header;             /* 00h */
--    U32                             ProductSpecificInfo;/* 04h */
--} CONFIG_PAGE_MANUFACTURING_9, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_9,
--  ManufacturingPage9_t, MPI_POINTER pManufacturingPage9_t;
--
--#define MPI_MANUFACTURING9_PAGEVERSION                  (0x00)
--
--
--typedef struct _CONFIG_PAGE_MANUFACTURING_10
--{
--    CONFIG_PAGE_HEADER              Header;             /* 00h */
--    U32                             ProductSpecificInfo;/* 04h */
--} CONFIG_PAGE_MANUFACTURING_10, MPI_POINTER PTR_CONFIG_PAGE_MANUFACTURING_10,
--  ManufacturingPage10_t, MPI_POINTER pManufacturingPage10_t;
--
--#define MPI_MANUFACTURING10_PAGEVERSION                 (0x00)
--
--
- /****************************************************************************
- *   IO Unit Config Pages
- ****************************************************************************/
-@@ -1160,17 +1080,10 @@
- } CONFIG_PAGE_IOC_6, MPI_POINTER PTR_CONFIG_PAGE_IOC_6,
-   IOCPage6_t, MPI_POINTER pIOCPage6_t;
- 
--#define MPI_IOCPAGE6_PAGEVERSION                        (0x01)
-+#define MPI_IOCPAGE6_PAGEVERSION                        (0x00)
- 
- /* IOC Page 6 Capabilities Flags */
- 
--#define MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT  (0x00000010)
--#define MPI_IOCPAGE6_CAP_FLAGS_DISABLE_SMART_POLLING    (0x00000008)
--
--#define MPI_IOCPAGE6_CAP_FLAGS_MASK_METADATA_SIZE       (0x00000006)
--#define MPI_IOCPAGE6_CAP_FLAGS_64MB_METADATA_SIZE       (0x00000000)
--#define MPI_IOCPAGE6_CAP_FLAGS_512MB_METADATA_SIZE      (0x00000002)
--
- #define MPI_IOCPAGE6_CAP_FLAGS_GLOBAL_HOT_SPARE         (0x00000001)
- 
- 
-@@ -1237,7 +1150,6 @@
- #define MPI_BIOSPAGE1_IOCSET_ALTERNATE_CHS              (0x00000008)
- 
- /* values for the DeviceSettings field */
--#define MPI_BIOSPAGE1_DEVSET_DISABLE_SMART_POLLING      (0x00000010)
- #define MPI_BIOSPAGE1_DEVSET_DISABLE_SEQ_LUN            (0x00000008)
- #define MPI_BIOSPAGE1_DEVSET_DISABLE_RM_LUN             (0x00000004)
- #define MPI_BIOSPAGE1_DEVSET_DISABLE_NON_RM_LUN         (0x00000002)
-@@ -1434,15 +1346,6 @@
- #define MPI_BIOSPAGE2_FORM_SAS_WWN                      (0x05)
- #define MPI_BIOSPAGE2_FORM_ENCLOSURE_SLOT               (0x06)
- 
--typedef struct _CONFIG_PAGE_BIOS_4
--{
--    CONFIG_PAGE_HEADER      Header;                     /* 00h */
--    U64                     ReassignmentBaseWWID;       /* 04h */
--} CONFIG_PAGE_BIOS_4, MPI_POINTER PTR_CONFIG_PAGE_BIOS_4,
--  BIOSPage4_t, MPI_POINTER pBIOSPage4_t;
--
--#define MPI_BIOSPAGE4_PAGEVERSION                       (0x00)
--
- 
- /****************************************************************************
- *   SCSI Port Config Pages
-@@ -2257,11 +2160,6 @@
- #define MPI_RAIDVOL0_SETTING_AUTO_CONFIGURE             (0x0004)
- #define MPI_RAIDVOL0_SETTING_PRIORITY_RESYNC            (0x0008)
- #define MPI_RAIDVOL0_SETTING_FAST_DATA_SCRUBBING_0102   (0x0020) /* obsolete */
--
--#define MPI_RAIDVOL0_SETTING_MASK_METADATA_SIZE         (0x00C0)
--#define MPI_RAIDVOL0_SETTING_64MB_METADATA_SIZE         (0x0000)
--#define MPI_RAIDVOL0_SETTING_512MB_METADATA_SIZE        (0x0040)
--
- #define MPI_RAIDVOL0_SETTING_USE_PRODUCT_ID_SUFFIX      (0x0010)
- #define MPI_RAIDVOL0_SETTING_USE_DEFAULTS               (0x8000)
- 
-@@ -2305,7 +2203,7 @@
- } CONFIG_PAGE_RAID_VOL_0, MPI_POINTER PTR_CONFIG_PAGE_RAID_VOL_0,
-   RaidVolumePage0_t, MPI_POINTER pRaidVolumePage0_t;
- 
--#define MPI_RAIDVOLPAGE0_PAGEVERSION                    (0x07)
-+#define MPI_RAIDVOLPAGE0_PAGEVERSION                    (0x06)
- 
- /* values for RAID Volume Page 0 InactiveStatus field */
- #define MPI_RAIDVOLPAGE0_UNKNOWN_INACTIVE               (0x00)
-@@ -2320,11 +2218,11 @@
- typedef struct _CONFIG_PAGE_RAID_VOL_1
- {
-     CONFIG_PAGE_HEADER      Header;         /* 00h */
--    U8                      VolumeID;       /* 04h */
--    U8                      VolumeBus;      /* 05h */
--    U8                      VolumeIOC;      /* 06h */
--    U8                      Reserved0;      /* 07h */
--    U8                      GUID[24];       /* 08h */
-+    U8                      VolumeID;       /* 01h */
-+    U8                      VolumeBus;      /* 02h */
-+    U8                      VolumeIOC;      /* 03h */
-+    U8                      Reserved0;      /* 04h */
-+    U8                      GUID[24];       /* 05h */
-     U8                      Name[32];       /* 20h */
-     U64                     WWID;           /* 40h */
-     U32                     Reserved1;      /* 48h */
-@@ -2379,7 +2277,7 @@
- } RAID_PHYS_DISK0_STATUS, MPI_POINTER PTR_RAID_PHYS_DISK0_STATUS,
-   RaidPhysDiskStatus_t, MPI_POINTER pRaidPhysDiskStatus_t;
- 
--/* RAID Physical Disk PhysDiskStatus flags */
-+/* RAID Volume 2 IM Physical Disk DiskStatus flags */
- 
- #define MPI_PHYSDISK0_STATUS_FLAG_OUT_OF_SYNC           (0x01)
- #define MPI_PHYSDISK0_STATUS_FLAG_QUIESCED              (0x02)
-@@ -2434,15 +2332,6 @@
- #define MPI_RAID_PHYSDISK1_FLAG_BROKEN          (0x0002)
- #define MPI_RAID_PHYSDISK1_FLAG_INVALID         (0x0001)
- 
--
--/*
-- * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
-- * one and check Header.PageLength or NumPhysDiskPaths at runtime.
-- */
--#ifndef MPI_RAID_PHYS_DISK1_PATH_MAX
--#define MPI_RAID_PHYS_DISK1_PATH_MAX    (1)
--#endif
--
- typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1
- {
-     CONFIG_PAGE_HEADER              Header;             /* 00h */
-@@ -2450,7 +2339,7 @@
-     U8                              PhysDiskNum;        /* 05h */
-     U16                             Reserved2;          /* 06h */
-     U32                             Reserved1;          /* 08h */
--    RAID_PHYS_DISK1_PATH            Path[MPI_RAID_PHYS_DISK1_PATH_MAX];/* 0Ch */
-+    RAID_PHYS_DISK1_PATH            Path[1];            /* 0Ch */
- } CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1,
-   RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t;
- 
-@@ -2592,7 +2481,6 @@
- #define MPI_SAS_IOUNIT0_DS_TABLE_LINK                       (0x00000400)
- #define MPI_SAS_IOUNIT0_DS_UNSUPPORTED_DEVICE               (0x00000800)
- #define MPI_SAS_IOUNIT0_DS_MAX_SATA_TARGETS                 (0x00001000)
--#define MPI_SAS_IOUNIT0_DS_MULTI_PORT_DOMAIN                (0x00002000)
- 
- 
- typedef struct _MPI_SAS_IO_UNIT1_PHY_DATA
-@@ -2630,7 +2518,7 @@
- } CONFIG_PAGE_SAS_IO_UNIT_1, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_1,
-   SasIOUnitPage1_t, MPI_POINTER pSasIOUnitPage1_t;
- 
--#define MPI_SASIOUNITPAGE1_PAGEVERSION      (0x07)
-+#define MPI_SASIOUNITPAGE1_PAGEVERSION      (0x06)
- 
- /* values for SAS IO Unit Page 1 ControlFlags */
- #define MPI_SAS_IOUNIT1_CONTROL_DEVICE_SELF_TEST            (0x8000)
-@@ -2656,14 +2544,7 @@
- #define MPI_SAS_IOUNIT1_CONTROL_CLEAR_AFFILIATION           (0x0001)
- 
- /* values for SAS IO Unit Page 1 AdditionalControlFlags */
--#define MPI_SAS_IOUNIT1_ACONTROL_MULTI_PORT_DOMAIN_ILLEGAL          (0x0080)
--#define MPI_SAS_IOUNIT1_ACONTROL_SATA_ASYNCHROUNOUS_NOTIFICATION    (0x0040)
--#define MPI_SAS_IOUNIT1_ACONTROL_HIDE_NONZERO_ATTACHED_PHY_IDENT    (0x0020)
--#define MPI_SAS_IOUNIT1_ACONTROL_PORT_ENABLE_ONLY_SATA_LINK_RESET   (0x0010)
--#define MPI_SAS_IOUNIT1_ACONTROL_OTHER_AFFILIATION_SATA_LINK_RESET  (0x0008)
--#define MPI_SAS_IOUNIT1_ACONTROL_SELF_AFFILIATION_SATA_LINK_RESET   (0x0004)
--#define MPI_SAS_IOUNIT1_ACONTROL_NO_AFFILIATION_SATA_LINK_RESET     (0x0002)
--#define MPI_SAS_IOUNIT1_ACONTROL_ALLOW_TABLE_TO_TABLE               (0x0001)
-+#define MPI_SAS_IOUNIT1_ACONTROL_ALLOW_TABLE_TO_TABLE       (0x0001)
- 
- /* defines for SAS IO Unit Page 1 ReportDeviceMissingDelay */
- #define MPI_SAS_IOUNIT1_REPORT_MISSING_TIMEOUT_MASK         (0x7F)
-@@ -2704,11 +2585,9 @@
- } CONFIG_PAGE_SAS_IO_UNIT_2, MPI_POINTER PTR_CONFIG_PAGE_SAS_IO_UNIT_2,
-   SasIOUnitPage2_t, MPI_POINTER pSasIOUnitPage2_t;
- 
--#define MPI_SASIOUNITPAGE2_PAGEVERSION      (0x06)
-+#define MPI_SASIOUNITPAGE2_PAGEVERSION      (0x05)
- 
- /* values for SAS IO Unit Page 2 Status field */
--#define MPI_SAS_IOUNIT2_STATUS_DEVICE_LIMIT_EXCEEDED        (0x08)
--#define MPI_SAS_IOUNIT2_STATUS_ENCLOSURE_DEVICES_UNMAPPED   (0x04)
- #define MPI_SAS_IOUNIT2_STATUS_DISABLED_PERSISTENT_MAPPINGS (0x02)
- #define MPI_SAS_IOUNIT2_STATUS_FULL_PERSISTENT_MAPPINGS     (0x01)
- 
-@@ -2784,7 +2663,6 @@
- #define MPI_SAS_EXPANDER0_DS_UNSUPPORTED_DEVICE         (0x00000800)
- 
- /* values for SAS Expander Page 0 Flags field */
--#define MPI_SAS_EXPANDER0_FLAGS_CONNECTOR_END_DEVICE    (0x04)
- #define MPI_SAS_EXPANDER0_FLAGS_ROUTE_TABLE_CONFIG      (0x02)
- #define MPI_SAS_EXPANDER0_FLAGS_CONFIG_IN_PROGRESS      (0x01)
- 
-@@ -2825,7 +2703,7 @@
- /* see mpi_sas.h for values for SAS Expander Page 1 AttachedDeviceInfo values */
- 
- /* values for SAS Expander Page 1 DiscoveryInfo field */
--#define MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED     (0x04)
-+#define MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY DISABLED     (0x04)
- #define MPI_SAS_EXPANDER1_DISCINFO_LINK_STATUS_CHANGE   (0x02)
- #define MPI_SAS_EXPANDER1_DISCINFO_NO_ROUTING_ENTRIES   (0x01)
- 
-@@ -2861,38 +2739,24 @@
- } CONFIG_PAGE_SAS_DEVICE_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_DEVICE_0,
-   SasDevicePage0_t, MPI_POINTER pSasDevicePage0_t;
- 
--#define MPI_SASDEVICE0_PAGEVERSION          (0x05)
-+#define MPI_SASDEVICE0_PAGEVERSION          (0x04)
- 
- /* values for SAS Device Page 0 AccessStatus field */
--#define MPI_SAS_DEVICE0_ASTATUS_NO_ERRORS                   (0x00)
--#define MPI_SAS_DEVICE0_ASTATUS_SATA_INIT_FAILED            (0x01)
--#define MPI_SAS_DEVICE0_ASTATUS_SATA_CAPABILITY_FAILED      (0x02)
--#define MPI_SAS_DEVICE0_ASTATUS_SATA_AFFILIATION_CONFLICT   (0x03)
--/* specific values for SATA Init failures */
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_UNKNOWN                 (0x10)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT    (0x11)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_DIAG                    (0x12)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_IDENTIFICATION          (0x13)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_CHECK_POWER             (0x14)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_PIO_SN                  (0x15)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_MDMA_SN                 (0x16)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_UDMA_SN                 (0x17)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_ZONING_VIOLATION        (0x18)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_NOT_ADDRESSABLE         (0x19)
--#define MPI_SAS_DEVICE0_ASTATUS_SIF_MAX                     (0x1F)
-+#define MPI_SAS_DEVICE0_ASTATUS_NO_ERRORS               (0x00)
-+#define MPI_SAS_DEVICE0_ASTATUS_SATA_INIT_FAILED        (0x01)
-+#define MPI_SAS_DEVICE0_ASTATUS_SATA_CAPABILITY_FAILED  (0x02)
- 
- /* values for SAS Device Page 0 Flags field */
--#define MPI_SAS_DEVICE0_FLAGS_SATA_ASYNCHRONOUS_NOTIFY      (0x0400)
--#define MPI_SAS_DEVICE0_FLAGS_SATA_SW_PRESERVE              (0x0200)
--#define MPI_SAS_DEVICE0_FLAGS_UNSUPPORTED_DEVICE            (0x0100)
--#define MPI_SAS_DEVICE0_FLAGS_SATA_48BIT_LBA_SUPPORTED      (0x0080)
--#define MPI_SAS_DEVICE0_FLAGS_SATA_SMART_SUPPORTED          (0x0040)
--#define MPI_SAS_DEVICE0_FLAGS_SATA_NCQ_SUPPORTED            (0x0020)
--#define MPI_SAS_DEVICE0_FLAGS_SATA_FUA_SUPPORTED            (0x0010)
--#define MPI_SAS_DEVICE0_FLAGS_PORT_SELECTOR_ATTACH          (0x0008)
--#define MPI_SAS_DEVICE0_FLAGS_MAPPING_PERSISTENT            (0x0004)
--#define MPI_SAS_DEVICE0_FLAGS_DEVICE_MAPPED                 (0x0002)
--#define MPI_SAS_DEVICE0_FLAGS_DEVICE_PRESENT                (0x0001)
-+#define MPI_SAS_DEVICE0_FLAGS_SATA_SW_PRESERVE          (0x0200)
-+#define MPI_SAS_DEVICE0_FLAGS_UNSUPPORTED_DEVICE        (0x0100)
-+#define MPI_SAS_DEVICE0_FLAGS_SATA_48BIT_LBA_SUPPORTED  (0x0080)
-+#define MPI_SAS_DEVICE0_FLAGS_SATA_SMART_SUPPORTED      (0x0040)
-+#define MPI_SAS_DEVICE0_FLAGS_SATA_NCQ_SUPPORTED        (0x0020)
-+#define MPI_SAS_DEVICE0_FLAGS_SATA_FUA_SUPPORTED        (0x0010)
-+#define MPI_SAS_DEVICE0_FLAGS_PORT_SELECTOR_ATTACH      (0x0008)
-+#define MPI_SAS_DEVICE0_FLAGS_MAPPING_PERSISTENT        (0x0004)
-+#define MPI_SAS_DEVICE0_FLAGS_DEVICE_MAPPED             (0x0002)
-+#define MPI_SAS_DEVICE0_FLAGS_DEVICE_PRESENT            (0x0001)
- 
- /* see mpi_sas.h for values for SAS Device Page 0 DeviceInfo values */
- 
-@@ -2946,11 +2810,11 @@
-     U8                                  AttachedPhyIdentifier;  /* 16h */
-     U8                                  Reserved2;              /* 17h */
-     U32                                 AttachedDeviceInfo;     /* 18h */
--    U8                                  ProgrammedLinkRate;     /* 1Ch */
--    U8                                  HwLinkRate;             /* 1Dh */
--    U8                                  ChangeCount;            /* 1Eh */
--    U8                                  Flags;                  /* 1Fh */
--    U32                                 PhyInfo;                /* 20h */
-+    U8                                  ProgrammedLinkRate;     /* 20h */
-+    U8                                  HwLinkRate;             /* 21h */
-+    U8                                  ChangeCount;            /* 22h */
-+    U8                                  Flags;                  /* 23h */
-+    U32                                 PhyInfo;                /* 24h */
- } CONFIG_PAGE_SAS_PHY_0, MPI_POINTER PTR_CONFIG_PAGE_SAS_PHY_0,
-   SasPhyPage0_t, MPI_POINTER pSasPhyPage0_t;
- 
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi.h	2009-05-11 23:24:42.000000000 -0600
-@@ -1,12 +1,12 @@
- /*
-- *  Copyright (c) 2000-2007 LSI Logic Corporation.
-+ *  Copyright (c) 2000-2005 LSI Logic Corporation.
-  *
-  *
-  *           Name:  mpi.h
-  *          Title:  MPI Message independent structures and definitions
-  *  Creation Date:  July 27, 2000
-  *
-- *    mpi.h Version:  01.05.14
-+ *    mpi.h Version:  01.05.11
-  *
-  *  Version History
-  *  ---------------
-@@ -77,9 +77,6 @@
-  *  08-03-05  01.05.09  Bumped MPI_HEADER_VERSION_UNIT.
-  *  08-30-05  01.05.10  Added 2 new IOCStatus codes for Target.
-  *  03-27-06  01.05.11  Bumped MPI_HEADER_VERSION_UNIT.
-- *  10-11-06  01.05.12  Bumped MPI_HEADER_VERSION_UNIT.
-- *  05-24-07  01.05.13  Bumped MPI_HEADER_VERSION_UNIT.
-- *  08-07-07  01.05.14  Bumped MPI_HEADER_VERSION_UNIT.
-  *  --------------------------------------------------------------------------
-  */
- 
-@@ -110,7 +107,7 @@
- /* Note: The major versions of 0xe0 through 0xff are reserved */
- 
- /* versioning for this MPI header set */
--#define MPI_HEADER_VERSION_UNIT             (0x11)
-+#define MPI_HEADER_VERSION_UNIT             (0x0D)
- #define MPI_HEADER_VERSION_DEV              (0x00)
- #define MPI_HEADER_VERSION_UNIT_MASK        (0xFF00)
- #define MPI_HEADER_VERSION_UNIT_SHIFT       (8)
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_history.txt
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_history.txt	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_history.txt	2009-05-11 23:24:42.000000000 -0600
-@@ -0,0 +1,735 @@
-+
-+ ==============================
-+ MPI Header File Change History
-+ ==============================
-+
-+ Copyright (c) 2000-2005 LSI Logic Corporation.
-+
-+ ---------------------------------------
-+ Header Set Release Version:    01.05.12
-+ Header Set Release Date:       08-30-05
-+ ---------------------------------------
-+
-+ Filename               Current version     Prior version
-+ ----------             ---------------     -------------
-+ mpi.h                  01.05.10            01.05.09
-+ mpi_ioc.h              01.05.10            01.05.09
-+ mpi_cnfg.h             01.05.11            01.05.10
-+ mpi_init.h             01.05.06            01.05.06
-+ mpi_targ.h             01.05.05            01.05.05
-+ mpi_fc.h               01.05.01            01.05.01
-+ mpi_lan.h              01.05.01            01.05.01
-+ mpi_raid.h             01.05.02            01.05.02
-+ mpi_tool.h             01.05.03            01.05.03
-+ mpi_inb.h              01.05.01            01.05.01
-+ mpi_sas.h              01.05.02            01.05.01
-+ mpi_type.h             01.05.02            01.05.01
-+ mpi_history.txt        01.05.12            01.05.11
-+
-+
-+ *  Date      Version   Description
-+ *  --------  --------  ------------------------------------------------------
-+
-+mpi.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  05-24-00  00.10.02  Added MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH definition.
-+ *  06-06-00  01.00.01  Update MPI_VERSION_MAJOR and MPI_VERSION_MINOR.
-+ *  06-22-00  01.00.02  Added MPI_IOCSTATUS_LAN_ definitions.
-+ *                      Removed LAN_SUSPEND function definition.
-+ *                      Added MPI_MSGFLAGS_CONTINUATION_REPLY definition.
-+ *  06-30-00  01.00.03  Added MPI_CONTEXT_REPLY_TYPE_LAN definition.
-+ *                      Added MPI_GET/SET_CONTEXT_REPLY_TYPE macros.
-+ *  07-27-00  01.00.04  Added MPI_FAULT_ definitions.
-+ *                      Removed MPI_IOCSTATUS_MSG/DATA_XFER_ERROR definitions.
-+ *                      Added MPI_IOCSTATUS_INTERNAL_ERROR definition.
-+ *                      Added MPI_IOCSTATUS_TARGET_XFER_COUNT_MISMATCH.
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *  12-04-00  01.01.02  Added new function codes.
-+ *  01-09-01  01.01.03  Added more definitions to the system interface section
-+ *                      Added MPI_IOCSTATUS_TARGET_STS_DATA_NOT_SENT.
-+ *  01-25-01  01.01.04  Changed MPI_VERSION_MINOR from 0x00 to 0x01.
-+ *  02-20-01  01.01.05  Started using MPI_POINTER.
-+ *                      Added defines for MPI_DIAG_PREVENT_IOC_BOOT and
-+ *                      MPI_DIAG_CLEAR_FLASH_BAD_SIG.
-+ *                      Obsoleted MPI_IOCSTATUS_TARGET_FC_ defines.
-+ *  02-27-01  01.01.06  Removed MPI_HOST_INDEX_REGISTER define.
-+ *                      Added function codes for RAID.
-+ *  04-09-01  01.01.07  Added alternate define for MPI_DOORBELL_ACTIVE,
-+ *                      MPI_DOORBELL_USED, to better match the spec.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *                      Changed MPI_VERSION_MINOR from 0x01 to 0x02.
-+ *                      Added define MPI_FUNCTION_TOOLBOX.
-+ *  09-28-01  01.02.02  New function code MPI_SCSI_ENCLOSURE_PROCESSOR.
-+ *  11-01-01  01.02.03  Changed name to MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR.
-+ *  03-14-02  01.02.04  Added MPI_HEADER_VERSION_ defines.
-+ *  05-31-02  01.02.05  Bumped MPI_HEADER_VERSION_UNIT.
-+ *  07-12-02  01.02.06  Added define for MPI_FUNCTION_MAILBOX.
-+ *  09-16-02  01.02.07  Bumped value for MPI_HEADER_VERSION_UNIT.
-+ *  11-15-02  01.02.08  Added define MPI_IOCSTATUS_TARGET_INVALID_IO_INDEX and
-+ *                      obsoleted define MPI_IOCSTATUS_TARGET_INVALID_IOCINDEX.
-+ *  04-01-03  01.02.09  New IOCStatus code: MPI_IOCSTATUS_FC_EXCHANGE_CANCELED
-+ *  06-26-03  01.02.10  Bumped MPI_HEADER_VERSION_UNIT value.
-+ *  01-16-04  01.02.11  Added define for MPI_IOCLOGINFO_TYPE_SHIFT.
-+ *  04-29-04  01.02.12  Added function codes for MPI_FUNCTION_DIAG_BUFFER_POST
-+ *                      and MPI_FUNCTION_DIAG_RELEASE.
-+ *                      Added MPI_IOCSTATUS_DIAGNOSTIC_RELEASED define.
-+ *                      Bumped MPI_HEADER_VERSION_UNIT value.
-+ *  05-11-04  01.03.01  Bumped MPI_VERSION_MINOR for MPI v1.3.
-+ *                      Added codes for Inband.
-+ *  08-19-04  01.05.01  Added defines for Host Buffer Access Control doorbell.
-+ *                      Added define for offset of High Priority Request Queue.
-+ *                      Added new function codes and new IOCStatus codes.
-+ *                      Added a IOCLogInfo type of SAS.
-+ *  12-07-04  01.05.02  Bumped MPI_HEADER_VERSION_UNIT.
-+ *  12-09-04  01.05.03  Bumped MPI_HEADER_VERSION_UNIT.
-+ *  01-15-05  01.05.04  Bumped MPI_HEADER_VERSION_UNIT.
-+ *  02-09-05  01.05.05  Bumped MPI_HEADER_VERSION_UNIT.
-+ *  02-22-05  01.05.06  Bumped MPI_HEADER_VERSION_UNIT.
-+ *  03-11-05  01.05.07  Removed function codes for SCSI IO 32 and
-+ *                      TargetAssistExtended requests.
-+ *                      Removed EEDP IOCStatus codes.
-+ *  06-24-05  01.05.08  Added function codes for SCSI IO 32 and
-+ *                      TargetAssistExtended requests.
-+ *                      Added EEDP IOCStatus codes.
-+ *  08-03-05  01.05.09  Bumped MPI_HEADER_VERSION_UNIT.
-+ *  08-30-05  01.05.10  Added 2 new IOCStatus codes for Target.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_ioc.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  05-24-00  00.10.02  Added _MSG_IOC_INIT_REPLY structure.
-+ *  06-06-00  01.00.01  Added CurReplyFrameSize field to _MSG_IOC_FACTS_REPLY.
-+ *  06-12-00  01.00.02  Added _MSG_PORT_ENABLE_REPLY structure.
-+ *                      Added _MSG_EVENT_ACK_REPLY structure.
-+ *                      Added _MSG_FW_DOWNLOAD_REPLY structure.
-+ *                      Added _MSG_TOOLBOX_REPLY structure.
-+ *  06-30-00  01.00.03  Added MaxLanBuckets to _PORT_FACT_REPLY structure.
-+ *  07-27-00  01.00.04  Added _EVENT_DATA structure definitions for _SCSI,
-+ *                      _LINK_STATUS, _LOOP_STATE and _LOGOUT.
-+ *  08-11-00  01.00.05  Switched positions of MsgLength and Function fields in
-+ *                      _MSG_EVENT_ACK_REPLY structure to match specification.
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *                      Added a value for Manufacturer to WhoInit
-+ *  12-04-00  01.01.02  Modified IOCFacts reply, added FWUpload messages, and
-+ *                      removed toolbox message.
-+ *  01-09-01  01.01.03  Added event enabled and disabled defines.
-+ *                      Added structures for FwHeader and DataHeader.
-+ *                      Added ImageType to FwUpload reply.
-+ *  02-20-01  01.01.04  Started using MPI_POINTER.
-+ *  02-27-01  01.01.05  Added event for RAID status change and its event data.
-+ *                      Added IocNumber field to MSG_IOC_FACTS_REPLY.
-+ *  03-27-01  01.01.06  Added defines for ProductId field of MPI_FW_HEADER.
-+ *                      Added structure offset comments.
-+ *  04-09-01  01.01.07  Added structure EVENT_DATA_EVENT_CHANGE.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *                      New format for FWVersion and ProductId in
-+ *                      MSG_IOC_FACTS_REPLY and MPI_FW_HEADER.
-+ *  08-31-01  01.02.02  Addded event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and
-+ *                      related structure and defines.
-+ *                      Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED.
-+ *                      Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE.
-+ *                      Replaced a reserved field in MSG_IOC_FACTS_REPLY with
-+ *                      IOCExceptions and changed DataImageSize to reserved.
-+ *                      Added MPI_FW_DOWNLOAD_ITYPE_NVSTORE_DATA and
-+ *                      MPI_FW_UPLOAD_ITYPE_NVDATA.
-+ *  09-28-01  01.02.03  Modified Event Data for Integrated RAID.
-+ *  11-01-01  01.02.04  Added defines for MPI_EXT_IMAGE_HEADER ImageType field.
-+ *  03-14-02  01.02.05  Added HeaderVersion field to MSG_IOC_FACTS_REPLY.
-+ *  05-31-02  01.02.06  Added define for
-+ *                      MPI_IOCFACTS_EXCEPT_RAID_CONFIG_INVALID.
-+ *                      Added AliasIndex to EVENT_DATA_LOGOUT structure.
-+ *  04-01-03  01.02.07  Added defines for MPI_FW_HEADER_SIGNATURE_.
-+ *  06-26-03  01.02.08  Added new values to the product family defines.
-+ *  04-29-04  01.02.09  Added IOCCapabilities field to MSG_IOC_FACTS_REPLY and
-+ *                      added related defines.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Added four new fields to MSG_IOC_INIT.
-+ *                      Added three new fields to MSG_IOC_FACTS_REPLY.
-+ *                      Defined four new bits for the IOCCapabilities field of
-+ *                      the IOCFacts reply.
-+ *                      Added two new PortTypes for the PortFacts reply.
-+ *                      Added six new events along with their EventData
-+ *                      structures.
-+ *                      Added a new MsgFlag to the FwDownload request to
-+ *                      indicate last segment.
-+ *                      Defined a new image type of boot loader.
-+ *                      Added FW family codes for SAS product families.
-+ *  10-05-04  01.05.02  Added ReplyFifoHostSignalingAddr field to
-+ *                      MSG_IOC_FACTS_REPLY.
-+ *  12-07-04  01.05.03  Added more defines for SAS Discovery Error event.
-+ *  12-09-04  01.05.04  Added Unsupported device to SAS Device event.
-+ *  01-15-05  01.05.05  Added event data for SAS SES Event.
-+ *  02-09-05  01.05.06  Added MPI_FW_UPLOAD_ITYPE_FW_BACKUP define.
-+ *  02-22-05  01.05.07  Added Host Page Buffer Persistent flag to IOC Facts
-+ *                      Reply and IOC Init Request.
-+ *  03-11-05  01.05.08  Added family code for 1068E family.
-+ *                      Removed IOCFacts Reply EEDP Capability bit.
-+ *  06-24-05  01.05.09  Added 5 new IOCFacts Reply IOCCapabilities bits.
-+ *                      Added Max SATA Targets to SAS Discovery Error event.
-+ *  08-30-05  01.05.10  Added 4 new events and their event data structures.
-+ *                      Added new ReasonCode value for SAS Device Status Change
-+ *                      event.
-+ *                      Added new family code for FC949E.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_cnfg.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  06-06-00  01.00.01  Update version number for 1.0 release.
-+ *  06-08-00  01.00.02  Added _PAGEVERSION definitions for all pages.
-+ *                      Added FcPhLowestVersion, FcPhHighestVersion, Reserved2
-+ *                      fields to FC_DEVICE_0 page, updated the page version.
-+ *                      Changed _FREE_RUNNING_CLOCK to _PACING_TRANSFERS in
-+ *                      SCSI_PORT_0, SCSI_DEVICE_0 and SCSI_DEVICE_1 pages
-+ *                      and updated the page versions.
-+ *                      Added _RESPONSE_ID_MASK definition to SCSI_PORT_1
-+ *                      page and updated the page version.
-+ *                      Added Information field and _INFO_PARAMS_NEGOTIATED
-+ *                      definitionto SCSI_DEVICE_0 page.
-+ *  06-22-00  01.00.03  Removed batch controls from LAN_0 page and updated the
-+ *                      page version.
-+ *                      Added BucketsRemaining to LAN_1 page, redefined the
-+ *                      state values, and updated the page version.
-+ *                      Revised bus width definitions in SCSI_PORT_0,
-+ *                      SCSI_DEVICE_0 and SCSI_DEVICE_1 pages.
-+ *  06-30-00  01.00.04  Added MaxReplySize to LAN_1 page and updated the page
-+ *                      version.
-+ *                      Moved FC_DEVICE_0 PageAddress description to spec.
-+ *  07-27-00  01.00.05  Corrected the SubsystemVendorID and SubsystemID field
-+ *                      widths in IOC_0 page and updated the page version.
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *                      Added Manufacturing pages, IO Unit Page 2, SCSI SPI
-+ *                      Port Page 2, FC Port Page 4, FC Port Page 5
-+ *  12-04-00  01.01.03  Config page changes to match MPI rev 1.00.01.
-+ *  12-05-00  01.01.04  Modified config page actions.
-+ *  01-09-01  01.01.05  Added defines for page address formats.
-+ *                      Data size for Manufacturing pages 2 and 3 no longer
-+ *                      defined here.
-+ *                      Io Unit Page 2 size is fixed at 4 adapters and some
-+ *                      flags were changed.
-+ *                      SCSI Port Page 2 Device Settings modified.
-+ *                      New fields added to FC Port Page 0 and some flags
-+ *                      cleaned up.
-+ *                      Removed impedance flash from FC Port Page 1.
-+ *                      Added FC Port pages 6 and 7.
-+ *  01-25-01  01.01.06  Added MaxInitiators field to FcPortPage0.
-+ *  01-29-01  01.01.07  Changed some defines to make them 32 character unique.
-+ *                      Added some LinkType defines for FcPortPage0.
-+ *  02-20-01  01.01.08  Started using MPI_POINTER.
-+ *  02-27-01  01.01.09  Replaced MPI_CONFIG_PAGETYPE_SCSI_LUN with
-+ *                      MPI_CONFIG_PAGETYPE_RAID_VOLUME.
-+ *                      Added definitions and structures for IOC Page 2 and
-+ *                      RAID Volume Page 2.
-+ *  03-27-01  01.01.10  Added CONFIG_PAGE_FC_PORT_8 and CONFIG_PAGE_FC_PORT_9.
-+ *                      CONFIG_PAGE_FC_PORT_3 now supports persistent by DID.
-+ *                      Added VendorId and ProductRevLevel fields to
-+ *                      RAIDVOL2_IM_PHYS_ID struct.
-+ *                      Modified values for MPI_FCPORTPAGE0_FLAGS_ATTACH_
-+ *                      defines to make them compatible to MPI version 1.0.
-+ *                      Added structure offset comments.
-+ *  04-09-01  01.01.11  Added some new defines for the PageAddress field and
-+ *                      removed some obsolete ones.
-+ *                      Added IO Unit Page 3.
-+ *                      Modified defines for Scsi Port Page 2.
-+ *                      Modified RAID Volume Pages.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *                      Added SepID and SepBus to RVP2 IMPhysicalDisk struct.
-+ *                      Added defines for the SEP bits in RVP2 VolumeSettings.
-+ *                      Modified the DeviceSettings field in RVP2 to use the
-+ *                      proper structure.
-+ *                      Added defines for SES, SAF-TE, and cross channel for
-+ *                      IOCPage2 CapabilitiesFlags.
-+ *                      Removed define for MPI_IOUNITPAGE2_FLAGS_RAID_DISABLE.
-+ *                      Removed define for
-+ *                      MPI_SCSIPORTPAGE2_PORT_FLAGS_PARITY_ENABLE.
-+ *                      Added define for MPI_CONFIG_PAGEATTR_RO_PERSISTENT.
-+ *  08-29-01 01.02.02   Fixed value for MPI_MANUFACTPAGE_DEVID_53C1035.
-+ *                      Added defines for MPI_FCPORTPAGE1_FLAGS_HARD_ALPA_ONLY
-+ *                      and MPI_FCPORTPAGE1_FLAGS_IMMEDIATE_ERROR_REPLY.
-+ *                      Removed MPI_SCSIPORTPAGE0_CAP_PACING_TRANSFERS,
-+ *                      MPI_SCSIDEVPAGE0_NP_PACING_TRANSFERS, and
-+ *                      MPI_SCSIDEVPAGE1_RP_PACING_TRANSFERS, and
-+ *                      MPI_SCSIDEVPAGE1_CONF_PPR_ALLOWED.
-+ *                      Added defines for MPI_SCSIDEVPAGE1_CONF_WDTR_DISALLOWED
-+ *                      and MPI_SCSIDEVPAGE1_CONF_SDTR_DISALLOWED.
-+ *                      Added OnBusTimerValue to CONFIG_PAGE_SCSI_PORT_1.
-+ *                      Added rejected bits to SCSI Device Page 0 Information.
-+ *                      Increased size of ALPA array in FC Port Page 2 by one
-+ *                      and removed a one byte reserved field.
-+ *  09-28-01 01.02.03   Swapped NegWireSpeedLow and NegWireSpeedLow in
-+ *                      CONFIG_PAGE_LAN_1 to match preferred 64-bit ordering.
-+ *                      Added structures for Manufacturing Page 4, IO Unit
-+ *                      Page 3, IOC Page 3, IOC Page 4, RAID Volume Page 0, and
-+ *                      RAID PhysDisk Page 0.
-+ *  10-04-01 01.02.04   Added define for MPI_CONFIG_PAGETYPE_RAID_PHYSDISK.
-+ *                      Modified some of the new defines to make them 32
-+ *                      character unique.
-+ *                      Modified how variable length pages (arrays) are defined.
-+ *                      Added generic defines for hot spare pools and RAID
-+ *                      volume types.
-+ *  11-01-01 01.02.05   Added define for MPI_IOUNITPAGE1_DISABLE_IR.
-+ *  03-14-02 01.02.06   Added PCISlotNum field to CONFIG_PAGE_IOC_1 along with
-+ *                      related define, and bumped the page version define.
-+ *  05-31-02 01.02.07   Added a Flags field to CONFIG_PAGE_IOC_2_RAID_VOL in a
-+ *                      reserved byte and added a define.
-+ *                      Added define for
-+ *                      MPI_RAIDVOL0_STATUS_FLAG_VOLUME_INACTIVE.
-+ *                      Added new config page: CONFIG_PAGE_IOC_5.
-+ *                      Added MaxAliases, MaxHardAliases, and NumCurrentAliases
-+ *                      fields to CONFIG_PAGE_FC_PORT_0.
-+ *                      Added AltConnector and NumRequestedAliases fields to
-+ *                      CONFIG_PAGE_FC_PORT_1.
-+ *                      Added new config page: CONFIG_PAGE_FC_PORT_10.
-+ *  07-12-02 01.02.08   Added more MPI_MANUFACTPAGE_DEVID_ defines.
-+ *                      Added additional MPI_SCSIDEVPAGE0_NP_ defines.
-+ *                      Added more MPI_SCSIDEVPAGE1_RP_ defines.
-+ *                      Added define for
-+ *                      MPI_SCSIDEVPAGE1_CONF_EXTENDED_PARAMS_ENABLE.
-+ *                      Added new config page: CONFIG_PAGE_SCSI_DEVICE_3.
-+ *                      Modified MPI_FCPORTPAGE5_FLAGS_ defines.
-+ *  09-16-02 01.02.09   Added MPI_SCSIDEVPAGE1_CONF_FORCE_PPR_MSG define.
-+ *  11-15-02 01.02.10   Added ConnectedID defines for CONFIG_PAGE_SCSI_PORT_0.
-+ *                      Added more Flags defines for CONFIG_PAGE_FC_PORT_1.
-+ *                      Added more Flags defines for CONFIG_PAGE_FC_DEVICE_0.
-+ *  04-01-03 01.02.11   Added RR_TOV field and additional Flags defines for
-+ *                      CONFIG_PAGE_FC_PORT_1.
-+ *                      Added define MPI_FCPORTPAGE5_FLAGS_DISABLE to disable
-+ *                      an alias.
-+ *                      Added more device id defines.
-+ *  06-26-03 01.02.12   Added MPI_IOUNITPAGE1_IR_USE_STATIC_VOLUME_ID define.
-+ *                      Added TargetConfig and IDConfig fields to
-+ *                      CONFIG_PAGE_SCSI_PORT_1.
-+ *                      Added more PortFlags defines for CONFIG_PAGE_SCSI_PORT_2
-+ *                      to control DV.
-+ *                      Added more Flags defines for CONFIG_PAGE_FC_PORT_1.
-+ *                      In CONFIG_PAGE_FC_DEVICE_0, replaced Reserved1 field
-+ *                      with ADISCHardALPA.
-+ *                      Added MPI_FC_DEVICE_PAGE0_PROT_FCP_RETRY define.
-+ *  01-16-04  01.02.13  Added InitiatorDeviceTimeout and InitiatorIoPendTimeout
-+ *                      fields and related defines to CONFIG_PAGE_FC_PORT_1.
-+ *                      Added define for
-+ *                      MPI_FCPORTPAGE1_FLAGS_SOFT_ALPA_FALLBACK.
-+ *                      Added new fields to the substructures of
-+ *                      CONFIG_PAGE_FC_PORT_10.
-+ *  04-29-04 01.02.14   Added define for IDP bit for CONFIG_PAGE_SCSI_PORT_0,
-+ *                      CONFIG_PAGE_SCSI_DEVICE_0, and
-+ *                      CONFIG_PAGE_SCSI_DEVICE_1. Also bumped Page Version for
-+ *                      these pages.
-+ *  05-11-04 01.03.01   Added structure for CONFIG_PAGE_INBAND_0.
-+ *  08-19-04 01.05.01   Modified MSG_CONFIG request to support extended config
-+ *                      pages.
-+ *                      Added a new structure for extended config page header.
-+ *                      Added new extended config pages types and structures for
-+ *                      SAS IO Unit, SAS Expander, SAS Device, and SAS PHY.
-+ *                      Replaced a reserved byte in CONFIG_PAGE_MANUFACTURING_4
-+ *                      to add a Flags field.
-+ *                      Two new Manufacturing config pages (5 and 6).
-+ *                      Two new bits defined for IO Unit Page 1 Flags field.
-+ *                      Modified CONFIG_PAGE_IO_UNIT_2 to add three new fields
-+ *                      to specify the BIOS boot device.
-+ *                      Four new Flags bits defined for IO Unit Page 2.
-+ *                      Added IO Unit Page 4.
-+ *                      Added EEDP Flags settings to IOC Page 1.
-+ *                      Added new BIOS Page 1 config page.
-+ *  10-05-04 01.05.02   Added define for
-+ *                      MPI_IOCPAGE1_INITIATOR_CONTEXT_REPLY_DISABLE.
-+ *                      Added new Flags field to CONFIG_PAGE_MANUFACTURING_5 and
-+ *                      associated defines.
-+ *                      Added more defines for SAS IO Unit Page 0
-+ *                      DiscoveryStatus field.
-+ *                      Added define for MPI_SAS_IOUNIT0_DS_SUBTRACTIVE_LINK
-+ *                      and MPI_SAS_IOUNIT0_DS_TABLE_LINK.
-+ *                      Added defines for Physical Mapping Modes to SAS IO Unit
-+ *                      Page 2.
-+ *                      Added define for
-+ *                      MPI_SAS_DEVICE0_FLAGS_PORT_SELECTOR_ATTACH.
-+ *  10-27-04 01.05.03   Added defines for new SAS PHY page addressing mode.
-+ *                      Added defines for MaxTargetSpinUp to BIOS Page 1.
-+ *                      Added 5 new ControlFlags defines for SAS IO Unit
-+ *                      Page 1.
-+ *                      Added MaxNumPhysicalMappedIDs field to SAS IO Unit
-+ *                      Page 2.
-+ *                      Added AccessStatus field to SAS Device Page 0 and added
-+ *                      new Flags bits for supported SATA features.
-+ *  12-07-04  01.05.04  Added config page structures for BIOS Page 2, RAID
-+ *                      Volume Page 1, and RAID Physical Disk Page 1.
-+ *                      Replaced IO Unit Page 1 BootTargetID,BootBus, and
-+ *                      BootAdapterNum with reserved field.
-+ *                      Added DataScrubRate and ResyncRate to RAID Volume
-+ *                      Page 0.
-+ *                      Added MPI_SAS_IOUNIT2_FLAGS_RESERVE_ID_0_FOR_BOOT
-+ *                      define.
-+ *  12-09-04  01.05.05  Added Target Mode Large CDB Enable to FC Port Page 1
-+ *                      Flags field.
-+ *                      Added Auto Port Config flag define for SAS IOUNIT
-+ *                      Page 1 ControlFlags.
-+ *                      Added Disabled bad Phy define to Expander Page 1
-+ *                      Discovery Info field.
-+ *                      Added SAS/SATA device support to SAS IOUnit Page 1
-+ *                      ControlFlags.
-+ *                      Added Unsupported device to SAS Dev Page 0 Flags field
-+ *                      Added disable use SATA Hash Address for SAS IOUNIT
-+ *                      page 1 in ControlFields.
-+ *  01-15-05  01.05.06  Added defaults for data scrub rate and resync rate to
-+ *                      Manufacturing Page 4.
-+ *                      Added new defines for BIOS Page 1 IOCSettings field.
-+ *                      Added ExtDiskIdentifier field to RAID Physical Disk
-+ *                      Page 0.
-+ *                      Added new defines for SAS IO Unit Page 1 ControlFlags
-+ *                      and to SAS Device Page 0 Flags to control SATA devices.
-+ *                      Added defines and structures for the new Log Page 0, a
-+ *                      new type of configuration page.
-+ *  02-09-05  01.05.07  Added InactiveStatus field to RAID Volume Page 0.
-+ *                      Added WWID field to RAID Volume Page 1.
-+ *                      Added PhysicalPort field to SAS Expander pages 0 and 1.
-+ *  03-11-05  01.05.08  Removed the EEDP flags from IOC Page 1.
-+ *                      Added Enclosure/Slot boot device format to BIOS Page 2.
-+ *                      New status value for RAID Volume Page 0 VolumeStatus
-+ *                      (VolumeState subfield).
-+ *                      New value for RAID Physical Page 0 InactiveStatus.
-+ *                      Added Inactive Volume Member flag RAID Physical Disk
-+ *                      Page 0 PhysDiskStatus field.
-+ *                      New physical mapping mode in SAS IO Unit Page 2.
-+ *                      Added CONFIG_PAGE_SAS_ENCLOSURE_0.
-+ *                      Added Slot and Enclosure fields to SAS Device Page 0.
-+ *  06-24-05  01.05.09  Added EEDP defines to IOC Page 1.
-+ *                      Added more RAID type defines to IOC Page 2.
-+ *                      Added Port Enable Delay settings to BIOS Page 1.
-+ *                      Added Bad Block Table Full define to RAID Volume Page 0.
-+ *                      Added Previous State defines to RAID Physical Disk
-+ *                      Page 0.
-+ *                      Added Max Sata Targets define for DiscoveryStatus field
-+ *                      of SAS IO Unit Page 0.
-+ *                      Added Device Self Test to Control Flags of SAS IO Unit
-+ *                      Page 1.
-+ *                      Added Direct Attach Starting Slot Number define for SAS
-+ *                      IO Unit Page 2.
-+ *                      Added new fields in SAS Device Page 2 for enclosure
-+ *                      mapping.
-+ *                      Added OwnerDevHandle and Flags field to SAS PHY Page 0.
-+ *                      Added IOC GPIO Flags define to SAS Enclosure Page 0.
-+ *                      Fixed the value for MPI_SAS_IOUNIT1_CONTROL_DEV_SATA_SUPPORT.
-+ *  08-03-05  01.05.10  Removed ISDataScrubRate and ISResyncRate from
-+ *                      Manufacturing Page 4.
-+ *                      Added MPI_IOUNITPAGE1_SATA_WRITE_CACHE_DISABLE bit.
-+ *                      Added NumDevsPerEnclosure field to SAS IO Unit page 2.
-+ *                      Added MPI_SAS_IOUNIT2_FLAGS_HOST_ASSIGNED_PHYS_MAP
-+ *                      define.
-+ *                      Added EnclosureHandle field to SAS Expander page 0.
-+ *                      Removed redundant NumTableEntriesProg field from SAS
-+ *                      Expander Page 1.
-+ *  08-30-05  01.05.11  Added DeviceID for FC949E and changed the DeviceID for
-+ *                      SAS1078.
-+ *                      Added more defines for Manufacturing Page 4 Flags field.
-+ *                      Added more defines for IOCSettings and added
-+ *                      ExpanderSpinup field to Bios Page 1.
-+ *                      Added postpone SATA Init bit to SAS IO Unit Page 1
-+ *                      ControlFlags.
-+ *                      Changed LogEntry format for Log Page 0.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_init.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  05-24-00  00.10.02  Added SenseBufferLength to _MSG_SCSI_IO_REPLY.
-+ *  06-06-00  01.00.01  Update version number for 1.0 release.
-+ *  06-08-00  01.00.02  Added MPI_SCSI_RSP_INFO_ definitions.
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *  12-04-00  01.01.02  Added MPI_SCSIIO_CONTROL_NO_DISCONNECT.
-+ *  02-20-01  01.01.03  Started using MPI_POINTER.
-+ *  03-27-01  01.01.04  Added structure offset comments.
-+ *  04-10-01  01.01.05  Added new MsgFlag for MSG_SCSI_TASK_MGMT.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *  08-29-01  01.02.02  Added MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET.
-+ *                      Added MPI_SCSI_STATE_QUEUE_TAG_REJECTED for
-+ *                      MSG_SCSI_IO_REPLY.
-+ *  09-28-01  01.02.03  Added structures and defines for SCSI Enclosure
-+ *                      Processor messages.
-+ *  10-04-01  01.02.04  Added defines for SEP request Action field.
-+ *  05-31-02  01.02.05  Added MPI_SCSIIO_MSGFLGS_CMD_DETERMINES_DATA_DIR define
-+ *                      for SCSI IO requests.
-+ *  11-15-02  01.02.06  Added special extended SCSI Status defines for FCP.
-+ *  06-26-03  01.02.07  Added MPI_SCSI_STATUS_FCPEXT_UNASSIGNED define.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Added MsgFlags defines for EEDP to SCSI IO request.
-+ *                      Added new word to MSG_SCSI_IO_REPLY to add TaskTag field
-+ *                      and a reserved U16.
-+ *                      Added new MSG_SCSI_IO32_REQUEST structure.
-+ *                      Added a TaskType of Clear Task Set to SCSI
-+ *                      Task Management request.
-+ *  12-07-04  01.05.02  Added support for Task Management Query Task.
-+ *  01-15-05  01.05.03  Modified SCSI Enclosure Processor Request to support
-+ *                      WWID addressing.
-+ *  03-11-05  01.05.04  Removed EEDP flags from SCSI IO Request.
-+ *                      Removed SCSI IO 32 Request.
-+ *                      Modified SCSI Enclosure Processor Request and Reply to
-+ *                      support Enclosure/Slot addressing rather than WWID
-+ *                      addressing.
-+ *  06-24-05  01.05.05  Added SCSI IO 32 structures and defines.
-+ *                      Added four new defines for SEP SlotStatus.
-+ *  08-03-05  01.05.06  Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them
-+ *                      unique in the first 32 characters.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_targ.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  06-06-00  01.00.01  Update version number for 1.0 release.
-+ *  06-22-00  01.00.02  Added _MSG_TARGET_CMD_BUFFER_POST_REPLY structure.
-+ *                      Corrected DECSRIPTOR typo to DESCRIPTOR.
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *                      Modified target mode to use IoIndex instead of
-+ *                      HostIndex and IocIndex. Added Alias.
-+ *  01-09-01  01.01.02  Added defines for TARGET_ASSIST_FLAGS_REPOST_CMD_BUFFER
-+ *                      and TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER.
-+ *  02-20-01  01.01.03  Started using MPI_POINTER.
-+ *                      Added structures for MPI_TARGET_SCSI_SPI_CMD_BUFFER and
-+ *                      MPI_TARGET_FCP_CMD_BUFFER.
-+ *  03-27-01  01.01.04  Added structure offset comments.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *  09-28-01  01.02.02  Added structure for MPI_TARGET_SCSI_SPI_STATUS_IU.
-+ *                      Added PriorityReason field to some replies and
-+ *                      defined more PriorityReason codes.
-+ *                      Added some defines for to support previous version
-+ *                      of MPI.
-+ *  10-04-01  01.02.03  Added PriorityReason to MSG_TARGET_ERROR_REPLY.
-+ *  11-01-01  01.02.04  Added define for TARGET_STATUS_SEND_FLAGS_HIGH_PRIORITY.
-+ *  03-14-02  01.02.05  Modified MPI_TARGET_FCP_RSP_BUFFER to get the proper
-+ *                      byte ordering.
-+ *  05-31-02  01.02.06  Modified TARGET_MODE_REPLY_ALIAS_MASK to only include
-+ *                      one bit.
-+ *                      Added AliasIndex field to MPI_TARGET_FCP_CMD_BUFFER.
-+ *  09-16-02  01.02.07  Added flags for confirmed completion.
-+ *                      Added PRIORITY_REASON_TARGET_BUSY.
-+ *  11-15-02  01.02.08  Added AliasID field to MPI_TARGET_SCSI_SPI_CMD_BUFFER.
-+ *  04-01-03  01.02.09  Added OptionalOxid field to MPI_TARGET_FCP_CMD_BUFFER.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Added new request message structures for
-+ *                      MSG_TARGET_CMD_BUF_POST_BASE_REQUEST,
-+ *                      MSG_TARGET_CMD_BUF_POST_LIST_REQUEST, and
-+ *                      MSG_TARGET_ASSIST_EXT_REQUEST.
-+ *                      Added new structures for SAS SSP Command buffer, SSP
-+ *                      Task buffer, and SSP Status IU.
-+ *  10-05-04  01.05.02  MSG_TARGET_CMD_BUFFER_POST_BASE_LIST_REPLY added.
-+ *  02-22-05  01.05.03  Changed a comment.
-+ *  03-11-05  01.05.04  Removed TargetAssistExtended Request.
-+ *  06-24-05  01.05.05  Added TargetAssistExtended structures and defines.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_fc.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  06-06-00  01.00.01  Update version number for 1.0 release.
-+ *  06-12-00  01.00.02  Added _MSG_FC_ABORT_REPLY structure.
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *  12-04-00  01.01.02  Added messages for Common Transport Send and
-+ *                      Primitive Send.
-+ *  01-09-01  01.01.03  Modifed some of the new flags to have an MPI prefix
-+ *                      and modified the FcPrimitiveSend flags.
-+ *  01-25-01  01.01.04  Move InitiatorIndex in LinkServiceRsp reply to a larger
-+ *                      field.
-+ *                      Added FC_ABORT_TYPE_CT_SEND_REQUEST and
-+ *                      FC_ABORT_TYPE_EXLINKSEND_REQUEST for FcAbort request.
-+ *                      Added MPI_FC_PRIM_SEND_FLAGS_STOP_SEND.
-+ *  02-20-01  01.01.05  Started using MPI_POINTER.
-+ *  03-27-01  01.01.06  Added Flags field to MSG_LINK_SERVICE_BUFFER_POST_REPLY
-+ *                      and defined MPI_LS_BUF_POST_REPLY_FLAG_NO_RSP_NEEDED.
-+ *                      Added MPI_FC_PRIM_SEND_FLAGS_RESET_LINK define.
-+ *                      Added structure offset comments.
-+ *  04-09-01  01.01.07  Added RspLength field to MSG_LINK_SERVICE_RSP_REQUEST.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *  09-28-01  01.02.02  Change name of reserved field in
-+ *                      MSG_LINK_SERVICE_RSP_REPLY.
-+ *  05-31-02  01.02.03  Adding AliasIndex to FC Direct Access requests.
-+ *  01-16-04  01.02.04  Added define for MPI_FC_PRIM_SEND_FLAGS_ML_RESET_LINK.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Original release for MPI v1.5.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_lan.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  05-24-00  00.10.02  Added LANStatus field to _MSG_LAN_SEND_REPLY.
-+ *                      Added LANStatus field to _MSG_LAN_RECEIVE_POST_REPLY.
-+ *                      Moved ListCount field in _MSG_LAN_RECEIVE_POST_REPLY.
-+ *  06-06-00  01.00.01  Update version number for 1.0 release.
-+ *  06-12-00  01.00.02  Added MPI_ to BUCKETSTATUS_ definitions.
-+ *  06-22-00  01.00.03  Major changes to match new LAN definition in 1.0 spec.
-+ *  06-30-00  01.00.04  Added Context Reply definitions per revised proposal.
-+ *                      Changed transaction context usage to bucket/buffer.
-+ *  07-05-00  01.00.05  Removed LAN_RECEIVE_POST_BUCKET_CONTEXT_MASK definition
-+ *                      to lan private header file
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *  02-20-01  01.01.02  Started using MPI_POINTER.
-+ *  03-27-01  01.01.03  Added structure offset comments.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Original release for MPI v1.5.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_raid.h
-+ *  02-27-01  01.01.01  Original release for this file.
-+ *  03-27-01  01.01.02  Added structure offset comments.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *  08-29-01  01.02.02  Added DIAG_DATA_UPLOAD_HEADER and related defines.
-+ *  09-28-01  01.02.02  Major rework for MPI v1.2 Integrated RAID changes.
-+ *  10-04-01  01.02.03  Added ActionData defines for
-+ *                      MPI_RAID_ACTION_DELETE_VOLUME action.
-+ *  11-01-01  01.02.04  Added define for MPI_RAID_ACTION_ADATA_DO_NOT_SYNC.
-+ *  03-14-02  01.02.05  Added define for MPI_RAID_ACTION_ADATA_LOW_LEVEL_INIT.
-+ *  05-07-02  01.02.06  Added define for MPI_RAID_ACTION_ACTIVATE_VOLUME,
-+ *                      MPI_RAID_ACTION_INACTIVATE_VOLUME, and
-+ *                      MPI_RAID_ACTION_ADATA_INACTIVATE_ALL.
-+ *  07-12-02  01.02.07  Added structures for Mailbox request and reply.
-+ *  11-15-02  01.02.08  Added missing MsgContext field to MSG_MAILBOX_REQUEST.
-+ *  04-01-03  01.02.09  New action data option flag for
-+ *                      MPI_RAID_ACTION_DELETE_VOLUME.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Original release for MPI v1.5.
-+ *  01-15-05  01.05.02  Added defines for the two new RAID Actions for
-+ *                      _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_tool.h
-+ *  08-08-01  01.02.01  Original release.
-+ *  08-29-01  01.02.02  Added DIAG_DATA_UPLOAD_HEADER and related defines.
-+ *  01-16-04  01.02.03  Added defines and structures for new tools
-+ *.                     MPI_TOOLBOX_ISTWI_READ_WRITE_TOOL and
-+ *                      MPI_TOOLBOX_FC_MANAGEMENT_TOOL.
-+ *  04-29-04  01.02.04  Added message structures for Diagnostic Buffer Post and
-+ *                      Diagnostic Release requests and replies.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Original release for MPI v1.5.
-+ *  10-06-04  01.05.02  Added define for MPI_DIAG_BUF_TYPE_COUNT.
-+ *  02-09-05  01.05.03  Added frame size option to FC management tool.
-+ *                      Added Beacon tool to the Toolbox.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_inb.h
-+ *  05-11-04  01.03.01  Original release.
-+ *  08-19-04  01.05.01  Original release for MPI v1.5.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_sas.h
-+ *  08-19-04  01.05.01  Original release.
-+ *  08-30-05  01.05.02  Added DeviceInfo bit for SEP.
-+ *                      Added PrimFlags and Primitive field to SAS IO Unit
-+ *                      Control request, and added a new operation code.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_type.h
-+ *  05-08-00  00.10.01  Original release for 0.10 spec dated 4/26/2000.
-+ *  06-06-00  01.00.01  Update version number for 1.0 release.
-+ *  11-02-00  01.01.01  Original release for post 1.0 work
-+ *  02-20-01  01.01.02  Added define and ifdef for MPI_POINTER.
-+ *  08-08-01  01.02.01  Original release for v1.2 work.
-+ *  05-11-04  01.03.01  Original release for MPI v1.3.
-+ *  08-19-04  01.05.01  Original release for MPI v1.5.
-+ *  08-30-05  01.05.02  Added PowerPC option to #ifdef's.
-+ *  --------------------------------------------------------------------------
-+
-+mpi_history.txt         Parts list history
-+
-+Filename    01.05.12  01.05.11  01.05.10  01.05.09
-+----------  --------  --------  --------  --------
-+mpi.h       01.05.10  01.05.09  01.05.08  01.05.07
-+mpi_ioc.h   01.05.10  01.05.09  01.05.09  01.05.08
-+mpi_cnfg.h  01.05.11  01.05.10  01.05.09  01.05.08
-+mpi_init.h  01.05.06  01.05.06  01.05.05  01.05.04
-+mpi_targ.h  01.05.05  01.05.05  01.05.05  01.05.04
-+mpi_fc.h    01.05.01  01.05.01  01.05.01  01.05.01
-+mpi_lan.h   01.05.01  01.05.01  01.05.01  01.05.01
-+mpi_raid.h  01.05.02  01.05.02  01.05.02  01.05.02
-+mpi_tool.h  01.05.03  01.05.03  01.05.03  01.05.03
-+mpi_inb.h   01.05.01  01.05.01  01.05.01  01.05.01
-+mpi_sas.h   01.05.02  01.05.01  01.05.01  01.05.01
-+mpi_type.h  01.05.02  01.05.01  01.05.01  01.05.01
-+
-+Filename    01.05.08   01.05.07   01.05.06   01.05.05   01.05.04   01.05.03
-+----------  --------   --------   --------   --------   --------   --------
-+mpi.h       01.05.06   01.05.05   01.05.04   01.05.03   01.05.02   01.05.01
-+mpi_ioc.h   01.05.07   01.05.06   01.05.05   01.05.04   01.05.03   01.05.02
-+mpi_cnfg.h  01.05.07   01.05.07   01.05.06   01.05.05   01.05.04   01.05.03
-+mpi_init.h  01.05.03   01.05.03   01.05.03   01.05.02   01.05.02   01.05.01
-+mpi_targ.h  01.05.03   01.05.02   01.05.02   01.05.02   01.05.02   01.05.02
-+mpi_fc.h    01.05.01   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01
-+mpi_lan.h   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01
-+mpi_raid.h  01.05.02   01.05.02   01.05.02   01.05.01   01.05.01   01.05.01
-+mpi_tool.h  01.05.03   01.05.03   01.05.02   01.05.02   01.05.02   01.05.02
-+mpi_inb.h   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01
-+mpi_sas.h   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01
-+mpi_type.h  01.05.01   01.05.01   01.05.01   01.05.01   01.05.01   01.05.01
-+
-+Filename    01.05.02   01.05.01   01.03.01   01.02.14   01.02.13   01.02.12
-+----------  --------   --------   --------   --------   --------   --------
-+mpi.h       01.05.01   01.05.01   01.03.01   01.02.12   01.02.11   01.02.10
-+mpi_ioc.h   01.05.02   01.05.01   01.03.01   01.02.09   01.02.08   01.02.08
-+mpi_cnfg.h  01.05.02   01.05.01   01.03.01   01.02.14   01.02.13   01.02.12
-+mpi_init.h  01.05.01   01.05.01   01.03.01   01.02.07   01.02.07   01.02.07
-+mpi_targ.h  01.05.02   01.05.01   01.03.01   01.02.09   01.02.09   01.02.09
-+mpi_fc.h    01.05.01   01.05.01   01.03.01   01.02.04   01.02.04   01.02.03
-+mpi_lan.h   01.05.01   01.05.01   01.03.01   01.02.01   01.02.01   01.02.01
-+mpi_raid.h  01.05.01   01.05.01   01.03.01   01.02.09   01.02.09   01.02.09
-+mpi_tool.h  01.05.02   01.05.01   01.03.01   01.02.01   01.02.01   01.02.01
-+mpi_inb.h   01.05.01   01.05.01   01.03.01
-+mpi_sas.h   01.05.01   01.05.01
-+mpi_type.h  01.05.01   01.05.01   01.03.01   01.02.04   01.02.03   01.02.02
-+
-+Filename    01.02.11   01.02.10   01.02.09   01.02.08   01.02.07   01.02.06
-+----------  --------   --------   --------   --------   --------   --------
-+mpi.h       01.02.09   01.02.08   01.02.07   01.02.06   01.02.05   01.02.04
-+mpi_ioc.h   01.02.07   01.02.06   01.02.06   01.02.06   01.02.06   01.02.05
-+mpi_cnfg.h  01.02.11   01.02.10   01.02.09   01.02.08   01.02.07   01.02.06
-+mpi_init.h  01.02.06   01.02.06   01.02.05   01.02.05   01.02.05   01.02.04
-+mpi_targ.h  01.02.09   01.02.08   01.02.07   01.02.06   01.02.06   01.02.05
-+mpi_fc.h    01.02.03   01.02.03   01.02.03   01.02.03   01.02.03   01.02.02
-+mpi_lan.h   01.02.01   01.02.01   01.02.01   01.02.01   01.02.01   01.02.01
-+mpi_raid.h  01.02.09   01.02.08   01.02.07   01.02.07   01.02.06   01.02.05
-+mpi_tool.h  01.02.01   01.02.01   01.02.01   01.02.01   01.02.01   01.02.01
-+mpi_type.h  01.02.02   01.02.02   01.02.02   01.02.02   01.02.02   01.02.02
-+
-+Filename    01.02.05   01.02.04   01.02.03   01.02.02   01.02.01   01.01.10
-+----------  --------   --------   --------   --------   --------   --------
-+mpi.h       01.02.03   01.02.02   01.02.02   01.02.01   01.02.01   01.01.07
-+mpi_ioc.h   01.02.04   01.02.03   01.02.03   01.02.02   01.02.01   01.01.07
-+mpi_cnfg.h  01.02.05   01.02.04   01.02.03   01.02.02   01.02.01   01.01.11
-+mpi_init.h  01.02.04   01.02.04   01.02.03   01.02.02   01.02.01   01.01.05
-+mpi_targ.h  01.02.04   01.02.03   01.02.02   01.02.01   01.02.01   01.01.04
-+mpi_fc.h    01.02.02   01.02.02   01.02.02   01.02.01   01.02.01   01.01.07
-+mpi_lan.h   01.02.01   01.02.01   01.02.01   01.02.01   01.02.01   01.01.03
-+mpi_raid.h  01.02.04   01.02.03   01.02.02   01.02.01   01.02.01   01.01.02
-+mpi_tool.h  01.02.02   01.02.02   01.02.02   01.02.02   01.02.01
-+mpi_type.h  01.02.02   01.02.02   01.02.02   01.02.02   01.02.01   01.01.02
-+
-+Filename    01.01.09   01.01.08   01.01.07   01.01.06   01.01.05   01.01.04
-+----------  --------   --------   --------   --------   --------   --------
-+mpi.h       01.01.06   01.01.06   01.01.05   01.01.04   01.01.04   01.01.03
-+mpi_ioc.h   01.01.06   01.01.05   01.01.04   01.01.03   01.01.03   01.01.03
-+mpi_cnfg.h  01.01.10   01.01.09   01.01.08   01.01.07   01.01.06   01.01.05
-+mpi_init.h  01.01.04   01.01.03   01.01.03   01.01.02   01.01.02   01.01.02
-+mpi_targ.h  01.01.04   01.01.03   01.01.03   01.01.02   01.01.02   01.01.02
-+mpi_fc.h    01.01.06   01.01.05   01.01.05   01.01.04   01.01.04   01.01.03
-+mpi_lan.h   01.01.03   01.01.02   01.01.02   01.01.01   01.01.01   01.01.01
-+mpi_raid.h  01.01.02   01.01.01
-+mpi_type.h  01.01.02   01.01.02   01.01.02   01.01.01   01.01.01   01.01.01
-+
-+Filename    01.01.03   01.01.02   01.01.01   01.00.07   01.00.06   01.00.05
-+----------  --------   --------   --------   --------   --------   --------
-+mpi.h       01.01.02   01.01.02   01.01.01   01.00.04   01.00.04   01.00.03
-+mpi_ioc.h   01.01.02   01.01.02   01.01.01   01.00.05   01.00.04   01.00.03
-+mpi_cnfg.h  01.01.04   01.01.03   01.01.01   01.00.05   01.00.05   01.00.04
-+mpi_init.h  01.01.02   01.01.02   01.01.01   01.00.02   01.00.02   01.00.02
-+mpi_targ.h  01.01.01   01.01.01   01.01.01   01.00.02   01.00.02   01.00.02
-+mpi_fc.h    01.01.02   01.01.02   01.01.01   01.00.02   01.00.02   01.00.02
-+mpi_lan.h   01.01.01   01.01.01   01.01.01   01.00.05   01.00.05   01.00.05
-+mpi_type.h  01.01.01   01.01.01   01.01.01   01.00.01   01.00.01   01.00.01
-+
-+Filename     01.00.04   01.00.03   01.00.02   01.00.01   00.10.02   00.10.01
-+----------   --------   --------   --------   --------   --------   --------
-+mpi.h        01.00.02   01.00.01   01.00.01   01.00.01   00.10.02   00.10.01
-+mpi_ioc.h    01.00.02   01.00.02   01.00.01   01.00.01   00.10.02   00.10.01
-+mpi_cnfg.h   01.00.03   01.00.02   01.00.02   01.00.01   00.10.01   00.10.01
-+mpi_init.h   01.00.02   01.00.02   01.00.02   01.00.01   00.10.02   00.10.01
-+mpi_targ.h   01.00.02   01.00.01   01.00.01   01.00.01   00.10.01   00.10.01
-+mpi_fc.h     01.00.02   01.00.02   01.00.01   01.00.01   00.10.01   00.10.01
-+mpi_lan.h    01.00.03   01.00.02   01.00.01   01.00.01   00.10.02   00.10.01
-+mpi_type.h   01.00.01   01.00.01   01.00.01   01.00.01   00.10.01   00.10.01
-+
-+
-+ *  --------------------------------------------------------------------------
-+
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_init.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_init.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_init.h	2009-05-11 23:24:42.000000000 -0600
-@@ -1,12 +1,12 @@
- /*
-- *  Copyright (c) 2000-2007 LSI Logic Corporation.
-+ *  Copyright (c) 2000-2005 LSI Logic Corporation.
-  *
-  *
-  *           Name:  mpi_init.h
-  *          Title:  MPI initiator mode messages and structures
-  *  Creation Date:  June 8, 2000
-  *
-- *    mpi_init.h Version:  01.05.09
-+ *    mpi_init.h Version:  01.05.07
-  *
-  *  Version History
-  *  ---------------
-@@ -53,9 +53,6 @@
-  *  08-03-05  01.05.06  Fixed some MPI_SCSIIO32_MSGFLGS_ defines to make them
-  *                      unique in the first 32 characters.
-  *  03-27-06  01.05.07  Added Task Management type of Clear ACA.
-- *  10-11-06  01.05.08  Shortened define for Task Management type of Clear ACA.
-- *  02-28-07  01.05.09  Defined two new MsgFlags bits for SCSI Task Management
-- *                      Request: Do Not Send Task IU and Soft Reset Option.
-  *  --------------------------------------------------------------------------
-  */
- 
-@@ -431,17 +428,13 @@
- #define MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET    (0x05)
- #define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET        (0x06)
- #define MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK            (0x07)
--#define MPI_SCSITASKMGMT_TASKTYPE_CLR_ACA               (0x08)
-+#define MPI_SCSITASKMGMT_TASKTYPE_CLEAR_ACA             (0x08)
- 
- /* MsgFlags bits */
--#define MPI_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU   (0x01)
--
- #define MPI_SCSITASKMGMT_MSGFLAGS_TARGET_RESET_OPTION   (0x00)
- #define MPI_SCSITASKMGMT_MSGFLAGS_LIP_RESET_OPTION      (0x02)
- #define MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION (0x04)
- 
--#define MPI_SCSITASKMGMT_MSGFLAGS_SOFT_RESET_OPTION     (0x08)
--
- /* SCSI Task Management Reply */
- typedef struct _MSG_SCSI_TASK_MGMT_REPLY
- {
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_ioc.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_ioc.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_ioc.h	2009-05-11 23:24:42.000000000 -0600
-@@ -1,12 +1,12 @@
- /*
-- *  Copyright (c) 2000-2007 LSI Logic Corporation.
-+ *  Copyright (c) 2000-2005 LSI Logic Corporation.
-  *
-  *
-  *           Name:  mpi_ioc.h
-  *          Title:  MPI IOC, Port, Event, FW Download, and FW Upload messages
-  *  Creation Date:  August 11, 2000
-  *
-- *    mpi_ioc.h Version:  01.05.15
-+ *    mpi_ioc.h Version:  01.05.11
-  *
-  *  Version History
-  *  ---------------
-@@ -98,26 +98,6 @@
-  *                      Added MPI_EVENT_SAS_INIT_TABLE_OVERFLOW and event
-  *                      data structure.
-  *                      Added MPI_EXT_IMAGE_TYPE_INITIALIZATION.
-- *  10-11-06  01.05.12  Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED.
-- *                      Added MaxInitiators field to PortFacts reply.
-- *                      Added SAS Device Status Change ReasonCode for
-- *                      asynchronous notificaiton.
-- *                      Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event
-- *                      data structure.
-- *                      Added new ImageType values for FWDownload and FWUpload
-- *                      requests.
-- *  02-28-07  01.05.13  Added MPI_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT for SAS
-- *                      Broadcast Event Data (replacing _RESERVED2).
-- *                      For Discovery Error Event Data DiscoveryStatus field,
-- *                      replaced _MULTPL_PATHS with _UNSUPPORTED_DEVICE and
-- *                      added _MULTI_PORT_DOMAIN.
-- *  05-24-07  01.05.14  Added Common Boot Block type to FWDownload Request.
-- *                      Added Common Boot Block type to FWUpload Request.
-- *  08-07-07  01.05.15  Added MPI_EVENT_SAS_INIT_RC_REMOVED define.
-- *                      Added MPI_EVENT_IR2_RC_DUAL_PORT_ADDED and
-- *                      MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED for IR2 event data.
-- *                      Added SASAddress field to SAS Initiator Device Table
-- *                      Overflow event data structure.
-  *  --------------------------------------------------------------------------
-  */
- 
-@@ -284,7 +264,6 @@
- #define MPI_IOCFACTS_EXCEPT_RAID_CONFIG_INVALID         (0x0002)
- #define MPI_IOCFACTS_EXCEPT_FW_CHECKSUM_FAIL            (0x0004)
- #define MPI_IOCFACTS_EXCEPT_PERSISTENT_TABLE_FULL       (0x0008)
--#define MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED        (0x0010)
- 
- #define MPI_IOCFACTS_FLAGS_FW_DOWNLOAD_BOOT             (0x01)
- #define MPI_IOCFACTS_FLAGS_REPLY_FIFO_HOST_SIGNAL       (0x02)
-@@ -349,8 +328,7 @@
-      U16                    MaxPostedCmdBuffers;        /* 1Ch */
-      U16                    MaxPersistentIDs;           /* 1Eh */
-      U16                    MaxLanBuckets;              /* 20h */
--     U8                     MaxInitiators;              /* 22h */
--     U8                     Reserved4;                  /* 23h */
-+     U16                    Reserved4;                  /* 22h */
-      U32                    Reserved5;                  /* 24h */
- } MSG_PORT_FACTS_REPLY, MPI_POINTER PTR_MSG_PORT_FACTS_REPLY,
-   PortFactsReply_t, MPI_POINTER pPortFactsReply_t;
-@@ -509,7 +487,6 @@
- #define MPI_EVENT_SAS_INIT_DEVICE_STATUS_CHANGE (0x00000018)
- #define MPI_EVENT_SAS_INIT_TABLE_OVERFLOW       (0x00000019)
- #define MPI_EVENT_SAS_SMP_ERROR                 (0x0000001A)
--#define MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE    (0x0000001B)
- #define MPI_EVENT_LOG_ENTRY_ADDED               (0x00000021)
- 
- /* AckRequired field values */
-@@ -616,7 +593,6 @@
- #define MPI_EVENT_SAS_DEV_STAT_RC_ABORT_TASK_SET_INTERNAL   (0x0A)
- #define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL   (0x0B)
- #define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL       (0x0C)
--#define MPI_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION        (0x0D)
- 
- 
- /* SCSI Event data for Queue Full event */
-@@ -713,8 +689,6 @@
- #define MPI_EVENT_IR2_RC_PD_REMOVED                 (0x05)
- #define MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED       (0x06)
- #define MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR       (0x07)
--#define MPI_EVENT_IR2_RC_DUAL_PORT_ADDED            (0x08)
--#define MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED          (0x09)
- 
- /* defines for logical disk states */
- #define MPI_LD_STATE_OPTIMAL                        (0x00)
-@@ -806,7 +780,7 @@
- 
- #define MPI_EVENT_PRIMITIVE_CHANGE              (0x01)
- #define MPI_EVENT_PRIMITIVE_EXPANDER            (0x03)
--#define MPI_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT  (0x04)
-+#define MPI_EVENT_PRIMITIVE_RESERVED2           (0x04)
- #define MPI_EVENT_PRIMITIVE_RESERVED3           (0x05)
- #define MPI_EVENT_PRIMITIVE_RESERVED4           (0x06)
- #define MPI_EVENT_PRIMITIVE_CHANGE0_RESERVED    (0x07)
-@@ -871,9 +845,8 @@
- #define MPI_EVENT_DSCVRY_ERR_DS_SMP_CRC_ERROR               (0x00000100)
- #define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_SUBTRACTIVE          (0x00000200)
- #define MPI_EVENT_DSCVRY_ERR_DS_TABLE_TO_TABLE              (0x00000400)
--#define MPI_EVENT_DSCVRY_ERR_DS_UNSUPPORTED_DEVICE          (0x00000800)
-+#define MPI_EVENT_DSCVRY_ERR_DS_MULTPL_PATHS                (0x00000800)
- #define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS            (0x00001000)
--#define MPI_EVENT_DSCVRY_ERR_DS_MULTI_PORT_DOMAIN           (0x00002000)
- 
- /* SAS SMP Error Event data */
- 
-@@ -909,7 +882,6 @@
- 
- /* defines for the ReasonCode field of the SAS Initiator Device Status Change event */
- #define MPI_EVENT_SAS_INIT_RC_ADDED                 (0x01)
--#define MPI_EVENT_SAS_INIT_RC_REMOVED               (0x02)
- 
- /* SAS Initiator Device Table Overflow Event data */
- 
-@@ -918,60 +890,11 @@
-     U8                      MaxInit;                    /* 00h */
-     U8                      CurrentInit;                /* 01h */
-     U16                     Reserved1;                  /* 02h */
--    U64                     SASAddress;                 /* 04h */
- } EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
-   MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
-   MpiEventDataSasInitTableOverflow_t,
-   MPI_POINTER pMpiEventDataSasInitTableOverflow_t;
- 
--/* SAS Expander Status Change Event data */
--
--typedef struct _EVENT_DATA_SAS_EXPANDER_STATUS_CHANGE
--{
--    U8                      ReasonCode;             /* 00h */
--    U8                      Reserved1;              /* 01h */
--    U16                     Reserved2;              /* 02h */
--    U8                      PhysicalPort;           /* 04h */
--    U8                      Reserved3;              /* 05h */
--    U16                     EnclosureHandle;        /* 06h */
--    U64                     SASAddress;             /* 08h */
--    U32                     DiscoveryStatus;        /* 10h */
--    U16                     DevHandle;              /* 14h */
--    U16                     ParentDevHandle;        /* 16h */
--    U16                     ExpanderChangeCount;    /* 18h */
--    U16                     ExpanderRouteIndexes;   /* 1Ah */
--    U8                      NumPhys;                /* 1Ch */
--    U8                      SASLevel;               /* 1Dh */
--    U8                      Flags;                  /* 1Eh */
--    U8                      Reserved4;              /* 1Fh */
--} EVENT_DATA_SAS_EXPANDER_STATUS_CHANGE,
--  MPI_POINTER PTR_EVENT_DATA_SAS_EXPANDER_STATUS_CHANGE,
--  MpiEventDataSasExpanderStatusChange_t,
--  MPI_POINTER pMpiEventDataSasExpanderStatusChange_t;
--
--/* values for ReasonCode field of SAS Expander Status Change Event data */
--#define MPI_EVENT_SAS_EXP_RC_ADDED                      (0x00)
--#define MPI_EVENT_SAS_EXP_RC_NOT_RESPONDING             (0x01)
--
--/* values for DiscoveryStatus field of SAS Expander Status Change Event data */
--#define MPI_EVENT_SAS_EXP_DS_LOOP_DETECTED              (0x00000001)
--#define MPI_EVENT_SAS_EXP_DS_UNADDRESSABLE_DEVICE       (0x00000002)
--#define MPI_EVENT_SAS_EXP_DS_MULTIPLE_PORTS             (0x00000004)
--#define MPI_EVENT_SAS_EXP_DS_EXPANDER_ERR               (0x00000008)
--#define MPI_EVENT_SAS_EXP_DS_SMP_TIMEOUT                (0x00000010)
--#define MPI_EVENT_SAS_EXP_DS_OUT_ROUTE_ENTRIES          (0x00000020)
--#define MPI_EVENT_SAS_EXP_DS_INDEX_NOT_EXIST            (0x00000040)
--#define MPI_EVENT_SAS_EXP_DS_SMP_FUNCTION_FAILED        (0x00000080)
--#define MPI_EVENT_SAS_EXP_DS_SMP_CRC_ERROR              (0x00000100)
--#define MPI_EVENT_SAS_EXP_DS_SUBTRACTIVE_LINK           (0x00000200)
--#define MPI_EVENT_SAS_EXP_DS_TABLE_LINK                 (0x00000400)
--#define MPI_EVENT_SAS_EXP_DS_UNSUPPORTED_DEVICE         (0x00000800)
--
--/* values for Flags field of SAS Expander Status Change Event data */
--#define MPI_EVENT_SAS_EXP_FLAGS_ROUTE_TABLE_CONFIG      (0x02)
--#define MPI_EVENT_SAS_EXP_FLAGS_CONFIG_IN_PROGRESS      (0x01)
--
--
- 
- /*****************************************************************************
- *
-@@ -1003,11 +926,6 @@
- #define MPI_FW_DOWNLOAD_ITYPE_BIOS              (0x02)
- #define MPI_FW_DOWNLOAD_ITYPE_NVDATA            (0x03)
- #define MPI_FW_DOWNLOAD_ITYPE_BOOTLOADER        (0x04)
--#define MPI_FW_DOWNLOAD_ITYPE_MANUFACTURING     (0x06)
--#define MPI_FW_DOWNLOAD_ITYPE_CONFIG_1          (0x07)
--#define MPI_FW_DOWNLOAD_ITYPE_CONFIG_2          (0x08)
--#define MPI_FW_DOWNLOAD_ITYPE_MEGARAID          (0x09)
--#define MPI_FW_DOWNLOAD_ITYPE_COMMON_BOOT_BLOCK (0x0B)
- 
- 
- typedef struct _FWDownloadTCSGE
-@@ -1056,18 +974,12 @@
- } MSG_FW_UPLOAD, MPI_POINTER PTR_MSG_FW_UPLOAD,
-   FWUpload_t, MPI_POINTER pFWUpload_t;
- 
--#define MPI_FW_UPLOAD_ITYPE_FW_IOC_MEM          (0x00)
--#define MPI_FW_UPLOAD_ITYPE_FW_FLASH            (0x01)
--#define MPI_FW_UPLOAD_ITYPE_BIOS_FLASH          (0x02)
--#define MPI_FW_UPLOAD_ITYPE_NVDATA              (0x03)
--#define MPI_FW_UPLOAD_ITYPE_BOOTLOADER          (0x04)
--#define MPI_FW_UPLOAD_ITYPE_FW_BACKUP           (0x05)
--#define MPI_FW_UPLOAD_ITYPE_MANUFACTURING       (0x06)
--#define MPI_FW_UPLOAD_ITYPE_CONFIG_1            (0x07)
--#define MPI_FW_UPLOAD_ITYPE_CONFIG_2            (0x08)
--#define MPI_FW_UPLOAD_ITYPE_MEGARAID            (0x09)
--#define MPI_FW_UPLOAD_ITYPE_COMPLETE            (0x0A)
--#define MPI_FW_UPLOAD_ITYPE_COMMON_BOOT_BLOCK   (0x0B)
-+#define MPI_FW_UPLOAD_ITYPE_FW_IOC_MEM      (0x00)
-+#define MPI_FW_UPLOAD_ITYPE_FW_FLASH        (0x01)
-+#define MPI_FW_UPLOAD_ITYPE_BIOS_FLASH      (0x02)
-+#define MPI_FW_UPLOAD_ITYPE_NVDATA          (0x03)
-+#define MPI_FW_UPLOAD_ITYPE_BOOTLOADER      (0x04)
-+#define MPI_FW_UPLOAD_ITYPE_FW_BACKUP       (0x05)
- 
- typedef struct _FWUploadTCSGE
- {
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_log_fc.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_log_fc.h	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_log_fc.h	2009-05-11 23:24:42.000000000 -0600
-@@ -0,0 +1,89 @@
-+/*
-+ *  Copyright (c) 2000-2001 LSI Logic Corporation. All rights reserved.
-+ *
-+ *  NAME:           fc_log.h
-+ *  SUMMARY:        MPI IocLogInfo definitions for the SYMFC9xx chips
-+ *  DESCRIPTION:    Contains the enumerated list of values that may be returned
-+ *                  in the IOCLogInfo field of a MPI Default Reply Message.
-+ *
-+ *  CREATION DATE:  6/02/2000
-+ *  ID:             $Id: fc_log.h,v 4.6 2001/07/26 14:41:33 sschremm Exp $
-+ */
-+
-+
-+/*
-+ * MpiIocLogInfo_t enum
-+ *
-+ * These 32 bit values are used in the IOCLogInfo field of the MPI reply
-+ * messages.
-+ * The value is 0xabcccccc where
-+ *          a = The type of log info as per the MPI spec. Since these codes are
-+ *              all for Fibre Channel this value will always be 2.
-+ *          b = Specifies a subclass of the firmware where
-+ *                  0 = FCP Initiator
-+ *                  1 = FCP Target
-+ *                  2 = LAN
-+ *                  3 = MPI Message Layer
-+ *                  4 = FC Link
-+ *                  5 = Context Manager
-+ *                  6 = Invalid Field Offset
-+ *                  7 = State Change Info
-+ *                  all others are reserved for future use
-+ *          c = A specific value within the subclass.
-+ *
-+ * NOTE: Any new values should be added to the end of each subclass so that the
-+ *       codes remain consistent across firmware releases.
-+ */
-+typedef enum _MpiIocLogInfoFc
-+{
-+    MPI_IOCLOGINFO_FC_INIT_BASE                     = 0x20000000,
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_OUT_OF_ORDER_FRAME = 0x20000001, /* received an out of order frame - unsupported */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_START_OF_FRAME = 0x20000002, /* Bad Rx Frame, bad start of frame primative */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_BAD_END_OF_FRAME   = 0x20000003, /* Bad Rx Frame, bad end of frame primative */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_OVER_RUN           = 0x20000004, /* Bad Rx Frame, overrun */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OTHER           = 0x20000005, /* Other errors caught by IOC which require retries */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_SUBPROC_DEAD       = 0x20000006, /* Main processor could not initialize sub-processor */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_RX_OVERRUN         = 0x20000007, /* Scatter Gather overrun  */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_RX_BAD_STATUS      = 0x20000008, /* Receiver detected context mismatch via invalid header */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_RX_UNEXPECTED_FRAME= 0x20000009, /* CtxMgr detected unsupported frame type  */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_LINK_FAILURE       = 0x2000000A, /* Link failure occurred  */
-+    MPI_IOCLOGINFO_FC_INIT_ERROR_TX_TIMEOUT         = 0x2000000B, /* Transmitter timeout error */
-+
-+    MPI_IOCLOGINFO_FC_TARGET_BASE                   = 0x21000000,
-+    MPI_IOCLOGINFO_FC_TARGET_NO_PDISC               = 0x21000001, /* not sent because we are waiting for a PDISC from the initiator */
-+    MPI_IOCLOGINFO_FC_TARGET_NO_LOGIN               = 0x21000002, /* not sent because we are not logged in to the remote node */
-+    MPI_IOCLOGINFO_FC_TARGET_DOAR_KILLED_BY_LIP     = 0x21000003, /* Data Out, Auto Response, not sent due to a LIP */
-+    MPI_IOCLOGINFO_FC_TARGET_DIAR_KILLED_BY_LIP     = 0x21000004, /* Data In, Auto Response, not sent due to a LIP */
-+    MPI_IOCLOGINFO_FC_TARGET_DIAR_MISSING_DATA      = 0x21000005, /* Data In, Auto Response, missing data frames */
-+    MPI_IOCLOGINFO_FC_TARGET_DONR_KILLED_BY_LIP     = 0x21000006, /* Data Out, No Response, not sent due to a LIP */
-+    MPI_IOCLOGINFO_FC_TARGET_WRSP_KILLED_BY_LIP     = 0x21000007, /* Auto-response after a write not sent due to a LIP */
-+    MPI_IOCLOGINFO_FC_TARGET_DINR_KILLED_BY_LIP     = 0x21000008, /* Data In, No Response, not completed due to a LIP */
-+    MPI_IOCLOGINFO_FC_TARGET_DINR_MISSING_DATA      = 0x21000009, /* Data In, No Response, missing data frames */
-+    MPI_IOCLOGINFO_FC_TARGET_MRSP_KILLED_BY_LIP     = 0x2100000a, /* Manual Response not sent due to a LIP */
-+    MPI_IOCLOGINFO_FC_TARGET_NO_CLASS_3             = 0x2100000b, /* not sent because remote node does not support Class 3 */
-+    MPI_IOCLOGINFO_FC_TARGET_LOGIN_NOT_VALID        = 0x2100000c, /* not sent because login to remote node not validated */
-+    MPI_IOCLOGINFO_FC_TARGET_FROM_OUTBOUND          = 0x2100000e, /* cleared from the outbound queue after a logout */
-+    MPI_IOCLOGINFO_FC_TARGET_WAITING_FOR_DATA_IN    = 0x2100000f, /* cleared waiting for data after a logout */
-+
-+    MPI_IOCLOGINFO_FC_LAN_BASE                      = 0x22000000,
-+    MPI_IOCLOGINFO_FC_LAN_TRANS_SGL_MISSING         = 0x22000001, /* Transaction Context Sgl Missing */
-+    MPI_IOCLOGINFO_FC_LAN_TRANS_WRONG_PLACE         = 0x22000002, /* Transaction Context found before an EOB */
-+    MPI_IOCLOGINFO_FC_LAN_TRANS_RES_BITS_SET        = 0x22000003, /* Transaction Context value has reserved bits set */
-+    MPI_IOCLOGINFO_FC_LAN_WRONG_SGL_FLAG            = 0x22000004, /* Invalid SGL Flags */
-+
-+    MPI_IOCLOGINFO_FC_MSG_BASE                      = 0x23000000,
-+
-+    MPI_IOCLOGINFO_FC_LINK_BASE                     = 0x24000000,
-+    MPI_IOCLOGINFO_FC_LINK_LOOP_INIT_TIMEOUT        = 0x24000001, /* Loop initialization timed out */
-+    MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED      = 0x24000002, /* Another system controller already initialized the loop */
-+    MPI_IOCLOGINFO_FC_LINK_LINK_NOT_ESTABLISHED     = 0x24000003, /* Not synchronized to signal or still negotiating (possible cable problem) */
-+    MPI_IOCLOGINFO_FC_LINK_CRC_ERROR                = 0x24000004, /* CRC check detected error on received frame */
-+
-+    MPI_IOCLOGINFO_FC_CTX_BASE                      = 0x25000000,
-+
-+    MPI_IOCLOGINFO_FC_INVALID_FIELD_BYTE_OFFSET     = 0x26000000, /* The lower 24 bits give the byte offset of the field in the request message that is invalid */
-+    MPI_IOCLOGINFO_FC_INVALID_FIELD_MAX_OFFSET      = 0x26ffffff,
-+
-+    MPI_IOCLOGINFO_FC_STATE_CHANGE                  = 0x27000000  /* The lower 24 bits give additional information concerning state change */
-+
-+} MpiIocLogInfoFc_t;
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_log_sas.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_log_sas.h	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_log_sas.h	2009-05-11 23:24:42.000000000 -0600
-@@ -0,0 +1,156 @@
-+
-+/***************************************************************************
-+ *                                                                         *
-+ *  Copyright 2003 LSI Logic Corporation.  All rights reserved.            *
-+ *                                                                         *
-+ ***************************************************************************
-+ *
-+ *           Name:  iopiIocLogInfo.h
-+ *          Title:  SAS Firmware IOP Interface IOC Log Info Definitions
-+ *     Programmer:  Guy Kendall
-+ *  Creation Date:  September 24, 2003
-+ *
-+ *  Version History
-+ *  ---------------
-+ *
-+ *  Last Updated
-+ *  -------------
-+ *  Version         %version: 22 %
-+ *  Date Updated    %date_modified: %
-+ *  Programmer      %created_by: nperucca %
-+ *
-+ *  Date      Who   Description
-+ *  --------  ---   -------------------------------------------------------
-+ *  09/24/03  GWK   Initial version
-+ *
-+ *
-+ * Description
-+ * ------------
-+ * This include file contains SAS firmware interface IOC Log Info codes
-+ *
-+ *-------------------------------------------------------------------------
-+ */
-+
-+#ifndef IOPI_IOCLOGINFO_H_INCLUDED
-+#define IOPI_IOCLOGINFO_H_INCLUDED
-+
-+
-+/****************************************************************************/
-+/*  IOC LOGINFO defines, 0x00000000 - 0x0FFFFFFF                            */
-+/*  Format:                                                                 */
-+/*      Bits 31-28: MPI_IOCLOGINFO_TYPE_SAS (3)                             */
-+/*      Bits 27-24: IOC_LOGINFO_ORIGINATOR: 0=IOP, 1=PL, 2=IR               */
-+/*      Bits 23-16: LOGINFO_CODE                                            */
-+/*      Bits 15-0:  LOGINFO_CODE Specific                                   */
-+/****************************************************************************/
-+
-+/****************************************************************************/
-+/* IOC_LOGINFO_ORIGINATOR defines                                           */
-+/****************************************************************************/
-+#define IOC_LOGINFO_ORIGINATOR_IOP                      (0x00000000)
-+#define IOC_LOGINFO_ORIGINATOR_PL                       (0x01000000)
-+#define IOC_LOGINFO_ORIGINATOR_IR                       (0x02000000)
-+
-+/****************************************************************************/
-+/* LOGINFO_CODE defines                                                     */
-+/****************************************************************************/
-+#define IOC_LOGINFO_CODE_MASK                           (0x00FF0000)
-+#define IOC_LOGINFO_CODE_SHIFT                          (16)
-+
-+/****************************************************************************/
-+/* IOP LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IOP          */
-+/****************************************************************************/
-+#define IOP_LOGINFO_CODE_INVALID_SAS_ADDRESS            (0x00010000)
-+#define IOP_LOGINFO_CODE_UNUSED2                        (0x00020000)
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE            (0x00030000)
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_RT         (0x00030100) /* Route Table Entry not found */
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PN         (0x00030200) /* Invalid Page Number */
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_FORM       (0x00030300) /* Invalid FORM */
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PT         (0x00030400) /* Invalid Page Type */
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DNM        (0x00030500) /* Device Not Mapped */
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_PERSIST    (0x00030600) /* Persistent Page not found */
-+#define IOP_LOGINFO_CODE_CONFIG_INVALID_PAGE_DEFAULT    (0x00030700) /* Default Page not found */
-+#define IOP_LOGINFO_CODE_TASK_TERMINATED                (0x00050000)
-+
-+
-+/****************************************************************************/
-+/* PL LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = PL            */
-+/****************************************************************************/
-+#define PL_LOGINFO_CODE_OPEN_FAILURE                        (0x00010000)
-+#define PL_LOGINFO_CODE_INVALID_SGL                         (0x00020000)
-+#define PL_LOGINFO_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH       (0x00030000)
-+#define PL_LOGINFO_CODE_FRAME_XFER_ERROR                    (0x00040000)
-+#define PL_LOGINFO_CODE_TX_FM_CONNECTED_LOW                 (0x00050000)
-+#define PL_LOGINFO_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET         (0x00060000)
-+#define PL_LOGINFO_CODE_SATA_READ_LOG_RECEIVE_DATA_ERR      (0x00070000)
-+#define PL_LOGINFO_CODE_SATA_NCQ_FAIL_ALL_CMDS_AFTR_ERR     (0x00080000)
-+#define PL_LOGINFO_CODE_SATA_ERR_IN_RCV_SET_DEV_BIT_FIS     (0x00090000)
-+#define PL_LOGINFO_CODE_RX_FM_INVALID_MESSAGE               (0x000A0000)
-+#define PL_LOGINFO_CODE_RX_CTX_MESSAGE_VALID_ERROR          (0x000B0000)
-+#define PL_LOGINFO_CODE_RX_FM_CURRENT_FRAME_ERROR           (0x000C0000)
-+#define PL_LOGINFO_CODE_SATA_LINK_DOWN                      (0x000D0000)
-+#define PL_LOGINFO_CODE_DISCOVERY_SATA_INIT_W_IOS           (0x000E0000)
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE                 (0x000F0000)
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_PT              (0x000F0100) /* Invalid Page Type */
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NUM_PHYS        (0x000F0200) /* Invalid Number of Phys */
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NOT_IMP         (0x000F0300) /* Case Not Handled */
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NO_DEV          (0x000F0400) /* No Device Found */
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_FORM            (0x000F0500) /* Invalid FORM */
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_PHY             (0x000F0600) /* Invalid Phy */
-+#define PL_LOGINFO_CODE_CONFIG_INVALID_PAGE_NO_OWNER        (0x000F0700) /* No Owner Found */
-+#define PL_LOGINFO_CODE_DSCVRY_SATA_INIT_TIMEOUT            (0x00100000)
-+#define PL_LOGINFO_CODE_RESET                               (0x00110000)
-+#define PL_LOGINFO_CODE_ABORT                               (0x00120000)
-+#define PL_LOGINFO_CODE_IO_NOT_YET_EXECUTED                 (0x00130000)
-+#define PL_LOGINFO_CODE_IO_EXECUTED                         (0x00140000)
-+#define PL_LOGINFO_SUB_CODE_OPEN_FAILURE                    (0x00000100)
-+#define PL_LOGINFO_SUB_CODE_INVALID_SGL                     (0x00000200)
-+#define PL_LOGINFO_SUB_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH   (0x00000300)
-+#define PL_LOGINFO_SUB_CODE_FRAME_XFER_ERROR                (0x00000400)
-+#define PL_LOGINFO_SUB_CODE_TX_FM_CONNECTED_LOW             (0x00000500)
-+#define PL_LOGINFO_SUB_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET     (0x00000600)
-+#define PL_LOGINFO_SUB_CODE_SATA_READ_LOG_RECEIVE_DATA_ERR  (0x00000700)
-+#define PL_LOGINFO_SUB_CODE_SATA_NCQ_FAIL_ALL_CMDS_AFTR_ERR (0x00000800)
-+#define PL_LOGINFO_SUB_CODE_SATA_ERR_IN_RCV_SET_DEV_BIT_FIS (0x00000900)
-+#define PL_LOGINFO_SUB_CODE_RX_FM_INVALID_MESSAGE           (0x00000A00)
-+#define PL_LOGINFO_SUB_CODE_RX_CTX_MESSAGE_VALID_ERROR      (0x00000B00)
-+#define PL_LOGINFO_SUB_CODE_RX_FM_CURRENT_FRAME_ERROR       (0x00000C00)
-+#define PL_LOGINFO_SUB_CODE_SATA_LINK_DOWN                  (0x00000D00)
-+#define PL_LOGINFO_SUB_CODE_DISCOVERY_SATA_INIT_W_IOS       (0x00000E00)
-+#define PL_LOGINFO_SUB_CODE_DSCVRY_SATA_INIT_TIMEOUT        (0x00001000)
-+
-+
-+#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_FRAME_FAILURE         (0x00200000) /* Can't get SMP Frame */
-+#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_READ_ERROR            (0x00200001) /* Error occured on SMP Read */
-+#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_WRITE_ERROR           (0x00200002) /* Error occured on SMP Write */
-+#define PL_LOGINFO_CODE_ENCL_MGMT_NOT_SUPPORTED_ON_ENCL     (0x00200004) /* Encl Mgmt services not available for this WWID */
-+#define PL_LOGINFO_CODE_ENCL_MGMT_ADDR_MODE_NOT_SUPPORTED   (0x00200005) /* Address Mode not suppored */
-+#define PL_LOGINFO_CODE_ENCL_MGMT_BAD_SLOT_NUM              (0x00200006) /* Invalid Slot Number in SEP Msg */
-+#define PL_LOGINFO_CODE_ENCL_MGMT_SGPIO_NOT_PRESENT         (0x00200007) /* SGPIO not present/enabled */
-+
-+#define PL_LOGINFO_DA_SEP_NOT_PRESENT                       (0x00200100) /* SEP not present when msg received */
-+#define PL_LOGINFO_DA_SEP_SINGLE_THREAD_ERROR               (0x00200101) /* Can only accept 1 msg at a time */
-+#define PL_LOGINFO_DA_SEP_ISTWI_INTR_IN_IDLE_STATE          (0x00200102) /* ISTWI interrupt recvd. while IDLE */
-+#define PL_LOGINFO_DA_SEP_RECEIVED_NACK_FROM_SLAVE          (0x00200103) /* SEP NACK'd, it is busy */
-+#define PL_LOGINFO_DA_SEP_BAD_STATUS_HDR_CHKSUM             (0x00200104) /* SEP stopped or sent bad chksum in Hdr */
-+#define PL_LOGINFO_DA_SEP_UNSUPPORTED_SCSI_STATUS_1         (0x00200105) /* SEP returned unknown scsi status */
-+#define PL_LOGINFO_DA_SEP_UNSUPPORTED_SCSI_STATUS_2         (0x00200106) /* SEP returned unknown scsi status */
-+#define PL_LOGINFO_DA_SEP_CHKSUM_ERROR_AFTER_STOP           (0x00200107) /* SEP returned bad chksum after STOP */
-+#define PL_LOGINFO_DA_SEP_CHKSUM_ERROR_AFTER_STOP_GETDATA   (0x00200108) /* SEP returned bad chksum after STOP while gettin data*/
-+
-+
-+/****************************************************************************/
-+/* IR LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = IR            */
-+/****************************************************************************/
-+#define IR_LOGINFO_CODE_UNUSED1                         (0x00010000)
-+#define IR_LOGINFO_CODE_UNUSED2                         (0x00020000)
-+
-+/****************************************************************************/
-+/* Defines for convienence                                                  */
-+/****************************************************************************/
-+#define IOC_LOGINFO_PREFIX_IOP                          ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IOP)
-+#define IOC_LOGINFO_PREFIX_PL                           ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_PL)
-+#define IOC_LOGINFO_PREFIX_IR                           ((MPI_IOCLOGINFO_TYPE_SAS << MPI_IOCLOGINFO_TYPE_SHIFT) | IOC_LOGINFO_ORIGINATOR_IR)
-+
-+#endif /* end of file */
-+
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_raid.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_raid.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_raid.h	2009-05-11 23:24:42.000000000 -0600
-@@ -1,12 +1,12 @@
- /*
-- *  Copyright (c) 2001-2007 LSI Logic Corporation.
-+ *  Copyright (c) 2001-2005 LSI Logic Corporation.
-  *
-  *
-  *           Name:  mpi_raid.h
-  *          Title:  MPI RAID message and structures
-  *  Creation Date:  February 27, 2001
-  *
-- *    mpi_raid.h Version:  01.05.04
-+ *    mpi_raid.h Version:  01.05.02
-  *
-  *  Version History
-  *  ---------------
-@@ -32,10 +32,6 @@
-  *  08-19-04  01.05.01  Original release for MPI v1.5.
-  *  01-15-05  01.05.02  Added defines for the two new RAID Actions for
-  *                      _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE.
-- *  02-28-07  01.05.03  Added new RAID Action, Device FW Update Mode, and
-- *                      associated defines.
-- *  08-07-07  01.05.04  Added Disable Full Rebuild bit to the ActionDataWord
-- *                      for the RAID Action MPI_RAID_ACTION_DISABLE_VOLUME.
-  *  --------------------------------------------------------------------------
-  */
- 
-@@ -94,7 +90,6 @@
- #define MPI_RAID_ACTION_INACTIVATE_VOLUME           (0x12)
- #define MPI_RAID_ACTION_SET_RESYNC_RATE             (0x13)
- #define MPI_RAID_ACTION_SET_DATA_SCRUB_RATE         (0x14)
--#define MPI_RAID_ACTION_DEVICE_FW_UPDATE_MODE       (0x15)
- 
- /* ActionDataWord defines for use with MPI_RAID_ACTION_CREATE_VOLUME action */
- #define MPI_RAID_ACTION_ADATA_DO_NOT_SYNC           (0x00000001)
-@@ -107,9 +102,6 @@
- #define MPI_RAID_ACTION_ADATA_KEEP_LBA0             (0x00000000)
- #define MPI_RAID_ACTION_ADATA_ZERO_LBA0             (0x00000002)
- 
--/* ActionDataWord defines for use with MPI_RAID_ACTION_DISABLE_VOLUME action */
--#define MPI_RAID_ACTION_ADATA_DISABLE_FULL_REBUILD  (0x00000001)
--
- /* ActionDataWord defines for use with MPI_RAID_ACTION_ACTIVATE_VOLUME action */
- #define MPI_RAID_ACTION_ADATA_INACTIVATE_ALL        (0x00000001)
- 
-@@ -119,10 +111,6 @@
- /* ActionDataWord defines for use with MPI_RAID_ACTION_SET_DATA_SCRUB_RATE action */
- #define MPI_RAID_ACTION_ADATA_DATA_SCRUB_RATE_MASK  (0x000000FF)
- 
--/* ActionDataWord defines for use with MPI_RAID_ACTION_DEVICE_FW_UPDATE_MODE action */
--#define MPI_RAID_ACTION_ADATA_ENABLE_FW_UPDATE          (0x00000001)
--#define MPI_RAID_ACTION_ADATA_MASK_FW_UPDATE_TIMEOUT    (0x0000FF00)
--#define MPI_RAID_ACTION_ADATA_SHIFT_FW_UPDATE_TIMEOUT   (8)
- 
- 
- /* RAID Action reply message */
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_sas.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/lsi/mpi_sas.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/lsi/mpi_sas.h	2009-05-11 23:24:42.000000000 -0600
-@@ -1,12 +1,12 @@
- /*
-- *  Copyright (c) 2004-2006 LSI Logic Corporation.
-+ *  Copyright (c) 2004 LSI Logic Corporation.
-  *
-  *
-  *           Name:  mpi_sas.h
-  *          Title:  MPI Serial Attached SCSI structures and definitions
-  *  Creation Date:  August 19, 2004
-  *
-- *    mpi_sas.h Version:  01.05.04
-+ *    mpi_sas.h Version:  01.05.03
-  *
-  *  Version History
-  *  ---------------
-@@ -21,8 +21,6 @@
-  *                      and Remove Device operations to SAS IO Unit Control.
-  *                      Added DevHandle field to SAS IO Unit Control request and
-  *                      reply.
-- *  10-11-06  01.05.04  Fixed the name of a define for Operation field of SAS IO
-- *                      Unit Control request.
-  *  --------------------------------------------------------------------------
-  */
- 
-@@ -239,8 +237,7 @@
- #define MPI_SAS_OP_SEND_PRIMITIVE               (0x0A)
- #define MPI_SAS_OP_FORCE_FULL_DISCOVERY         (0x0B)
- #define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL  (0x0C)
--#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE       (0x0D)  /* obsolete name */
--#define MPI_SAS_OP_REMOVE_DEVICE                (0x0D)
-+#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE       (0x0D)
- 
- /* values for the PrimFlags field */
- #define MPI_SAS_PRIMFLAGS_SINGLE                (0x08)
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/Makefile
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/Makefile	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/Makefile	2009-05-11 23:24:42.000000000 -0600
-@@ -7,9 +7,7 @@
- #EXTRA_CFLAGS += -DMPT_DEBUG_INIT
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/Makefile linux-2.6.9-55.0.12/drivers/message/fusion/Makefile
+--- linux-2.6.9-67.0.1/drivers/message/fusion/Makefile	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/Makefile	2007-11-02 09:10:23.000000000 +0100
+@@ -8,8 +8,6 @@
  #EXTRA_CFLAGS += -DMPT_DEBUG_EXIT
  #EXTRA_CFLAGS += -DMPT_DEBUG_FAIL
--#EXTRA_CFLAGS += -DMPT_DEBUG_SAS
--#EXTRA_CFLAGS += -DMPT_DEBUG_CSMISAS
--#EXTRA_CFLAGS += -DMPT_DEBUG_TM
-+#EXTRA_CFLAGS  += -DMPT_DEBUG_SAS
+ #EXTRA_CFLAGS  += -DMPT_DEBUG_SAS
+-EXTRA_CFLAGS += -DCPQ_CIM
+-EXTRA_CFLAGS += -DMPT_SUPPORT_FWDLB_IOCTL
  
  #
  # driver/module specifics...
-@@ -19,7 +17,8 @@
- #CFLAGS_mptbase.o += -DMPT_DEBUG_CONFIG
- #CFLAGS_mptbase.o += -DMPT_DEBUG_DL
- #CFLAGS_mptbase.o += -DMPT_DEBUG_IRQ
--#CFLAGS_mptbase.o += -DMPT_DEBUG_RESET -DMPT_DEBUG_INIT
-+#CFLAGS_mptbase.o += -DMPT_DEBUG_RESET
-+#CFLAGS_mptbase.o += -DMPT_DEBUG_INIT
- #
- #  For mptscsi:
- #CFLAGS_mptscsi.o += -DMPT_DEBUG_DV
-@@ -30,8 +29,7 @@
+@@ -31,6 +29,7 @@ EXTRA_CFLAGS += -DMPT_SUPPORT_FWDLB_IOCT
  #
  #  For mptctl:
  #CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL
--CFLAGS_mptctl.o  += -DCPG_CIM
--CFLAGS_mptctl.o  += -DMPT_SUPPORT_FWDLB_IOCTL
 +CFLAGS_mptctl.o  += -DCPQ_CIM
  #
  #  For mptsas:
  #CFLAGS_mptsas.o += -DMPT_DEBUG_HOTPLUG
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptbase.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c	2009-05-11 23:24:42.000000000 -0600
-@@ -2,11 +2,11 @@
-  *  linux/drivers/message/fusion/mptbase.c
-  *      This is the Fusion MPT base driver which supports multiple
-  *      (SCSI + LAN) specialized protocol drivers.
-- *      For use with LSI PCI chip/adapter(s)
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      For use with LSI Logic PCI chip/adapter(s)
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptbase.c linux-2.6.9-55.0.12/drivers/message/fusion/mptbase.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptbase.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptbase.c	2007-11-02 09:10:23.000000000 +0100
+@@ -5,8 +5,8 @@
+  *      For use with LSI Logic PCI chip/adapter(s)
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
   *  $Id: mptbase.c,v 1.130 2003/05/07 14:08:30 Exp $
   */
-@@ -60,8 +60,6 @@
- #include <linux/blkdev.h>
- #include <linux/delay.h>
- #include <linux/interrupt.h>		/* needed for in_interrupt() proto */
--#include <scsi/scsi.h>
--#include <scsi/scsi_host.h>
- #include <asm/io.h>
- #ifdef CONFIG_MTRR
- #include <asm/mtrr.h>
-@@ -95,7 +93,6 @@
+@@ -93,8 +93,6 @@ MODULE_VERSION(MPT_LINUX_VERSION_COMMON)
  char *mptbase = NULL;
  
  /* Command line args */
 -
+-
  int mpt_can_queue = 128;
  module_param(mpt_can_queue, int, 0);
  MODULE_PARM_DESC(mpt_can_queue, " Max IO depth per controller (default=128)");
-@@ -116,10 +113,6 @@
+@@ -115,11 +113,6 @@ static int mpt_msi_enable = 0;
  module_param(mpt_msi_enable, int, 0);
  MODULE_PARM_DESC(mpt_msi_enable, " MSI Support Enable (default=0)");
  
@@ -16417,27 +14704,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -module_param(mpt_enable_deadioc_detect, int, 0);
 -MODULE_PARM_DESC(mpt_enable_deadioc_detect, "Detection of Dead IOC Enable (default=0)");
 -
+-//@@@@
  #ifdef MFCNT
  static int mfcounter = 0;
  #define PRINT_MF_COUNT 20000
-@@ -163,12 +156,10 @@
+@@ -163,13 +156,10 @@ static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq
   */
  static irqreturn_t mpt_interrupt(int irq, void *bus_id, struct pt_regs *r);
  static int	mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply);
 -int	mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes,
--		u32 *req, int replyBytes, u16 *u16reply, int maxwait,
--		int sleepFlag);
--int             mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag);
--int		mpt_writeSDP1(MPT_ADAPTER *hd, int portnum, int id, int flags);
--void		mpt_setSDP1parameters (u8 width, u8 factor, u8 offset, u8 flags, int *requestedPtr, int *configurationPtr);
 +static int	mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes,
-+			u32 *req, int replyBytes, u16 *u16reply, int maxwait,
-+			int sleepFlag);
+ 			u32 *req, int replyBytes, u16 *u16reply, int maxwait,
+ 			int sleepFlag);
+-int    	        mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag);
+-int             mpt_writeSDP1(MPT_ADAPTER *hd, int portnum, int id, int flags);
+-void    mpt_setSDP1parameters (u8 width, u8 factor, u8 offset, u8 flags, int *requestedPtr, int *configurationPtr);
+-
 +static int	mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag);
  static void	mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev);
  static void	mpt_adapter_disable(MPT_ADAPTER *ioc);
  static void	mpt_adapter_dispose(MPT_ADAPTER *ioc);
-@@ -186,7 +177,7 @@
+@@ -187,7 +177,7 @@ static int	mpt_do_upload(MPT_ADAPTER *io
  int		mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag);
  static int	mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag);
  static int	KickStart(MPT_ADAPTER *ioc, int ignore, int sleepFlag);
@@ -16446,7 +14733,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  static int	PrimeIocFifos(MPT_ADAPTER *ioc);
  static int	WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag);
  static int	WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag);
-@@ -196,6 +187,9 @@
+@@ -197,6 +187,9 @@ static int	GetFcPortPage0(MPT_ADAPTER *i
  static int	GetIoUnitPage2(MPT_ADAPTER *ioc);
  static int	GetManufPage5(MPT_ADAPTER *ioc, int numPorts);
  static int	GetManufPage0(MPT_ADAPTER *ioc);
@@ -16456,7 +14743,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  int		mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
  static void	mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
  		    MpiEventDataRaid_t * pRaidEventData);
-@@ -203,7 +197,6 @@
+@@ -204,7 +197,6 @@ static int	mpt_GetScsiPortSettings(MPT_A
  static int	mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum);
  static void 	mpt_read_ioc_pg_1(MPT_ADAPTER *ioc);
  static void 	mpt_read_ioc_pg_4(MPT_ADAPTER *ioc);
@@ -16464,7 +14751,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  static void	mpt_timer_expired(unsigned long data);
  static int	SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch);
  static int	SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp);
-@@ -226,7 +219,6 @@
+@@ -227,7 +219,6 @@ static void	mpt_sp_ioc_info(MPT_ADAPTER 
  static void	mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info);
  static void	mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info);
  static void	mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info);
@@ -16472,15 +14759,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  /* module entry point */
  static int  __init    fusion_init  (void);
-@@ -264,7 +256,6 @@
- 	pci_write_config_word(pdev, PCI_COMMAND, command_reg);
- }
- 
--
- /*
-  *  Process turbo (context) reply...
-  */
-@@ -273,9 +264,12 @@
+@@ -273,10 +264,10 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa
  {
  	MPT_FRAME_HDR *mf = NULL;
  	MPT_FRAME_HDR *mr = NULL;
@@ -16488,21 +14767,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +	int req_idx = 0;
  	int cb_idx;
  
+-	dmfprintk((MYIOC_s_INFO_FMT "Got TURBO reply pa=%08x\n",
 +	dmfprintk((MYIOC_s_INFO_FMT "Got TURBO reply req_idx=%08x\n",
-+				ioc->name, pa));
-+
+ 				ioc->name, pa));
+ 
  	switch (pa >> MPI_CONTEXT_REPLY_TYPE_SHIFT) {
- 	case MPI_CONTEXT_REPLY_TYPE_SCSI_INIT:
- 		req_idx = pa & 0x0000FFFF;
-@@ -299,6 +293,7 @@
- 			mpt_free_msg_frame(ioc, mf);
- 			mb();
- 			return;
-+			break;
- 		}
- 		mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
- 		break;
-@@ -308,9 +303,7 @@
+@@ -312,9 +303,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa
  		break;
  	default:
  		cb_idx = 0;
@@ -16513,7 +14783,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	}
  
  	/*  Check for (valid) IO callback!  */
-@@ -338,12 +331,6 @@
+@@ -342,12 +331,6 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
  
  	u32 reply_dma_low;
  	u16 ioc_stat;
@@ -16526,21 +14796,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  	/* non-TURBO reply!  Hmmm, something may be up...
  	 *  Newest turbo reply mechanism; get address
-@@ -363,44 +350,21 @@
+@@ -367,44 +350,21 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
  	cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx;
  	mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
  
 -	ioc_stat = le16_to_cpu(mr->u.reply.IOCStatus);
 -#ifdef MPT_DEBUG_REPLY
--	if ((ioc_stat != MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE) && /* 0x0043 */
--	    (ioc_stat != MPI_IOCSTATUS_SCSI_DATA_UNDERRUN)) {    /* 0x0045 */
+-         if ((ioc_stat != MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE) && /* 0x0043 */
+-	      (ioc_stat != MPI_IOCSTATUS_SCSI_DATA_UNDERRUN)) {    /* 0x0045 */
 -		function = mr->u.hdr.Function;
 -		dreplyprintk((MYIOC_s_WARN_FMT "non-TURBO reply context=%04x%04x Function=%x IOCStatus=%04x\n",
 -			ioc->name, cb_idx, req_idx, function, ioc_stat));
 -		DBG_DUMP_REPLY_FRAME(mr)
--	
+-
 -		printk("Request:\n");
--		DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mf)
+-                DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mf)
 -		chain_number = 1;
 -		chain_idx = ioc->ReqToChain[req_idx];
 -		while (chain_idx != MPT_HOST_NO_CHAIN) {
@@ -16548,7 +14818,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -			chain = (MPT_FRAME_HDR *) (ioc->ChainBuffer
 -				+ (chain_idx * ioc->req_sz));
 -			printk("Chain %d:\n", chain_number++);
--			DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, chain)
+-                        DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, chain)
 -			chain_idx = next;
 -		}
 -	}
@@ -16576,12 +14846,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	}
  	if (ioc_stat & MPI_IOCSTATUS_MASK) {
  		if (ioc->bus_type == SPI &&
-@@ -428,32 +392,6 @@
+@@ -432,31 +392,6 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
  	if (freeme)
  		mpt_free_msg_frame(ioc, mf);
  	mb();
--
--	if (ioc->CheckFcLinkSpeed &&
+-if (ioc->CheckFcLinkSpeed &&
 -	    ioc->FcLinkSpeedCheckNeeded &&
 -	    ioc->FcLinkSpeedReqActive == NULL &&
 -	    (mf = mpt_get_msg_frame(mpt_base_index, ioc))) {
@@ -16601,7 +14870,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -		pConfigMsg->Header.PageNumber = 0;
 -		pConfigMsg->Header.PageLength = sizeof(FCPortPage0_t) / 4;
 -		pConfigMsg->Header.PageVersion = MPI_FCPORTPAGE0_PAGEVERSION;
--		ioc->add_sge((char *)&pConfigMsg->PageBufferSGE,
+-		mpt_add_sge((char *)&pConfigMsg->PageBufferSGE,
 -			MPT_SGE_FLAGS_SSIMPLE_READ + sizeof(FCPortPage0_t),
 -			physAddr);
 -		mpt_put_msg_frame(mpt_base_index, ioc, mf);
@@ -16609,79 +14878,29 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  }
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -478,21 +416,20 @@
- mpt_interrupt(int irq, void *bus_id, struct pt_regs *r)
- {
- 	MPT_ADAPTER *ioc = bus_id;
--	u32 pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
--
--	if (pa == 0xFFFFFFFF)
--		return IRQ_HANDLED;
-+	u32 pa;
- 
- 	/*
- 	 *  Drain the reply FIFO!
- 	 */
--	do {
--	    if (pa & MPI_ADDRESS_REPLY_A_BIT)
--		mpt_reply(ioc, pa);
--	    else
--		mpt_turbo_reply(ioc, pa);
--	    pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
--	} while (pa != 0xFFFFFFFF);
-+	while (1) {
-+		pa = CHIPREG_READ32_dmasync(&ioc->chip->ReplyFifo);
-+		if (pa == 0xFFFFFFFF)
-+			return IRQ_HANDLED;
-+		else if (pa & MPI_ADDRESS_REPLY_A_BIT)
-+			mpt_reply(ioc, pa);
-+		else
-+			mpt_turbo_reply(ioc, pa);
-+	}
- 
- 	return IRQ_HANDLED;
- }
-@@ -515,7 +452,18 @@
- 	int freereq = 1;
- 	u8 func;
- 
-+	dmfprintk((MYIOC_s_INFO_FMT "mpt_base_reply() called\n", ioc->name));
-+
-+#if defined(MPT_DEBUG_MSG_FRAME)
-+	if (!(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) {
-+		dmfprintk((KERN_INFO MYNAM ": Original request frame (@%p) header\n", mf));
-+		DBG_DUMP_REQUEST_FRAME_HDR(mf)
-+	}
-+#endif
-+
- 	func = reply->u.hdr.Function;
-+	dmfprintk((MYIOC_s_INFO_FMT "mpt_base_reply, Function=%02Xh\n",
-+			ioc->name, func));
- 
- 	if (func == MPI_FUNCTION_EVENT_NOTIFICATION) {
- 		EventNotificationReply_t *pEvReply = (EventNotificationReply_t *) reply;
-@@ -530,17 +478,14 @@
+@@ -543,17 +478,15 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRA
  		}
  
  		/*
--		 *	EventNotificationReply is an exception
+-		 *	 EventNotificationReply is an exception
 +		 *	Hmmm...  It seems that EventNotificationReply is an exception
  		 *	to the rule of one reply per request.
  		 */
  		if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) {
  			freereq = 0;
  		} else {
--			devtprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns mf=%p evnp=%p\n",
--				ioc->name, pEvReply, mf, ioc->evnp));
--			if ( (MPT_FRAME_HDR *)ioc->evnp == mf ) {
--				ioc->evnp = NULL;
--			}
+-                    devtprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns mf=%p evnp=%p\n", ioc->name, pEvReply, mf, ioc->evnp));
+-              if ( (MPT_FRAME_HDR *)ioc->evnp == mf ) {
+-                         ioc->evnp = NULL;
+-                   }
+- }
 +			devtprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns Request frame\n",
 +				ioc->name, pEvReply));
- 		}
++		}
  
  #ifdef CONFIG_PROC_FS
-@@ -550,7 +495,7 @@
+ //		LogEvent(ioc, pEvReply);
+@@ -562,7 +495,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRA
  	} else if (func == MPI_FUNCTION_EVENT_ACK) {
  		dprintk((MYIOC_s_INFO_FMT "mpt_base_reply, EventAck reply received\n",
  				ioc->name));
@@ -16690,78 +14909,67 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		CONFIGPARMS *pCfg;
  		unsigned long flags;
  
-@@ -605,38 +550,6 @@
+@@ -617,29 +550,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRA
  			 */
  			pCfg->wait_done = 1;
  			wake_up(&mpt_waitq);
--		} else if (mf == ioc->FcLinkSpeedReqActive) {
--			pFCPortPage0_t	pFCPortPage0 = (pFCPortPage0_t)((u8 *)mf + sizeof(pConfig_t));
--			u8		OldSpeed = ioc->FcLinkSpeed;
--			u8		NewSpeed = pFCPortPage0->CurrentSpeed;
--			u8		State = pFCPortPage0->PortState;
--
--			ioc->FcLinkSpeedReqActive = NULL;
+-		}else if (mf == ioc->FcLinkSpeedReqActive) {
+-     pFCPortPage0_t  pFCPortPage0 = (pFCPortPage0_t)((u8 *)mf + sizeof(pConfig_t));
+-                u8 OldSpeed = ioc->FcLinkSpeed;
+-		u8 NewSpeed = pFCPortPage0->CurrentSpeed;
+-		u8 State = pFCPortPage0->PortState;
+-                ioc->FcLinkSpeedReqActive = NULL;
 -			if (State != MPI_FCPORTPAGE0_PORTSTATE_OFFLINE &&
 -			    NewSpeed != MPI_FCPORTPAGE0_CURRENT_SPEED_UKNOWN) {
 -				char	*old;
 -				char	*new;
+- old = OldSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? "1 Gbps" :OldSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? "2 Gbps" :OldSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? "4 Gbps" :
+- "Unknown";
+-new = NewSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? "1 Gbps" :NewSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? "2 Gbps" :
+-NewSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? "4 Gbps" : "Unknown";
 -
--				old = OldSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? "1 Gbps" :
--				       OldSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? "2 Gbps" :
--					OldSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? "4 Gbps" :
--					 "Unknown";
--				new = NewSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? "1 Gbps" :
--				       NewSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? "2 Gbps" :
--					NewSpeed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? "4 Gbps" :
--					 "Unknown";
--				if (OldSpeed == 0) {
--					printk(MYIOC_s_NOTE_FMT
--						"FC Link Established, Speed = %s\n",
--						ioc->name, new);
--				} else if (OldSpeed != NewSpeed) {
--					printk(MYIOC_s_WARN_FMT
--						"FC Link Speed Change, Old Speed = %s, New Speed = %s\n",
--						ioc->name, old, new);
--				}
--
--				ioc->FcLinkSpeed = NewSpeed;
--			}
- 		}
+-if (OldSpeed == 0) { printk(MYIOC_s_NOTE_FMT "FC Link Established, Speed = %s\n", ioc->name, new);
+-	} else if (OldSpeed != NewSpeed)
+-{
+-printk(MYIOC_s_WARN_FMT "FC Link Speed Change, Old Speed = %s, New Speed = %s\n",ioc->name, old, new);
+-}
+-ioc->FcLinkSpeed = NewSpeed;
+-}
+-}
++		}
  	} else if (func == MPI_FUNCTION_SAS_IO_UNIT_CONTROL) {
  		/* we should be always getting a reply frame */
-@@ -866,19 +779,18 @@
+ 		memcpy(ioc->persist_reply_frame, reply,
+@@ -868,10 +779,6 @@ MPT_FRAME_HDR*
  mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
  {
  	MPT_FRAME_HDR *mf;
--#ifdef MPT_DEBUG_FAIL
--	u8	*mem;
--#endif
+-        #ifdef MPT_DEBUG_FAIL
+-          u8      *mem;
+-        #endif
+-
  	unsigned long flags;
  	u16	 req_idx;	/* Request index */
  
- 	/* validate handle and ioc identifier */
--	if (!ioc->active) {
- #ifdef MFCNT
--		printk(KERN_WARNING "IOC Not Active! mpt_get_msg_frame!!\n");
-+	if (!ioc->active)
-+		printk(KERN_WARNING "IOC Not Active! mpt_get_msg_frame returning NULL!\n");
- #endif
-+
-+	/* If interrupts are not attached, do not return a request frame */
-+	if (!ioc->active)
+@@ -884,10 +791,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTE
+ 
+ 	/* If interrupts are not attached, do not return a request frame */
+ 	if (!ioc->active)
+-       {
+-            printk(KERN_WARNING "IOC Not Active! mpt_get_msg_frame!!\n");
  		return NULL;
--	}
+-       }
  
  	spin_lock_irqsave(&ioc->FreeQlock, flags);
  	if (!list_empty(&ioc->FreeQ)) {
-@@ -898,33 +810,9 @@
+@@ -907,36 +811,10 @@ mpt_get_msg_frame(int handle, MPT_ADAPTE
  #ifdef MFCNT
  		ioc->mfcnt++;
  #endif
 -	} else {
 -#ifdef MPT_DEBUG_FAIL
--		dfailprintk((MYIOC_s_WARN_FMT "%s, No Free Message Frame!!\n",
--		    ioc->name,__FUNCTION__));
+-dfailprintk((MYIOC_s_WARN_FMT "%s, No Free Message Frame!!\n",
+-     ioc->name,__FUNCTION__));
 -		mem = (u8 *) ioc->req_frames;
 -		for (req_idx = 0; req_idx < 10; req_idx++) {
 -	{
@@ -16777,40 +14985,29 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -			printk("%08x ", le32_to_cpu(m[ii]));
 -		}
 -		printk("\n");
- 	}
--			mem += ioc->req_sz;
--		}
--
--//		panic ("No free Message Frame!!!!!\n");
+-          }
+-               mem += ioc->req_sz;
+-               }
 -#endif
+-
+-
+-
+-mf = NULL;
+-}
+-spin_unlock_irqrestore(&ioc->FreeQlock, flags);
+-
++	}
 +	else
- 		mf = NULL;
--	}
- 	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
++		mf = NULL;
++	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
  
  #ifdef MFCNT
-@@ -935,6 +823,8 @@
- 		printk(KERN_INFO "MF Count 0x%x Max 0x%x \n", ioc->mfcnt, ioc->req_depth);
- #endif
- 
-+	dmfprintk((KERN_INFO MYNAM ": %s: mpt_get_msg_frame(%d,%d), got mf=%p\n",
-+			ioc->name, handle, ioc->id, mf));
- 	return mf;
- }
- 
-@@ -964,24 +854,24 @@
- 	mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx);
- 	mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0;
- 
--/*#ifdef MPT_DEBUG_MSG_FRAME
-+#ifdef MPT_DEBUG_MSG_FRAME
- 	{
- 		u32	*m = mf->u.frame.hwhdr.__hdr;
- 		int	 ii, n;
+ 	if (mf == NULL)
+@@ -984,13 +862,13 @@ mpt_put_msg_frame(int handle, MPT_ADAPTE
  
  		printk(KERN_INFO MYNAM ": %s: About to Put msg frame @ %p:\n" KERN_INFO " ",
  				ioc->name, m);
--		n = ioc->req_sz/4;
+-		n = ioc->req_sz/4 ;
 +		n = ioc->req_sz/4 - 1;
  		while (m[n] == 0)
  			n--;
@@ -16822,166 +15019,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		}
  		printk("\n");
  	}
--#endif */
-+#endif
- 
- 	mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; 
- 	dsgprintk((MYIOC_s_INFO_FMT "mf_dma_addr=%x req_idx=%d RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, ioc->RequestNB[req_idx]));
-@@ -1014,138 +904,32 @@
- }
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*
-- *	mpt_freeChainBuffers - Function to free chain buffers associated
-- *	with a SCSI IO request
-- *	@ioc: Pointer to MPT_ADAPTER structure
-- *	@req_idx: Index of the SCSI IO request frame.
-- *
-- *	Called if SG chain buffer allocation fails and mptscsih callbacks.
-- *	No return.
-- */
--void
--mpt_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
--{
--	MPT_FRAME_HDR *chain;
--	unsigned long flags;
--	int chain_idx;
--	int next;
--
--	/* Get the first chain index and reset
--	 * tracker state.
--	 */
--	chain_idx = ioc->ReqToChain[req_idx];
--	ioc->ReqToChain[req_idx] = MPT_HOST_NO_CHAIN;
--
--	while (chain_idx != MPT_HOST_NO_CHAIN) {
--
--		/* Save the next chain buffer index */
--		next = ioc->ChainToChain[chain_idx];
--
--		/* Free this chain buffer and reset
--		 * tracker
--		 */
--		ioc->ChainToChain[chain_idx] = MPT_HOST_NO_CHAIN;
--
--		chain = (MPT_FRAME_HDR *) (ioc->ChainBuffer
--					+ (chain_idx * ioc->req_sz));
--		spin_lock_irqsave(&ioc->FreeQlock, flags);
--		list_add_tail(&chain->u.frame.linkage.list, &ioc->FreeChainQ);
--		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
--
--		/* handle next */
--		chain_idx = next;
--	}
--	return;
--}
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/**
-- *	mpt_u32_add_sge - Place a simple u32 SGE at address pAddr.
-- *	@pAddr: virtual address for SGE
-- *	@flagslength: SGE flags and data transfer length
-- *	@dma_addr: Physical address
-- *
-- */
--void
--mpt_u32_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
--{
--	SGESimple32_t *pSge = (SGESimple32_t *) pAddr;
--	pSge->FlagsLength = cpu_to_le32(flagslength);
--	pSge->Address = cpu_to_le32(dma_addr);
--}
--
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/**
-- *	mpt_u64_add_sge - Place a simple u64 SGE at address pAddr.
-- *	@pAddr: virtual address for SGE
-- *	@flagslength: SGE flags and data transfer length
-- *	@dma_addr: Physical address
-- *
-- */
--void
--mpt_u64_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
--{
--	SGESimple64_t *pSge = (SGESimple64_t *) pAddr;
--	u32 tmp = dma_addr & 0xFFFFFFFF;
--
--	pSge->FlagsLength = cpu_to_le32(flagslength);
--	pSge->Address.Low = cpu_to_le32(tmp);
--	tmp = (u32) ((u64)dma_addr >> 32);
--	pSge->Address.High = cpu_to_le32(tmp);
--}
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /**
-- *	mpt_1078 u64_add_sge - Place a simple u64 SGE at address pAddr for 
-- *	the 1078.
-+ *	mpt_add_sge - Place a simple SGE at address pAddr.
-  *	@pAddr: virtual address for SGE
-  *	@flagslength: SGE flags and data transfer length
-  *	@dma_addr: Physical address
-  *
-+ *	This routine places a MPT request frame back on the MPT adapter's
-+ *	FreeQ.
-  */
- void
--mpt_1078_u64_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
-+mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
- {
--	SGESimple64_t *pSge = (SGESimple64_t *) pAddr;
--	u32 tmp;
-+	if (sizeof(dma_addr_t) == sizeof(u64)) {
-+		SGESimple64_t *pSge = (SGESimple64_t *) pAddr;
-+		u32 tmp = dma_addr & 0xFFFFFFFF;
- 
--	tmp = dma_addr & 0xFFFFFFFF;
--	pSge->Address.Low = cpu_to_le32(tmp);
--	tmp = (u32) ((u64)dma_addr >> 32);
-+		pSge->FlagsLength = cpu_to_le32(flagslength);
-+		pSge->Address.Low = cpu_to_le32(tmp);
-+		tmp = (u32) ((u64)dma_addr >> 32);
-+		pSge->Address.High = cpu_to_le32(tmp);
- 
--	/*
--	 * 1078 errata workaround for the 36GB limitation
--	 */
--	if ( (((u64)dma_addr + MPI_SGE_LENGTH(flagslength)) >> 32)  == 9) {
--		flagslength |=
--		    MPI_SGE_SET_FLAGS(MPI_SGE_FLAGS_LOCAL_ADDRESS);
--		tmp |= (1<<31);
--		d36GBprintk ((KERN_WARNING MYNAM ": 1078 36GB address hit flagslength=%x tmp=%x\n",
--			flagslength, tmp));
-+	} else {
-+		SGESimple32_t *pSge = (SGESimple32_t *) pAddr;
-+		pSge->FlagsLength = cpu_to_le32(flagslength);
-+		pSge->Address = cpu_to_le32(dma_addr);
- 	}
--
--	pSge->FlagsLength = cpu_to_le32(flagslength);
--	pSge->Address.High = cpu_to_le32(tmp);
--}
--
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/**
-- *	mpt_1078_u32_add_sge - Place a simple u32 SGE at address pAddr for i
-- *	the 1078.
-- *	@pAddr: virtual address for SGE
-- *	@flagslength: SGE flags and data transfer length
-- *	@dma_addr: Physical address
-- *
-- */
--void
--mpt_1078_u32_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
--{
--	SGESimple32_t *pSge = (SGESimple32_t *) pAddr;
--	pSge->FlagsLength = cpu_to_le32(flagslength);
--	pSge->Address = cpu_to_le32(dma_addr);
- }
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -1167,31 +951,29 @@
+@@ -1074,14 +952,16 @@ mpt_add_sge(char *pAddr, u32 flagslength
   *	Returns 0 for success, non-zero for failure.
   */
  int
@@ -16994,16 +15032,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -	int	ii;
 +	int	 ii;
  
+-	dtmprintk((KERN_WARNING MYNAM ": %s: mpt_send_handshake_request reqBytes=%d\n",
+-		ioc->name, reqBytes));
 +	/* State is known to be good upon entering
 +	 * this function so issue the bus reset
 +	 * request.
 +	 */
  
--	dtmprintk((KERN_WARNING MYNAM ": %s: mpt_send_handshake_request reqBytes=%d\n",
--		ioc->name, reqBytes));
  	/*
  	 * Emulate what mpt_put_msg_frame() does /wrt to sanity
- 	 * setting cb_idx/req_idx.  But ONLY if this request
+@@ -1089,16 +969,12 @@ mpt_send_handshake_request(int handle, M
  	 * is in proper (pre-alloc'd) request buffer range...
  	 */
  	ii = MFPTR_2_MPT_INDEX(ioc,(MPT_FRAME_HDR*)req);
@@ -17014,52 +15052,52 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		mf->u.frame.hwhdr.msgctxu.fld.cb_idx = handle;
  	}
  
--	ioc->tmPtr = (MPT_FRAME_HDR *)req;
--	ioc->TMtimer.expires = jiffies + HZ*timeout;  /* seconds */
--	add_timer(&ioc->TMtimer);
+-               ioc->tmPtr = (MPT_FRAME_HDR *)req;
+-               ioc->TMtimer.expires = jiffies + HZ*timeout;  /* seconds */
+-               add_timer(&ioc->TMtimer);
 -
  	/* Make sure there are no doorbells */
  	CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
  
-@@ -1201,24 +983,20 @@
+@@ -1108,25 +984,20 @@ mpt_send_handshake_request(int handle, M
  
  	/* Wait for IOC doorbell int */
  	if ((ii = WaitForDoorbellInt(ioc, 5, sleepFlag)) < 0) {
--		r = ii;
--		goto mpt_send_handshake_failed;
+-		r= ii;
+-                goto mpt_send_handshake_failed;
 +		return ii;
  	}
  
  	/* Read doorbell and check for active bit */
--	if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) {
--		r = -5;
--		goto mpt_send_handshake_failed;
--	}
+-	if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)){
+-		r= -5;
+-                goto mpt_send_handshake_failed;
+-           }
+-
 +	if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE))
 +		return -5;
  
--	dtmprintk((KERN_WARNING MYNAM ": %s: mpt_send_handshake_request start, WaitCnt=%d\n",
-+	dhsprintk((KERN_INFO MYNAM ": %s: mpt_send_handshake_request start, WaitCnt=%d\n",
+ 	dhsprintk((KERN_INFO MYNAM ": %s: mpt_send_handshake_request start, WaitCnt=%d\n",
  		ioc->name, ii));
  
  	CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
  
--	if ((WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
--		r = -2;
--		goto mpt_send_handshake_failed;
+-        if ((WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
+-            r=-2;
+-             goto mpt_send_handshake_failed;
 +	if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
 +		return -2;
  	}
  
  	/* Send request via doorbell handshake */
-@@ -1230,33 +1008,23 @@
+@@ -1138,33 +1009,21 @@ mpt_send_handshake_request(int handle, M
  			(req_as_bytes[(ii*4) + 1] <<  8) |
  			(req_as_bytes[(ii*4) + 2] << 16) |
  			(req_as_bytes[(ii*4) + 3] << 24));
--			dtmprintk((KERN_WARNING MYNAM ": %s: mpt_send_handshake_request word=%08x ii=%d\n",
--		ioc->name, word, ii));
+-dtmprintk((KERN_WARNING MYNAM ": %s: mpt_send_handshake_request word=%08x ii=%d\n",ioc->name, word, ii));
+-
  		CHIPREG_WRITE32(&ioc->chip->Doorbell, word);
--		if (WaitForDoorbellAck(ioc, 5, sleepFlag) < 0) {
+-		if ( WaitForDoorbellAck(ioc, 5, sleepFlag) < 0) {
 +		if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
  			r = -3;
 -			goto mpt_send_handshake_failed;
@@ -17069,7 +15107,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
 -	dtmprintk((KERN_WARNING MYNAM ": %s: mpt_send_handshake_request reqBytes=%d sent, WaitForDoorbellInt\n",
 -		ioc->name, reqBytes));
--	if (WaitForDoorbellInt(ioc, 10, sleepFlag) < 0)
+-
+-	if ( WaitForDoorbellInt(ioc, 10, sleepFlag)< 0)
 +	if (r >= 0 && WaitForDoorbellInt(ioc, 10, sleepFlag) >= 0)
 +		r = 0;
 +	else
@@ -17085,43 +15124,29 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -	}
 -	dtmprintk((KERN_WARNING MYNAM ": %s: mpt_send_handshake_request r=%d\n",
 -		ioc->name, r));
+-
+-
  	return r;
  }
--
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /**
-  * mpt_host_page_access_control - provides mechanism for the host
-@@ -1276,6 +1044,8 @@
+@@ -1186,6 +1045,7 @@ mpt_send_handshake_failed:
  static int
  mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag)
  {
 +	int	 r = 0;
-+
+ 
  	/* return if in use */
  	if (CHIPREG_READ32(&ioc->chip->Doorbell)
- 	    & MPI_DOORBELL_ACTIVE)
-@@ -1289,9 +1059,9 @@
+@@ -1200,7 +1060,7 @@ mpt_host_page_access_control(MPT_ADAPTER
  		 (access_control_value<<12)));
  
  	/* Wait for IOC to clear Doorbell Status bit */
--	if ((WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
+-	if (( WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
 +	if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
  		return -2;
--	} else
-+	}else
+ 	}else
  		return 0;
- }
- 
-@@ -1360,7 +1130,7 @@
- 	}
- 	flags_length = flags_length << MPI_SGE_FLAGS_SHIFT;
- 	flags_length |= ioc->HostPageBuffer_sz;
--	ioc->add_sge(psge, flags_length, ioc->HostPageBuffer_dma);
-+	mpt_add_sge(psge, flags_length, ioc->HostPageBuffer_dma);
- 	ioc->facts.HostPageBufferSGE = ioc_init->HostPageBufferSGE;
- 
- return 0;
-@@ -1433,10 +1203,21 @@
+@@ -1344,10 +1204,20 @@ mpt_bringup_adapter(MPT_ADAPTER *ioc, in
  {
  	int r;
  
@@ -17129,169 +15154,114 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +		if((r=mpt_alt_ioc_wait(ioc->alt_ioc)!=0))
 +			return r;
 +	}
-+
+ 
  	r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
  	    CAN_SLEEP);
  
--	return r;
 +	if(ioc->alt_ioc) {
 +		spin_lock(&ioc->alt_ioc->initializing_hba_lock);
 +		ioc->alt_ioc->initializing_hba_lock_flag=0;
 +		spin_unlock(&ioc->alt_ioc->initializing_hba_lock);
 +	}
 +
-+return r;
+ return r;
  }
  
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -1471,7 +1252,6 @@
+@@ -1383,8 +1253,6 @@ mpt_attach(struct pci_dev *pdev, const s
  	u8		 revision;
  	u8		 pcixcmd;
  	static int	 mpt_ids = 0;
--	unsigned long flags;
+-        unsigned long flags;
+-
  #ifdef CONFIG_PROC_FS
  	struct proc_dir_entry *dent, *ent;
  #endif
-@@ -1507,7 +1287,6 @@
+@@ -1420,7 +1288,6 @@ mpt_attach(struct pci_dev *pdev, const s
  	ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
  
  	ioc->pcidev = pdev;
--	ioc->ioc_reset_in_progress = 0;
+-        ioc->IOCResetInProgress = 0;
  	ioc->diagPending = 0;
  	spin_lock_init(&ioc->diagLock);
  	spin_lock_init(&ioc->initializing_hba_lock);
-@@ -1588,16 +1367,6 @@
- 		ioc->pio_chip = (SYSIF_REGS __iomem *)pmem;
- 	}
- 
--	if (sizeof(dma_addr_t) == sizeof(u64)) {
--		ioc->add_sge = &mpt_u64_add_sge;
--		dinitprintk((MYIOC_s_WARN_FMT "add_sge is mpt_u64_add_sge\n", 
--			ioc->name));
--	} else {
--		ioc->add_sge = &mpt_u32_add_sge;
--		dinitprintk((MYIOC_s_WARN_FMT "add_sge is mpt_u32_add_sge\n", 
--			ioc->name));
--	}
--
- 	if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC909) {
- 		ioc->prod_name = "LSIFC909";
- 		ioc->bus_type = FC;
-@@ -1651,11 +1420,8 @@
- 		ioc->errata_flag_1064 = 1;
- 	}
- 	else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC949E) {
-+		ioc->prod_name = "LSIFC949E";
- 		ioc->bus_type = FC;
--		if (pdev->vendor == 0x1657)
--			ioc->prod_name = "   BRE040";
--		else
--			ioc->prod_name = "LSIFC949E";
- 	}
- 	else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) {
- 		ioc->prod_name = "LSI53C1030";
-@@ -1691,30 +1457,15 @@
- 	else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
- 		ioc->prod_name = "LSISAS1078";
- 		ioc->bus_type = SAS;
--		if (sizeof(dma_addr_t) == sizeof(u64)) {
--			ioc->add_sge = &mpt_1078_u64_add_sge;
--			dinitprintk((MYIOC_s_WARN_FMT "resetting add_sge to mpt_1078_u64_add_sge\n", 
--				ioc->name));
--		} else {
--			ioc->add_sge = &mpt_1078_u32_add_sge;
--			dinitprintk((MYIOC_s_WARN_FMT "resetting add_sge to mpt_1078_u32_add_sge\n", 
--				ioc->name));
--		}
- 	}
- 
+@@ -1596,17 +1463,10 @@ mpt_attach(struct pci_dev *pdev, const s
  	if(ioc->errata_flag_1064) {
  		pci_disable_io_access(pdev);
  	}
- 
--	if(ioc->bus_type == FC) {
--		ioc->CheckFcLinkSpeed = 1;
--		ioc->FcLinkSpeed = 0;
--	}
+-           if(ioc->bus_type == FC) {
+-               ioc->CheckFcLinkSpeed = 1;
+-               ioc->FcLinkSpeed = 0;
+-        }
 -
+ 
  	sprintf(ioc->name, "ioc%d", ioc->id);
  
  	spin_lock_init(&ioc->FreeQlock);
--	spin_lock_init(&ioc->PendingMFlock);
+-        spin_lock_init(&ioc->PendingMFlock);
+-
  
  	/* Disable all! */
  	CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);
-@@ -1766,44 +1517,21 @@
- 	/* Check for "bound ports" (929, 929X, 1030, 1035) to reduce redundant resets.
+@@ -1659,43 +1519,22 @@ mpt_attach(struct pci_dev *pdev, const s
  	 */
  	mpt_detect_bound_ports(ioc, pdev);
--	
--	if(mpt_enable_deadioc_detect){
--		/* The following list initializations is moved from PrimeIocFifos
--	   	because the lists will not get initialize for non-operational
--	   	IOCs and which cause a crash when the lists are accessed later
--		*/
--		/* Initialize the free chain Q.*/
--
--		INIT_LIST_HEAD(&ioc->FreeChainQ);
  
--		spin_lock_irqsave(&ioc->FreeQlock, flags);
--		INIT_LIST_HEAD(&ioc->FreeQ);
--		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
--		
--		init_MUTEX(&ioc->raid_data.inactive_list_mutex);
--		INIT_LIST_HEAD(&ioc->raid_data.inactive_list);
--
--		/* Even If there is any error in IOC bringup, the IOC is allowed to
--	   	be attached with MPT drivers, This change is done to support
--	   	Firmware download boot functionality for FW dead IOC */
--		mpt_bringup_adapter(ioc, CAN_SLEEP);
--	}
--	else {
--		if ((r = mpt_bringup_adapter(ioc, CAN_SLEEP)) != 0){
--			printk(KERN_WARNING MYNAM
--		  	": WARNING - %s did not initialize properly! (%d)\n",
--		  	ioc->name, r);
+-if(mpt_enable_deadioc_detect){
+-/* The following list initializations is moved from PrimeIocFifos
+-                because the lists will not get initialize for non-operational
+-                IOCs and which cause a crash when the lists are accessed later
+-                */
+-/* Initialize the free chain Q.*/
+-
+-        INIT_LIST_HEAD(&ioc->FreeChainQ);
+-        spin_lock_irqsave(&ioc->FreeQlock, flags);
+-        INIT_LIST_HEAD(&ioc->FreeQ);
+-        spin_unlock_irqrestore(&ioc->FreeQlock, flags);
+-        init_MUTEX(&ioc->raid_data.inactive_list_mutex);
+-        INIT_LIST_HEAD(&ioc->raid_data.inactive_list);
+-
+-	/* Even If there is any error in IOC bringup, the IOC is allowed to
+-		be attached with MPT drivers, This change is done to support
+-		Firmware download boot functionality for FW dead IOC */
+-       mpt_bringup_adapter(ioc, CAN_SLEEP);
+-     }
+-
+-else {
+-        if ((r = mpt_bringup_adapter(ioc, CAN_SLEEP)) != 0){
+-            printk(KERN_WARNING MYNAM
+-               ": WARNING - %s did not initialize properly! (%d)\n",
+-               ioc->name, r);
+-               list_del(&ioc->list);
+-               free_irq(ioc->pci_irq, ioc);
+-               if (mpt_msi_enable == 1) {
+-                      pci_disable_msi(pdev);
+-               }
+-               iounmap(mem);
+-               kfree(ioc);
+-	       pci_set_drvdata(pdev, NULL);
+-               return r;
 +	if ((r = mpt_bringup_adapter(ioc, CAN_SLEEP)) != 0){
 +		printk(KERN_WARNING MYNAM
 +		  ": WARNING - %s did not initialize properly! (%d)\n",
 +		  ioc->name, r);
- 
--			list_del(&ioc->list);
--			free_irq(ioc->pci_irq, ioc);
--			if (mpt_msi_enable == 1) {
--				pci_disable_msi(pdev);
--			}
--			iounmap(mem);
--			kfree(ioc);
--			pci_set_drvdata(pdev, NULL);
--			return r;
++
 +		list_del(&ioc->list);
 +		free_irq(ioc->pci_irq, ioc);
 +		if (mpt_msi_enable == 1) {
 +			pci_disable_msi(pdev);
- 		}
++		}
 +		iounmap(mem);
 +		kfree(ioc);
 +		pci_set_drvdata(pdev, NULL);
 +		return r;
  	}
  
+-}
  	/* call per device driver probe entry point */
-@@ -1910,14 +1638,19 @@
- 			return -EAGAIN /*FIXME*/;
- 			break;
- 	}
-+
- 	printk(MYIOC_s_INFO_FMT
- 	"pci-suspend: pdev=0x%p, slot=%s, Entering operating state [D%d]\n",
- 		ioc->name, pdev, pci_name(pdev), device_state);
- 
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9))
-+	pci_save_state(pdev);
-+#else
- 	pci_save_state(pdev, ioc->PciState);
-+#endif
+ 	for(ii=0; ii<MPT_MAX_PROTOCOL_DRIVERS; ii++) {
+ 		if(MptDeviceDriverHandlers[ii] &&
+@@ -1812,7 +1651,7 @@ mpt_suspend(struct pci_dev *pdev, pm_mes
+ #endif
  
  	/* put ioc into READY_STATE */
 -	if(mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) {
@@ -17299,111 +15269,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		printk(MYIOC_s_ERR_FMT
  		"pci-suspend:  IOC msg unit reset failed!\n", ioc->name);
  	}
-@@ -1954,7 +1687,11 @@
- 		ioc->name, pdev, pci_name(pdev), device_state);
- 
- 	pci_set_power_state(pdev, 0);
-+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9))
-+	pci_restore_state(pdev);
-+#else
- 	pci_restore_state(pdev, ioc->PciState);
-+#endif
- 	pci_enable_device(pdev);
- 
- 	/* enable interrupts */
-@@ -1965,8 +1702,7 @@
+@@ -1864,8 +1703,7 @@ mpt_resume(struct pci_dev *pdev)
  	if(!CHIPREG_READ32(&ioc->chip->Doorbell)) {
  		/* enable domain validation flags */
  		for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
 -			ioc->spi_data.dvStatus[ii] |= (MPT_SCSICFG_NEED_DV |
--						       MPT_SCSICFG_DV_NOT_DONE);
+-                                                             MPT_SCSICFG_DV_NOT_DONE);
 +			ioc->spi_data.dvStatus[ii] |= MPT_SCSICFG_NEED_DV;
  		}
  	}
  
-@@ -1991,81 +1727,6 @@
- }
- #endif
- 
--
--/*
-- *	mpt_flush_running_cmds - For each command found, search
-- *		Scsi_Host instance taskQ and reply to OS.
-- *		Called only if recovering from a FW reload.
-- *	@ioc: Pointer to MPT_ADAPTER structure
-- *
-- *	Returns: None.
-- *
-- */
--static void
--mpt_flush_running_cmds(MPT_ADAPTER *ioc)
--{
--	struct scsi_cmnd	*SCpnt;
--	MPT_FRAME_HDR	*mf;
--	int		 ii;
--	int		 max = ioc->req_depth;
--
--	drsprintk((MYIOC_s_WARN_FMT ": %s entered\n", 
--		ioc->name, __FUNCTION__));
--	if (ioc->ScsiLookup == NULL)
--		return;
--	for (ii= 0; ii < max; ii++) {
--		if ((SCpnt = ioc->ScsiLookup[ii]) != NULL) {
--
--			/* Command found.
--			 */
--
--			/* Null ScsiLookup index
--			 */
--			ioc->ScsiLookup[ii] = NULL;
--
--			mf = MPT_INDEX_2_MFPTR(ioc, ii);
--
--			drsprintk((MYIOC_s_WARN_FMT "flush mf=%p sc=%p\n",
--		    		ioc->name, mf, SCpnt));
--			DBG_DUMP_RESET_REQUEST_FRAME(ioc, mf)
--
--			/* Free Chain buffers */
--			mpt_freeChainBuffers(ioc, ii);
--
--			/* Free Message frame */
--			mpt_free_msg_frame(ioc, mf);
--
--			if ((unsigned char *)mf != SCpnt->host_scribble) {
--				drsprintk(( "%s Skipping scsi_done mf=%p host_scribble=%p\n",
--					__FUNCTION__, mf, SCpnt->host_scribble));
--				continue;
--			}
--
--			/* Set status, free OS resources (SG DMA buffers)
--			 * Do OS callback
--			 * Free driver resources (chain, msg buffers)
--			 */
--			if (SCpnt->use_sg) {
--				pci_unmap_sg(ioc->pcidev,
--					(struct scatterlist *) SCpnt->request_buffer,
--					SCpnt->use_sg,
--					SCpnt->sc_data_direction);
--			} else if (SCpnt->request_bufflen) {
--				pci_unmap_single(ioc->pcidev,
--					SCpnt->SCp.dma_handle,
--					SCpnt->request_bufflen,
--					SCpnt->sc_data_direction);
--			}
--			SCpnt->result = (DID_BUS_BUSY << 16);
--//			SCpnt->result = (DID_RESET << 16);
--			SCpnt->host_scribble = NULL;
--			SCpnt->scsi_done(SCpnt);	/* Issue the command callback */
--		}
--	}
--	drsprintk((MYIOC_s_WARN_FMT ": %s exiting\n", 
--		ioc->name, __FUNCTION__));
--}
--
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-  *	mpt_do_ioc_recovery - Initialize or recover MPT adapter.
-@@ -2081,43 +1742,38 @@
+@@ -1905,19 +1743,23 @@ mpt_resume(struct pci_dev *pdev)
   *
   *	Returns:
   *		 0 for success
@@ -17414,11 +15290,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
   *		-3 if READY but PrimeIOCFifos Failed
   *		-4 if READY but IOCInit Failed
   */
--int
+-int mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
+-{       unsigned long flags;
 +static int
- mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
- {
--	unsigned long flags;
++mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
++{
  	int	 hard_reset_done = 0;
 +	int	 alt_ioc_ready = 0;
  	int	 hard;
@@ -17426,31 +15302,24 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	int	 ii;
 +	int	 handlers;
  	int	 ret = 0;
+-
 +	int	 reset_alt_ioc_active = 0;
  
--	printk(KERN_WARNING MYNAM ": Initiating %s %s\n",
-+	printk(KERN_INFO MYNAM ": Initiating %s %s\n",
+ 	printk(KERN_INFO MYNAM ": Initiating %s %s\n",
  			ioc->name, reason==MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery");
- 
- 	/* Disable reply interrupts (also blocks FreeQ) */
+@@ -1926,15 +1768,13 @@ int mpt_do_ioc_recovery(MPT_ADAPTER *ioc
  	CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);
--
--	spin_lock_irqsave(&ioc->diagLock, flags);
--	ioc->ioc_reset_in_progress = 1;
--	spin_unlock_irqrestore(&ioc->diagLock, flags);
--
--	mpt_flush_running_cmds(ioc);
  	ioc->active = 0;
  
--	/* If an event notification has not returned
--	 * its request frame,
--	 * free resources associated with this request.
--	 */
--	if (ioc->evnp) {
--		drsprintk((MYIOC_s_WARN_FMT "do_ioc_recovery: freeing evnp=%p\n",
--			   ioc->name, ioc->evnp));
--		mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)ioc->evnp);
--		ioc->evnp = NULL;
+-/* If an event notification has not returned
+- * its request frame,
+- * free resources associated with this request.
+- */
+-        if (ioc->evnp) {
+-            drsprintk((MYIOC_s_WARN_FMT "do_ioc_recovery: freeing evnp=%p\n",
+-                 ioc->name, ioc->evnp));
+-            mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)ioc->evnp);
+-            ioc->evnp = NULL;
 +	if (ioc->alt_ioc) {
 +		if (ioc->alt_ioc->active)
 +			reset_alt_ioc_active = 1;
@@ -17461,7 +15330,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	}
  
  	hard = 1;
-@@ -2128,37 +1784,68 @@
+@@ -1945,39 +1785,68 @@ int mpt_do_ioc_recovery(MPT_ADAPTER *ioc
  		if (hard_reset_done == -4) {
  			printk(KERN_WARNING MYNAM ": %s Owned by PEER..skipping!\n",
  					ioc->name);
@@ -17478,19 +15347,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			printk(KERN_WARNING MYNAM ": %s NOT READY WARNING!\n",
  					ioc->name);
  		}
--		spin_lock_irqsave(&ioc->diagLock, flags);
--		ioc->ioc_reset_in_progress = 0;
--		spin_unlock_irqrestore(&ioc->diagLock, flags);
+-
+-               spin_lock_irqsave(&ioc->diagLock, flags);
+-               ioc->IOCResetInProgress = 0;
+-               spin_unlock_irqrestore(&ioc->diagLock, flags);
  		return -1;
  	}
  
--	if (reason == MPT_HOSTEVENT_IOC_BRINGUP || 
--						mpt_enable_deadioc_detect){
--		for (ii=0; ii<5; ii++) {
--			/* Get IOC facts! Allow 5 retries */
--			if ((rc = GetIocFacts(ioc, sleepFlag, reason)) == 0)
--				break;
--		}
 +	/* hard_reset_done = 0 if a soft reset was performed
 +	 * and 1 if a hard reset was performed.
 +	 */
@@ -17502,27 +15365,34 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +					": alt-%s: Not ready WARNING!\n",
 +					ioc->alt_ioc->name);
 +	}
- 
++
 +	for (ii=0; ii<5; ii++) {
 +		/* Get IOC facts! Allow 5 retries */
 +		if ((rc = GetIocFacts(ioc, sleepFlag, reason)) == 0)
 +			break;
 +	}
  
--		if (ii == 5) {
--			dinitprintk((MYIOC_s_INFO_FMT "Retry IocFacts failed rc=%x\n", ioc->name, rc));
--			ret = -2;
--		} else {
--			if (reason == MPT_HOSTEVENT_IOC_BRINGUP)
--				MptDisplayIocCapabilities(ioc);
-+
+-if (reason == MPT_HOSTEVENT_IOC_BRINGUP ||
+-                        mpt_enable_deadioc_detect){
+-             for (ii=0; ii<5; ii++) {
+-                /* Get IOC facts! Allow 5 retries */
+-                   if ((rc = GetIocFacts(ioc, sleepFlag, reason)) == 0)
+-                               break;
+-}
+ 
 +	if (ii == 5) {
 +		dinitprintk((MYIOC_s_INFO_FMT "Retry IocFacts failed rc=%x\n", ioc->name, rc));
 +		ret = -2;
 +	} else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
 +		MptDisplayIocCapabilities(ioc);
 +	}
-+
+ 
+-if(ii==5) {
+-dinitprintk((MYIOC_s_INFO_FMT "Retry IocFacts failed rc=%x\n", ioc->name , rc));
+-             ret = -2;
+-        } else {
+-       if (reason == MPT_HOSTEVENT_IOC_BRINGUP)
+-         MptDisplayIocCapabilities(ioc);
 +	if (alt_ioc_ready) {
 +		if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) {
 +			dinitprintk((MYIOC_s_INFO_FMT "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc));
@@ -17546,7 +15416,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	 */
  	if ((ret == 0) && ((rc = PrimeIocFifos(ioc)) != 0))
  		ret = -3;
-@@ -2168,6 +1855,23 @@
+@@ -1987,6 +1856,23 @@ dinitprintk((MYIOC_s_INFO_FMT "Retry Ioc
  	 */
  	if ((ret == 0) && ((rc = SendIocInit(ioc, sleepFlag)) != 0))
  		ret = -4;
@@ -17570,7 +15440,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  	if (reason == MPT_HOSTEVENT_IOC_BRINGUP){
  		if (ioc->upload_fw) {
-@@ -2205,6 +1909,13 @@
+@@ -2024,6 +1910,13 @@ dinitprintk((MYIOC_s_INFO_FMT "Retry Ioc
  		ioc->active = 1;
  	}
  
@@ -17584,7 +15454,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  	/*  Enable MPT base driver management of EventNotification
  	 *  and EventAck handling.
-@@ -2212,6 +1923,9 @@
+@@ -2031,6 +1924,9 @@ dinitprintk((MYIOC_s_INFO_FMT "Retry Ioc
  	if ((ret == 0) && (!ioc->facts.EventState))
  		(void) SendEventNotification(ioc, 1);	/* 1=Enable EventNotification */
  
@@ -17594,7 +15464,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	/*	Add additional "reason" check before call to GetLanConfigPages
  	 *	(combined with GetIoUnitPage2 call).  This prevents a somewhat
  	 *	recursive scenario; GetLanConfigPages times out, timer expired
-@@ -2219,30 +1933,32 @@
+@@ -2038,30 +1934,32 @@ dinitprintk((MYIOC_s_INFO_FMT "Retry Ioc
  	 *	and we try GetLanConfigPages again...
  	 */
  	if ((ret == 0) && (reason == MPT_HOSTEVENT_IOC_BRINGUP)) {
@@ -17629,17 +15499,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			    MPI_IOCFACTS_EXCEPT_PERSISTENT_TABLE_FULL) {
  				ret = mptbase_sas_persist_operation(ioc,
  				    MPI_SAS_OP_CLEAR_NOT_PRESENT);
--				if(ret != 0) {
--					spin_lock_irqsave(&ioc->diagLock, flags);
--					ioc->ioc_reset_in_progress = 0;
--					spin_unlock_irqrestore(&ioc->diagLock, flags);
+-				if(ret != 0){
+-                                 spin_lock_irqsave(&ioc->diagLock, flags);
+-                                       ioc->IOCResetInProgress = 0;
+-                                       spin_unlock_irqrestore(&ioc->diagLock, flags);
 +				if(ret != 0)
  					return -1;
--				}
+-                                        }
  			}
  
  			/* Find IM volumes
-@@ -2299,11 +2015,6 @@
+@@ -2118,11 +2016,6 @@ dinitprintk((MYIOC_s_INFO_FMT "Retry Ioc
  		}
  
  		GetIoUnitPage2(ioc);
@@ -17651,24 +15521,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	}
  
  	/*
-@@ -2312,34 +2023,28 @@
+@@ -2131,35 +2024,26 @@ dinitprintk((MYIOC_s_INFO_FMT "Retry Ioc
  	 * NOTE: If we're doing _IOC_BRINGUP, there can be no
  	 * MptResetHandlers[] registered yet.
  	 */
--	if (ret == 0) {
--		rc = 0;
+-	         if (ret == 0) {
+-                       rc = 0;
+-
+-               for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
+-                         if (MptResetHandlers[ii]) {
+-       drsprintk((MYIOC_s_INFO_FMT "Calling IOC post_reset handler #%d\ n",ioc->name, ii));
+-
 +	if (hard_reset_done) {
 +		rc = handlers = 0;
- 		for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
--			if (MptResetHandlers[ii]) {
--				drsprintk((MYIOC_s_INFO_FMT "Calling IOC post_reset handler #%d\n",
++		for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
 +			if ((ret == 0) && MptResetHandlers[ii]) {
 +				dprintk((MYIOC_s_INFO_FMT "Calling IOC post_reset handler #%d\n",
- 						ioc->name, ii));
++						ioc->name, ii));
  				rc += (*(MptResetHandlers[ii]))(ioc, MPT_IOC_POST_RESET);
 +				handlers++;
 +			}
-+
+ 
 +			if (alt_ioc_ready && MptResetHandlers[ii]) {
 +				drsprintk((MYIOC_s_INFO_FMT "Calling alt-%s post_reset handler #%d\n",
 +						ioc->name, ioc->alt_ioc->name, ii));
@@ -17679,7 +15552,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +		/* FIXME?  Examine results here? */
  	}
  
--	if (ioc->bus_type == FC) {
+-if (ioc->bus_type == FC) {
 -		ioc->FcLinkSpeedCheckNeeded = 1;
 -	}
 -
@@ -17692,16 +15565,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -	}
 -
 -	spin_lock_irqsave(&ioc->diagLock, flags);
--	ioc->ioc_reset_in_progress = 0;
+-	ioc->IOCResetInProgress = 0;
 -	spin_unlock_irqrestore(&ioc->diagLock, flags);
--	return ret;
--}
-+	return ret;
-+}
+-
+ 	return ret;
+ }
  
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-@@ -2402,11 +2107,9 @@
+@@ -2224,11 +2108,9 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc,
  static void
  mpt_adapter_disable(MPT_ADAPTER *ioc)
  {
@@ -17714,7 +15584,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	void *			request_data;
  	dma_addr_t		request_data_dma;
  	u32			request_data_sz;
-@@ -2431,7 +2134,7 @@
+@@ -2253,7 +2135,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  		if ( request_data ) {
  			request_data_sz = ioc->DiagBuffer_sz[ii];
  			request_data_dma = ioc->DiagBuffer_dma[ii];
@@ -17723,7 +15593,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 		ioc->name, ii, request_data, request_data_sz));
  			pci_free_consistent(ioc->pcidev, request_data_sz,
  				request_data,
-@@ -2442,7 +2145,7 @@
+@@ -2264,7 +2146,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  	}
  	if (ioc->alloc != NULL) {
  		sz = ioc->alloc_sz;
@@ -17732,7 +15602,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 	ioc->name, ioc->alloc, ioc->alloc_sz));
  		pci_free_consistent(ioc->pcidev, sz,
  				ioc->alloc, ioc->alloc_dma);
-@@ -2454,7 +2157,7 @@
+@@ -2276,7 +2158,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  
  	if (ioc->sense_buf_pool != NULL) {
  		sz = (ioc->req_depth * MPT_SENSE_BUFFER_ALLOC);
@@ -17741,7 +15611,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 	ioc->name, ioc->sense_buf_pool, sz));
  		pci_free_consistent(ioc->pcidev, sz,
  				ioc->sense_buf_pool, ioc->sense_buf_pool_dma);
-@@ -2464,7 +2167,7 @@
+@@ -2286,7 +2168,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  
  	if (ioc->events != NULL){
  		sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS);
@@ -17750,7 +15620,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 	ioc->name, ioc->events, sz));
  		kfree(ioc->events);
  		ioc->events = NULL;
-@@ -2473,7 +2176,7 @@
+@@ -2295,7 +2177,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  
  	if (ioc->cached_fw != NULL) {
  		sz = ioc->facts.FWImageSize;
@@ -17759,7 +15629,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 	ioc->name, ioc->cached_fw, sz));
  		pci_free_consistent(ioc->pcidev, sz,
  			ioc->cached_fw, ioc->cached_fw_dma);
-@@ -2482,29 +2185,22 @@
+@@ -2304,29 +2186,22 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  	}
  
  	if (ioc->spi_data.nvram != NULL) {
@@ -17780,7 +15650,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
 -	if (ioc->raid_data.pIocPg6 != NULL) {
 -		dexitprintk((KERN_INFO MYNAM ": %s: free raid_data.pIocPg6 @ %p\n",
--		 	ioc->name, ioc->raid_data.pIocPg6));
+-			ioc->name, ioc->raid_data.pIocPg6));
 -		kfree(ioc->raid_data.pIocPg6);
 -		ioc->raid_data.pIocPg6 = NULL;
 -	}
@@ -17792,7 +15662,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 	ioc->name, ioc->spi_data.pIocPg4, sz));
  		pci_free_consistent(ioc->pcidev, sz,
  			ioc->spi_data.pIocPg4,
-@@ -2514,43 +2210,40 @@
+@@ -2336,41 +2211,38 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  	}
  
  	if (ioc->ReqToChain != NULL) {
@@ -17832,12 +15702,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -			for (id = 0; id < ioc->DevicesPerBus; id++) {
 -				if ((pTarget = pMptTarget->Target[id])) {
 -					dexitprintk((KERN_INFO MYNAM ": %s: free bus=%d id=%d pTarget=%p\n",
--	 					ioc->name, bus, id, pTarget));
+-						ioc->name, bus, id, pTarget));
 -					kfree (pTarget);
 -				}
 -			}
 -			dexitprintk((KERN_INFO MYNAM ": %s: free bus=%d pMptTarget=%p\n",
--	 			ioc->name, bus, pMptTarget));
+-				ioc->name, bus, pMptTarget));
 -			kfree (pMptTarget);
 -		}
 +	if (ioc->sasPhyInfo != NULL) {
@@ -17846,12 +15716,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +		kfree(ioc->sasPhyInfo);
 +		ioc->sasPhyInfo = NULL;
  	}
--			
-+
+ 
  /* emoore at lsil.com : Host Page Buffer Suport, start */
- 	if (ioc->HostPageBuffer != NULL) {
- 		if((ret = mpt_host_page_access_control(ioc,
-@@ -2559,7 +2252,7 @@
+@@ -2381,7 +2253,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
  			   ": %s: host page buffers free failed (%d)!\n",
  			    __FUNCTION__, ret);
  		}
@@ -17860,7 +15727,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 	ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz));
  		pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz,
  				ioc->HostPageBuffer,
-@@ -2619,7 +2312,7 @@
+@@ -2441,7 +2313,7 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
  	dexitprintk((KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n",
  		ioc->name, sz_first-sz_last+(int)sizeof(MPT_ADAPTER), sz_first));
  	dexitprintk((KERN_INFO MYNAM ": %s: sz_first=%d sz_last=%d sizeof(MPT_ADAPTER)=%d\n",
@@ -17869,7 +15736,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  	if (ioc->alt_ioc)
  		ioc->alt_ioc->alt_ioc = NULL;
-@@ -2699,18 +2392,13 @@
+@@ -2521,17 +2393,12 @@ MakeIocReady(MPT_ADAPTER *ioc, int force
  
  	/* Get current [raw] IOC state  */
  	ioc_state = mpt_GetIocState(ioc, 0);
@@ -17880,57 +15747,67 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		ioc->DiagBuffer[ii] = NULL;
  		ioc->DiagBuffer_Status[ii] = 0;
  	}
- 
--	if (ioc->bus_type == FC) {
--		ioc->FcLinkSpeedCheckNeeded = 0;
--		ioc->FcLinkSpeedReqActive = NULL;
--	}
+-if (ioc->bus_type == FC) {
+-      ioc->FcLinkSpeedCheckNeeded = 0;
+-      ioc->FcLinkSpeedReqActive = NULL;
+-}
 -
+ 
  	/*
  	 *	Check to see if IOC got left/stuck in doorbell handshake
- 	 *	grip of death.  If so, hard reset the IOC.
-@@ -2723,12 +2411,7 @@
+@@ -2544,12 +2411,9 @@ if (ioc->bus_type == FC) {
+ 	}
  
  	/* Is it already READY? */
- 	if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) 
--	{
--		drsprintk((KERN_INFO MYNAM ": %s : MakeIocReady ioc_state=%08x = READY\n", ioc->name, ioc_state));
--		/* Dont return for SAS IOCs */
--		if (ioc->bus_type != SAS)
--			return 0;
--	}
+-	if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY)  {
+-drsprintk((KERN_INFO MYNAM ": %s : MakeIocReady ioc_state=%08x = READY\n", ioc->name, ioc_state));
+-             /* Dont return for SAS IOCs */
+-             if (ioc->bus_type != SAS)
+-               return 0;
+-              }
++	if (!statefault && (ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_READY) 
 +		return 0;
- 
++
  	/*
  	 *	Check to see if IOC is in FAULT state.
-@@ -2761,7 +2444,7 @@
+ 	 */
+@@ -2581,7 +2445,7 @@ drsprintk((KERN_INFO MYNAM ": %s : MakeI
  			return -4;
  		else {
  			if ((statefault == 0 ) && (force == 0)) {
--				if ((r = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) == 0)
+-if ((r = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) == 0)
 +				if ((r = SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) == 0)
  					return 0;
  			}
  			statefault = 3;
-@@ -2784,7 +2467,7 @@
+@@ -2604,7 +2468,7 @@ if ((r = mpt_SendIocReset(ioc, MPI_FUNCT
  			 *  BIOS or previous driver load left IOC in OP state.
  			 *  Reset messaging FIFOs.
  			 */
--			if ((r = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) != 0) {
+-if ((r = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) != 0) {
 +			if ((r = SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) != 0) {
  				printk(MYIOC_s_ERR_FMT "IOC msg unit reset failed!\n", ioc->name);
  				return -2;
  			}
-@@ -2793,7 +2476,7 @@
+@@ -2613,7 +2477,7 @@ if ((r = mpt_SendIocReset(ioc, MPI_FUNCT
  			 *  Something is wrong.  Try to get IOC back
  			 *  to a known state.
  			 */
--			if ((r = mpt_SendIocReset(ioc, MPI_FUNCTION_IO_UNIT_RESET, sleepFlag)) != 0) {
+-if ((r = mpt_SendIocReset(ioc, MPI_FUNCTION_IO_UNIT_RESET, sleepFlag)) != 0) {
 +			if ((r = SendIocReset(ioc, MPI_FUNCTION_IO_UNIT_RESET, sleepFlag)) != 0) {
  				printk(MYIOC_s_ERR_FMT "IO unit reset failed!\n", ioc->name);
  				return -3;
  			}
-@@ -2946,9 +2629,6 @@
+@@ -2629,7 +2493,7 @@ if ((r = mpt_SendIocReset(ioc, MPI_FUNCT
+ 		if (sleepFlag == CAN_SLEEP)
+ 			msleep_interruptible(1);
+ 		else
+-			MPT_MDELAY(1);  /* 1 msec delay */
++			MPT_MDELAY(1);	/* 1 msec delay */
+ 
+ 	}
+ 
+@@ -2766,9 +2630,6 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepF
  			facts->FWVersion.Word = le32_to_cpu(facts->FWVersion.Word);
  
  		facts->ProductID = le16_to_cpu(facts->ProductID);
@@ -17940,18 +15817,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		facts->CurrentHostMfaHighAddr =
  				le32_to_cpu(facts->CurrentHostMfaHighAddr);
  		facts->GlobalCredits = le16_to_cpu(facts->GlobalCredits);
-@@ -2994,9 +2674,7 @@
+@@ -2814,9 +2675,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepF
  		dinitprintk((MYIOC_s_INFO_FMT "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n",
  					ioc->name, vv, shiftFactor, r));
  
--		/* Allow dead IOCs to get detected after FWDLB*/
--		if (reason == MPT_HOSTEVENT_IOC_BRINGUP || 
--						mpt_enable_deadioc_detect) {
+-/* Allow dead IOCs to get detected after FWDLB*/
+- if (reason == MPT_HOSTEVENT_IOC_BRINGUP ||mpt_enable_deadioc_detect) {
+-
 +		if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
  			/*
  			 * Set values for this IOC's request & reply frame sizes,
  			 * and request & reply queue depths...
-@@ -3050,7 +2728,6 @@
+@@ -2870,7 +2729,6 @@ GetPortFacts(MPT_ADAPTER *ioc, int portn
  	int			 ii;
  	int			 req_sz;
  	int			 reply_sz;
@@ -17959,7 +15836,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  	/* IOC *must* NOT be in RESET state! */
  	if (ioc->last_state == MPI_IOC_STATE_RESET) {
-@@ -3093,31 +2770,6 @@
+@@ -2913,31 +2771,6 @@ GetPortFacts(MPT_ADAPTER *ioc, int portn
  	pfacts->IOCLogInfo = le32_to_cpu(pfacts->IOCLogInfo);
  	pfacts->MaxDevices = le16_to_cpu(pfacts->MaxDevices);
  	pfacts->PortSCSIID = le16_to_cpu(pfacts->PortSCSIID);
@@ -17991,7 +15868,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	pfacts->ProtocolFlags = le16_to_cpu(pfacts->ProtocolFlags);
  	pfacts->MaxPostedCmdBuffers = le16_to_cpu(pfacts->MaxPostedCmdBuffers);
  	pfacts->MaxPersistentIDs = le16_to_cpu(pfacts->MaxPersistentIDs);
-@@ -3163,11 +2815,15 @@
+@@ -2983,11 +2816,15 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepF
  	dinitprintk((MYIOC_s_INFO_FMT "upload_fw %d facts.Flags=%x\n",
  		   ioc->name, ioc->upload_fw, ioc->facts.Flags));
  
@@ -18012,7 +15889,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	dinitprintk((MYIOC_s_INFO_FMT "facts.MsgVersion=%x\n",
  		   ioc->name, ioc->facts.MsgVersion));
  /* emoore at lsil.com : Host Page Buffer Suport, start */
-@@ -3290,7 +2946,9 @@
+@@ -3110,7 +2947,9 @@ SendPortEnable(MPT_ADAPTER *ioc, int por
  
  	/* RAID FW may take a long time to enable
  	 */
@@ -18023,7 +15900,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		rc = mpt_handshake_req_reply_wait(ioc, req_sz,
  		(u32*)&port_enable, reply_sz, (u16*)&reply_buf,
  		300 /*seconds*/, sleepFlag);
-@@ -3331,7 +2989,7 @@
+@@ -3151,7 +2990,7 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
  	int sz;
  
  	sz = ioc->facts.FWImageSize;
@@ -18032,36 +15909,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
  	pci_free_consistent(ioc->pcidev, sz,
  			ioc->cached_fw, ioc->cached_fw_dma);
-@@ -3404,7 +3062,7 @@
- 	sgeoffset = sizeof(FWUpload_t) - sizeof(SGE_MPI_UNION) + sizeof(FWUploadTCSGE_t);
- 
- 	flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ | sz;
--	ioc->add_sge(&request[sgeoffset], flagsLength, ioc->cached_fw_dma);
-+	mpt_add_sge(&request[sgeoffset], flagsLength, ioc->cached_fw_dma);
- 
- 	sgeoffset += sizeof(u32) + sizeof(dma_addr_t);
- 	dinitprintk((KERN_INFO MYNAM ": Sending FW Upload (req @ %p) sgeoffset=%d \n",
-@@ -3465,45 +3123,14 @@
+@@ -3285,43 +3124,14 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFw
  	u32			 diag0val;
  	int			 count;
  	u32			*ptrFw;
--	u32			 diagRwData, doorbell;
+-	u32			 diagRwData,doorbell;
 +	u32			 diagRwData;
  	u32			 nextImage;
  	u32			 load_addr;
 +	u32 			 ioc_state=0;
  
--	ddlprintk((MYIOC_s_WARN_FMT "downloadboot: pFwHeader=%p\n",
--		ioc->name, pFwHeader));
-+	ddlprintk((MYIOC_s_INFO_FMT "downloadboot: fw size 0x%x (%d), FW Ptr %p\n",
-+				ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader));
- 
+-ddlprintk((MYIOC_s_WARN_FMT "downloadboot: pFwHeader=%p\n",ioc->name, pFwHeader));
 -	nextImage = pFwHeader->NextImageHeaderOffset;
 -	if (ioc->bus_type == SAS) {
 -		while (nextImage) {
 -			if ( (pExtImage = (MpiExtImageHeader_t *) ((char *)pFwHeader + nextImage)) ) {
 -				ddlprintk((MYIOC_s_WARN_FMT "downloadboot: SAS nextImage=%x pExtImage=%p ImageType=%x\n",
--					ioc->name, nextImage, pExtImage, 
+-					ioc->name, nextImage, pExtImage,
 -					pExtImage->ImageType));
 -			} else {
 -				ddlprintk((MYIOC_s_WARN_FMT "downloadboot: SAS nextImage=%x pExtImage=%p is NULL!\n",
@@ -18084,27 +15948,25 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -	fwSize = (pFwHeader->ImageSize + 3)/4;
 -	ptrFw = (u32 *) pFwHeader;
 -	load_addr = pFwHeader->LoadStartAddress;
--
++	ddlprintk((MYIOC_s_INFO_FMT "downloadboot: fw size 0x%x (%d), FW Ptr %p\n",
++				ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader));
+ 
 -imageFound:
 -	ddlprintk((MYIOC_s_WARN_FMT "downloadboot: fw size 0x%x (%d), FW Ptr %p load_addr=%x\n",
 -		ioc->name, fwSize, fwSize, ptrFw, load_addr));
  
  	CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
  	CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_1ST_KEY_VALUE);
-@@ -3523,10 +3150,11 @@
- 	diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
- 	CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER);
- 
-+
+@@ -3345,7 +3155,7 @@ imageFound:
  	for (count = 0; count < 30; count ++) {
  		diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
  		if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) {
--			ddlprintk((MYIOC_s_WARN_FMT "RESET_ADAPTER cleared, count=%d\n",
+-                      ddlprintk((MYIOC_s_WARN_FMT "RESET_ADAPTER cleared, count=%d\n",
 +			ddlprintk((MYIOC_s_INFO_FMT "RESET_ADAPTER cleared, count=%d\n",
  				ioc->name, count));
  			break;
  		}
-@@ -3538,7 +3166,7 @@
+@@ -3357,7 +3167,7 @@ imageFound:
  	}
  
  	if ( count == 30 ) {
@@ -18113,33 +15975,33 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		ioc->name, diag0val));
  		return -3;
  	}
-@@ -3551,8 +3179,10 @@
+@@ -3370,9 +3180,10 @@ imageFound:
  	CHIPREG_WRITE32(&ioc->chip->WriteSequence, MPI_WRSEQ_5TH_KEY_VALUE);
  
  	/* Set the DiagRwEn and Disable ARM bits */
--	diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
--	CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM));
 +	CHIPREG_WRITE32(&ioc->chip->Diagnostic, (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM));
-+
+ 
+-        diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
+-CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | (MPI_DIAG_RW_ENABLE | MPI_DIAG_DISABLE_ARM));
 +	fwSize = (pFwHeader->ImageSize + 3)/4;
 +	ptrFw = (u32 *) pFwHeader;
  
  	/* Write the LoadStartAddress to the DiagRw Address Register
  	 * using Programmed IO
-@@ -3560,51 +3190,49 @@
+@@ -3380,28 +3191,26 @@ CHIPREG_WRITE32(&ioc->chip->Diagnostic, 
  	if(ioc->errata_flag_1064) {
  		pci_enable_io_access(ioc->pcidev);
  	}
--	CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr);
--	ddlprintk((MYIOC_s_WARN_FMT "LoadStart addr written 0x%x \n",
--		ioc->name, load_addr));
+-CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr);
 +	CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->LoadStartAddress);
 +	ddlprintk((MYIOC_s_INFO_FMT "LoadStart addr written 0x%x \n",
 +		ioc->name, pFwHeader->LoadStartAddress));
  
--	ddlprintk((MYIOC_s_WARN_FMT "Write FW Image: 0x%x (%d) bytes @ %p\n",
+-ddlprintk((MYIOC_s_WARN_FMT "LoadStart addr written 0x%x \n",ioc->name, load_addr));
+-ddlprintk((MYIOC_s_WARN_FMT "Write FW Image: 0x%x (%d) bytes @ %p\n",
+-                                ioc->name, fwSize*4, fwSize*4, ptrFw));
 +	ddlprintk((MYIOC_s_INFO_FMT "Write FW Image: 0x%x (%d) bytes @ %p\n",
- 				ioc->name, fwSize*4, fwSize*4, ptrFw));
++				ioc->name, fwSize*4, fwSize*4, ptrFw));
  	while (fwSize--) {
  		CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++);
  	}
@@ -18154,39 +16016,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +	while (nextImage) {
 +		pExtImage = (MpiExtImageHeader_t *) ((char *)pFwHeader + nextImage);
  
--			load_addr = pExtImage->LoadStartAddress;
-+		load_addr = pExtImage->LoadStartAddress;
+ 		load_addr = pExtImage->LoadStartAddress;
  
--			fwSize = (pExtImage->ImageSize + 3) >> 2;
--			ptrFw = (u32 *)pExtImage;
-+		fwSize = (pExtImage->ImageSize + 3) >> 2;
-+		ptrFw = (u32 *)pExtImage;
+ 		fwSize = (pExtImage->ImageSize + 3) >> 2;
+ 		ptrFw = (u32 *)pExtImage;
  
--			ddlprintk((MYIOC_s_WARN_FMT "Write Ext Image: 0x%x (%d) bytes @ %p load_addr=%x\n",
--				ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr));
--			CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr);
+-		ddlprintk((MYIOC_s_WARN_FMT "Write Ext Image: 0x%x (%d) bytes @ %p load_addr=%x\n",
 +		ddlprintk((MYIOC_s_INFO_FMT "Write Ext Image: 0x%x (%d) bytes @ %p load_addr=%x\n",
-+						ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr));
-+		CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr);
+ 						ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr));
+ 		CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr);
  
--			while (fwSize--) {
--				CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++);
--			}
--			nextImage = pExtImage->NextImageHeaderOffset;
-+		while (fwSize--) {
-+			CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++);
- 		}
-+		nextImage = pExtImage->NextImageHeaderOffset;
+@@ -3411,18 +3220,20 @@ ddlprintk((MYIOC_s_WARN_FMT "Write FW Im
+ 		nextImage = pExtImage->NextImageHeaderOffset;
  	}
  
+- }
  	/* Write the IopResetVectorRegAddr */
--	ddlprintk((MYIOC_s_WARN_FMT "Write IopResetVector Addr=%x! \n", 			ioc->name, pFwHeader->IopResetRegAddr));
+-	ddlprintk((MYIOC_s_WARN_FMT "Write IopResetVector Addr=%x! \n", ioc->name, 	pFwHeader->IopResetRegAddr));
 +	ddlprintk((MYIOC_s_INFO_FMT "Write IopResetVector Addr=%x! \n", ioc->name, 	pFwHeader->IopResetRegAddr));
  	CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->IopResetRegAddr);
  
  	/* Write the IopResetVectorValue */
--	ddlprintk((MYIOC_s_WARN_FMT "Write IopResetVector Value=%x! \n", 
--		ioc->name, pFwHeader->IopResetVectorValue));
+-	ddlprintk((MYIOC_s_WARN_FMT "Write IopResetVector Value=%x! \n", ioc->name, pFwHeader->IopResetVectorValue));
 +	ddlprintk((MYIOC_s_INFO_FMT "Write IopResetVector Value=%x! \n", ioc->name, pFwHeader->IopResetVectorValue));
  	CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, pFwHeader->IopResetVectorValue);
  
@@ -18200,7 +16051,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		 * the ClearFlashBadSignatureBit
  		 */
  		CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000);
-@@ -3613,83 +3241,69 @@
+@@ -3431,6 +3242,16 @@ ddlprintk((MYIOC_s_WARN_FMT "Write FW Im
  		CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, 0x3F000000);
  		CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, diagRwData);
  
@@ -18217,56 +16068,48 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	}
  
  	if(ioc->errata_flag_1064) {
- 		pci_disable_io_access(ioc->pcidev);
+@@ -3438,77 +3259,48 @@ ddlprintk((MYIOC_s_WARN_FMT "Write FW Im
  	}
--	
-+
+ 
  	diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
--	ddlprintk((MYIOC_s_WARN_FMT "downloadboot: diag0val=%x, turning off PREVENT_IOC_BOOT, DISABLE_ARM\n",
+-	ddlprintk((MYIOC_s_WARN_FMT "downloadboot diag0val=%x, turning off PREVENT_IOC_BOOT, DISABLE_ARM, RW_ENABLE\n",
 +	ddlprintk((MYIOC_s_INFO_FMT "downloadboot diag0val=%x, turning off PREVENT_IOC_BOOT, DISABLE_ARM, RW_ENABLE\n",
  		ioc->name, diag0val));
--	diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM);
--	ddlprintk((MYIOC_s_WARN_FMT "downloadboot: now diag0val=%x\n",
+-
+-diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM);
+-ddlprintk((MYIOC_s_WARN_FMT "downloadboot: now diag0val=%x\n",
 +	diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM | MPI_DIAG_RW_ENABLE);
 +	ddlprintk((MYIOC_s_INFO_FMT "downloadboot now diag0val=%x\n",
  		ioc->name, diag0val));
  	CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
--	if (ioc->bus_type == SAS ) {
--		/* wait 1 sec */
--		if (sleepFlag == CAN_SLEEP)
--		{
--			msleep_interruptible(1000);
--		}
--		else
--			MPT_MDELAY(1000);
--	
--
--		diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
--		ddlprintk((MYIOC_s_WARN_FMT "downloadboot: diag0val=%x, turning off RW_ENABLE\n",
--			ioc->name, diag0val));
--		diag0val &= ~(MPI_DIAG_RW_ENABLE);
--		ddlprintk((MYIOC_s_WARN_FMT "downloadboot: now diag0val=%x\n",
--			ioc->name, diag0val));
--		CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
- 
--		diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
--		if (diag0val & MPI_DIAG_FLASH_BAD_SIG) {
--			diag0val |= MPI_DIAG_CLEAR_FLASH_BAD_SIG;
--			CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
--			diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
--		}
--		diag0val &= ~(MPI_DIAG_DISABLE_ARM);
--		CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
--		diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
--		CHIPREG_WRITE32(&ioc->chip->DiagRwAddress, 0x3f000004);
--	}
- 	/* Write 0xFF to reset the sequencer */
- 	CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
  
--	for (count = 0; count < 30; count ++) {
--		doorbell = CHIPREG_READ32(&ioc->chip->Doorbell);
+-if (ioc->bus_type == SAS ) {
+-/* wait 1 sec */
+-if (sleepFlag == CAN_SLEEP)
+-{
+-msleep_interruptible(1000);
 -
--		doorbell &= MPI_IOC_STATE_MASK;
+-}
+-else
+-MPT_MDELAY(1000);
+-
+-
+-
++	/* Write 0xFF to reset the sequencer */
++	CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
+ 
+-diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
+-ddlprintk((MYIOC_s_WARN_FMT "downloadboot: diag0val=%x, turning off RW_ENABLE\n"
+-            ioc->name, diag0val));
+-diag0val &= ~(MPI_DIAG_RW_ENABLE);
+-ddlprintk((MYIOC_s_WARN_FMT "downloadboot: now diag0val=%x\n",
+-                   ioc->name, diag0val));
+-CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
+-diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
+-if (diag0val & MPI_DIAG_FLASH_BAD_SIG) {
+-diag0val |= MPI_DIAG_CLEAR_FLASH_BAD_SIG;
+-CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
+-diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
 +	if (ioc->bus_type == SAS) {
 +		ioc_state = mpt_GetIocState(ioc, 0);
 +		if ( (GetIocFacts(ioc, sleepFlag,
@@ -18274,10 +16117,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +			ddlprintk((MYIOC_s_INFO_FMT "GetIocFacts failed: IocState=%x\n",
 +					ioc->name, ioc_state));
 +			return -EFAULT;
-+		}
-+	}
+ 		}
+-diag0val &= ~(MPI_DIAG_DISABLE_ARM);
+-CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
+-diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
+-CHIPREG_WRITE32(&ioc->chip->DiagRwAddress, 0x3f000004);
+ 	}
+-/* Write 0xFF to reset the sequencer */
+-CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
+-
+-        for (count = 0; count < 30; count ++) {
+-           doorbell = CHIPREG_READ32(&ioc->chip->Doorbell);
+-           doorbell &= MPI_IOC_STATE_MASK;
+-
+-                   if (doorbell == MPI_IOC_STATE_READY) {
  
--		if (doorbell == MPI_IOC_STATE_READY) {
 +	for (count=0; count<HZ*20; count++) {
 +		if ((ioc_state = mpt_GetIocState(ioc, 0)) & MPI_IOC_STATE_READY) {
 +			ddlprintk((MYIOC_s_INFO_FMT "downloadboot successful! (count=%d) IocState=%x\n",
@@ -18285,95 +16139,73 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			if (ioc->bus_type == SAS) {
  				return 0;
  			}
- 			if ((SendIocInit(ioc, sleepFlag)) != 0) {
+-
+-
+-	if ((SendIocInit(ioc, sleepFlag)) != 0) {
 -				ddlprintk((MYIOC_s_WARN_FMT "downloadboot: SendIocInit failed\n",
++			if ((SendIocInit(ioc, sleepFlag)) != 0) {
 +				ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit failed\n",
  					ioc->name));
  				return -EFAULT;
  			}
 -			ddlprintk((MYIOC_s_WARN_FMT "downloadboot: SendIocInit successful\n",
--				ioc->name));
 +			ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit successful\n",
-+					ioc->name));
+ 					ioc->name));
  			return 0;
  		}
--		ddlprintk((MYIOC_s_WARN_FMT "downloadboot: looking for READY STATE: doorbell=%x count=%d\n", 
--			ioc->name, doorbell, count));
--		/* wait 1 sec */
+-       ddlprintk((MYIOC_s_WARN_FMT "downloadboot: looking for READY STATE:doorbell=%x count=%d\n",ioc->name, doorbell, count));
+-                     /* wait 1 sec */
+-
  		if (sleepFlag == CAN_SLEEP)
--		{
 -			msleep_interruptible(1000);
--		}
 +			msleep_interruptible(10);
  		else
 -			MPT_MDELAY(1000);
 +			MPT_MDELAY(10);
  	}
 -	ddlprintk((MYIOC_s_WARN_FMT "downloadboot failed! IocState=%x\n",
--		ioc->name, doorbell));
 +	ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! IocState=%x\n",
-+		ioc->name, ioc_state));
+ 		ioc->name, ioc_state));
  	return -EFAULT;
  }
-+ 
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-@@ -3729,7 +3343,7 @@
+@@ -3552,7 +3344,8 @@ KickStart(MPT_ADAPTER *ioc, int force, i
  		/* Always issue a Msg Unit Reset first. This will clear some
  		 * SCSI bus hang conditions.
  		 */
--		mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag);
+-            mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag);
 +		SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag);
- 
++
  		if (sleepFlag == CAN_SLEEP)
  			msleep_interruptible(1000);
-@@ -3803,26 +3417,6 @@
+ 		else
+@@ -3624,26 +3417,6 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ign
+ 			msleep_interruptible(1);
  		else
  			MPT_MDELAY(1);
- 
--		/*
+-/*
 -		 * Call each currently registered protocol IOC reset handler
 -		 * with post-reset indication.
 -		 * NOTE: If we're doing _IOC_BRINGUP, there can be no
 -		 * MptResetHandlers[] registered yet.
--		 */
--		{
--			int	 ii;
--			int	 r = 0;
--
--			for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
--				if (MptResetHandlers[ii]) {
--					drsprintk((MYIOC_s_INFO_FMT "Calling IOC post_reset handler #%d\n",
--							ioc->name, ii));
--					r += (*(MptResetHandlers[ii]))(ioc, MPT_IOC_POST_RESET);
--				}
--			}
--			/* FIXME?  Examine results here? */
--		}
+- */
+-                  {
+-                      int	 ii;
+-                      int        r=0;
+-
+-                  for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
+-                              if (MptResetHandlers[ii]) {
+-  drsprintk((MYIOC_s_INFO_FMT "Calling IOC post_reset handler #%d\n",ioc->name, ii));
+-  r += (*(MptResetHandlers[ii]))(ioc, MPT_IOC_POST_RESET);
+-
+-   }
+-}
+-/* FIXME?  Examine results here? */
 -
+-}
+ 
  		for (count = 0; count < 60; count ++) {
  			doorbell = CHIPREG_READ32(&ioc->chip->Doorbell);
- 			doorbell &= MPI_IOC_STATE_MASK;
-@@ -3886,7 +3480,7 @@
- 
- 			diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
- 
--			drsprintk((MYIOC_s_INFO_FMT "Wrote magic DiagWriteEn sequence (%x)\n",
-+			dprintk((MYIOC_s_INFO_FMT "Wrote magic DiagWriteEn sequence (%x)\n",
- 					ioc->name, diag0val));
- 		}
- 
-@@ -3909,7 +3503,7 @@
- 		 */
- 		CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER);
- 		hard_reset_done = 1;
--		drsprintk((MYIOC_s_INFO_FMT "Diagnostic reset performed\n",
-+		dprintk((MYIOC_s_INFO_FMT "Diagnostic reset performed\n",
- 				ioc->name));
- 
- 		/*
-@@ -3924,11 +3518,11 @@
+@@ -3746,11 +3519,11 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ign
  
  			for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
  				if (MptResetHandlers[ii]) {
@@ -18387,7 +16219,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  								ioc->name, ioc->alt_ioc->name, ii));
  						r += (*(MptResetHandlers[ii]))(ioc->alt_ioc, MPT_IOC_PRE_RESET);
  					}
-@@ -4079,27 +3673,18 @@
+@@ -3901,31 +3674,18 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ign
   *
   *	Returns 0 for success, non-zero for failure.
   */
@@ -18396,33 +16228,38 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +static int
 +SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
  {
--	unsigned long flags;
+-        unsigned long flags;
  	int r;
 -	u32 state, Doorbell;
 +	u32 state;
  	int cntdn, count;
  
--	Doorbell = (reset_type<<MPI_DOORBELL_FUNCTION_SHIFT);
--	drsprintk((MYIOC_s_WARN_FMT ": %s: reset_type=%02x Doorbell=%08x!\n",
--			ioc->name, __FUNCTION__, reset_type, Doorbell));
--	CHIPREG_WRITE32(&ioc->chip->Doorbell, Doorbell);
--	if ((r = WaitForDoorbellAck(ioc, 15, sleepFlag)) < 0) {
--		drsprintk((MYIOC_s_WARN_FMT ": %s: WaitForDoorbellAck failed r=%d after IOC Reset type=%02x!\n",
--			ioc->name, __FUNCTION__, r, reset_type));
+-Doorbell = (reset_type<<MPI_DOORBELL_FUNCTION_SHIFT);
+-
+-drsprintk((MYIOC_s_WARN_FMT ": %s: reset_type=%02x Doorbell=%08x!\n",
+-ioc->name, __FUNCTION__, reset_type, Doorbell));
+-CHIPREG_WRITE32(&ioc->chip->Doorbell, Doorbell);
+-
+-if ((r = WaitForDoorbellAck(ioc, 15, sleepFlag)) < 0){
+-                drsprintk((MYIOC_s_WARN_FMT ": %s: WaitForDoorbellAck failed r=%d after IOC Rese
+-t type=%02x!\n",
+-                        ioc->name, __FUNCTION__, r, reset_type));
+- return r;
+-}
+-
+-spin_lock_irqsave(&ioc->diagLock, flags);
+-ioc->IOCResetInProgress = 1;
+-spin_unlock_irqrestore(&ioc->diagLock, flags);
+-
 +	drsprintk((KERN_INFO MYNAM ": %s: Sending IOC reset(0x%02x)!\n",
 +			ioc->name, reset_type));
 +	CHIPREG_WRITE32(&ioc->chip->Doorbell, reset_type<<MPI_DOORBELL_FUNCTION_SHIFT);
 +	if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0)
- 		return r;
--	}
--
--	spin_lock_irqsave(&ioc->diagLock, flags);
--	ioc->ioc_reset_in_progress = 1;
--	spin_unlock_irqrestore(&ioc->diagLock, flags);
++		return r;
  
  	/* FW ACK'd request, wait for READY state
  	 */
-@@ -4124,15 +3709,13 @@
+@@ -3950,13 +3710,13 @@ spin_unlock_irqrestore(&ioc->diagLock, f
  			MPT_MDELAY(1);	/* 1 msec delay */
  	}
  
@@ -18432,59 +16269,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +	 */
  	if (ioc->facts.Function)
  		ioc->facts.EventState = 0;
- 
--	spin_lock_irqsave(&ioc->diagLock, flags);
--	ioc->ioc_reset_in_progress = 0;
--	spin_unlock_irqrestore(&ioc->diagLock, flags);
--	drsprintk((MYIOC_s_WARN_FMT ": %s: IOC reset completed successfully state=%08x count=%d\n",
--		ioc->name, __FUNCTION__, state, count));
--
+-spin_lock_irqsave(&ioc->diagLock, flags);
+-ioc->IOCResetInProgress = 0;
+-spin_unlock_irqrestore(&ioc->diagLock, flags);
+-drsprintk((MYIOC_s_WARN_FMT ": %s: IOC reset completed successfully state=%08x count=%d\ n",
+-ioc->name, __FUNCTION__, state, count));
++
  	return 0;
  }
  
-@@ -4140,7 +3723,7 @@
- /*
-  *	mpt_initChainBuffers - Allocate memory for and initialize
-  *	chain buffer control arrays and spinlock.
-- *	@ioc: Pointer to MPT_ADAPTER structure
-+ *	@hd: Pointer to MPT_SCSI_HOST structure
-  */
- static int
- mpt_initChainBuffers (MPT_ADAPTER *ioc)
-@@ -4220,31 +3803,12 @@
+@@ -4044,9 +3804,8 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  	unsigned long flags;
  	dma_addr_t alloc_dma;
  	u8 *mem;
 -	int i, reply_sz, req_sz, sz, total_size, num_chain, total_num_chain;
-+	int i, reply_sz, sz, total_size, num_chain, total_num_chain;
- 	int scale, scale1, num_sge, numSGE, maxSGEs, SGE_size;
+-        int scale, scale1, num_sge, numSGE, maxSGEs, SGE_size;
 -	int max_sg_tablesize;
--	u64	dma_mask;
++	int i, reply_sz, sz, total_size, num_chain, total_num_chain;
++	int scale, scale1, num_sge, numSGE, maxSGEs, SGE_size;
  
--	dma_mask = 0;
  	/*  Prime reply FIFO...  */
  
- 	if (ioc->reply_frames == NULL) {
-- 
--		/*
--		 * 1078 errata workaround for the 36GB limitation
--		 */
--		if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078 &&
--		    ioc->dma_mask > MPT_DMA_35BIT_MASK) {
--			if (!pci_set_dma_mask(ioc->pcidev,
--			    MPT_DMA_35BIT_MASK)) {
--				dma_mask = MPT_DMA_35BIT_MASK;
--				dinitprintk((KERN_INFO MYNAM
--				    ": %s: setting 35 bit addressing for "
--				    "Request/Reply/Chain and Sense Buffers\n",
--				    ioc->name));
--			}
--		}
--
- 		/* Calculate the number of chain buffers needed per I/O
- 		 * then multiply by the maximum number of simultaneous cmds
- 		 *
-@@ -4267,13 +3831,12 @@
+@@ -4073,13 +3832,12 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  			" numSGE=%d MaxChainDepth=%d maxSGEs=%d mpt_sg_tablesize=%d\n",
  			ioc->name, ioc->req_sz, SGE_size, scale, num_sge, numSGE, 
  			ioc->facts.MaxChainDepth, maxSGEs, mpt_sg_tablesize));
@@ -18504,7 +16310,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			dinitprintk((KERN_INFO MYNAM ": %s numSGE=%d now\n",
  				ioc->name, numSGE));
  		}
-@@ -4293,12 +3856,11 @@
+@@ -4099,12 +3857,11 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  
  		numSGE = scale1 * (total_num_chain-1);
  		maxSGEs = num_sge + numSGE;
@@ -18521,26 +16327,29 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  		dinitprintk((KERN_INFO MYNAM ": %s req_depth=%d max num_chain=%d mpt_chain_alloc_percent=%d total_num_chain=%d\n",
  			ioc->name, ioc->req_depth, num_chain, mpt_chain_alloc_percent, total_num_chain));
-@@ -4310,15 +3872,14 @@
+@@ -4116,17 +3873,14 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  		dinitprintk((KERN_INFO MYNAM ": %s Total ReplyBuffer sz=%d[%x] bytes\n",
  			 	ioc->name, reply_sz, reply_sz));
  
--		req_sz = ioc->req_sz;
--		sz = (req_sz * ioc->req_depth);
+-                req_sz = ioc->req_sz;
+-                sz = (req_sz * ioc->req_depth);
+-
+-	dinitprintk((KERN_INFO MYNAM ": %s RequestBuffer sz=%d bytes, RequestDepth=%d\n",
+-				ioc->name, req_sz, ioc->req_depth));
+-
 +		sz = (ioc->req_sz * ioc->req_depth);
- 		dinitprintk((KERN_INFO MYNAM ": %s RequestBuffer sz=%d bytes, RequestDepth=%d\n",
--			 	ioc->name, req_sz, ioc->req_depth));
++		dinitprintk((KERN_INFO MYNAM ": %s RequestBuffer sz=%d bytes, RequestDepth=%d\n",
 +			 	ioc->name, ioc->req_sz, ioc->req_depth));
  		dinitprintk((KERN_INFO MYNAM ": %s Total RequestBuffer sz=%d[%x] bytes\n",
  			 	ioc->name, sz, sz));
  		total_size += sz;
  
--		sz = total_num_chain * req_sz; /* chain buffer pool size */
+-		sz = total_num_chain *req_sz; /* chain buffer pool size */
 +		sz = total_num_chain * ioc->req_sz; /* chain buffer pool size */
  		dinitprintk((KERN_INFO MYNAM ": %s Total ChainBuffer sz=%d[%x] bytes total_num_chain=%d\n",
  			 	ioc->name, sz, sz, total_num_chain));
  
-@@ -4374,14 +3935,14 @@
+@@ -4182,14 +3936,14 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  #endif
  
  		for (i = 0; i < ioc->req_depth; i++) {
@@ -18558,7 +16367,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			ioc->name, ioc->ChainBuffer, (void *)(ulong)ioc->ChainBufferDMA));
  
  		/* Initialize the free chain Q.
-@@ -4389,6 +3950,10 @@
+@@ -4197,6 +3951,10 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  
  		INIT_LIST_HEAD(&ioc->FreeChainQ);
  
@@ -18569,7 +16378,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		/* Post the chain buffers to the FreeChainQ.
  	 	*/
  		mem = (u8 *)ioc->ChainBuffer;
-@@ -4397,7 +3962,7 @@
+@@ -4205,7 +3963,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  			list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeChainQ);
  //			dinitprintk((MYIOC_s_INFO_FMT "Adding %p to FreeChainQ at %d\n",
   //				ioc->name, mf, i));
@@ -18578,7 +16387,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		}
  
  		/* Initialize Request frames linked list
-@@ -4412,7 +3977,7 @@
+@@ -4220,7 +3978,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
  
  			/*  Queue REQUESTs *internally*!  */
  			list_add_tail(&mf->u.frame.linkage.list, &ioc->FreeQ);
@@ -18587,36 +16396,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		}
  		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
  
-@@ -4444,13 +4009,6 @@
- 		alloc_dma += ioc->reply_sz;
- 	}
- 
--	if (dma_mask == MPT_DMA_35BIT_MASK) {
--		if (pci_set_dma_mask(ioc->pcidev, ioc->dma_mask)) {
--			dinitprintk((MYIOC_s_WARN_FMT "%s at %d: resetting dma_mask failed\n",
--			   ioc->name, __FUNCTION__, __LINE__));
--		}
--	}
--
- 	return 0;
- 
- out_fail:
-@@ -4470,14 +4028,6 @@
- 				ioc->sense_buf_pool, ioc->sense_buf_pool_dma);
- 		ioc->sense_buf_pool = NULL;
- 	}
--
--	if (dma_mask == MPT_DMA_35BIT_MASK) {
--		if (pci_set_dma_mask(ioc->pcidev, ioc->dma_mask)) {
--			dinitprintk((MYIOC_s_WARN_FMT "out_fail in %s at %d: resetting dma_mask failed\n",
--			   ioc->name, __FUNCTION__, __LINE__));
--		}
--	}
--
- 	return -1;
- }
- 
-@@ -4500,7 +4050,8 @@
+@@ -4293,7 +4051,8 @@ out_fail:
   *
   *	Returns 0 for success, non-zero for failure.
   */
@@ -18626,7 +16406,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		int replyBytes, u16 *u16reply, int maxwait, int sleepFlag)
  {
  	MPIDefaultReply_t *mptReply;
-@@ -4619,7 +4170,7 @@
+@@ -4412,7 +4171,7 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int
  			intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
  			if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
  				break;
@@ -18635,25 +16415,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			count++;
  		}
  	} else {
-@@ -4627,7 +4178,7 @@
+@@ -4420,7 +4179,7 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int
  			intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
  			if (! (intstat & MPI_HIS_IOP_DOORBELL_STATUS))
  				break;
--			udelay(1000);
+-                          udelay(1000);
 +			MPT_MDELAY(1);
  			count++;
  		}
  	}
-@@ -4659,7 +4210,7 @@
- WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
- {
- 	int cntdn;
--	int count = 1;
-+	int count = 0;
- 	u32 intstat=0;
- 
- 	cntdn = 1000 * howlong;
-@@ -4668,7 +4219,7 @@
+@@ -4461,7 +4220,7 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int
  			intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
  			if (intstat & MPI_HIS_DOORBELL_INTERRUPT)
  				break;
@@ -18662,25 +16433,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			count++;
  		}
  	} else {
-@@ -4676,7 +4227,7 @@
+@@ -4469,7 +4228,7 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int
  			intstat = CHIPREG_READ32(&ioc->chip->IntStatus);
  			if (intstat & MPI_HIS_DOORBELL_INTERRUPT)
  				break;
--			udelay(1000);
+-                          udelay(1000);
 +			MPT_MDELAY(1);
  			count++;
  		}
  	}
-@@ -5137,7 +4688,7 @@
- 	 *	Normalize endianness of structure data,
- 	 *	by byte-swapping all > 1 byte fields!
- 	 */
--	memcpy( ioc->board_tracer,
-+	memcpy( ioc->BoardTracerNumber,
- 	    mfgPage0->BoardTracerNumber, 16 );
- 
- 
-@@ -5151,121 +4702,560 @@
+@@ -4944,40 +4703,481 @@ GetManufPage0_exit:
  	return rc;
  }
  
@@ -18764,34 +16526,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +	cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
 +	cfg.dir = 0;	/* read */
 +	cfg.timeout = 10;
- 
--	default:
--		return -1;
--		break;
++
 +	if ((rc = mpt_config(ioc, &cfg)) != 0) {
 +		goto mpt_sas_get_info_exit;
- 	}
- 
--	printk("%s: persist_opcode=%x\n",__FUNCTION__, persist_opcode);
--
--	/* Get a MF for this command.
--	 */
--	if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
--		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
--		    ioc->name,__FUNCTION__));
--		return -1;
--        }
++	}
++
 +	if (hdr.ExtPageLength == 0) {
 +		rc = -EFAULT;
 +		goto mpt_sas_get_info_exit;
 +	}
- 
--	mpi_hdr = (MPIHeader_t *) mf;
--	sasIoUnitCntrReq = (SasIoUnitControlRequest_t *)mf;
--	memset(sasIoUnitCntrReq,0,sizeof(SasIoUnitControlRequest_t));
--	sasIoUnitCntrReq->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL;
--	sasIoUnitCntrReq->MsgContext = mpi_hdr->MsgContext;
--	sasIoUnitCntrReq->Operation = persist_opcode;
++
 +	sasIoUnitPg0_data_sz = hdr.ExtPageLength * 4;
 +	sasIoUnitPg0 = (SasIOUnitPage0_t *) pci_alloc_consistent(ioc->pcidev,
 +	    sasIoUnitPg0_data_sz, &sasIoUnitPg0_dma);
@@ -18799,78 +16543,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +		rc = -ENOMEM;
 +		goto mpt_sas_get_info_exit;
 +	}
- 
--	init_timer(&ioc->persist_timer);
--	ioc->persist_timer.data = (unsigned long) ioc;
--	ioc->persist_timer.function = mpt_timer_expired;
--	ioc->persist_timer.expires = jiffies + HZ*10 /* 10 sec */;
--	ioc->persist_wait_done=0;
--	add_timer(&ioc->persist_timer);
--	mpt_put_msg_frame(mpt_base_index, ioc, mf);
--	wait_event(mpt_waitq, ioc->persist_wait_done);
++
 +	memset((u8 *)sasIoUnitPg0, 0, sasIoUnitPg0_data_sz);
 +	cfg.physAddr = sasIoUnitPg0_dma;
 +	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
- 
--	sasIoUnitCntrReply =
--	    (SasIoUnitControlReply_t *)ioc->persist_reply_frame;
--	if ( le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) {
--		printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
--		    __FUNCTION__,
--		    sasIoUnitCntrReply->IOCStatus,
--		    sasIoUnitCntrReply->IOCLogInfo);
--		return -1;
++
 +	if ((rc = mpt_config(ioc, &cfg)) != 0) {
 +		goto mpt_sas_get_info_exit;
- 	}
- 
--	printk("%s: success\n",__FUNCTION__);
--	return 0;
--}
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
++	}
++
 +	/* save the data */
 +	ioc->numPhys = sasIoUnitPg0->NumPhys;
- 
--static void
--mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
--    MpiEventDataRaid_t * pRaidEventData)
--{
--	struct _MPT_DEVICE	*pMptTarget;
--	VirtDevice		*pTarget;
--	int 	id, bus;
--	int 	reason;
--	int 	disk;
--	int 	status;
--	int 	flags;
--	int 	state;
++
 +	dsasprintk((MYIOC_s_INFO_FMT "Number of PHYS=%d\n",
 +	    ioc->name, sasIoUnitPg0->NumPhys));
- 
--	id	= pRaidEventData->VolumeID;
--	reason	= pRaidEventData->ReasonCode;
--	disk	= pRaidEventData->PhysDiskNum;
--	status	= le32_to_cpu(pRaidEventData->SettingsStatus);
--	flags	= (status >> 0) & 0xff;
--	state	= (status >> 8) & 0xff;
++
 +	sz = ioc->numPhys * sizeof (sas_phy_info_t);
- 
--	if (reason == MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
--		return;
++
 +	if ((mem = kmalloc(sz, GFP_ATOMIC)) == NULL) {
 +		rc = -ENOMEM;
 +		goto mpt_sas_get_info_exit;
- 	}
- 
--	if ((reason >= MPI_EVENT_RAID_RC_PHYSDISK_CREATED &&
--	     reason <= MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED) ||
--	    (reason == MPI_EVENT_RAID_RC_SMART_DATA)) {
--		printk(MYIOC_s_INFO_FMT "RAID STATUS CHANGE for PhysDisk %d\n",
--			ioc->name, disk);
--	} else {
--		printk(MYIOC_s_INFO_FMT "RAID STATUS CHANGE for VolumeID %d\n",
--			ioc->name, id);
--	}
++	}
++
 +	memset(mem, 0, sz);
 +	ioc->alloc_total += sz;
 +	ioc->sasPhyInfo = (sas_phy_info_t *) mem;
@@ -19251,118 +16945,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +	case MPI_SAS_OP_CLEAR_NOT_PRESENT:
 +	case MPI_SAS_OP_CLEAR_ALL_PERSISTENT:
 +		break;
-+
-+	default:
-+		return -1;
-+		break;
-+	}
-+
-+	printk("%s: persist_opcode=%x\n",__FUNCTION__, persist_opcode);
-+
-+	/* Get a MF for this command.
-+	 */
-+	if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
-+		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
-+		    ioc->name,__FUNCTION__));
-+		return -1;
-+	}
-+
-+	mpi_hdr = (MPIHeader_t *) mf;
-+	sasIoUnitCntrReq = (SasIoUnitControlRequest_t *)mf;
-+	memset(sasIoUnitCntrReq,0,sizeof(SasIoUnitControlRequest_t));
-+	sasIoUnitCntrReq->Function = MPI_FUNCTION_SAS_IO_UNIT_CONTROL;
-+	sasIoUnitCntrReq->MsgContext = mpi_hdr->MsgContext;
-+	sasIoUnitCntrReq->Operation = persist_opcode;
-+
-+	init_timer(&ioc->persist_timer);
-+	ioc->persist_timer.data = (unsigned long) ioc;
-+	ioc->persist_timer.function = mpt_timer_expired;
-+	ioc->persist_timer.expires = jiffies + HZ*10 /* 10 sec */;
-+	ioc->persist_wait_done=0;
-+	add_timer(&ioc->persist_timer);
-+	mpt_put_msg_frame(mpt_base_index, ioc, mf);
-+	wait_event(mpt_waitq, ioc->persist_wait_done);
-+
-+	sasIoUnitCntrReply =
-+	    (SasIoUnitControlReply_t *)ioc->persist_reply_frame;
-+	if ( le16_to_cpu(sasIoUnitCntrReply->IOCStatus) != MPI_IOCSTATUS_SUCCESS) {
-+		printk("%s: IOCStatus=0x%X IOCLogInfo=0x%X\n",
-+		    __FUNCTION__,
-+		    sasIoUnitCntrReply->IOCStatus,
-+		    sasIoUnitCntrReply->IOCLogInfo);
-+		return -1;
-+	}
-+
-+	printk("%s: success\n",__FUNCTION__);
-+	return 0;
-+}
-+
-+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-+
-+static void
-+mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
-+    MpiEventDataRaid_t * pRaidEventData)
-+{
-+	int 	volume;
-+	int 	reason;
-+	int 	disk;
-+	int 	status;
-+	int 	flags;
-+	int 	state;
-+
-+	volume	= pRaidEventData->VolumeID;
-+	reason	= pRaidEventData->ReasonCode;
-+	disk	= pRaidEventData->PhysDiskNum;
-+	status	= le32_to_cpu(pRaidEventData->SettingsStatus);
-+	flags	= (status >> 0) & 0xff;
-+	state	= (status >> 8) & 0xff;
-+
-+	if (reason == MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
-+		return;
-+	}
-+
-+	if ((reason >= MPI_EVENT_RAID_RC_PHYSDISK_CREATED &&
-+	     reason <= MPI_EVENT_RAID_RC_PHYSDISK_STATUS_CHANGED) ||
-+	    (reason == MPI_EVENT_RAID_RC_SMART_DATA)) {
-+		printk(MYIOC_s_INFO_FMT "RAID STATUS CHANGE for PhysDisk %d\n",
-+			ioc->name, disk);
-+	} else {
-+		printk(MYIOC_s_INFO_FMT "RAID STATUS CHANGE for VolumeID %d\n",
-+			ioc->name, volume);
+ 
+ 	default:
+ 		return -1;
+@@ -4992,7 +5192,7 @@ mptbase_sas_persist_operation(MPT_ADAPTE
+ 		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
+ 		    ioc->name,__FUNCTION__));
+ 		return -1;
+-        }
 +	}
  
- 	switch(reason) {
- 	case MPI_EVENT_RAID_RC_VOLUME_CREATED:
-@@ -5285,17 +5275,6 @@
- 		break;
- 
- 	case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
--		bus	= pRaidEventData->VolumeBus;
--		pMptTarget = ioc->Target_List[bus];
--		pTarget = (VirtDevice *)pMptTarget->Target[id];
--		if (pTarget) {
--			if ((state == MPI_RAIDVOL0_STATUS_STATE_FAILED) ||
--			    (state == MPI_RAIDVOL0_STATUS_STATE_MISSING)) {
--				pTarget->tflags |= MPT_TARGET_FLAGS_DELETED;
--			} else {
--				pTarget->tflags &= ~MPT_TARGET_FLAGS_DELETED;
--			}
--		}
- 		printk(MYIOC_s_INFO_FMT "  volume is now %s%s%s%s\n",
- 			ioc->name,
- 			state == MPI_RAIDVOL0_STATUS_STATE_OPTIMAL
-@@ -5304,9 +5283,7 @@
- 			  ? "degraded"
- 			  : state == MPI_RAIDVOL0_STATUS_STATE_FAILED
- 			   ? "failed"
--			   : state == MPI_RAIDVOL0_STATUS_STATE_MISSING
--			    ? "missing"
--			    : "state unknown",
-+			   : "state unknown",
- 			flags & MPI_RAIDVOL0_STATUS_FLAG_ENABLED
- 			 ? ", enabled" : "",
- 			flags & MPI_RAIDVOL0_STATUS_FLAG_QUIESCED
-@@ -5525,7 +5502,7 @@
+ 	mpi_hdr = (MPIHeader_t *) mf;
+ 	sasIoUnitCntrReq = (SasIoUnitControlRequest_t *)mf;
+@@ -5303,7 +5503,7 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc
  
  				if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) {
  					ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS;
@@ -19371,28 +16966,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  						ioc->name, pPP0->Capabilities));
  				}
  				ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0;
-@@ -5656,206 +5633,24 @@
- 	ioc->spi_data.sdp1version = cfg.cfghdr.hdr->PageVersion;
- 	ioc->spi_data.sdp1length = cfg.cfghdr.hdr->PageLength;
+@@ -5452,188 +5652,6 @@ mpt_readScsiDevicePageHeaders(MPT_ADAPTE
+ 	return 0;
+ }
  
--	header.PageVersion = 0;
--	header.PageLength = 0;
--	header.PageNumber = 0;
--	header.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
--	if (mpt_config(ioc, &cfg) != 0)
--		 return -EFAULT;
--
--	ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion;
--	ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength;
--
--	dcprintk((MYIOC_s_INFO_FMT "Headers: 0: version %d length %d\n",
--			ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length));
--
--	dcprintk((MYIOC_s_INFO_FMT "Headers: 1: version %d length %d\n",
--			ioc->name, ioc->spi_data.sdp1version, ioc->spi_data.sdp1length));
--	return 0;
--}
--
 -/**
 - *	mpt_raid_phys_disk_pg0 - returns phys disk page zero
 - *	@ioc: Pointer to a Adapter Structure
@@ -19545,13 +17122,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -
 -	if (!handle_inactive_volumes)
 -		goto out;
-+	header.PageVersion = 0;
-+	header.PageLength = 0;
-+	header.PageNumber = 0;
-+	header.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
-+	if (mpt_config(ioc, &cfg) != 0)
-+		 return -EFAULT;
- 
+-
 -	down(&ioc->raid_data.inactive_list_mutex);
 -	for (i = 0; i < buffer->NumPhysDisks; i++) {
 -		if(mpt_raid_phys_disk_pg0(ioc,
@@ -19568,36 +17139,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -		component_info->d.PhysDiskBus = phys_disk.PhysDiskBus;
 -		component_info->d.PhysDiskID = phys_disk.PhysDiskID;
 -		component_info->d.PhysDiskIOC = phys_disk.PhysDiskIOC;
-+	ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion;
-+	ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength;
- 
+-
 -		list_add_tail(&component_info->list,
 -		    &ioc->raid_data.inactive_list);
 -	}
 -	up(&ioc->raid_data.inactive_list_mutex);
-+	dcprintk((MYIOC_s_INFO_FMT "Headers: 0: version %d length %d\n",
-+			ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length));
- 
+-
 - out:
 -	if (buffer)
 -		pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, buffer,
 -		    dma_handle);
-+	dcprintk((MYIOC_s_INFO_FMT "Headers: 1: version %d length %d\n",
-+			ioc->name, ioc->spi_data.sdp1version, ioc->spi_data.sdp1length));
-+	return 0;
- }
- 
+-}
+-
 -
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  /**
   *	mpt_findImVolumes - Identify IDs of hidden disks and RAID Volumes
-@@ -5879,17 +5674,9 @@
+@@ -5657,16 +5675,8 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
  	int			 jj;
  	int			 rc = 0;
  	int			 iocpage2sz;
-+	u8			 nVols, nPhys;
-+	u8			 vid, vbus, vioc;
- 
+-
 -	if (!ioc->ir_firmware)
 -		return 0;
 -
@@ -19607,11 +17169,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -	ioc->raid_data.pIocPg2 = NULL;
 -	mpt_inactive_raid_list_free(ioc);
 -	ioc->raid_data.isRaid = 0;
--	
++	u8			 nVols, nPhys;
++	u8			 vid, vbus, vioc;
+ 
  	/* Read IOCP2 header then the page.
  	 */
- 	header.PageVersion = 0;
-@@ -5918,34 +5705,53 @@
+@@ -5696,35 +5706,53 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
  	if (mpt_config(ioc, &cfg) != 0)
  		goto done_and_free;
  
@@ -19634,9 +17197,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -	if (pIoc2->NumActiveVolumes) {
 -
 -		pIocRv = pIoc2->RaidVolume;
--		/* 
--		 * WARNING - ioc->raid_data.isRaid 
--		 * doesn't consider channels 
+-		/*
+-		 * WARNING - ioc->raid_data.isRaid
+-		 * doesn't consider channels
 +	nVols = pIoc2->NumActiveVolumes;
 +	if ( nVols == 0) {
 +		/* No RAID Volume.
@@ -19668,24 +17231,26 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 +				 */
 +			}
  		}
+-	             mpt_read_ioc_pg_3(ioc);
+-                     mpt_read_ioc_pg_6(ioc);
+-        }
 +	}
-+
+ 
 +	/* Identify Hidden Physical Disk Id's */
 +	nPhys = pIoc2->NumActivePhysDisks;
 +	if (nPhys == 0) {
 +		/* No physical disks.
 +		 */
 +	} else {
- 		mpt_read_ioc_pg_3(ioc);
--		mpt_read_ioc_pg_6(ioc);
- 	}
++		mpt_read_ioc_pg_3(ioc);
++	}
  
 - done_and_free:
 +done_and_free:
  	pci_free_consistent(ioc->pcidev, iocpage2sz, pIoc2, ioc2_dma);
  
  	return rc;
-@@ -6066,65 +5872,6 @@
+@@ -5845,65 +5873,6 @@ mpt_read_ioc_pg_4(MPT_ADAPTER *ioc)
  }
  
  static void
@@ -19751,24 +17316,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
  {
  	IOCPage1_t		*pIoc1;
-@@ -6223,21 +5970,18 @@
- 	EventNotification_t	*evnp;
- 
- 	evnp = (EventNotification_t *) mpt_get_msg_frame(mpt_base_index, ioc);
--	dinitprintk((MYIOC_s_WARN_FMT "%s: evnp=%p\n",
--			   ioc->name, __FUNCTION__, evnp));
- 	if (evnp == NULL) {
- 		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
+@@ -6007,12 +5976,13 @@ SendEventNotification(MPT_ADAPTER *ioc, 
  		    ioc->name,__FUNCTION__));
  		return 0;
  	}
 -	ioc->evnp = evnp;
--
- 	memset(evnp, 0, sizeof(*evnp));
+-        memset(evnp, 0, sizeof(*evnp));
++	memset(evnp, 0, sizeof(*evnp));
  
--	devtprintk((MYIOC_s_WARN_FMT "%s: (%d) request %p\n", 
--		ioc->name, __FUNCTION__, EvSwitch, evnp));
-+	devtprintk((MYIOC_s_INFO_FMT "Sending EventNotification (%d) request %p\n", ioc->name, EvSwitch, evnp));
+ 	devtprintk((MYIOC_s_INFO_FMT "Sending EventNotification (%d) request %p\n", ioc->name, EvSwitch, evnp));
  
  	evnp->Function = MPI_FUNCTION_EVENT_NOTIFICATION;
 +	evnp->ChainOffset = 0;
@@ -19776,13 +17332,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	evnp->Switch = EvSwitch;
  
  	mpt_put_msg_frame(mpt_base_index, ioc, (MPT_FRAME_HDR *)evnp);
-@@ -6262,11 +6006,13 @@
+@@ -6037,10 +6007,13 @@ SendEventAck(MPT_ADAPTER *ioc, EventNoti
  		return -1;
  	}
  
--	devtprintk((MYIOC_s_INFO_FMT "Sending EventAck\n", ioc->name));
--
--	memset(pAck, 0, sizeof(*pAck));
+-	devtprintk((MYIOC_s_INFO__FMT "Sending EventAck\n", ioc->name));
+-        memset(pAck, 0, sizeof(*pAck));
 +	devtprintk((MYIOC_s_WARN_FMT "Sending EventAck\n", ioc->name));
  
  	pAck->Function     = MPI_FUNCTION_EVENT_ACK;
@@ -19793,7 +17348,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	pAck->Event        = evnp->Event;
  	pAck->EventContext = evnp->EventContext;
  	DBG_DUMP_EVENT_REQUEST_FRAME(pAck);
-@@ -6306,7 +6052,7 @@
+@@ -6080,7 +6053,7 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS
  	 */
  	in_isr = in_interrupt();
  	if (in_isr) {
@@ -19802,121 +17357,67 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  				ioc->name));
  		return -EPERM;
  	}
-@@ -6359,7 +6105,7 @@
- 	if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) {
- 		flagsLength |= pExtHdr->ExtPageLength * 4;
- 
--		dcprintk((MYIOC_s_INFO_FMT "Sending Config request type %d Extended page %d and action %d\n",
-+		dcprintk((MYIOC_s_INFO_FMT "Sending Config request type %d, page %d and action %d\n",
- 			ioc->name, pReq->ExtPageType, pReq->Header.PageNumber, pReq->Action));
- 	}
- 	else {
-@@ -6369,7 +6115,7 @@
- 			ioc->name, pReq->Header.PageType, pReq->Header.PageNumber, pReq->Action));
- 	}
- 
--	ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, pCfg->physAddr);
-+	mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, pCfg->physAddr);
- 
- 	/* Append pCfg pointer to end of mf
- 	 */
-@@ -6446,9 +6192,12 @@
- 
- 	dprintk((KERN_INFO MYNAM
- 			": IOC %s_reset routed to MPT base driver!\n",
--			reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"));
-+			reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
-+			reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
- 
--	if (reset_phase == MPT_IOC_PRE_RESET) {
-+	if (reset_phase == MPT_IOC_SETUP_RESET) {
-+		;
-+	} else if (reset_phase == MPT_IOC_PRE_RESET) {
- 		/* If the internal config Q is not empty -
- 		 * delete timer. MF resources will be freed when
- 		 * the FIFO's are primed.
-@@ -6818,7 +6567,6 @@
- mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
- {
- 	int		 rc;
--	u32	 ioc_state;
- 	unsigned long	 flags;
- 
- 	dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name));
-@@ -6831,317 +6579,59 @@
+@@ -6607,12 +6580,11 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, i
  	 * mpt_do_ioc_recovery at any instant in time.
  	 */
  	spin_lock_irqsave(&ioc->diagLock, flags);
--	if (ioc->ioc_reset_in_progress){
+-	   if (ioc->IOCResetInProgress){
 +	if ((ioc->diagPending) || (ioc->alt_ioc && ioc->alt_ioc->diagPending)){
  		spin_unlock_irqrestore(&ioc->diagLock, flags);
--		dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler: ioc_reset_in_progress!\n",
--			   ioc->name));
- 		return 0;
+-	dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler: IOCResetInProgress!\n",
+-              ioc->name));
+-
+-                return 0;
++		return 0;
 +	} else {
 +		ioc->diagPending = 1;
  	}
  	spin_unlock_irqrestore(&ioc->diagLock, flags);
  
--	dtmprintk((MYIOC_s_WARN_FMT "Calling mpt_SendIocReset MUR!\n",
--		ioc->name));
--	if ((rc = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, sleepFlag)) != 0) {
--		ioc_state = mpt_GetIocState(ioc, 0);
--		dfailprintk((MYIOC_s_WARN_FMT "IOC MUR failed! ioc_state=%08x\n", ioc->name, ioc_state));
--		ioc->ioc_reset_in_progress = 0;
-+	/* FIXME: If do_ioc_recovery fails, repeat....
-+	 */
- 
--	} else {
--		dtmprintk((MYIOC_s_WARN_FMT "IOC MUR succeeded\n", ioc->name));
--		dtmprintk((MYIOC_s_WARN_FMT "Calling do_ioc_recovery! \n", ioc->name));
--		if ((rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag)) != 0) {
--			dfailprintk((MYIOC_s_ERR_FMT "- (%d) ioc_recovery failed\n", ioc->name, rc));
--		} else {
--			dtmprintk((MYIOC_s_WARN_FMT "Successful do_ioc_recovery! \n", ioc->name));
--			return 0;
-+	/* The SCSI driver needs to adjust timeouts on all current
-+	 * commands prior to the diagnostic reset being issued.
-+	 * Prevents timeouts occuring during a diagnostic reset...very bad.
-+	 * For all other protocol drivers, this is a no-op.
-+	 */
-+	{
-+		int	 ii;
-+		int	 r = 0;
-+
-+		for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
-+			if (MptResetHandlers[ii]) {
-+				dtmprintk((MYIOC_s_INFO_FMT "Calling IOC reset_setup handler #%d\n",
-+						ioc->name, ii));
-+				r += (*(MptResetHandlers[ii]))(ioc, MPT_IOC_SETUP_RESET);
+@@ -6633,6 +6605,11 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, i
+ 				dtmprintk((MYIOC_s_INFO_FMT "Calling IOC reset_setup handler #%d\n",
+ 						ioc->name, ii));
+ 				r += (*(MptResetHandlers[ii]))(ioc, MPT_IOC_SETUP_RESET);
 +				if (ioc->alt_ioc) {
 +					dtmprintk((MYIOC_s_INFO_FMT "Calling alt-%s setup reset handler #%d\n",
 +							ioc->name, ioc->alt_ioc->name, ii));
 +					r += (*(MptResetHandlers[ii]))(ioc->alt_ioc, MPT_IOC_SETUP_RESET);
 +				}
-+			}
+ 			}
  		}
  	}
- 
--
--	/* FIXME: If do_ioc_recovery fails, repeat....
--	 */
--
- 	if ((rc = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, sleepFlag)) != 0) {
- 		printk(KERN_WARNING MYNAM ": WARNING - (%d) Cannot recover %s\n",
+@@ -6642,307 +6619,23 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, i
  			rc, ioc->name);
  	}
  	ioc->reload_fw = 0;
--
- 	if (ioc->alt_ioc)
- 		ioc->alt_ioc->reload_fw = 0;
++	if (ioc->alt_ioc)
++		ioc->alt_ioc->reload_fw = 0;
  
+-	if (ioc->alt_ioc) {
+-  dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler alt_ioc: checking IOCResetInProgress=%d\n",
+-			ioc->alt_ioc->name, ioc->alt_ioc->IOCResetInProgress));
+-	spin_lock_irqsave(&ioc->alt_ioc->diagLock, flags);
+-
+-if (ioc->alt_ioc->IOCResetInProgress) {
+- dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler: alt_ioc IOCResetInProgress!\n", ioc->alt_ioc->name));
+-
+-spin_unlock_irqrestore(&ioc->alt_ioc->diagLock, flags);
+-return 0;
+-}
+-spin_unlock_irqrestore(&ioc->alt_ioc->diagLock, flags);
+-if ((rc = mpt_do_ioc_recovery(ioc->alt_ioc, MPT_HOSTEVENT_IOC_RECOVER,
+-sleepFlag)) != 0) {
+-printk(KERN_WARNING MYNAM ": WARNING - alt_%s mpt_do_ioc_recovery failed rc=%x\n", ioc->name,   rc );
+-     }
+-ioc->alt_ioc->reload_fw = 0;
+-}
+-
 +	spin_lock_irqsave(&ioc->diagLock, flags);
 +	ioc->diagPending = 0;
 +	if (ioc->alt_ioc)
 +		ioc->alt_ioc->diagPending = 0;
 +	spin_unlock_irqrestore(&ioc->diagLock, flags);
-+
+ 
  	dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler rc = %d!\n", ioc->name, rc));
  
  	return rc;
@@ -19924,7 +17425,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 -/*	mpt_writeSDP1  - write SCSI Device Page 1
-- *	@ioc: Pointer to a SCSI Host Adapter Structure 
+- *	@ioc: Pointer to a SCSI Host Adapter Structure
 - *	@portnum: IOC port number
 - *	@id: writeSDP1 for single ID
 - *	@flags: MPT_SCSICFG_ALL_IDS, MPT_SCSICFG_USE_NVRAM, MPT_SCSICFG_BLK_NEGO
@@ -19979,7 +17480,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -		if (loop_id == ioc->pfacts[portnum].PortSCSIID)
 -			continue;
 -
--		
+-
 -		pTarget = pMptTarget->Target[loop_id];
 -
 -		/* Use NVRAM to get adapter and target maximums
@@ -20111,7 +17612,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -		 */
 -		flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE | ioc->spi_data.sdp1length * 4;
 -
--		ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
+-		mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
 -
 -		/* Set up the common data portion
 -		 */
@@ -20145,7 +17646,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -}
 -
 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*	mpt_setSDP1parameters  - set SDP1 Requested and Configuration 
+-/*	mpt_setSDP1parameters  - set SDP1 Requested and Configuration
 - *	fields based on width, factor, offset and flags parameters.
 - *	@width: bus width
 - *	@factor: sync factor
@@ -20192,7 +17693,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  # define EVENT_DESCR_STR_SZ		100
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -7171,6 +6661,9 @@
+-
+-
+-
+-
+-
+ static void
+ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
+ {
+@@ -6969,6 +6662,9 @@ EventDescriptionStr(u8 event, u32 evData
  		break;
  	case MPI_EVENT_RESCAN:
  		ds = "Bus Rescan Event";
@@ -20202,7 +17711,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		break;
  	case MPI_EVENT_LINK_STATUS_CHANGE:
  		if (evData0 == MPI_EVENT_LINK_STATUS_FAILURE)
-@@ -7182,9 +6675,9 @@
+@@ -6980,9 +6676,9 @@ EventDescriptionStr(u8 event, u32 evData
  		if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LIP)
  			ds = "Loop State(LIP) Change";
  		else if (evData0 == MPI_EVENT_LOOP_STATE_CHANGE_LPE)
@@ -20214,7 +17723,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		break;
  	case MPI_EVENT_LOGOUT:
  		ds = "Logout";
-@@ -7197,6 +6690,9 @@
+@@ -6995,6 +6691,9 @@ EventDescriptionStr(u8 event, u32 evData
  		break;
  	case MPI_EVENT_INTEGRATED_RAID:
  	{
@@ -20224,7 +17733,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		u8 ReasonCode = (u8)(evData0 >> 16);
  		switch (ReasonCode) {
  		case MPI_EVENT_RAID_RC_VOLUME_CREATED :
-@@ -7246,65 +6742,36 @@
+@@ -7044,65 +6743,36 @@ EventDescriptionStr(u8 event, u32 evData
  		break;
  	case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
  	{
@@ -20304,7 +17813,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		}
  		break;
  	}
-@@ -7407,86 +6874,15 @@
+@@ -7205,86 +6875,15 @@ EventDescriptionStr(u8 event, u32 evData
  	}
  	case MPI_EVENT_SAS_DISCOVERY:
  	{
@@ -20326,11 +17835,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -		u8 phy_num = (u8)(evData0);
 -		u8 port_num = (u8)(evData0 >> 8);
 -		u8 port_width = (u8)(evData0 >> 16);
--		u8 primitive = (u8)(evData0 >> 24);
+-		u8 primative = (u8)(evData0 >> 24);
 -		snprintf(evStr, EVENT_DESCR_STR_SZ,
 -		    "SAS Broadcase Primative: phy=%d port=%d "
--		    "width=%d primitive=0x%02x",
--		    phy_num, port_num, port_width, primitive);
+-		    "width=%d primative=0x%02x",
+-		    phy_num, port_num, port_width, primative);
 -		break;
 -	}
 -
@@ -20394,29 +17903,29 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	/*
  	 *  MPT base "custom" events may be added here...
  	 */
-@@ -7531,20 +6927,24 @@
+@@ -7329,20 +6928,24 @@ ProcessEventNotification(MPT_ADAPTER *io
  	}
  
  	EventDescriptionStr(event, evData0, evStr);
--	devtprintk((MYIOC_s_DEBUG_FMT "MPT event:(%02Xh) : %s\n",
+-	devtprintk((MYIOC_s_WARN_FMT "MPT event:(%02Xh) : %s\n",
 -	    ioc->name, event, evStr));
 +	devtprintk((MYIOC_s_WARN_FMT "MPT Event=%02Xh (%s) detected!\n",
 +			ioc->name, event, evStr));
- 
--//#if defined(MPT_DEBUG) || defined(MPT_DEBUG_EVENTS)
--//	printk(KERN_WARNING MYNAM ": %s: Event data:\n", ioc->name);
--//	for (ii = 0; ii < evDataLen; ii++)
--//		printk(" %08x", le32_to_cpu(pEventReply->Data[ii]));
--//	printk("\n");
--//#endif
-+#if defined(MPT_DEBUG) || defined(MPT_DEBUG_EVENTS)
++
+ #if defined(MPT_DEBUG) || defined(MPT_DEBUG_EVENTS)
+-       printk(KERN_WARN MYNAM ": Event data:\n" KERN_INFO);
+-       for (ii = 0; ii < evDataLen; ii++)
+-               printk(" %08x", le32_to_cpu(pEventReply->Data[ii]));
+-       printk("\n");
 +	printk(KERN_INFO MYNAM ": Event data:\n" KERN_INFO);
 +	for (ii = 0; ii < evDataLen; ii++)
 +		printk(" %08x", le32_to_cpu(pEventReply->Data[ii]));
 +	printk("\n");
-+#endif
+ #endif
  
- 	/*
+-
+-       /*
++	/*
  	 *  Do general / base driver event processing
  	 */
  	switch(event) {
@@ -20427,38 +17936,42 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  	case MPI_EVENT_EVENT_CHANGE:		/* 0A */
  		if (evDataLen) {
  			u8 evState = evData0 & 0xFF;
-@@ -7561,10 +6961,6 @@
+@@ -7359,11 +6962,6 @@ ProcessEventNotification(MPT_ADAPTER *io
  		mptbase_raid_process_event_data(ioc,
  		    (MpiEventDataRaid_t *)pEventReply->Data);
  		break;
--	case MPI_EVENT_RESCAN:
--	case MPI_EVENT_LINK_STATUS_CHANGE:
--		ioc->FcLinkSpeedCheckNeeded = 1;
--		break;
+-case MPI_EVENT_RESCAN:
+-case MPI_EVENT_LINK_STATUS_CHANGE:
+-ioc->FcLinkSpeedCheckNeeded = 1;
+-break;
+-
  	default:
  		break;
  	}
-@@ -7597,8 +6993,8 @@
+@@ -7396,10 +6994,9 @@ break;
  	 */
  	for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
  		if (MptEvHandlers[ii]) {
--//			devtprintk((MYIOC_s_WARN_FMT "Routing Event to event handler #%d\n",
--//					ioc->name, ii));
+-		devtprintk((MYIOC_s_WARN_FMT "Routing Event to event handler #%d\n",
+-                                 ioc->name, ii));
+-
+-                       r += (*(MptEvHandlers[ii]))(ioc, pEventReply);
 +			devtprintk((MYIOC_s_INFO_FMT "Routing Event to event handler #%d\n",
 +					ioc->name, ii));
- 			r += (*(MptEvHandlers[ii]))(ioc, pEventReply);
++			r += (*(MptEvHandlers[ii]))(ioc, pEventReply);
  			handlers++;
  		}
-@@ -7609,7 +7005,7 @@
- 	 *  If needed, send (a single) EventAck.
- 	 */
- 	if (pEventReply->AckRequired == MPI_EVENT_NOTIFICATION_ACK_REQUIRED) {
--		devtprintk((MYIOC_s_INFO_FMT
-+		devtprintk((MYIOC_s_WARN_FMT
+ 	}
+@@ -7412,7 +7009,7 @@ break;
+ 		devtprintk((MYIOC_s_WARN_FMT
  			"EventAck required\n",ioc->name));
  		if ((ii = SendEventAck(ioc, pEventReply)) != 0) {
- 			devtprintk((MYIOC_s_WARN_FMT "SendEventAck returned %d\n",
-@@ -7799,14 +7195,20 @@
+-			devtprintk((MYIOC_s_INFO_FMT "SendEventAck returned %d\n",
++			devtprintk((MYIOC_s_WARN_FMT "SendEventAck returned %d\n",
+ 					ioc->name, ii));
+ 		}
+ 	}
+@@ -7599,14 +7196,20 @@ union loginfo_type {
  	}
  
  	if (code_desc != NULL)
@@ -20481,7 +17994,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  			originator_str[sas_loginfo.dw.originator],
  			sas_loginfo.dw.code,
  			sas_loginfo.dw.subcode);
-@@ -7825,12 +7227,7 @@
+@@ -7625,12 +7228,7 @@ static void
  mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf)
  {
  	u32 status = ioc_status & MPI_IOCSTATUS_MASK;
@@ -20495,16 +18008,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  
  	switch (status) {
  	case MPI_IOCSTATUS_INVALID_FUNCTION: /* 0x0001 */
-@@ -7839,8 +7236,6 @@
+@@ -7639,8 +7237,6 @@ mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 io
  
  	case MPI_IOCSTATUS_BUSY: /* 0x0002 */
  		desc = "Busy";
--		ddvprintk (("%s IOCSTATUS_BUSY", ioc->name));
--		DBG_DUMP_RESET_REQUEST_FRAME(ioc, mf)
+-                ddvprintk (("%s IOCSTATUS_BUSY", ioc->name));
+-                DBG_DUMP_RESET_REQUEST_FRAME(ioc, mf)
  		break;
  
  	case MPI_IOCSTATUS_INVALID_SGL: /* 0x0003 */
-@@ -7892,11 +7287,11 @@
+@@ -7692,11 +7288,11 @@ mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 io
  
  	case MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE: /* 0x0043 */
  	  {
@@ -20518,7 +18031,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  		break;
  	  }
  
-@@ -7942,17 +7337,10 @@
+@@ -7742,16 +7338,8 @@ mpt_sp_ioc_info(MPT_ADAPTER *ioc, u32 io
  		desc = "Others";
  		break;
  	}
@@ -20530,16 +18043,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -		} else {
 -			printk(MYIOC_s_WARN_FMT "IOCStatus(0x%04x): %s on Function=%02x\n", ioc->name, status, desc, function);
 -		}
--		DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mf)
+-		 DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mf)
 -	}
 +	if (desc != "")
 +		printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04x): %s\n", ioc->name, status, desc);
  }
-+
+ 
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /**
-  *	mpt_poll_interrupt - Check the status of interrupt and if any interrupt
-@@ -7969,6 +7357,7 @@
+@@ -7770,6 +7358,7 @@ mpt_poll_interrupt(MPT_ADAPTER *ioc)
  	if (intstat & MPI_HIS_REPLY_MESSAGE_INTERRUPT)
  		mpt_interrupt(0, ioc, NULL);
  }
@@ -20547,7 +18058,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  EXPORT_SYMBOL(mpt_attach);
  EXPORT_SYMBOL(mpt_detach);
-@@ -7978,6 +7367,7 @@
+@@ -7779,6 +7368,7 @@ EXPORT_SYMBOL(mpt_suspend);
  #endif
  EXPORT_SYMBOL(ioc_list);
  EXPORT_SYMBOL(mpt_can_queue);
@@ -20555,16 +18066,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
  EXPORT_SYMBOL(mpt_proc_root_dir);
  EXPORT_SYMBOL(mpt_register);
  EXPORT_SYMBOL(mpt_deregister);
-@@ -7991,7 +7381,7 @@
- EXPORT_SYMBOL(mpt_get_msg_frame);
- EXPORT_SYMBOL(mpt_put_msg_frame);
- EXPORT_SYMBOL(mpt_free_msg_frame);
--EXPORT_SYMBOL(mpt_freeChainBuffers);
-+EXPORT_SYMBOL(mpt_add_sge);
- EXPORT_SYMBOL(mpt_send_handshake_request);
- EXPORT_SYMBOL(mpt_verify_adapter);
- EXPORT_SYMBOL(mpt_GetIocState);
-@@ -7999,21 +7389,17 @@
+@@ -7800,21 +7390,16 @@ EXPORT_SYMBOL(mpt_print_ioc_summary);
  EXPORT_SYMBOL(mpt_lan_index);
  EXPORT_SYMBOL(mpt_stm_index);
  EXPORT_SYMBOL(mpt_HardResetHandler);
@@ -20585,34 +18087,24 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.c
 -EXPORT_SYMBOL(mpt_enable_deadioc_detect);
 -EXPORT_SYMBOL(mpt_handshake_req_reply_wait);
 +
-+
+ 
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  /*
-  *	fusion_init - Fusion MPT base driver initialization routine.
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptbase.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h	2009-05-11 23:24:42.000000000 -0600
-@@ -3,10 +3,10 @@
-  *      High performance SCSI + LAN / Fibre Channel device drivers.
-  *      For use with PCI chip/adapter(s):
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptbase.h linux-2.6.9-55.0.12/drivers/message/fusion/mptbase.h
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptbase.h	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptbase.h	2007-11-02 09:10:23.000000000 +0100
+@@ -5,8 +5,8 @@
   *          LSIFC9xx/LSI409xx Fibre Channel
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (    mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
   *  $Id: mptbase.h,v 1.149 2003/05/07 14:08:31 Exp $
   */
-@@ -74,18 +74,18 @@
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- 
- #ifndef MODULEAUTHOR
--#define MODULEAUTHOR	"LSI Corporation"
-+#define MODULEAUTHOR	"LSI Logic Corporation"
+@@ -78,14 +78,14 @@
  #endif
  
  #ifndef COPYRIGHT
@@ -20620,14 +18112,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 +#define COPYRIGHT	"Copyright (c) 1999-2006 " MODULEAUTHOR
  #endif
  
--#define MPT_LINUX_VERSION_COMMON	"3.12.19.00rh"
--#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.12.19.00rh"
+-#define MPT_LINUX_VERSION_COMMON	"3.02.99.00rh"
+-#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.02.99.00rh"
 +#define MPT_LINUX_VERSION_COMMON	"3.02.73rh"
 +#define MPT_LINUX_PACKAGE_NAME		"@(#)mptlinux-3.02.73rh"
  #define MPT_LINUX_MAJOR_VERSION		3
--#define MPT_LINUX_MINOR_VERSION		12
--#define MPT_LINUX_BUILD_VERSION		19
-+#define MPT_LINUX_MINOR_VERSION		02
+ #define MPT_LINUX_MINOR_VERSION		02
+-#define MPT_LINUX_BUILD_VERSION		99
 +#define MPT_LINUX_BUILD_VERSION		73
  #define MPT_LINUX_RELEASE_VERSION	00
  #define WHAT_MAGIC_STRING		"@" "(" "#" ")"
@@ -20644,45 +18135,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  #define MPT_MAX_SCSI_DEVICES		16
  #define MPT_LAST_LUN			255
  #define MPT_NON_IU_LAST_LUN		63
-@@ -137,12 +139,8 @@
+@@ -137,9 +139,6 @@
  #define	 CAN_SLEEP			1
  #define  NO_SLEEP			0
  
--#define MPT_HZ				1000
--#define MPT_JIFFY			100
+-#define MPT_HZ                         1000
+-#define MPT_JIFFY                      100
+-
  #define MPT_COALESCING_TIMEOUT		0x10
  
--#define MPT_DMA_35BIT_MASK  0x00000007ffffffffULL
--
  /*
-  * SCSI transfer rate defines.
-  */
-@@ -171,9 +169,7 @@
+@@ -170,9 +169,7 @@
  /*
   * Default MAX_SGE value.  Can be changed by using mptbase sg_count parameter.
   */
 -#ifndef CONFIG_FUSION_MAX_SGE
--#define CONFIG_FUSION_MAX_SGE	128
+-#define CONFIG_FUSION_MAX_SGE  128
 -#endif
 +#define MPT_SCSI_SG_DEPTH	128
  
  #ifdef __KERNEL__	/* { */
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -190,13 +186,11 @@
- #define MYIOC_s_NOTE_FMT		KERN_NOTICE MYNAM ": %s: "
- #define MYIOC_s_WARN_FMT		KERN_WARNING MYNAM ": %s: WARNING - "
- #define MYIOC_s_ERR_FMT			KERN_ERR MYNAM ": %s: ERROR - "
--#define MYIOC_s_DEBUG_FMT		KERN_DEBUG MYNAM ": %s: "
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-  *  MPT protocol driver defs...
-  */
--typedef void (*MPT_ADD_SGE)(char *pAddr, u32 flagslength, dma_addr_t dma_addr);
- typedef enum {
- 	MPTBASE_DRIVER,		/* MPT base class */
- 	MPTCTL_DRIVER,		/* MPT ioctl class */
-@@ -221,6 +215,8 @@
+@@ -218,6 +215,8 @@ typedef union _MPT_FRAME_TRACKER {
  	struct {
  		struct list_head        list;
  		u32			 arg1;
@@ -20691,7 +18165,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  	} linkage;
  	/*
  	 * NOTE: When request frames are free, on the linkage structure
-@@ -280,11 +276,6 @@
+@@ -277,12 +276,6 @@ typedef struct _MPT_FRAME_HDR {
  	} u;
  } MPT_FRAME_HDR;
  
@@ -20700,13 +18174,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 -		MPT_FRAME_HDR		*mf;
 -} MPT_LINKAGE;
 -
+-
  #define MPT_REQ_MSGFLAGS_DROPME		0x80
  
  typedef struct _MPT_SGL_HDR {
-@@ -338,29 +329,15 @@
+@@ -336,31 +329,15 @@ typedef struct _SYSIF_REGS
  #define MPT_TARGET_NO_NEGO_QAS		0x04
  #define MPT_TAPE_NEGO_IDP     		0x08
  
+-#if defined(CPQ_CIM)
 -struct sas_mapping{
 -	u8			id;
 -	u8			channel;
@@ -20716,17 +18192,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 -	struct list_head 	list;
 -	struct sas_mapping	os;	/* operating system mapping*/
 -	struct sas_mapping	fw;	/* firmware mapping */
--	u64			sas_address; 
+-	u64			sas_address;
 -	u32			device_info; /* specific bits for devices */
 -	u8			is_logical_volume; /* is this logical volume */
 -	u8			is_cached;	/* cached data for a removed device */
 -};
+-#endif
 -
  /*
   *	VirtDevice - FC LUN device or SCSI target device
   */
  typedef struct _VirtDevice {
--	struct _MPT_ADAPTER	*ioc;
+-        struct _MPT_ADAPTER	*ioc;
 +	struct scsi_device	*device;
  	u16			 tflags;
 -	u8			 id;
@@ -20737,12 +18214,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  	u8			 minSyncFactor;	/* 0xFF is async */
  	u8			 maxOffset;	/* 0 if async */
  	u8			 maxWidth;	/* 0 if narrow, 1 if wide */
-@@ -385,13 +362,9 @@
+@@ -385,13 +362,9 @@ typedef struct _VirtDevice {
  	u8			 pad2[4];
  	U64			 WWPN;
  	U64			 WWNN;
--	struct work_struct	 dvTask;
- 	u8			 configured_lun;
+-       struct work_struct        dvTask;
+-       u8			 configured_lun;
++	u8			 configured_lun;
  } VirtDevice;
  
 -typedef struct _MPT_DEVICE {
@@ -20751,24 +18229,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  /*
   *  Fibre Channel (SCSI) target device and associated defines...
   */
-@@ -440,24 +413,19 @@
+@@ -440,6 +413,7 @@ do { \
  #define MPT_IOCTL_STATUS_SENSE_VALID	0x08	/* Sense data is valid */
  #define MPT_IOCTL_STATUS_COMMAND_GOOD	0x10	/* Command Status GOOD */
  #define MPT_IOCTL_STATUS_TMTIMER_ACTIVE	0x20	/* The TM timer is running */
--
--#define MPT_MGMT_STATUS_RF_VALID	MPT_IOCTL_STATUS_RF_VALID
--#define MPT_MGMT_STATUS_COMMAND_GOOD	MPT_IOCTL_STATUS_COMMAND_GOOD
--#define MPT_MGMT_STATUS_DID_IOCRESET	MPT_IOCTL_STATUS_DID_IOCRESET
--#define MPT_MGMT_STATUS_SENSE_VALID	MPT_IOCTL_STATUS_SENSE_VALID
--#define MPT_MGMT_STATUS_TIMER_ACTIVE	MPT_IOCTL_STATUS_TMTIMER_ACTIVE	
 +#define MPT_IOCTL_STATUS_TM_FAILED	0x40	/* User TM request failed */
  
  #define MPTCTL_RESET_OK			0x01	/* Issue Bus Reset */
  
- typedef struct _MPT_IOCTL {
- 	struct _MPT_ADAPTER	*ioc;
--	u8			 reply[MPT_DEFAULT_FRAME_SIZE];	/* reply frame data */
-+	u8			 ReplyFrame[MPT_DEFAULT_FRAME_SIZE];	/* reply frame data */
+@@ -448,10 +422,10 @@ typedef struct _MPT_IOCTL {
+ 	u8			 ReplyFrame[MPT_DEFAULT_FRAME_SIZE];	/* reply frame data */
  	u8			 sense[MPT_SENSE_BUFFER_ALLOC];
  	int			 wait_done;	/* wake-up value for this ioc */
 +	u8			 rsvd;
@@ -20780,7 +18250,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  	struct semaphore	 sem_ioc;
  } MPT_IOCTL;
  
-@@ -468,7 +436,7 @@
+@@ -462,7 +436,7 @@ typedef struct _MPT_IOCTL {
  typedef struct _mpt_ioctl_events {
  	u32	event;		/* Specified by define above */
  	u32	eventContext;	/* Index or counter */
@@ -20789,7 +18259,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  } MPT_IOCTL_EVENTS;
  
  /*
-@@ -483,14 +451,14 @@
+@@ -477,14 +451,14 @@ typedef struct _mpt_ioctl_events {
  						/* dvStatus defines: */
  #define MPT_SCSICFG_NEGOTIATE		0x01	/* Negotiate on next IO */
  #define MPT_SCSICFG_NEED_DV		0x02	/* Schedule DV */
@@ -20797,7 +18267,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 +#define MPT_SCSICFG_DV_PENDING		0x04	/* DV on this physical id pending */
  #define MPT_SCSICFG_DV_NOT_DONE		0x08	/* DV has not been performed */
 -#define MPT_SCSICFG_PHYSDISK_DV_ONLY	0x10	/* DV only on this PhysDisk*/
--#define MPT_SCSICFG_BLK_NEGO		0x20	/* WriteSDP1 with WDTR and SDTR disabled */
+-#define MPT_SCSICFG_BLK_NEGO		0x20	/* WriteSDP1 with WDTR and SDTR disabled*/
 -#define MPT_SCSICFG_RELOAD_IOC_PG3	0x40	/* IOC Pg 3 data is obsolete */
 +#define MPT_SCSICFG_BLK_NEGO		0x10	/* WriteSDP1 with WDTR and SDTR disabled */
 +#define MPT_SCSICFG_RELOAD_IOC_PG3	0x20	/* IOC Pg 3 data is obsolete */
@@ -20808,14 +18278,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  
  typedef	struct _SpiCfgData {
  	u32		 PortFlags;
-@@ -520,40 +488,54 @@
- } SpiCfgData;
- 
- typedef	struct _SasCfgData {
--	u8		mptsas_device_queue_depth;
- 	u8		 ptClear;		/* 1 to automatically clear the
- 						 * persistent table.
- 						 * 0 to disable
+@@ -520,36 +494,48 @@ typedef	struct _SasCfgData {
  						 * automatic clearing.
  						 */
  	u8		mpt_sas_hot_plug_enable;  /* disables hot swap device remove support */
@@ -20848,7 +18311,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  /*
 - *  Adapter Structure - pci_dev specific.
 + * sas device info link list
-+ */
+  */
 +typedef struct _sas_device_info {
 +	struct list_head list;
 +	u64	SASAddress;
@@ -20878,18 +18341,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 +	u8	reserved;
 +} sas_phy_info_t;
 +
-+/*
+ /*
+- *  Adapter Structure - pci_dev specific.
 + *  Adapter Structure - pci_dev specific. Maximum: MPT_MAX_ADAPTERS
   */
  typedef struct _MPT_ADAPTER
  {
-@@ -563,21 +545,15 @@
- 	char			*prod_name;	/* "LSIFC9x9"         */
- 	SYSIF_REGS __iomem	*chip;		/* == c8817000 (mmap) */
+@@ -561,18 +547,13 @@ typedef struct _MPT_ADAPTER
  	SYSIF_REGS __iomem	*pio_chip;	/* Programmed IO (downloadboot) */
--	MPT_ADD_SGE		add_sge;	/* Pointer to add_sge function */
--	u8			 bus_type;	/* SPI/FC/SAS indicator  */
-+	u8			 bus_type;	/* Parallel SCSI i/f */
+ 	u8			 bus_type;	/* Parallel SCSI i/f */
  	u8			 pci_slot_number; /* ioc page 1 - pci slot number */
 -	u8			 ir_firmware; /* =1 if IR firmware detected */
  	u16			 deviceID;
@@ -20906,7 +18366,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  	u8			*alloc;		/* frames alloc ptr */
  	dma_addr_t		 alloc_dma;
  	u32			 alloc_sz;
-@@ -605,12 +581,7 @@
+@@ -600,12 +581,7 @@ typedef struct _MPT_ADAPTER
  	int			 req_depth;	/* Number of request frames */
  	int			 req_sz;	/* Request frame size (bytes) */
  	spinlock_t		 FreeQlock;
@@ -20919,18 +18379,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  		/* Pool of SCSI sense buffers for commands coming from
  		 * the SCSI mid-layer.  We have one 256 byte sense buffer
  		 * for each REQ entry.
-@@ -638,19 +609,15 @@
- 	SpiCfgData		spi_data;	/* Scsi config. data */
- 	RaidCfgData		raid_data;	/* Raid config. data */
- 	SasCfgData		sas_data;	/* Sas config. data */
--	MPT_IOCTL		taskmgmt_cmds;	/* TaskMgmt Structure*/
--	MPT_IOCTL		ioctl_cmds;	/* ioctl data struct place holder*/
- 	MPT_IOCTL		*ioctl;		/* ioctl data pointer */
- 	struct proc_dir_entry	*ioc_dentry;
+@@ -638,12 +614,10 @@ typedef struct _MPT_ADAPTER
  	struct _MPT_ADAPTER	*alt_ioc;	/* ptr to 929 bound adapter port */
  	spinlock_t		 diagLock;	/* diagnostic reset lock */
  	int			 diagPending;
--	int			 ioc_reset_in_progress;
+-	int                      IOCResetInProgress;
  	u32			 biosVersion;	/* BIOS version from IO Unit Page 2 */
  	int			 eventTypes;	/* Event logging parameters */
  	int			 eventContext;	/* Next event context */
@@ -20939,40 +18392,32 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  	u8			*cached_fw;	/* Pointer to FW */
  	dma_addr_t	 	cached_fw_dma;
  	struct list_head	 configQ;	/* linked list of config. requests */
-@@ -668,14 +635,12 @@
- 	FCPortPage0_t		 fc_port_page0[2];
+@@ -662,12 +636,10 @@ typedef struct _MPT_ADAPTER
  /* emoore at lsil.com - sas support - start */
  	U64			 sas_port_WWID[4];
--	u8			 board_tracer[16];
-+	u8			 BoardTracerNumber[16];
+ 	u8			 BoardTracerNumber[16];
 +	u8			 numPhys;
  	u16			 vendorID;
+-#if defined(CPQ_CIM)
 -	struct list_head	 sas_device_info_list;
 -	struct semaphore	 sas_device_info_mutex;
 -	u32			 num_ports;
+-#endif
 +	sas_phy_info_t		 *sasPhyInfo;
 +	struct list_head	 sasDeviceList;
  	struct semaphore	 hot_plug_semaphore;
--	struct semaphore	 AEN_semaphore;
--	struct work_struct	 AEN_Task;
  	struct work_struct	 mptscsih_persistTask;
  	struct timer_list	 persist_timer;	/* persist table timer */
- 	int			 persist_wait_done; /* persist completion flag */
-@@ -683,8 +648,12 @@
- /* emoore at lsil.com - sas support - end */
- 	LANPage0_t		 lan_cnfg_page0;
- 	LANPage1_t		 lan_cnfg_page1;
-+#if CONFIG_PM && (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,9))
+@@ -680,7 +652,7 @@ typedef struct _MPT_ADAPTER
  	u32           		 PciState[64];     /* save PCI state to this area */
+ #endif
+ #if defined(CPQ_CIM)
 -	u32         csmi_change_count;    /* count to track all IR events for CSMI */
-+#endif
-+#if defined(CPQ_CIM)
 +    u32         csmi_change_count;    /* count to track all IR events for CSMI */
-+#endif
+ #endif
  	/*  
  	 * Description: errata_flag_1064
- 	 * If a PCIX read occurs within 1 or 2 cycles after the chip receives
-@@ -697,11 +666,7 @@
+@@ -694,11 +666,7 @@ typedef struct _MPT_ADAPTER
  	u8			 upload_fw;	/* If set, do a fw upload */
  	u8			 reload_fw;	/* Force a FW Reload on next reset */
  	u8			 NBShiftFactor;  /* NB Shift Factor based on Block Size (Facts)  */
@@ -20985,25 +18430,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  	int			 DoneCtx;
  	int			 TaskCtx;
  	int			 InternalCtx;
-@@ -709,9 +674,6 @@
- 	int 	 		 initializing_hba_lock_flag;
- 	struct list_head	 list;
- 	struct net_device	*netdev;
--	struct scsi_cmnd	**ScsiLookup;
--	u64			 dma_mask;
--	u32			 broadcast_aen_busy;
- } MPT_ADAPTER;
- 
- /*
-@@ -725,6 +687,7 @@
- /* reset_phase defs */
- #define MPT_IOC_PRE_RESET		0
- #define MPT_IOC_POST_RESET		1
-+#define MPT_IOC_SETUP_RESET		2
- 
- /*
-  * Invent MPT host event (super-set of MPI Events)
-@@ -816,23 +779,6 @@
+@@ -811,25 +779,6 @@ typedef struct _mpt_sge {
  #define DBG_DUMP_EVENT_REQUEST_FRAME(mfp)
  #endif
  
@@ -21024,38 +18451,35 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 -#define DBG_DUMP_PENDING_REQUEST_FRAME(ioc, mfp)
 -#endif
 -
+-
+-
  #ifdef MPT_DEBUG_HOTPLUG
  #define dhotpprintk(x)  printk x
  #else
-@@ -841,59 +787,16 @@
+@@ -838,51 +787,16 @@ typedef struct _mpt_sge {
  
  #ifdef MPT_DEBUG_RESET
  #define drsprintk(x)  printk x
 -#define DBG_DUMP_RESET_REQUEST_FRAME(ioc, mfp) \
--	{	int  i, n = ioc->req_sz/4;				\
--		u32 *m = (u32 *)(mfp);					\
--		for (i=0; i<n; i++) {					\
--			if (i && ((i%8)==0))				\
--				printk("\n");				\
--			printk("%08x ", le32_to_cpu(m[i]));		\
--		}							\
--		printk("\n");						\
--	}
+-       {       int  i, n = ioc->req_sz/4;                                              \
+-               u32 *m = (u32 *)(mfp);                                  \
+-               for (i=0; i<n; i++) {                                   \
+-                       if (i && ((i%8)==0))                            \
+-                               printk("\n");                           \
+-                       printk("%08x ", le32_to_cpu(m[i]));             \
+-               }                                                       \
+-               printk("\n");                                           \
+-       }
  #else
  #define drsprintk(x)
 -#define DBG_DUMP_RESET_REQUEST_FRAME(ioc, mfp)
  #endif
  
-+//#if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
+ //#if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
  #if defined(MPT_DEBUG_MSG_FRAME)
  #define dmfprintk(x)  printk x
--#else
--#define dmfprintk(x)
-- #endif
--
--#if defined(MPT_DEBUG_REQ_FRAME)
--#define DBG_DUMP_REQUEST_FRAME(ioc, mfp) \
--	{	int  i, n = ioc->req_sz/4;				\
+-#define DBG_DUMP_REQUEST_FRAME(ioc,mfp) \
+-	{	int  i, n = ioc->req_sz/4;
 -		u32 *m = (u32 *)(mfp);					\
 -		for (i=0; i<n; i++) {					\
 -			if (i && ((i%8)==0))				\
@@ -21065,13 +18489,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 -		printk("\n");						\
 -	}
 -#else
--#define DBG_DUMP_REQUEST_FRAME(ioc, mfp)
--#endif
--
--#if defined(MPT_DEBUG_IC)
--#define dicprintk(x)  printk x
--#else
--#define dicprintk(x)
+-#define dmfprintk(x)
+-#define DBG_DUMP_REQUEST_FRAME(ioc,mfp)
 -#endif
 -
 -#if defined(MPT_DEBUG_IOS)
@@ -21080,6 +18499,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 -#define dioprintk(x)
 -#endif
 -
+-
 -#if defined(MPT_DEBUG_CSMI)
 -#define DBG_DUMP_CSMI_FRAME(mfp) \
 +#define DBG_DUMP_REQUEST_FRAME(mfp) \
@@ -21089,7 +18509,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  		for (i=0; i<n; i++) {					\
  			if (i && ((i%8)==0))				\
  				printk("\n");				\
-@@ -902,7 +805,8 @@
+@@ -891,7 +805,8 @@ typedef struct _mpt_sge {
  		printk("\n");						\
  	}
  #else
@@ -21099,72 +18519,57 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  #endif
  
  #ifdef MPT_DEBUG_SG
-@@ -929,28 +833,28 @@
+@@ -918,22 +833,28 @@ typedef struct _mpt_sge {
  #define dnegoprintk(x)
  #endif
  
--#ifdef MPT_DEBUG_IOCTL
--#define dctlprintk(x) printk x
 +#if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY)
 +#define ddvtprintk(x)  printk x
- #else
--#define dctlprintk(x)
++#else
 +#define ddvtprintk(x)
++#endif
++
+ #ifdef MPT_DEBUG_IOCTL
+ #define dctlprintk(x) printk x
+ #else
+ #define dctlprintk(x)
  #endif
  
 -#ifdef MPT_DEBUG_SAS
 -#define dsasprintk(x) printk x
-+#ifdef MPT_DEBUG_IOCTL
-+#define dctlprintk(x) printk x
- #else
--#define dsasprintk(x)
-+#define dctlprintk(x)
- #endif
- 
--#ifdef MPT_DEBUG_CSMISAS
--#define dcsmisasprintk(ioc, x) x
 +#ifdef MPT_DEBUG_REPLY
 +#define dreplyprintk(x) printk x
  #else
--#define dcsmisasprintk(ioc, x)
+-#define dsasprintk(x)
 +#define dreplyprintk(x)
  #endif
  
--#ifdef MPT_DEBUG_36GB
--#define d36GBprintk(x) printk x
+-#ifdef MPT_DEBUG_CSMISAS
+-#define dcsmisasprintk(x) printk x
 +#ifdef MPT_DEBUG_SAS
 +#define dsasprintk(x) printk x
  #else
--#define d36GBprintk(x)
+-#define dcsmisasprintk(x)
 +#define dsasprintk(x)
  #endif
  
  #ifdef MPT_DEBUG_TM
-@@ -989,7 +893,7 @@
- #define dcprintk(x)
- #endif
- 
--#if defined(MPT_DEBUG_SCSI) || defined(MPT_DEBUG)
-+#if defined(MPT_DEBUG_SCSI) || defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
- #define dsprintk(x) printk x
- #else
- #define dsprintk(x)
-@@ -1005,8 +909,7 @@
+@@ -988,8 +909,7 @@ typedef struct _mpt_sge {
  #define MPT_INDEX_2_RFPTR(ioc,idx) \
  	(MPT_FRAME_HDR*)( (u8*)(ioc)->reply_frames + (ioc)->req_sz * (idx) )
  
--#if defined(MPT_DEBUG_REPLY) || defined(MPT_DEBUG_HANDSHAKE)
+-#if defined(MPT_DEBUG_REPLY) || defined(MPT_DEBUG_MSG_FRAME) || defined(MPT_DEBUG_HANDSHAKE)
 -#define dreplyprintk(x) printk x
 +#if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME) || defined(MPT_DEBUG_HANDSHAKE)
  #define DBG_DUMP_REPLY_FRAME(mfp) \
  	{	u32 *m = (u32 *)(mfp);					\
  		int  i, n = (le32_to_cpu(m[0]) & 0x00FF0000) >> 16;	\
-@@ -1023,36 +926,9 @@
+@@ -1006,36 +926,9 @@ typedef struct _mpt_sge {
  			printk(" %08x", le32_to_cpu(m[i]));		\
  		printk("\n");						\
  	}
--#define DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mfp) \
--	{	int  i, n = ioc->req_sz/4;						\
+-#define DBG_DUMP_REPLYS_REQUEST_FRAME(ioc,mfp) \
+-	{	int  i, n = ioc->req_sz/4;;						\
 -		u32 *m = (u32 *)(mfp);					\
 -		for (i=0; i<n; i++) {					\
 -			if (i && ((i%8)==0))				\
@@ -21185,7 +18590,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 -#define dreplyprintk(x)
  #define DBG_DUMP_REPLY_FRAME(mfp)
  #define DBG_DUMP_REQUEST_FRAME_HDR(mfp)
--#define DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mfp)
+-#define DBG_DUMP_REPLYS_REQUEST_FRAME(ioc,mfp)
 -#define DBG_DUMP_SENSE_DATA(mfp)
 -#endif
 -
@@ -21196,16 +18601,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  #endif
  
  
-@@ -1110,35 +986,32 @@
- 	MPT_ADAPTER		 *ioc;
- 	int			  port;
+@@ -1095,34 +988,32 @@ typedef struct _MPT_SCSI_HOST {
  	u32			  pad0;
-+	struct scsi_cmnd	**ScsiLookup;
+ 	struct scsi_cmnd	**ScsiLookup;
  	struct scsi_device 	 *device;
 +	VirtDevice		**Targets;
  	MPT_LOCAL_REPLY		 *pLocal;		/* used for internal commands */
 -	struct timer_list	  InternalCmdTimer;
--	struct timer_list	  DVCmdTimer;
 +	struct timer_list	  timer;
  		/* Pool of memory for holding SCpnts before doing
  		 * OS callbacks. freeQ is the free pool.
@@ -21218,7 +18620,6 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
 -	u8			  rsvd[4];
 +	u8			  rsvd[2];
  	MPT_FRAME_HDR		 *cmdPtr;		/* Ptr to nonOS request */
--	MPT_FRAME_HDR		 *DVcmdPtr;		/* Ptr to DV request */
  	struct scsi_cmnd	 *abortSCpnt;
  	MPT_LOCAL_REPLY		  localReply;		/* internal cmd reply struct */
  	unsigned long		  hard_resets;		/* driver forced bus resets count */
@@ -21234,35 +18635,34 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  	long			  last_queue_full;
 -	u8			  mpt_pq_filter;
 -	u16			  tm_iocstatus;
--	u8			  tm_response_code;
 -	struct list_head	  target_reset_list;
 +	u8		 	  mpt_pq_filter;
  } MPT_SCSI_HOST;
  
+-
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -1190,30 +1063,24 @@
- extern int	 mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx);
- extern void	 mpt_device_driver_deregister(int cb_idx);
- extern MPT_FRAME_HDR	*mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc);
--extern void	 mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
- extern void	 mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
--extern void	 mpt_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx);
-+extern void	 mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
-+extern void	 mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr);
- 
--//int		 mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
--extern int	 mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, ulong timeout, int sleepFlag);
+ /*
+  *	More Dynamic Multi-Pathing stuff...
+@@ -1176,29 +1067,20 @@ extern void	 mpt_free_msg_frame(MPT_ADAP
+ extern void	 mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
+ extern void	 mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr);
+ 
+-extern int	 mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes,
+-u32 *req, ulong timeout, int sleepFlag);
+-
 +extern int	 mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req, int sleepFlag);
  extern int	 mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp);
  extern u32	 mpt_GetIocState(MPT_ADAPTER *ioc, int cooked);
  extern void	 mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buf, int *size, int len, int showlan);
  extern int	 mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
+-
 -extern int       mpt_SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag);
--extern void	 mptscsih_TM_timeout(unsigned long data);
+-extern void      mptscsih_TM_timeout(unsigned long data);
+-
  extern int	 mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *cfg);
 -extern int       mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag);
--extern int	 mpt_writeSDP1(MPT_ADAPTER *ioc, int portnum, int id, int flags);
--extern void	 mpt_setSDP1parameters (u8 width, u8 factor, u8 offset, u8 flags, int *requestedPtr, int *configurationPtr);
+-extern int       mpt_writeSDP1(MPT_ADAPTER *ioc, int portnum, int id, int flags);
+-extern void  mpt_setSDP1parameters (u8 width, u8 factor, u8 offset, u8 flags, int *requestedPtr, int *configurationPtr);
  extern void	 mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size);
  extern void	 mpt_free_fw_memory(MPT_ADAPTER *ioc);
  extern int	 mpt_findImVolumes(MPT_ADAPTER *ioc);
@@ -21276,11 +18676,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  
  /*
   *  Public data decl's...
-@@ -1249,11 +1116,10 @@
- 	else					\
- 		mdelay(n);
- 
--
+@@ -1237,7 +1119,7 @@ extern int		mpt_sg_tablesize;
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  #endif		/* } __KERNEL__ */
  
@@ -21289,21 +18685,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptbase.h
  #define CAST_U32_TO_PTR(x)	((void *)(u64)x)
  #define CAST_PTR_TO_U32(x)	((u32)(u64)x)
  #else
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptctl.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c	2009-05-11 23:24:42.000000000 -0600
-@@ -1,11 +1,11 @@
- /*
-  *  linux/drivers/message/fusion/mptctl.c
-  *      mpt Ioctl driver.
-- *      For use with LSI PCI chip/adapters
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      For use with LSI Logic PCI chip/adapters
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptctl.c linux-2.6.9-55.0.12/drivers/message/fusion/mptctl.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptctl.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptctl.c	2007-11-02 09:10:23.000000000 +0100
+@@ -4,8 +4,8 @@
+  *      For use with LSI Logic PCI chip/adapters
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
@@ -21323,10 +18713,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  #include <scsi/scsi_host.h>
  #include <scsi/scsi_tcq.h>
  
--#define COPYRIGHT	"Copyright (c) 1999-2007 LSI Corporation"
--#define MODULEAUTHOR	"LSI Corporation"
+-#define COPYRIGHT	"Copyright (c) 1999-2007 LSI Logic Corporation"
 +#define COPYRIGHT	"Copyright (c) 1999-2005 LSI Logic Corporation"
-+#define MODULEAUTHOR	"LSI Logic Corporation"
+ #define MODULEAUTHOR	"LSI Logic Corporation"
  #include "mptbase.h"
  #include "mptctl.h"
  
@@ -21338,7 +18727,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  #define my_NAME		"Fusion MPT misc device (ioctl) driver"
  #define my_VERSION	MPT_LINUX_VERSION_COMMON
-@@ -85,19 +83,14 @@
+@@ -85,12 +83,10 @@
  MODULE_AUTHOR(MODULEAUTHOR);
  MODULE_DESCRIPTION(my_NAME);
  MODULE_LICENSE("GPL");
@@ -21347,28 +18736,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  
  extern	int mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag);
- 
 -extern int	mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req, int replyBytes, u16 *u16reply, int maxwait, int sleepFlag);
--
- static int mptctl_id = -1;
--static int mptctl_taskmgmt_id = -1;
- 
- static DECLARE_WAIT_QUEUE_HEAD ( mptctl_wait );
--static DECLARE_WAIT_QUEUE_HEAD ( mptctl_taskmgmt_wait );
  
+ static int mptctl_id = -1;
  
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -121,9 +114,6 @@
- static int mptctl_eventenable(unsigned long arg);
+@@ -119,10 +115,6 @@ static int mptctl_eventenable(unsigned l
  static int mptctl_eventreport(unsigned long arg);
  static int mptctl_replace_fw(unsigned long arg);
+ 
 -#ifdef MPT_SUPPORT_FWDLB_IOCTL
 -static int mptctl_hba_pciinfo(unsigned long arg);
 -#endif
- 
+-
  static int mptctl_do_reset(unsigned long arg);
  static int mptctl_hp_hostinfo(unsigned long arg, unsigned int cmd);
-@@ -135,34 +125,37 @@
+ static int mptctl_hp_targetinfo(unsigned long arg);
+@@ -133,29 +125,27 @@ static int mptctl_unregister_diag_buffer
  static int mptctl_query_diag_buffer(unsigned long arg);
  static int mptctl_read_diag_buffer(unsigned long arg);
  #if defined(CPQ_CIM)
@@ -21419,26 +18802,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  #endif // CPQ_CIM
  
  static int  mptctl_probe(struct pci_dev *, const struct pci_device_id *);
- static void mptctl_remove(struct pci_dev *);
- 
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
-+#ifdef CONFIG_COMPAT
-+static long compat_mpctl_ioctl(struct file *f, unsigned cmd, unsigned long arg);
-+#endif /* CONFIG_COMPAT */
-+#endif /*(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))*/
- /*
-  * Private function calls.
-  */
-@@ -173,7 +166,7 @@
- 		struct buflist **blp, dma_addr_t *sglbuf_dma, MPT_ADAPTER *ioc);
- static void kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma,
- 		struct buflist *buflist, MPT_ADAPTER *ioc);
--static void mptctl_timeout_expired (MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
-+static void mptctl_timeout_expired (MPT_IOCTL *ioctl);
- static int  mptctl_bus_reset(MPT_IOCTL *ioctl);
- static int mptctl_set_tm_flags(MPT_SCSI_HOST *hd);
- static void mptctl_free_tm_flags(MPT_ADAPTER *ioc);
-@@ -227,7 +220,7 @@
+@@ -230,7 +220,7 @@ static inline int
  mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock)
  {
  	int rc = 0;
@@ -21447,7 +18811,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  
  	if (nonblock) {
  		if (down_trylock(&ioc->ioctl->sem_ioc))
-@@ -236,7 +229,7 @@
+@@ -239,7 +229,7 @@ mptctl_syscall_down(MPT_ADAPTER *ioc, in
  		if (down_interruptible(&ioc->ioctl->sem_ioc))
  			rc = -ERESTARTSYS;
  	}
@@ -21456,21 +18820,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	return rc;
  }
  
-@@ -288,7 +281,7 @@
- 		 */
- 		dctlprintk(("Copying Reply Frame @%p to ioc%d!\n",
- 			reply, ioc->id));
--		memcpy(ioc->ioctl->reply, reply,
-+		memcpy(ioc->ioctl->ReplyFrame, reply,
- 			min(ioc->reply_sz, 4*reply->u.reply.MsgLength));
- 		ioc->ioctl->status |= MPT_IOCTL_STATUS_RF_VALID;
- 
-@@ -301,17 +294,9 @@
+@@ -304,17 +294,9 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME
  
  		if ((cmd == MPI_FUNCTION_SCSI_IO_REQUEST) ||
  			(cmd == MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH)) {
 -
--			dcsmisasprintk(ioc, printk(KERN_DEBUG "\tiocstatus = 0x%x, "
+-			dcsmisasprintk(("\tiocstatus = 0x%x, "
 -				"scsi_status = 0x%x, scsi_state = 0x%x\n",
 -				reply->u.sreply.IOCStatus,
 -				reply->u.sreply.SCSIStatus,
@@ -21479,102 +18834,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			ioc->ioctl->reset &= ~MPTCTL_RESET_OK;
  
  			if ((iocStatus == MPI_IOCSTATUS_SCSI_DATA_UNDERRUN) ||
--				(iocStatus == MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH) ||
+-                                (iocStatus == MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH) ||
  				(iocStatus == MPI_IOCSTATUS_SCSI_RECOVERED_ERROR)) {
  				ioc->ioctl->status |= MPT_IOCTL_STATUS_COMMAND_GOOD;
  			}
-@@ -328,12 +313,8 @@
- 			ioc->ioctl->status |= MPT_IOCTL_STATUS_SENSE_VALID;
- 		}
- 
--		if (cmd == MPI_FUNCTION_SCSI_TASK_MGMT) {
-+		if (cmd == MPI_FUNCTION_SCSI_TASK_MGMT)
- 			mptctl_free_tm_flags(ioc);
--			del_timer(&ioc->TMtimer);
--			dctlprintk((MYIOC_s_INFO_FMT "%s: TM completed\n",
--				ioc->name, __FUNCTION__));
--		}
- 
- 		if (cmd == MPI_FUNCTION_DIAG_BUFFER_POST) {
- 
-@@ -364,58 +345,6 @@
- 	return 1;
- }
- 
--static int
--mptctl_taskmgmt_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply)
--{
--	u16 iocStatus;
--
--	dctlprintk(("mptctl_taskmgmt_reply()!\n"));
--	if (!req)
--		return 1;
--
--	if (reply==NULL) {
--
--		dctlprintk(("mptctl_taskmgmt_reply() NULL Reply Function\n"));
--
--		ioc->taskmgmt_cmds.status |= MPT_IOCTL_STATUS_COMMAND_GOOD;
--		ioc->taskmgmt_cmds.reset &= ~MPTCTL_RESET_OK;
--
--		/* We are done, issue wake up
-- 		*/
--		ioc->taskmgmt_cmds.wait_done = 1;
--		wake_up (&mptctl_taskmgmt_wait);
--		return 1;
--
--	}
--
--	/* Copy the reply frame (which much exist
--	 * for non-SCSI I/O) to the IOC structure.
--	 */
--	dctlprintk(("Copying Reply Frame @%p to ioc%d!\n",
--		reply, ioc->id));
--	memcpy(ioc->taskmgmt_cmds.reply, reply,
--		min(ioc->reply_sz, 4*reply->u.reply.MsgLength));
--	ioc->taskmgmt_cmds.status |= MPT_IOCTL_STATUS_RF_VALID;
--
--	/* Set the command status to GOOD if IOC Status is GOOD
--	 * OR if SCSI I/O cmd and data underrun or recovered error.
--	 */
--	iocStatus = le16_to_cpu(reply->u.reply.IOCStatus) & MPI_IOCSTATUS_MASK;
--	if (iocStatus  == MPI_IOCSTATUS_SUCCESS)
--		ioc->taskmgmt_cmds.status |= MPT_IOCTL_STATUS_COMMAND_GOOD;
--
--	mptctl_free_tm_flags(ioc);
--
--
--	/* We are done, issue wake up
--	 */
--	ioc->taskmgmt_cmds.wait_done = 1;
--	wake_up (&mptctl_taskmgmt_wait);
--	return 1;
--}
--
--
--
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /* mptctl_timer_expired
-  *
-@@ -423,13 +352,14 @@
-  *
-  */
- static void
--mptctl_timeout_expired (MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
-+mptctl_timeout_expired (MPT_IOCTL *ioctl)
- {
- 	int rc = 1;
--	MPT_IOCTL *ioctl = ioc->ioctl;
- 
- 	dctlprintk((KERN_NOTICE MYNAM ": Timeout Expired! Host %d\n",
--				ioc->id));
-+				ioctl->ioc->id));
-+	if (ioctl == NULL)
-+		return;
- 
- 	ioctl->wait_done = 0;
- 	if (ioctl->reset & MPTCTL_RESET_OK)
-@@ -490,8 +420,8 @@
+@@ -438,8 +420,8 @@ mptctl_bus_reset(MPT_IOCTL *ioctl)
  			ioctl->ioc->name, mf));
  
  	pScsiTm = (SCSITaskMgmt_t *) mf;
@@ -21585,48 +18849,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	pScsiTm->ChainOffset = 0;
  	pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
  	pScsiTm->Reserved = 0;
-@@ -512,7 +442,7 @@
+@@ -460,7 +442,7 @@ mptctl_bus_reset(MPT_IOCTL *ioctl)
  
  	ioctl->wait_done=0;
  	if ((retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc,
--	    sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, 10, CAN_SLEEP)) != 0) {
+-	    sizeof(SCSITaskMgmt_t), (u32*)pScsiTm,10, CAN_SLEEP)) != 0) {
 +	     sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) {
  		dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!"
  			" (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd,
  			hd->ioc, mf));
-@@ -586,12 +516,16 @@
- {
- 	MPT_IOCTL *ioctl = ioc->ioctl;
- 	dctlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to IOCTL driver!\n",
--		reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"));
-+		reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
-+		reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
- 
- 	if(ioctl == NULL)
- 		return 1;
- 
- 	switch(reset_phase) {
-+	case MPT_IOC_SETUP_RESET:
-+		ioctl->status |= MPT_IOCTL_STATUS_DID_IOCRESET;
-+		break;
- 	case MPT_IOC_POST_RESET:
- 		ioctl->status &= ~MPT_IOCTL_STATUS_DID_IOCRESET;
- 		break;
-@@ -681,8 +615,13 @@
-  *  cmd - specify the particular IOCTL command to be issued
-  *  arg - data specific to the command. Must not be null.
-  */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- static int
- mptctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
-+#else
-+static long
-+__mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-+#endif
- {
- 	mpt_ioctl_header __user *uhdr = (void __user *) arg;
- 	mpt_ioctl_header	 khdr;
-@@ -695,7 +634,7 @@
+@@ -652,7 +634,7 @@ __mptctl_ioctl(struct file *file, unsign
  	dctlprintk(("mptctl_ioctl() called with cmd=%x\n", cmd));
  
  	if (copy_from_user(&khdr, uhdr, sizeof(khdr))) {
@@ -21635,16 +18867,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"Unable to copy mpt_ioctl_header data @ %p\n",
  				__FILE__, __LINE__, uhdr);
  		return -EFAULT;
-@@ -736,38 +675,28 @@
+@@ -693,38 +675,28 @@ __mptctl_ioctl(struct file *file, unsign
  		return mptctl_query_diag_buffer(arg);
  	} else if (cmd == MPTDIAGUNREGISTER) {
  		return mptctl_unregister_diag_buffer(arg);
 -
- 	}
+-	}
 -#ifdef MPT_SUPPORT_FWDLB_IOCTL
 -	 else if (cmd == MPTHBAPCIINFO) {
 -		return mptctl_hba_pciinfo(arg);
--	}
+ 	}
 -#endif
  
  #if defined(CPQ_CIM)
@@ -21680,7 +18912,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	if (cmd == MPTFWDOWNLOAD)
  		ret = mptctl_fw_download(arg);
  	else if (cmd == MPTFWDOWNLOADBOOT)
-@@ -788,41 +717,37 @@
+@@ -745,41 +717,37 @@ __mptctl_ioctl(struct file *file, unsign
  		ret = mptctl_read_diag_buffer(arg);
  #if defined(CPQ_CIM)
  	else if (cmd == CC_CSMI_SAS_GET_PHY_INFO)
@@ -21740,7 +18972,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  #endif // CPQ_CIM
  	else {
  		dctlprintk(("mptctl_ioctl() cmd=%x not found\n", cmd));
-@@ -831,10 +756,21 @@
+@@ -788,7 +756,6 @@ __mptctl_ioctl(struct file *file, unsign
  
  	up(&iocp->ioctl->sem_ioc);
  
@@ -21748,22 +18980,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	return ret;
  }
  
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
-+static long
-+mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-+{
-+	long ret;
-+	lock_kernel();
-+	ret = __mptctl_ioctl(file, cmd, arg);
-+	unlock_kernel();
-+	return ret;
-+}
-+#endif
-+
- static int mptctl_do_reset(unsigned long arg)
- {
- 	struct mpt_ioctl_diag_reset __user *urinfo = (void __user *) arg;
-@@ -844,7 +780,7 @@
+@@ -813,7 +780,7 @@ static int mptctl_do_reset(unsigned long
  	dctlprintk(("mptctl_do_reset called.\n"));
  
  	if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) {
@@ -21772,7 +18989,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"Unable to copy mpt_ioctl_diag_reset struct @ %p\n",
  				__FILE__, __LINE__, urinfo);
  		return -EFAULT;
-@@ -889,7 +825,7 @@
+@@ -858,7 +825,7 @@ mptctl_fw_download(unsigned long arg)
  
  	dctlprintk(("mptctl_fwdl called. mptctl_id = %xh\n", mptctl_id)); //tc
  	if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) {
@@ -21781,12 +18998,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"Unable to copy mpt_fw_xfer struct @ %p\n",
  				__FILE__, __LINE__, ufwdl);
  		return -EFAULT;
-@@ -1042,10 +978,10 @@
- 		if (nib == 0 || nib == 3) {
- 			;
- 		} else if (sgIn->Address) {
--			iocp->add_sge(sgOut, sgIn->FlagsLength, sgIn->Address);
-+			mpt_add_sge(sgOut, sgIn->FlagsLength, sgIn->Address);
+@@ -1014,7 +981,7 @@ mptctl_do_fw_download(int ioc, char __us
+ 			mpt_add_sge(sgOut, sgIn->FlagsLength, sgIn->Address);
  			n++;
  			if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) {
 -				printk(KERN_ERR "%s@%d: _ioctl_fwdl - "
@@ -21794,7 +19007,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  						"Unable to copy f/w buffer hunk#%d @ %p\n",
  						__FILE__, __LINE__, n, ufwbuf);
  				goto fwdl_out;
-@@ -1071,9 +1007,6 @@
+@@ -1040,9 +1007,6 @@ mptctl_do_fw_download(int ioc, char __us
  	 * Finally, perform firmware download.
  	 */
  	ReplyMsg = NULL;
@@ -21804,25 +19017,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	mpt_put_msg_frame(mptctl_id, iocp, mf);
  
  	/* Now wait for the command to complete */
-@@ -1083,7 +1016,7 @@
- 
- 	if(ret <=0 && (iocp->ioctl->wait_done != 1 )) {
- 	/* Now we need to reset the board */
--		mptctl_timeout_expired(iocp, mf);
-+		mptctl_timeout_expired(iocp->ioctl);
- 		ret = -ENODATA;
- 		goto fwdl_out;
- 	}
-@@ -1091,7 +1024,7 @@
- 	if (sgl)
- 		kfree_sgl(sgl, sgl_dma, buflist, iocp);
- 
--	ReplyMsg = (pFWDownloadReply_t)iocp->ioctl->reply;
-+	ReplyMsg = (pFWDownloadReply_t)iocp->ioctl->ReplyFrame;
- 	iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK;
- 	if (iocstat == MPI_IOCSTATUS_SUCCESS) {
- 		printk(KERN_INFO MYNAM ": F/W update successfully sent to %s!\n", iocp->name);
-@@ -1106,7 +1039,7 @@
+@@ -1075,7 +1039,7 @@ mptctl_do_fw_download(int ioc, char __us
  		printk(KERN_WARNING MYNAM ": (try again later?)\n");
  		return -EBUSY;
  	} else {
@@ -21831,7 +19026,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				    iocp->name, iocstat);
  		printk(KERN_WARNING MYNAM ": (bad VooDoo)\n");
  		return -ENOMSG;
-@@ -1142,7 +1075,7 @@
+@@ -1111,7 +1075,7 @@ mptctl_fw_downloadboot(unsigned long arg
  
  	dctlprintk(("mptctl_fwdlboot called. mptctl_id = %xh\n", mptctl_id)); //tc
  	if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) {
@@ -21840,48 +19035,56 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"Unable to copy mpt_fw_xfer struct @ %p\n",
  				__FILE__, __LINE__, ufwdl);
  		return -EFAULT;
-@@ -1180,20 +1113,11 @@
+@@ -1149,20 +1113,11 @@ mptctl_do_fw_downloadboot(int ioc_num, c
  		return -ENODEV; /* (-6) No such device or address */
  	}
  
 -	pbuf = (char *)__get_free_pages(GFP_KERNEL, get_order(fwlen));
--	
--	if (pbuf==NULL) {
--		printk(KERN_ERR "%s@%d: _ioctl_fwdlboot - "
--				"Unable to allocate memory\n",
--				__FILE__, __LINE__);
--		return -ENOMEM;
--	}
+-       if (pbuf==NULL) {
+-               printk(KERN_ERR "%s@%d: _ioctl_fwdlboot - "
+-                               "Unable to allocate memory\n",
+-                               __FILE__, __LINE__);
+-               return -ENOMEM;
+-       }
 -
-+	pbuf = kmalloc(fwlen, GFP_KERNEL);
- 	if (copy_from_user(pbuf, ufwbuf, fwlen)) {
+-
+-if (copy_from_user(pbuf, ufwbuf, fwlen)) {
 -		printk(KERN_ERR "%s@%d: _ioctl_fwdlboot - "
++	pbuf = kmalloc(fwlen, GFP_KERNEL);
++	if (copy_from_user(pbuf, ufwbuf, fwlen)) {
 +		printk(KERN_ERR "%s@%d::_ioctl_fwdlboot - "
  				"Unable to copy mpt_fw @ %p\n",
  				__FILE__, __LINE__, (void*)ufwbuf);
--		free_pages((unsigned long)pbuf, get_order(fwlen));
+-free_pages((unsigned long)pbuf, get_order(fwlen));
  		return -EFAULT;
  	}
  
-@@ -1203,7 +1127,6 @@
+@@ -1171,10 +1126,7 @@ free_pages((unsigned long)pbuf, get_orde
+ 
  	rc = mpt_downloadboot(ioc, (MpiFwHeader_t *)pbuf, CAN_SLEEP);
  	ddlprintk((MYIOC_s_INFO_FMT "mptctl_do_fw_downloadboot rc=%x\n",
+-
  				ioc->name, rc));
 -#if 0
+-
  	if ( (rc == 0) && (ioc->bus_type == SAS) ) {
  /*		if ((rc = mptctl_syscall_down(ioc, nonblock)) != 0)
  			return rc; */
-@@ -1223,8 +1146,7 @@
+@@ -1194,12 +1146,10 @@ free_pages((unsigned long)pbuf, get_orde
  			ioc->name));
  		} */
  	}
 -#endif
--	free_pages((unsigned long)pbuf, get_order(fwlen));
+-free_pages((unsigned long)pbuf, get_order(fwlen));
 +	kfree(pbuf);
  	return rc;
  }
  
-@@ -1306,9 +1228,9 @@
+-
+ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ /*
+  * SGE Allocation routine
+@@ -1278,9 +1228,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i
  		if (buflist[buflist_ent].kptr == NULL) {
  			alloc_sz = alloc_sz / 2;
  			if (alloc_sz == 0) {
@@ -21893,7 +19096,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  						    numfrags);
  				goto free_and_fail;
  			}
-@@ -1332,17 +1254,17 @@
+@@ -1304,17 +1254,17 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i
  
  		/* Need to chain? */
  		if (fragcnt == sg_spill) {
@@ -21915,7 +19118,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  					    numfrags);
  			goto free_and_fail;
  		}
-@@ -1463,16 +1385,18 @@
+@@ -1435,16 +1385,18 @@ mptctl_getiocinfo (unsigned long arg, un
  	struct mpt_ioctl_iocinfo __user *uarg = (void __user *) arg;
  	struct mpt_ioctl_iocinfo *karg;
  	MPT_ADAPTER		*ioc;
@@ -21937,7 +19140,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	/* Add of PCI INFO results in unaligned access for
  	 * IA64 and Sparc. Reset long to int. Return no PCI
  	 * data for obsolete format.
-@@ -1485,20 +1409,18 @@
+@@ -1457,20 +1409,18 @@ mptctl_getiocinfo (unsigned long arg, un
  		cim_rev = 2;
  	else if (data_size == (sizeof(struct mpt_ioctl_iocinfo_rev0)+12))
  		cim_rev = 0;	/* obsolete */
@@ -21961,7 +19164,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_iocinfo struct @ %p\n",
  				__FILE__, __LINE__, (void*)uarg);
  		kfree(karg);
-@@ -1512,11 +1434,10 @@
+@@ -1484,11 +1434,10 @@ mptctl_getiocinfo (unsigned long arg, un
  		kfree(karg);
  		return -ENODEV;
  	}
@@ -21974,7 +19177,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Structure size mismatch. Command not completed.\n",
  				__FILE__, __LINE__);
  		kfree(karg);
-@@ -1563,11 +1484,18 @@
+@@ -1535,11 +1484,18 @@ mptctl_getiocinfo (unsigned long arg, un
  
  	/* Get number of devices
           */
@@ -21998,7 +19201,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  					numDevices++;
  			}
  		}
-@@ -1591,7 +1519,7 @@
+@@ -1563,7 +1519,7 @@ mptctl_getiocinfo (unsigned long arg, un
  	/* Copy the data from kernel memory to user memory
  	 */
  	if (copy_to_user((char __user *)arg, karg, data_size)) {
@@ -22007,7 +19210,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out mpt_ioctl_iocinfo struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		kfree(karg);
-@@ -1618,22 +1546,25 @@
+@@ -1590,22 +1546,25 @@ mptctl_gettargetinfo (unsigned long arg)
  	struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg;
  	struct mpt_ioctl_targetinfo karg;
  	MPT_ADAPTER		*ioc;
@@ -22037,7 +19240,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_targetinfo struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -1646,7 +1577,6 @@
+@@ -1618,7 +1577,6 @@ mptctl_gettargetinfo (unsigned long arg)
  		return -ENODEV;
  	}
  
@@ -22045,7 +19248,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	/* Get the port number and set the maximum number of bytes
  	 * in the returned structure.
  	 * Ignore the port setting.
-@@ -1656,7 +1586,7 @@
+@@ -1628,7 +1586,7 @@ mptctl_gettargetinfo (unsigned long arg)
  	port = karg.hdr.port;
  
  	if (maxWordsLeft <= 0) {
@@ -22054,7 +19257,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				__FILE__, __LINE__);
  		return -ENOMEM;
  	}
-@@ -1677,7 +1607,7 @@
+@@ -1649,7 +1607,7 @@ mptctl_gettargetinfo (unsigned long arg)
  	 */
  	pmem = kmalloc(numBytes, GFP_KERNEL);
  	if (pmem == NULL) {
@@ -22063,7 +19266,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				__FILE__, __LINE__);
  		return -ENOMEM;
  	}
-@@ -1686,69 +1616,71 @@
+@@ -1658,68 +1616,71 @@ mptctl_gettargetinfo (unsigned long arg)
  
  	/* Get number of devices
           */
@@ -22083,11 +19286,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
 -						goto data_space_full;
 -					}
 -					if ( ( pIoc2->RaidVolume[0].Flags & MPI_IOCPAGE2_FLAG_VOLUME_INACTIVE ) == 0 )
--                       				devType = 0x80;
+-						devType = 0x80;
 -					else
--                       				devType = 0xC0;
+-						devType = 0xC0;
 -					if ( bus == pIoc2->RaidVolume[0].VolumeBus) {
--            					numDevices++;
+-						numDevices++;
 -						*pdata = ( (devType << 24) | (bus<< 8) | id );
 +	if ((sh = ioc->sh) != NULL) {
 +
@@ -22126,16 +19329,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
 -					}
 -				} else {
 -					pIoc3 = ioc->raid_data.pIocPg3;
--					if (pIoc3)
--						for ( jj = 0; jj < pIoc3->NumPhysDisks; jj++ ) {
--							if ((pIoc3->PhysDisk[jj].PhysDiskID == id) && (pIoc3->PhysDisk[jj].PhysDiskBus == bus))
+-					for ( jj = 0; jj < pIoc3->NumPhysDisks; jj++ ) {
+-						if ((pIoc3->PhysDisk[jj].PhysDiskID == id) && (pIoc3->PhysDisk[jj].PhysDiskBus == bus))
+-							goto next_id;
 +					} else {
 +						pIoc3 = ioc->raid_data.pIocPg3;
 +            					for ( jj = 0; jj < pIoc3->NumPhysDisks; jj++ ) {
 +                    					if ( pIoc3->PhysDisk[jj].PhysDiskID == id )
- 								goto next_id;
- 						}
-+					}
++								goto next_id;
++						}
+ 					}
  				}
 -			}
 -			if ((pMptTarget = ioc->Target_List[bus])) {
@@ -22175,7 +19378,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  		}
  	}
  data_space_full:
-@@ -1758,7 +1690,7 @@
+@@ -1729,7 +1690,7 @@ data_space_full:
  	 */
  	if (copy_to_user((char __user *)arg, &karg,
  				sizeof(struct mpt_ioctl_targetinfo))) {
@@ -22184,7 +19387,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out mpt_ioctl_targetinfo struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		kfree(pmem);
-@@ -1768,7 +1700,7 @@
+@@ -1739,7 +1700,7 @@ data_space_full:
  	/* Copy the remaining data from kernel memory to user memory
  	 */
  	if (copy_to_user(uarg->targetInfo, pmem, numBytes)) {
@@ -22193,10 +19396,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out mpt_ioctl_targetinfo struct @ %p\n",
  				__FILE__, __LINE__, pdata);
  		kfree(pmem);
-@@ -1779,68 +1711,6 @@
- 
+@@ -1751,70 +1712,6 @@ data_space_full:
  	return 0;
  }
+ 
 -#ifdef MPT_SUPPORT_FWDLB_IOCTL
 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 -/*
@@ -22232,7 +19435,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
 -		karg.hbapciinfo[ioc_num].iocNumber = ioc_num;
 -		karg.hbapciinfo[ioc_num].deviceID = ioc->deviceID;
 -		karg.hbapciinfo[ioc_num].vendorID = ioc->vendorID;
--		
+-
 -		pci_read_config_byte(ioc->pcidev, PCI_CLASS_REVISION, &revision);
 -
 -		karg.hbapciinfo[ioc_num].subSystemVendorID = ioc->pcidev->subsystem_vendor;
@@ -22259,10 +19462,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
 -	return 0;
 -}
 -#endif
- 
+-
+-
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  /* MPT IOCTL Test function.
-@@ -1860,7 +1730,7 @@
+  *
+@@ -1833,7 +1730,7 @@ mptctl_readtest (unsigned long arg)
  
  	dctlprintk(("mptctl_readtest called.\n"));
  	if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) {
@@ -22271,7 +19476,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_test struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -1890,7 +1760,7 @@
+@@ -1863,7 +1760,7 @@ mptctl_readtest (unsigned long arg)
  	/* Copy the data from kernel memory to user memory
  	 */
  	if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) {
@@ -22280,7 +19485,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out mpt_ioctl_test struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -1920,7 +1790,7 @@
+@@ -1893,7 +1790,7 @@ mptctl_eventquery (unsigned long arg)
  
  	dctlprintk(("mptctl_eventquery called.\n"));
  	if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) {
@@ -22289,7 +19494,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_eventquery struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -1939,7 +1809,7 @@
+@@ -1912,7 +1809,7 @@ mptctl_eventquery (unsigned long arg)
  	/* Copy the data from kernel memory to user memory
  	 */
  	if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) {
@@ -22298,7 +19503,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out mpt_ioctl_eventquery struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -1958,7 +1828,7 @@
+@@ -1931,7 +1828,7 @@ mptctl_eventenable (unsigned long arg)
  
  	dctlprintk(("mptctl_eventenable called.\n"));
  	if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) {
@@ -22307,7 +19512,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_eventenable struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -2005,7 +1875,7 @@
+@@ -1978,7 +1875,7 @@ mptctl_eventreport (unsigned long arg)
  
  	dctlprintk(("mptctl_eventreport called.\n"));
  	if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) {
@@ -22316,7 +19521,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_eventreport struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -2037,7 +1907,7 @@
+@@ -2010,7 +1907,7 @@ mptctl_eventreport (unsigned long arg)
  	 */
  	numBytes = max * sizeof(MPT_IOCTL_EVENTS);
  	if (copy_to_user(uarg->eventData, ioc->events, numBytes)) {
@@ -22325,7 +19530,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out mpt_ioctl_eventreport struct @ %p\n",
  				__FILE__, __LINE__, ioc->events);
  		return -EFAULT;
-@@ -2058,7 +1928,7 @@
+@@ -2031,7 +1928,7 @@ mptctl_replace_fw (unsigned long arg)
  
  	dctlprintk(("mptctl_replace_fw called.\n"));
  	if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) {
@@ -22334,7 +19539,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_replace_fw struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -2094,7 +1964,7 @@
+@@ -2067,7 +1964,7 @@ mptctl_replace_fw (unsigned long arg)
  	/* Copy the data from user memory to kernel space
  	 */
  	if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) {
@@ -22343,7 +19548,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_replace_fw image @ %p\n",
  			__FILE__, __LINE__, uarg);
  		mpt_free_fw_memory(ioc);
-@@ -2131,7 +2001,7 @@
+@@ -2104,7 +2001,7 @@ mptctl_mpt_command (unsigned long arg)
  	dctlprintk(("mptctl_command called.\n"));
  
  	if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) {
@@ -22352,22 +19557,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in mpt_ioctl_command struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -2176,12 +2046,10 @@
+@@ -2149,11 +2046,10 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  	int		iocnum, flagsLength;
  	int		sz, rc = 0;
  	int		msgContext;
 -	u16		req_idx=0;
 +	u16		req_idx;
  	ulong 		timeout;
--	MPT_FRAME_HDR	*SAS_handshake_mf=NULL;
--	char		*SAS_handshake_reply=NULL;
--	u16		msgSize=0;
- 
+-        MPT_FRAME_HDR   *SAS_handshake_mf=NULL;
+-        char            *SAS_handshake_reply=NULL;
+-        u16             msgSize=0;
++
 +	dctlprintk(("mptctl_do_mpt_command called.\n"));
  	bufIn.kptr = bufOut.kptr = NULL;
  
  	if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
-@@ -2190,14 +2058,13 @@
+@@ -2162,14 +2058,13 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  				iocnum));
  		return -ENODEV;
  	}
@@ -22384,7 +19589,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Busy with IOC Reset \n", __FILE__, __LINE__);
  		return -EBUSY;
  	}
-@@ -2211,7 +2078,7 @@
+@@ -2183,7 +2078,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  		sz += sizeof(dma_addr_t) + sizeof(u32);
  
  	if (sz > ioc->req_sz) {
@@ -22393,7 +19598,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Request frame too large (%d) maximum (%d)\n",
  				__FILE__, __LINE__, sz, ioc->req_sz);
  		return -EFAULT;
-@@ -2219,42 +2086,18 @@
+@@ -2191,44 +2086,18 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  
  	/* Get a free request frame and save the message context.
  	 */
@@ -22402,25 +19607,25 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
 -		if ( (mf = (MPT_FRAME_HDR *)kmalloc(msgSize, GFP_KERNEL)) == NULL) {
 -			dfailprintk(("%s: mptctl_do_mpt_command, Unable to kmalloc msgSize=%d for SAS_handshake!!\n",
 -			ioc->name, msgSize));
--               		return -ENOMEM;
+-			return -ENOMEM;
 -		}
--		SAS_handshake_mf = mf; 
+-		SAS_handshake_mf = mf;
 -		if (karg.maxReplyBytes) {
 -			if ( (SAS_handshake_reply = (char *)kmalloc(karg.maxReplyBytes, GFP_KERNEL)) == NULL) {
 -				kfree(SAS_handshake_mf);
 -				dfailprintk(("%s: mptctl_do_mpt_command, Unable to kmalloc maxReplyBytes=%d for SAS_handshake!!\n",
 -					ioc->name, karg.maxReplyBytes));
--               			return -ENOMEM;
+-				return -ENOMEM;
 -			}
 -		}
 -		hdr = (MPIHeader_t *) mf;
 -		msgContext = le32_to_cpu(0x02012020);
 -		karg.hdr.port &= 0x0000ffff;
 -	} else {
--        	if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
+-		if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
 -			dfailprintk((MYIOC_s_WARN_FMT "%s: no msg frames!!\n",
 -			    ioc->name,__FUNCTION__));
--               		return -EAGAIN;
+-			return -EAGAIN;
 -		} else {
 -			hdr = (MPIHeader_t *) mf;
 -			msgContext = le32_to_cpu(hdr->MsgContext);
@@ -22429,11 +19634,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
 -	}
 +        if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL)
 +                return -EAGAIN;
-+
+ 
 +	hdr = (MPIHeader_t *) mf;
 +	msgContext = le32_to_cpu(hdr->MsgContext);
 +	req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
  
+-//@@@@@
  	/* Copy the request frame
  	 * Reset the saved message context.
  	 */
@@ -22443,7 +19649,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read MF from mpt_ioctl_command struct @ %p\n",
  			__FILE__, __LINE__, mfPtr);
  		rc = -EFAULT;
-@@ -2285,34 +2128,17 @@
+@@ -2259,34 +2128,17 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  	case MPI_FUNCTION_SCSI_IO_REQUEST:
  		if (ioc->sh) {
  			SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf;
@@ -22483,7 +19689,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				rc = -ENODEV;
  				goto done_free_mem;
  			}
-@@ -2336,7 +2162,8 @@
+@@ -2310,7 +2162,8 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  				   + (req_idx * MPT_SENSE_BUFFER_ALLOC));
  
  			if ((hd = (MPT_SCSI_HOST *) ioc->sh->hostdata)) {
@@ -22493,7 +19699,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			}
  
  			if (pTarget &&(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
-@@ -2357,10 +2184,10 @@
+@@ -2331,10 +2184,10 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  			pScsiReq->DataLength = cpu_to_le32(dataSize);
  
  			ioc->ioctl->reset = MPTCTL_RESET_OK;
@@ -22506,7 +19712,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"SCSI driver is not loaded. \n",
  					__FILE__, __LINE__);
  			rc = -EFAULT;
-@@ -2379,7 +2206,7 @@
+@@ -2353,7 +2206,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  
  	case MPI_FUNCTION_SATA_PASSTHROUGH:
  		if (!ioc->sh) {
@@ -22515,7 +19721,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"SCSI driver is not loaded. \n",
  					__FILE__, __LINE__);
  			rc = -EFAULT;
-@@ -2435,10 +2262,9 @@
+@@ -2409,10 +2262,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  			pScsiReq->DataLength = cpu_to_le32(dataSize);
  
  			ioc->ioctl->reset = MPTCTL_RESET_OK;
@@ -22528,7 +19734,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"SCSI driver is not loaded. \n",
  					__FILE__, __LINE__);
  			rc = -EFAULT;
-@@ -2450,7 +2276,7 @@
+@@ -2424,7 +2276,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  		{
  			MPT_SCSI_HOST *hd = NULL;
  			if ((ioc->sh == NULL) || ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) {
@@ -22537,19 +19743,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  					"SCSI driver not loaded or SCSI host not found. \n",
  					__FILE__, __LINE__);
  				rc = -EFAULT;
-@@ -2478,19 +2304,12 @@
- 				sense_high= 0;
- 			}
- 
--			if ((pInit->MaxDevices == 0) && (pInit->MaxBuses == 0)) {
--				/* Fix for SR 2-188096080:
--				 * lsiutil fails to program SAS WWN */
--				pInit->MaxDevices = ioc->facts.MaxDevices;
--				pInit->MaxBuses = ioc->facts.MaxBuses;
--			}
--
- 			if ((pInit->Flags != 0) || (pInit->MaxDevices != ioc->facts.MaxDevices) ||
- 				(pInit->MaxBuses != ioc->facts.MaxBuses) ||
+@@ -2457,7 +2309,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  				(pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) ||
  				(pInit->HostMfaHighAddr != high_addr) ||
  				(pInit->SenseBufferHighAddr != sense_high)) {
@@ -22558,7 +19752,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  					"IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n",
  					__FILE__, __LINE__);
  				rc = -EFAULT;
-@@ -2523,7 +2342,7 @@
+@@ -2490,7 +2342,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  		 	MPI_FUNCTION_LAN_RESET
  		*/
  
@@ -22567,16 +19761,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Illegal request (function 0x%x) \n",
  			__FILE__, __LINE__, hdr->Function);
  		rc = -EFAULT;
-@@ -2574,7 +2393,7 @@
- 				/* Set up this SGE.
- 				 * Copy to MF and to sglbuf
- 				 */
--				ioc->add_sge(psge, flagsLength, dma_addr_out);
-+				mpt_add_sge(psge, flagsLength, dma_addr_out);
- 				psge += (sizeof(u32) + sizeof(dma_addr_t));
- 
- 				/* Copy user data to kernel space.
-@@ -2583,7 +2402,7 @@
+@@ -2550,7 +2402,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  						karg.dataOutBufPtr,
  						bufOut.len)) {
  					printk(KERN_ERR
@@ -22585,7 +19770,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  						"to read user data "
  						"struct @ %p\n",
  						__FILE__, __LINE__,karg.dataOutBufPtr);
-@@ -2594,7 +2413,16 @@
+@@ -2561,7 +2413,16 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  		}
  
  		if (karg.dataInSize > 0) {
@@ -22603,19 +19788,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			flagsLength |= karg.dataInSize;
  
  			bufIn.len = karg.dataInSize;
-@@ -2608,24 +2436,23 @@
- 				/* Set up this SGE
- 				 * Copy to MF and to sglbuf
- 				 */
--				ioc->add_sge(psge, flagsLength, dma_addr_in);
-+				mpt_add_sge(psge, flagsLength, dma_addr_in);
- 			}
- 		}
- 	} else  {
- 		/* Add a NULL SGE
- 		 */
--		ioc->add_sge(psge, flagsLength, (dma_addr_t) -1);
-+		mpt_add_sge(psge, flagsLength, (dma_addr_t) -1);
+@@ -2585,14 +2446,13 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  	}
  
  	ioc->ioctl->wait_done = 0;
@@ -22626,132 +19799,109 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  		DBG_DUMP_TM_REQUEST_FRAME((u32 *)mf);
  
  		if (mpt_send_handshake_request(mptctl_id, ioc,
--		    sizeof(SCSITaskMgmt_t), (u32*)mf, 10, CAN_SLEEP) != 0) {
+-		    sizeof(SCSITaskMgmt_t), (u32*)mf,10, CAN_SLEEP) != 0) {
 +			sizeof(SCSITaskMgmt_t), (u32*)mf,
 +			CAN_SLEEP) != 0) {
  			dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!"
  				" (ioc %p, mf %p) \n", ioc->name,
  				ioc, mf));
-@@ -2633,81 +2460,28 @@
+@@ -2600,73 +2460,27 @@ mptctl_do_mpt_command (struct mpt_ioctl_
  			rc = -ENODATA;
  			goto done_free_mem;
  		}
--		timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT;
--		timeout = wait_event_timeout(mptctl_wait,
--	     		ioc->ioctl->wait_done == 1,
--	     		HZ*timeout);
- 
--		if(timeout <=0 && (ioc->ioctl->wait_done != 1 )) {
--		/* Now we need to reset the board */
--			mptctl_free_tm_flags(ioc);
--			mptctl_timeout_expired(ioc, mf);
--			rc = -ENODATA;
--			goto done_free_mem;
--		}
--	} else {
--		if ( SAS_handshake_mf ) {
--			dctlprintk(("SAS_handshake_message Function=%x\n",
--				hdr->Function));
--
--			timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT;
--			rc = mpt_handshake_req_reply_wait(ioc,
--				msgSize, 
--				(u32*)SAS_handshake_mf,
--				karg.maxReplyBytes, 
--				(u16*)SAS_handshake_reply, timeout /*seconds*/, 
--				CAN_SLEEP);
--			kfree(SAS_handshake_mf);
--			SAS_handshake_mf = NULL;
--			if (rc == 0) {
--				dctlprintk(("SAS_handshake_message Function=%x completed successfully\n",
--				hdr->Function));
--				sz = karg.maxReplyBytes;
--
--				if (sz > 0) {
--					if (copy_to_user((char *)karg.replyFrameBufPtr,
--						 SAS_handshake_reply, sz)){
--
--					 	printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - "
--					 	"Unable to write out reply frame %p\n",
--					 	__FILE__, __LINE__, (void*)karg.replyFrameBufPtr);
--						rc =  -ENODATA;
--					}
--				} else {
--					rc =  -ENODATA;
--					dctlprintk(("SAS_handshake_message failed sz=%d\n", sz));
--				}
--				
--				kfree(SAS_handshake_reply);
--				SAS_handshake_reply = NULL;
--				goto done_free_mem;
--			}
--			else
--			{
--				rc = -ENODATA;
--				kfree(SAS_handshake_reply);
--				SAS_handshake_reply = NULL;
--				goto done_free_mem;
--			}
--		} else {
--			mpt_put_msg_frame(mptctl_id, ioc, mf);
--			/* Now wait for the command to complete */
--			timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT;
--			timeout = wait_event_timeout(mptctl_wait,
--	    		 ioc->ioctl->wait_done == 1,
--			     HZ*timeout);
+-timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT;
+-timeout = wait_event_timeout(mptctl_wait,ioc->ioctl->wait_done == 1,HZ*timeout);
+ 
+- if(timeout <=0 && (ioc->ioctl->wait_done != 1 )) {
+-               /* Now we need to reset the board */
+-                       mptctl_free_tm_flags(ioc);
+-                       mptctl_timeout_expired(ioc->ioctl);
+-                       rc = -ENODATA;
+-                       goto done_free_mem;
+-               }
+-} else {
+-               if ( SAS_handshake_mf ) {
+-                       dctlprintk(("SAS_handshake_message Function=%x\n",
+-                               hdr->Function));
+-
+-                       timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT;
+-                       rc = mpt_handshake_req_reply_wait(ioc,
+-                               msgSize,
+-                               (u32*)SAS_handshake_mf,
+-                              karg.maxReplyBytes,
+-                              (u16*)SAS_handshake_reply, timeout /*seconds*/,
+-                               CAN_SLEEP);
+-                       kfree(SAS_handshake_mf);
+-                       SAS_handshake_mf = NULL;
+-              if (rc == 0) {
+-              dctlprintk(("SAS_handshake_message Function=%x completed successfully\n",
+-                               hdr->Function));
+-                               sz = karg.maxReplyBytes;
+-                               if (sz > 0) {
+-                    if (copy_to_user((char *)karg.replyFrameBufPtr,SAS_handshake_reply, sz)){
+-printk(KERN_ERR "%s@%d::mptctl_do_mpt_command -" "Unable to write out reply frame %p\n",__FILE__, __LINE__, (void*)karg.replyFrameBufPtr);
+-                               rc =  -ENODATA;
+-                              }
+-                       }else {
+-
+-                                rc =  -ENODATA;
+-                               dctlprintk(("SAS_handshake_message failed sz=%d\n", sz));
+-                                }
+-                               kfree(SAS_handshake_reply);
+-                               SAS_handshake_reply = NULL;
+-                               goto done_free_mem;
+-                             }
+-                            else
+-                            {
+-                               rc = -ENODATA;
+-                               kfree(SAS_handshake_reply);
+-                               SAS_handshake_reply = NULL;
+-                               goto done_free_mem;
+-                            }
+-                         }else {
+-                               mpt_put_msg_frame(mptctl_id, ioc, mf);
+-                       /* Now wait for the command to complete */
+-                       timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT;
+-                       timeout = wait_event_timeout(mptctl_wait,
+-                        ioc->ioctl->wait_done == 1,
+-                            HZ*timeout);
 +	} else
 +		mpt_put_msg_frame(mptctl_id, ioc, mf);
  
--			if(timeout <=0 && (ioc->ioctl->wait_done != 1 )) {
--			/* Now we need to reset the board */
+-                if(timeout <=0 && (ioc->ioctl->wait_done != 1 )) {
 +	/* Now wait for the command to complete */
 +	timeout = (karg.timeout > 0) ? karg.timeout : MPT_IOCTL_DEFAULT_TIMEOUT;
 +	timeout = wait_event_timeout(mptctl_wait,
 +	     ioc->ioctl->wait_done == 1,
 +	     HZ*timeout);
  
--				mptctl_timeout_expired(ioc, mf);
--				rc = -ENODATA;
--				goto done_free_mem;
--			}
 +	if(timeout <=0 && (ioc->ioctl->wait_done != 1 )) {
-+	/* Now we need to reset the board */
+ 	/* Now we need to reset the board */
  
--		}
 +		if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT)
 +			mptctl_free_tm_flags(ioc);
 +
-+		mptctl_timeout_expired(ioc->ioctl);
-+		rc = -ENODATA;
-+		goto done_free_mem;
- 	}
- 
+ 		mptctl_timeout_expired(ioc->ioctl);
+ 		rc = -ENODATA;
+ 		goto done_free_mem;
+-	       }
+-       }
+-}
++	}
 +
- 	mf = NULL;
  
- 	/* If a valid reply frame, copy to the user.
-@@ -2715,16 +2489,16 @@
- 	 */
- 	if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) {
- 		if (karg.maxReplyBytes < ioc->reply_sz) {
--			 sz = min(karg.maxReplyBytes, 4*ioc->ioctl->reply[2]);
-+			 sz = min(karg.maxReplyBytes, 4*ioc->ioctl->ReplyFrame[2]);
- 		} else {
--			 sz = min(ioc->reply_sz, 4*ioc->ioctl->reply[2]);
-+			 sz = min(ioc->reply_sz, 4*ioc->ioctl->ReplyFrame[2]);
- 		}
+ 	mf = NULL;
  
- 		if (sz > 0) {
+@@ -2684,7 +2498,7 @@ printk(KERN_ERR "%s@%d::mptctl_do_mpt_co
  			if (copy_to_user(karg.replyFrameBufPtr,
--				 &ioc->ioctl->reply, sz)){
-+				 &ioc->ioctl->ReplyFrame, sz)){
+ 				 &ioc->ioctl->ReplyFrame, sz)){
  
 -				 printk(KERN_ERR "%s@%d: mptctl_do_mpt_command - "
 +				 printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - "
  				 "Unable to write out reply frame %p\n",
  				 __FILE__, __LINE__, karg.replyFrameBufPtr);
  				 rc =  -ENODATA;
-@@ -2739,7 +2513,7 @@
+@@ -2699,7 +2513,7 @@ printk(KERN_ERR "%s@%d::mptctl_do_mpt_co
  		sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE);
  		if (sz > 0) {
  			if (copy_to_user(karg.senseDataPtr, ioc->ioctl->sense, sz)) {
@@ -22760,7 +19910,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"Unable to write sense data to user %p\n",
  				__FILE__, __LINE__,
  				karg.senseDataPtr);
-@@ -2756,7 +2530,7 @@
+@@ -2716,7 +2530,7 @@ printk(KERN_ERR "%s@%d::mptctl_do_mpt_co
  				(karg.dataInSize > 0) && (bufIn.kptr)) {
  		if (copy_to_user(karg.dataInBufPtr,
  			 bufIn.kptr, karg.dataInSize)) {
@@ -22769,7 +19919,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				"Unable to write data to user %p\n",
  				__FILE__, __LINE__,
  				karg.dataInBufPtr);
-@@ -2766,6 +2540,10 @@
+@@ -2726,6 +2540,10 @@ printk(KERN_ERR "%s@%d::mptctl_do_mpt_co
  
  done_free_mem:
  
@@ -22780,21 +19930,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	/* Free the allocated memory.
  	 */
  	 if (bufOut.kptr != NULL) {
-@@ -2777,13 +2555,6 @@
- 		pci_free_consistent(ioc->pcidev,
+@@ -2738,14 +2556,6 @@ done_free_mem:
  			bufIn.len, (void *) bufIn.kptr, dma_addr_in);
  	}
--	
--	if (SAS_handshake_mf) {
+ 
+-if (SAS_handshake_mf) {
 -		kfree(SAS_handshake_mf);
 -		mf=NULL;
 -	}
--	if (SAS_handshake_reply)
+-if (SAS_handshake_reply)
 -		kfree(SAS_handshake_reply);
- 
+-
+-
  	/* mf is null if command issued successfully
  	 * otherwise, failure occured after mf acquired.
-@@ -2831,7 +2602,7 @@
+ 	 */
+@@ -2792,7 +2602,7 @@ mptctl_hp_hostinfo(unsigned long arg, un
  		return -EFAULT;
  
  	if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) {
@@ -22803,21 +19954,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in hp_host_info struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -2884,7 +2655,7 @@
- 	karg.fw_version[11] = '\0';
- 
- 	if (ioc->bus_type == SAS) {
--		strncpy(karg.serial_number, ioc->board_tracer, 24);
-+		strncpy(karg.serial_number, ioc->BoardTracerNumber, 24);
- 		karg.serial_number[24-1]='\0';
- 	}
- 
-@@ -2949,12 +2720,10 @@
- 	pbuf = pci_alloc_consistent(ioc->pcidev, 4, &buf_dma);
- 	if (!pbuf)
- 		goto out;
--	ioc->add_sge((char *)&IstwiRWRequest->SGL,
-+	mpt_add_sge((char *)&IstwiRWRequest->SGL,
+@@ -2914,8 +2724,6 @@ mptctl_hp_hostinfo(unsigned long arg, un
  	    (MPT_SGE_FLAGS_SSIMPLE_READ|4), buf_dma);
  
  	ioc->ioctl->wait_done = 0;
@@ -22826,17 +19963,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	mpt_put_msg_frame(mptctl_id, ioc, mf);
  
  	rc = wait_event_timeout(mptctl_wait,
-@@ -2963,8 +2732,8 @@
- 
- 	if(rc <=0 && (ioc->ioctl->wait_done != 1 )) {
- 	/* Now we need to reset the board */
--		mptctl_timeout_expired(ioc, mf);
- 		mpt_free_msg_frame(ioc, mf);
-+		mptctl_timeout_expired(ioc->ioctl);
- 		goto out;
- 	}
- 
-@@ -2986,7 +2755,7 @@
+@@ -2947,7 +2755,7 @@ mptctl_hp_hostinfo(unsigned long arg, un
  	/* Copy the data from kernel memory to user memory
  	 */
  	if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) {
@@ -22845,7 +19972,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out hp_host_info @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -3025,7 +2794,7 @@
+@@ -2986,7 +2794,7 @@ mptctl_hp_targetinfo(unsigned long arg)
  
  	dctlprintk(("mptctl_hp_targetinfo called.\n"));
  	if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) {
@@ -22854,7 +19981,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to read in hp_host_targetinfo struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -3136,7 +2905,7 @@
+@@ -3097,7 +2905,7 @@ mptctl_hp_targetinfo(unsigned long arg)
  	/* Copy the data from kernel memory to user memory
  	 */
  	if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) {
@@ -22863,7 +19990,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  			"Unable to write out mpt_ioctl_targetinfo struct @ %p\n",
  				__FILE__, __LINE__, uarg);
  		return -EFAULT;
-@@ -3270,8 +3039,6 @@
+@@ -3231,8 +3039,6 @@ allocDiagBuffer:
  	DiagBufferPostRequest->BufferAddress.Low = cpu_to_le32(tmp);
  
  	ioc->ioctl->wait_done = 0;
@@ -22872,26 +19999,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	mpt_put_msg_frame(mptctl_id, ioc, mf);
  
  	/* Now wait for the command to complete */
-@@ -3281,8 +3048,8 @@
- 
- 	if(ii <=0 && (ioc->ioctl->wait_done != 1 )) {
- 	/* Now we need to reset the board */
--		mptctl_timeout_expired(ioc, mf);
- 		mpt_free_msg_frame(ioc, mf);
-+		mptctl_timeout_expired(ioc->ioctl);
- 		rc = -ENODATA;
- 		goto mptctl_register_diag_buffer_out;
- 	}
-@@ -3291,7 +3058,7 @@
- 	if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) {
- 
- 		DiagBufferPostReply =
--		    (DiagBufferPostReply_t *)ioc->ioctl->reply;
-+		    (DiagBufferPostReply_t *)ioc->ioctl->ReplyFrame;
- 
- 		if ( le16_to_cpu(DiagBufferPostReply->IOCStatus) == MPI_IOCSTATUS_SUCCESS) {
- 			if ( DiagBufferPostReply->MsgLength > 5 ) {
-@@ -3314,6 +3081,10 @@
+@@ -3275,6 +3081,10 @@ allocDiagBuffer:
  
  mptctl_register_diag_buffer_out:
  
@@ -22902,7 +20010,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	if ( rc ) {
  		pci_free_consistent(ioc->pcidev, request_data_sz,
  			request_data,
-@@ -3410,8 +3181,6 @@
+@@ -3371,8 +3181,6 @@ mptctl_release_diag_buffer (unsigned lon
  	DiagRelease->MsgFlags = 0;
  
  	ioc->ioctl->wait_done = 0;
@@ -22911,26 +20019,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	mpt_put_msg_frame(mptctl_id, ioc, mf);
  
  	/* Now wait for the command to complete */
-@@ -3421,8 +3190,8 @@
- 
- 	if(ii <=0 && (ioc->ioctl->wait_done != 1 )) {
- 	/* Now we need to reset the board */
--		mptctl_timeout_expired(ioc, mf);
- 		mpt_free_msg_frame(ioc, mf);
-+		mptctl_timeout_expired(ioc->ioctl);
- 		rc = -ENODATA;
- 		goto mptctl_release_diag_buffer_out;
- 	}
-@@ -3430,7 +3199,7 @@
- 	/* process the completed Reply Message Frame */
- 	if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) {
- 		DiagReleaseReply =
--		    (DiagReleaseReply_t *)ioc->ioctl->reply;
-+		    (DiagReleaseReply_t *)ioc->ioctl->ReplyFrame;
- 
- 		if ( le16_to_cpu(DiagReleaseReply->IOCStatus) != MPI_IOCSTATUS_DIAGNOSTIC_RELEASED) {
- 			dctlprintk(("DiagReleaseReply: IOCStatus=%x IOCLogInfo=%x\n",
-@@ -3449,6 +3218,10 @@
+@@ -3410,6 +3218,10 @@ mptctl_release_diag_buffer (unsigned lon
  
  mptctl_release_diag_buffer_out:
  
@@ -22941,7 +20030,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	return rc;
  }
  
-@@ -3745,8 +3518,6 @@
+@@ -3706,8 +3518,6 @@ mptctl_read_diag_buffer (unsigned long a
  		DiagBufferPostRequest->BufferAddress.Low = cpu_to_le32(tmp);
  
  		ioc->ioctl->wait_done = 0;
@@ -22950,26 +20039,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  		mpt_put_msg_frame(mptctl_id, ioc, mf);
  
  		/* Now wait for the command to complete */
-@@ -3756,8 +3527,8 @@
- 
- 		if(ii <=0 && (ioc->ioctl->wait_done != 1 )) {
- 		/* Now we need to reset the board */
--			mptctl_timeout_expired(ioc, mf);
- 			mpt_free_msg_frame(ioc, mf);
-+			mptctl_timeout_expired(ioc->ioctl);
- 			rc = -ENODATA;
- 			goto mptctl_read_diag_buffer_out;
- 		}
-@@ -3765,7 +3536,7 @@
- 		/* process the completed Reply Message Frame */
- 		if (ioc->ioctl->status & MPT_IOCTL_STATUS_RF_VALID) {
- 			DiagBufferPostReply =
--			    (DiagBufferPostReply_t *)ioc->ioctl->reply;
-+			    (DiagBufferPostReply_t *)ioc->ioctl->ReplyFrame;
- 
- 			if ( le16_to_cpu(DiagBufferPostReply->IOCStatus) == MPI_IOCSTATUS_SUCCESS) {
- 				if ( DiagBufferPostReply->MsgLength > 5 ) {
-@@ -3785,8 +3556,14 @@
+@@ -3746,8 +3556,14 @@ mptctl_read_diag_buffer (unsigned long a
  				ioc->ioctl->status));
  			rc = -EFAULT;
  		}
@@ -22985,30 +20055,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	return rc;
  }
  
-@@ -3798,7 +3575,14 @@
- 	.open =		mptctl_open,
- 	.release =	mptctl_release,
- 	.fasync = 	mptctl_fasync,
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- 	.ioctl =	mptctl_ioctl,
-+#else
-+	.unlocked_ioctl = mptctl_ioctl,
-+#ifdef CONFIG_COMPAT
-+	.compat_ioctl = compat_mpctl_ioctl,
-+#endif /* CONFIG_COMPAT */
-+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) */
- };
- 
- static struct miscdevice mptctl_miscdev = {
-@@ -3820,6 +3604,7 @@
-  * does contain pointer(s), then the specialized function is used
-  * to ensure the structure contents is properly processed by mptctl.
-  */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- static int
- compat_mptctl_ioctl(unsigned int fd, unsigned int cmd,
- 			unsigned long arg, struct file *filp)
-@@ -3827,15 +3612,22 @@
+@@ -3796,7 +3612,7 @@ compat_mptctl_ioctl(unsigned int fd, uns
  	int ret;
  
  	lock_kernel();
@@ -23017,22 +20064,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	ret = mptctl_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
  	unlock_kernel();
  	return ret;
- }
-+#endif
- 
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- static int
- compat_mptfwxfer_ioctl(unsigned int fd, unsigned int cmd,
- 			unsigned long arg, struct file *filp)
-+#else
-+static int
-+compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,
-+			unsigned long arg)
-+#endif
- {
- 	struct mpt_fw_xfer32 kfw32;
- 	struct mpt_fw_xfer kfw;
-@@ -3844,7 +3636,7 @@
+@@ -3820,7 +3636,7 @@ compat_mptfwxfer_ioctl(struct file *filp
  	int nonblock = (filp->f_flags & O_NONBLOCK);
  	int ret;
  
@@ -23041,7 +20073,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  
  	if (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32)))
  		return -EFAULT;
-@@ -3853,7 +3645,7 @@
+@@ -3829,7 +3645,7 @@ compat_mptfwxfer_ioctl(struct file *filp
  	iocnumX = kfw32.iocnum & 0xFF;
  	if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
  	    (iocp == NULL)) {
@@ -23050,23 +20082,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				__LINE__, iocnumX));
  		return -ENODEV;
  	}
-@@ -3872,9 +3664,15 @@
- 	return ret;
- }
- 
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- static int
- compat_mpt_command(unsigned int fd, unsigned int cmd,
- 			unsigned long arg, struct file *filp)
-+#else
-+static int
-+compat_mpt_command(struct file *filp, unsigned int cmd,
-+			unsigned long arg)
-+#endif
- {
- 	struct mpt_ioctl_command32 karg32;
- 	struct mpt_ioctl_command32 __user *uarg = (struct mpt_ioctl_command32 __user *) arg;
-@@ -3884,7 +3682,7 @@
+@@ -3866,7 +3682,7 @@ compat_mpt_command(struct file *filp, un
  	int nonblock = (filp->f_flags & O_NONBLOCK);
  	int ret;
  
@@ -23075,7 +20091,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  
  	if (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32)))
  		return -EFAULT;
-@@ -3893,7 +3691,7 @@
+@@ -3875,7 +3691,7 @@ compat_mpt_command(struct file *filp, un
  	iocnumX = karg32.hdr.iocnum & 0xFF;
  	if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
  	    (iocp == NULL)) {
@@ -23084,101 +20100,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  				__LINE__, iocnumX));
  		return -ENODEV;
  	}
-@@ -3926,6 +3724,40 @@
- 	return ret;
- }
- 
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
-+static long
-+compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
-+{
-+	long ret;
-+	lock_kernel();
-+	switch (cmd) {
-+	case MPTIOCINFO:
-+	case MPTIOCINFO1:
-+	case MPTIOCINFO2:
-+	case MPTTARGETINFO:
-+	case MPTEVENTQUERY:
-+	case MPTEVENTENABLE:
-+	case MPTEVENTREPORT:
-+	case MPTHARDRESET:
-+	case HP_GETHOSTINFO:
-+	case HP_GETTARGETINFO:
-+	case MPTTEST:
-+		ret = __mptctl_ioctl(f, cmd, arg);
-+		break;
-+	case MPTCOMMAND32:
-+		ret = compat_mpt_command(f, cmd, arg);
-+		break;
-+	case MPTFWDOWNLOAD32:
-+		ret = compat_mptfwxfer_ioctl(f, cmd, arg);
-+		break;
-+	default:
-+		ret = -ENOIOCTLCMD;
-+		break;
-+	}
-+	unlock_kernel();
-+	return ret;
-+}
-+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11)) */
- #endif /* CONFIG_COMPAT */
- 
- 
-@@ -3941,13 +3773,31 @@
- static int
- mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id)
- {
-+	int err;
-+	int sz;
-+	u8 *mem;
- 	MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
- 
--	memset(&ioc->ioctl_cmds, 0, sizeof(MPT_IOCTL));
--	ioc->ioctl = &ioc->ioctl_cmds;
-+	/*
-+	 * Allocate and inite a MPT_IOCTL structure
-+	*/
-+	sz = sizeof (MPT_IOCTL);
-+	mem = kmalloc(sz, GFP_KERNEL);
-+	if (mem == NULL) {
-+		err = -ENOMEM;
-+		goto out_fail;
-+	}
-+
-+	memset(mem, 0, sz);
-+	ioc->ioctl = (MPT_IOCTL *) mem;
- 	ioc->ioctl->ioc = ioc;
- 	sema_init(&ioc->ioctl->sem_ioc, 1);
- 	return 0;
-+
-+out_fail:
-+
-+	mptctl_remove(pdev);
-+	return err;
- }
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -3960,8 +3810,9 @@
- static void
- mptctl_remove(struct pci_dev *pdev)
- {
--	//MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
-+	MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
- 
-+	kfree ( ioc->ioctl );
- }
- 
- static struct mpt_pci_driver mptctl_driver = {
-@@ -3983,6 +3834,7 @@
- 		": failed to register dd callbacks\n"));
- 	}
- 
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- #ifdef CONFIG_COMPAT
- 	err = register_ioctl32_conversion(MPTIOCINFO, compat_mptctl_ioctl);
- 	if (++where && err) goto out_fail;
-@@ -4051,14 +3903,6 @@
+@@ -4087,14 +3903,6 @@ static int __init mptctl_init(void)
  	if (++where && err) goto out_fail;
  	err = register_ioctl32_conversion(CC_CSMI_SAS_GET_RAID_CONFIG, compat_mptctl_ioctl);
  	if (++where && err) goto out_fail;
@@ -23193,31 +20115,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	err = register_ioctl32_conversion(CC_CSMI_SAS_SET_PHY_INFO, compat_mptctl_ioctl);
  	if (++where && err) goto out_fail;
  	err = register_ioctl32_conversion(CC_CSMI_SAS_STP_PASSTHRU, compat_mptctl_ioctl);
-@@ -4073,6 +3917,7 @@
- 	if (++where && err) goto out_fail;
- #endif /* CPQ_CIM */
- #endif /* CONFIG_COMPAT */
-+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) */
- 
- 	/* Register this device */
- 	err = misc_register(&mptctl_miscdev);
-@@ -4094,7 +3939,6 @@
- 		err = -EBUSY;
- 		goto out_fail;
- 	}
--	mptctl_taskmgmt_id = mpt_register(mptctl_taskmgmt_reply, MPTCTL_DRIVER);
- 
- 	if (mpt_reset_register(mptctl_id, mptctl_ioc_reset) == 0) {
- 		dprintk((KERN_INFO MYNAM ": Registered for IOC reset notifications\n"));
-@@ -4111,6 +3955,7 @@
- 
- out_fail:
- 
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- #ifdef CONFIG_COMPAT
- 	printk(KERN_ERR MYNAM ": ERROR: Failed to register ioctl32_conversion!"
- 			" (%d:err=%d)\n", where, err);
-@@ -4148,10 +3993,6 @@
+@@ -4185,10 +3993,6 @@ out_fail:
  	unregister_ioctl32_conversion(CC_CSMI_SAS_FIRMWARE_DOWNLOAD);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_GET_RAID_INFO);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_GET_RAID_CONFIG);
@@ -23228,30 +20126,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	unregister_ioctl32_conversion(CC_CSMI_SAS_SET_PHY_INFO);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_STP_PASSTHRU);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_TASK_MANAGEMENT);
-@@ -4160,6 +4001,7 @@
- 	unregister_ioctl32_conversion(CC_CSMI_SAS_GET_LOCATION);
- #endif /* CPQ_CIM */
- #endif /* CONFIG_COMPAT */
-+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) */
- 
- 	mpt_device_driver_deregister(MPTCTL_DRIVER);
- 
-@@ -4180,13 +4022,13 @@
- 	mpt_event_deregister(mptctl_id);
- 	dprintk((KERN_INFO MYNAM ": Deregistered for IOC event notifications\n"));
- 
--	mpt_deregister(mptctl_taskmgmt_id);
- 	/* De-register callback handler from base module */
- 	mpt_deregister(mptctl_id);
- 	printk(KERN_INFO MYNAM ": Deregistered from Fusion MPT base driver\n");
- 
-         mpt_device_driver_deregister(MPTCTL_DRIVER);
- 
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
- #ifdef CONFIG_COMPAT
- 	unregister_ioctl32_conversion(MPTIOCINFO);
- 	unregister_ioctl32_conversion(MPTIOCINFO1);
-@@ -4222,10 +4064,6 @@
+@@ -4260,10 +4064,6 @@ static void mptctl_exit(void)
  	unregister_ioctl32_conversion(CC_CSMI_SAS_FIRMWARE_DOWNLOAD);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_GET_RAID_INFO);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_GET_RAID_CONFIG);
@@ -23262,12 +20137,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  	unregister_ioctl32_conversion(CC_CSMI_SAS_SET_PHY_INFO);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_STP_PASSTHRU);
  	unregister_ioctl32_conversion(CC_CSMI_SAS_TASK_MANAGEMENT);
-@@ -4234,11 +4072,12 @@
- 	unregister_ioctl32_conversion(CC_CSMI_SAS_GET_LOCATION);
- #endif /* CPQ_CIM */
- #endif /* CONFIG_COMPAT */
-+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) */
- 
+@@ -4277,7 +4077,7 @@ static void mptctl_exit(void)
  }
  
  #if defined(CPQ_CIM)
@@ -23276,19 +20146,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.c
  #endif // CPQ_CIM
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptctl.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.h	2009-05-11 23:24:42.000000000 -0600
-@@ -3,10 +3,10 @@
-  *      Fusion MPT misc device (ioctl) driver.
-  *      For use with PCI chip/adapter(s):
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptctl.h linux-2.6.9-55.0.12/drivers/message/fusion/mptctl.h
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptctl.h	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptctl.h	2007-11-02 09:10:23.000000000 +0100
+@@ -5,8 +5,8 @@
   *          LSIFC9xx/LSI409xx Fibre Channel
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
@@ -23302,23 +20168,24 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.h
  
  #define MPT_PRODUCT_LENGTH              12
  
-@@ -93,15 +94,6 @@
- #define MPTDIAGUNREGISTER	_IOWR(MPT_MAGIC_NUMBER,28,mpt_diag_unregister_t)
+@@ -94,16 +95,6 @@
  #define MPTDIAGQUERY		_IOWR(MPT_MAGIC_NUMBER,29,mpt_diag_query_t)
  #define MPTDIAGREADBUFFER	_IOWR(MPT_MAGIC_NUMBER,30,mpt_diag_read_buffer_t)
+ 
 -#ifdef MPT_SUPPORT_FWDLB_IOCTL
 -#define MPTHBAPCIINFO		_IOWR(MPT_MAGIC_NUMBER,31,struct mpt_ioctl_hbapciinfo)
 -#endif
 -
+-
 -#define INITIALIZE_IOCTL_STATUS(status) \
 -	status &= ~( MPT_IOCTL_STATUS_COMMAND_GOOD \
 -	| MPT_IOCTL_STATUS_SENSE_VALID \
 -	| MPT_IOCTL_STATUS_RF_VALID);
 -
- 
  /*
   * SPARC PLATFORM REMARKS:
-@@ -313,28 +305,6 @@
+  * IOCTL data structures that contain pointers
+@@ -314,28 +305,6 @@ typedef struct mpt_ioctl_replace_fw {
  	u8		 newImage[1];
  } mpt_ioctl_replace_fw_t;
  
@@ -23328,7 +20195,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.h
 -    U8  iocState;
 -    U8  revisionID;
 -    U8  reserved1;
--    U16 vendorID; 
+-    U16 vendorID;
 -    U16 deviceID;
 -    U16 subSystemVendorID;
 -    U16 subSystemID;
@@ -23347,39 +20214,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptctl.h
  /* General MPT Pass through data strucutre
   *
   * iocnum
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptfc.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c	2009-05-11 23:24:42.000000000 -0600
-@@ -1,10 +1,10 @@
- /*
-  *  linux/drivers/message/fusion/mptfc.c
-- *      For use with LSI PCI chip/adapter(s)
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      For use with LSI Logic PCI chip/adapter(s)
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptfc.c linux-2.6.9-55.0.12/drivers/message/fusion/mptfc.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptfc.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptfc.c	2007-11-02 09:10:23.000000000 +0100
+@@ -3,8 +3,8 @@
+  *      For use with LSI Logic PCI chip/adapter(s)
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
   */
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -43,11 +43,8 @@
-     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--
--#include <linux/config.h>
--#include <linux/version.h>
--#include <linux/kernel.h>
- #include <linux/module.h>
-+#include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/errno.h>
- #include <linux/kdev_t.h>
-@@ -77,35 +74,16 @@
+@@ -74,7 +74,6 @@
  MODULE_AUTHOR(MODULEAUTHOR);
  MODULE_DESCRIPTION(my_NAME);
  MODULE_LICENSE("GPL");
@@ -23387,48 +20236,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
  
  /* Command line args */
  static int mpt_pq_filter = 0;
- module_param(mpt_pq_filter, int, 0);
- MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1  (default=0)");
- 
--static int mptfc_device_queue_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
--module_param(mptfc_device_queue_depth, int, 0);
--MODULE_PARM_DESC(mptfc_device_queue_depth, " Max Device Queue Depth (default=" __MODULE_STRING(MPT_SCSI_CMD_PER_DEV_HIGH) ")");
--
- static int	mptfcDoneCtx = -1;
- static int	mptfcTaskCtx = -1;
- static int	mptfcInternalCtx = -1; /* Used only for internal commands */
- 
--static int mptfc_slave_configure(struct scsi_device *sdev);
--
--static struct device_attribute mptfc_queue_depth_attr = {
--	.attr = {
--		.name = 	"queue_depth",
--		.mode =		S_IWUSR,
--	},
--	.store = mptscsih_store_queue_depth,
--};
--
--static struct device_attribute *mptfc_dev_attrs[] = {
--	&mptfc_queue_depth_attr,
--	NULL,
--};
- 
- /* Show the ioc state for this card */
- static ssize_t
-@@ -140,8 +118,11 @@
- 	.info				= mptscsih_info,
- 	.queuecommand			= mptscsih_qcmd,
- 	.slave_alloc			= mptscsih_slave_alloc,
--	.slave_configure		= mptfc_slave_configure,
-+	.slave_configure		= mptscsih_slave_configure,
- 	.slave_destroy			= mptscsih_slave_destroy,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
-+	.change_queue_depth 		= mptscsih_change_queue_depth,
-+#endif
- 	.eh_abort_handler		= mptscsih_abort,
- 	.eh_device_reset_handler	= mptscsih_dev_reset,
- 	.eh_bus_reset_handler		= mptscsih_bus_reset,
-@@ -149,12 +130,11 @@
+@@ -131,7 +130,7 @@ static struct scsi_host_template mptfc_d
  	.bios_param			= mptscsih_bios_param,
  	.can_queue			= MPT_FC_CAN_QUEUE,
  	.this_id			= -1,
@@ -23437,55 +20245,16 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
  	.max_sectors			= 8192,
  	.cmd_per_lun			= 7,
  	.use_clustering			= ENABLE_CLUSTERING,
- 	.shost_attrs			= mptfc_host_attrs,
--	.sdev_attrs			= mptfc_dev_attrs,
- 	.dump_sanity_check		= mptscsih_sanity_check,
- 	.dump_poll			= mptscsih_poll,
- };
-@@ -180,42 +160,10 @@
+@@ -161,8 +160,6 @@ static struct pci_device_id mptfc_pci_ta
  		PCI_ANY_ID, PCI_ANY_ID },
  	{ PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC949E,
  		PCI_ANY_ID, PCI_ANY_ID },
--	{ 0x1657, MPI_MANUFACTPAGE_DEVICEID_FC949E,
--		PCI_ANY_ID, PCI_ANY_ID },
+-        { 0x1657, MPI_MANUFACTPAGE_DEVICEID_FC949E,
+-                PCI_ANY_ID, PCI_ANY_ID },
  	{0}	/* Terminating entry */
  };
  MODULE_DEVICE_TABLE(pci, mptfc_pci_table);
- 
--/**
-- * mptfc_slave_configure
-- *
-- *
-- * @sdev
-- *
-- **/
--static int
--mptfc_slave_configure(struct scsi_device *sdev)
--{
--#ifdef MPT_DEBUG_INIT
--	MPT_SCSI_HOST	*hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
--	MPT_ADAPTER *ioc = hd->ioc;
--	int		channel;
--	int		id;
--
--	channel = sdev->channel;
--	id = sdev->id;
--
--	dinitprintk((MYIOC_s_INFO_FMT
--		"%s: id=%d channel=%d sdev->queue_depth=%d mptfc_device_queue_depth=%d\n",
--		ioc->name, __FUNCTION__, id, channel, sdev->queue_depth,
--		mptfc_device_queue_depth));
--#endif
--
--	return mptscsih_slave_configure(sdev, mptfc_device_queue_depth);
--}
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-@@ -233,6 +181,8 @@
+@@ -184,6 +181,8 @@ mptfc_probe(struct pci_dev *pdev, const 
  	MPT_ADAPTER 		*ioc;
  	unsigned long		 flags;
  	int			 sz, ii;
@@ -23494,7 +20263,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
  	int			 ioc_cap;
  	u8			*mem;
  	int			error=0;
-@@ -311,20 +261,52 @@
+@@ -262,16 +261,46 @@ mptfc_probe(struct pci_dev *pdev, const 
  		ioc->name, mpt_can_queue, ioc->req_depth,
  		sh->can_queue));
  
@@ -23511,7 +20280,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
  	 */
  	sh->unique_id = ioc->id;
 -	sh->sg_tablesize = ioc->sg_tablesize;
- 
++
 +	/* Verify that we won't exceed the maximum
 +	 * number of chain buffers
 +	 * We can optimize:  ZZ = req_sz/sizeof(SGE)
@@ -23541,25 +20310,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
 +		  ioc->name, numSGE, sh->sg_tablesize));
 +		sh->sg_tablesize = numSGE;
 +	}
-+
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	/* Set the pci device pointer in Scsi_Host structure.
- 	 */
- 	scsi_set_device(sh, &ioc->pcidev->dev);
-+#endif
- 
- 	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
- 
-@@ -342,29 +324,28 @@
- 	}
- 
- 	memset(mem, 0, sz);
--	ioc->ScsiLookup = (struct scsi_cmnd **) mem;
-+	hd->ScsiLookup = (struct scsi_cmnd **) mem;
  
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ 	/* Set the pci device pointer in Scsi_Host structure.
+@@ -300,24 +329,23 @@ mptfc_probe(struct pci_dev *pdev, const 
  	dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
--		 ioc->name, ioc->ScsiLookup, sz));
-+		 ioc->name, hd->ScsiLookup, sz));
+ 		 ioc->name, hd->ScsiLookup, sz));
  
 -	for (ii=0; ii < ioc->NumberOfBuses; ii++) {
 -		/* Allocate memory for the device structures.
@@ -23597,22 +20353,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
  
  	/* Clear the TM flags
  	 */
-@@ -380,18 +361,13 @@
+@@ -333,17 +361,13 @@ mptfc_probe(struct pci_dev *pdev, const 
  	 */
  	hd->cmdPtr = NULL;
  
 -	/* Initialize this IOC's timers
 +	/* Initialize this SCSI Hosts' timers
  	 * To use, set the timer expires field
--	 * and add_timer.  Used for internally
--	 * generated commands.
+-	 * and add_timer. Used for internally
+-         * generated commands.
 +	 * and add_timer
  	 */
--	init_timer(&hd->InternalCmdTimer);
+-        init_timer(&hd->InternalCmdTimer);
 -	hd->InternalCmdTimer.data = (unsigned long) hd;
 -	hd->InternalCmdTimer.function = mptscsih_InternalCmdTimer_expired;
--
--	init_timer(&ioc->TMtimer);
+-        init_timer(&ioc->TMtimer);
 -	ioc->TMtimer.data = (unsigned long) ioc;
 -	ioc->TMtimer.function = mptscsih_TM_timeout;
 +	init_timer(&hd->timer);
@@ -23621,31 +20376,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
  
  	hd->mpt_pq_filter = mpt_pq_filter;
  
-@@ -404,9 +380,6 @@
+@@ -356,9 +380,6 @@ mptfc_probe(struct pci_dev *pdev, const 
  	hd->scandv_wait_done = 0;
  	hd->last_queue_full = 0;
  
--	init_waitqueue_head(&hd->TM_waitq);
--	hd->TM_wait_done = 0;
+-        init_waitqueue_head(&hd->TM_waitq);
+-        hd->TM_wait_done = 0;
 -
  	error = scsi_add_host (sh, &ioc->pcidev->dev);
  	if(error) {
  		dprintk((KERN_ERR MYNAM
-@@ -428,9 +401,13 @@
- 	.id_table	= mptfc_pci_table,
- 	.probe		= mptfc_probe,
- 	.remove		= __devexit_p(mptscsih_remove),
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	.driver         = {
- 		.shutdown = mptscsih_shutdown,
-         },
-+#else
-+	.shutdown       = mptscsih_shutdown,
-+#endif
- #ifdef CONFIG_PM
- 	.suspend	= mptscsih_suspend,
- 	.resume		= mptscsih_resume,
-@@ -438,59 +415,6 @@
+@@ -394,60 +415,6 @@ static struct pci_driver mptfc_driver = 
  };
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -23655,8 +20396,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
 -	MPT_SCSI_HOST *hd;
 -	u8 event = le32_to_cpu(pEvReply->Event) & 0xFF;
 -
--//	devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to FC host driver!\n",
--//			ioc->name, event));
+-	devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to FC host driver!\n",
+-			ioc->name, event));
 -
 -	if (ioc->sh == NULL ||
 -		((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL))
@@ -23693,7 +20434,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
 -	case MPI_EVENT_EVENT_CHANGE:			/* 0A */
 -	case MPI_EVENT_INTEGRATED_RAID:			/* 0B */
 -	default:
--		devtprintk((KERN_INFO "%s:  Ignoring event (=%02Xh)\n", 
+-		devtprintk((KERN_INFO "%s:  Ignoring event (=%02Xh)\n",
 -			__FUNCTION__, event));
 -		break;
 -	}
@@ -23701,36 +20442,39 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptfc.c
 -	return 1;		/* currently means nothing really */
 -}
 -
+-
 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  /**
   *	mptfc_init - Register MPT adapter(s) as SCSI host(s) with
   *	linux scsi mid-layer.
-@@ -507,9 +431,9 @@
+@@ -464,9 +431,9 @@ mptfc_init(void)
  	mptfcTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTFC_DRIVER);
  	mptfcInternalCtx = mpt_register(mptscsih_scandv_complete, MPTFC_DRIVER);
  
--	if (mpt_event_register(mptfcDoneCtx, mptfc_event_process) == 0) {
+-        if (mpt_event_register(mptfcDoneCtx, mptfc_event_process) == 0) {
 +	if (mpt_event_register(mptfcDoneCtx, mptscsih_event_process) == 0) {
  		devtprintk((KERN_INFO MYNAM
--		  ": mptfc_event_process Registered for IOC event notifications\n"));
+-                  ": mptfc_event_process Registered for IOC event notifications\n"));
 +		  ": Registered for IOC event notifications\n"));
  	}
  
  	if (mpt_reset_register(mptfcDoneCtx, mptscsih_ioc_reset) == 0) {
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptlan.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c	2009-05-11 23:24:42.000000000 -0600
-@@ -1,10 +1,10 @@
- /*
-  *  linux/drivers/message/fusion/mptlan.c
-  *      IP Over Fibre Channel device driver.
-- *      For use with LSI Fibre Channel PCI chip/adapters
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      For use with LSI Logic Fibre Channel PCI chip/adapters
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+@@ -488,7 +455,6 @@ mptfc_exit(void)
+ {
+ 	pci_unregister_driver(&mptfc_driver);
+ 
+-
+ 	mpt_reset_deregister(mptfcDoneCtx);
+ 	dprintk((KERN_INFO MYNAM
+ 	  ": Deregistered for IOC reset notifications\n"));
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptlan.c linux-2.6.9-55.0.12/drivers/message/fusion/mptlan.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptlan.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptlan.c	2007-11-02 09:10:23.000000000 +0100
+@@ -4,7 +4,7 @@
+  *      For use with LSI Logic Fibre Channel PCI chip/adapters
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 2000-2007 LSI Corporation
+- *  Copyright (c) 2000-2007 LSI Logic Corporation
 + *  Copyright (c) 2000-2005 LSI Logic Corporation
   *
   *  $Id: mptlan.c,v 1.55 2003/05/07 14:08:32 Exp $
@@ -23747,7 +20491,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  /*
-@@ -185,16 +183,16 @@
+@@ -185,16 +183,16 @@ lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_H
  	struct net_device *dev = ioc->netdev;
  	int FreeReqFrame = 0;
  
@@ -23767,7 +20511,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  				IOC_AND_NETDEV_NAMES_s_s(dev),
  				tmsg));
  
-@@ -204,14 +202,14 @@
+@@ -204,14 +202,14 @@ lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_H
  		//  mptbase.c::mpt_interrupt() routine and callcack here
  #if 0
  		case LAN_REPLY_FORM_MESSAGE_CONTEXT:
@@ -23784,7 +20528,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  //				  "calling mpt_lan_send_reply (turbo)\n"));
  
  			//	FreeReqFrame = mpt_lan_send_turbo(dev, tmsg);
-@@ -230,7 +228,7 @@
+@@ -230,7 +228,7 @@ lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_H
  			break;
  
  		case LAN_REPLY_FORM_RECEIVE_SINGLE:
@@ -23793,7 +20537,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  //				  "rcv-Turbo = %08x\n", tmsg));
  			mpt_lan_receive_post_turbo(dev, tmsg);
  			break;
-@@ -248,10 +246,10 @@
+@@ -248,10 +246,10 @@ lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_H
  	}
  
  //	msg = (u32 *) reply;
@@ -23806,7 +20550,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  //		  reply->u.hdr.Function));
  
  	switch (reply->u.hdr.Function) {
-@@ -275,7 +273,7 @@
+@@ -275,7 +273,7 @@ lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_H
  			if (!(pRecvRep->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY))
  				FreeReqFrame = 1;
  		} else
@@ -23815,34 +20559,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  				  "ReceivePostReply received.\n"));
  		break;
  	}
-@@ -321,12 +319,15 @@
- 		priv = netdev_priv(dev);
- 	
- 	dlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to LAN driver!\n",
--			reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"));
-+			reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
-+			reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
- 
- 	if (priv->mpt_rxfidx == NULL)
- 		return (1);
- 
--	if (reset_phase == MPT_IOC_PRE_RESET) {
-+	if (reset_phase == MPT_IOC_SETUP_RESET) {
-+		;
-+	} else if (reset_phase == MPT_IOC_PRE_RESET) {
- 		int i;
- 		unsigned long flags;
- 
-@@ -354,7 +355,7 @@
- static int
- mpt_lan_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
- {
--//	dlprintk((KERN_INFO MYNAM ": MPT event routed to LAN driver!\n"));
-+	dlprintk((KERN_INFO MYNAM ": MPT event routed to LAN driver!\n"));
- 
- 	switch (le32_to_cpu(pEvReply->Event)) {
- 	case MPI_EVENT_NONE:				/* 00 */
-@@ -614,7 +615,7 @@
+@@ -617,7 +615,7 @@ mpt_lan_send_turbo(struct net_device *de
  	priv->stats.tx_packets++;
  	priv->stats.tx_bytes += sent->len;
  
@@ -23851,7 +20568,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  			IOC_AND_NETDEV_NAMES_s_s(dev),
  			__FUNCTION__, sent));
  
-@@ -646,7 +647,7 @@
+@@ -649,7 +647,7 @@ mpt_lan_send_reply(struct net_device *de
  
  	count = pSendRep->NumberOfContexts;
  
@@ -23860,7 +20577,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  		 le16_to_cpu(pSendRep->IOCStatus)));
  
  	/* Add check for Loginfo Flag in IOCStatus */
-@@ -680,7 +681,7 @@
+@@ -683,7 +681,7 @@ mpt_lan_send_reply(struct net_device *de
  		sent = priv->SendCtl[ctx].skb;
  		priv->stats.tx_bytes += sent->len;
  
@@ -23869,7 +20586,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  				IOC_AND_NETDEV_NAMES_s_s(dev),
  				__FUNCTION__, sent));
  
-@@ -719,7 +720,7 @@
+@@ -722,7 +720,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, s
  	int ctx;
  	u16 cur_naa = 0x1000;
  
@@ -23878,7 +20595,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  			__FUNCTION__, skb));
  
  	spin_lock_irqsave(&priv->txfidx_lock, flags);
-@@ -745,7 +746,7 @@
+@@ -748,7 +746,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, s
  	ctx = priv->mpt_txfidx[priv->mpt_txfidx_tail--];
  	spin_unlock_irqrestore(&priv->txfidx_lock, flags);
  
@@ -23887,7 +20604,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  //			IOC_AND_NETDEV_NAMES_s_s(dev)));
  
  	pSendReq = (LANSendRequest_t *) mf;
-@@ -780,7 +781,7 @@
+@@ -783,7 +781,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, s
  	pTrans->Flags         = 0;
  	pTrans->TransactionContext[0] = cpu_to_le32(ctx);
  
@@ -23896,7 +20613,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  //			IOC_AND_NETDEV_NAMES_s_s(dev),
  //			ctx, skb, skb->data));
  
-@@ -840,7 +841,7 @@
+@@ -843,7 +841,7 @@ mpt_lan_sdu_send (struct sk_buff *skb, s
  	mpt_put_msg_frame (LanCtx, mpt_dev, mf);
  	dev->trans_start = jiffies;
  
@@ -23905,7 +20622,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  			IOC_AND_NETDEV_NAMES_s_s(dev),
  			le32_to_cpu(pSimple->FlagsLength)));
  
-@@ -861,10 +862,10 @@
+@@ -864,10 +862,10 @@ mpt_lan_wake_post_buckets_task(struct ne
  			schedule_work(&priv->post_buckets_task);
  		} else {
  			schedule_delayed_work(&priv->post_buckets_task, 1);
@@ -23918,7 +20635,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  			   IOC_AND_NETDEV_NAMES_s_s(dev) ));
  	}
  }
-@@ -877,7 +878,7 @@
+@@ -880,7 +878,7 @@ mpt_lan_receive_skb(struct net_device *d
  
  	skb->protocol = mpt_lan_type_trans(skb, dev);
  
@@ -23927,7 +20644,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  		 "delivered to upper level.\n",
  			IOC_AND_NETDEV_NAMES_s_s(dev), skb->len));
  
-@@ -887,13 +888,13 @@
+@@ -890,13 +888,13 @@ mpt_lan_receive_skb(struct net_device *d
  	skb->dev = dev;
  	netif_rx(skb);
  
@@ -23943,7 +20660,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  		  "remaining, %d received back since sod\n",
  		  atomic_read(&priv->buckets_out), priv->total_received));
  
-@@ -1024,8 +1025,8 @@
+@@ -1027,8 +1025,8 @@ mpt_lan_receive_post_reply(struct net_de
  	int count;
  	int i, l;
  
@@ -23954,7 +20671,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  		 le16_to_cpu(pRecvRep->IOCStatus)));
  
  	if ((le16_to_cpu(pRecvRep->IOCStatus) & MPI_IOCSTATUS_MASK) ==
-@@ -1054,14 +1055,14 @@
+@@ -1057,14 +1055,14 @@ mpt_lan_receive_post_reply(struct net_de
  //				offset);
  //	}
  
@@ -23971,7 +20688,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  //			"for single packet, concatenating...\n",
  //				IOC_AND_NETDEV_NAMES_s_s(dev)));
  
-@@ -1083,7 +1084,7 @@
+@@ -1086,7 +1084,7 @@ mpt_lan_receive_post_reply(struct net_de
  			if (szrem < l)
  				l = szrem;
  
@@ -23980,7 +20697,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  //					IOC_AND_NETDEV_NAMES_s_s(dev),
  //					i, l));
  
-@@ -1211,7 +1212,7 @@
+@@ -1214,7 +1212,7 @@ mpt_lan_post_receive_buckets(void *dev_i
  	curr = atomic_read(&priv->buckets_out);
  	buckets = (priv->max_buckets_out - curr);
  
@@ -23989,7 +20706,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  			IOC_AND_NETDEV_NAMES_s_s(dev),
  			__FUNCTION__, buckets, curr));
  
-@@ -1223,7 +1224,7 @@
+@@ -1226,7 +1224,7 @@ mpt_lan_post_receive_buckets(void *dev_i
  		if (mf == NULL) {
  			printk (KERN_ERR "%s: Unable to alloc request frame\n",
  				__FUNCTION__);
@@ -23998,7 +20715,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  				 __FUNCTION__, buckets));
  			goto out;
  		}
-@@ -1334,9 +1335,9 @@
+@@ -1337,9 +1335,9 @@ mpt_lan_post_receive_buckets(void *dev_i
  	}
  
  out:
@@ -24010,20 +20727,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.c
  	__FUNCTION__, priv->total_posted, priv->total_received));
  
  	clear_bit(0, &priv->post_buckets_active);
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptlan.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.h	2009-05-11 23:24:42.000000000 -0600
-@@ -29,7 +29,7 @@
- #include <asm/io.h>
- 
- /* Override mptbase.h by pre-defining these! */
--#define MODULEAUTHOR "LSI Corporation"
-+#define MODULEAUTHOR "LSI Logic Corporation"
- 
- #include "mptbase.h"
- 
-@@ -65,9 +65,9 @@
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptlan.h linux-2.6.9-55.0.12/drivers/message/fusion/mptlan.h
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptlan.h	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptlan.h	2007-11-02 09:10:23.000000000 +0100
+@@ -65,9 +65,9 @@ MODULE_DESCRIPTION(LANAME);
  
  /*****************************************************************************/
  #ifdef MPT_LAN_IO_DEBUG
@@ -24035,44 +20742,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptlan.h
  #endif
  
  #ifdef MPT_LAN_DEBUG
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptsas.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c	2009-05-11 23:24:42.000000000 -0600
-@@ -1,15 +1,15 @@
- /*
-  *  linux/drivers/message/fusion/mptsas.c
-- *      For use with LSI PCI SAS chip/adapter(s)
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      For use with LSI Logic PCI chip/adapter(s)
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptsas.c linux-2.6.9-55.0.12/drivers/message/fusion/mptsas.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptsas.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptsas.c	2007-11-02 09:10:23.000000000 +0100
+@@ -3,8 +3,8 @@
+  *      For use with LSI Logic PCI chip/adapter(s)
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
   */
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
--   This program is free software; you can redistribute it and/or modify
-+    This program is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published by
-     the Free Software Foundation; version 2 of the License.
- 
-@@ -44,10 +44,8 @@
- */
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- 
--#include <linux/config.h>
--#include <linux/version.h>
--#include <linux/kernel.h>
- #include <linux/module.h>
-+#include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/errno.h>
- #include <linux/kdev_t.h>
-@@ -66,7 +64,6 @@
+@@ -64,7 +64,6 @@
  
  #include "mptbase.h"
  #include "mptscsih.h"
@@ -24080,15 +20764,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  #define my_NAME		"Fusion MPT SAS Host driver"
-@@ -76,7 +73,6 @@
+@@ -74,10 +73,8 @@
  MODULE_AUTHOR(MODULEAUTHOR);
  MODULE_DESCRIPTION(my_NAME);
  MODULE_LICENSE("GPL");
 -MODULE_VERSION(my_VERSION);
  
  /* Command line args */
+-
  static int mpt_pq_filter = 0;
-@@ -91,628 +87,40 @@
+ module_param(mpt_pq_filter, int, 0);
+ MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1  (default=0)");
+@@ -90,627 +87,40 @@ static int mpt_sas_hot_plug_enable = 1;
  module_param(mpt_sas_hot_plug_enable, int, 0);
  MODULE_PARM_DESC(mpt_sas_hot_plug_enable, " Enable SAS Hot Plug Support: enable=1 (default=1)");
  
@@ -24096,11 +20783,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -module_param(mpt_cmd_retry_count, int, 0);
 -MODULE_PARM_DESC(mpt_cmd_retry_count, " Device discovery TUR command retry count: default=144");
 -
--static int mptsas_device_queue_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
--module_param(mptsas_device_queue_depth, int, 0);
--MODULE_PARM_DESC(mptsas_device_queue_depth, " Max Device Queue Depth (default=" __MODULE_STRING(MPT_SCSI_CMD_PER_DEV_HIGH) ")");
--
 -extern int mpt_enable_deadioc_detect;
+-
 -extern int	mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 bus, u8 id, u8 lun, int ctx2abort, ulong timeout);
 +extern int	mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
  static int	mptsasDoneCtx = -1;
@@ -24109,6 +20793,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
 -static void mptsas_hotplug_work(void *arg);
 -
+-#if defined(CPQ_CIM)
 -/**
 - * mptsas_sas_io_unit_pg0
 - *
@@ -24171,7 +20856,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -		error = -ENOMEM;
 -		goto out_free_consistent;
 -	}
--	
+-
 -	if (port_info->num_phys)
 -		port_info->handle =
 -		    le16_to_cpu(buffer->PhyData[0].ControllerDevHandle);
@@ -24197,7 +20882,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 - * mptsas_sas_device_pg0
 - *
 - * obtaining SAS_DEVICE page 0
-- * 
+- *
 - * @ioc
 - * device_info
 - *
@@ -24246,7 +20931,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -
 -	cfg.physAddr = dma_handle;
 -	cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
- 
+-
 -	error = mpt_config(ioc, &cfg);
 -	if (error)
 -		goto out_free_consistent;
@@ -24580,7 +21265,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -		if(mpt_raid_phys_disk_pg0(ioc,
 -		    buffer->PhysDisk[i].PhysDiskNum, &phys_disk) != 0)
 -			continue;
--
+ 
 -		mptsas_add_device_component_single(ioc, phys_disk.PhysDiskBus,
 -		    phys_disk.PhysDiskID);
 -	}
@@ -24673,6 +21358,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -	}
 -	up(&ioc->sas_device_info_mutex);
 -}
+-#endif
 -
 -/**
 - * mptsas_find_vdevice
@@ -24740,7 +21426,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  		SCpnt->result = DID_NO_CONNECT << 16;
  		done(SCpnt);
  		return 0;
-@@ -721,42 +129,6 @@
+@@ -719,32 +129,6 @@ mptsas_qcmd(struct scsi_cmnd *SCpnt, voi
  	return mptscsih_qcmd(SCpnt,done);
  }
  
@@ -24754,6 +21440,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -static int
 -mptsas_slave_configure(struct scsi_device *sdev)
 -{
+-#if defined(CPQ_CIM)
 -	MPT_SCSI_HOST	*hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
 -	MPT_ADAPTER *ioc = hd->ioc;
 -	int		channel;
@@ -24762,104 +21449,41 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -	channel = sdev->channel;
 -	id = sdev->id;
 -
--	dinitprintk((MYIOC_s_INFO_FMT
--		"%s: id=%d channel=%d sdev->queue_depth=%d mptsas_device_queue_depth=%d\n",
--		ioc->name, __FUNCTION__, id, channel, sdev->queue_depth,
--		mptsas_device_queue_depth));
 -	if ((ioc->raid_data.isRaid & (1 << id)) == 0)
 -		mptsas_add_device_component_single(ioc, channel, id);
--	return mptscsih_slave_configure(sdev, mptsas_device_queue_depth);
+-#endif
+-	return mptscsih_slave_configure(sdev);
 -}
 -
--static struct device_attribute mptsas_queue_depth_attr = {
--	.attr = {
--		.name = 	"queue_depth",
--		.mode =		S_IWUSR,
--	},
--	.store = mptscsih_store_queue_depth,
--};
--
 -
  /* Show the ioc state for this card */
  static ssize_t
  mptsas_show_iocstate(struct class_device *class_dev, char *buf)
-@@ -782,48 +154,6 @@
-         NULL,
- };
- 
--static ssize_t mptsas_show_sas_address (struct device *dev, char *buf)
--{
--	struct scsi_device *sdev = to_scsi_device(dev);
--	MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) sdev->host->hostdata;
--	MPT_ADAPTER *ioc = hd->ioc;
--	struct sas_device_info  *si, *sas_info = NULL;
--	ssize_t len = -ENXIO;
--
--	down(&ioc->sas_device_info_mutex);
--	list_for_each_entry(si, &ioc->sas_device_info_list, list) {
--		if (si->os.channel == sdev->channel &&
--		    si->os.id == sdev->id) {
--			sas_info = si;
--			goto out;
--		}
--	}
--
--out:
--	if (sas_info)
--		len = snprintf(buf, 20, "0x%016llx\n",
--				(unsigned long long) sas_info->sas_address);
--
--	up(&ioc->sas_device_info_mutex);
--	return len;
--}
--
--static struct device_attribute mptsas_sas_address_attr = {
--	.attr = {
--		.name =		"suse_sas_address",
--		.mode =		S_IRUSR,
--	},
--	.show = mptsas_show_sas_address
--};
--
--/* Device attributes */
--static struct device_attribute *mptsas_dev_attrs[] = {
--	&mptsas_queue_depth_attr,
--	&mptsas_sas_address_attr,
--	NULL,
--};
--
--
- static struct scsi_host_template mptsas_driver_template = {
- 	.module				= THIS_MODULE,
- 	.proc_name			= "mptsas",
-@@ -832,8 +162,11 @@
+@@ -778,300 +162,49 @@ static struct scsi_host_template mptsas_
  	.info				= mptscsih_info,
  	.queuecommand			= mptsas_qcmd,
  	.slave_alloc			= mptscsih_slave_alloc,
 -	.slave_configure		= mptsas_slave_configure,
-+	.slave_configure		= mptscsih_slave_configure,
- 	.slave_destroy			= mptscsih_slave_destroy,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
-+	.change_queue_depth 		= mptscsih_change_queue_depth,
-+#endif
- 	.eh_abort_handler		= mptscsih_abort,
- 	.eh_device_reset_handler	= mptscsih_dev_reset,
- 	.eh_bus_reset_handler		= mptscsih_bus_reset,
-@@ -841,287 +174,37 @@
- 	.bios_param			= mptscsih_bios_param,
- 	.can_queue			= MPT_FC_CAN_QUEUE,
- 	.this_id			= -1,
+-	.slave_destroy			= mptscsih_slave_destroy,
+-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
+-	.change_queue_depth 		= mptscsih_change_queue_depth,
+-#endif
+-	.eh_abort_handler		= mptscsih_abort,
+-	.eh_device_reset_handler	= mptscsih_dev_reset,
+-	.eh_bus_reset_handler		= mptscsih_bus_reset,
+-	.eh_host_reset_handler		= mptscsih_host_reset,
+-	.bios_param			= mptscsih_bios_param,
+-	.can_queue			= MPT_FC_CAN_QUEUE,
+-	.this_id			= -1,
 -	.sg_tablesize			= CONFIG_FUSION_MAX_SGE,
-+	.sg_tablesize			= MPT_SCSI_SG_DEPTH,
- 	.max_sectors			= 8192,
- 	.cmd_per_lun			= 7,
- 	.use_clustering			= ENABLE_CLUSTERING,
- 	.shost_attrs			= mptsas_host_attrs,
--	.sdev_attrs			= mptsas_dev_attrs,
- 	.dump_sanity_check		= mptscsih_sanity_check,
- 	.dump_poll			= mptscsih_poll,
- };
- 
+-	.max_sectors			= 8192,
+-	.cmd_per_lun			= 7,
+-	.use_clustering			= ENABLE_CLUSTERING,
+-	.shost_attrs			= mptsas_host_attrs,
+-	.dump_sanity_check		= mptscsih_sanity_check,
+-	.dump_poll			= mptscsih_poll,
+-};
+-
 -/**
 - * mptsas_remove
 - *
@@ -24869,9 +21493,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 - **/
 -static void __devexit mptsas_remove(struct pci_dev *pdev)
 -{
+-#if defined(CPQ_CIM)
 -	MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
--	if(ioc->sh != NULL)
--		mptsas_del_device_components(ioc);
+-  if(ioc->sh != NULL)
+-	mptsas_del_device_components(ioc);
+-#endif
 -
 -	flush_scheduled_work();
 -	mptscsih_remove(pdev);
@@ -24916,7 +21542,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -	DBG_DUMP_TM_REQUEST_FRAME(mf);
 -
 -	if (mpt_send_handshake_request(ioc->TaskCtx, ioc,
--	    sizeof(SCSITaskMgmt_t), (u32 *)mf, 10, NO_SLEEP)) {
+-	    sizeof(SCSITaskMgmt_t), (u32 *)mf, 10,NO_SLEEP)) {
 -		mpt_free_msg_frame(ioc, mf);
 -		dfailprintk((MYIOC_s_WARN_FMT "%s, tm handshake failed @%d!!\n",
 -		    ioc->name,__FUNCTION__, __LINE__));
@@ -25072,7 +21698,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -		hd->resetPending = 1;
 -	}
 -}
--
++	.slave_configure		= mptscsih_slave_configure,
++	.slave_destroy			= mptscsih_slave_destroy,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
++	.change_queue_depth 		= mptscsih_change_queue_depth,
++#endif
++	.eh_abort_handler		= mptscsih_abort,
++	.eh_device_reset_handler	= mptscsih_dev_reset,
++	.eh_bus_reset_handler		= mptscsih_bus_reset,
++	.eh_host_reset_handler		= mptscsih_host_reset,
++	.bios_param			= mptscsih_bios_param,
++	.can_queue			= MPT_FC_CAN_QUEUE,
++	.this_id			= -1,
++	.sg_tablesize			= MPT_SCSI_SG_DEPTH,
++	.max_sectors			= 8192,
++	.cmd_per_lun			= 7,
++	.use_clustering			= ENABLE_CLUSTERING,
++	.shost_attrs			= mptsas_host_attrs,
++	.dump_sanity_check		= mptscsih_sanity_check,
++	.dump_poll			= mptscsih_poll,
++};
+ 
 -/**
 - * mptsas_taskmgmt_complete
 - *
@@ -25083,11 +21729,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 - **/
 -static int
 -mptsas_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
--{
++static void __devexit mptsas_remove(struct pci_dev *pdev)
+ {
 -	mptsas_dev_reset_complete(ioc);
 -	return mptscsih_taskmgmt_complete(ioc, mf, mr);
--}
--
++	flush_scheduled_work();
++	mptscsih_remove(pdev);
+ }
+ 
 -/**
 - * mptscsih_ioc_reset
 - *
@@ -25097,46 +21746,36 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 - **/
 -static int
 -mptsas_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
--{
--	MPT_SCSI_HOST	*hd =NULL;	
++static void
++mptsas_target_reset(MPT_ADAPTER *ioc, VirtDevice * vdevice)
+ {
+-        MPT_SCSI_HOST   *hd =NULL;
 -	struct mptscsih_target_reset	*target_reset_list, *n;
 -	int rc;
--	
--	if ((ioc->sh != NULL) && (ioc->sh->hostdata != NULL))
-- 		hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
 -
--	rc = mptscsih_ioc_reset(ioc, reset_phase);
+-        if ((ioc->sh != NULL) && (ioc->sh->hostdata != NULL))
+-              hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
 -
+-	rc = mptscsih_ioc_reset(ioc, reset_phase);
++	MPT_SCSI_HOST		*hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
+ 
 -	if (reset_phase != MPT_IOC_POST_RESET)
 -		goto out;
 -
 -	if (ioc->bus_type != SAS)
 -		goto out;
--	
--	if(hd == NULL)
--		goto out;
+-       if(hd == NULL)
+-               goto out;
+-
 -
 -	if (list_empty(&hd->target_reset_list))
 -		goto out;
-+static void __devexit mptsas_remove(struct pci_dev *pdev)
-+{
-+	flush_scheduled_work();
-+	mptscsih_remove(pdev);
-+}
- 
+-
 -	/* flush the target_reset_list */
 -	list_for_each_entry_safe(target_reset_list, n,
 -	    &hd->target_reset_list, list) {
 -		list_del(&target_reset_list->list);
 -		kfree(target_reset_list);
--	}
-+static void
-+mptsas_target_reset(MPT_ADAPTER *ioc, VirtDevice * vdevice)
-+{
-+	MPT_SCSI_HOST		*hd = (MPT_SCSI_HOST *)ioc->sh->hostdata;
- 
-- out:
--	return rc;
 +	if (mptscsih_TMHandler(hd,
 +	     MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
 +	     vdevice->bus_id, vdevice->target_id, 0, 0, 5) < 0) {
@@ -25145,14 +21784,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 +		printk(MYIOC_s_WARN_FMT
 +	       "Error processing TaskMgmt id=%d TARGET_RESET\n",
 +			ioc->name, vdevice->target_id);
-+	}
+ 	}
+-
+- out:
+-	return rc;
  }
  
 -
  /****************************************************************************
   * Supported hardware
   */
-@@ -1142,13 +225,6 @@
+@@ -1092,13 +225,6 @@ static struct pci_device_id mptsas_pci_t
  MODULE_DEVICE_TABLE(pci, mptsas_pci_table);
  
  
@@ -25166,7 +21808,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  static void
  mptscsih_sas_persist_clear_table(void * arg)
  {
-@@ -1157,52 +233,76 @@
+@@ -1107,52 +233,76 @@ mptscsih_sas_persist_clear_table(void * 
  	mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
  }
  
@@ -25280,7 +21922,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  }
  
  /*
-@@ -1217,32 +317,20 @@
+@@ -1167,32 +317,20 @@ mptsas_remove_target(MPT_ADAPTER *ioc, s
  	struct Scsi_Host *shost = ioc->sh;
  	unsigned long flags;
  	struct scsi_device *sdev;
@@ -25290,13 +21932,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  	id = hot_plug_info->id;
 -	channel = hot_plug_info->channel;
- 
+-
 -	if ( id >= ioc->DevicesPerBus ) {
 -		printk(MYIOC_s_WARN_FMT "%s: Invalid id=%d, DevicesPerBus=%d\n",
 -		    ioc->name, __FUNCTION__, id, ioc->DevicesPerBus);
 -		return;
 -	}
--
+ 
 -	if ( channel >= ioc->NumberOfBuses ) {
 -		printk(MYIOC_s_WARN_FMT
 -		    "%s: Invalid channel=%d, NumberOfBuses=%d\n",
@@ -25319,7 +21961,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	spin_lock_irqsave(shost->host_lock, flags);
   restart:
  	list_for_each_entry(sdev, &shost->__devices, siblings) {
-@@ -1258,50 +346,49 @@
+@@ -1208,46 +346,26 @@ mptsas_remove_target(MPT_ADAPTER *ioc, s
  	spin_unlock_irqrestore(shost->host_lock, flags);
  }
  
@@ -25370,33 +22012,24 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -		return;
 -	}
 -
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14))
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14))
  	sdev = scsi_add_device(ioc->sh, channel, id, lun);
  	if (!IS_ERR(sdev))
- 		mptsas_hotplug_print(ioc, hot_plug_info, lun,
- 		    "attaching");
-+#else
-+	error = scsi_add_device(ioc->sh, channel, id, lun);
-+	if (!error) /* no error */
-+		mptsas_hotplug_print(ioc, hot_plug_info, lun,
-+		    "attaching");
-+#endif
-+}
-+
-+static int scsilun_to_int(struct scsi_lun *scsilun)
-+{
-+	int i;
-+	unsigned int lun;
-+
-+	lun = 0;
-+	for (i = 0; i < sizeof(lun); i += 2)
-+		lun = lun | (((scsilun->scsi_lun[i] << 8) |
-+			scsilun->scsi_lun[i + 1]) << (i * 8));
-+	return lun;
+@@ -1261,13 +379,6 @@ mptsas_add_device(MPT_ADAPTER *ioc, stru
+ #endif
  }
  
- /*
-@@ -1322,170 +409,56 @@
+-/**
+- * scsilun_to_int
+- *
+- *
+- * @scsilun
+- *
+- **/
+ static int scsilun_to_int(struct scsi_lun *scsilun)
+ {
+ 	int i;
+@@ -1298,170 +409,56 @@ mptsas_scan_target(MPT_ADAPTER *ioc, str
  	u32 		length, channel, id, lun, num_luns;
  	u8 		*data;
  	u32		retries;
@@ -25405,7 +22038,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  	id = hot_plug_info->id;
 -	channel = hot_plug_info->channel;
--
+ 
 -	if ( id > ioc->DevicesPerBus ) {
 -		printk(MYIOC_s_WARN_FMT "%s: Invalid id=%d, DevicesPerBus=%d\n",
 -		    ioc->name, __FUNCTION__, id, ioc->DevicesPerBus);
@@ -25418,7 +22051,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -		    ioc->name, __FUNCTION__, channel, ioc->NumberOfBuses);
 -		return;
 -	}
- 
+-
 -	/*
 -	 * Integrated RAID doesn't support REPORT_LUNS, it will timeout
 -	 */
@@ -25473,7 +22106,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -		} else if (rc == MPT_SCANDV_BUSY) {
 -			dinitprintk((MYIOC_s_INFO_FMT "TUR: BUSY\n",
 -				ioc->name));
--			msleep(1000);  /* sleep 1 second */
+-		         msleep(1000);  /* sleep 1 second */
 -			continue;
 -		} else if (rc == MPT_SCANDV_SENSE) {
 -			u8 skey = hd->pLocal->sense[2] & 0x0F;
@@ -25493,7 +22126,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -				dinitprintk((MYIOC_s_INFO_FMT
 -				    "TUR: Becoming Ready\n",
 -				    ioc->name));
--				msleep(1000);  /* sleep 1 second */
+-                                    msleep(1000);  /* sleep 1 second */
 -				continue;
 -			}
 -		}
@@ -25554,7 +22187,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -			goto report_luns_done;
 -		} else if (rc == MPT_SCANDV_BUSY) {
 -			dinitprintk((MYIOC_s_INFO_FMT "RL: BUSY\n", ioc->name));
--			msleep(1000);  /* sleep 1 second */
+-		        msleep(1000);
 -			continue;
 -		} else if (rc == MPT_SCANDV_SENSE) {
 -			u8 skey = hd->pLocal->sense[2] & 0x0F;
@@ -25572,8 +22205,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -			    (asc == 0x04)&&(ascq == 0x01)) {
 -				dinitprintk((MYIOC_s_INFO_FMT
 -				    "RL: Becoming Ready\n", ioc->name));
--				msleep(1000);  /* sleep 1 second */
--				continue;
+-				     msleep(1000);
+-                                     continue;
 -			}
 -		}
 +		completion_code = mptscsih_do_cmd(hd, &iocmd);
@@ -25586,7 +22219,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	/*
  	 * Attaching lun=0
  	 */
-@@ -1494,8 +467,6 @@
+@@ -1470,8 +467,6 @@ mptsas_scan_target(MPT_ADAPTER *ioc, str
  	/*
  	 * Get the length from the first four bytes of lun_data.
  	 */
@@ -25595,7 +22228,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	data = (u8 *)lun_data;
  	length = ((data[0] << 24) | (data[1] << 16) |
  	    (data[2] << 8) | (data[3] << 0));
-@@ -1525,85 +496,93 @@
+@@ -1501,91 +496,93 @@ mptsas_scan_target(MPT_ADAPTER *ioc, str
  		    lun_data_dma);
  }
  
@@ -25644,9 +22277,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  	switch  (hot_plug_info->event_type) {
  	case MPTSAS_DEL_DEVICE:
+-#if defined(CPQ_CIM)
 -		mptsas_del_device_component(ioc, channel, id);
 -		if (hot_plug_info->refresh_raid_config_pages)
 -			mptsas_add_device_component_hotspare(ioc);
+-#endif
  		dhotpprintk((MYIOC_s_WARN_FMT
  		    "MPTSAS_DEL_DEVICE: channel=%d id=%d\n",
 -		    ioc->name, channel, id));
@@ -25666,8 +22301,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  		break;
  
  	case MPTSAS_ADD_DEVICE:
+-#if defined(CPQ_CIM)
 -		if (ioc->raid_data.isRaid & (1 << id))
 -			mptsas_add_device_component_ir(ioc, channel, id);
+-#endif
  		dhotpprintk((MYIOC_s_WARN_FMT
  		    "MPTSAS_ADD_DEVICE: channel=%d id=%d\n",
 -		    ioc->name, channel, id));
@@ -25683,6 +22320,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 +		}
  		mptsas_scan_target(ioc, hot_plug_info);
  		break;
+-#if defined(CPQ_CIM)
 -	case MPTSAS_ADD_INACTIVE_VOLUME:
 -		dhotpprintk((MYIOC_s_WARN_FMT
 -		    "MPTSAS_ADD_INACTIVE_VOLUME: channel=%d id=%d\n",
@@ -25692,6 +22330,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -	case MPTSAS_PHYSDISK_ADD:
 -		mptsas_add_device_component_single(ioc, channel, id);
 -		break;
+-#endif
  	default:
  		dhotpprintk((MYIOC_s_WARN_FMT
 -		    "Unknown hot_plug event_type=%x: channel=%d id=%d "
@@ -25734,7 +22373,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  static void
  mptsas_send_sas_event(MPT_ADAPTER *ioc,
  		EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *sas_event_data)
-@@ -1628,11 +607,8 @@
+@@ -1610,11 +607,8 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
  	}
  
  	switch (sas_event_data->ReasonCode) {
@@ -25747,7 +22386,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  		ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
  		if (!ev) {
  			printk(KERN_WARNING "mptsas: lost hotplug event\n");
-@@ -1660,7 +636,6 @@
+@@ -1642,7 +636,6 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
  			ev->event_type = MPTSAS_DEL_DEVICE;
  		schedule_work(&ev->work);
  		break;
@@ -25755,7 +22394,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	case MPI_EVENT_SAS_DEV_STAT_RC_NO_PERSIST_ADDED:
  	/*
  	 * Persistent table is full.
-@@ -1670,7 +645,6 @@
+@@ -1652,7 +645,6 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
  		    (void *)ioc);
  		schedule_work(&ioc->mptscsih_persistTask);
  		break;
@@ -25763,7 +22402,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
  	/* TODO */
  	case MPI_EVENT_SAS_DEV_STAT_RC_INTERNAL_DEVICE_RESET:
-@@ -1680,21 +654,12 @@
+@@ -1662,21 +654,12 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
  	}
  }
  
@@ -25786,7 +22425,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  	if (ioc->bus_type != SAS)
  		return;
-@@ -1706,13 +671,11 @@
+@@ -1688,13 +671,11 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
  	}
  
  	memset(ev,0,sizeof(struct mptsas_hotplug_event));
@@ -25802,7 +22441,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	switch (raid_event_data->ReasonCode) {
  	case MPI_EVENT_RAID_RC_PHYSDISK_DELETED:
  		ev->event_type = MPTSAS_ADD_DEVICE;
-@@ -1720,190 +683,25 @@
+@@ -1702,24 +683,6 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
  	case MPI_EVENT_RAID_RC_PHYSDISK_CREATED:
  		ev->event_type = MPTSAS_DEL_DEVICE;
  		break;
@@ -25827,10 +22466,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	case MPI_EVENT_RAID_RC_VOLUME_DELETED:
  		ev->event_type = MPTSAS_DEL_DEVICE;
  		break;
- 	case MPI_EVENT_RAID_RC_VOLUME_CREATED:
+@@ -1727,68 +690,18 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
  		ev->event_type = MPTSAS_ADD_DEVICE;
  		break;
--/*	case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
+ 	case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
 -		switch (state) {
 -		case MPI_RAIDVOL0_STATUS_STATE_FAILED:
 -		case MPI_RAIDVOL0_STATUS_STATE_MISSING:
@@ -25845,23 +22484,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -			    ": ignoring this event! %d\n", __LINE__));
 -			return;
 -		}
--		break; */
-+	case MPI_EVENT_RAID_RC_VOLUME_STATUS_CHANGED:
 +		volumeStatus = (RAID_VOL0_STATUS *) &
 +		    raid_event_data->SettingsStatus;
 +		ev->event_type = (volumeStatus->State ==
 +		    MPI_RAIDVOL0_STATUS_STATE_FAILED) ?
 +		    MPTSAS_DEL_DEVICE : MPTSAS_ADD_DEVICE;
-+		break;
+ 		break;
  	default:
 -		devtprintk((KERN_INFO MYNAM
 -		    ": ignoring this event! %d\n", __LINE__));
 -		return;
--	}
++		break;
+ 	}
 -	INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
--	schedule_work(&ev->work);
--}
--
+ 	schedule_work(&ev->work);
+ }
+ 
+-#if defined(CPQ_CIM)
 -/*
 - * mptsas_send_ir2_event
 - *
@@ -25889,108 +22528,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -	INIT_WORK(&ev->work, mptsas_hotplug_work, ev);
 -	schedule_work(&ev->work);
 -};
--
--
--/**
-- *	mptsas_broadcast_primative_work - Work queue thread to handle
-- *	broadcast primitive events
-- *	@arg: work queue payload containing info describing the event
-- *
-- **/
--static void
--mptsas_broadcast_primative_work(void *arg)
--{
--	struct mptsas_broadcast_primative_event *ev = arg;
--	MPT_ADAPTER		*ioc = ev->ioc;
--	MPT_SCSI_HOST		*hd;
--	MPT_FRAME_HDR		*mf;
--	VirtDevice		*vdevice;
--	int			ii;
--	struct scsi_cmnd	*sc;
--	int			task_context;
--	u8			channel, id;
--	int			 lun;
--
--	hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
--	mpt_findImVolumes(ioc);
--	down(&ioc->AEN_semaphore);
--	dtmprintk((MYIOC_s_WARN_FMT "%s - enter\n", ioc->name, __FUNCTION__));
--	for (ii = 0; ii < ioc->req_depth; ii++) {
--		sc = ioc->ScsiLookup[ii];
--		if (!sc)
--			continue;
--		mf = MPT_INDEX_2_MFPTR(ioc, ii);
--		if (!mf)
--			continue;
--		task_context = mf->u.frame.hwhdr.msgctxu.MsgContext;
--		channel = sc->device->channel;
--		id = sc->device->id;
--		lun = sc->device->lun;
--		vdevice = mptsas_find_vdevice(ioc, channel, id);
--		if (!vdevice)
--			continue;
--		if (vdevice->raidVolume)
--			continue; /* skip raid volumes */
--		if (mptscsih_IssueTaskMgmt(hd,
--		    MPI_SCSITASKMGMT_TASKTYPE_QUERY_TASK,
--		    channel, id, lun, task_context, 30)) {
--			dtmprintk((MYIOC_s_WARN_FMT "%s: QUERY_TASK "
--			    "failed!\n", ioc->name, __FUNCTION__));
--			continue;
--		}
--		if ((hd->tm_iocstatus == MPI_IOCSTATUS_SUCCESS) &&
--		    (hd->tm_response_code == MPI_SCSITASKMGMT_RSP_TM_SUCCEEDED
--		     || hd->tm_response_code ==
--		     MPI_SCSITASKMGMT_RSP_IO_QUEUED_ON_IOC))
--			continue;
--		if (mptscsih_IssueTaskMgmt(hd,
--		    MPI_SCSITASKMGMT_TASKTYPE_ABRT_TASK_SET,
--		    channel, id, lun, 0, 30))
--			dtmprintk((MYIOC_s_WARN_FMT "%s: ABRT_TASK_SET "
--			    "failed!\n", ioc->name, __FUNCTION__));
--		else
--			dtmprintk((MYIOC_s_WARN_FMT "%s: ABRT_TASK_SET "
--			    "successful!\n", ioc->name, __FUNCTION__));
-+		break;
- 	}
--
--	ioc->broadcast_aen_busy = 0;
--	dtmprintk((MYIOC_s_WARN_FMT "%s - exit\n", ioc->name, __FUNCTION__));
--	up(&ioc->AEN_semaphore);
--	kfree(ev);
--}
+-#endif
 -
 -/**
-- *	mptsas_send_broadcast_primative_event - processing of event data
-- *	@ioc: Pointer to MPT_ADAPTER structure
-- *	broadcast_event_data: event data
-- *
-- **/
--static void
--mptsas_send_broadcast_primative_event(MPT_ADAPTER * ioc,
--	EVENT_DATA_SAS_BROADCAST_PRIMITIVE *broadcast_event_data)
--{
--	struct mptsas_broadcast_primative_event *ev;
--
--	if (ioc->broadcast_aen_busy)
--		return;
--
--	if (broadcast_event_data->Primitive !=
--	    MPI_EVENT_PRIMITIVE_ASYNCHRONOUS_EVENT)
--		return;
--
--	ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
--	if (!ev)
--		return;
--
--	ioc->broadcast_aen_busy = 1;
--	memset(ev, 0, sizeof(*ev));
--	INIT_WORK(&ev->work, mptsas_broadcast_primative_work, ev);
--	ev->ioc = ioc;
- 	schedule_work(&ev->work);
- }
- 
--/**
 - * mptsas_event_process
 - *
 - *
@@ -26001,36 +22541,38 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  static int
  mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
  {
-@@ -1918,12 +716,10 @@
+@@ -1803,16 +716,10 @@ mptsas_event_process(MPT_ADAPTER *ioc, E
  
  	switch (event) {
  	case MPI_EVENT_SAS_DEVICE_STATUS_CHANGE:
+-#if defined(CPQ_CIM)
 -		ioc->csmi_change_count++;
+-#endif
  		mptsas_send_sas_event(ioc,
  			(EVENT_DATA_SAS_DEVICE_STATUS_CHANGE *)reply->Data);
  		break;
  	case MPI_EVENT_INTEGRATED_RAID:
+-#if defined(CPQ_CIM)
 -		ioc->csmi_change_count++;
+-#endif
  		mptsas_send_raid_event(ioc,
  			(EVENT_DATA_RAID *)reply->Data);
  		break;
-@@ -1933,15 +729,6 @@
+@@ -1822,13 +729,6 @@ mptsas_event_process(MPT_ADAPTER *ioc, E
  		    (void *)ioc);
  		schedule_work(&ioc->mptscsih_persistTask);
  		break;
+-#if defined(CPQ_CIM)
 -	case MPI_EVENT_IR2:
 -		ioc->csmi_change_count++;
 -		mptsas_send_ir2_event(ioc,
 -		    (PTR_MPI_EVENT_DATA_IR2)reply->Data);
 -		break;
--	case MPI_EVENT_SAS_BROADCAST_PRIMITIVE:
--		mptsas_send_broadcast_primative_event(ioc,
--			(EVENT_DATA_SAS_BROADCAST_PRIMITIVE *)reply->Data);
--		break;
+-#endif
  	default:
  		rc = mptscsih_event_process(ioc, reply);
  		break;
-@@ -1968,11 +755,12 @@
+@@ -1855,13 +755,12 @@ mptsas_probe(struct pci_dev *pdev, const
  	MPT_ADAPTER 		*ioc;
  	unsigned long		 flags;
  	int			 sz, ii;
@@ -26040,23 +22582,24 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	u8			*mem;
  	int			error=0;
  	int			r;
+-#if defined(CPQ_CIM)
 -	struct mptsas_portinfo	*port_info;
+-#endif
  
  	if ((r = mpt_attach(pdev,id)) != 0)
  		return r;
-@@ -1985,26 +773,18 @@
+@@ -1874,27 +773,19 @@ mptsas_probe(struct pci_dev *pdev, const
  	/*  Added sanity check on readiness of the MPT adapter.
  	 */
  	if (ioc->last_state != MPI_IOC_STATE_OPERATIONAL) {
--		if(mpt_enable_deadioc_detect)
--			return 0;
--		else {
--			printk(MYIOC_s_WARN_FMT
--		  		"Skipping because it's not operational!\n",
--		  		ioc->name);
--			error = -ENODEV;
--			goto out_mptsas_probe;
--		}
+-                 if(mpt_enable_deadioc_detect)
+-	             return 0;
+-                 else {
+-                  printk(MYIOC_s_WARN_FMT
+-                         "Skipping because it's not operational!\n", ioc->name);
+-                      error = -ENODEV;
+-               goto out_mptsas_probe;
+-                 }
 +		printk(MYIOC_s_WARN_FMT
 +		  "Skipping because it's not operational!\n",
 +		  ioc->name);
@@ -26065,22 +22608,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	}
  
  	if (!ioc->active) {
--		if(mpt_enable_deadioc_detect)
--			return 0;
--		else {
--			printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
--		  	ioc->name);
--			error = -ENODEV;
--			goto out_mptsas_probe;
--		}
+-	      if(mpt_enable_deadioc_detect)
+-                      return 0;
+-               else {
+-
+-              printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
 +		printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
-+		  ioc->name);
-+		error = -ENODEV;
-+		goto out_mptsas_probe;
+ 		  ioc->name);
+ 		error = -ENODEV;
+ 		goto out_mptsas_probe;
  	}
+-     }
  
  	/*  Sanity check - ensure at least 1 port is INITIATOR capable
-@@ -2017,8 +797,9 @@
+ 	 */
+@@ -1906,8 +797,9 @@ mptsas_probe(struct pci_dev *pdev, const
  	}
  
  	if (!ioc_cap) {
@@ -26092,7 +22634,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  		return 0;
  	}
  
-@@ -2026,8 +807,8 @@
+@@ -1915,8 +807,8 @@ mptsas_probe(struct pci_dev *pdev, const
  
  	if (!sh) {
  		printk(MYIOC_s_WARN_FMT
@@ -26103,7 +22645,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  		error = -1;
  		goto out_mptsas_probe;
          }
-@@ -2050,23 +831,55 @@
+@@ -1939,19 +831,49 @@ mptsas_probe(struct pci_dev *pdev, const
  	else
  		sh->can_queue = ioc->req_depth;
  	dinitprintk((MYIOC_s_INFO_FMT
@@ -26125,7 +22667,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	 */
  	sh->unique_id = ioc->id;
 -	sh->sg_tablesize = ioc->sg_tablesize;
- 
++
 +	/* Verify that we won't exceed the maximum
 +	 * number of chain buffers
 +	 * We can optimize:  ZZ = req_sz/sizeof(SGE)
@@ -26155,16 +22697,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 +		  ioc->name, numSGE, sh->sg_tablesize));
 +		sh->sg_tablesize = numSGE;
 +	}
-+
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	/* Set the pci device pointer in Scsi_Host structure.
- 	 */
- 	scsi_set_device(sh, &ioc->pcidev->dev);
-+#endif
- 
- 	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
  
-@@ -2077,36 +890,35 @@
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ 	/* Set the pci device pointer in Scsi_Host structure.
+@@ -1968,7 +890,7 @@ mptsas_probe(struct pci_dev *pdev, const
  	 * (with size equal to req_depth*PtrSz!)
  	 */
  	sz = ioc->req_depth * sizeof(void *);
@@ -26173,14 +22709,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	if (mem == NULL) {
  		error = -ENOMEM;
  		goto out_mptsas_probe;
- 	}
- 
- 	memset(mem, 0, sz);
--	ioc->ScsiLookup = (struct scsi_cmnd **) mem;
-+	hd->ScsiLookup = (struct scsi_cmnd **) mem;
+@@ -1978,26 +900,25 @@ mptsas_probe(struct pci_dev *pdev, const
+ 	hd->ScsiLookup = (struct scsi_cmnd **) mem;
  
  	dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
--	    ioc->name, ioc->ScsiLookup, sz));
+-	    ioc->name, hd->ScsiLookup, sz));
 +		 ioc->name, hd->ScsiLookup, sz));
  
 -	for (ii=0; ii < ioc->NumberOfBuses; ii++) {
@@ -26219,39 +22752,31 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  	/* Clear the TM flags
  	 */
-@@ -2122,73 +934,44 @@
+@@ -2013,18 +934,13 @@ mptsas_probe(struct pci_dev *pdev, const
  	 */
  	hd->cmdPtr = NULL;
  
--	/* Initialize this IOC's timers
+-	/* Initialize this IOC's  timers
 +	/* Initialize this SCSI Hosts' timers
  	 * To use, set the timer expires field
--	 * and add_timer.  Used for internally
--	 * generated commands.
+-	 * and add_timer. Used for internally
+-         * generated commands.
 +	 * and add_timer
  	 */
--	init_timer(&hd->InternalCmdTimer);
--	hd->InternalCmdTimer.data = (unsigned long) hd;
--	hd->InternalCmdTimer.function = mptscsih_InternalCmdTimer_expired;
+-       init_timer(&hd->InternalCmdTimer);
+-       hd->InternalCmdTimer.data = (unsigned long) hd;
+-       hd->InternalCmdTimer.function = mptscsih_InternalCmdTimer_expired;
 -
--	init_timer(&ioc->TMtimer);
--	ioc->TMtimer.data = (unsigned long) ioc;
--	ioc->TMtimer.function = mptscsih_TM_timeout;
+-       init_timer(&ioc->TMtimer);
+-       ioc->TMtimer.data = (unsigned long) ioc;
+-       ioc->TMtimer.function = mptscsih_TM_timeout;
 +	init_timer(&hd->timer);
 +	hd->timer.data = (unsigned long) hd;
 +	hd->timer.function = mptscsih_timer_expired;
  
--	init_MUTEX(&ioc->AEN_semaphore);
  	init_MUTEX(&ioc->hot_plug_semaphore);
  
- 	hd->mpt_pq_filter = mpt_pq_filter;
- 	ioc->sas_data.ptClear = mpt_pt_clear;
- 	ioc->sas_data.mpt_sas_hot_plug_enable =
- 	    mpt_sas_hot_plug_enable;
--	ioc->sas_data.mptsas_device_queue_depth = mptsas_device_queue_depth;
- 
- 	if(ioc->sas_data.ptClear==1) {
- 		mptbase_sas_persist_operation(
+@@ -2038,50 +954,24 @@ mptsas_probe(struct pci_dev *pdev, const
  		    ioc, MPI_SAS_OP_CLEAR_ALL_PERSISTENT);
  	}
  
@@ -26267,17 +22792,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	hd->scandv_wait_done = 0;
  	hd->last_queue_full = 0;
  
--	init_waitqueue_head(&hd->TM_waitq);
--	hd->TM_wait_done = 0;
+-        init_waitqueue_head(&hd->TM_waitq);
+-        hd->TM_wait_done = 0;
 -
 -	INIT_LIST_HEAD(&hd->target_reset_list);
 -
+-#if defined(CPQ_CIM)
 -	INIT_LIST_HEAD(&ioc->sas_device_info_list);
 -	init_MUTEX(&ioc->sas_device_info_mutex);
 -	port_info = kmalloc(sizeof(*port_info), GFP_KERNEL);
 -	if (port_info && !mptsas_sas_io_unit_pg0(ioc, port_info))
 -		ioc->num_ports = port_info->num_phys;
 -	kfree(port_info);
+-#endif
 -
  	error = scsi_add_host (sh, &ioc->pcidev->dev);
  	if(error) {
@@ -26289,6 +22816,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  	scsi_scan_host(sh);
 -
+-#if defined(CPQ_CIM)
 -	/*
 -	 * Handling Inactive Volumes
 -	 */
@@ -26301,25 +22829,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
 -		mptsas_add_device_component_ir(ioc,
 -		    ioc->raid_data.pIocPg2->RaidVolume[ii].VolumeBus,
 -		    ioc->raid_data.pIocPg2->RaidVolume[ii].VolumeID);
+-#endif
 -
  	return 0;
  
  out_mptsas_probe:
-@@ -2202,9 +985,13 @@
- 	.id_table	= mptsas_pci_table,
- 	.probe		= mptsas_probe,
- 	.remove		= __devexit_p(mptsas_remove),
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	.driver         = {
- 		.shutdown = mptscsih_shutdown,
-         },
-+#else
-+	.shutdown       = mptscsih_shutdown,
-+#endif
- #ifdef CONFIG_PM
- 	.suspend	= mptscsih_suspend,
- 	.resume		= mptscsih_resume,
-@@ -2225,17 +1012,17 @@
+@@ -2122,17 +1012,17 @@ mptsas_init(void)
  	show_mptmod_ver(my_NAME, my_VERSION);
  
  	mptsasDoneCtx = mpt_register(mptscsih_io_done, MPTSAS_DRIVER);
@@ -26341,7 +22856,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  	}
  
  	return pci_register_driver(&mptsas_driver);
-@@ -2254,11 +1041,11 @@
+@@ -2151,11 +1041,11 @@ mptsas_exit(void)
  
  	mpt_reset_deregister(mptsasDoneCtx);
  	dprintk((KERN_INFO MYNAM
@@ -26355,20 +22870,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.c
  
  	mpt_deregister(mptsasInternalCtx);
  	mpt_deregister(mptsasTaskCtx);
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptsas.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.h	2009-04-18 06:33:31.404506136 -0600
-@@ -1,169 +0,0 @@
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptsas.h linux-2.6.9-55.0.12/drivers/message/fusion/mptsas.h
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptsas.h	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptsas.h	1970-01-01 01:00:00.000000000 +0100
+@@ -1,166 +0,0 @@
 -/*
 - *  linux/drivers/message/fusion/mptsas.h
 - *      High performance SCSI + LAN / Fibre Channel device drivers.
 - *      For use with PCI chip/adapter(s):
 - *          LSIFC9xx/LSI409xx Fibre Channel
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
+- *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
 - *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 - *
 - */
 -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -26493,8 +23007,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.h
 -#if defined(MPT_WIDE_PORT_API)
 -	u8	sas_port_add_phy;	/* flag to request sas_port_add_phy*/
 -#endif
+-#if defined(CPQ_CIM)
 -	u8	change_count;		/* change count of the phy */
 -	u8	port_flags;		/* info wrt host sas ports */
+-#endif
 -	u32	phy_info;		/* various info wrt the phy */
 -	struct mptsas_devinfo identify;	/* point to phy device info */
 -	struct mptsas_devinfo attached;	/* point to attached device info */
@@ -26522,43 +23038,31 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptsas.h
 -	u8	sep_channel;		/* SEP channel logical channel id */
 -};
 -
--struct mptsas_broadcast_primative_event {
--	struct work_struct	work;
--	MPT_ADAPTER		*ioc;
--};
--
 -/*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 -#endif
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptscsi.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c	2009-05-11 23:24:42.000000000 -0600
-@@ -1,10 +1,10 @@
- /*
-- *  linux/drivers/message/fusion/mptscsih.c
-- *      For use with LSI PCI chip/adapter(s)
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *  linux/drivers/message/fusion/mptscsi.c
-+ *      For use with LSI Logic PCI chip/adapter(s)
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptscsi.c linux-2.6.9-55.0.12/drivers/message/fusion/mptscsi.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptscsi.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptscsi.c	2007-11-02 09:10:23.000000000 +0100
+@@ -3,8 +3,8 @@
+  *      For use with LSI Logic PCI chip/adapter(s)
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
   *  $Id: mptscsih.c,v 1.1.2.4 2003/05/07 14:08:34 Exp $
   */
-@@ -74,14 +74,21 @@
+@@ -74,7 +74,6 @@
  MODULE_AUTHOR(MODULEAUTHOR);
  MODULE_DESCRIPTION(my_NAME);
  MODULE_LICENSE("GPL");
 -MODULE_VERSION(my_VERSION);
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-+
- typedef struct _BIG_SENSE_BUF {
- 	u8		data[MPT_SENSE_BUFFER_ALLOC];
+ 
+@@ -83,6 +82,13 @@ typedef struct _BIG_SENSE_BUF {
  } BIG_SENSE_BUF;
  
  #define OEM_TLR_COMMAND			0xC2
@@ -26572,28 +23076,25 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  #define MPT_SCANDV_MAX_RETRIES		(10)
  
-@@ -112,42 +119,55 @@
- /*
-  *  Other private/forward protos...
-  */
--
--static int	SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
+@@ -116,37 +122,44 @@ typedef struct _dv_parameters {
  int		mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
  static void	mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSIIORequest_t *pScsiReq);
  int		mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
 +
  static int	mptscsih_AddSGE(MPT_ADAPTER *ioc, struct scsi_cmnd *SCpnt,
  				 SCSIIORequest_t *pReq, int req_idx);
-+static void	mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx);
+ static void	mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx);
  static void	mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply);
  static int	mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd);
+-static int	SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
 -int		mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, u8 lun, int ctx2abort, ulong timeout);
+-static int	mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, u8 lun, int ctx2abort, ulong timeout);
 +static int	mptscsih_tm_wait_for_completion(MPT_SCSI_HOST * hd, ulong timeout );
 +static u32	SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc);
 +
 +int		mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
 +static int	mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
-+
+ 
  int		mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
  int		mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
 -static void	mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus, int id, u8 lun, char *data, int dlen);
@@ -26609,8 +23110,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +static int	mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags);
 +static int	mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus);
  int		mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
--void		mptscsih_InternalCmdTimer_expired(unsigned long data);
--void		mptscsih_DVCmdTimer_expired(unsigned long data);
+-void           mptscsih_InternalCmdTimer_expired(unsigned long data);
 +void		mptscsih_timer_expired(unsigned long data);
  static int	mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum);
  
@@ -26621,7 +23121,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +static int	mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id);
  static void	mptscsih_qas_check(MPT_SCSI_HOST *hd, int id);
 -static int	mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int id);
--static void	mptscsih_post_PendingMF_command(MPT_ADAPTER *ioc);
+-static void    mptscsih_post_PendingMF_command(MPT_ADAPTER *ioc);
 +static int	mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target);
  static void	mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage);
 -static MPT_FRAME_HDR * mptscsih_search_PendingMF(MPT_ADAPTER *ioc, struct scsi_cmnd * sc);
@@ -26633,16 +23133,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +mpt_IssueTLR(MPT_SCSI_HOST *hd, VirtDevice *pTarget);
  
  void		mptscsih_remove(struct pci_dev *);
-+// This was changed in the 2.6.13 kernel
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- void		mptscsih_shutdown(struct device *);
-+#else
-+void		mptscsih_shutdown(struct pci_dev *);
-+#endif
- 
- #ifdef CONFIG_PM
- int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
-@@ -162,11 +182,42 @@
+ // This was changed in the 2.6.13 kernel
+@@ -169,6 +182,8 @@ int mptscsih_resume(struct pci_dev *pdev
   */
  static spinlock_t dvtaskQ_lock = SPIN_LOCK_UNLOCKED;
  static int dvtaskQ_active = 0;
@@ -26651,157 +23143,41 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  #endif
  
  
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /**
-+ *	mptscsih_add_sge - Place a simple SGE at address pAddr.
-+ *	@pAddr: virtual address for SGE
-+ *	@flagslength: SGE flags and data transfer length
-+ *	@dma_addr: Physical address
-+ *
-+ *	This routine places a MPT request frame back on the MPT adapter's
-+ *	FreeQ.
-+ */
-+static inline void
-+mptscsih_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
-+{
-+	if (sizeof(dma_addr_t) == sizeof(u64)) {
-+		SGESimple64_t *pSge = (SGESimple64_t *) pAddr;
-+		u32 tmp = dma_addr & 0xFFFFFFFF;
-+
-+		pSge->FlagsLength = cpu_to_le32(flagslength);
-+		pSge->Address.Low = cpu_to_le32(tmp);
-+		tmp = (u32) ((u64)dma_addr >> 32);
-+		pSge->Address.High = cpu_to_le32(tmp);
-+
-+	} else {
-+		SGESimple32_t *pSge = (SGESimple32_t *) pAddr;
-+		pSge->FlagsLength = cpu_to_le32(flagslength);
-+		pSge->Address = cpu_to_le32(dma_addr);
-+	}
-+} /* mptscsih_add_sge() */
-+
-+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-+/**
-  *	mptscsih_add_chain - Place a chain SGE at address pAddr.
-  *	@pAddr: virtual address for SGE
-  *	@next: nextChainOffset value (u32's)
-@@ -299,7 +350,7 @@
- 				      SCpnt->sc_data_direction);
- 		dsgprintk((MYIOC_s_INFO_FMT "SG: non-SG for %p, len=%d\n",
- 				ioc->name, SCpnt, SCpnt->request_bufflen));
--		ioc->add_sge((char *) &pReq->SGL,
-+		mptscsih_add_sge((char *) &pReq->SGL,
- 			0xD1000000|MPT_SGE_FLAGS_ADDRESSING|sgdir|SCpnt->request_bufflen,
- 			SCpnt->SCp.dma_handle);
- 
-@@ -338,7 +389,7 @@
- 		}
- 
- 		v2 = sg_dma_address(sg);
--		ioc->add_sge(psge, sgflags | thisxfer, v2);
-+		mptscsih_add_sge(psge, sgflags | thisxfer, v2);
- 
- 		sg++;		/* Get next SG element from the OS */
- 		psge += (sizeof(u32) + sizeof(dma_addr_t));
-@@ -359,7 +410,7 @@
- 		thisxfer = sg_dma_len(sg);
- 
- 		v2 = sg_dma_address(sg);
--		ioc->add_sge(psge, sgflags | thisxfer, v2);
-+		mptscsih_add_sge(psge, sgflags | thisxfer, v2);
- 		/*
- 		sg++;
- 		psge += (sizeof(u32) + sizeof(dma_addr_t));
-@@ -519,12 +570,11 @@
- 		printk (MYIOC_s_ERR_FMT
- 		    "req_idx=%x req_idx_MR=%x mf=%p mr=%p sc=%p\n",
- 		    ioc->name, req_idx, req_idx_MR, mf, mr, 
--		    ioc->ScsiLookup[req_idx_MR]);
-+		    hd->ScsiLookup[req_idx_MR]);
- 		return 0;
+@@ -560,7 +575,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  	}
  
--	sc = ioc->ScsiLookup[req_idx];
--	ioc->ScsiLookup[req_idx] = NULL;
-+	sc = hd->ScsiLookup[req_idx];
+ 	sc = hd->ScsiLookup[req_idx];
+-	hd->ScsiLookup[req_idx] = NULL;
  	if (sc == NULL) {
  		MPIHeader_t *hdr = (MPIHeader_t *)mf;
  
-@@ -532,20 +582,11 @@
- 		 * If a SCSI I/O cmd, device disabled by OS and
- 		 * completion done. Cannot touch sc struct. Just free mem.
- 		 */
--		if (hdr->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {
-+		if (hdr->Function == MPI_FUNCTION_SCSI_IO_REQUEST)
- 			printk(MYIOC_s_ERR_FMT "NULL ScsiCmd ptr!\n",
- 			ioc->name);
--			DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mf)
--//			panic ("NULL ScsiCmd ptr panic!\n");
--		}
- 
--		mpt_freeChainBuffers(ioc, req_idx);
--		return 1;
--	}
--	if ((unsigned char *)mf != sc->host_scribble) {
--		dfailprintk((MYIOC_s_WARN_FMT "mf=%p != sc->host_scribble=%p sc=%p!!\n",
--		    ioc->name, mf, sc->host_scribble, sc));
--		mpt_freeChainBuffers(ioc, req_idx);
-+		mptscsih_freeChainBuffers(ioc, req_idx);
+@@ -575,10 +589,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
+ 		mptscsih_freeChainBuffers(ioc, req_idx);
  		return 1;
  	}
+-	if ((unsigned char *)mf != sc->host_scribble) {
+-		mptscsih_freeChainBuffers(ioc, req_idx);
+-		return 1;
+-	}
  
-@@ -553,26 +594,25 @@
+ 	sc->result = DID_OK << 16;		/* Set default reply as OK */
  	pScsiReq = (SCSIIORequest_t *) mf;
- 	pScsiReply = (SCSIIOReply_t *) mr;
- 
-+	if((ioc->facts.MsgVersion >= MPI_VERSION_01_05) && pScsiReply){
-+		dmfprintk((MYIOC_s_INFO_FMT
-+			"ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d,task-tag=%d)\n",
-+			ioc->name, mf, mr, sc, req_idx, pScsiReply->TaskTag));
-+	}else{
-+		dmfprintk((MYIOC_s_INFO_FMT
-+			"ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d)\n",
-+			ioc->name, mf, mr, sc, req_idx));
-+	}
-+
- 	if (pScsiReply == NULL) {
--		dmfprintk((MYIOC_s_WARN_FMT
--			"Trbo mf=%p sc=%p idx=%04x\n",
--			ioc->name, mf, sc, req_idx));
- 		/* special context reply handling */
- 		;
- 	} else {
+@@ -601,12 +611,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  		u32	 xfer_cnt;
  		u16	 ioc_status;
  		u8	 scsi_state, scsi_status;
 -#ifdef MPT_DEBUG_ERROR
--		u8	 ii, skey, asc, ascq;
+-               u8       ii, skey, asc, ascq;
 -#endif
--		struct _MPT_DEVICE	*pMptTarget;
+-	        struct _MPT_DEVICE	*pMptTarget;
 -		VirtDevice	*pTarget;
 -		int	 bus, id;
--
--		dmfprintk((MYIOC_s_WARN_FMT
--			"Addr mf=%p sc=%p idx=%04x mr=%p\n",
--			ioc->name, mf, sc, req_idx, mr));
 +		VirtDevice		*pTarget;
 +		int	 target;
  
  		ioc_status = le16_to_cpu(pScsiReply->IOCStatus) & MPI_IOCSTATUS_MASK;
  		scsi_state = pScsiReply->SCSIState;
-@@ -580,11 +620,6 @@
- 		xfer_cnt = le32_to_cpu(pScsiReply->TransferCount);
- 		sc->resid = sc->request_bufflen - xfer_cnt;
- 
--		bus = pScsiReq->Bus;
--		id = pScsiReq->TargetID;
--		pMptTarget = ioc->Target_List[bus];
--		pTarget = (VirtDevice *)pMptTarget->Target[id];
--
- 		/*
- 		 *  if we get a data underrun indication, yet no data was
- 		 *  transferred and the SCSI status indicates that the
-@@ -598,34 +633,17 @@
+@@ -627,35 +633,18 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  			ioc_status = MPI_IOCSTATUS_SUCCESS;
  		}
  
@@ -26822,46 +23198,50 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +			ioc_status, scsi_state, scsi_status, sc->resid,
 +			sc->request_bufflen, xfer_cnt));
  
--		if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) {
+-		if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID){
 +		if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID)
  			mptscsih_copy_sense_data(sc, hd, mf, pScsiReply);
+ 
 -#ifdef MPT_DEBUG_ERROR
--			skey = sc->sense_buffer[2];
--			asc  = sc->sense_buffer[12];
--			ascq = sc->sense_buffer[13];
--			derrprintk((MYIOC_s_WARN_FMT
--				"id=%d SenseKey:ASC:ASCQ = (%x:%02x:%02x) CDB:\n",
--				ioc->name, pScsiReq->TargetID, 
--				skey, asc, ascq));
-- 
--			for (ii=0; ii<pScsiReq->CDBLength; ii++) {
--				printk("%02x ", pScsiReq->CDB[ii]);
--			}
--			printk("\n");
+-                       skey = sc->sense_buffer[2];
+-                       asc  = sc->sense_buffer[12];
+-                       ascq = sc->sense_buffer[13];
+-                       derrprintk((MYIOC_s_WARN_FMT
+-                               "id=%d SenseKey:ASC:ASCQ = (%x:%02x:%02x) CDB:\n",
+-                               ioc->name, pScsiReq->TargetID,
+-                               skey, asc, ascq));
+-
+-                       for (ii=0; ii<pScsiReq->CDBLength; ii++) {
+-                               printk("%02x ", pScsiReq->CDB[ii]);
+-                       }
+-                       printk("\n");
 -#endif
--		} else if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID &&
-+
+-  } else if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID && pScsiReply->ResponseInfo) {
 +		if (scsi_state & MPI_SCSI_STATE_RESPONSE_INFO_VALID &&
- 		    pScsiReply->ResponseInfo) {
++		    pScsiReply->ResponseInfo) {
  			printk(KERN_NOTICE "ha=%d id=%d lun=%d: "
  			"FCP_ResponseInfo=%08xh\n",
-@@ -641,12 +659,6 @@
+ 			ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1],
+@@ -670,13 +659,6 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  			 * killing interrupt handler:-(
  			 */
  			sc->result = SAM_STAT_BUSY;
 -#ifdef MPT_DEBUG_FAIL
--			derrprintk((MYIOC_s_ERR_FMT
--				"id=%d MPI_IOCSTATUS_BUSY\n",
--				ioc->name, pScsiReq->TargetID)); 
--//			panic ("IOCSTATUS_BUSY!!!!!\n");
+-                       derrprintk((MYIOC_s_ERR_FMT
+-                               "id=%d MPI_IOCSTATUS_BUSY\n",
+-                               ioc->name, pScsiReq->TargetID));
+-//                     panic ("IOCSTATUS_BUSY!!!!!\n");
 -#endif
+-
  			break;
  
  		case MPI_IOCSTATUS_SCSI_INVALID_BUS:		/* 0x0041 */
-@@ -658,10 +670,11 @@
+@@ -688,15 +670,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  			/* Spoof to SCSI Selection Timeout! */
  			sc->result = DID_NO_CONNECT << 16;
  
+-			bus = pScsiReq->Bus;
+-			id = pScsiReq->TargetID;
 -			if ( ioc->bus_type == SPI ) {
 -				if (hd->sel_timeout[id] < 0xFFFF)
 -					hd->sel_timeout[pScsiReq->TargetID]++;
@@ -26869,12 +23249,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +			target = pScsiReq->TargetID;
 +			if (hd->sel_timeout[target] < 0xFFFF)
 +				hd->sel_timeout[pScsiReq->TargetID]++;
-+
+ 
+-			pMptTarget = ioc->Target_List[bus];
+-			pTarget = (VirtDevice *)pMptTarget->Target[id];
 +			pTarget = hd->Targets[target];
  
  			if ( pTarget ) {
  				if (pTarget->tflags & MPT_TARGET_FLAGS_LED_ON) {
-@@ -675,8 +688,8 @@
+@@ -710,8 +688,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  					} else {
  						SEPMsg = (SEPRequest_t *)mf;
  						SEPMsg->Function = MPI_FUNCTION_SCSI_ENCLOSURE_PROCESSOR;
@@ -26885,26 +23267,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  						SEPMsg->Action = MPI_SEP_REQ_ACTION_WRITE_STATUS;
  						SEPMsg->SlotStatus = MPI_SEP_REQ_SLOTSTATUS_UNCONFIGURED;
  						pTarget->tflags &= ~MPT_TARGET_FLAGS_LED_ON;
-@@ -688,44 +701,30 @@
- 			}
- 			break;
- 
--		case MPI_IOCSTATUS_SCSI_TASK_TERMINATED:	/* 0x0048 */
--			/* DID_RESET causes a retry but does not bump the 
--			 * retries counter in the sc structure */
--			sc->result = DID_RESET << 16;
--			dreplyprintk((MYIOC_s_WARN_FMT "TASK_TERMINATED: "
--				"id=%d "
--				"IOCStatus=%04x SCSIState=%02x\n"
--				"SCSIStatus=%02x "
--				"sc->result=%08x retries=%d sc=%p\n",
--				ioc->name, pScsiReq->TargetID, 
--				le16_to_cpu(pScsiReply->IOCStatus),
--				scsi_state, 
--				scsi_status, sc->result, 
--				sc->retries, sc));
--			break;
--
+@@ -726,24 +704,24 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  		case MPI_IOCSTATUS_SCSI_IOC_TERMINATED:		/* 0x004B */
  			if ( ioc->bus_type == SAS ) {
  				u16	 status = le16_to_cpu(pScsiReply->IOCStatus);
@@ -26912,7 +23275,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -// 				sc->result = DID_RESET << 16;
 -				sc->result = DID_SOFT_ERROR << 16;
  				if (status & MPI_IOCSTATUS_FLAG_LOG_INFO_AVAILABLE) {
--					if ((log_info & 0xFFFF0000) == 
+-					if ((log_info & 0xFFFF0000) ==
 -						SAS_LOGINFO_NEXUS_LOSS) {
 +					u32	 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo);
 +					log_info &= 0xFFFF0000;  /* mask subcodes */
@@ -26936,17 +23299,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -					"IOCStatus=%04x SCSIState=%02x\n"
 -					"SCSIStatus=%02x LogInfo=%08x "
 -					"sc->result=%08x sc=%p\n",
--					ioc->id, pScsiReq->TargetID, 
--					pScsiReq->LUN[1], status, scsi_state, 
+-					ioc->id, pScsiReq->TargetID,
+-					pScsiReq->LUN[1], status, scsi_state,
 -					scsi_status, log_info, sc->result, sc));
--				break;	
+-				break;
  			}  /* allow non-SAS & non-NEXUS_LOSS to drop into below code */
-+
-+		case MPI_IOCSTATUS_SCSI_TASK_TERMINATED:	/* 0x0048 */
- 		case MPI_IOCSTATUS_SCSI_EXT_TERMINATED:		/* 0x004C */
- 			/* Linux handles an unsolicited DID_RESET better
- 			 * than an unsolicited DID_ABORT.
-@@ -754,7 +753,7 @@
+ 
+ 		case MPI_IOCSTATUS_SCSI_TASK_TERMINATED:	/* 0x0048 */
+@@ -775,7 +753,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  			} else {
  				sc->result = DID_SOFT_ERROR << 16;
  			}
@@ -26955,54 +23315,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			printk("RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->device->id);
  			break;
  #else
-@@ -763,7 +762,7 @@
+@@ -784,7 +762,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  				sc->result=DID_SOFT_ERROR << 16;
  			else /* Sufficient data transfer occurred */
  				sc->result = (DID_OK << 16) | scsi_status;
--			derrprintk((KERN_NOTICE 
+-			derrprintk((KERN_NOTICE
 +			dreplyprintk((KERN_NOTICE 
  			    "RESIDUAL_MISMATCH: result=%x on id=%d\n", sc->result, sc->device->id));
  			break;
  #endif
-@@ -773,33 +772,11 @@
- 			 *  precedence!
- 			 */
- 			sc->result = (DID_OK << 16) | scsi_status;
--
--			if (!(scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID)) {
--
--				/*
--				 * For an Errata on LSI53C1030
--				 * When the length of request data
--				 * and transfer data are different
--				 * with result of command (READ or VERIFY),
--				 * DID_SOFT_ERROR is set.
-+			if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) {
-+				/* Have already saved the status and sense data
- 				 */
--				if (ioc->bus_type == SPI && pTarget) {
--					if (pScsiReq->CDB[0] == READ_6  ||
--					    pScsiReq->CDB[0] == READ_10 ||
--					    pScsiReq->CDB[0] == READ_12 ||
--					    pScsiReq->CDB[0] == READ_16 ||
--					    pScsiReq->CDB[0] == VERIFY  ||
--					    pScsiReq->CDB[0] == VERIFY_16) {
--						if (sc->request_bufflen !=
--						    xfer_cnt) {
--						    sc->result = DID_SOFT_ERROR << 16;
--						    printk(KERN_WARNING "Errata"
--						    "on LSI53C1030 occurred. sc->request_bufflen=0x%02x, "
--						    "xfer_cnt=0x%02x\n", sc->request_bufflen, xfer_cnt);
--						}
--					}
--				}
--
-+				;
-+			} else {
- 				if (xfer_cnt < sc->underflow) {
- 					if (scsi_status == SAM_STAT_BUSY)
+@@ -804,9 +782,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  						sc->result = SAM_STAT_BUSY;
-@@ -817,6 +794,9 @@
+ 					else
+ 						sc->result = DID_SOFT_ERROR << 16;
+- derrprintk((KERN_NOTICE " xfer_cnt=%d < sc->underflow=%d result=%08x\n",xfer_cnt, sc->underflow, sc->result));
+-
+-                                 }
++				}
+ 				if (scsi_state & (MPI_SCSI_STATE_AUTOSENSE_FAILED | MPI_SCSI_STATE_NO_SCSI_STATUS)) {
+ 					/* What to do?
+ 				 	*/
+@@ -818,6 +794,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  				}
  			}
  
@@ -27012,69 +23345,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			/* Report Queue Full
  			 */
  			if (scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL)
-@@ -835,43 +815,6 @@
- 			if (scsi_state == 0) {
- 				;
- 			} else if (scsi_state & MPI_SCSI_STATE_AUTOSENSE_VALID) {
--
--				/*
--				 * For potential trouble on LSI53C1030. (date:2007.xx.)
--				 * It is checked whether the length of request data is equal to
--				 * the length of transfer and residual.
--				 * MEDIUM_ERROR is set by incorrect data.
--				 */
--				if (ioc->bus_type == SPI && pTarget){
--					if (sc->sense_buffer[2] & 0x20) {
--					    u32	 difftransfer;
--					    difftransfer =
--					    sc->sense_buffer[3] << 24 |
--					    sc->sense_buffer[4] << 16 |
--					    sc->sense_buffer[5] << 8 |
--					    sc->sense_buffer[6];
--					    if ((sc->sense_buffer[3] & 0x80) == 0x80) {
--						if (sc->request_bufflen != xfer_cnt) {
--						    sc->sense_buffer[2] = MEDIUM_ERROR;
--						    sc->sense_buffer[12] = 0xff;
--						    sc->sense_buffer[13] = 0xff;
--						    printk(KERN_WARNING "Errata on "
--						    "LSI53C1030 occurred. sc->request_bufflen=0x%02x,"
--						    "xfer_cnt=0x%02x\n" ,sc->request_bufflen, xfer_cnt);
--						}
--					} else {
--						if (sc->request_bufflen != xfer_cnt + difftransfer) {
--						    sc->sense_buffer[2] = MEDIUM_ERROR;
--						    sc->sense_buffer[12] = 0xff;
--						    sc->sense_buffer[13] = 0xff;
--						    printk(KERN_WARNING "Errata on "
--						    "LSI53C1030 occurred. sc->request_bufflen=0x%02x,"
--						    " xfer_cnt=0x%02x, difftransfer=0x%02x\n",
--						    sc->request_bufflen , xfer_cnt, difftransfer);
--						}
--						}
--					}
--				}
- 				/*
- 				 * If running against circa 200003dd 909 MPT f/w,
- 				 * may get this (AUTOSENSE_VALID) for actual TASK_SET_FULL
-@@ -933,16 +876,7 @@
+@@ -896,18 +875,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
+ 			break;
  
  		}	/* switch(ioc_status) */
- 
--		if (ioc_status != MPI_IOCSTATUS_SCSI_DATA_UNDERRUN) {
--			derrprintk((KERN_NOTICE "ha=%d id=%d lun=%d "
--				"IOCStatus=%04x SCSIState=%02x\n"
--				"SCSIStatus=%02x "
--				"sc->result=%08x sc=%p\n",
--				ioc->id, pScsiReq->TargetID, 
--				pScsiReq->LUN[1], ioc_status, 
--				scsi_state, scsi_status, sc->result,
--				sc));
--		}
+-               if (ioc_status != MPI_IOCSTATUS_SCSI_DATA_UNDERRUN) {
+-                       derrprintk((KERN_NOTICE "ha=%d id=%d lun=%d "
+-                               "IOCStatus=%04x SCSIState=%02x\n"
+-                               "SCSIStatus=%02x "
+-                               "sc->result=%08x sc=%p\n",
+-                               ioc->id, pScsiReq->TargetID,
+-                               pScsiReq->LUN[1], ioc_status,
+-                               scsi_state, scsi_status, sc->result,
+-                               sc));
+-               }
+ 
+-              } /* end of address reply case */
 +		dreplyprintk((KERN_NOTICE "  sc->result is %08xh\n", sc->result));
- 	} /* end of address reply case */
++	} /* end of address reply case */
  
  	/* Unmap the DMA buffers, if any. */
-@@ -954,22 +888,88 @@
+ 	if (sc->use_sg) {
+@@ -918,7 +888,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_F
  				sc->request_bufflen, sc->sc_data_direction);
  	}
  
@@ -27084,62 +23376,51 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	sc->scsi_done(sc);		/* Issue the command callback */
  
  	/* Free Chain buffers */
--	mpt_freeChainBuffers(ioc, req_idx);
-+	mptscsih_freeChainBuffers(ioc, req_idx);
- 	return 1;
- }
+@@ -945,9 +916,7 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOS
+ 	int		 ii;
+ 	int		 max = ioc->req_depth;
  
- /*
-+ *	mptscsih_flush_running_cmds - For each command found, search
-+ *		Scsi_Host instance taskQ and reply to OS.
-+ *		Called only if recovering from a FW reload.
-+ *	@hd: Pointer to a SCSI HOST structure
-+ *
-+ *	Returns: None.
-+ *
-+ *	Must be called while new I/Os are being queued.
-+ */
-+static void
-+mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
-+{
-+	MPT_ADAPTER *ioc = hd->ioc;
-+	struct scsi_cmnd	*SCpnt;
-+	MPT_FRAME_HDR	*mf;
-+	int		 ii;
-+	int		 max = ioc->req_depth;
-+
+-
+-drsprintk((MYIOC_s_WARN_FMT ": %s entered\n",ioc->name, __FUNCTION__));
+-
 +	dprintk((KERN_INFO MYNAM ": flush_ScsiLookup called\n"));
-+	for (ii= 0; ii < max; ii++) {
-+		if ((SCpnt = hd->ScsiLookup[ii]) != NULL) {
-+
-+			/* Command found.
-+			 */
-+
-+			/* Null ScsiLookup index
-+			 */
-+			hd->ScsiLookup[ii] = NULL;
-+
-+			mf = MPT_INDEX_2_MFPTR(ioc, ii);
+ 	for (ii= 0; ii < max; ii++) {
+ 		if ((SCpnt = hd->ScsiLookup[ii]) != NULL) {
+ 
+@@ -959,24 +928,8 @@ drsprintk((MYIOC_s_WARN_FMT ": %s entere
+ 			hd->ScsiLookup[ii] = NULL;
+ 
+ 			mf = MPT_INDEX_2_MFPTR(ioc, ii);
+-
+-/*                     drsprintk((MYIOC_s_WARN_FMT "flush mf=%p sc=%p\n",
+-                               ioc->name, mf, SCpnt));
+-                       DBG_DUMP_RESET_REQUEST_FRAME(ioc, mf) */
+-
+-
+-			/* Free Chain buffers */
+-			mptscsih_freeChainBuffers(ioc, ii);
+-
+-			/* Free Message frames */
+-			mpt_free_msg_frame(ioc, mf);
+-
+-			if ((unsigned char *)mf != SCpnt->host_scribble) {
+-                     drsprintk(( "%s Skipping scsi_done mf=%p host_scribble=%p\n",
+-                         __FUNCTION__, mf, SCpnt->host_scribble));
+-
+-				continue;
+-			}
 +			dmfprintk(( "flush: ScsiDone (mf=%p,sc=%p)\n",
 +					mf, SCpnt));
-+
-+			/* Set status, free OS resources (SG DMA buffers)
-+			 * Do OS callback
-+			 * Free driver resources (chain, msg buffers)
-+			 */
-+			if (SCpnt->use_sg) {
-+				pci_unmap_sg(ioc->pcidev,
-+					(struct scatterlist *) SCpnt->request_buffer,
-+					SCpnt->use_sg,
-+					SCpnt->sc_data_direction);
-+			} else if (SCpnt->request_bufflen) {
-+				pci_unmap_single(ioc->pcidev,
-+					SCpnt->SCp.dma_handle,
-+					SCpnt->request_bufflen,
-+					SCpnt->sc_data_direction);
-+			}
+ 
+ 			/* Set status, free OS resources (SG DMA buffers)
+ 			 * Do OS callback
+@@ -993,14 +946,20 @@ drsprintk((MYIOC_s_WARN_FMT ": %s entere
+ 					SCpnt->request_bufflen,
+ 					SCpnt->sc_data_direction);
+ 			}
+-                        SCpnt->result = (DID_BUS_BUSY << 16);
 +			SCpnt->result = DID_RESET << 16;
-+			SCpnt->host_scribble = NULL;
+ 			SCpnt->host_scribble = NULL;
 +
 +			/* Free Chain buffers */
 +			mptscsih_freeChainBuffers(ioc, ii);
@@ -27147,17 +23428,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +			/* Free Message frames */
 +			mpt_free_msg_frame(ioc, mf);
 +
-+			SCpnt->scsi_done(SCpnt);	/* Issue the command callback */
-+		}
-+	}
-+
+ 			SCpnt->scsi_done(SCpnt);	/* Issue the command callback */
+ 		}
+ 	}
+ 
+-drsprintk((MYIOC_s_WARN_FMT ": %s exiting\n", ioc->name, __FUNCTION__));
+-
 +	return;
-+}
-+
-+/*
-  *	mptscsih_search_running_cmds - Delete any commands associated
-  *		with the specified target and lun. Function called only
-  *		when a lun is disable by mid-layer.
+ }
+ 
+ /*
+@@ -1010,7 +969,7 @@ drsprintk((MYIOC_s_WARN_FMT ": %s exitin
   *		Do NOT access the referenced scsi_cmnd structure or
   *		members. Will cause either a paging or NULL ptr error.
   *	@hd: Pointer to a SCSI HOST structure
@@ -27166,7 +23447,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
   *	@lun: lun
   *
   *	Returns: None.
-@@ -977,47 +977,43 @@
+@@ -1018,47 +977,43 @@ drsprintk((MYIOC_s_WARN_FMT ": %s exitin
   *	Called from slave_destroy.
   */
  static void
@@ -27186,21 +23467,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +			target, lun, max));
  
  	for (ii=0; ii < max; ii++) {
--		if ((sc = ioc->ScsiLookup[ii]) != NULL) {
-+		if ((sc = hd->ScsiLookup[ii]) != NULL) {
+ 		if ((sc = hd->ScsiLookup[ii]) != NULL) {
  
 -			mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(ioc, ii);
 +			mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii);
  
  			dsprintk(( "search_running: found (sc=%p, mf = %p)\n",
--					ioc->ScsiLookup[ii], mf));
-+					hd->ScsiLookup[ii], mf));
+ 					hd->ScsiLookup[ii], mf));
  			if (mf == NULL)
  				continue;
 -			dsprintk(( "search_running: found (sc=%p, mf = %p) id %d, lun %d \n",
--					ioc->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1]));
 +			dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n",
-+					hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1]));
+ 					hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1]));
  
 -			if ((mf->TargetID != ((u8)id)) || (mf->LUN[1] != ((u8) lun)))
 +			if ((mf->TargetID != ((u8)target)) || (mf->LUN[1] != ((u8) lun)))
@@ -27208,13 +23486,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  			/* Cleanup
  			 */
--			ioc->ScsiLookup[ii] = NULL;
--			mpt_freeChainBuffers(ioc, ii);
+ 			hd->ScsiLookup[ii] = NULL;
+-			mptscsih_freeChainBuffers(ioc, ii);
 -			mpt_free_msg_frame(ioc, (MPT_FRAME_HDR *)mf);
 -			if ((unsigned char *)mf != sc->host_scribble) {
 -				continue;
 -			}
-+			hd->ScsiLookup[ii] = NULL;
 +			mptscsih_freeChainBuffers(hd->ioc, ii);
 +			mpt_free_msg_frame(hd->ioc, (MPT_FRAME_HDR *)mf);
  			if (sc->use_sg) {
@@ -27229,7 +23506,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					sc->SCp.dma_handle,
  					sc->request_bufflen,
  					sc->sc_data_direction);
-@@ -1027,8 +1023,8 @@
+@@ -1068,8 +1023,8 @@ mptscsih_search_running_cmds(MPT_SCSI_HO
  			sc->scsi_done(sc);
  		}
  	}
@@ -27240,57 +23517,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	return;
  }
  
-@@ -1127,112 +1123,10 @@
- 	return 0;
+@@ -1169,66 +1124,9 @@ mptscsih_sendIOCInit(MPT_SCSI_HOST *hd)
  }
  
--/**
-- * mptscsih_reset_bus_noblock
-- *
-- * Issues RESET_BUS to the specified channel using handshaking method
-- *
-- * @ioc
-- * @channel
-- *
-- * Returns (0) success
-- *         (1) failure
-- *
-- **/
--static int
--mptscsih_reset_bus_noblock(MPT_ADAPTER *ioc, u8 channel)
--{
--	MPT_FRAME_HDR	*mf;
--	SCSITaskMgmt_t	*pScsiTm;
--
--	if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
--		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames @%d!!\n",
--		    ioc->name,__FUNCTION__, __LINE__));
--		return 1;
--	}
--
--	/* Format the Request
--	 */
--	pScsiTm = (SCSITaskMgmt_t *) mf;
--	memset (pScsiTm, 0, sizeof(SCSITaskMgmt_t));
--	pScsiTm->Bus = channel;
--	pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
--	pScsiTm->TaskType = MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS;
--	pScsiTm->MsgFlags = MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION;
--
--	DBG_DUMP_TM_REQUEST_FRAME(mf);
--
--	if (mpt_send_handshake_request(ioc->TaskCtx, ioc,
--	    sizeof(SCSITaskMgmt_t), (u32 *)mf, 10, NO_SLEEP)) {
--		mpt_free_msg_frame(ioc, mf);
--		dfailprintk((MYIOC_s_WARN_FMT "%s, tm handshake failed @%d!!\n",
--		    ioc->name,__FUNCTION__, __LINE__));
--		return 1;
--	}
--
--	return 0;
--}
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 -/*	mptscsih_TM_timeout - Call back for timeout on a
 - *	task management request.
 - *	@data: Pointer to MPT_ADAPTER recast as an unsigned long
@@ -27316,24 +23546,25 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -
 -	ioc->tmPtr = NULL;
 -
--	dtmprintk((MYIOC_s_WARN_FMT "%s: Calling mpt_SendIocReset MUR!\n", 
+-	dtmprintk((MYIOC_s_WARN_FMT "%s: Calling mpt_SendIocReset MUR!\n",
 -		ioc->name, __FUNCTION__));
 -	if ((retval = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, NO_SLEEP)) != 0) {
 -		ioc_state = mpt_GetIocState(ioc, 0);
 -		dfailprintk((MYIOC_s_WARN_FMT "%s: IOC MUR failed! ioc_state=%08x\n",
 -			ioc->name, __FUNCTION__, ioc_state));
 -//		panic ("IOC MUR Failed");
--		ioc->ioc_reset_in_progress = 0;
+-		ioc->IOCResetInProgress = 0;
 -
 -		if ((retval = mpt_HardResetHandler(ioc, NO_SLEEP)) < 0){
 -			printk(KERN_WARNING "%s: %s: HardResetHandler FAILED!!\n",
 -				ioc->name, __FUNCTION__);
 -		} else {
--			dtmprintk((MYIOC_s_WARN_FMT "%s: HardResetHandler succeeded!!\n", 
+-			dtmprintk((MYIOC_s_WARN_FMT "%s: HardResetHandler succeeded!!\n",
 -				ioc->name, __FUNCTION__));
 -		}
 -	} else {
 -		dtmprintk((MYIOC_s_WARN_FMT "IOC MUR succeeded\n", ioc->name));
+-		mptscsih_flush_running_cmds(hd);
 -		dtmprintk((MYIOC_s_WARN_FMT "Calling do_ioc_recovery! \n", ioc->name));
 -		if ((retval = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, NO_SLEEP)) != 0) {
 -			dfailprintk((MYIOC_s_ERR_FMT "%s: (%d) ioc_recovery failed\n", ioc->name, __FUNCTION__, retval));
@@ -27345,7 +23576,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -	wake_up(&hd->TM_waitq);
 -}
 -
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  /*	mptscsih_writeFCPortPage3  - write FC Port Page 3
   *	@hd: Pointer to a SCSI Host Structure
 - *	@bus: write FC Port Page 3 for this bus
@@ -27354,7 +23585,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
   *
   *	Return: -EAGAIN if unable to obtain a Message Frame
   *		or 0 if success.
-@@ -1240,7 +1134,7 @@
+@@ -1236,7 +1134,7 @@ void mptscsih_TM_timeout(unsigned long d
   *	Remark: We do not wait for a return, write pages sequentially.
   */
  static int
@@ -27363,7 +23594,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  {
  	MPT_ADAPTER		*ioc = hd->ioc;
  	Config_t		*pReq;
-@@ -1251,7 +1145,6 @@
+@@ -1247,7 +1145,6 @@ mptscsih_writeFCPortPage3(MPT_SCSI_HOST 
  	u32			 frameOffset;
  	u32			 flagsLength;
  	int			 ii;
@@ -27371,7 +23602,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	VirtDevice		*pTarget;
  
  	/* Get a MF for this command.
-@@ -1291,10 +1184,9 @@
+@@ -1287,10 +1184,9 @@ mptscsih_writeFCPortPage3(MPT_SCSI_HOST 
         	pReq->Header.PageType = MPI_CONFIG_PAGETYPE_FC_PORT |
  				MPI_CONFIG_PAGEATTR_PERSISTENT;
  	pReq->PageAddress = cpu_to_le32(MPI_FC_PORT_PGAD_FORM_INDEX |
@@ -27384,29 +23615,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	FCPort3->Header.PageVersion = MPI_FCPORTPAGE3_PAGEVERSION;
  	FCPort3->Header.PageLength = sizeof(FCPortPage3_t) / 4;
-@@ -1303,17 +1195,16 @@
+@@ -1299,8 +1195,8 @@ mptscsih_writeFCPortPage3(MPT_SCSI_HOST 
  				   MPI_CONFIG_PAGEATTR_PERSISTENT;
         	FCPort3->Entry[0].PhysicalIdentifier.WWN.WWPN = pTarget->WWPN;
         	FCPort3->Entry[0].PhysicalIdentifier.WWN.WWNN = pTarget->WWNN;
--       	FCPort3->Entry[0].TargetID = id;
--       	FCPort3->Entry[0].Bus = bus;
+-	FCPort3->Entry[0].TargetID = id;
+-	FCPort3->Entry[0].Bus = bus;
 +       	FCPort3->Entry[0].TargetID = pTarget->target_id;
 +       	FCPort3->Entry[0].Bus = pTarget->bus_id;
  	FCPort3->Entry[0].Flags = cpu_to_le16(MPI_PERSISTENT_FLAGS_ENTRY_VALID);
  
  	/* Add a SGE to the config request.
- 	 */
+@@ -1308,7 +1204,7 @@ mptscsih_writeFCPortPage3(MPT_SCSI_HOST 
  	flagsLength = MPT_SGE_FLAGS_SSIMPLE_READ | sizeof(FCPortPage3_t);
--	ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
-+	mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
+ 	mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
  
--	drsprintk((MYIOC_s_INFO_FMT "writeFCPortPage3: bus=%d id=%d\n", 
--		ioc->name, bus, id));
+-	drsprintk((MYIOC_s_INFO_FMT "writeFCPortPage3: bus=%d id=%d\n", ioc->name, , bus, id));
 +	drsprintk((MYIOC_s_INFO_FMT "writeFCPortPage3: target=%d\n", ioc->name, target_id));
  
  	mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
  
-@@ -1325,7 +1216,7 @@
+@@ -1320,7 +1216,7 @@ mptscsih_writeFCPortPage3(MPT_SCSI_HOST 
   *	mptscsih_readFCDevicePage0 - returns FC Device Page 0 data
   *	@ioc: Pointer to MPT_ADAPTER structure
   *	@bus: bus id
@@ -27415,7 +23644,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
   *	@fcDevicePage: FC Device Page 0 data
   *
   *	Returns count of number bytes copied into @fcDevicePage
-@@ -1333,7 +1224,7 @@
+@@ -1328,7 +1224,7 @@ mptscsih_writeFCPortPage3(MPT_SCSI_HOST 
   */
  
  int
@@ -27424,7 +23653,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  {
  	ConfigPageHeader_t	 hdr;
  	CONFIGPARMS		 cfg;
-@@ -1353,7 +1244,7 @@
+@@ -1348,7 +1244,7 @@ mptscsih_readFCDevicePage0(MPT_ADAPTER *
  	cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
  	cfg.dir = 0;
  
@@ -27433,48 +23662,44 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	cfg.timeout = 0;
  
  	if ((rc = mpt_config(ioc, &cfg)) != 0)
-@@ -1441,31 +1332,35 @@
+@@ -1436,16 +1332,15 @@ mptscsih_remove(struct pci_dev *pdev)
  		spin_unlock_irqrestore(&dvtaskQ_lock, flags);
  	}
  	if (!count)
--		printk(KERN_ERR MYNAM ": %s: ERROR - DV thread still active!\n",
--			ioc->name);
+-   printk(KERN_ERR MYNAM ": %s: ERROR - DV thread still active!\n",
+-            ioc->name);
 -#ifdef MPT_DEBUG_DV
 +		printk(KERN_ERR MYNAM ": ERROR - DV thread still active!\n");
 +#if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY)
  	else
--		printk(KERN_ERR MYNAM ": %s: DV thread orig %d, count %d\n", ioc->name, 10 * HZ, count);
+-		printk(KERN_ERR MYNAM ": DV thread orig %d, count %d\n", ioc->name,10 * HZ, count);
 +		printk(KERN_ERR MYNAM ": DV thread orig %d, count %d\n", 10 * HZ, count);
  #endif
  #endif
  
--	dexitprintk((KERN_INFO MYNAM ": %s ioc=%p hd=%p MaxDevices=%d\n", 
+-	dexitprintk((KERN_INFO MYNAM ": %s ioc=%p hd=%p MaxDevices=%d\n",
 -		ioc->name, ioc, hd, ioc->facts.MaxDevices));
 +	dexitprintk((KERN_INFO MYNAM ": %s ioc=%p hd=%p Targets=%p MaxDevices=%d\n", 
 +		ioc->name, ioc, hd, hd->Targets, ioc->facts.MaxDevices));
-+// This was changed in the 2.6.13 kernel
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ // This was changed in the 2.6.13 kernel
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
  	mptscsih_shutdown(&pdev->dev);
-+#else
-+	mptscsih_shutdown(pdev);
-+#endif
+@@ -1453,19 +1348,19 @@ mptscsih_remove(struct pci_dev *pdev)
+ 	mptscsih_shutdown(pdev);
+ #endif
  
--	dexitprintk((KERN_INFO MYNAM ": %s: calling scsi_remove_host ioc=%p host=%p\n", 
-+/*	dexitprintk((KERN_INFO MYNAM ": %s: calling scsi_remove_host ioc=%p host=%p\n", 
+-	dexitprintk((KERN_INFO MYNAM ": %s: calling scsi_remove_host ioc=%p host=%p\n",
++	dexitprintk((KERN_INFO MYNAM ": %s: calling scsi_remove_host ioc=%p host=%p\n", 
  		ioc->name, ioc, host));
  
  	scsi_remove_host(host);
--	dexitprintk((KERN_INFO MYNAM ": %s: scsi_remove_host completed\n", ioc->name));
-+	dexitprintk((KERN_INFO MYNAM ": %s: scsi_remove_host completed\n", ioc->name)); */
+ 	dexitprintk((KERN_INFO MYNAM ": %s: scsi_remove_host completed\n", ioc->name));
  
--	if (ioc->ScsiLookup != NULL) {
+ 	if (hd->ScsiLookup != NULL) {
 -		sz1 = ioc->req_depth * sizeof(void *);
--		kfree(ioc->ScsiLookup);
--		ioc->ScsiLookup = NULL;
-+	if (hd->ScsiLookup != NULL) {
 +		sz1 = hd->ioc->req_depth * sizeof(void *);
-+		kfree(hd->ScsiLookup);
-+		hd->ScsiLookup = NULL;
+ 		kfree(hd->ScsiLookup);
+ 		hd->ScsiLookup = NULL;
  		dprintk((MYIOC_s_INFO_FMT
  			"Free'd ScsiLookup (%d) memory\n",
 -			ioc->name, sz1));
@@ -27482,7 +23707,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	}
  
  	if (hd->info_kbuf != NULL)
-@@ -1473,7 +1368,7 @@
+@@ -1473,7 +1368,7 @@ mptscsih_remove(struct pci_dev *pdev)
  
  	/* NULL the Scsi_Host pointer
  	 */
@@ -27491,23 +23716,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	scsi_host_put(host);
  
-@@ -1486,47 +1381,49 @@
-  *	mptscsih_shutdown - reboot notifier
-  *
-  */
-+// This was changed in the 2.6.13 kernel
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- void
- mptscsih_shutdown(struct device * dev)
+@@ -1498,36 +1393,25 @@ mptscsih_shutdown(struct pci_dev *pdev)
  {
- 	MPT_ADAPTER 		*ioc = pci_get_drvdata(to_pci_dev(dev));
+        MPT_ADAPTER             *ioc = pci_get_drvdata(pdev);
+ #endif
 -	struct Scsi_Host 	*host;
-+#else
-+void
-+mptscsih_shutdown(struct pci_dev *pdev)
-+{
-+       MPT_ADAPTER             *ioc = pci_get_drvdata(pdev);
-+#endif
 +	struct Scsi_Host 	*host = ioc->sh;
  	MPT_SCSI_HOST		*hd;
  
@@ -27544,19 +23757,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
   *
   *
   */
- int
- mptscsih_suspend(struct pci_dev *pdev, pm_message_t state)
- {
-+// This was changed in the 2.6.13 kernel
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	mptscsih_shutdown(&pdev->dev);
-+#else
-+	mptscsih_shutdown(pdev);
-+#endif
- 	return mpt_suspend(pdev,state);
- }
- 
-@@ -1553,7 +1450,7 @@
+@@ -1566,7 +1450,7 @@ mptscsih_resume(struct pci_dev *pdev)
  		return 0;
  
  #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
@@ -27565,7 +23766,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	unsigned long lflags;
  	spin_lock_irqsave(&dvtaskQ_lock, lflags);
  	if (!dvtaskQ_active) {
-@@ -1565,7 +1462,7 @@
+@@ -1578,7 +1462,7 @@ mptscsih_resume(struct pci_dev *pdev)
  	} else {
  		spin_unlock_irqrestore(&dvtaskQ_lock, lflags);
  	}
@@ -27574,7 +23775,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  #endif
  	return 0;
  }
-@@ -1719,13 +1616,10 @@
+@@ -1732,13 +1616,10 @@ int
  mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
  {
  	MPT_SCSI_HOST		*hd;
@@ -27583,15 +23784,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	SCSIIORequest_t		*pScsiReq;
 -	struct _MPT_DEVICE	*pMptTarget;
  	VirtDevice		*pTarget;
--	unsigned long	 	flags;
--	int	 bus, id;
+-        unsigned long 	         flags;
+-        int	 bus, id;
 +	int	 target;
  	int	 lun;
  	u32	 datalen;
  	u32	 scsictl;
-@@ -1734,70 +1628,49 @@
+@@ -1746,34 +1627,18 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, v
+ 	int	 my_idx;
  	int	 ii;
  
+-	/* EDM Debug */
+-//	mptscsih_scsi_print_command(SCpnt);
+-
  	hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
 -	ioc = hd->ioc;
 -	bus = SCpnt->device->channel;
@@ -27600,19 +23805,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	lun = SCpnt->device->lun;
  	SCpnt->scsi_done = done;
  
--	spin_lock_irqsave(&ioc->diagLock, flags);
--	if (ioc->ioc_reset_in_progress) {
--		dfailprintk((MYIOC_s_WARN_FMT "qcmd, SCpnt=%p IOCResetInProgress!!\n",
--			     ioc->name, SCpnt));
--		spin_unlock_irqrestore(&ioc->diagLock, flags);
--		return SCSI_MLQUEUE_HOST_BUSY;
--	} else if (ioc->broadcast_aen_busy) {
--		dfailprintk((MYIOC_s_WARN_FMT "qcmd, SCpnt=%p broadcast_aen_busy!!\n",
--			     ioc->name, SCpnt));
--		spin_unlock_irqrestore(&ioc->diagLock, flags);
--		return SCSI_MLQUEUE_HOST_BUSY;
--	}
--	spin_unlock_irqrestore(&ioc->diagLock, flags);
+-       spin_lock_irqsave(&ioc->diagLock, flags);
+-       if (ioc->IOCResetInProgress) {
+-               dfailprintk((MYIOC_s_WARN_FMT "qcmd, SCpnt=%p IOCResetInProgress!!\n",
+-                            ioc->name, SCpnt));
+-               spin_unlock_irqrestore(&ioc->diagLock, flags);
+-               goto fail;
+-       }
+-       spin_unlock_irqrestore(&ioc->diagLock, flags);
+-
 -
 -	pMptTarget = ioc->Target_List[bus];
 -	pTarget = pMptTarget->Target[id];
@@ -27627,46 +23828,38 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			SCpnt->result = DID_BAD_TARGET << 16;
  			SCpnt->scsi_done(SCpnt);
  			return 0;
- 		}
--		/* Default to untagged. Once a target structure has been
--		 * allocated, use the Inquiry data to determine if device
-+		/* Default to untagged. Once a target structure has been 
-+		 * allocated, use the Inquiry data to determine if device 
+@@ -1782,31 +1647,32 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, v
+ 		 * allocated, use the Inquiry data to determine if device 
  		 * supports tagged.
  	 	*/
--		if (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)
+-		if ( pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)
 +		if ( (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)
 +		    && (SCpnt->device->tagged_supported)) {
  			scsictl = MPI_SCSIIO_CONTROL_SIMPLEQ;
--		else
+-		 else
 +		} else {
  			scsictl = MPI_SCSIIO_CONTROL_UNTAGGED;
--	} else {
--		scsictl = MPI_SCSIIO_CONTROL_UNTAGGED;
--		dioprintk((MYIOC_s_WARN_FMT "qcmd: CDB=%02x id=%d lun=%d Null pTarget, sending Untagged\n",
--			ioc->name, SCpnt->cmnd[0], id, lun));
--		if (ioc->bus_type == SPI) {
--			dnegoprintk(("writeSDP1: id=%d Async/Narrow\n", 
--				id));
--			mpt_writeSDP1(ioc, 0, id, 0);
- 		}
--	}
++		}
  
--#ifdef MPT_DEBUG_REPLY
--	if (SCpnt->retries) {
--		dreplyprintk((MYIOC_s_WARN_FMT "qcmd, SCpnt=%p retries=%d\n",
--			     ioc->name, SCpnt, SCpnt->retries));
+-	} else {
 +	} else
-+		scsictl = MPI_SCSIIO_CONTROL_UNTAGGED;
+ 		scsictl = MPI_SCSIIO_CONTROL_UNTAGGED;
+-dioprintk((MYIOC_s_WARN_FMT "qcmd: CDB=%02x id=%d lun=%d Null pTarget, sending Untagged\n",
+-                       ioc->name, SCpnt->cmnd[0], id, lun));
+-               if (ioc->bus_type == SPI) {
+-                       dnegoprintk(("writeSDP1: id=%d Async/Narrow\n",
+-                               id));
+-                       mpt_writeSDP1(ioc, 0, id, 0);
+-               }
 +	dmfprintk((MYIOC_s_INFO_FMT "qcmd: SCpnt=%p, done()=%p\n",
 +			(hd && hd->ioc) ? hd->ioc->name : "ioc?", SCpnt, done));
-+
+ 
+- }
 +	if (hd->resetPending) {
 +		dfailprintk((MYIOC_s_INFO_FMT "QueueCmd, SCpnt=%p resetPending!!\n",
 +				hd->ioc->name, SCpnt));
 +		return SCSI_MLQUEUE_HOST_BUSY;
- 	}
--#endif
++	}
  
  	/*
  	 *  Put together a MPT SCSI request...
@@ -27675,11 +23868,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +	if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) {
  		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
 -		    ioc->name,__FUNCTION__));
+-	            goto fail;
+-               }
 +		    hd->ioc->name,__FUNCTION__));
- 		return SCSI_MLQUEUE_HOST_BUSY;
- 	}
++		return SCSI_MLQUEUE_HOST_BUSY;
++	}
  
-@@ -1824,8 +1697,8 @@
+ 	pScsiReq = (SCSIIORequest_t *) mf;
+ 
+@@ -1831,8 +1697,8 @@ dioprintk((MYIOC_s_WARN_FMT "qcmd: CDB=%
  
  	/* Use the above information to set up the message frame
  	 */
@@ -27690,7 +23887,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	pScsiReq->ChainOffset = 0;
  	pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST;
  	pScsiReq->CDBLength = SCpnt->cmd_len;
-@@ -1856,7 +1729,7 @@
+@@ -1863,7 +1729,7 @@ dioprintk((MYIOC_s_WARN_FMT "qcmd: CDB=%
  	pScsiReq->DataLength = cpu_to_le32(datalen);
  
  	/* SenseBuffer low address */
@@ -27699,39 +23896,36 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					   + (my_idx * MPT_SENSE_BUFFER_ALLOC));
  
  	/* Now add the SG list
-@@ -1864,38 +1737,120 @@
- 	 */
- 	if (datalen == 0) {
- 		/* Add a NULL SGE */
--		ioc->add_sge((char *)&pScsiReq->SGL, MPT_SGE_FLAGS_SSIMPLE_READ | 0,
-+		mptscsih_add_sge((char *)&pScsiReq->SGL, MPT_SGE_FLAGS_SSIMPLE_READ | 0,
+@@ -1875,39 +1741,67 @@ dioprintk((MYIOC_s_WARN_FMT "qcmd: CDB=%
  			(dma_addr_t) -1);
  	} else {
  		/* Add a 32 or 64 bit SGE */
--		if (mptscsih_AddSGE(ioc, SCpnt, pScsiReq, my_idx) != SUCCESS) {
--			mpt_freeChainBuffers(ioc, my_idx);
--			mpt_free_msg_frame(ioc, mf);
--			return SCSI_MLQUEUE_HOST_BUSY;
--		}
+-		if (mptscsih_AddSGE(ioc, SCpnt, pScsiReq, my_idx) != SUCCESS){
+-                    mptscsih_freeChainBuffers(ioc, my_idx);
+-                    mpt_free_msg_frame(ioc, mf);
 +		if (mptscsih_AddSGE(hd->ioc, SCpnt, pScsiReq, my_idx) != SUCCESS)
-+			goto fail;
+ 			goto fail;
+-                   }
  	}
  
--	SCpnt->host_scribble = (unsigned char *)mf;
-+	hd->ScsiLookup[my_idx] = SCpnt;
+-       SCpnt->host_scribble = (unsigned char *)mf;
+-
+-       if (ioc->bus_type == SPI &&
+-               ioc->spi_data.dvStatus[id] & MPT_SCSICFG_DV_IN_PROGRESS) {
+-               spin_lock_irqsave(&ioc->PendingMFlock, flags);
+-               ioc->PendingMF = mf;
+-               ioc->PendingSCpnt = SCpnt;
+-               spin_unlock_irqrestore(&ioc->PendingMFlock, flags);
+-               dpendprintk((KERN_INFO " qcmd: %s: DV In Progress id=%d mf=%p sc=%p into PendingMF\n",
+-                       ioc->name, id, mf, SCpnt));
+-               DBG_DUMP_REQUEST_FRAME(ioc, mf)
+-//             mod_timer(&SCpnt->eh_timeout, jiffies + 40 * HZ);
+-               return 0;
+-}
+ 	hd->ScsiLookup[my_idx] = SCpnt;
 +	SCpnt->host_scribble = NULL;
  
--	if (ioc->bus_type == SPI &&
--		ioc->spi_data.dvStatus[id] & MPT_SCSICFG_DV_IN_PROGRESS) {
--		spin_lock_irqsave(&ioc->PendingMFlock, flags);
--		ioc->PendingMF = mf;
--		ioc->PendingSCpnt = SCpnt;
--		spin_unlock_irqrestore(&ioc->PendingMFlock, flags);
--		dpendprintk((KERN_INFO " qcmd: %s: DV In Progress id=%d mf=%p sc=%p into PendingMF\n",
--			ioc->name, id, mf, SCpnt));
--		DBG_DUMP_REQUEST_FRAME(ioc, mf)
--//		mod_timer(&SCpnt->eh_timeout, jiffies + 40 * HZ);
--		return 0;
+-	mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
 +#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
 +	if (hd->ioc->bus_type == SPI) {
 +		int dvStatus = hd->ioc->spi_data.dvStatus[target];
@@ -27772,209 +23966,39 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +			if (!issueCmd)
 +				goto fail;
 +		}
- 	}
++	}
 +#endif
- 
--	ioc->ScsiLookup[my_idx] = SCpnt;
--	mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
--	dmfprintk((MYIOC_s_WARN_FMT "qcmd mf=%p sc=%p idx=%04x\n",
--			ioc->name, mf, SCpnt, my_idx));
--	DBG_DUMP_REQUEST_FRAME(ioc, mf)
++
 +	mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf);
-+	dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
+ 	dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
+-			ioc->name, SCpnt, mf, my_idx));
+-	DBG_DUMP_REQUEST_FRAME(ioc,mf)
 +			hd->ioc->name, SCpnt, mf, my_idx));
 +	DBG_DUMP_REQUEST_FRAME(mf)
  	return 0;
-+
-+ fail:
+ 
+  fail:
+-       SCpnt->result = DID_BUS_BUSY << 16;
+-       SCpnt->scsi_done(SCpnt);
+-       return 0;
 +	hd->ScsiLookup[my_idx] = NULL;
 +	mptscsih_freeChainBuffers(hd->ioc, my_idx);
 +	mpt_free_msg_frame(hd->ioc, mf);
 +	return SCSI_MLQUEUE_HOST_BUSY;
-+}
-+
-+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-+/*
-+ *	mptscsih_freeChainBuffers - Function to free chain buffers associated
-+ *	with a SCSI IO request
-+ *	@hd: Pointer to the MPT_SCSI_HOST instance
-+ *	@req_idx: Index of the SCSI IO request frame.
-+ *
-+ *	Called if SG chain buffer allocation fails and mptscsih callbacks.
-+ *	No return.
-+ */
-+static void
-+mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
-+{
-+	MPT_FRAME_HDR *chain;
-+	unsigned long flags;
-+	int chain_idx;
-+	int next;
-+
-+	/* Get the first chain index and reset
-+	 * tracker state.
-+	 */
-+	chain_idx = ioc->ReqToChain[req_idx];
-+	ioc->ReqToChain[req_idx] = MPT_HOST_NO_CHAIN;
-+
-+	while (chain_idx != MPT_HOST_NO_CHAIN) {
-+
-+		/* Save the next chain buffer index */
-+		next = ioc->ChainToChain[chain_idx];
-+
-+		/* Free this chain buffer and reset
-+		 * tracker
-+		 */
-+		ioc->ChainToChain[chain_idx] = MPT_HOST_NO_CHAIN;
-+
-+		chain = (MPT_FRAME_HDR *) (ioc->ChainBuffer
-+					+ (chain_idx * ioc->req_sz));
-+		spin_lock_irqsave(&ioc->FreeQlock, flags);
-+		list_add_tail(&chain->u.frame.linkage.list, &ioc->FreeChainQ);
-+		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
-+
-+		dmfprintk((MYIOC_s_INFO_FMT "FreeChainBuffers (index %d)\n",
-+				ioc->name, chain_idx));
-+
-+		/* handle next */
-+		chain_idx = next;
-+	}
-+	return;
  }
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -1905,124 +1860,13 @@
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-- *	mptscsih_IssueTaskMgmt - Generic send Task Management function.
-- *	@hd: Pointer to MPT_SCSI_HOST structure
-+ *	mptscsih_TMHandler - Generic handler for SCSI Task Management.
-+ *	Fall through to mpt_HardResetHandler if: not operational, too many
-+ *	failed TM requests or handshake failure.
-+ *
-+ *	@ioc: Pointer to MPT_ADAPTER structure
+@@ -1972,8 +1866,7 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *i
+  *
+  *	@ioc: Pointer to MPT_ADAPTER structure
   *	@type: Task Management type
-- *	@id: Logical Target ID for reset (if appropriate)
-- *	@lun: Logical Unit for reset (if appropriate)
-- *	@ctx2abort: Context for the task to be aborted (if appropriate)
-- *
-- *	Remark: _HardResetHandler can be invoked from an interrupt thread (timer)
-- *	or a non-interrupt thread.  In the former, must not call schedule().
-- *
-- *	Not all fields are meaningfull for all task types.
-- *
-- *	Returns 0 for SUCCESS, -999 for "no msg frames",
-- *	else other non-zero value returned.
-- */
--int
--mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 bus, u8 id, u8 lun, int ctx2abort, ulong timeout)
--{
--	MPT_ADAPTER		*ioc = hd->ioc;
--	MPT_FRAME_HDR	*mf;
--	SCSITaskMgmt_t	*pScsiTm;
--	int		 ii;
--	int		 retval;
--	u32              ioc_state;
--	unsigned long	 flags;
--
--	/* Return Fail to calling function if no message frames available.
--	 */
--	if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
--		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
--		    ioc->name,__FUNCTION__));
--		return FAILED;
--	}
--	dtmprintk((MYIOC_s_WARN_FMT "IssueTaskMgmt request @ %p\n",
--			ioc->name, mf));
--
--	/* Format the Request
--	 */
--	pScsiTm = (SCSITaskMgmt_t *) mf;
--	pScsiTm->TargetID = id;
--	pScsiTm->Bus = bus;
--	pScsiTm->ChainOffset = 0;
--	pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
--
--	pScsiTm->Reserved = 0;
--	pScsiTm->TaskType = type;
--	pScsiTm->Reserved1 = 0;
--	pScsiTm->MsgFlags = (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS)
--                    ? MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION : 0;
--
--	for (ii= 0; ii < 8; ii++) {
--		pScsiTm->LUN[ii] = 0;
--	}
--	pScsiTm->LUN[1] = lun;
--
--	for (ii=0; ii < 7; ii++)
--		pScsiTm->Reserved2[ii] = 0;
--
--	pScsiTm->TaskMsgContext = ctx2abort;
--
--	dtmprintk((MYIOC_s_WARN_FMT "IssueTaskMgmt: ctx2abort (0x%08x) type=%d\n",
--			ioc->name, ctx2abort, type));
--
--	DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm);
--
--	hd->TM_wait_done = 0;
--	if ((retval = mpt_send_handshake_request(ioc->TaskCtx, ioc,
--		sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, timeout, CAN_SLEEP)) != 0) {
--		dfailprintk((MYIOC_s_WARN_FMT "%s: send_handshake FAILED!\n", 
--			ioc->name, __FUNCTION__));
--		mpt_free_msg_frame(ioc, mf);
--
--		dtmprintk((MYIOC_s_WARN_FMT "Calling mpt_SendIocReset MUR!\n", 
--			ioc->name));
--		if ((retval = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) != 0) {
--			ioc_state = mpt_GetIocState(ioc, 0);
--			dfailprintk((MYIOC_s_WARN_FMT "IOC MUR failed! ioc_state=%08x\n", ioc->name, ioc_state));
--//			panic ("IOC MUR Failed");
--			ioc->ioc_reset_in_progress = 0;
--
--			if ((retval = mpt_HardResetHandler(ioc, CAN_SLEEP)) < 0){
--				printk((KERN_WARNING " HardResetHandler FAILED!!\n"));			}
--			else {
--				dtmprintk((MYIOC_s_WARN_FMT " HardResetHandler succeeded!!\n", ioc->name));
--			}
--		} else {
--			dtmprintk((MYIOC_s_WARN_FMT "IOC MUR succeeded\n", ioc->name));
--			dtmprintk((MYIOC_s_WARN_FMT "Calling do_ioc_recovery! \n", ioc->name));
--			if ((retval = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, CAN_SLEEP)) != 0) {
--				dfailprintk((MYIOC_s_ERR_FMT "- (%d) ioc_recovery failed\n", ioc->name, retval));
--			} else {
--				dtmprintk((MYIOC_s_WARN_FMT "Successful do_ioc_recovery! \n", ioc->name));
--			}
--		}
--	} else {
--		dtmprintk((MYIOC_s_WARN_FMT "%s: send_handshake SUCCESS!\n", 
--			ioc->name, __FUNCTION__));
--		if (hd->TM_wait_done == 0) {
--			wait_event(hd->TM_waitq, hd->TM_wait_done);
--		}
--	}
--	spin_lock_irqsave(&ioc->FreeQlock, flags);
--	hd->tmPending = 0;
--	hd->tmState = TM_STATE_NONE;
--	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
--	return retval;
--}
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*
-- *	mptscsih_TMHandler - Generic handler for SCSI Task Management.
-- *	Fall through to mpt_HardResetHandler if: not operational, too many
-- *	failed TM requests or handshake failure.
-- *
-- *	@ioc: Pointer to MPT_ADAPTER structure
-- *	@type: Task Management type
 - *	@bus: Logical Bus for reset (if appropriate)
 - *	@id: Logical Target ID for reset (if appropriate)
 + *	@target: Logical Target ID for reset (if appropriate)
   *	@lun: Logical Unit for reset (if appropriate)
   *	@ctx2abort: Context for the task to be aborted (if appropriate)
   *
-@@ -2031,10 +1875,10 @@
+@@ -1982,10 +1875,10 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *i
   *	Remark: With old EH code, at most 1 SCSI TaskMgmt function per IOC
   *	will be active.
   *
@@ -27987,10 +24011,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  {
  	MPT_ADAPTER	*ioc;
  	int		 rc = -1;
-@@ -2049,14 +1893,16 @@
+@@ -2000,15 +1893,16 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8
  		return 0;
  
  	ioc = hd->ioc;
+-
 +	if (ioc == NULL) {
 +		printk(KERN_ERR MYNAM " TMHandler" " NULL ioc!\n");
 +		return FAILED;
@@ -28000,14 +24025,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	// SJR - CHECKME - Can we avoid this here?
  	// (mpt_HardResetHandler has this check...)
  	spin_lock_irqsave(&ioc->diagLock, flags);
--	if (ioc->ioc_reset_in_progress) {
--		dtmprintk((KERN_INFO MYNAM ": %s: TMHandler failing: "
--			   "IOCResetInProgress\n", ioc->name));
+- if (ioc->IOCResetInProgress) {
+-     dtmprintk((KERN_INFO MYNAM ": %s: TMHandler failing: "
+-                "IOCResetInProgress\n", ioc->name));
 +	if ((ioc->diagPending) || (ioc->alt_ioc && ioc->alt_ioc->diagPending)) {
  		spin_unlock_irqrestore(&ioc->diagLock, flags);
  		return FAILED;
  	}
-@@ -2071,54 +1917,52 @@
+@@ -2023,54 +1917,52 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8
  		if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) {
  			dtmprintk((KERN_INFO MYNAM ": %s: TMHandler abort: "
  			   "Timed out waiting for last TM (%d) to complete! \n",
@@ -28046,11 +24071,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  #ifdef MPT_DEBUG_RESET
  	if ((ioc_raw_state & MPI_IOC_STATE_MASK) != MPI_IOC_STATE_OPERATIONAL) {
  		printk(MYIOC_s_WARN_FMT
--			"TMHandler: IOC Not operational(0x%x)!\n",
--			ioc->name, ioc_raw_state);
--		return FAILED;
--//		panic (	"TMHandler: IOC Not operational!");
-+			"TM Handler: IOC Not operational(0x%x)!\n",
+ 			"TM Handler: IOC Not operational(0x%x)!\n",
+-                ioc->name, ioc_raw_state);
+-               return FAILED;
+-//             panic ( "TMHandler: IOC Not operational!");
 +			hd->ioc->name, ioc_raw_state);
  	}
  #endif
@@ -28074,7 +24098,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		}
  	}
  
-@@ -2127,24 +1971,101 @@
+@@ -2079,21 +1971,11 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8
  	if ((type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) && (rc ||
  		ioc->reload_fw || (ioc->alt_ioc && ioc->alt_ioc->reload_fw))) {
  		dtmprintk((MYIOC_s_INFO_FMT "Calling HardReset! \n",
@@ -28084,87 +24108,94 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +		rc = mpt_HardResetHandler(hd->ioc, CAN_SLEEP);
  	}
  
--	/*
--	 * Check IOCStatus from TM reply message
-+	dtmprintk((MYIOC_s_INFO_FMT "TMHandler rc = %d!\n", hd->ioc->name, rc));
-+
-+	return rc;
-+}
-+
-+
-+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-+/*
-+ *	mptscsih_IssueTaskMgmt - Generic send Task Management function.
-+ *	@hd: Pointer to MPT_SCSI_HOST structure
-+ *	@type: Task Management type
-+ *	@target: Logical Target ID for reset (if appropriate)
-+ *	@lun: Logical Unit for reset (if appropriate)
-+ *	@ctx2abort: Context for the task to be aborted (if appropriate)
-+ *
-+ *	Remark: _HardResetHandler can be invoked from an interrupt thread (timer)
-+ *	or a non-interrupt thread.  In the former, must not call schedule().
-+ *
-+ *	Not all fields are meaningfull for all task types.
-+ *
-+ *	Returns 0 for SUCCESS, -999 for "no msg frames",
-+ *	else other non-zero value returned.
-+ */
-+static int
-+mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout)
-+{
-+	MPT_FRAME_HDR	*mf;
-+	SCSITaskMgmt_t	*pScsiTm;
-+	int		 ii;
-+	int		 retval;
-+
-+	/* Return Fail to calling function if no message frames available.
- 	 */
+-    /*
+-     * Check IOCStatus from TM reply message
+-     */
 -	if (hd->tm_iocstatus == MPI_IOCSTATUS_SUCCESS ||
--	    hd->tm_iocstatus == MPI_IOCSTATUS_SCSI_TASK_TERMINATED ||
--	    hd->tm_iocstatus == MPI_IOCSTATUS_SCSI_IOC_TERMINATED)
+-	   hd->tm_iocstatus == MPI_IOCSTATUS_SCSI_TASK_TERMINATED ||
+-	   hd->tm_iocstatus == MPI_IOCSTATUS_SCSI_IOC_TERMINATED)
 -		rc = 0;
 -	else
 -		rc = FAILED;
+-
+-	dtmprintk((MYIOC_s_INFO_FMT "TMHandler rc = %d!\n", ioc->name, rc));
++	dtmprintk((MYIOC_s_INFO_FMT "TMHandler rc = %d!\n", hd->ioc->name, rc));
+ 
+ 	return rc;
+ }
+@@ -2104,7 +1986,7 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8
+  *	mptscsih_IssueTaskMgmt - Generic send Task Management function.
+  *	@hd: Pointer to MPT_SCSI_HOST structure
+  *	@type: Task Management type
+- *	@id: Logical Target ID for reset (if appropriate)
++ *	@target: Logical Target ID for reset (if appropriate)
+  *	@lun: Logical Unit for reset (if appropriate)
+  *	@ctx2abort: Context for the task to be aborted (if appropriate)
+  *
+@@ -2117,31 +1999,28 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8
+  *	else other non-zero value returned.
+  */
+ static int
+-mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 bus, u8 id, u8 lun, int ctx2abort, ulong timeout)
++mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout)
+ {
+-	MPT_ADAPTER		*ioc = hd->ioc;
+ 	MPT_FRAME_HDR	*mf;
+ 	SCSITaskMgmt_t	*pScsiTm;
+ 	int		 ii;
+ 	int		 retval;
+-	u32              ioc_state;
+-	unsigned long	 flags;
+ 
+ 	/* Return Fail to calling function if no message frames available.
+ 	 */
+-	if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
 +	if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) {
-+		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
+ 		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
+-		    ioc->name,__FUNCTION__));
 +		    hd->ioc->name,__FUNCTION__));
-+		return FAILED;
-+	}
+ 		return FAILED;
+ 	}
+-	dtmprintk((MYIOC_s_WARN_FMT "IssueTaskMgmt request @ %p\n",
+-			ioc->name, mf));
 +	dtmprintk((MYIOC_s_INFO_FMT "IssueTaskMgmt request @ %p\n",
 +			hd->ioc->name, mf));
  
--	dtmprintk((MYIOC_s_INFO_FMT "TMHandler rc = %d tm_iocstatus=%08x!\n", 
--		ioc->name, rc, hd->tm_iocstatus));
-+	/* Format the Request
-+	 */
-+	pScsiTm = (SCSITaskMgmt_t *) mf;
+ 	/* Format the Request
+ 	 */
+ 	pScsiTm = (SCSITaskMgmt_t *) mf;
+-	pScsiTm->TargetID = id;
+-	pScsiTm->Bus = bus;
 +	pScsiTm->TargetID = target;
 +	pScsiTm->Bus = channel;
-+	pScsiTm->ChainOffset = 0;
-+	pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
+ 	pScsiTm->ChainOffset = 0;
+ 	pScsiTm->Function = MPI_FUNCTION_SCSI_TASK_MGMT;
  
--	return rc;
-+	pScsiTm->Reserved = 0;
-+	pScsiTm->TaskType = type;
-+	pScsiTm->Reserved1 = 0;
-+	pScsiTm->MsgFlags = (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS)
-+                    ? MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION : 0;
-+
-+	for (ii= 0; ii < 8; ii++) {
-+		pScsiTm->LUN[ii] = 0;
-+	}
-+	pScsiTm->LUN[1] = lun;
-+
-+	for (ii=0; ii < 7; ii++)
-+		pScsiTm->Reserved2[ii] = 0;
-+
-+	pScsiTm->TaskMsgContext = ctx2abort;
-+
+@@ -2161,52 +2040,31 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd
+ 
+ 	pScsiTm->TaskMsgContext = ctx2abort;
+ 
+-	dtmprintk((MYIOC_s_WARN_FMT "IssueTaskMgmt: ctx2abort (0x%08x) type=%d\n",
+-			ioc->name, ctx2abort, type));
 +	dtmprintk((MYIOC_s_INFO_FMT "IssueTaskMgmt: ctx2abort (0x%08x) type=%d\n",
 +			hd->ioc->name, ctx2abort, type));
-+
-+	DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm);
-+
+ 
+ 	DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm);
+ 
+-	hd->TM_wait_done = 0;
+-	if ((retval = mpt_send_handshake_request(ioc->TaskCtx, ioc,
+-		sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, timeout, CAN_SLEEP)) != 0) {
+-		dfailprintk((MYIOC_s_WARN_FMT "%s: send_handshake FAILED!\n",
+-			ioc->name, __FUNCTION__));
+-		mpt_free_msg_frame(ioc, mf);
+-
+-		dtmprintk((MYIOC_s_WARN_FMT "Calling mpt_SendIocReset MUR!\n",
+-			ioc->name));
+-		if ((retval = mpt_SendIocReset(ioc, MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET, CAN_SLEEP)) != 0) {
+-			ioc_state = mpt_GetIocState(ioc, 0);
+-			dfailprintk((MYIOC_s_WARN_FMT "IOC MUR failed! ioc_state=%08x\n", ioc->name, ioc_state));
+-//			panic ("IOC MUR Failed");
+-			ioc->IOCResetInProgress = 0;
 +	if ((retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc,
 +		sizeof(SCSITaskMgmt_t), (u32*)pScsiTm,
 +		CAN_SLEEP)) != 0) {
@@ -28174,7 +24205,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +		mpt_free_msg_frame(hd->ioc, mf);
 +		return retval;
 +	}
-+
+ 
+-			if ((retval = mpt_HardResetHandler(ioc, CAN_SLEEP)) < 0){
+-				printk((KERN_WARNING " HardResetHandler FAILED!!\n"));			}
+-			else {
+-				dtmprintk((MYIOC_s_WARN_FMT " HardResetHandler succeeded!!\n", ioc->name));
+-			}
+-		} else {
+-			dtmprintk((MYIOC_s_WARN_FMT "IOC MUR succeeded\n", ioc->name));
+-			mptscsih_flush_running_cmds(hd);
+-			dtmprintk((MYIOC_s_WARN_FMT "Calling do_ioc_recovery! \n", ioc->name));
+-			if ((retval = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_RECOVER, CAN_SLEEP)) != 0) {
+-				dfailprintk((MYIOC_s_ERR_FMT "- (%d) ioc_recovery failed\n", ioc->name, retval));
+-			} else {
+-				dtmprintk((MYIOC_s_WARN_FMT "Successful do_ioc_recovery! \n", ioc->name));
+-			}
+-		}
+-	} else {
+-		dtmprintk((MYIOC_s_WARN_FMT "%s: send_handshake SUCCESS!\n",
+-			ioc->name, __FUNCTION__));
+-		if (hd->TM_wait_done == 0) {
+-			wait_event(hd->TM_waitq, hd->TM_wait_done);
+-		}
 +	if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) {
 +		dfailprintk((MYIOC_s_ERR_FMT "_wait_for_completion FAILED!"
 +			" (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd,
@@ -28183,68 +24235,66 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +		dtmprintk((MYIOC_s_INFO_FMT "Calling HardReset! \n",
 +			 hd->ioc->name));
 +		retval = mpt_HardResetHandler(hd->ioc, CAN_SLEEP);
-+	}
+ 	}
+-	spin_lock_irqsave(&ioc->FreeQlock, flags);
+-	hd->tmPending = 0;
+-	hd->tmState = TM_STATE_NONE;
+-	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 +
-+	return retval;
+ 	return retval;
  }
  
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -2166,14 +2087,13 @@
+@@ -2229,8 +2087,6 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
  	int		 scpnt_idx;
  	int		 retval;
  	int		 tm_timeout;
--	unsigned long	 flags;
+-        unsigned long    flags;
 -	unsigned long	 sn = SCpnt->serial_number;
--#ifdef MPT_DEBUG_TM
--	MPT_FRAME_HDR *chain;
--	int chain_idx, chain_number, next;
--#endif
  
-+/* From the 2.6.13 kernels, they have removed calling
-+ *	eh_threads with the host_lock in locked state
-+ */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	spinlock_t	*host_lock = SCpnt->device->host->host_lock;
-+#endif
- 
- 	/* If we can't locate our host adapter structure, return FAILED status.
- 	 */
-@@ -2187,51 +2107,30 @@
+ /* From the 2.6.13 kernels, they have removed calling
+  *	eh_threads with the host_lock in locked state
+@@ -2251,57 +2107,30 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
  	}
  
  	ioc = hd->ioc;
--	spin_lock_irqsave(&ioc->diagLock, flags);
--	if (ioc->ioc_reset_in_progress) {
--		dtmprintk((KERN_INFO ": %s: abort: "
--			   "IOCResetInProgress (sc=%p)\n",
--			   ioc->name, SCpnt));
--		spin_unlock_irqrestore(&ioc->diagLock, flags);
+-       spin_lock_irqsave(&ioc->diagLock, flags);
+-       if (ioc->IOCResetInProgress) {
+-               dtmprintk((KERN_INFO ": %s: abort: "
+-                          "IOCResetInProgress (sc=%p)\n",
+-                          ioc->name, SCpnt));
+-               spin_unlock_irqrestore(&ioc->diagLock, flags);
+-
+-
 +	if (hd->resetPending) {
  		return FAILED;
  	}
--	spin_unlock_irqrestore(&ioc->diagLock, flags);
  
+-spin_unlock_irqrestore(&ioc->diagLock, flags);
+-
  	if (hd->timeouts < -1)
+-
  		hd->timeouts++;
  
--	printk(KERN_WARNING MYNAM ": %s: attempting task abort! (sc=%p)\n",
--	       ioc->name, SCpnt);
--	scsi_print_command(SCpnt);
+-       printk(KERN_WARNING MYNAM ": %s: attempting task abort! (sc=%p)\n",
+-              ioc->name, SCpnt);
+-             scsi_print_command(SCpnt);
+-
+-//     printk(KERN_WARNING MYNAM ": %s: Delaying 30 seconds\n", ioc->name);
+-//     mdelay (30000);
+-       /* If this command is pended, then timeout/hang occurred
+-        * during DV. Post command and flush pending Q
+-        * and then following up with the reset request.
+-        */
+-       if ( (mf = mptscsih_search_PendingMF(ioc, SCpnt)) != NULL) {
+-               /* Cmd was in PendingMF.
+-                */
+-               dpendprintk((KERN_INFO MYNAM ": %s: mptscsih_abort: "
+-                          "Command was in PendingMF! (sc=%p)\n",
+-                          ioc->name, SCpnt));
+-               return SUCCESS;
+-       }
+-
 -
--//	printk(KERN_WARNING MYNAM ": %s: Delaying 30 seconds\n", ioc->name);
--//	mdelay (30000);
--	/* If this command is pended, then timeout/hang occurred
--	 * during DV. Post command and flush pending Q
--	 * and then following up with the reset request.
--	 */
--	if ( (mf = mptscsih_search_PendingMF(ioc, SCpnt)) != NULL) {
--		/* Cmd was in PendingMF.
--		 */
--		dpendprintk((KERN_INFO MYNAM ": %s: mptscsih_abort: "
--			   "Command was in PendingMF! (sc=%p)\n",
--			   ioc->name, SCpnt));
--		return SUCCESS;
--	}
 -
  	/* Find this command
  	 */
@@ -28268,7 +24318,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	/* Most important!  Set TaskMsgContext to SCpnt's MsgContext!
  	 * (the IO to be ABORT'd)
  	 *
-@@ -2239,14 +2138,16 @@
+@@ -2309,7 +2138,7 @@ spin_unlock_irqrestore(&ioc->diagLock, f
  	 *	 swap it here either.  It is an opaque cookie to
  	 *	 the controller, so it does not matter. -DaveM
  	 */
@@ -28277,170 +24327,138 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	ctx2abort = mf->u.frame.hwhdr.msgctxu.MsgContext;
  
  	hd->abortSCpnt = SCpnt;
- 
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+@@ -2318,7 +2147,7 @@ spin_unlock_irqrestore(&ioc->diagLock, f
  	spin_unlock_irq(host_lock);
-+#endif
+ #endif
  	/* set timeout in seconds */
 -	switch (ioc->bus_type) {
 +	switch (hd->ioc->bus_type) {
  	case FC:
  		tm_timeout=40;
  		break;
-@@ -2255,58 +2156,28 @@
+@@ -2327,7 +2156,7 @@ spin_unlock_irqrestore(&ioc->diagLock, f
  		break;
  	case SPI:
  	default:
--//		tm_timeout=2;
 -		tm_timeout=10;
 +		tm_timeout=2;
  		break;
  	}
--#ifdef MPT_DEBUG_TM
--	printk("Abort this Request: sc=%p retries=%d\n", SCpnt, SCpnt->retries);
--	DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, mf)
--	chain_number = 1;
--	chain_idx = ioc->ReqToChain[scpnt_idx];
--	while (chain_idx != MPT_HOST_NO_CHAIN) {
--		next = ioc->ChainToChain[chain_idx];
--		chain = (MPT_FRAME_HDR *) (ioc->ChainBuffer
--			+ (chain_idx * ioc->req_sz));
--		printk("Chain %d:\n", chain_number++);
--		DBG_DUMP_REPLYS_REQUEST_FRAME(ioc, chain)
--		chain_idx = next;
--	}
--#endif
--//	panic ("Abort Task panic!!\n");
  	retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
- 		SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun,
- 		ctx2abort, tm_timeout);
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+@@ -2337,30 +2166,17 @@ spin_unlock_irqrestore(&ioc->diagLock, f
  	spin_lock_irq(host_lock);
-+#endif
+ #endif
  
--	if (ioc->bus_type == FC) {
--		if (SCPNT_TO_LOOKUP_IDX(SCpnt) == scpnt_idx &&
--		    SCpnt->serial_number == sn) {
--			dtmprintk((KERN_INFO MYNAM ": %s: mptscsih_abort: "
+-if (ioc->bus_type == FC) {
+-	if (SCPNT_TO_LOOKUP_IDX(SCpnt) == scpnt_idx &&
+-	    SCpnt->serial_number == sn) {
+-		dtmprintk((KERN_INFO MYNAM ": %s: mptscsih_abort: "
 -			   "scpnt_idx=%08x sn=%lx (sc=%p)\n",
 -			   ioc->name, scpnt_idx, sn, SCpnt));
--			retval = FAILED;
--		}
+-		retval = FAILED;
 -	}
+-}
 -
--//	panic ("Task Abort completed");
--	spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
--	hd->tmPending = 0;
--	hd->tmState = TM_STATE_NONE;
--	spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
-+	printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n",
+ 	printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n",
+-		ioc->name,
 +		hd->ioc->name,
-+		((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+ 		((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+-       hd->ScsiLookup[scpnt_idx] = NULL;
+-//panic ("Task Abort completed");
+-       spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
+-       hd->tmPending = 0;
+-       hd->tmState = TM_STATE_NONE;
+-       spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
+-
  
--	if (retval == 0) {
--		printk (KERN_WARNING MYNAM ": %s: task abort: SUCCESS (sc=%p)\n",
--			ioc->name, SCpnt);
--		/* Remove ScsiLookup entry only on TM Success */
--		ioc->ScsiLookup[scpnt_idx] = NULL;
-+	if (retval == 0)
+ 	if (retval == 0)
  		return SUCCESS;
--	} else {
--		printk (KERN_WARNING MYNAM ": %s: task abort: FAILED (sc=%p)\n",
--			ioc->name, SCpnt);
--		/* Failed Abort will be followed by a Target Reset */
--		return FAILED;
-+
+ 
 +	if(retval != FAILED ) {
 +		hd->tmPending = 0;
 +		hd->tmState = TM_STATE_NONE;
- 	}
-+	return FAILED;
++	}
+ 	return FAILED;
  }
  
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -2322,12 +2193,15 @@
+@@ -2377,10 +2193,8 @@ int
  mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
  {
  	MPT_SCSI_HOST	*hd;
 -	MPT_ADAPTER	*ioc;
--	int		 id, retval;
+-	int		id,retval;
 +	int		 retval;
  	int		 tm_timeout;
--	unsigned long	 flags;
- 
-+/* From the 2.6.13 kernels, they have removed calling
-+ *	eh_threads with the host_lock in locked state
-+ */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	spinlock_t	*host_lock = SCpnt->device->host->host_lock;
-+#endif
+-        unsigned long    flags;
  
- 	/* If we can't locate our host adapter structure, return FAILED status.
- 	 */
-@@ -2338,24 +2212,17 @@
+ /* From the 2.6.13 kernels, they have removed calling
+  *	eh_threads with the host_lock in locked state
+@@ -2398,27 +2212,17 @@ mptscsih_dev_reset(struct scsi_cmnd * SC
  		return FAILED;
  	}
  
--	ioc = hd->ioc;
--	id = SCpnt->device->id;
--	spin_lock_irqsave(&ioc->diagLock, flags);
--	if (ioc->ioc_reset_in_progress) {
--		dtmprintk((KERN_INFO ": %s: target reset: "
--			   "IOCResetInProgress (sc=%p)\n",
--			   ioc->name, SCpnt));
--		spin_unlock_irqrestore(&ioc->diagLock, flags);
+-       ioc = hd->ioc;
+-       id = SCpnt->device->id;
+-       spin_lock_irqsave(&ioc->diagLock, flags);
+-       if (ioc->IOCResetInProgress) {
+-               dtmprintk((KERN_INFO ": %s: target reset: "
+-                          "IOCResetInProgress (sc=%p)\n",
+-                          ioc->name, SCpnt));
+-               spin_unlock_irqrestore(&ioc->diagLock, flags);
+-
+-            return FAILED;
+-}
+-spin_unlock_irqrestore(&ioc->diagLock, flags);
 +	if (hd->resetPending)
- 		return FAILED;
--	}
--	spin_unlock_irqrestore(&ioc->diagLock, flags);
++		return FAILED;
  
  	printk(KERN_WARNING MYNAM ": %s: attempting target reset! (sc=%p)\n",
 -	       ioc->name, SCpnt);
 +	       hd->ioc->name, SCpnt);
  	scsi_print_command(SCpnt);
  
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
  	spin_unlock_irq(host_lock);
+ #endif
 -	switch (ioc->bus_type) {
-+#endif
 +	switch (hd->ioc->bus_type) {
  	case FC:
  		tm_timeout=40;
  		break;
-@@ -2364,29 +2231,25 @@
+@@ -2427,29 +2231,25 @@ spin_unlock_irqrestore(&ioc->diagLock, f
  		break;
  	case SPI:
  	default:
--//		tm_timeout=5;
 -		tm_timeout=10;
 +		tm_timeout=5;
  		break;
  	}
  	retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
--		SCpnt->device->channel, id, 0, 0, tm_timeout);
+-	SCpnt->device->channel, id, 0, 0, tm_timeout);
 +		SCpnt->device->channel, SCpnt->device->id,
 +		0, 0, tm_timeout);
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
  	spin_lock_irq(host_lock);
-+#endif
+ #endif
  	printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n",
 -		ioc->name,
 +		hd->ioc->name,
  		((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
- 
--	spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
--	hd->tmPending = 0;
--	hd->tmState = TM_STATE_NONE;
--	spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
--
--	if (retval == 0) {
--		if (ioc->bus_type == SPI) {
--			dnegoprintk(("writeSDP1: id=%d USE_NVRAM\n", 
--				id));
--			mpt_writeSDP1(ioc, 0, id, MPT_SCSICFG_USE_NVRAM);
--		}
+-       spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
+-       hd->tmPending = 0;
+-       hd->tmState = TM_STATE_NONE;
+-       spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
+-
+-       if (retval == 0) {
+-               if (ioc->bus_type == SPI) {
+-                       dnegoprintk(("writeSDP1: id=%d USE_NVRAM\n",
+-                               id));
+-                       mpt_writeSDP1(ioc, 0, id, MPT_SCSICFG_USE_NVRAM);
+-               }
+-              return SUCCESS;
++
 +	if (retval == 0)
- 		return SUCCESS;
++		return SUCCESS;
 +
 +	if(retval != FAILED ) {
 +		hd->tmPending = 0;
@@ -28448,25 +24466,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	}
  	return FAILED;
  }
-@@ -2404,12 +2267,15 @@
+@@ -2467,10 +2267,8 @@ int
  mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
  {
  	MPT_SCSI_HOST	*hd;
 -	MPT_ADAPTER	*ioc;
  	int		 retval;
  	int		 tm_timeout;
--	unsigned long	 flags;
- 
-+/* From the 2.6.13 kernels, they have removed calling
-+ *	eh_threads with the host_lock in locked state
-+ */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	spinlock_t	*host_lock = SCpnt->device->host->host_lock;
-+#endif
+-        unsigned long    flags;
  
- 	/* If we can't locate our host adapter structure, return FAILED status.
- 	 */
-@@ -2420,17 +2286,18 @@
+ /* From the 2.6.13 kernels, they have removed calling
+  *	eh_threads with the host_lock in locked state
+@@ -2488,9 +2286,8 @@ mptscsih_bus_reset(struct scsi_cmnd * SC
  		return FAILED;
  	}
  
@@ -28477,73 +24488,73 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	scsi_print_command(SCpnt);
  
  	if (hd->timeouts < -1)
- 		hd->timeouts++;
- 
- 	/* We are now ready to execute the task management request. */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+@@ -2500,7 +2297,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SC
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
  	spin_unlock_irq(host_lock);
+ #endif
 -	switch (ioc->bus_type) {
-+#endif
 +	switch (hd->ioc->bus_type) {
  	case FC:
  		tm_timeout=40;
  		break;
-@@ -2439,26 +2306,26 @@
+@@ -2509,7 +2306,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SC
  		break;
  	case SPI:
  	default:
--//		tm_timeout=5;
 -		tm_timeout=10;
 +		tm_timeout=5;
  		break;
  	}
  	retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
- 		SCpnt->device->channel, 0, 0, 0, tm_timeout);
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	spin_lock_irq(host_lock);
-+#endif
+@@ -2519,20 +2316,17 @@ mptscsih_bus_reset(struct scsi_cmnd * SC
+ #endif
  
  	printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n",
 -		ioc->name,
 +		hd->ioc->name,
  		((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
  
--	spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
--	hd->tmPending = 0;
--	hd->tmState = TM_STATE_NONE;
--	spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
+-       spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
+-       hd->tmPending = 0;
+-       hd->tmState = TM_STATE_NONE;
+-       spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
+-
+-
 -
  	if (retval == 0)
  		return SUCCESS;
  
+-        return FAILED;
 +	if(retval != FAILED ) {
 +		hd->tmPending = 0;
 +		hd->tmState = TM_STATE_NONE;
 +	}
- 	return FAILED;
++	return FAILED;
  }
  
-@@ -2476,11 +2343,16 @@
+ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+@@ -2549,10 +2343,8 @@ int
  mptscsih_host_reset(struct scsi_cmnd *SCpnt)
  {
  	MPT_SCSI_HOST *  hd;
 -	MPT_ADAPTER	*ioc;
  	int              status = SUCCESS;
--	unsigned long	 flags;
+-        unsigned long    flags;
 -
 +	int		 can_sleep;
-+/* From the 2.6.13 kernels, they have removed calling
-+ *	eh_threads with the host_lock in locked state
-+ */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ /* From the 2.6.13 kernels, they have removed calling
+  *	eh_threads with the host_lock in locked state
+  */
+@@ -2560,6 +2352,8 @@ mptscsih_host_reset(struct scsi_cmnd *SC
  	spinlock_t	*host_lock = SCpnt->device->host->host_lock;
-+#endif
-+
-+	can_sleep = crashdump_mode() ? NO_SLEEP : CAN_SLEEP;
+ #endif
  
++	can_sleep = crashdump_mode() ? NO_SLEEP : CAN_SLEEP;
++
  	/*  If we can't locate the host to reset, then we failed. */
  	if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){
-@@ -2490,82 +2362,36 @@
+ 		dtmprintk( ( KERN_INFO MYNAM ": mptscsih_host_reset: "
+@@ -2568,9 +2362,8 @@ mptscsih_host_reset(struct scsi_cmnd *SC
  		return FAILED;
  	}
  
@@ -28554,18 +24565,21 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	/*  If our attempts to reset the host failed, then return a failed
  	 *  status.  The host will be taken off line by the SCSI mid-layer.
- 	 */
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+@@ -2578,78 +2371,26 @@ mptscsih_host_reset(struct scsi_cmnd *SC
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
  	MPT_HOST_UNLOCK(host_lock);
+ #endif
 -	if (mpt_HardResetHandler(ioc,
--	    	crashdump_mode() ? NO_SLEEP : CAN_SLEEP) < 0) {
--		dfailprintk((MYIOC_s_ERR_FMT "host reset: HardResetHandler failed\n", ioc->name));
-+#endif
+-	    crashdump_mode() ? NO_SLEEP : CAN_SLEEP) < 0) {
+-dfailprintk((MYIOC_s_ERR_FMT "host reset: HardResetHandler failed\n", ioc->name));
+-
 +	if (mpt_HardResetHandler(hd->ioc, can_sleep) < 0){
  		status = FAILED;
  	} else {
--		dtmprintk((MYIOC_s_ERR_FMT "host reset: HardResetHandler succeeded\n", ioc->name));
--		status = SUCCESS;
+-
+-dtmprintk((MYIOC_s_ERR_FMT "host reset: HardResetHandler succeeded\n", ioc->name));
+-        status = SUCCESS;
+-
 +		/*  Make sure TM pending is cleared and TM state is set to
 +		 *  NONE.
 +		 */
@@ -28573,22 +24587,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +		hd->tmState = TM_STATE_NONE;
  	}
 -
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
  	MPT_HOST_LOCK(host_lock);
-+#endif
- 
--	spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
--	hd->tmPending = 0;
--	hd->tmState = TM_STATE_NONE;
--	spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
-+	dtmprintk( ( KERN_INFO MYNAM ": mptscsih_host_reset: "
-+		     "Status = %s\n",
-+		     (status == SUCCESS) ? "SUCCESS" : "FAILED" ) );
- 
- 	return status;
- }
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ #endif
+-       spin_lock_irqsave(&hd->ioc->FreeQlock, flags);
+-       hd->tmPending = 0;
+-       hd->tmState = TM_STATE_NONE;
+-       spin_unlock_irqrestore(&hd->ioc->FreeQlock, flags);
+-
+-	return status;
+-}
+-
+-/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 -/* Search the pendingMF for a command with specific index.
 - * If found, delete and return mf pointer
 - * If not found, return NULL
@@ -28596,11 +24606,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -static MPT_FRAME_HDR *
 -mptscsih_search_PendingMF(MPT_ADAPTER *ioc, struct scsi_cmnd * sc)
 -{
+-	MPT_SCSI_HOST	*hd=(MPT_SCSI_HOST *) ioc->sh->hostdata;
 -	MPT_FRAME_HDR	*mf;
 -	unsigned long	 flags;
 -	u16		 req_idx;
--
--	dpendprintk((MYIOC_s_WARN_FMT "%s entered\n", 
+ 
+-	dpendprintk((MYIOC_s_WARN_FMT "%s entered\n",
 -		ioc->name, __FUNCTION__));
 -
 -	spin_lock_irqsave(&ioc->PendingMFlock, flags);
@@ -28608,20 +24619,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -		spin_unlock_irqrestore(&ioc->PendingMFlock, flags);
 -		return NULL;
 -	}
--
++	dtmprintk( ( KERN_INFO MYNAM ": mptscsih_host_reset: "
++		     "Status = %s\n",
++		     (status == SUCCESS) ? "SUCCESS" : "FAILED" ) );
+ 
 -	req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
--	if (sc == ioc->ScsiLookup[req_idx]) {
+-	if (sc == hd->ScsiLookup[req_idx]) {
 -		ioc->PendingMF = NULL;
 -		spin_unlock_irqrestore(&ioc->PendingMFlock, flags);
 -
--		dpendprintk((MYIOC_s_WARN_FMT "%s: found mf=%p\n", 
+-		dpendprintk((MYIOC_s_WARN_FMT "%s: found mf=%p\n",
 -			ioc->name, __FUNCTION__, mf));
 -		DBG_DUMP_PENDING_REQUEST_FRAME(ioc, mf)
 -		/* Free Chain buffers */
--		mpt_freeChainBuffers(ioc, req_idx);
+-		mptscsih_freeChainBuffers(ioc, req_idx);
 -		/* Free Message frames */
 -		mpt_free_msg_frame(ioc, mf);
--		ioc->ScsiLookup[req_idx] = NULL;
+-		hd->ScsiLookup[req_idx] = NULL;
 -		sc->result = (DID_RESET << 16);
 -		sc->host_scribble = NULL;
 -		sc->scsi_done(sc);	/* Issue the command callback */
@@ -28630,17 +24644,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -		return mf;
 -	}
 -	spin_unlock_irqrestore(&ioc->PendingMFlock, flags);
--	dpendprintk((MYIOC_s_WARN_FMT "%s exiting mf=%p not in ScsiLookup\n", 
+-	dpendprintk((MYIOC_s_WARN_FMT "%s exiting mf=%p not in ScsiLookup\n",
 -		ioc->name, __FUNCTION__, mf));
 -	return NULL;
--}
--
++	return status;
+ }
+ 
 -
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  /**
   *	mptscsih_tm_pending_wait - wait for pending task management request to
-  *		complete.
-@@ -2576,21 +2402,20 @@
+@@ -2661,21 +2402,20 @@ mptscsih_search_PendingMF(MPT_ADAPTER *i
  static int
  mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
  {
@@ -28665,7 +24679,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		msleep(250);
  	} while (--loop_count);
  
-@@ -2598,6 +2423,34 @@
+@@ -2683,6 +2423,34 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST *
  }
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -28700,7 +24714,35 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  static void
  mptscsih_taskmgmt_response_code(MPT_ADAPTER *ioc, u8 response_code)
  {
-@@ -2654,74 +2507,64 @@
+@@ -2720,17 +2488,17 @@ mptscsih_taskmgmt_response_code(MPT_ADAP
+ 
+ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ /**
+- *      mptscsih_taskmgmt_complete - Registered with Fusion MPT base driver
+- *      @ioc: Pointer to MPT_ADAPTER structure
+- *      @mf: Pointer to SCSI task mgmt request frame
+- *      @mr: Pointer to SCSI task mgmt reply frame
+- *
+- *      This routine is called from mptbase.c::mpt_interrupt() at the completion
+- *      of any SCSI task management request.
+- *      This routine is registered with the MPT (base) driver at driver
+- *      load/init time via the mpt_register() API call.
++ *	mptscsih_taskmgmt_complete - Registered with Fusion MPT base driver
++ *	@ioc: Pointer to MPT_ADAPTER structure
++ *	@mf: Pointer to SCSI task mgmt request frame
++ *	@mr: Pointer to SCSI task mgmt reply frame
+  *
+- *      Returns 1 indicating alloc'd request frame ptr should be freed.
++ *	This routine is called from mptbase.c::mpt_interrupt() at the completion
++ *	of any SCSI task management request.
++ *	This routine is registered with the MPT (base) driver at driver
++ *	load/init time via the mpt_register() API call.
++ *
++ *	Returns 1 indicating alloc'd request frame ptr should be freed.
+  */
+ int
+ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
+@@ -2739,26 +2507,27 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *
  	SCSITaskMgmt_t		*pScsiTmReq;
  	MPT_SCSI_HOST		*hd;
  	unsigned long		 flags;
@@ -28728,8 +24770,6 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +		return 1;
  	}
  
--	hd->tm_response_code = 0;
--	
  	if (mr == NULL) {
 -		dtmprintk((MYIOC_s_WARN_FMT "ERROR! TaskMgmt Turbo Reply: Request %p\n",
 +		dtmprintk((MYIOC_s_WARN_FMT "ERROR! TaskMgmt Reply: NULL Request %p\n",
@@ -28738,13 +24778,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	} else {
  		pScsiTmReply = (SCSITaskMgmtReply_t*)mr;
  		pScsiTmReq = (SCSITaskMgmt_t*)mf;
- 
- 		/* Figure out if this was ABORT_TASK, TARGET_RESET, or BUS_RESET! */
- 		tmType = pScsiTmReq->TaskType;
--		hd->tm_response_code = pScsiTmReply->ResponseCode;
- 
- 		if (ioc->facts.MsgVersion >= MPI_VERSION_01_05 &&
- 		    pScsiTmReply->ResponseCode)
+@@ -2771,40 +2540,31 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *
  			mptscsih_taskmgmt_response_code(ioc,
  			    pScsiTmReply->ResponseCode);
  
@@ -28780,10 +24814,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			 * FC FW may respond FAILED to an ABORT
  			 */
 -			else if (tmType == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) {
--				if (iocstatus == MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED) {
 +			if (tmType == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) {
-+				if ((hd->cmdPtr) ||
-+				    (iocstatus == MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED)) {
+ 				if ((hd->cmdPtr) ||
+ 				    (iocstatus == MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED)) {
  					if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) {
  						printk((KERN_WARNING
  							" Firmware Reload FAILED!!\n"));
@@ -28793,7 +24826,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					}
  				}
  			}
-@@ -2735,12 +2578,9 @@
+@@ -2818,16 +2578,12 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *
  
  	spin_lock_irqsave(&ioc->FreeQlock, flags);
  	hd->tmPending = 0;
@@ -28807,23 +24840,30 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	return 1;
  }
  
-@@ -2800,46 +2640,40 @@
+-
+ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ /*
+  *	This is anyones guess quite frankly.
+@@ -2884,48 +2640,38 @@ mptscsih_slave_alloc(struct scsi_device 
  {
  	struct Scsi_Host	*host = device->host;
  	MPT_SCSI_HOST		*hd = (MPT_SCSI_HOST *)host->hostdata;
 -	MPT_ADAPTER		*ioc = hd->ioc;
 -	struct _MPT_DEVICE	*pMptTarget;
  	VirtDevice		*pTarget;
--        SpiCfgData		*pSpi;
--	uint			bus=device->channel, id=device->id, lun=device->lun;
+-	SpiCfgData             *pSpi;
+-        uint			bus=device->channel, id=device->id, lun=device->lun;
 +	uint			target = device->id, lun = device->lun;
  	int			indexed_lun, lun_index;
  
--	pMptTarget = ioc->Target_List[bus];
--	pTarget = pMptTarget->Target[id];
 +	if (hd == NULL)
 +		return -ENODEV;
  
+-	pMptTarget = ioc->Target_List[bus];
+-	pTarget = pMptTarget->Target[id];
+-	dinitprintk((MYIOC_s_INFO_FMT "mptscsih_slave_alloc: bus=%d id=%d lun=%d hd=%p pMptTarget=%p pTarget=%p\n",
+-		ioc->name, bus, id, lun, hd, pMptTarget, pTarget));
+-
 -	if (pTarget) {
 -		dinitprintk((MYIOC_s_ERR_FMT "slave_alloc: pTarget=%p already allocated!\n",
 -			ioc->name, pTarget));
@@ -28842,10 +24882,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +	dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_alloc target=%d lun=%d pTarget=%p\n",
 +			hd->ioc->name, target, lun, pTarget));
  	memset(pTarget, 0, sizeof(VirtDevice));
--	if (ioc->bus_type != SPI)
--		pTarget->tflags = MPT_TARGET_FLAGS_Q_YES;
--	pTarget->ioc = ioc;
--	pTarget->id = id;
+-if (ioc->bus_type != SPI)
+-        pTarget->tflags = MPT_TARGET_FLAGS_Q_YES;
+-        pTarget->ioc = ioc;
+-        pTarget->id = id;
 -	pTarget->bus = bus;
 +	pTarget->tflags = MPT_TARGET_FLAGS_Q_YES;
 +	pTarget->ioc_id = hd->ioc->id;
@@ -28853,28 +24893,24 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +	pTarget->bus_id = device->channel;
  	pTarget->last_lun = MPT_LAST_LUN;
 -	pMptTarget->Target[id] = pTarget;
--	if (ioc->raid_data.isRaid & (1 << device->id)) {
--		pTarget->raidVolume = 1;
--		ddvprintk((KERN_INFO
--		    "RAID Volume @ id %d\n", device->id));
--	}
 -	if (ioc->bus_type == SPI) {
--		pSpi = &ioc->spi_data;
--		pSpi->dvStatus[id] |= (MPT_SCSICFG_NEED_DV |
--				       MPT_SCSICFG_DV_NOT_DONE);
+-	         pSpi = &ioc->spi_data;
+-                 pSpi->dvStatus[id] |= (MPT_SCSICFG_NEED_DV |
+-                                         MPT_SCSICFG_DV_NOT_DONE);
+-
+-		if (ioc->raid_data.isRaid & (1 << device->id)) {
 +	pTarget->raidVolume = 0;
 +	pTarget->device = device;
 +	hd->Targets[target] = pTarget;
 +	if (hd->ioc->bus_type == SPI) {
 +		if (hd->ioc->raid_data.isRaid & (1 << device->id)) {
-+			pTarget->raidVolume = 1;
+ 			pTarget->raidVolume = 1;
+-			ddvprintk((KERN_INFO
 +			ddvtprintk((KERN_INFO
-+			    "RAID Volume @ id %d\n", device->id));
-+		}
+ 			    "RAID Volume @ id %d\n", device->id));
+ 		}
  	}
- 
- out:
-@@ -2849,8 +2683,8 @@
+@@ -2937,8 +2683,8 @@ out:
  	indexed_lun = (lun % 32);
  	pTarget->luns[lun_index] |= (1 << indexed_lun);
  
@@ -28885,7 +24921,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	return 0;
  }
  
-@@ -2863,24 +2697,20 @@
+@@ -2951,24 +2697,20 @@ mptscsih_slave_destroy(struct scsi_devic
  {
  	struct Scsi_Host	*host = device->host;
  	MPT_SCSI_HOST		*hd = (MPT_SCSI_HOST *)host->hostdata;
@@ -28918,7 +24954,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	; /* this target reset shouldn't be issued to hidden
  	   * phys disk in a raid volume.  The result would
  	   * kill domain validation on that disk; e.g. disk
-@@ -2896,46 +2726,43 @@
+@@ -2984,41 +2726,38 @@ mptscsih_slave_destroy(struct scsi_devic
  	     */
  	}
  
@@ -28943,8 +24979,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -	if (ioc->bus_type == SPI) {
 -		if (mptscsih_is_phys_disk(ioc, bus, id)) {
 -			ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
--			dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy PhysDisk bus=%d id=%d lun=%d pTarget=%p retained\n",
--			ioc->name, bus, id, lun, pTarget));
+-    dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy PhysDisk bus=%d id=% d lun=%d pTarget=%p retained\n",ioc->name, bus, id, lun, pTarget));
+-
+-
 +	dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy target=%d lun=%d freeing pTarget=%p\n",
 +			hd->ioc->name, target, lun, pTarget));
 +	kfree(pTarget);
@@ -28955,38 +24992,31 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +			hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
  		} else {
 -			ioc->spi_data.dvStatus[id] =
--				(MPT_SCSICFG_NEGOTIATE | MPT_SCSICFG_DV_NOT_DONE);
--			kfree(pTarget);
--			pMptTarget->Target[id] = NULL;
--			dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy bus=%d id=%d lun=%d pTarget=%p completed\n",
--				ioc->name, bus, id, lun, pTarget));
+-                (MPT_SCSICFG_NEGOTIATE | MPT_SCSICFG_DV_NOT_DONE);
+-                kfree(pTarget);
+-                pMptTarget->Target[id] = NULL;
+-                dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy bus=%d id=%d lun=%d pTarget=%p completed\n",ioc->name, bus, id, lun, pTarget));
 +			hd->ioc->spi_data.dvStatus[target] =
 +				MPT_SCSICFG_NEGOTIATE;
-+
+ 
 +			if (!hd->negoNvram) {
 +				hd->ioc->spi_data.dvStatus[target] |=
 +					MPT_SCSICFG_DV_NOT_DONE;
 +			}
  		}
--	} else {
--		kfree(pTarget);
--		pMptTarget->Target[id] = NULL;
--		dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy bus=%d id=%d lun=%d pTarget=%p completed\n",
--			ioc->name, bus, id, lun, pTarget));
- 	}
+-}else {
+-kfree(pTarget);
+-pMptTarget->Target[id] = NULL;
+-dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy bus=%d id=%d lun=%d pTarget=%p completed\n",
+-ioc->name, bus, id, lun, pTarget));
+-      }
++	}
 +	dsprintk((MYIOC_s_INFO_FMT " mptscsih_slave_destroy target=%d lun=%d pTarget=%p completed\n",
 +			hd->ioc->name, target, lun, pTarget));
  }
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-- *	mptscsih_change_queue_depth - This function will set a device's queue 
-- *	depth
-+ *	mptscsih_change_queue_depth - This function will set a devices queue depth
-  *	@sdev: per scsi_device pointer
-  *	@qdepth: requested queue depth
-  *
-@@ -2945,28 +2772,28 @@
+@@ -3033,34 +2772,29 @@ int
  mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
  {
  	MPT_SCSI_HOST	*hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
@@ -29002,40 +25032,41 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +	if (!(pTarget = hd->Targets[sdev->id]))
  		return 0;
  
--	if (ioc->bus_type == SPI) {
--		if (sdev->type == TYPE_DISK &&
--		    pTarget->minSyncFactor <= MPT_ULTRA160)
--			max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
--		else
--			max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
+-
+-       if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
+-               if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
+-                       max_depth = 1;
+-               else if (ioc->bus_type == SPI) {
+-                       if (((pTarget->inq_data[0] & 0x1f) == 0x00) &&
+-                                (pTarget->minSyncFactor <= MPT_ULTRA160 ))
 +	if (hd->ioc->bus_type == SPI) {
 +		if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
 +			if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
 +				max_depth = 1;
 +			else if (((pTarget->inq_data[0] & 0x1f) == 0x00) &&
 +			         (pTarget->minSyncFactor <= MPT_ULTRA160 ))
-+				max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
-+			else
+ 				max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+ 			else
+-			max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
 +				max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
 +		} else {
 +			/* error case - No Inq. Data */
 +			max_depth = 1;
 +		}
- 	} else
--		max_depth = ioc->sh->can_queue;
--
--	if (!sdev->tagged_supported)
--		max_depth = 1;
++	} else
 +		max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
  
+-               } else
+-                       max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
+-       } else {
+-               /* error case - No Inq. Data */
+-               max_depth = 1;
+-       }
  	if (qdepth > max_depth)
  		qdepth = max_depth;
-@@ -2986,33 +2813,28 @@
-  *	Return non-zero if fails.
-  */
- int
--mptscsih_slave_configure(struct scsi_device *device, int device_queue_depth)
-+mptscsih_slave_configure(struct scsi_device *device)
+ 	if (qdepth == 1)
+@@ -3082,29 +2816,25 @@ int
+ mptscsih_slave_configure(struct scsi_device *device)
  {
  	struct Scsi_Host	*sh = device->host;
 -	struct _MPT_DEVICE	*pMptTarget;
@@ -29044,17 +25075,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -	MPT_ADAPTER		*ioc = hd->ioc;
  	int			rc;
  
--	dinitprintk((MYIOC_s_INFO_FMT
--		"%s: device @ %p, id=%d, LUN=%d, channel=%d\n",
--		ioc->name, __FUNCTION__, device, device->id, device->lun, 
--		device->channel));
--	dinitprintk((MYIOC_s_INFO_FMT
+-       dinitprintk((MYIOC_s_INFO_FMT
+-               "%s: device @ %p, id=%d, LUN=%d, channel=%d\n",
+-               ioc->name, __FUNCTION__, device, device->id, device->lun,
+-               device->channel));
+-       dinitprintk((MYIOC_s_INFO_FMT
+-                "sdtr %d wdtr %d ppr %d inq length=%d\n",
+-		ioc->name, device->sdtr, device->wdtr,
 +	dsprintk((MYIOC_s_INFO_FMT
 +		"device @ %p, id=%d, LUN=%d, channel=%d\n",
 +		hd->ioc->name, device, device->id, device->lun, device->channel));
 +	dsprintk((MYIOC_s_INFO_FMT
- 		"sdtr %d wdtr %d ppr %d inq length=%d\n",
--		ioc->name, device->sdtr, device->wdtr,
++		"sdtr %d wdtr %d ppr %d inq length=%d\n",
 +		hd->ioc->name, device->sdtr, device->wdtr,
  		device->ppr, device->inquiry_len));
  
@@ -29066,21 +25098,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	}
  
 -	pMptTarget = ioc->Target_List[device->channel];
--
 -	pTarget = pMptTarget->Target[device->id];
 +	pTarget = hd->Targets[device->id];
  
  	if (pTarget == NULL) {
  		/* Driver doesn't know about this device.
-@@ -3024,70 +2846,55 @@
- 		 * queue_depth set to DEV_HIGH for this reason.
- 		 */
- 		scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
--			device_queue_depth);
-+			MPT_SCSI_CMD_PER_DEV_HIGH);
- 		goto slave_configure_exit;
--	} else
-+	}else
+@@ -3122,19 +2852,19 @@ mptscsih_slave_configure(struct scsi_dev
  		pTarget->configured_lun=1;
  
  	/* LUN persistancy support */
@@ -29105,32 +25128,20 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				le32_to_cpu(fcDevicePage.WWPN.High),
  				le32_to_cpu(fcDevicePage.WWPN.Low),
  				le32_to_cpu(fcDevicePage.WWNN.High),
- 				le32_to_cpu(fcDevicePage.WWNN.Low)));
-+
- 		}
- 	}
- 
- 	mptscsih_initTarget(hd, device->channel, device->id, device->lun,
+@@ -3147,19 +2877,19 @@ mptscsih_slave_configure(struct scsi_dev
  		device->inquiry, device->inquiry_len );
--	mptscsih_change_queue_depth(device, device_queue_depth);
-+	mptscsih_change_queue_depth(device, MPT_SCSI_CMD_PER_DEV_HIGH);
+ 	mptscsih_change_queue_depth(device, MPT_SCSI_CMD_PER_DEV_HIGH);
  
 -	dinitprintk((MYIOC_s_INFO_FMT
--		"Queue depth=%d, tflags=%x, device_queue_depth=%d\n",
--		ioc->name, device->queue_depth, pTarget->tflags, device_queue_depth));
--
--	if (ioc->bus_type == SPI) {
--		dinitprintk((MYIOC_s_INFO_FMT
--			"negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
--			ioc->name, pTarget->negoFlags, pTarget->maxOffset, 
--			pTarget->minSyncFactor));
--	}
 +	dsprintk((MYIOC_s_INFO_FMT
-+		"Queue depth=%d, tflags=%x\n",
+ 		"Queue depth=%d, tflags=%x\n",
+-		ioc->name, device->queue_depth, pTarget->tflags));
 +		hd->ioc->name, device->queue_depth, pTarget->tflags));
-+
+ 
+-	dinitprintk((MYIOC_s_INFO_FMT
 +	dsprintk((MYIOC_s_INFO_FMT
-+		"negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
+ 		"negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
+-		ioc->name, pTarget->negoFlags, pTarget->maxOffset, pTarget->minSyncFactor));
 +		hd->ioc->name, pTarget->negoFlags, pTarget->maxOffset, pTarget->minSyncFactor));
  
  slave_configure_exit:
@@ -29143,33 +25154,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		device->ordered_tags));
  
  	return 0;
- }
- 
--ssize_t
--mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count)
--{
--	int			 depth;
--	struct scsi_device	*sdev = to_scsi_device(dev);
--
--	depth = simple_strtoul(buf, NULL, 0);
--	if (depth == 0)
--		return -EINVAL;
--	mptscsih_change_queue_depth(sdev, depth);
--	return count;
--}
--
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-  *	OS entry point to check whether the host drivier is sane enough
-@@ -3130,7 +2937,6 @@
- 	mpt_poll_interrupt(hd->ioc);
- }
- 
--
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-  *  Private routines...
-@@ -3144,20 +2950,16 @@
+@@ -3220,20 +2950,16 @@ mptscsih_poll(struct scsi_device *sdev)
  static void
  mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply)
  {
@@ -29193,7 +25178,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	if (sense_count) {
  		u8 *sense_data;
-@@ -3165,27 +2967,25 @@
+@@ -3241,15 +2967,15 @@ mptscsih_copy_sense_data(struct scsi_cmn
  
  		/* Copy the sense received into the scsi command block. */
  		req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
@@ -29212,50 +25197,32 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  				idx = ioc->eventContext % MPTCTL_EVENT_LOG_SIZE;
  				ioc->events[idx].event = MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE;
- 				ioc->events[idx].eventContext = ioc->eventContext;
- 
--				ioc->events[idx].data[0] = 
--					(pReq->LUN[1] << 24) |
--					(MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) |
--					(pReq->Bus << 8) | pReq->TargetID;
-+				ioc->events[idx].data[0] = (pReq->LUN[1] << 24) ||
-+					(MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) ||
-+					(pReq->Bus << 8) || pReq->TargetID;
- 
--				ioc->events[idx].data[1] = 
--					(sense_data[13] << 8) | sense_data[12];
-+				ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12];
- 
- 				ioc->eventContext++;
- 				/* OEM Specific to light the fault light */
-@@ -3213,8 +3013,25 @@
+@@ -3287,21 +3013,19 @@ mptscsih_copy_sense_data(struct scsi_cmn
  		}
  	} else {
  		dprintk((MYIOC_s_INFO_FMT "Hmmm... SenseData len=0! (?)\n",
 -				ioc->name));
 +				hd->ioc->name));
-+	}
-+}
-+
-+static u32
-+SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc)
-+{
-+	MPT_SCSI_HOST *hd;
-+	int i;
-+
-+	hd = (MPT_SCSI_HOST *) sc->device->host->hostdata;
-+
-+	for (i = 0; i < hd->ioc->req_depth; i++) {
-+		if (hd->ScsiLookup[i] == sc) {
-+			return i;
-+		}
  	}
-+
-+	return -1;
  }
  
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -3222,15 +3039,14 @@
+-static int
++static u32
+ SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc)
+ {
+ 	MPT_SCSI_HOST *hd;
+-	MPT_ADAPTER	*ioc;
+ 	int i;
+ 
+ 	hd = (MPT_SCSI_HOST *) sc->device->host->hostdata;
+ 
+-	ioc = hd->ioc;
+-	for (i = 0; i < ioc->req_depth; i++) {
++	for (i = 0; i < hd->ioc->req_depth; i++) {
+ 		if (hd->ScsiLookup[i] == sc) {
+ 			return i;
+ 		}
+@@ -3315,10 +3039,8 @@ int
  mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
  {
  	MPT_SCSI_HOST	*hd;
@@ -29267,66 +25234,43 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	int		n;
  
  	dtmprintk((KERN_INFO MYNAM
- 			": IOC %s_reset routed to SCSI host driver!\n",
--			reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"));
-+			reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
-+			reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
- 
- 	/* If a FW reload request arrives after base installed but
- 	 * before all scsi hosts have been attached, then an alt_ioc
-@@ -3241,7 +3057,16 @@
- 	else
- 		hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
+@@ -3338,8 +3060,11 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int
+ 	if (reset_phase == MPT_IOC_SETUP_RESET) {
+ 		dtmprintk((MYIOC_s_WARN_FMT "Setup-Diag Reset\n", ioc->name));
  
--	if (reset_phase == MPT_IOC_PRE_RESET) {
-+	if (reset_phase == MPT_IOC_SETUP_RESET) {
-+		dtmprintk((MYIOC_s_WARN_FMT "Setup-Diag Reset\n", ioc->name));
-+
+-                mptscsih_flush_running_cmds(hd);
+-                dtmprintk((MYIOC_s_WARN_FMT "Setup-Diag Complete\n", ioc->name));
 +		/* Clean Up:
 +		 * 1. Set Hard Reset Pending Flag
 +		 * All new commands go to doneQ
 +		 */
 +		hd->resetPending = 1;
-+
-+	} else if (reset_phase == MPT_IOC_PRE_RESET) {
- 		dtmprintk((MYIOC_s_WARN_FMT "Pre-Diag Reset\n", ioc->name));
- 
- 		/* 2. Flush running commands
-@@ -3251,31 +3076,15 @@
- 
- 		/* 2b. Reply to OS all known outstanding I/O commands.
- 		 */
--//		mptscsih_flush_running_cmds(hd);
-+		mptscsih_flush_running_cmds(hd);
  
- 		/* 2c. If there was an internal command that
- 		 * has not completed, configuration or io request,
+ 	} else if (reset_phase == MPT_IOC_PRE_RESET) {
+ 		dtmprintk((MYIOC_s_WARN_FMT "Pre-Diag Reset\n", ioc->name));
+@@ -3358,41 +3083,28 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int
  		 * free these resources.
  		 */
  		if (hd->cmdPtr) {
 -			del_timer(&hd->InternalCmdTimer);
 +			del_timer(&hd->timer);
  			mpt_free_msg_frame(ioc, hd->cmdPtr);
--			hd->cmdPtr = NULL;
--		}
--
--		if (hd->DVcmdPtr) {
--			del_timer(&hd->DVCmdTimer);
--			mpt_free_msg_frame(ioc, hd->DVcmdPtr);
--			hd->DVcmdPtr = NULL;
--		} 
--
--		/* 2d. If a task management has not completed,
--		 * free resources associated with this request.
--		 */
--		if (ioc->tmPtr) {
--			del_timer(&ioc->TMtimer);
--			mpt_free_msg_frame(ioc, ioc->tmPtr);
--			ioc->tmPtr = NULL;
+-                        hd->cmdPtr = NULL;
  		}
+-               /* 2d. If a task management has not completed,
+-                * free resources associated with this request.
+-                */
+-               if (ioc->tmPtr) {
+-                       del_timer(&ioc->TMtimer);
+-                       mpt_free_msg_frame(ioc, ioc->tmPtr);
+-                       ioc->tmPtr = NULL;
+-               }
+ 
+-               dtmprintk((MYIOC_s_WARN_FMT "Pre-Reset complete.\n", ioc->name));
++		dtmprintk((MYIOC_s_WARN_FMT "Pre-Reset complete.\n", ioc->name));
  
- 		dtmprintk((MYIOC_s_WARN_FMT "Pre-Reset complete.\n", ioc->name));
-@@ -3285,21 +3094,17 @@
+ 	} else {
+ 		dtmprintk((MYIOC_s_WARN_FMT "Post-Diag Reset\n", ioc->name));
  
  		if (ioc->bus_type == FC) {
  			n = 0;
@@ -29359,25 +25303,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				}
  			}
  
-@@ -3315,31 +3120,31 @@
+@@ -3408,7 +3120,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int
  
  		/* ScsiLookup initialization
  		 */
 -		for (ii=0; ii < ioc->req_depth; ii++)
--			ioc->ScsiLookup[ii] = NULL;
 +		for (ii=0; ii < hd->ioc->req_depth; ii++)
-+			hd->ScsiLookup[ii] = NULL;
+ 			hd->ScsiLookup[ii] = NULL;
  
  		/* 2. Chain Buffer initialization
- 		 */
- 
--		/* 4. Renegotiate to all devices, if SCSI
-+		/* 4. Renegotiate to all devices, if SPI
+@@ -3417,19 +3129,17 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int
+ 		/* 4. Renegotiate to all devices, if SPI
  		 */
  		if (ioc->bus_type == SPI) {
--			dnegoprintk((MYIOC_s_WARN_FMT "%s: writeSDP1: ALL_IDS USE_NVRAM\n",
--				ioc->name, __FUNCTION__));
--			mpt_writeSDP1(ioc, 0, 0, (MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM));
+-                       dnegoprintk((MYIOC_s_WARN_FMT "%s: writeSDP1: ALL_IDS USE_NVRAM\n",
+-                               ioc->name, __FUNCTION__));
+-                       mpt_writeSDP1(ioc, 0, 0, (MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM));
+-
 +			dnegoprintk(("writeSDP1: ALL_IDS USE_NVRAM\n"));
 +			mptscsih_writeSDP1(hd, 0, 0, MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM);
  		}
@@ -29386,135 +25328,102 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		 */
  		spin_lock_irqsave(&ioc->FreeQlock, flags);
  		hd->tmPending = 0;
--		hd->tmState = TM_STATE_NONE;
- 		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
++		spin_unlock_irqrestore(&ioc->FreeQlock, flags);
 +		hd->resetPending = 0;
-+		hd->tmState = TM_STATE_NONE;
+ 		hd->tmState = TM_STATE_NONE;
+-                spin_unlock_irqrestore(&ioc->FreeQlock, flags);
+-
  
  		/* 6. If there was an internal command,
  		 * wake this process up.
- 		 */
--		if (hd->cmdPtr || hd->DVcmdPtr) {
-+		if (hd->cmdPtr) {
- 			/*
- 			 * Wake up the original calling thread
- 			 */
-@@ -3348,14 +3153,13 @@
- 			hd->scandv_wait_done = 1;
- 			wake_up(&hd->scandv_waitq);
- 			hd->cmdPtr = NULL;
--			hd->DVcmdPtr = NULL;
- 		}
- 
+@@ -3448,9 +3158,8 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int
  		/* 7. Set flag to force DV and re-read IOC Page 3
  		 */
  		if (ioc->bus_type == SPI) {
--			ioc->spi_data.forceDv = MPT_SCSICFG_RELOAD_IOC_PG3;
--			ddvprintk(("Set reload IOC Pg3 Flag\n"));
+-ioc->spi_data.forceDv = MPT_SCSICFG_RELOAD_IOC_PG3;
+-ddvprintk(("Set reload IOC Pg3 Flag\n"));
+-
 +			ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
 +			ddvtprintk(("Set reload IOC Pg3 Flag\n"));
  		}
  
  		dtmprintk((MYIOC_s_WARN_FMT "Post-Reset complete.\n", ioc->name));
-@@ -3365,24 +3169,7 @@
- 	return 1;		/* currently means nothing really */
- }
- 
--static int
--SCPNT_TO_LOOKUP_IDX(struct scsi_cmnd *sc)
--{
--	MPT_SCSI_HOST *hd;
--	MPT_ADAPTER	*ioc;
--	int i;
--
--	hd = (MPT_SCSI_HOST *) sc->device->host->hostdata;
--
--	ioc = hd->ioc;
--	for (i = 0; i < ioc->req_depth; i++) {
--		if (ioc->ScsiLookup[i] == sc) {
--			return i;
--		}
--	}
- 
--	return -1;
--}
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- int
-@@ -3390,12 +3177,9 @@
+@@ -3468,13 +3177,9 @@ mptscsih_event_process(MPT_ADAPTER *ioc,
  {
  	MPT_SCSI_HOST *hd;
  	u8 event = le32_to_cpu(pEvReply->Event) & 0xFF;
--	struct _MPT_DEVICE	*pMptTarget;
--	VirtDevice		*pTarget;
--	int	 physDiskNum, bus, id;
+-       struct _MPT_DEVICE      *pMptTarget;
+-       VirtDevice              *pTarget;
+-       int      physDiskNum, bus, id;
+-
+-       devtprintk((MYIOC_s_WARN_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n",
+-                       ioc->name, event));
  
--//	devtprintk((MYIOC_s_WARN_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n",
--//			ioc->name, event));
 +	devtprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n",
 +			ioc->name, event));
  
  	if (ioc->sh == NULL ||
  		((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL))
-@@ -3429,51 +3213,15 @@
+@@ -3508,53 +3213,16 @@ mptscsih_event_process(MPT_ADAPTER *ioc,
  #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
  	case MPI_EVENT_INTEGRATED_RAID:			/* 0B */
  	{
--#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
--                pMpiEventDataRaid_t pRaidEventData =
--                    (pMpiEventDataRaid_t) &pEvReply->Data;
 +		pMpiEventDataRaid_t pRaidEventData =
 +		    (pMpiEventDataRaid_t) pEvReply->Data;
  
--                /* Domain Validation Needed */
--	        if (ioc->bus_type == SPI &&
+-#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
+-                pMpiEventDataRaid_t pRaidEventData =
+-                (pMpiEventDataRaid_t) &pEvReply->Data;
+-
+-/* Domain Validation Needed */
 +		/* Domain Validation Needed */
-+		if (ioc->bus_type == SPI &&
+ 		if (ioc->bus_type == SPI &&
  			pRaidEventData->ReasonCode ==
--				MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
--       			SpiCfgData	*pSpi;
-+			MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
- 
--			physDiskNum = pRaidEventData->PhysDiskNum;
--			if (ioc->raid_data.pIocPg3) {
--				id = ioc->raid_data.pIocPg3->PhysDisk[physDiskNum].PhysDiskID;
--				bus = ioc->raid_data.pIocPg3->PhysDisk[physDiskNum].PhysDiskBus;
--				pMptTarget = ioc->Target_List[bus];
--				pTarget = (VirtDevice *)pMptTarget->Target[id];
--				ddvprintk((KERN_WARNING "%s: Raid Event: DV Requested for PhysDiskNum=%d bus=%d id=%d pTarget=%p\n",
--					ioc->name, physDiskNum, bus, id, pTarget));
--			} else {
--				ddvprintk((KERN_WARNING "%s: Raid Event: DV Requested for PhysDiskNum=%d but raid_data.pIocPg3 is NULL\n",
--					ioc->name, physDiskNum));
--				break;
--			}
--			pSpi = &ioc->spi_data;
--			pSpi->dvStatus[id] |= (MPT_SCSICFG_PHYSDISK_DV_ONLY |
--					      MPT_SCSICFG_NEED_DV |
--					      MPT_SCSICFG_DV_NOT_DONE);
--
--			if (pTarget == NULL) {
--				ddvprintk((KERN_WARNING " Raid Event: DV Requested for PhysDiskNum=%d bus=%d id=%d but pTarget is NULL\n",
--					physDiskNum, bus, id));
--				mptscsih_initTarget(hd, bus, id, 0,
--					NULL, 0 );
--				pTarget = (VirtDevice *)pMptTarget->Target[id];
--				ddvprintk((KERN_WARNING "%s: Raid Event: DV Requested for PhysDiskNum=%d bus=%d id=%d pTarget%p now\n",
--					ioc->name, physDiskNum, bus, id, pTarget));
--			}
--			pSpi->forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
--			ddvprintk((KERN_WARNING "%s: Raid Event: Scheduling DV for PhysDiskNum=%d bus=%d id=%d pTarget=%p\n",
--				ioc->name, physDiskNum, bus, id, pTarget));
--			INIT_WORK(&pTarget->dvTask, mptscsih_domainValidation, (void *) pTarget);
--			schedule_work(&pTarget->dvTask);
--			ddvprintk((KERN_WARNING "%s: Raid Event: DV Scheduled for PhysDiskNum=%d bus=%d id=%d pTarget=%p\n",
--				ioc->name, physDiskNum, bus, id, pTarget));
+ 			MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) {
+-                         SpiCfgData      *pSpi;
+-                       physDiskNum = pRaidEventData->PhysDiskNum;
+-                       if (ioc->raid_data.pIocPg3) {
+-                               id = ioc->raid_data.pIocPg3->PhysDisk[physDiskNum].PhysDiskID;
+-                               bus = ioc->raid_data.pIocPg3->PhysDisk[physDiskNum].PhysDiskBus;
+-                               pMptTarget = ioc->Target_List[bus];
+-                               pTarget = (VirtDevice *)pMptTarget->Target[id];
+-                               ddvprintk((KERN_WARNING "%s: Raid Event: DV Requested for PhysDiskNum=%d bus=%d id=%d pTarget=%p\n",
+-                                       ioc->name, physDiskNum, bus, id, pTarget));
+-                       } else {
+-                               ddvprintk((KERN_WARNING "%s: Raid Event: DV Requested for PhysDiskNum=%d but raid_data.pIocPg3 is NULL\n",
+-                                       ioc->name, physDiskNum));
+-                               break;
+-                       }
+-                       pSpi = &ioc->spi_data;
+-                       pSpi->dvStatus[id] |= (MPT_SCSICFG_PHYSDISK_DV_ONLY |
+-                                             MPT_SCSICFG_NEED_DV |
+-                                             MPT_SCSICFG_DV_NOT_DONE);
+-
+-                       if (pTarget == NULL) {
+- ddvprintk((KERN_WARNING " Raid Event: DV Requested for PhysDiskNum=%d bus=%d id=%d but pTarget is NULL\n",
+-                                       physDiskNum, bus, id));
+-                               mptscsih_initTarget(hd, bus, id, 0,
+-                                       NULL, 0 );
+-                               pTarget = (VirtDevice *)pMptTarget->Target[id];
+- ddvprintk((KERN_WARNING "%s: Raid Event: DV Requested for PhysDiskNum=%d bus=%d id=%d pTarget%p now\n",
+-                                       ioc->name, physDiskNum, bus, id, pTarget));
+-                       }
+-                       pSpi->forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
+- ddvprintk((KERN_WARNING "%s: Raid Event: Scheduling DV for PhysDiskNum=%d bus=%d id=%d pTarget=%p\n",
+-                               ioc->name, physDiskNum, bus, id, pTarget));
+- INIT_WORK(&pTarget->dvTask, mptscsih_domainValidation, (void *) pTarget);
+-                       schedule_work(&pTarget->dvTask);
+- ddvprintk((KERN_WARNING "%s: Raid Event: DV Scheduled for PhysDiskNum=%d bus=%d id=%d pTarget=%p\n",
+-                               ioc->name, physDiskNum, bus, id, pTarget));
 -#endif
+ 
+-	}
 +			mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum);
- 		}
++		}
  		break;
  	}
-@@ -3495,8 +3243,8 @@
+ #endif
+@@ -3575,8 +3243,8 @@ mptscsih_event_process(MPT_ADAPTER *ioc,
  /*
   *	mptscsih_initTarget - Target, LUN alloc/free functionality.
   *	@hd: Pointer to MPT_SCSI_HOST structure
@@ -29525,7 +25434,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
   *	@lun: SCSI LUN id
   *	@data: Pointer to data
   *	@dlen: Number of INQUIRY bytes
-@@ -3509,17 +3257,16 @@
+@@ -3589,17 +3257,16 @@ mptscsih_event_process(MPT_ADAPTER *ioc,
   *
   */
  static void
@@ -29539,14 +25448,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	SpiCfgData	*pSpi;
  	char		data_56;
  
--	dinitprintk((MYIOC_s_WARN_FMT "initTarget bus=%d id=%d lun=%d\n",
--			ioc->name, bus, id, lun));
+-	dinitprintk((MYIOC_s_WARN_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n",
+-			ioc->name, bus, id, lun, hd));
 +	dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n",
 +			ioc->name, bus_id, target_id, lun, hd));
  
  	/*
  	 * If the peripheral qualifier filter is enabled then if the target reports a 0x1
-@@ -3530,68 +3277,30 @@
+@@ -3610,71 +3277,29 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, i
  	 * around a bug in th emid-layer in some distributions in which the mid-layer will
  	 * continue to try to communicate to the LUN and evntually create a dummy LUN.
  	*/
@@ -29557,46 +25466,52 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	/* Is LUN supported? If so, upper 2 bits will be 0
  	* in first byte of inquiry data.
  	*/
--	if (dlen && (data[0] & 0xe0))
 +	if (data[0] & 0xe0)
- 		return;
++		return;
  
+-        if (dlen && (data[0] & 0xe0))
+-	return;
+-
 -	pMptTarget = ioc->Target_List[bus];
 -	pTarget = pMptTarget->Target[id];
--	if (pTarget == NULL) {
--		dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d pTarget is NULL\n",
--			ioc->name, bus, id, lun));
--		pTarget = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
--		if (!pTarget) {
--			printk(MYIOC_s_ERR_FMT "initTarget kmalloc(%zd) FAILED!\n",
--				ioc->name, sizeof(VirtDevice));
--			return;
--		}
+-       if (pTarget == NULL) {
+-               dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d pTarget is NULL\n"
+-,
+-                       ioc->name, bus, id, lun));
+-               pTarget = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
+-               if (!pTarget) {
+-                       printk(MYIOC_s_ERR_FMT "initTarget kmalloc(%zd) FAILED!\n",
+-                               ioc->name, sizeof(VirtDevice));
+-                       return;
+-               }
+-
+-               memset(pTarget, 0, sizeof(VirtDevice));
+-               if (ioc->bus_type != SPI)
+-                       pTarget->tflags = MPT_TARGET_FLAGS_Q_YES;
+-               pTarget->ioc = ioc;
+-               pTarget->id = id;
+-               pTarget->bus = bus;
+-               pTarget->last_lun = MPT_LAST_LUN;
+-               pTarget->raidVolume = 0;
+-               pMptTarget->Target[id] = pTarget;
+-               if (ioc->bus_type == SPI) {
+-                       if (ioc->raid_data.isRaid & (1 << id)) {
+-                               pTarget->raidVolume = 1;
+-                               ddvprintk((KERN_INFO
+-                                   "RAID Volume @ id %d\n", id));
+-                       }
+-               }
 -
--		memset(pTarget, 0, sizeof(VirtDevice));
--		if (ioc->bus_type != SPI)
--			pTarget->tflags = MPT_TARGET_FLAGS_Q_YES;
--		pTarget->ioc = ioc;
--		pTarget->id = id;
--		pTarget->bus = bus;
--		pTarget->last_lun = MPT_LAST_LUN;
--		pTarget->raidVolume = 0;
--		pMptTarget->Target[id] = pTarget;
--		if (ioc->raid_data.isRaid & (1 << id)) {
--			pTarget->raidVolume = 1;
--			ddvprintk((KERN_INFO
--			    "RAID Volume @ id %d\n", id));
--		}
 +	if ((pTarget = hd->Targets[target_id]) == NULL) {
  		return;
- 	}
- 
+-}
 -	dinitprintk((MYIOC_s_WARN_FMT "initTarget bus=%d id=%d lun=%d pTarget=%p\n",
 -			ioc->name, bus, id, lun, pTarget));
--
--	pSpi = &ioc->spi_data;
--	pTarget->ioc = ioc;
--	pTarget->tflags &= ~MPT_TARGET_FLAGS_DELETED;
+-       pSpi = &ioc->spi_data;
+-       pTarget->ioc = ioc;
+-       pTarget->tflags &= ~MPT_TARGET_FLAGS_DELETED;
++	}
+ 
  	lun_index = (lun >> 5);  /* 32 luns per lun_index */
  	indexed_lun = (lun % 32);
  	pTarget->luns[lun_index] |= (1 << indexed_lun);
@@ -29614,13 +25529,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			 * command line option is set */
  			pTarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
 -			mptscsih_writeIOCPage4(hd, id, bus);
--		} else if ((data[0] == TYPE_PROCESSOR) &&
 +			mptscsih_writeIOCPage4(hd, target_id, bus_id);
-+		}else if ((data[0] == TYPE_PROCESSOR) &&
+ 		}else if ((data[0] == TYPE_PROCESSOR) &&
  			!(pTarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) {
  			if ( dlen > 49 ) {
- //				pTarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
-@@ -3602,15 +3311,29 @@
+@@ -3686,17 +3311,29 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, i
  				     data[48] == 'T' &&
  				     data[49] == 'E' ) {
  					pTarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
@@ -29629,7 +25542,9 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				}
  			}
  		}
--		data_56 = 0x00;  /* Default to no Ultra 160 or 320 capabilities if Inq data length is < 57 */
+-data_56 = 0x00;  /* Default to no Ultra 160 or 320 capabilities if Inq data length is < 57 */
+-
+-
  		if (!(pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) {
 +			if ( dlen > 8 ) {
 +				memcpy (pTarget->inq_data, data, 8);
@@ -29652,7 +25567,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			if (dlen > 56) {
  				if ( (!(pTarget->tflags & MPT_TARGET_FLAGS_VALID_56))) {
  				/* Update the target capabilities
-@@ -3619,6 +3342,7 @@
+@@ -3705,6 +3342,7 @@ data_56 = 0x00;  /* Default to no Ultra 
  					pTarget->tflags |= MPT_TARGET_FLAGS_VALID_56;
  				}
  			}
@@ -29660,7 +25575,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		} else {
  			/* Initial Inquiry may not request enough data bytes to
  			 * obtain byte 57.  DV will; if target doesn't return
-@@ -3629,37 +3353,25 @@
+@@ -3715,40 +3353,25 @@ data_56 = 0x00;  /* Default to no Ultra 
  				 */
  					data_56 = data[56];
  					pTarget->tflags |= MPT_TARGET_FLAGS_VALID_56;
@@ -29668,34 +25583,37 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				}
  			}
  		}
--		mptscsih_setTargetNegoParms(hd, pTarget, data_56);
--		if (pSpi->dvStatus[id] & MPT_SCSICFG_NEED_DV) {
--			ddvprintk((MYIOC_s_WARN_FMT "%s: DV Scheduled for non-PhysDisk id %d\n",
--				ioc->name, __FUNCTION__, id));
--			INIT_WORK(&pTarget->dvTask, mptscsih_domainValidation, (void *) pTarget);
--			schedule_work(&pTarget->dvTask);
--		}
--	} else {
--		pTarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
--		if (ioc->bus_type == SAS) {
--			if ( (pTarget->inq_data[7] & 0x02) == 0) {
--				pTarget->tflags &= ~MPT_TARGET_FLAGS_Q_YES;
--			}
--			if ((data[0] == TYPE_TAPE)) {
--				if (ioc->facts.IOCCapabilities & 
--					MPI_IOCFACTS_CAPABILITY_TLR ) {
--					if ((pTarget->tflags & MPT_TARGET_FLAGS_TLR_DONE) == 0) {
--						if ( data[8]  == 'H' &&
--						     data[9]  == 'P' &&
--						     data[10] == ' ' &&
--						     data[11] == ' ' &&
--						     data[12] == ' ' &&
--						     data[13] == ' ' &&
--						     data[14] == ' ' &&
--						     data[15] == ' ' ) {
--							mpt_IssueTLR(hd, pTarget);
--							pTarget->tflags |= MPT_TARGET_FLAGS_TLR_DONE;
--						}
+-
+-mptscsih_setTargetNegoParms(hd, pTarget, data_56);
+-if (pSpi->dvStatus[id] & MPT_SCSICFG_NEED_DV) {
+-       ddvprintk((MYIOC_s_WARN_FMT "%s: DV Scheduled for non-PhysDisk id %d\n",
+-                 ioc->name, __FUNCTION__, id));
+-INIT_WORK(&pTarget->dvTask, mptscsih_domainValidation, (void *) pTarget);
+-schedule_work(&pTarget->dvTask);
+-       }
+-       } else {
+-         pTarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
+-         if (ioc->bus_type == SAS) {
+-            if ( (pTarget->inq_data[7] & 0x02) == 0) {
+-                 pTarget->tflags &= ~MPT_TARGET_FLAGS_Q_YES;
+-                     }
+-            if ((data[0] == TYPE_TAPE)) {
+-                      if (ioc->facts.IOCCapabilities &
+-                               MPI_IOCFACTS_CAPABILITY_TLR ) {
+-                      if ((pTarget->tflags & MPT_TARGET_FLAGS_TLR_DONE) == 0){
+-                                               if ( data[8]  == 'H' &&
+-                                                    data[9]  == 'P' &&
+-                                                    data[10] == ' ' &&
+-                                                    data[11] == ' ' &&
+-                                                    data[12] == ' ' &&
+-                                                    data[13] == ' ' &&
+-                                                    data[14] == ' ' &&
+-                                                    data[15] == ' ' ) {
+-                                                       mpt_IssueTLR(hd, pTarget);
+-                                                  pTarget->tflags |= MPT_TARGET_FLAGS_TLR_DONE;
+-
+-                                                }
+-
 +	} else if (ioc->bus_type == SAS) {
 +		if ((data[0] == TYPE_TAPE)) {
 +			if (ioc->facts.IOCCapabilities & 
@@ -29714,7 +25632,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					}
  				}
  			}
-@@ -3671,12 +3383,11 @@
+@@ -3760,12 +3383,11 @@ schedule_work(&pTarget->dvTask);
  static void
  mpt_IssueTLR(MPT_SCSI_HOST *hd, VirtDevice *pTarget)
  {
@@ -29729,7 +25647,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	for (lun=0; lun <= MPT_LAST_LUN; lun++) {
  		/* If LUN present, issue the command
  		 */
-@@ -3688,7 +3399,7 @@
+@@ -3777,7 +3399,7 @@ mpt_IssueTLR(MPT_SCSI_HOST *hd, VirtDevi
  		}
  	}
  	printk(MYIOC_s_INFO_FMT "mpt_IssueTLR: Unable find a lun on id=%d\n",
@@ -29738,7 +25656,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	return;
  issueTLR:
  	iocmd.flags = 0;
-@@ -3701,7 +3412,7 @@
+@@ -3790,7 +3412,7 @@ issueTLR:
  	if (mptscsih_do_cmd(hd, &iocmd) < 0) {
  		if (mptscsih_do_cmd(hd, &iocmd) < 0) {
  			printk(MYIOC_s_INFO_FMT "Unable to set TLR on id=%d\n",
@@ -29747,7 +25665,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		}
  	}
  }
-@@ -3713,14 +3424,12 @@
+@@ -3802,14 +3424,12 @@ issueTLR:
   *
   */
  static void
@@ -29766,19 +25684,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	int ii;
  	u8 width = MPT_NARROW;
  	u8 factor = MPT_ASYNC;
-@@ -3728,9 +3437,9 @@
+@@ -3817,36 +3437,31 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOS
  	u8 version, nfactor;
  	u8 noQas = 1;
  
 -	pTarget->negoFlags = pspi_data->noQas;
+-ddvprintk((KERN_INFO "Command-line QAS setting sets noQas=%02x on id=%d!\n",
+-               pspi_data->noQas, id));
 +	target->negoFlags = pspi_data->noQas;
  
--	ddvprintk((KERN_INFO "Command-line QAS setting sets noQas=%02x on id=%d!\n", 
+-/* noQas == 0 => device supports QAS. Need byte 56 of Inq to determine
 +	ddvtprintk((KERN_INFO "Command-line QAS setting sets noQas=%02x on id=%d!\n", 
- 		pspi_data->noQas, id));
- 	/* noQas == 0 => device supports QAS. Need byte 56 of Inq to determine
++		pspi_data->noQas, id));
++	/* noQas == 0 => device supports QAS. Need byte 56 of Inq to determine
  	 * support. If available, default QAS to off and allow enabling.
-@@ -3739,25 +3448,20 @@
+ 	 * If not available, default QAS to on, turn off for non-disks.
+ 	 */
  
  	/* Set flags based on Inquiry data
  	 */
@@ -29795,12 +25716,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +		if (target->inq_data[7] & 0x20) {
  			width = 1;
  		}
--		if (pTarget->inq_data[7] & 0x02) 
--			pTarget->tflags |= MPT_TARGET_FLAGS_Q_YES;
--		else
--			pTarget->tflags &= ~MPT_TARGET_FLAGS_Q_YES;
--
  
+-               if (pTarget->inq_data[7] & 0x02)
+-                       pTarget->tflags |= MPT_TARGET_FLAGS_Q_YES;
+-               else
+-                       pTarget->tflags &= ~MPT_TARGET_FLAGS_Q_YES;
+-
 -		if (pTarget->inq_data[7] & 0x10) {
 +		if (target->inq_data[7] & 0x10) {
  			factor = pspi_data->minSyncFactor;
@@ -29809,11 +25730,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				/* bits 2 & 3 show Clocking support */
  				if ((byte56 & 0x0C) == 0)
  					factor = MPT_ULTRA2;
-@@ -3768,17 +3472,17 @@
+@@ -3857,17 +3472,17 @@ ddvprintk((KERN_INFO "Command-line QAS s
  						factor = MPT_ULTRA320;
  						if (byte56 & 0x02)
  						{
--							ddvprintk((KERN_INFO "Enabling QAS due to byte56=%02x on id=%d!\n", byte56, id));
+-                                                   ddvprintk((KERN_INFO "Enabling QAS due to byte56=%02x on id=%d!\n", byte56, id));
 +							ddvtprintk((KERN_INFO "Enabling QAS due to byte56=%02x on id=%d!\n", byte56, id));
  							noQas = 0;
  						}
@@ -29831,7 +25752,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				factor = MPT_ULTRA2;
  			}
  
-@@ -3790,7 +3494,7 @@
+@@ -3879,7 +3494,7 @@ ddvprintk((KERN_INFO "Command-line QAS s
  			 * bit 1 QAS support, non-raid only
  			 * bit 0 IU support
  			 */
@@ -29840,18 +25761,17 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				noQas = 0;
  			}
  		} else {
-@@ -3799,6 +3503,10 @@
+@@ -3888,6 +3503,9 @@ ddvprintk((KERN_INFO "Command-line QAS s
  		}
  	}
  
 +	if ( (target->inq_data[7] & 0x02) == 0) {
 +		target->tflags &= ~MPT_TARGET_FLAGS_Q_YES;
 +	}
-+
+ 
  	/* Update tflags based on NVRAM settings. (SCSI only)
  	 */
- 	if (pspi_data->nvram && (pspi_data->nvram[id] != MPT_HOST_NVRAM_INVALID)) {
-@@ -3836,43 +3544,41 @@
+@@ -3926,43 +3544,41 @@ ddvprintk((KERN_INFO "Command-line QAS s
  
  	/* Save the data to the target structure.
  	 */
@@ -29893,28 +25813,28 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  			/* Disable QAS in a mixed configuration case
  	 		*/
+-ddvprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id));
  
--			ddvprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id));
--			pMptTarget = ioc->Target_List[0];
+-                pMptTarget = ioc->Target_List[0];
 +			ddvtprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id));
  			for (ii = 0; ii < id; ii++) {
 -				loop_pTarget = pMptTarget->Target[id];
 -				if ((loop_pTarget)) {
 -					loop_pTarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
--					mpt_writeSDP1(ioc, 0, ii, loop_pTarget->negoFlags);
+-                                        mpt_writeSDP1(ioc, 0, ii, loop_pTarget->negoFlags);
 +				if ( (pTarget = hd->Targets[ii]) ) {
 +					pTarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
 +					mptscsih_writeSDP1(hd, 0, ii, pTarget->negoFlags);
  				}
  			}
  		}
-@@ -3880,33 +3586,115 @@
+@@ -3970,33 +3586,115 @@ ddvprintk((KERN_INFO "Disabling QAS due 
  
  	/* Write SDP1 on this I/O to this target */
  	if (pspi_data->dvStatus[id] & MPT_SCSICFG_NEGOTIATE) {
 -		dnegoprintk((KERN_INFO "MPT_SCSICFG_NEGOTIATE on id=%d!\n", id));
--		/* First IO to this device; NEED_DV will cause async/narrow */
--		mpt_writeSDP1(ioc, 0, id, 0);
+-                /* First IO to this device; NEED_DV will cause async/narrow */
+-                mpt_writeSDP1(ioc, 0, id, 0);
 +		ddvtprintk((KERN_INFO "MPT_SCSICFG_NEGOTIATE on id=%d!\n", id));
 +		mptscsih_writeSDP1(hd, 0, id, hd->negoNvram);
  		pspi_data->dvStatus[id] &= ~MPT_SCSICFG_NEGOTIATE;
@@ -30037,13 +25957,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	return;
  }
-@@ -3916,75 +3704,332 @@
+@@ -4006,9 +3704,266 @@ mptscsih_no_negotiate(MPT_SCSI_HOST *hd,
   *  SCSI Config Page functionality ...
   */
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*	mptscsih_writeIOCPage4  - write IOC Page 4
-- *	@hd: Pointer to a SCSI Host Structure
-- *	@id: write IOC Page4 for this ID & Bus
 +/*	mptscsih_setDevicePage1Flags  - add Requested and Configuration fields flags
 + *	based on width, factor and offset parameters.
 + *	@width: bus width
@@ -30052,8 +25969,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 + *	@requestedPtr: pointer to requested values (updated)
 + *	@configurationPtr: pointer to configuration values (updated)
 + *	@flags: flags to block WDTR or SDTR negotiation
-  *
-- *	Return: -EAGAIN if unable to obtain a Message Frame
++ *
 + *	Return: None.
 + *
 + *	Remark: Called by writeSDP1 and _dv_params
@@ -30097,30 +26013,26 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 + *	@flags: MPT_SCSICFG_ALL_IDS, MPT_SCSICFG_USE_NVRAM, MPT_SCSICFG_BLK_NEGO
 + *
 + *	Return: -EFAULT if read of config page header fails
-  *		or 0 if success.
-  *
++ *		or 0 if success.
++ *
 + *	Remark: If a target has been found, the settings from the
 + *		target structure are used, else the device is set
 + *		to async/narrow.
 + *
 + *	Remark: Called during init and after a FW reload.
-  *	Remark: We do not wait for a return, write pages sequentially.
-  */
- static int
--mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int id, int bus)
++ *	Remark: We do not wait for a return, write pages sequentially.
++ */
++static int
 +mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
- {
- 	MPT_ADAPTER		*ioc = hd->ioc;
- 	Config_t		*pReq;
--	IOCPage4_t		*IOCPage4Ptr;
++{
++	MPT_ADAPTER		*ioc = hd->ioc;
++	Config_t		*pReq;
 +	SCSIDevicePage1_t	*pData;
 +	VirtDevice		*pTarget;
- 	MPT_FRAME_HDR		*mf;
- 	dma_addr_t		 dataDma;
- 	u16			 req_idx;
- 	u32			 frameOffset;
--	u32			 flagsLength;
--	int			 ii;
++	MPT_FRAME_HDR		*mf;
++	dma_addr_t		 dataDma;
++	u16			 req_idx;
++	u32			 frameOffset;
 +	u32			 requested, configuration, flagsLength;
 +	int			 ii, nvram;
 +	int			 id = 0, maxid = 0;
@@ -30130,13 +26042,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +	u8			 bus = 0;
 +	u8			 negoFlags;
 +	u8			 maxwidth, maxoffset, maxfactor;
- 
--	/* Get a MF for this command.
--	 */
--	if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
--		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
--		    ioc->name,__FUNCTION__));
--		return -EAGAIN;
++
 +	if (ioc->spi_data.sdp1length == 0)
 +		return 0;
 +
@@ -30146,31 +26052,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +	} else if (ioc->sh) {
 +		id = target_id;
 +		maxid = min_t(int, id, ioc->sh->max_id - 1);
- 	}
- 
--	/* Set the request and the data pointers.
--	 * Place data at end of MF.
--	 */
--	pReq = (Config_t *)mf;
++	}
++
 +	for (; id <= maxid; id++) {
- 
--	req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
--	frameOffset = ioc->req_sz - sizeof(IOCPage4_t);
++
 +		if (id == ioc->pfacts[portnum].PortSCSIID)
 +			continue;
- 
--	/* Complete the request frame (same for all requests).
--	 */
--	pReq->Action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
--	pReq->Reserved = 0;
--	pReq->ChainOffset = 0;
--	pReq->Function = MPI_FUNCTION_CONFIG;
--	pReq->ExtPageLength = 0;
--	pReq->ExtPageType = 0;
--	pReq->MsgFlags = 0;
--	for (ii=0; ii < 8; ii++) {
--		pReq->Reserved2[ii] = 0;
--	}
++
 +		/* Use NVRAM to get adapter and target maximums
 +		 * Data over-riden by target structure information, if present
 +		 */
@@ -30179,18 +26067,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +		maxfactor = ioc->spi_data.minSyncFactor;
 +		if (ioc->spi_data.nvram && (ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
 +			nvram = ioc->spi_data.nvram[id];
- 
--       	IOCPage4Ptr = ioc->spi_data.pIocPg4;
--       	dataDma = ioc->spi_data.IocPg4_dma;
--       	ii = IOCPage4Ptr->ActiveSEP++;
--       	IOCPage4Ptr->SEP[ii].SEPTargetID = id;
--       	IOCPage4Ptr->SEP[ii].SEPBus = bus;
--       	pReq->Header = IOCPage4Ptr->Header;
--	pReq->PageAddress = cpu_to_le32(id | (bus << 8 ));
++
 +			if (maxwidth)
 +				maxwidth = nvram & MPT_NVRAM_WIDE_DISABLE ? 0 : 1;
- 
--	/* Add a SGE to the config request.
++
 +			if (maxoffset > 0) {
 +				maxfactor = (nvram & MPT_NVRAM_SYNC_MASK) >> 8;
 +				if (maxfactor == 0) {
@@ -30338,72 +26218,36 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +}
 +
 +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-+/*	mptscsih_writeIOCPage4  - write IOC Page 4
-+ *	@hd: Pointer to a SCSI Host Structure
+ /*	mptscsih_writeIOCPage4  - write IOC Page 4
+  *	@hd: Pointer to a SCSI Host Structure
+- *	@id: write IOC Page4 for this ID & Bus
 + *	@target_id: write IOC Page4 for this ID & Bus
-+ *
-+ *	Return: -EAGAIN if unable to obtain a Message Frame
-+ *		or 0 if success.
-+ *
-+ *	Remark: We do not wait for a return, write pages sequentially.
-+ */
-+static int
+  *
+  *	Return: -EAGAIN if unable to obtain a Message Frame
+  *		or 0 if success.
+@@ -4016,7 +3971,7 @@ mptscsih_no_negotiate(MPT_SCSI_HOST *hd,
+  *	Remark: We do not wait for a return, write pages sequentially.
+  */
+ static int
+-mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int id, int bus)
 +mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus)
-+{
-+	MPT_ADAPTER		*ioc = hd->ioc;
-+	Config_t		*pReq;
-+	IOCPage4_t		*IOCPage4Ptr;
-+	MPT_FRAME_HDR		*mf;
-+	dma_addr_t		 dataDma;
-+	u16			 req_idx;
-+	u32			 frameOffset;
-+	u32			 flagsLength;
-+	int			 ii;
-+
-+	/* Get a MF for this command.
-+	 */
-+	if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
-+		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
-+		    ioc->name,__FUNCTION__));
-+		return -EAGAIN;
-+	}
-+
-+	/* Set the request and the data pointers.
-+	 * Place data at end of MF.
-+	 */
-+	pReq = (Config_t *)mf;
-+
-+	req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
-+	frameOffset = ioc->req_sz - sizeof(IOCPage4_t);
-+
-+	/* Complete the request frame (same for all requests).
-+	 */
-+	pReq->Action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
-+	pReq->Reserved = 0;
-+	pReq->ChainOffset = 0;
-+	pReq->Function = MPI_FUNCTION_CONFIG;
-+	pReq->ExtPageLength = 0;
-+	pReq->ExtPageType = 0;
-+	pReq->MsgFlags = 0;
-+	for (ii=0; ii < 8; ii++) {
-+		pReq->Reserved2[ii] = 0;
-+	}
-+
-+       	IOCPage4Ptr = ioc->spi_data.pIocPg4;
-+       	dataDma = ioc->spi_data.IocPg4_dma;
-+       	ii = IOCPage4Ptr->ActiveSEP++;
+ {
+ 	MPT_ADAPTER		*ioc = hd->ioc;
+ 	Config_t		*pReq;
+@@ -4060,10 +4015,10 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd
+        	IOCPage4Ptr = ioc->spi_data.pIocPg4;
+        	dataDma = ioc->spi_data.IocPg4_dma;
+        	ii = IOCPage4Ptr->ActiveSEP++;
+-	IOCPage4Ptr->SEP[ii].SEPTargetID = id;
 +       	IOCPage4Ptr->SEP[ii].SEPTargetID = target_id;
-+       	IOCPage4Ptr->SEP[ii].SEPBus = bus;
-+       	pReq->Header = IOCPage4Ptr->Header;
+        	IOCPage4Ptr->SEP[ii].SEPBus = bus;
+        	pReq->Header = IOCPage4Ptr->Header;
+-	pReq->PageAddress = cpu_to_le32(id | (bus << 8 ));
 +	pReq->PageAddress = cpu_to_le32(target_id | (bus << 8 ));
-+
-+	/* Add a SGE to the config request.
- 	 */
- 	flagsLength = MPT_SGE_FLAGS_SSIMPLE_WRITE |
- 		(IOCPage4Ptr->Header.PageLength + ii) * 4;
  
--	ioc->add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
-+	mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
+ 	/* Add a SGE to the config request.
+ 	 */
+@@ -4074,7 +4029,7 @@ mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd
  
  	dinitprintk((MYIOC_s_INFO_FMT
  		"writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n",
@@ -30412,59 +26256,55 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
  
-@@ -4026,15 +4071,6 @@
+@@ -4116,9 +4071,6 @@ mptscsih_scandv_complete(MPT_ADAPTER *io
  
  	hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
  
--	if (hd->DVcmdPtr) {
--		del_timer(&hd->DVCmdTimer);
--		hd->DVcmdPtr = NULL;
--	} else {
--		 if (hd->cmdPtr) {
--			del_timer(&hd->InternalCmdTimer);
--			hd->cmdPtr = NULL;
--		}
--	}
+-        del_timer(&hd->InternalCmdTimer);
+-
+-
  	if ((mf == NULL) ||
  	    (mf >= MPT_INDEX_2_MFPTR(ioc, ioc->req_depth))) {
  		printk(MYIOC_s_ERR_FMT
-@@ -4043,12 +4079,19 @@
+@@ -4127,18 +4079,19 @@ mptscsih_scandv_complete(MPT_ADAPTER *io
  		goto wakeup;
  	}
  
 +	del_timer(&hd->timer);
  	req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
--	ioc->ScsiLookup[req_idx] = NULL;
-+	hd->ScsiLookup[req_idx] = NULL;
+ 	hd->ScsiLookup[req_idx] = NULL;
  	pReq = (SCSIIORequest_t *) mf;
  
--	ddvprintk((MYIOC_s_WARN_FMT "ScanDvComplete mf=%p mr=%p id=%d CDB=%02x\n",
--			ioc->name, mf, mr, pReq->TargetID, pReq->CDB[0]));
-+	if (mf != hd->cmdPtr) {
+ 	if (mf != hd->cmdPtr) {
+-		printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p,!= cmdPtr=%p, idx=%d)\n",
+-				ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx);
 +		printk(MYIOC_s_WARN_FMT "ScanDvComplete (mf=%p, cmdPtr=%p, idx=%d)\n",
 +				hd->ioc->name, (void *)mf, (void *) hd->cmdPtr, req_idx);
-+	}
-+	hd->cmdPtr = NULL;
-+
+ 	}
+ 	hd->cmdPtr = NULL;
+ 
+-	ddvprintk((MYIOC_s_WARN_FMT "ScanDvComplete mf=%p,mr=%p,idx=%d\n",
+-			ioc->name, mf, mr, req_idx));
 +	ddvprintk((MYIOC_s_INFO_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n",
 +			hd->ioc->name, mf, mr, req_idx));
  
  	hd->pLocal = &hd->localReply;
  	hd->pLocal->scsiStatus = 0;
-@@ -4067,9 +4110,9 @@
+@@ -4156,9 +4109,10 @@ mptscsih_scandv_complete(MPT_ADAPTER *io
+ 
  		status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK;
  		scsi_status = pReply->SCSIStatus;
- 
--		ddvprintk((MYIOC_s_WARN_FMT "%s: IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh IOCLogInfo=%08xh\n",
--		     ioc->name, __FUNCTION__, status, pReply->SCSIState, scsi_status,
--		     le32_to_cpu(pReply->IOCLogInfo)));
+- ddvprintk((MYIOC_s_WARN_FMT "%s: IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh IOCLogInfo=%08xh\n",
+-                     ioc->name, __FUNCTION__, status, pReply->SCSIState, scsi_status,
+-                     le32_to_cpu(pReply->IOCLogInfo)));
++
 +		ddvtprintk((KERN_NOTICE "  IOCStatus=%04xh, SCSIState=%02xh, SCSIStatus=%02xh, IOCLogInfo=%08xh\n",
 +			     status, pReply->SCSIState, scsi_status,
 +			     le32_to_cpu(pReply->IOCLogInfo)));
  
  		switch(status) {
  
-@@ -4114,14 +4157,13 @@
+@@ -4203,14 +4157,13 @@ mptscsih_scandv_complete(MPT_ADAPTER *io
  				 */
  				completionCode = MPT_SCANDV_SENSE;
  				hd->pLocal->scsiStatus = scsi_status;
@@ -30480,7 +26320,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				ddvprintk((KERN_NOTICE "  Check Condition, sense ptr %p\n",
  						sense_data));
  			} else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) {
-@@ -4135,7 +4177,7 @@
+@@ -4224,7 +4177,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *io
  			else if (pReply->SCSIState & MPI_SCSI_STATE_TERMINATED)
  				completionCode = MPT_SCANDV_DID_RESET;
  			else if (scsi_status == MPI_SCSI_STATUS_BUSY)
@@ -30489,130 +26329,90 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			else {
  				completionCode = MPT_SCANDV_GOOD;
  				hd->pLocal->scsiStatus = scsi_status;
-@@ -4154,10 +4196,9 @@
+@@ -4243,9 +4196,9 @@ mptscsih_scandv_complete(MPT_ADAPTER *io
  			break;
  
  		}	/* switch(status) */
--		ddvprintk((MYIOC_s_WARN_FMT ": completionCode=%08xh\n",
--			ioc->name, completionCode));
--
+-               ddvprintk((MYIOC_s_WARN_FMT ": completionCode=%08xh\n",
+-                       ioc->name, completionCode));
  
 +		ddvtprintk((KERN_NOTICE "  completionCode set to %08xh\n",
 +				completionCode));
  	} /* end of address reply case */
  
  	hd->pLocal->completion = completionCode;
-@@ -4166,7 +4207,7 @@
- 	 */
- wakeup:
- 	/* Free Chain buffers (will never chain) in scan or dv */
--	//mpt_freeChainBuffers(ioc, req_idx);
-+	//mptscsih_freeChainBuffers(ioc, req_idx);
- 
- 	/*
- 	 * Wake up the original calling thread
-@@ -4178,84 +4219,48 @@
+@@ -4266,53 +4219,48 @@ wakeup:
  }
  
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*	mptscsih_InternalCmdTimer_expired - Call back for InternalCmd timer 
-- *	process.
-- *	Used only for Internal Command functionality.
-- *	@data: Pointer to MPT_SCSI_HOST recast as an unsigned long
-- *
-- */
--void mptscsih_InternalCmdTimer_expired(unsigned long data)
--{
--	MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
--	MPT_ADAPTER	*ioc=hd->ioc;
--	MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr;
--
--	dicprintk((MYIOC_s_WARN_FMT "InternalCmdTimer_expired! cmdPtr=%p\n", 
--		ioc->name, cmd));
--
--	if (cmd->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {
--#ifdef MPT_DEBUG_IC
--		SCSIIORequest_t	*pScsiReq = (SCSIIORequest_t *) cmd;
--		int	 id = pScsiReq->TargetID;
--
--		dicprintk((MYIOC_s_WARN_FMT "InternalCmd Timeout: id=%d CDB=%02x\n", 
--			ioc->name, id, pScsiReq->CDB[0]));
--#endif
--	}
--	hd->cmdPtr = NULL;
--	/* Perform a Diagnostic Reset */
--	if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) {
--		printk(MYIOC_s_WARN_FMT "InternalCmdTimer_expired: HardReset FAILED!\n", ioc->name);
--		dfailprintk((MYIOC_s_ERR_FMT "InternalCmdTimer_expired: HardReset failed\n", ioc->name));
--	} else {
--		dicprintk((MYIOC_s_ERR_FMT "InternalCmdTimer_expired: HardReset succeeded\n", ioc->name));
--	}
--	dicprintk((MYIOC_s_WARN_FMT "InternalCmdTimer_expired Complete!\n", ioc->name));
--}
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/*	mptscsih_DVCmdTimer_expired - Call back for DV timer process.
+-/*	mptscsih_InternalCmdTimer_expired - Call back for DV timer process.
 +/*	mptscsih_timer_expired - Call back for timer process.
   *	Used only for dv functionality.
   *	@data: Pointer to MPT_SCSI_HOST recast as an unsigned long
   *
   */
--void mptscsih_DVCmdTimer_expired(unsigned long data)
+-void mptscsih_InternalCmdTimer_expired(unsigned long data)
 +void
 +mptscsih_timer_expired(unsigned long data)
  {
  	MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
 -	MPT_ADAPTER	*ioc=hd->ioc;
--	MPIHeader_t *cmd = (MPIHeader_t *)hd->DVcmdPtr;
--
--	ddvprintk((MYIOC_s_WARN_FMT "DVCmdTimer_expired! DVcmdPtr=%p\n", 
+-	MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr;
+ 
+-	ddvprintk((MYIOC_s_WARN_FMT "InternalCmdTimer_expired! cmdPtr=%p\n",
 -		ioc->name, cmd));
++	ddvprintk((MYIOC_s_WARN_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr));
  
--	hd->DVcmdPtr = NULL;
+-	hd->cmdPtr = NULL;
 -	if (cmd->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {
+-#ifdef MPT_DEBUG_DV
 -		SCSIIORequest_t	*pScsiReq = (SCSIIORequest_t *) cmd;
--		int	 bus = pScsiReq->Bus;
--		
-+	ddvprintk((MYIOC_s_WARN_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr));
- 
--		ddvprintk((MYIOC_s_WARN_FMT "DV Cmd Timeout: channel=%d id=%d CDB=%02x\n", 
--			ioc->name, bus, pScsiReq->TargetID, pScsiReq->CDB[0]));
+-		int	 id = pScsiReq->TargetID;
+-
+-		/* Desire to issue a task management request here.
+-		 * TM requests MUST be single threaded.
+-		 * If old eh code and no TM current, issue request.
+-		 * If new eh code, do nothing. Wait for OS cmd timeout
+-		 *	for bus reset.
+-		 */
+-		ddvprintk((MYIOC_s_WARN_FMT "DV Cmd Timeout: id=%d CDB=%02x\n",
+-			ioc->name, id, pScsiReq->CDB[0]));
+-#endif
 +	if (hd->cmdPtr) {
 +		MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr;
  
--		if (mptscsih_reset_bus_noblock(ioc, bus) == 0) {
--			/*
--			 * Wake up the original calling thread
+-		/*
+-		 * Wake up the original calling thread
+-		 */
+-		hd->pLocal = &hd->localReply;
+-		hd->pLocal->completion = MPT_SCANDV_FALLBACK;
+-		hd->scandv_wait_done = 1;
+-		wake_up(&hd->scandv_waitq);
+-	} else {
+-		/* Perform a FW reload */
+-		if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) {
+-			printk(MYIOC_s_WARN_FMT "InternalCmdTimer_expired: HardReset FAILED!\n", ioc->name);
+-			dfailprintk((MYIOC_s_ERR_FMT "InternalCmdTimer_expired: HardReset failed\n", ioc->name));
 +		if (cmd->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {
 +			/* Desire to issue a task management request here.
 +			 * TM requests MUST be single threaded.
 +			 * If old eh code and no TM current, issue request.
 +			 * If new eh code, do nothing. Wait for OS cmd timeout
 +			 *	for bus reset.
- 			 */
--			hd->pLocal = &hd->localReply;
--			hd->pLocal->completion = MPT_SCANDV_FALLBACK;
--			hd->scandv_wait_done = 1;
--			wake_up(&hd->scandv_waitq);
--			ddvprintk((MYIOC_s_WARN_FMT "DVCmdTimer_expired bus_reset completed, request DV FALLBACK\n", ioc->name));
--			return;
++			 */
 +			ddvtprintk((MYIOC_s_NOTE_FMT "DV Cmd Timeout: NoOp\n", hd->ioc->name));
-+		} else {
+ 		} else {
+-			ddvprintk((MYIOC_s_ERR_FMT "InternalCmdTimer_expired: HardReset succeeded\n", ioc->name));
 +			/* Perform a FW reload */
 +			if (mpt_HardResetHandler(hd->ioc, NO_SLEEP) < 0) {
 +				printk(MYIOC_s_WARN_FMT "Firmware Reload FAILED!\n", hd->ioc->name);
 +			}
  		}
--	}
--	/* Perform a Diagnostic Reset */
--	if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) {
--		printk(MYIOC_s_WARN_FMT "DVCmdTimer_expired: HardReset FAILED!\n", ioc->name);
--		dfailprintk((MYIOC_s_ERR_FMT "DVCmdTimer_expired: HardReset failed\n", ioc->name));
- 	} else {
--		ddvprintk((MYIOC_s_ERR_FMT "DVCmdTimer_expired: HardReset succeeded\n", ioc->name));
++	} else {
 +		/* This should NEVER happen */
 +		printk(MYIOC_s_WARN_FMT "Null cmdPtr!!!!\n", hd->ioc->name);
  	}
+-	ddvprintk((MYIOC_s_WARN_FMT "InternalCmdTimer_expired Complete!\n", ioc->name));
 +
 +	/* No more processing.
 +	 * TM call will generate an interrupt for SCSI TM Management.
@@ -30625,7 +26425,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  }
  
  #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
-@@ -4274,23 +4279,22 @@
+@@ -4331,23 +4279,22 @@ void mptscsih_InternalCmdTimer_expired(u
  static int
  mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io)
  {
@@ -30637,7 +26437,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	in_isr = in_interrupt();
  	if (in_isr) {
 -		dfailprintk((MYIOC_s_WARN_FMT "Internal raid request not allowed in ISR context!\n",
--       				ioc->name));
+-				ioc->name));
 +		dprintk((MYIOC_s_WARN_FMT "Internal raid request not allowed in ISR context!\n",
 +       				hd->ioc->name));
  		return -EPERM;
@@ -30653,297 +26453,32 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		return -EAGAIN;
  	}
  	pReq = (MpiRaidActionRequest_t *)mf;
-@@ -4301,273 +4305,36 @@
- 	pReq->VolumeID = io->id;
- 	pReq->VolumeBus = io->bus;
- 	pReq->PhysDiskNum = io->physDiskNum;
--	pReq->MsgFlags = 0;
--	pReq->Reserved2 = 0;
--	pReq->ActionDataWord = 0; /* Reserved for this action */
--	//pReq->ActionDataSGE = 0;
--
--	ioc->add_sge((char *)&pReq->ActionDataSGE,
--		MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
--
--	ddvprintk((MYIOC_s_INFO_FMT "RAID Volume action %x id %d\n",
--			ioc->name, action, io->id));
--
--	hd->pLocal = NULL;
--	hd->DVCmdTimer.expires = jiffies + HZ*10; /* 10 second timeout */
--	hd->scandv_wait_done = 0;
--
--	/* Save cmd pointer, for resource free if timeout or
--	 * FW reload occurs
--	 */
--	hd->DVcmdPtr = mf;
--
--	add_timer(&hd->DVCmdTimer);
--	mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
--	wait_event(hd->scandv_waitq, hd->scandv_wait_done);
--
--	if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD))
--		return -1;
--
--	return 0;
--}
--#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */
--
--/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
--/**
-- *	mptscsih_do_DVcmd - Do DV command.
-- *	@hd: MPT_SCSI_HOST pointer
-- *	@io: INTERNAL_CMD pointer.
-- *
-- *	Issue the specified internally generated command and do command
-- *	specific cleanup. For bus scan / DV only.
-- *	NOTES: If command is Inquiry and status is good,
-- *	initialize a target structure, save the data
-- *
-- *	Remark: Single threaded access only.
-- *
-- *	Return:
-- *		< 0 if an illegal command or no resources
-- *
-- *		   0 if good
-- *
-- *		 > 0 if command complete but some type of completion error.
-- */
--int
--mptscsih_do_DVcmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
--{
--	MPT_ADAPTER	*ioc = hd->ioc;
--	MPT_FRAME_HDR	*mf;
--	SCSIIORequest_t	*pScsiReq;
--	SCSIIORequest_t	 ReqCopy;
--	int		 my_idx, ii, dir;
--	int		 rc, cmdTimeout;
--	int		in_isr;
--	u8		 cmdLen;
--	u8		 CDB[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
--	u8		 cmd = io->cmd;
--
--	in_isr = in_interrupt();
--	if (in_isr) {
--		dfailprintk((MYIOC_s_WARN_FMT "Internal SCSI IO request not allowed in ISR context!\n",
--       				ioc->name));
--		return -EPERM;
--	}
--
--
--	/* Set command specific information
--	 */
--	switch (cmd) {
--	case INQUIRY:
--		cmdLen = 6;
--		dir = MPI_SCSIIO_CONTROL_READ;
--		CDB[0] = cmd;
--		CDB[4] = io->size;
--		cmdTimeout = 1;
--		break;
--
--	case TEST_UNIT_READY:
--		cmdLen = 6;
--		dir = MPI_SCSIIO_CONTROL_READ;
--		cmdTimeout = 1;
--		break;
--
--	case REQUEST_SENSE:
--		cmdLen = 6;
--		CDB[0] = cmd;
--		CDB[4] = io->size;
--		dir = MPI_SCSIIO_CONTROL_READ;
--		cmdTimeout = 1;
--		break;
--
--	case READ_BUFFER:
--		cmdLen = 10;
--		dir = MPI_SCSIIO_CONTROL_READ;
--		CDB[0] = cmd;
--		if (io->flags & MPT_ICFLAG_ECHO) {
--			CDB[1] = 0x0A;
--		} else {
--			CDB[1] = 0x02;
--		}
--
--		if (io->flags & MPT_ICFLAG_BUF_CAP) {
--			CDB[1] |= 0x01;
--		}
--		CDB[6] = (io->size >> 16) & 0xFF;
--		CDB[7] = (io->size >>  8) & 0xFF;
--		CDB[8] = io->size & 0xFF;
--		cmdTimeout = 1;
--		break;
--
--	case WRITE_BUFFER:
--		cmdLen = 10;
--		dir = MPI_SCSIIO_CONTROL_WRITE;
--		CDB[0] = cmd;
--		if (io->flags & MPT_ICFLAG_ECHO) {
--			CDB[1] = 0x0A;
--		} else {
--			CDB[1] = 0x02;
--		}
--		CDB[6] = (io->size >> 16) & 0xFF;
--		CDB[7] = (io->size >>  8) & 0xFF;
--		CDB[8] = io->size & 0xFF;
--		cmdTimeout = 1;
--		break;
--
--	case RESERVE:
--		cmdLen = 6;
--		dir = MPI_SCSIIO_CONTROL_READ;
--		CDB[0] = cmd;
--		cmdTimeout = 1;
--		break;
--
--	case RELEASE:
--		cmdLen = 6;
--		dir = MPI_SCSIIO_CONTROL_READ;
--		CDB[0] = cmd;
--		cmdTimeout = 1;
--		break;
--
--	default:
--		/* Error Case */
--		dfailprintk((MYIOC_s_WARN_FMT "%s,Unknown cmd=%02x!!\n",
--		    ioc->name,__FUNCTION__, cmd));
--		return -EFAULT;
--	}
--
--	/* Get and Populate a free Frame
--	 */
--	if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
--		dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
--		    ioc->name,__FUNCTION__));
--		return -EBUSY;
--	}
--
--	pScsiReq = (SCSIIORequest_t *) mf;
--
--	/* Get the request index */
--	my_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
--	ADD_INDEX_LOG(my_idx); /* for debug */
--
--	if (io->flags & MPT_ICFLAG_PHYS_DISK) {
--		pScsiReq->TargetID = io->physDiskNum;
--		pScsiReq->Bus = 0;
--		pScsiReq->ChainOffset = 0;
--		pScsiReq->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH;
--	} else {
--		pScsiReq->TargetID = io->id;
--		pScsiReq->Bus = io->bus;
--		pScsiReq->ChainOffset = 0;
--		pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST;
--	}
--
--	pScsiReq->CDBLength = cmdLen;
--	pScsiReq->SenseBufferLength = MPT_SENSE_BUFFER_SIZE;
--
--	pScsiReq->Reserved = 0;
--
--	pScsiReq->MsgFlags = mpt_msg_flags();
--	/* MsgContext set in mpt_get_msg_fram call  */
--
--	for (ii=0; ii < 8; ii++)
--		pScsiReq->LUN[ii] = 0;
--	pScsiReq->LUN[1] = io->lun;
--
--	if (io->flags & MPT_ICFLAG_TAGGED_CMD)
--		pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_SIMPLEQ);
--	else
--		pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
--
--	if (cmd == REQUEST_SENSE) {
--		pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
--		ddvprintk((MYIOC_s_INFO_FMT "Untagged! 0x%2x\n",
--			ioc->name, cmd));
--	}
--
--	for (ii=0; ii < 16; ii++)
--		pScsiReq->CDB[ii] = CDB[ii];
--
--	pScsiReq->DataLength = cpu_to_le32(io->size);
--	pScsiReq->SenseBufferLowAddr = cpu_to_le32(ioc->sense_buf_low_dma
--					   + (my_idx * MPT_SENSE_BUFFER_ALLOC));
--
--	ddvprintk((MYIOC_s_INFO_FMT "Sending Command 0x%x for (%d:%d:%d) mf=%p\n",
--			ioc->name, cmd, io->bus, io->id, io->lun, pScsiReq));
-+	pReq->MsgFlags = 0;
-+	pReq->Reserved2 = 0;
-+	pReq->ActionDataWord = 0; /* Reserved for this action */
-+	//pReq->ActionDataSGE = 0;
+@@ -4367,11 +4314,10 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 a
+ 		MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
  
--	if (dir == MPI_SCSIIO_CONTROL_READ) {
--		ioc->add_sge((char *) &pScsiReq->SGL,
--			MPT_SGE_FLAGS_SSIMPLE_READ | io->size,
--			io->data_dma);
--	} else {
--		ioc->add_sge((char *) &pScsiReq->SGL,
--			MPT_SGE_FLAGS_SSIMPLE_WRITE | io->size,
--			io->data_dma);
--	}
-+	mpt_add_sge((char *)&pReq->ActionDataSGE,
-+		MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
- 
--	/* The ISR will free the request frame, but we need
--	 * the information to initialize the target. Duplicate.
--	 */
--	memcpy(&ReqCopy, pScsiReq, sizeof(SCSIIORequest_t));
-+	ddvprintk((MYIOC_s_INFO_FMT "RAID Volume action %x id %d\n",
+ 	ddvprintk((MYIOC_s_INFO_FMT "RAID Volume action %x id %d\n",
+-			ioc->name, action, io->id));
 +			hd->ioc->name, action, io->id));
  
--	/* Issue this command after:
--	 *	finish init
--	 *	add timer
--	 * Wait until the reply has been received
--	 *  ScsiScanDvCtx callback function will
--	 *	set hd->pLocal;
--	 *	set scandv_wait_done and call wake_up
--	 */
  	hd->pLocal = NULL;
--	hd->DVCmdTimer.expires = jiffies + HZ*cmdTimeout;
+-	hd->InternalCmdTimer.data = (unsigned long) hd;
+-        hd->InternalCmdTimer.expires = jiffies + HZ*10; /* 10 second timeout */
 +	hd->timer.expires = jiffies + HZ*10; /* 10 second timeout */
  	hd->scandv_wait_done = 0;
  
  	/* Save cmd pointer, for resource free if timeout or
- 	 * FW reload occurs
+@@ -4379,8 +4325,8 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 a
  	 */
--	hd->DVcmdPtr = mf;
-+	hd->cmdPtr = mf;
+ 	hd->cmdPtr = mf;
  
--	add_timer(&hd->DVCmdTimer);
--	mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
+-	add_timer(&hd->InternalCmdTimer);
+-        mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
 +	add_timer(&hd->timer);
 +	mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf);
  	wait_event(hd->scandv_waitq, hd->scandv_wait_done);
  
--	if (hd->pLocal) {
--		rc = hd->pLocal->completion;
--		hd->pLocal->skip = 0;
--
--		/* Always set fatal error codes in some cases.
--		 */
--		if (rc == MPT_SCANDV_SELECTION_TIMEOUT)
--			rc = -ENXIO;
--		else if (rc == MPT_SCANDV_SOME_ERROR)
--			rc =  -rc;
--	} else {
--		rc = -EFAULT;
--		/* This should never happen. */
--		ddvprintk((MYIOC_s_INFO_FMT "_do_DVcmd: Null pLocal!!!\n",
--				ioc->name));
--	}
-+	if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD))
-+		return -1;
- 
--	return rc;
-+	return 0;
- }
-+#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */
- 
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /**
-@@ -4592,7 +4359,6 @@
+ 	if ((hd->pLocal == NULL) || (hd->pLocal->completion != MPT_SCANDV_GOOD))
+@@ -4413,7 +4359,6 @@ mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 a
  int
  mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
  {
@@ -30951,103 +26486,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	MPT_FRAME_HDR	*mf;
  	SCSIIORequest_t	*pScsiReq;
  	SCSIIORequest_t	 ReqCopy;
-@@ -4605,8 +4371,8 @@
+@@ -4426,8 +4371,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTER
  
  	in_isr = in_interrupt();
  	if (in_isr) {
 -		dfailprintk((MYIOC_s_WARN_FMT "Internal SCSI IO request not allowed in ISR context!\n",
--       				ioc->name));
+-				ioc->name));
 +		dprintk((MYIOC_s_WARN_FMT "Internal SCSI IO request not allowed in ISR context!\n",
 +       				hd->ioc->name));
  		return -EPERM;
  	}
  
-@@ -4614,12 +4380,84 @@
- 	/* Set command specific information
- 	 */
- 	switch (cmd) {
-+	case INQUIRY:
-+		cmdLen = 6;
-+		dir = MPI_SCSIIO_CONTROL_READ;
-+		CDB[0] = cmd;
-+		CDB[4] = io->size;
-+		cmdTimeout = 10;
-+		break;
-+
- 	case TEST_UNIT_READY:
- 		cmdLen = 6;
- 		dir = MPI_SCSIIO_CONTROL_READ;
- 		cmdTimeout = 10;
- 		break;
- 
-+	case START_STOP:
-+		cmdLen = 6;
-+		dir = MPI_SCSIIO_CONTROL_READ;
-+		CDB[0] = cmd;
-+		CDB[4] = 1;	/*Spin up the disk */
-+		cmdTimeout = 15;
-+		break;
-+
-+	case REQUEST_SENSE:
-+		cmdLen = 6;
-+		CDB[0] = cmd;
-+		CDB[4] = io->size;
-+		dir = MPI_SCSIIO_CONTROL_READ;
-+		cmdTimeout = 10;
-+		break;
-+
-+	case READ_BUFFER:
-+		cmdLen = 10;
-+		dir = MPI_SCSIIO_CONTROL_READ;
-+		CDB[0] = cmd;
-+		if (io->flags & MPT_ICFLAG_ECHO) {
-+			CDB[1] = 0x0A;
-+		} else {
-+			CDB[1] = 0x02;
-+		}
-+
-+		if (io->flags & MPT_ICFLAG_BUF_CAP) {
-+			CDB[1] |= 0x01;
-+		}
-+		CDB[6] = (io->size >> 16) & 0xFF;
-+		CDB[7] = (io->size >>  8) & 0xFF;
-+		CDB[8] = io->size & 0xFF;
-+		cmdTimeout = 10;
-+		break;
-+
-+	case WRITE_BUFFER:
-+		cmdLen = 10;
-+		dir = MPI_SCSIIO_CONTROL_WRITE;
-+		CDB[0] = cmd;
-+		if (io->flags & MPT_ICFLAG_ECHO) {
-+			CDB[1] = 0x0A;
-+		} else {
-+			CDB[1] = 0x02;
-+		}
-+		CDB[6] = (io->size >> 16) & 0xFF;
-+		CDB[7] = (io->size >>  8) & 0xFF;
-+		CDB[8] = io->size & 0xFF;
-+		cmdTimeout = 10;
-+		break;
-+
-+	case RESERVE:
-+		cmdLen = 6;
-+		dir = MPI_SCSIIO_CONTROL_READ;
-+		CDB[0] = cmd;
-+		cmdTimeout = 10;
-+		break;
-+
-+	case RELEASE:
-+		cmdLen = 6;
-+		dir = MPI_SCSIIO_CONTROL_READ;
-+		CDB[0] = cmd;
-+		cmdTimeout = 10;
-+		break;
-+
- 	case SYNCHRONIZE_CACHE:
- 		cmdLen = 10;
- 		dir = MPI_SCSIIO_CONTROL_READ;
-@@ -4649,16 +4487,14 @@
+@@ -4542,16 +4487,14 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTER
  
  	default:
  		/* Error Case */
@@ -31066,16 +26516,14 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		return -EBUSY;
  	}
  
-@@ -4697,22 +4533,28 @@
- 	else
+@@ -4593,18 +4536,18 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTER
+ 	if (cmd == REQUEST_SENSE) {
  		pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
- 
-+	if (cmd == REQUEST_SENSE) {
-+		pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
-+		ddvprintk((MYIOC_s_INFO_FMT "Untagged! 0x%2x\n",
+ 		ddvprintk((MYIOC_s_INFO_FMT "Untagged! 0x%2x\n",
+-			ioc->name, cmd));
 +			hd->ioc->name, cmd));
-+	}
-+
+ 	}
+ 
  	for (ii=0; ii < 16; ii++)
  		pScsiReq->CDB[ii] = CDB[ii];
  
@@ -31084,54 +26532,44 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +	pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma
  					   + (my_idx * MPT_SENSE_BUFFER_ALLOC));
  
--	dicprintk((MYIOC_s_INFO_FMT "Sending Command 0x%x for (%d:%d:%d) mf=%p\n",
--			ioc->name, cmd, io->bus, io->id, io->lun, pScsiReq));
+-       ddvprintk((MYIOC_s_INFO_FMT "Sending Command 0x%x for (%d:%d:%d) mf=%p\n",
+-                       ioc->name, cmd, io->bus, io->id, io->lun, pScsiReq));
 +	ddvprintk((MYIOC_s_INFO_FMT "Sending Command 0x%x for (%d:%d:%d)\n",
 +			hd->ioc->name, cmd, io->bus, io->id, io->lun));
  
  	if (dir == MPI_SCSIIO_CONTROL_READ) {
--		ioc->add_sge((char *) &pScsiReq->SGL,
-+		mpt_add_sge((char *) &pScsiReq->SGL,
- 			MPT_SGE_FLAGS_SSIMPLE_READ | io->size,
- 			io->data_dma);
- 	} else {
--		ioc->add_sge((char *) &pScsiReq->SGL,
-+		mpt_add_sge((char *) &pScsiReq->SGL,
- 			MPT_SGE_FLAGS_SSIMPLE_WRITE | io->size,
- 			io->data_dma);
- 	}
-@@ -4731,7 +4573,7 @@
+ 		mpt_add_sge((char *) &pScsiReq->SGL,
+@@ -4630,8 +4573,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTER
  	 *	set scandv_wait_done and call wake_up
  	 */
  	hd->pLocal = NULL;
--	hd->InternalCmdTimer.expires = jiffies + HZ*cmdTimeout;
+-        hd->InternalCmdTimer.data = (unsigned long) hd;
+-        hd->InternalCmdTimer.expires = jiffies + HZ*cmdTimeout;
 +	hd->timer.expires = jiffies + HZ*cmdTimeout;
  	hd->scandv_wait_done = 0;
  
  	/* Save cmd pointer, for resource free if timeout or
-@@ -4739,8 +4581,8 @@
+@@ -4639,8 +4581,8 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTER
  	 */
  	hd->cmdPtr = mf;
  
--	add_timer(&hd->InternalCmdTimer);
+-        add_timer(&hd->InternalCmdTimer);
 -	mpt_put_msg_frame(ioc->InternalCtx, ioc, mf);
 +	add_timer(&hd->timer);
 +	mpt_put_msg_frame(hd->ioc->InternalCtx, hd->ioc, mf);
  	wait_event(hd->scandv_waitq, hd->scandv_wait_done);
  
  	if (hd->pLocal) {
-@@ -4756,8 +4598,8 @@
- 	} else {
+@@ -4657,7 +4599,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTER
  		rc = -EFAULT;
  		/* This should never happen. */
--		dicprintk((MYIOC_s_INFO_FMT "_do_cmd: Null pLocal!!!\n",
+ 		ddvprintk((MYIOC_s_INFO_FMT "_do_cmd: Null pLocal!!!\n",
 -				ioc->name));
-+		ddvprintk((MYIOC_s_INFO_FMT "_do_cmd: Null pLocal!!!\n",
 +				hd->ioc->name));
  	}
  
  	return rc;
-@@ -4778,7 +4620,6 @@
+@@ -4678,7 +4620,6 @@ static int
  mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum)
  {
  	MPT_ADAPTER		*ioc= hd->ioc;
@@ -31139,7 +26577,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	VirtDevice		*pTarget;
  	SCSIDevicePage1_t	*pcfg1Data = NULL;
  	INTERNAL_CMD		 iocmd;
-@@ -4790,6 +4631,7 @@
+@@ -4690,6 +4631,7 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  	int			 lun;
  	int			 indexed_lun, lun_index;
  	int			 hostId = ioc->pfacts[portnum].PortSCSIID;
@@ -31147,7 +26585,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	int			 requested, configuration, data;
  	int			 doConfig = 0;
  	u8			 flags, factor;
-@@ -4797,6 +4639,8 @@
+@@ -4697,6 +4639,8 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  	dexitprintk((KERN_INFO MYNAM ": %s called\n",
  		__FUNCTION__));
  
@@ -31156,16 +26594,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	/* Following parameters will not change
  	 * in this routine.
  	 */
-@@ -4814,7 +4658,7 @@
- 	if (ioc->bus_type == SPI) {
- 		if (ioc->spi_data.sdp1length > 0) {
- 			pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev,
--				ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);
-+					 ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);
- 
- 			if (pcfg1Data != NULL) {
- 				doConfig = 1;
-@@ -4833,11 +4677,10 @@
+@@ -4733,11 +4677,10 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  
  	/* loop through all devices on this port
  	 */
@@ -31179,7 +26608,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  		if (doConfig) {
  
-@@ -4845,9 +4688,9 @@
+@@ -4745,9 +4688,9 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  			if (pTarget && !pTarget->raidVolume) {
  				flags = pTarget->negoFlags;
  			} else {
@@ -31192,15 +26621,15 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  					if (data & MPT_NVRAM_WIDE_DISABLE)
  						flags |= MPT_TARGET_NO_NEGO_WIDE;
-@@ -4859,16 +4702,16 @@
+@@ -4759,16 +4702,16 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  			}
  
  			/* Force to async, narrow */
--			mpt_setSDP1parameters(0, MPT_ASYNC, 0, flags, 
--				&requested, &configuration);
--			dnegoprintk(("%s: syncronize cache: id=%d width=0 factor=MPT_ASYNC "
--				"offset=0 negoFlags=%x requested=%x configuration=%x\n",
--				ioc->name, id, flags, requested, configuration));
+-                       mpt_setSDP1parameters(0, MPT_ASYNC, 0, flags,
+-                               &requested, &configuration);
+-                       dnegoprintk(("%s: syncronize cache: id=%d width=0 factor=MPT_ASYNC "
+-                                "offset=0 negoFlags=%x requested=%x configuration=%x\n",
+-                                ioc->name, id, flags, requested, configuration));
 +			mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,
 +					&configuration, flags);
 +			dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC "
@@ -31215,7 +26644,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		}
  
  		/* If target Ptr NULL or if this target is NOT a disk, skip.
-@@ -4880,9 +4723,6 @@
+@@ -4780,9 +4723,6 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  				lun_index = (lun >> 5);  /* 32 luns per lun_index */
  				indexed_lun = (lun % 32);
  				if (pTarget->luns[lun_index] & (1<<indexed_lun)) {
@@ -31225,7 +26654,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					iocmd.lun = lun;
  					(void) mptscsih_do_cmd(hd, &iocmd);
  				}
-@@ -4895,23 +4735,16 @@
+@@ -4795,27 +4735,21 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  		if (id == hostId)
  			id++;
  
@@ -31250,7 +26679,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	return 0;
  }
  
-@@ -4930,209 +4763,163 @@
+ #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
++/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ /**
+  *	mptscsih_domainValidation - Top level handler for domain validation.
+  *	@hd: Pointer to MPT_SCSI_HOST structure.
+@@ -4829,209 +4763,163 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST
  static void
  mptscsih_domainValidation(void *arg)
  {
@@ -31268,8 +26702,13 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	spin_lock_irqsave(&dvtaskQ_lock, flags);
  	dvtaskQ_active = 1;
--	spin_unlock_irqrestore(&dvtaskQ_lock, flags);
--
++	if (dvtaskQ_release) {
++		dvtaskQ_active = 0;
++		spin_unlock_irqrestore(&dvtaskQ_lock, flags);
++		return;
++	}
+ 	spin_unlock_irqrestore(&dvtaskQ_lock, flags);
+ 
 -	if (pTarget == NULL) {
 -		ddvprintk((KERN_WARNING "domainValidation called with NULL pTarget\n"));
 -		goto mptscsih_domainValidation_exit;
@@ -31279,26 +26718,38 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -	if (ioc == NULL) {
 -		ddvprintk((KERN_WARNING "domainValidation called with NULL pTarget->ioc id=%d\n", id));
 -		goto mptscsih_domainValidation_exit;
-+	if (dvtaskQ_release) {
-+		dvtaskQ_active = 0;
-+		spin_unlock_irqrestore(&dvtaskQ_lock, flags);
-+		return;
- 	}
+-	}
 -//	set_current_state(TASK_INTERRUPTIBLE);
 -//	schedule_timeout(MPT_HZ/4);
-+	spin_unlock_irqrestore(&dvtaskQ_lock, flags);
- 
--	hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
 +	if (crashdump_mode())
 +		return;
  
+-	hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
++	/* For this ioc, loop through all devices and do dv to each device.
++	 * When complete with this ioc, search through the ioc list, and
++	 * for each scsi ioc found, do dv for all devices. Exit when no
++	 * device needs dv.
++	 */
++	did = 1;
++	while (did) {
++		did = 0;
++		list_for_each_entry(ioc, &ioc_list, list) {
++			spin_lock_irqsave(&dvtaskQ_lock, flags);
++			if (dvtaskQ_release) {
++				dvtaskQ_active = 0;
++				spin_unlock_irqrestore(&dvtaskQ_lock, flags);
++				return;
++			}
++			spin_unlock_irqrestore(&dvtaskQ_lock, flags);
+ 
 -	ddvprintk((KERN_WARNING "domainValidation pTarget=%p ioc=%p hd=%p id=%d\n",
 -		pTarget, ioc, hd, id));
 -	if (hd == NULL) {
 -		ddvprintk((KERN_WARNING "domainValidation called with NULL hd id=%d\n", id));
 -		goto mptscsih_domainValidation_exit;
 -	}
--	
++			msleep(250);
+ 
 -	if ((ioc->spi_data.forceDv & MPT_SCSICFG_RELOAD_IOC_PG3) != 0) {
 -		mpt_read_ioc_pg_3(ioc);
 -		if (ioc->spi_data.dvStatus[id] & MPT_SCSICFG_PHYSDISK_DV_ONLY) {
@@ -31313,47 +26764,29 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -				/* DV is complete. Clear flags.
 -				 */
 -				ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE;
-+	/* For this ioc, loop through all devices and do dv to each device.
-+	 * When complete with this ioc, search through the ioc list, and
-+	 * for each scsi ioc found, do dv for all devices. Exit when no
-+	 * device needs dv.
-+	 */
-+	did = 1;
-+	while (did) {
-+		did = 0;
-+		list_for_each_entry(ioc, &ioc_list, list) {
-+			spin_lock_irqsave(&dvtaskQ_lock, flags);
-+			if (dvtaskQ_release) {
-+				dvtaskQ_active = 0;
-+				spin_unlock_irqrestore(&dvtaskQ_lock, flags);
-+				return;
- 			}
+-			}
 -			goto mptscsih_domainValidation_exit;
 -		}
-+			spin_unlock_irqrestore(&dvtaskQ_lock, flags);
++			/* DV only to SPI adapters */
++			if (ioc->bus_type != SPI)
++				continue;
  
 -		if (ioc->raid_data.pIocPg3) {
 -			Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
 -			int	numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
-+			msleep(250);
++			/* Make sure everything looks ok */
++			if (ioc->sh == NULL)
++				continue;
  
 -			while (numPDisk) {
 -				if (ioc->spi_data.dvStatus[pPDisk->PhysDiskID] & MPT_SCSICFG_DV_NOT_DONE)
 -					ioc->spi_data.dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
-+			/* DV only to SPI adapters */
-+			if (ioc->bus_type != SPI)
++			hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
++			if (hd == NULL)
 +				continue;
  
 -				pPDisk++;
 -				numPDisk--;
-+			/* Make sure everything looks ok */
-+			if (ioc->sh == NULL)
-+				continue;
-+
-+			hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
-+			if (hd == NULL)
-+				continue;
-+
 +			if ((ioc->spi_data.forceDv & MPT_SCSICFG_RELOAD_IOC_PG3) != 0) {
 +				mpt_read_ioc_pg_3(ioc);
 +				if (ioc->raid_data.pIocPg3) {
@@ -31376,7 +26809,10 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
 -	dvStatus = ioc->spi_data.dvStatus[id];
 +			maxid = min_t(int, ioc->sh->max_id, MPT_MAX_SCSI_DEVICES);
-+
+ 
+-	if (dvStatus & MPT_SCSICFG_NEED_DV) {
+-		ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_DV_IN_PROGRESS;
+-		ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_NEED_DV;
 +			for (id = 0; id < maxid; id++) {
 +				spin_lock_irqsave(&dvtaskQ_lock, flags);
 +				if (dvtaskQ_release) {
@@ -31387,9 +26823,8 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +				spin_unlock_irqrestore(&dvtaskQ_lock, flags);
 +				dvStatus = hd->ioc->spi_data.dvStatus[id];
  
--	if (dvStatus & MPT_SCSICFG_NEED_DV) {
--		ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_DV_IN_PROGRESS;
--		ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_NEED_DV;
+-//		set_current_state(TASK_INTERRUPTIBLE);
+-//		schedule_timeout(MPT_HZ/4);
 +				if (dvStatus & MPT_SCSICFG_NEED_DV) {
 +					did++;
 +					hd->ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_DV_PENDING;
@@ -31410,14 +26845,6 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 +						}
 +					}
  
--//		set_current_state(TASK_INTERRUPTIBLE);
--//		schedule_timeout(MPT_HZ/4);
-+					if(mpt_alt_ioc_wait(hd->ioc)!=0) {
-+						ddvprintk((MYIOC_s_WARN_FMT "alt_ioc busy!\n",
-+						    hd->ioc->name));
-+						continue;
-+					}
- 
 -		/* If hidden phys disk, block IO's to all
 -		 *	raid volumes
 -		 * else, process normally
@@ -31431,6 +26858,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -					ddvprintk((KERN_WARNING "doDv for PhysDiskNum=%d PhysDiskID=%d numPDisk=%d\n",
 -						pPDisk->PhysDiskNum, ii, numPDisk));
 -					if (mptscsih_doDv(hd, 0, ii) == 1) {
++					if(mpt_alt_ioc_wait(hd->ioc)!=0) {
++						ddvprintk((MYIOC_s_WARN_FMT "alt_ioc busy!\n",
++						    hd->ioc->name));
++						continue;
++					}
++
 +					if (mptscsih_doDv(hd, 0, id) == 1) {
  						/* Untagged device was busy, try again
  						 */
@@ -31494,7 +26927,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	spin_unlock_irqrestore(&dvtaskQ_lock, flags);
 -}
 -
--
+ 
 -/* Post command on the PendingMF to the FW.
 - */
 -void
@@ -31509,23 +26942,23 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -	spin_lock_irqsave(&ioc->PendingMFlock, flags);
 -	if ((mf=ioc->PendingMF) == NULL) {
 -		spin_unlock_irqrestore(&ioc->PendingMFlock, flags);
--		dpendprintk((MYIOC_s_INFO_FMT "%s: PendingMF is empty\n", 
+-		dpendprintk((MYIOC_s_INFO_FMT "%s: PendingMF is empty\n",
 -			ioc->name, __FUNCTION__));
 -		return;
 -	}
- 
+-
 -	mf = ioc->PendingMF;
 -	SCpnt = ioc->PendingSCpnt;
 -	ioc->PendingMF = NULL;
 -	spin_unlock_irqrestore(&ioc->PendingMFlock, flags);
 -
--	dpendprintk((MYIOC_s_INFO_FMT "mptscsih_post_PendingMF_command: mf=%p\n", 
+-	dpendprintk((MYIOC_s_INFO_FMT "mptscsih_post_PendingMF_command: mf=%p\n",
 -		ioc->name, mf));
 -	DBG_DUMP_PENDING_REQUEST_FRAME(ioc, mf)
 -
 -	hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
 -	req_idx = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx);
--	ioc->ScsiLookup[req_idx] = SCpnt;
+-	hd->ScsiLookup[req_idx] = SCpnt;
 -	mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
 +	return;
  }
@@ -31540,7 +26973,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -	struct inactive_raid_component_info *component_info;
  	int i;
 -	int rc = 0;
- 
+-
 -	if (!ioc->raid_data.pIocPg3)
 -		goto out;
 -	for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
@@ -31550,7 +26983,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -			goto out;
 -		}
 -	}
--	
+ 
 -	/*
 -	 * Check inactive list for matching phys disks
 -	 */
@@ -31577,7 +27010,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  }
  
  /* Write SDP1 if no QAS has been enabled
-@@ -5140,36 +4927,32 @@
+@@ -5039,37 +4927,32 @@ mptscsih_is_phys_disk(MPT_ADAPTER *ioc, 
  static void
  mptscsih_qas_check(MPT_SCSI_HOST *hd, int id)
  {
@@ -31596,19 +27029,20 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			continue;
  
 -		pTarget = pMptTarget->Target[ii];
-+		pTarget = hd->Targets[ii];
- 
+-
 -		if (pTarget) {
 -			if (!pTarget->raidVolume) {
 -				if ((pTarget->negoFlags & ioc->spi_data.noQas) == 0) {
 -					pTarget->negoFlags |= ioc->spi_data.noQas;
 -					dnegoprintk(("mptscsih_qas_check: writeSDP1: id=%d negoFlags=%d\n", ii, pTarget->negoFlags));
--					mpt_writeSDP1(ioc, 0, ii, MPT_SCSICFG_USE_NVRAM);
--				}
+-		      mpt_writeSDP1(ioc, 0, ii, MPT_SCSICFG_USE_NVRAM);
+-						}
 -			} else {
 -				if (mptscsih_is_phys_disk(ioc, 0, ii) == 1) {
 -					dnegoprintk(("mptscsih_qas_check: is_phys_disk writeSDP1: id=%d SCSICFG_USE_NVRAM\n", ii));
--					mpt_writeSDP1(ioc, 0, ii, MPT_SCSICFG_USE_NVRAM);
+-				      mpt_writeSDP1(ioc, 0, ii, MPT_SCSICFG_USE_NVRAM);
++		pTarget = hd->Targets[ii];
+ 
 -				}
 +		if (pTarget && (!pTarget->raidVolume)) {
 +			if ((pTarget->negoFlags & hd->ioc->spi_data.noQas) == 0) {
@@ -31627,7 +27061,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  }
  
  
-@@ -5194,16 +4977,15 @@
+@@ -5094,16 +4977,15 @@ mptscsih_qas_check(MPT_SCSI_HOST *hd, in
   *	Return: None.
   */
  static int
@@ -31646,7 +27080,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	dma_addr_t		 dvbuf_dma = -1;
  	dma_addr_t		 buf1_dma = -1;
  	dma_addr_t		 buf2_dma = -1;
-@@ -5227,7 +5009,7 @@
+@@ -5127,7 +5009,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus
  	char			 firstPass = 1;
  	char			 doFallback = 0;
  	char			 readPage0;
@@ -31655,20 +27089,22 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	char			 inq0 = 0;
  
  	if (ioc->spi_data.sdp1length == 0)
-@@ -5242,10 +5024,9 @@
+@@ -5141,10 +5023,12 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus
+ 	 */
  	if (id == ioc->pfacts[0].PortSCSIID)
  		return 0;
+-ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_DV_IN_PROGRESS;
  
--	ioc->spi_data.dvStatus[id] |= MPT_SCSICFG_DV_IN_PROGRESS;
--
  	lun = 0;
--	ddvprintk((MYIOC_s_INFO_FMT
+-	ddvprintk((MYIOC_s_INFO_FMT "DV Started: bus=%d id=%d dv @ %p\n",ioc->name, bus, id, &dv));
 +	bus = (u8) bus_number;
 +	ddvtprintk((MYIOC_s_NOTE_FMT
- 			"DV Started: bus=%d id=%d dv @ %p\n",
- 			ioc->name, bus, id, &dv));
++			"DV Started: bus=%d id=%d dv @ %p\n",
++			ioc->name, bus, id, &dv));
  
-@@ -5270,8 +5051,7 @@
+ 	/* Prep DV structure
+ 	 */
+@@ -5167,8 +5051,7 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  	iocmd.physDiskNum = -1;
  	iocmd.rsvd = iocmd.rsvd2 = 0;
  
@@ -31678,34 +27114,34 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	/* Use tagged commands if possible.
  	 */
-@@ -5279,12 +5059,12 @@
+@@ -5176,12 +5059,12 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  		if (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)
  			iocmd.flags |= MPT_ICFLAG_TAGGED_CMD;
  		else {
 -			if (ioc->facts.FWVersion.Word < 0x01000600)
--				goto doDv_done;
+-				  goto doDv_done;
 +			if (hd->ioc->facts.FWVersion.Word < 0x01000600)
 +				return 0;
  
 -			if ((ioc->facts.FWVersion.Word >= 0x01010000) &&
 -				(ioc->facts.FWVersion.Word < 0x01010B00))
--				goto doDv_done;
+-			         goto doDv_done;
 +			if ((hd->ioc->facts.FWVersion.Word >= 0x01010000) &&
 +				(hd->ioc->facts.FWVersion.Word < 0x01010B00))
 +				return 0;
  		}
  	}
  
-@@ -5314,7 +5094,7 @@
+@@ -5211,7 +5094,7 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  
  	pDvBuf = pci_alloc_consistent(ioc->pcidev, dv_alloc, &dvbuf_dma);
  	if (pDvBuf == NULL)
--		goto doDv_done;
+-                goto doDv_done;
 +		return 0;
  
  	sz = 0;
  	pbuf1 = (u8 *)pDvBuf;
-@@ -5340,7 +5120,7 @@
+@@ -5237,7 +5120,7 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  	/* Skip this ID? Set cfg.cfghdr.hdr to force config page write
  	 */
  	{
@@ -31714,7 +27150,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		if (pspi_data->nvram && (pspi_data->nvram[id] != MPT_HOST_NVRAM_INVALID)) {
  			/* Set the factor from nvram */
  			nfactor = (pspi_data->nvram[id] & MPT_NVRAM_SYNC_MASK) >> 8;
-@@ -5350,7 +5130,7 @@
+@@ -5247,7 +5130,7 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  			if (!(pspi_data->nvram[id] & MPT_NVRAM_ID_SCAN_ENABLE) ||
  				(pspi_data->PortFlags == MPI_SCSIPORTPAGE2_PORT_FLAGS_OFF_DV) ) {
  
@@ -31723,7 +27159,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					ioc->name, bus, id, lun));
  
  				dv.cmd = MPT_SET_MAX;
-@@ -5363,7 +5143,7 @@
+@@ -5260,7 +5143,7 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  				cfg.physAddr = cfg1_dma_addr;
  				cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
  				cfg.dir = 1;
@@ -31732,7 +27168,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				goto target_done;
  			}
  		}
-@@ -5398,7 +5178,7 @@
+@@ -5295,7 +5178,7 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  	/* RAID Volume ID's may double for a physical device. If RAID but
  	 * not a physical ID as well, skip DV.
  	 */
@@ -31741,10 +27177,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		goto target_done;
  
  
-@@ -5415,9 +5195,8 @@
+@@ -5312,10 +5195,8 @@ ioc->spi_data.dvStatus[id] |= MPT_SCSICF
  	readPage0 = 0;
  	sz = SCSI_MAX_INQUIRY_BYTES;
  	rc = MPT_SCANDV_GOOD;
+-
 -start_DV:
  	while (1) {
 -		ddvprintk((MYIOC_s_INFO_FMT "DV: Start Basic test on id=%d\n", ioc->name, id));
@@ -31752,7 +27189,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		retcode = 0;
  		dv.cmd = MPT_SET_MIN;
  		mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data);
-@@ -5426,7 +5205,7 @@
+@@ -5324,7 +5205,7 @@ start_DV:
  		cfg.physAddr = cfg1_dma_addr;
  		cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
  		cfg.dir = 1;
@@ -31761,7 +27198,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			goto target_done;
  
  		/* Wide - narrow - wide workaround case
-@@ -5435,15 +5214,15 @@
+@@ -5333,9 +5214,9 @@ start_DV:
  			/* Send an untagged command to reset disk Qs corrupted
  			 * when a parity error occurs on a Request Sense.
  			 */
@@ -31774,23 +27211,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  				iocmd.cmd = REQUEST_SENSE;
  				iocmd.data_dma = buf1_dma;
- 				iocmd.data = pbuf1;
- 				iocmd.size = 0x12;
--				if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+				if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 					goto target_done;
- 				else {
- 					if (hd->pLocal == NULL)
-@@ -5464,7 +5243,7 @@
- 		iocmd.data = pbuf1;
- 		iocmd.size = sz;
- 		memset(pbuf1, 0x00, sz);
--		if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+		if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 			goto target_done;
- 		else {
- 			if (hd->pLocal == NULL)
-@@ -5502,13 +5281,19 @@
+@@ -5400,6 +5281,12 @@ start_DV:
  		 * if PROCESSOR, quit DV.
  		 */
  		if (inq0 == TYPE_PROCESSOR) {
@@ -31803,26 +27224,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			goto target_done;
  		}
  
- 		if (inq0 > 0x08)
- 			goto target_done;
- 
--		if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+		if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 			goto target_done;
- 
- 		if (sz == 0x40) {
-@@ -5528,8 +5313,8 @@
+@@ -5426,8 +5313,8 @@ start_DV:
  
  				if ((pbuf1[56] & 0x02) == 0) {
  					pTarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
 -					ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS;
--					ddvprintk((MYIOC_s_INFO_FMT 
+-					ddvprintk((MYIOC_s_INFO_FMT
 +					hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS;
 +					ddvprintk((MYIOC_s_NOTE_FMT 
  					    "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n", 
  					    ioc->name, id, pbuf1[56]));
  				}
-@@ -5542,7 +5327,7 @@
+@@ -5440,7 +5327,7 @@ start_DV:
  			dv.cmd = MPT_SET_MAX;
  
  		mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data);
@@ -31831,16 +27244,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			goto target_done;
  
  		if ((!dv.now.width) && (!dv.now.offset))
-@@ -5553,7 +5338,7 @@
- 		iocmd.data = pbuf2;
- 		iocmd.size = sz;
- 		memset(pbuf2, 0x00, sz);
--		if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+		if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 			goto target_done;
- 		else if (hd->pLocal == NULL)
- 			goto target_done;
-@@ -5575,7 +5360,7 @@
+@@ -5473,7 +5360,7 @@ start_DV:
  					cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
  					cfg.dir = 0;
  
@@ -31849,10 +27253,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  						goto target_done;
  
  					sdp0_info = le32_to_cpu(pcfg0Data->Information) & 0x0E;
-@@ -5606,9 +5391,20 @@
+@@ -5504,7 +5391,15 @@ start_DV:
  						if (!firstPass)
  							doFallback = 1;
  					} else {
+-
 +						ddvprintk((MYIOC_s_NOTE_FMT
 +						    "DV:Inquiry compared id=%d, calling initTarget\n", ioc->name, id));
 +						hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE;
@@ -31865,12 +27270,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  						break;	/* test complete */
  					}
  				}
-+
-+
- 			} else if (rc == MPT_SCANDV_ISSUE_SENSE)
- 				doFallback = 1;	/* set fallback flag */
- 			else if ((rc == MPT_SCANDV_DID_RESET) ||
-@@ -5621,7 +5417,7 @@
+@@ -5522,7 +5417,7 @@ start_DV:
  			firstPass = 0;
  		}
  	}
@@ -31879,7 +27279,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  	if (ioc->spi_data.mpt_dv == 0)
  		goto target_done;
-@@ -5633,10 +5429,10 @@
+@@ -5534,10 +5429,10 @@ start_DV:
  	if (inq0 != 0)
  		goto target_done;
  
@@ -31892,16 +27292,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			ioc->name, bus, id, lun, ioc->spi_data.PortFlags));
  		goto target_done;
  	}
-@@ -5660,7 +5456,7 @@
- 	iocmd.size = 0;
- 	notDone = 1;
- 	while (notDone) {
--		if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+		if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 			goto target_done;
- 
- 		if (hd->pLocal == NULL)
-@@ -5673,7 +5469,7 @@
+@@ -5574,7 +5469,7 @@ start_DV:
  			u8 skey = hd->pLocal->sense[2] & 0x0F;
  			u8 asc = hd->pLocal->sense[12];
  			u8 ascq = hd->pLocal->sense[13];
@@ -31910,16 +27301,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				"SenseKey:ASC:ASCQ = (%x:%02x:%02x)\n",
  				ioc->name, skey, asc, ascq));
  
-@@ -5722,7 +5518,7 @@
- 			if (notDone > 8)
- 				goto target_done;
- 
--			if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+			if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 				goto target_done;
- 			else if (hd->pLocal == NULL)
- 				goto target_done;
-@@ -5745,7 +5541,7 @@
+@@ -5646,7 +5541,7 @@ start_DV:
  					u8 skey = hd->pLocal->sense[2] & 0x0F;
  					u8 asc = hd->pLocal->sense[12];
  					u8 ascq = hd->pLocal->sense[13];
@@ -31928,53 +27310,19 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  						"SenseKey:ASC:ASCQ = (%x:%02x:%02x)\n",
  						ioc->name, skey, asc, ascq));
  					if (skey == ILLEGAL_REQUEST) {
-@@ -5764,10 +5560,6 @@
+@@ -5665,11 +5560,6 @@ start_DV:
  							ioc->name));
  						goto target_done;
  					}
--				} else if (rc == MPT_SCANDV_FALLBACK) {
--					doFallback = 1;	/* set fallback flag */
--					notDone++;
--					goto start_DV;
+-                               } else if (rc == MPT_SCANDV_FALLBACK) {
+-                                       doFallback = 1; /* set fallback flag */
+-                                       notDone++;
+-                                       goto start_DV;
+-
  				} else {
  					/* All other errors are fatal
  					 */
-@@ -5815,14 +5607,14 @@
- 			iocmd.data_dma = -1;
- 			iocmd.data = NULL;
- 			iocmd.size = 0;
--			if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+			if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 				goto target_done;
- 
- 			iocmd.cmd = RELEASE;
- 			iocmd.data_dma = -1;
- 			iocmd.data = NULL;
- 			iocmd.size = 0;
--			if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+			if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 				goto target_done;
- 			else if (hd->pLocal == NULL)
- 				goto target_done;
-@@ -5847,7 +5639,7 @@
- 			iocmd.data_dma = -1;
- 			iocmd.data = NULL;
- 			iocmd.size = 0;
--			if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+			if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 				goto target_done;
- 			else if (hd->pLocal == NULL)
- 				goto target_done;
-@@ -5890,7 +5682,7 @@
- 		iocmd.data_dma = buf1_dma;
- 		iocmd.data = pbuf1;
- 		iocmd.size = sz;
--		if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+		if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 			goto target_done;
- 		else if (hd->pLocal == NULL)
- 			goto target_done;
-@@ -5910,7 +5702,7 @@
+@@ -5812,7 +5702,7 @@ skip_Reserve:
  					dv.cmd = MPT_FALLBACK;
  					mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data);
  
@@ -31983,7 +27331,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  						goto target_done;
  
  					if ((!dv.now.width) && (!dv.now.offset))
-@@ -5924,7 +5716,7 @@
+@@ -5826,7 +5716,7 @@ skip_Reserve:
  				/* Restart data test if UA, else quit.
  				 */
  				u8 skey = hd->pLocal->sense[2] & 0x0F;
@@ -31992,16 +27340,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					"SenseKey:ASC:ASCQ = (%x:%02x:%02x)\n", ioc->name, skey,
  					hd->pLocal->sense[12], hd->pLocal->sense[13]));
  				if (skey == UNIT_ATTENTION) {
-@@ -5952,7 +5744,7 @@
- 		iocmd.data_dma = buf2_dma;
- 		iocmd.data = pbuf2;
- 		iocmd.size = sz;
--		if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+		if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 			goto target_done;
- 		else if (hd->pLocal == NULL)
- 			goto target_done;
-@@ -5989,7 +5781,7 @@
+@@ -5891,7 +5781,7 @@ skip_Reserve:
  						dv.cmd = MPT_FALLBACK;
  						mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data);
  
@@ -32010,7 +27349,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  							goto target_done;
  
  						if ((!dv.now.width) && (!dv.now.offset))
-@@ -6007,7 +5799,7 @@
+@@ -5909,7 +5799,7 @@ skip_Reserve:
  				dv.cmd = MPT_FALLBACK;
  				mptscsih_dv_parms(hd, &dv, (void *)pcfg1Data);
  
@@ -32019,7 +27358,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					 goto target_done;
  
  				if ((!dv.now.width) && (!dv.now.offset))
-@@ -6020,7 +5812,7 @@
+@@ -5922,7 +5812,7 @@ skip_Reserve:
  				/* Restart data test if UA, else quit.
  				 */
  				u8 skey = hd->pLocal->sense[2] & 0x0F;
@@ -32028,16 +27367,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  					"SenseKey:ASC:ASCQ = (%x:%02x:%02x)\n", ioc->name, skey,
  					hd->pLocal->sense[12], hd->pLocal->sense[13]));
  				if (skey == UNIT_ATTENTION) {
-@@ -6043,7 +5835,7 @@
- 		iocmd.data_dma = -1;
- 		iocmd.data = NULL;
- 		iocmd.size = 0;
--		if (mptscsih_do_DVcmd(hd, &iocmd) < 0)
-+		if (mptscsih_do_cmd(hd, &iocmd) < 0)
- 			printk(MYIOC_s_INFO_FMT "DV: Release failed. id %d",
- 					ioc->name, id);
- 		else if (hd->pLocal) {
-@@ -6062,8 +5854,8 @@
+@@ -5964,8 +5854,8 @@ target_done:
  		/* If disk, not U320, disable QAS
  		 */
  		if ((inq0 == 0) && (dv.now.factor > MPT_ULTRA320)) {
@@ -32048,7 +27378,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			    "noQas set due to id=%d has factor=%x\n", ioc->name, id, dv.now.factor));
  		}
  
-@@ -6078,7 +5870,7 @@
+@@ -5980,7 +5870,7 @@ target_done:
  		cfg.physAddr = cfg1_dma_addr;
  		cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
  		cfg.dir = 1;
@@ -32057,7 +27387,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		 */
  	}
  
-@@ -6089,20 +5881,13 @@
+@@ -5991,18 +5881,13 @@ target_done:
  			ddvprintk((MYIOC_s_ERR_FMT "RAID Enable FAILED!\n", ioc->name));
  	}
  
@@ -32067,20 +27397,18 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	if (pDvBuf)
  		pci_free_consistent(ioc->pcidev, dv_alloc, pDvBuf, dvbuf_dma);
  
--	ddvprintk((MYIOC_s_WARN_FMT "DV Done id=%d retcode=%x\n",
--			ioc->name, id, retcode));
--
--	ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_IN_PROGRESS);
--	/* Post an IO that was pended while
--	 * DV was running.
--	 */
--	mptscsih_post_PendingMF_command(ioc);
+-	ddvprintk((MYIOC_s_WARN_FMT "DV Done id=%d\n",ioc->name, id));
+-       ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_IN_PROGRESS);
+-       /* Post an IO that was pended while
+-        * DV was running.
+-        */
+-       mptscsih_post_PendingMF_command(ioc);
 +	ddvtprintk((MYIOC_s_INFO_FMT "DV Done id=%d\n",
 +			ioc->name, id));
  
  	return retcode;
  }
-@@ -6117,8 +5902,6 @@
+@@ -6017,8 +5902,6 @@ doDv_done:
  static void
  mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
  {
@@ -32089,7 +27417,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  	VirtDevice		*pTarget;
  	SCSIDevicePage0_t	*pPage0;
  	SCSIDevicePage1_t	*pPage1;
-@@ -6132,48 +5915,49 @@
+@@ -6032,48 +5915,49 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  
  	switch (cmd) {
  	case MPT_GET_NVRAM_VALS:
@@ -32170,7 +27498,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  		/* Check Consistency */
  		if (offset && (factor < MPT_ULTRA2) && !width)
-@@ -6183,13 +5967,13 @@
+@@ -6083,13 +5967,13 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  		dv->max.offset = offset;
  		dv->max.factor = factor;
  		dv->max.flags = negoFlags;
@@ -32187,7 +27515,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		/* Update tmax values with those from Device Page 0.*/
  		pPage0 = (SCSIDevicePage0_t *) pPage;
  		if (pPage0) {
-@@ -6203,10 +5987,12 @@
+@@ -6103,10 +5987,12 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  		dv->now.offset = dv->max.offset;
  		dv->now.factor = dv->max.factor;
  		ddvprintk(("id=%d width=%d factor=%x offset=%x negoFlags=%x\n",
@@ -32201,11 +27529,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		/* Set current to the max values. Update the config page.*/
  		dv->now.width = dv->max.width;
  		dv->now.offset = dv->max.offset;
-@@ -6215,18 +6001,22 @@
+@@ -6115,18 +6001,22 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  
  		pPage1 = (SCSIDevicePage1_t *)pPage;
  		if (pPage1) {
--			mpt_setSDP1parameters (dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags, 
+-			mpt_setSDP1parameters (dv->now.width, dv->now.factor, dv->now.offset, dv->now.flags,
 -				&val, &configuration);
 +			mptscsih_setDevicePage1Flags (dv->now.width, dv->now.factor,
 +				dv->now.offset, &val, &configuration, dv->now.flags);
@@ -32228,7 +27556,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  		/* Set page to asynchronous and narrow
  		 * Do not update now, breaks fallback routine. */
  		width = MPT_NARROW;
-@@ -6236,20 +6026,22 @@
+@@ -6136,20 +6026,22 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  
  		pPage1 = (SCSIDevicePage1_t *)pPage;
  		if (pPage1) {
@@ -32257,7 +27585,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  				dv->now.factor, dv->now.width));
  		width = dv->now.width;
  		offset = dv->now.offset;
-@@ -6312,32 +6104,31 @@
+@@ -6212,32 +6104,31 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  
  		pPage1 = (SCSIDevicePage1_t *)pPage;
  		if (pPage1) {
@@ -32283,7 +27611,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
 -		ddvprintk((MYIOC_s_INFO_FMT
 -			"Saving to pTarget: "
 -			"id=%d width=%x factor=%x offset=%d negoFlags=%x\n",
--				ioc->name, id, dv->now.width, dv->now.factor, 
+-				ioc->name, id, dv->now.width, dv->now.factor,
 -				dv->now.offset, dv->now.flags));
 +		ddvprintk((MYIOC_s_NOTE_FMT
 +			"Saving to Target structure: ", hd->ioc->name));
@@ -32301,7 +27629,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			pTarget->maxWidth = dv->now.width;
  			pTarget->maxOffset = dv->now.offset;
  			pTarget->minSyncFactor = dv->now.factor;
-@@ -6346,8 +6137,8 @@
+@@ -6246,8 +6137,8 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  			/* Preserv all flags, use
  			 * read-modify-write algorithm
  			 */
@@ -32312,7 +27640,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  
  				if (dv->now.width)
  					data &= ~MPT_NVRAM_WIDE_DISABLE;
-@@ -6360,7 +6151,7 @@
+@@ -6260,14 +6151,13 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVP
  				data &= ~MPT_NVRAM_SYNC_MASK;
  				data |= (dv->now.factor << MPT_NVRAM_SYNC_SHIFT) & MPT_NVRAM_SYNC_MASK;
  
@@ -32321,37 +27649,35 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsi.c
  			}
  		}
  		break;
-@@ -6521,15 +6312,11 @@
+ 	}
+ }
+ 
+-
+ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+ /*	mptscsih_fillbuf - fill a buffer with a special data pattern
+  *		cleanup. For bus scan only.
+@@ -6422,11 +6312,10 @@ EXPORT_SYMBOL(mptscsih_taskmgmt_complete
  EXPORT_SYMBOL(mptscsih_scandv_complete);
  EXPORT_SYMBOL(mptscsih_event_process);
  EXPORT_SYMBOL(mptscsih_ioc_reset);
--EXPORT_SYMBOL(mptscsih_store_queue_depth);
 -EXPORT_SYMBOL(mptscsih_InternalCmdTimer_expired);
--EXPORT_SYMBOL(mptscsih_DVCmdTimer_expired);
 +EXPORT_SYMBOL(mptscsih_timer_expired);
  EXPORT_SYMBOL(mptscsih_readFCDevicePage0);
  EXPORT_SYMBOL(mptscsih_change_queue_depth);
  EXPORT_SYMBOL(mptscsih_TMHandler);
 -EXPORT_SYMBOL(mptscsih_TM_timeout);
--EXPORT_SYMBOL(mptscsih_do_cmd);
--EXPORT_SYMBOL(mptscsih_IssueTaskMgmt);
  EXPORT_SYMBOL(mptscsih_sanity_check);
  EXPORT_SYMBOL(mptscsih_poll);
-+EXPORT_SYMBOL(mptscsih_do_cmd);
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsih.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptscsih.h	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptscsih.h	2009-05-11 23:24:42.000000000 -0600
-@@ -3,10 +3,10 @@
-  *      High performance SCSI / Fibre Channel SCSI Host device driver.
-  *      For use with PCI chip/adapter(s):
+ EXPORT_SYMBOL(mptscsih_do_cmd);
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptscsih.h linux-2.6.9-55.0.12/drivers/message/fusion/mptscsih.h
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptscsih.h	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptscsih.h	2007-11-02 09:10:23.000000000 +0100
+@@ -5,8 +5,8 @@
   *          LSIFC9xx/LSI409xx Fibre Channel
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
@@ -32371,82 +27697,42 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptscsih.h
 -#define MPT_SCANDV_BUSY			(0x00000040)
 -
 -//#define MPT_SCSI_CMD_PER_DEV_HIGH	64
--#define MPT_SCSI_CMD_PER_DEV_HIGH	48
+-#define MPT_SCSI_CMD_PER_DEV_HIGH      48
 +#define MPT_SCSI_CMD_PER_DEV_HIGH	64
  #define MPT_SCSI_CMD_PER_DEV_LOW	32
  
  #define MPT_SCSI_CMD_PER_LUN		7
-@@ -108,7 +98,11 @@
- 
- extern void mptscsih_remove(struct pci_dev *);
- // This was changed in the 2.6.13 kernel
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- extern void mptscsih_shutdown(struct device *);
-+#else
-+extern void mptscsih_shutdown(struct pci_dev *);
-+#endif
- #ifdef CONFIG_PM
- extern int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state);
- extern int mptscsih_resume(struct pci_dev *pdev);
-@@ -118,7 +112,7 @@
- extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *));
- extern int mptscsih_slave_alloc(struct scsi_device *device);
- extern void mptscsih_slave_destroy(struct scsi_device *device);
--extern int mptscsih_slave_configure(struct scsi_device *device, int queue_depth);
-+extern int mptscsih_slave_configure(struct scsi_device *device);
- extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
- extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
- extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
-@@ -129,9 +123,7 @@
+@@ -133,7 +123,7 @@ extern int mptscsih_taskmgmt_complete(MP
  extern int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
  extern int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
  extern int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
--extern ssize_t mptscsih_store_queue_depth(struct device *dev, const char *buf, size_t count);
 -extern void mptscsih_InternalCmdTimer_expired(unsigned long data);
--extern void mptscsih_DVCmdTimer_expired(unsigned long data);
 +extern void mptscsih_timer_expired(unsigned long data);
  extern int mptscsih_readFCDevicePage0(MPT_ADAPTER *ioc, u8 bus, u8 targetId, pFCDevicePage0_t fcDevicePage);
  extern void mptscsih_hot_plug_worker_thread(void * arg);
  extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 target, u8 lun, int ctx2abort, ulong timeout);
-@@ -139,4 +131,4 @@
+@@ -141,4 +131,4 @@ extern int mptscsih_change_queue_depth(s
  extern int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd);
  extern int mptscsih_sanity_check(struct scsi_device *sdev);
  extern void mptscsih_poll(struct scsi_device *sdev);
--extern int	 mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, u8 lun, int ctx2abort, ulong timeout);
+-extern void scsi_print_command(struct scsi_cmnd *cmd);
 +extern void scsi_print_command(struct scsi_cmnd *cmd);
-\ No newline at end of file
-Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/message/fusion/mptspi.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c	2009-05-11 23:24:42.000000000 -0600
-@@ -1,10 +1,10 @@
- /*
-  *  linux/drivers/message/fusion/mptspi.c
-- *      For use with LSI PCI chip/adapter(s)
-- *      running LSI Fusion MPT (Message Passing Technology) firmware.
-+ *      For use with LSI Logic PCI chip/adapter(s)
-+ *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
+\ Pas de fin de ligne à la fin du fichier.
+diff -Nrup linux-2.6.9-67.0.1/drivers/message/fusion/mptspi.c linux-2.6.9-55.0.12/drivers/message/fusion/mptspi.c
+--- linux-2.6.9-67.0.1/drivers/message/fusion/mptspi.c	2007-12-21 11:40:54.000000000 +0100
++++ linux-2.6.9-55.0.12/drivers/message/fusion/mptspi.c	2007-11-02 09:10:23.000000000 +0100
+@@ -3,8 +3,8 @@
+  *      For use with LSI Logic PCI chip/adapter(s)
+  *      running LSI Logic Fusion MPT (Message Passing Technology) firmware.
   *
-- *  Copyright (c) 1999-2007 LSI Corporation
-- *  (mailto:DL-MPTFusionLinux at lsi.com)
+- *  Copyright (c) 1999-2007 LSI Logic Corporation
+- *  (mailto:mpt_linux_developer at lsi.com)
 + *  Copyright (c) 1999-2005 LSI Logic Corporation
 + *  (mailto:mpt_linux_developer at lsil.com)
   *
   */
  /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
-@@ -44,10 +44,8 @@
- */
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- 
--#include <linux/config.h>
--#include <linux/version.h>
--#include <linux/kernel.h>
- #include <linux/module.h>
-+#include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/errno.h>
- #include <linux/kdev_t.h>
-@@ -75,7 +73,6 @@
+@@ -73,7 +73,6 @@
  MODULE_AUTHOR(MODULEAUTHOR);
  MODULE_DESCRIPTION(my_NAME);
  MODULE_LICENSE("GPL");
@@ -32454,48 +27740,11 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
  
  /* Command line args */
  #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
-@@ -105,29 +102,10 @@
- module_param(mpt_pq_filter, int, 0);
- MODULE_PARM_DESC(mpt_pq_filter, " Enable peripheral qualifier filter: enable=1  (default=0)");
- 
--static int mptspi_device_queue_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
--module_param(mptspi_device_queue_depth, int, 0);
--MODULE_PARM_DESC(mptspi_device_queue_depth, " Max Device Queue Depth (default=" __MODULE_STRING(MPT_SCSI_CMD_PER_DEV_HIGH) ")");
--
--static int mptspi_slave_configure(struct scsi_device *sdev);
--
- static int	mptspiDoneCtx = -1;
- static int	mptspiTaskCtx = -1;
- static int	mptspiInternalCtx = -1; /* Used only for internal commands */
- 
--static struct device_attribute mptspi_queue_depth_attr = {
--	.attr = {
--		.name = 	"queue_depth",
--		.mode =		S_IWUSR,
--	},
--	.store = mptscsih_store_queue_depth,
--};
--
--static struct device_attribute *mptspi_dev_attrs[] = {
--	&mptspi_queue_depth_attr,
--	NULL,
--};
--
- /* Show the ioc state for this card */
- static ssize_t
- mptspi_show_iocstate(struct class_device *class_dev, char *buf)
-@@ -161,21 +139,22 @@
- 	.info				= mptscsih_info,
- 	.queuecommand			= mptscsih_qcmd,
- 	.slave_alloc			= mptscsih_slave_alloc,
--	.slave_configure		= mptspi_slave_configure,
-+	.slave_configure		= mptscsih_slave_configure,
- 	.slave_destroy			= mptscsih_slave_destroy,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11))
-+	.change_queue_depth 		= mptscsih_change_queue_depth,
-+#endif
+@@ -146,13 +145,12 @@ static struct scsi_host_template mptspi_
+ 	.change_queue_depth 		= mptscsih_change_queue_depth,
+ #endif
  	.eh_abort_handler		= mptscsih_abort,
--	.eh_device_reset_handler	= mptscsih_dev_reset,
+-        .eh_device_reset_handler        = mptscsih_dev_reset,
  	.eh_bus_reset_handler		= mptscsih_bus_reset,
  	.eh_host_reset_handler		= mptscsih_host_reset,
  	.bios_param			= mptscsih_bios_param,
@@ -32506,48 +27755,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
  	.max_sectors			= 8192,
  	.cmd_per_lun			= 7,
  	.use_clustering			= ENABLE_CLUSTERING,
- 	.shost_attrs			= mptspi_host_attrs,
--	.sdev_attrs			= mptspi_dev_attrs,
- 	.dump_sanity_check		= mptscsih_sanity_check,
- 	.dump_poll			= mptscsih_poll,
- };
-@@ -193,35 +172,6 @@
- };
- MODULE_DEVICE_TABLE(pci, mptspi_pci_table);
- 
--
--/**
-- * mptspi_slave_configure
-- *
-- *
-- * @sdev
-- *
-- **/
--static int
--mptspi_slave_configure(struct scsi_device *sdev)
--{
--#ifdef MPT_DEBUG_INIT
--	MPT_SCSI_HOST	*hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
--	MPT_ADAPTER *ioc = hd->ioc;
--	int		channel;
--	int		id;
--
--	channel = sdev->channel;
--	id = sdev->id;
--
--	dinitprintk((MYIOC_s_INFO_FMT
--		"%s: id=%d channel=%d sdev->queue_depth=%d mptspi_device_queue_depth=%d\n",
--		ioc->name, __FUNCTION__, id, channel, sdev->queue_depth,
--		mptspi_device_queue_depth));
--#endif
--
--	return mptscsih_slave_configure(sdev, mptspi_device_queue_depth);
--}
--
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
- /*
-@@ -239,6 +189,8 @@
+@@ -191,6 +189,8 @@ mptspi_probe(struct pci_dev *pdev, const
  	MPT_ADAPTER 		*ioc;
  	unsigned long		 flags;
  	int			 sz, ii;
@@ -32556,7 +27764,7 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
  	int			 ioc_cap;
  	u8			*mem;
  	int			error=0;
-@@ -317,7 +269,7 @@
+@@ -269,7 +269,7 @@ mptspi_probe(struct pci_dev *pdev, const
  		ioc->name, mpt_can_queue, ioc->req_depth,
  		sh->can_queue));
  
@@ -32565,12 +27773,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
  
  	sh->max_lun = MPT_LAST_LUN + 1;
  	sh->max_channel = 0;
-@@ -326,11 +278,42 @@
+@@ -278,7 +278,36 @@ mptspi_probe(struct pci_dev *pdev, const
  	/* Required entry.
  	 */
  	sh->unique_id = ioc->id;
 -	sh->sg_tablesize = ioc->sg_tablesize;
- 
++
 +	/* Verify that we won't exceed the maximum
 +	 * number of chain buffers
 +	 * We can optimize:  ZZ = req_sz/sizeof(SGE)
@@ -32600,25 +27808,12 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
 +		  ioc->name, numSGE, sh->sg_tablesize));
 +		sh->sg_tablesize = numSGE;
 +	}
-+
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	/* Set the pci device pointer in Scsi_Host structure.
- 	 */
- 	scsi_set_device(sh, &ioc->pcidev->dev);
-+#endif
- 
- 	spin_unlock_irqrestore(&ioc->FreeQlock, flags);
- 
-@@ -348,34 +331,34 @@
- 	}
- 
- 	memset(mem, 0, sz);
--	ioc->ScsiLookup = (struct scsi_cmnd **) mem;
-+	hd->ScsiLookup = (struct scsi_cmnd **) mem;
  
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
+ 	/* Set the pci device pointer in Scsi_Host structure.
+@@ -307,29 +336,29 @@ mptspi_probe(struct pci_dev *pdev, const
  	dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p, sz=%d\n",
--		 ioc->name, ioc->ScsiLookup, sz));
-+		 ioc->name, hd->ScsiLookup, sz));
+ 		 ioc->name, hd->ScsiLookup, sz));
  
 -	for (ii=0; ii < ioc->NumberOfBuses; ii++) {
 -		/* Allocate memory for the device structures.
@@ -32662,35 +27857,36 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
  	hd->abortSCpnt = NULL;
  
  	/* Clear the pointer used to store
-@@ -385,22 +368,13 @@
+@@ -339,21 +368,16 @@ mptspi_probe(struct pci_dev *pdev, const
  	 */
  	hd->cmdPtr = NULL;
  
--	/* Initialize this IOC's timers
+-	/* Initialize this IOC's  timers
 +	/* Initialize this SCSI Hosts' timers
  	 * To use, set the timer expires field
--	 * and add_timer.  Used for internally
--	 * generated commands.
+-	 * and add_timer.Used for internally
+-         * generated commands.
 +	 * and add_timer
  	 */
--	init_timer(&hd->InternalCmdTimer);
--	hd->InternalCmdTimer.data = (unsigned long) hd;
--	hd->InternalCmdTimer.function = mptscsih_InternalCmdTimer_expired;
--
--	init_timer(&hd->DVCmdTimer);
--	hd->DVCmdTimer.data = (unsigned long) hd;
--	hd->DVCmdTimer.function = mptscsih_DVCmdTimer_expired;
+-       init_timer(&hd->InternalCmdTimer);
+-       hd->InternalCmdTimer.data = (unsigned long) hd;
+-       hd->InternalCmdTimer.function = mptscsih_InternalCmdTimer_expired;
 -
--	init_timer(&ioc->TMtimer);
--	ioc->TMtimer.data = (unsigned long) ioc;
--	ioc->TMtimer.function = mptscsih_TM_timeout;
+-       init_timer(&ioc->TMtimer);
+-       ioc->TMtimer.data = (unsigned long) ioc;
+-       ioc->TMtimer.function = mptscsih_TM_timeout;
 +	init_timer(&hd->timer);
 +	hd->timer.data = (unsigned long) hd;
 +	hd->timer.function = mptscsih_timer_expired;
  
- 	ioc->spi_data.Saf_Te = mpt_saf_te;
- 	hd->mpt_pq_filter = mpt_pq_filter;
-@@ -414,6 +388,7 @@
+-       ioc->spi_data.Saf_Te = mpt_saf_te;
+-       hd->mpt_pq_filter = mpt_pq_filter;
++	ioc->spi_data.Saf_Te = mpt_saf_te;
++	hd->mpt_pq_filter = mpt_pq_filter;
+ 
+ #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
+ 	if (ioc->spi_data.maxBusWidth > mpt_width)
+@@ -364,6 +388,7 @@ mptspi_probe(struct pci_dev *pdev, const
  		ioc->spi_data.maxSyncOffset = 0;
  	}
  	ioc->spi_data.mpt_dv = mpt_dv;
@@ -32698,24 +27894,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
  
  	ddvprintk((MYIOC_s_INFO_FMT
  		"dv %x width %x factor %x saf_te %x mpt_pq_filter %x\n",
-@@ -424,6 +399,7 @@
+@@ -374,7 +399,7 @@ mptspi_probe(struct pci_dev *pdev, const
  		mpt_saf_te,
  		mpt_pq_filter));
  #else
+-
 +	hd->negoNvram = MPT_SCSICFG_USE_NVRAM;
  	ddvprintk((MYIOC_s_INFO_FMT
  		"saf_te %x mpt_pq_filter %x\n",
  		ioc->name,
-@@ -437,18 +413,18 @@
+@@ -387,18 +412,18 @@ mptspi_probe(struct pci_dev *pdev, const
+ 		ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS;
  	else
  		ioc->spi_data.noQas = 0;
+-/* enable domain validation flags */
  
--	/* enable domain validation flags */
  	for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++)
- 		ioc->spi_data.dvStatus[ii] =
--		  (MPT_SCSICFG_NEGOTIATE | MPT_SCSICFG_DV_NOT_DONE);
+-ioc->spi_data.dvStatus[ii] =
++		ioc->spi_data.dvStatus[ii] =
 +		  MPT_SCSICFG_NEGOTIATE;
-+
+ 
+-(MPT_SCSICFG_NEGOTIATE | MPT_SCSICFG_DV_NOT_DONE);
 +	for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++)
 +		ioc->spi_data.dvStatus[ii] |=
 +		  MPT_SCSICFG_DV_NOT_DONE;
@@ -32723,43 +27922,27 @@ Index: linux-2.6.9-78.0.22/drivers/message/fusion/mptspi.c
  	init_waitqueue_head(&hd->scandv_waitq);
  	hd->scandv_wait_done = 0;
  	hd->last_queue_full = 0;
+-        init_waitqueue_head(&hd->TM_waitq);
+-        hd->TM_wait_done = 0;
  
--	init_waitqueue_head(&hd->TM_waitq);
--	hd->TM_wait_done = 0;
--
  	error = scsi_add_host (sh, &ioc->pcidev->dev);
  	if(error) {
- 		dprintk((KERN_ERR MYNAM
-@@ -463,10 +439,6 @@
+@@ -414,10 +439,6 @@ ioc->spi_data.dvStatus[ii] =
  		    0, 0, 0, 0, 5 /* 5 second timeout */);
  	}
  
--	dnegoprintk((MYIOC_s_WARN_FMT "%s: writeSDP1: ALL_IDS\n",
--		ioc->name, __FUNCTION__));
--	mpt_writeSDP1(ioc, 0, 0, MPT_SCSICFG_ALL_IDS);
+-       dnegoprintk((MYIOC_s_WARN_FMT "%s: writeSDP1: ALL_IDS\n",
+-               ioc->name, __FUNCTION__));
+-       mpt_writeSDP1(ioc, 0, 0, MPT_SCSICFG_ALL_IDS);
 -
  	scsi_scan_host(sh);
  	return 0;
  
-@@ -481,9 +453,13 @@
- 	.id_table	= mptspi_pci_table,
- 	.probe		= mptspi_probe,
- 	.remove		= __devexit_p(mptscsih_remove),
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13))
- 	.driver         = {
- 		.shutdown = mptscsih_shutdown,
-         },
-+#else
-+	.shutdown       = mptscsih_shutdown,
-+#endif
- #ifdef CONFIG_PM
- 	.suspend	= mptscsih_suspend,
- 	.resume		= mptscsih_resume,
-@@ -509,7 +485,7 @@
+@@ -464,7 +485,7 @@ mptspi_init(void)
  
  	if (mpt_event_register(mptspiDoneCtx, mptscsih_event_process) == 0) {
  		devtprintk((KERN_INFO MYNAM
--		   	": Registered for IOC event notifications mptspiDoneCtx=%08x\n", mptspiDoneCtx));
+-        ": Registered for IOC event notifications mptspiDoneCtx=%08x\n", mptspiDoneCtx));
 +		  ": Registered for IOC event notifications\n"));
  	}
  
diff --git a/lustre/kernel_patches/patches/mpt-fusion-max-sge.patch b/lustre/kernel_patches/patches/mpt-fusion-max-sge.patch
new file mode 100644
index 0000000..3fa6c48
--- /dev/null
+++ b/lustre/kernel_patches/patches/mpt-fusion-max-sge.patch
@@ -0,0 +1,31 @@
+diff -Nrup linux-2.6.18-92.1.10.orig/drivers/message/fusion/Kconfig linux-2.6.18-92.1.10/drivers/message/fusion/Kconfig
+--- linux-2.6.18-92.1.10.orig/drivers/message/fusion/Kconfig	2008-12-11 10:27:02.000000000 +1100
++++ linux-2.6.18-92.1.10/drivers/message/fusion/Kconfig	2008-12-11 10:28:42.000000000 +1100
+@@ -59,10 +59,10 @@ config FUSION_SAS
+ 	  LSISAS1078
+ 
+ config FUSION_MAX_SGE
+-	int "Maximum number of scatter gather entries (16 - 128)"
++	int "Maximum number of scatter gather entries (16 - 256)"
+ 	depends on FUSION
+-	default "128"
+-	range 16 128
++	default "256"
++	range 16 256
+ 	help
+ 	  This option allows you to specify the maximum number of scatter-
+ 	  gather entries per I/O. The driver default is 128, which matches
+diff -Nrup linux-2.6.18-92.1.10.orig/drivers/message/fusion/mptbase.h linux-2.6.18-92.1.10/drivers/message/fusion/mptbase.h
+--- linux-2.6.18-92.1.10.orig/drivers/message/fusion/mptbase.h	2008-12-11 10:27:03.000000000 +1100
++++ linux-2.6.18-92.1.10/drivers/message/fusion/mptbase.h	2008-12-11 10:30:55.000000000 +1100
+@@ -166,8 +166,8 @@
+ #ifdef  CONFIG_FUSION_MAX_SGE
+ #if     CONFIG_FUSION_MAX_SGE  < 16
+ #define MPT_SCSI_SG_DEPTH	16
+-#elif   CONFIG_FUSION_MAX_SGE  > 128
+-#define MPT_SCSI_SG_DEPTH	128
++#elif   CONFIG_FUSION_MAX_SGE  > 256 
++#define MPT_SCSI_SG_DEPTH	256
+ #else
+ #define MPT_SCSI_SG_DEPTH	CONFIG_FUSION_MAX_SGE
+ #endif
diff --git a/lustre/kernel_patches/patches/prune-icache-use-trylock-rhel5.patch b/lustre/kernel_patches/patches/prune-icache-use-trylock-rhel5.patch
new file mode 100644
index 0000000..beadec2
--- /dev/null
+++ b/lustre/kernel_patches/patches/prune-icache-use-trylock-rhel5.patch
@@ -0,0 +1,13 @@
+--- linux/fs/inode.c.orig	2009-01-24 03:28:57.000000000 +0800
++++ linux/fs/inode.c	2009-01-24 03:30:18.000000000 +0800
+@@ -418,7 +418,9 @@ static void prune_icache(int nr_to_scan)
+ 	int nr_scanned;
+ 	unsigned long reap = 0;
+ 
+-	mutex_lock(&iprune_mutex);
++	if (!mutex_trylock(&iprune_mutex))
++		return;
++
+ 	spin_lock(&inode_lock);
+ 	for (nr_scanned = 0; nr_scanned < nr_to_scan; nr_scanned++) {
+ 		struct inode *inode;
diff --git a/lustre/kernel_patches/patches/prune-icache-use-trylock-sles10.patch b/lustre/kernel_patches/patches/prune-icache-use-trylock-sles10.patch
new file mode 100644
index 0000000..51924f6
--- /dev/null
+++ b/lustre/kernel_patches/patches/prune-icache-use-trylock-sles10.patch
@@ -0,0 +1,13 @@
+--- linux/fs/inode.c.orig	2009-01-24 03:28:57.000000000 +0800
++++ linux/fs/inode.c	2009-01-24 03:30:18.000000000 +0800
+@@ -418,7 +418,9 @@ static void prune_icache(int nr_to_scan)
+ 	int nr_scanned;
+ 	unsigned long reap = 0;
+ 
+-	down(&iprune_sem);
++	if (down_trylock(&iprune_sem))
++		return;
++
+ 	spin_lock(&inode_lock);
+ 	for (nr_scanned = 0; nr_scanned < nr_to_scan; nr_scanned++) {
+ 		struct inode *inode;
diff --git a/lustre/kernel_patches/patches/qsnet-rhel4-2.6.patch b/lustre/kernel_patches/patches/qsnet-rhel4-2.6.patch
index b7623ab..f198a43 100644
--- a/lustre/kernel_patches/patches/qsnet-rhel4-2.6.patch
+++ b/lustre/kernel_patches/patches/qsnet-rhel4-2.6.patch
@@ -1,8 +1,8 @@
-Index: linux-2.6.9-78.0.22/fs/open.c
+Index: linux-269-5502/fs/open.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/open.c	2009-05-11 23:20:26.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/open.c	2009-05-11 23:21:42.000000000 -0600
-@@ -1031,6 +1031,8 @@
+--- linux-269-5502.orig/fs/open.c
++++ linux-269-5502/fs/open.c
+@@ -1029,6 +1029,8 @@ out_error:
  	goto out;
  }
  
@@ -11,11 +11,11 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  #ifndef __alpha__
  
  /*
-Index: linux-2.6.9-78.0.22/fs/read_write.c
+Index: linux-269-5502/fs/read_write.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/read_write.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/read_write.c	2009-05-11 23:21:42.000000000 -0600
-@@ -145,6 +145,7 @@
+--- linux-269-5502.orig/fs/read_write.c
++++ linux-269-5502/fs/read_write.c
+@@ -145,6 +145,7 @@ asmlinkage off_t sys_lseek(unsigned int 
  bad:
  	return retval;
  }
@@ -23,19 +23,19 @@ Index: linux-2.6.9-78.0.22/fs/read_write.c
  
  #ifdef __ARCH_WANT_SYS_LLSEEK
  asmlinkage long sys_llseek(unsigned int fd, unsigned long offset_high,
-Index: linux-2.6.9-78.0.22/fs/select.c
+Index: linux-269-5502/fs/select.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/select.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/select.c	2009-05-11 23:21:42.000000000 -0600
-@@ -539,3 +539,4 @@
+--- linux-269-5502.orig/fs/select.c
++++ linux-269-5502/fs/select.c
+@@ -539,3 +539,4 @@ out_fds:
  	poll_freewait(&table);
  	return err;
  }
 +EXPORT_SYMBOL_GPL(sys_poll);
-Index: linux-2.6.9-78.0.22/fs/exec.c
+Index: linux-269-5502/fs/exec.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/fs/exec.c	2009-05-11 23:20:26.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/exec.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/fs/exec.c
++++ linux-269-5502/fs/exec.c
 @@ -56,6 +56,8 @@
  #include <linux/kmod.h>
  #endif
@@ -45,7 +45,7 @@ Index: linux-2.6.9-78.0.22/fs/exec.c
  int core_uses_pid;
  char core_pattern[65] = "core";
  int suid_dumpable = 0;
-@@ -1233,6 +1235,9 @@
+@@ -1214,6 +1216,9 @@ int do_execve(char * filename,
  	if (retval < 0)
  		goto out;
  
@@ -55,11 +55,11 @@ Index: linux-2.6.9-78.0.22/fs/exec.c
  	retval = search_binary_handler(bprm,regs);
  	if (retval >= 0) {
  		free_arg_pages(bprm);
-Index: linux-2.6.9-78.0.22/arch/i386/Kconfig
+Index: linux-269-5502/arch/i386/Kconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/arch/i386/Kconfig	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/arch/i386/Kconfig	2009-05-11 23:21:42.000000000 -0600
-@@ -967,6 +967,9 @@
+--- linux-269-5502.orig/arch/i386/Kconfig
++++ linux-269-5502/arch/i386/Kconfig
+@@ -960,6 +960,9 @@ config REGPARM
  	generate incorrect output with certain kernel constructs when
  	-mregparm=3 is used.
  
@@ -69,11 +69,11 @@ Index: linux-2.6.9-78.0.22/arch/i386/Kconfig
  endmenu
  
  
-Index: linux-2.6.9-78.0.22/arch/i386/defconfig
+Index: linux-269-5502/arch/i386/defconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/arch/i386/defconfig	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/arch/i386/defconfig	2009-05-11 23:21:42.000000000 -0600
-@@ -119,6 +119,8 @@
+--- linux-269-5502.orig/arch/i386/defconfig
++++ linux-269-5502/arch/i386/defconfig
+@@ -119,6 +119,8 @@ CONFIG_MTRR=y
  CONFIG_IRQBALANCE=y
  CONFIG_HAVE_DEC_LOCK=y
  # CONFIG_REGPARM is not set
@@ -82,11 +82,11 @@ Index: linux-2.6.9-78.0.22/arch/i386/defconfig
  
  #
  # Power management options (ACPI, APM)
-Index: linux-2.6.9-78.0.22/arch/ia64/Kconfig
+Index: linux-269-5502/arch/ia64/Kconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/arch/ia64/Kconfig	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/arch/ia64/Kconfig	2009-05-11 23:21:42.000000000 -0600
-@@ -316,6 +316,9 @@
+--- linux-269-5502.orig/arch/ia64/Kconfig
++++ linux-269-5502/arch/ia64/Kconfig
+@@ -316,6 +316,9 @@ config IA64_PALINFO
  	  To use this option, you have to ensure that the "/proc file system
  	  support" (CONFIG_PROC_FS) is enabled, too.
  
@@ -96,11 +96,11 @@ Index: linux-2.6.9-78.0.22/arch/ia64/Kconfig
  source "drivers/firmware/Kconfig"
  
  source "fs/Kconfig.binfmt"
-Index: linux-2.6.9-78.0.22/arch/ia64/defconfig
+Index: linux-269-5502/arch/ia64/defconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/arch/ia64/defconfig	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/arch/ia64/defconfig	2009-05-11 23:21:42.000000000 -0600
-@@ -83,6 +83,8 @@
+--- linux-269-5502.orig/arch/ia64/defconfig
++++ linux-269-5502/arch/ia64/defconfig
+@@ -83,6 +83,8 @@ CONFIG_IA32_SUPPORT=y
  CONFIG_COMPAT=y
  CONFIG_PERFMON=y
  CONFIG_IA64_PALINFO=y
@@ -109,11 +109,11 @@ Index: linux-2.6.9-78.0.22/arch/ia64/defconfig
  
  #
  # Firmware Drivers
-Index: linux-2.6.9-78.0.22/arch/x86_64/Kconfig
+Index: linux-269-5502/arch/x86_64/Kconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/arch/x86_64/Kconfig	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/arch/x86_64/Kconfig	2009-05-11 23:21:42.000000000 -0600
-@@ -408,6 +408,9 @@
+--- linux-269-5502.orig/arch/x86_64/Kconfig
++++ linux-269-5502/arch/x86_64/Kconfig
+@@ -401,6 +401,9 @@ config X86_MCE_AMD
   	   Additional support for AMD specific MCE features such as
   	   the DRAM Error Threshold.
  
@@ -123,11 +123,11 @@ Index: linux-2.6.9-78.0.22/arch/x86_64/Kconfig
  endmenu
  
  
-Index: linux-2.6.9-78.0.22/arch/x86_64/defconfig
+Index: linux-269-5502/arch/x86_64/defconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/arch/x86_64/defconfig	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/arch/x86_64/defconfig	2009-05-11 23:21:42.000000000 -0600
-@@ -87,6 +87,8 @@
+--- linux-269-5502.orig/arch/x86_64/defconfig
++++ linux-269-5502/arch/x86_64/defconfig
+@@ -87,6 +87,8 @@ CONFIG_NR_CPUS=8
  CONFIG_GART_IOMMU=y
  CONFIG_SWIOTLB=y
  CONFIG_X86_MCE=y
@@ -136,10 +136,10 @@ Index: linux-2.6.9-78.0.22/arch/x86_64/defconfig
  
  #
  # Power management options
-Index: linux-2.6.9-78.0.22/kernel/ptrack.c
+Index: linux-269-5502/kernel/ptrack.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/kernel/ptrack.c	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/kernel/ptrack.c	2009-05-11 23:21:42.000000000 -0600
+--- /dev/null
++++ linux-269-5502/kernel/ptrack.c
 @@ -0,0 +1,145 @@
 +/*
 + *    Copyright (C) 2000  Regents of the University of California
@@ -286,11 +286,11 @@ Index: linux-2.6.9-78.0.22/kernel/ptrack.c
 +EXPORT_SYMBOL(ptrack_register);
 +EXPORT_SYMBOL(ptrack_deregister);
 +EXPORT_SYMBOL(ptrack_registered);
-Index: linux-2.6.9-78.0.22/kernel/signal.c
+Index: linux-269-5502/kernel/signal.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/kernel/signal.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/kernel/signal.c	2009-05-11 23:21:42.000000000 -0600
-@@ -2355,6 +2355,7 @@
+--- linux-269-5502.orig/kernel/signal.c
++++ linux-269-5502/kernel/signal.c
+@@ -2329,6 +2329,7 @@ sys_kill(int pid, int sig)
  
  	return kill_something_info(sig, &info, pid);
  }
@@ -298,10 +298,10 @@ Index: linux-2.6.9-78.0.22/kernel/signal.c
  
  /**
   *  sys_tgkill - send signal to one specific thread
-Index: linux-2.6.9-78.0.22/kernel/Kconfig
+Index: linux-269-5502/kernel/Kconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/kernel/Kconfig	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/kernel/Kconfig	2009-05-11 23:21:42.000000000 -0600
+--- /dev/null
++++ linux-269-5502/kernel/Kconfig
 @@ -0,0 +1,14 @@
 +#
 +# Kernel subsystem specific config
@@ -317,11 +317,11 @@ Index: linux-2.6.9-78.0.22/kernel/Kconfig
 +	created and destoryed in order for a resource management 
 +	system to know which processes are a member of a "job" and 
 +	to be able to clean up when the job is terminated.
-Index: linux-2.6.9-78.0.22/kernel/Makefile
+Index: linux-269-5502/kernel/Makefile
 ===================================================================
---- linux-2.6.9-78.0.22.orig/kernel/Makefile	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/kernel/Makefile	2009-05-11 23:21:42.000000000 -0600
-@@ -26,6 +26,7 @@
+--- linux-269-5502.orig/kernel/Makefile
++++ linux-269-5502/kernel/Makefile
+@@ -26,6 +26,7 @@ obj-$(CONFIG_AUDIT) += audit.o
  obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
  obj-$(CONFIG_AUDITFILESYSTEM) += auditfs.o
  obj-$(CONFIG_KPROBES) += kprobes.o
@@ -329,11 +329,11 @@ Index: linux-2.6.9-78.0.22/kernel/Makefile
  
  ifneq ($(CONFIG_IA64),y)
  # According to Alan Modra <alan at linuxcare.com.au>, the -fno-omit-frame-pointer is
-Index: linux-2.6.9-78.0.22/kernel/exit.c
+Index: linux-269-5502/kernel/exit.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/kernel/exit.c	2009-05-11 23:21:10.000000000 -0600
-+++ linux-2.6.9-78.0.22/kernel/exit.c	2009-05-11 23:21:42.000000000 -0600
-@@ -33,6 +33,8 @@
+--- linux-269-5502.orig/kernel/exit.c
++++ linux-269-5502/kernel/exit.c
+@@ -32,6 +32,8 @@
  #include <asm/pgtable.h>
  #include <asm/mmu_context.h>
  
@@ -342,7 +342,7 @@ Index: linux-2.6.9-78.0.22/kernel/exit.c
  extern void sem_exit (void);
  extern struct task_struct *child_reaper;
  
-@@ -852,6 +854,9 @@
+@@ -825,6 +827,9 @@ asmlinkage NORET_TYPE void do_exit(long 
  		current->tux_exit();
  	}
  
@@ -352,10 +352,10 @@ Index: linux-2.6.9-78.0.22/kernel/exit.c
  	if (unlikely(tsk->audit_context))
  		audit_free(tsk);
  	__exit_mm(tsk);
-Index: linux-2.6.9-78.0.22/kernel/fork.c
+Index: linux-269-5502/kernel/fork.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/kernel/fork.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/kernel/fork.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/kernel/fork.c
++++ linux-269-5502/kernel/fork.c
 @@ -14,6 +14,7 @@
  #include <linux/config.h>
  #include <linux/slab.h>
@@ -364,7 +364,7 @@ Index: linux-2.6.9-78.0.22/kernel/fork.c
  #include <linux/unistd.h>
  #include <linux/smp_lock.h>
  #include <linux/module.h>
-@@ -541,6 +542,9 @@
+@@ -443,6 +444,9 @@ static struct mm_struct * mm_init(struct
  	mm->page_table_lock = SPIN_LOCK_UNLOCKED;
  	mm->ioctx_list_lock = RW_LOCK_UNLOCKED;
  	mm->ioctx_list = NULL;
@@ -374,7 +374,7 @@ Index: linux-2.6.9-78.0.22/kernel/fork.c
  	mm->default_kioctx = (struct kioctx)INIT_KIOCTX(mm->default_kioctx, *mm);
  	mm->free_area_cache = TASK_UNMAPPED_BASE;
  
-@@ -1423,6 +1427,11 @@
+@@ -1312,6 +1316,11 @@ long do_fork(unsigned long clone_flags,
  			set_tsk_thread_flag(p, TIF_SIGPENDING);
  		}
  
@@ -386,10 +386,10 @@ Index: linux-2.6.9-78.0.22/kernel/fork.c
  		if (!(clone_flags & CLONE_STOPPED))
  			wake_up_new_task(p, clone_flags);
  		else
-Index: linux-2.6.9-78.0.22/Makefile
+Index: linux-269-5502/Makefile
 ===================================================================
---- linux-2.6.9-78.0.22.orig/Makefile	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/Makefile	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/Makefile
++++ linux-269-5502/Makefile
 @@ -1,7 +1,7 @@
  VERSION = 2
  PATCHLEVEL = 6
@@ -397,12 +397,12 @@ Index: linux-2.6.9-78.0.22/Makefile
 -EXTRAVERSION = -prep
 +EXTRAVERSION = -prep.qp3.5.34.4qsnet
  RHEL_VERSION = 4
- RHEL_UPDATE = 7
+ RHEL_UPDATE = 5
  NAME=AC 1
-Index: linux-2.6.9-78.0.22/Documentation/vm/ioproc.txt
+Index: linux-269-5502/Documentation/vm/ioproc.txt
 ===================================================================
---- linux-2.6.9-78.0.22.orig/Documentation/vm/ioproc.txt	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/Documentation/vm/ioproc.txt	2009-05-11 23:21:42.000000000 -0600
+--- /dev/null
++++ linux-269-5502/Documentation/vm/ioproc.txt
 @@ -0,0 +1,467 @@
 +Linux IOPROC patch overview
 +===========================
@@ -871,10 +871,10 @@ Index: linux-2.6.9-78.0.22/Documentation/vm/ioproc.txt
 +	ioproc_invalidate_range
 +
 +-- Last update Daniel J Blueman - 24 Mar 2006
-Index: linux-2.6.9-78.0.22/mm/ioproc.c
+Index: linux-269-5502/mm/ioproc.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/ioproc.c	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/mm/ioproc.c	2009-05-11 23:21:42.000000000 -0600
+--- /dev/null
++++ linux-269-5502/mm/ioproc.c
 @@ -0,0 +1,52 @@
 +/*
 + *    Copyright (C) 2006 Quadrics Ltd
@@ -928,10 +928,10 @@ Index: linux-2.6.9-78.0.22/mm/ioproc.c
 +}
 +
 +EXPORT_SYMBOL_GPL(ioproc_unregister_ops);
-Index: linux-2.6.9-78.0.22/mm/hugetlb.c
+Index: linux-269-5502/mm/hugetlb.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/hugetlb.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/hugetlb.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/hugetlb.c
++++ linux-269-5502/mm/hugetlb.c
 @@ -10,6 +10,7 @@
  #include <linux/hugetlb.h>
  #include <linux/sysctl.h>
@@ -940,7 +940,7 @@ Index: linux-2.6.9-78.0.22/mm/hugetlb.c
  
  const unsigned long hugetlb_zero = 0, hugetlb_infinity = ~0UL;
  static unsigned long nr_huge_pages, free_huge_pages;
-@@ -260,6 +261,7 @@
+@@ -260,6 +261,7 @@ void zap_hugepage_range(struct vm_area_s
  	struct mm_struct *mm = vma->vm_mm;
  
  	spin_lock(&mm->page_table_lock);
@@ -948,10 +948,10 @@ Index: linux-2.6.9-78.0.22/mm/hugetlb.c
  	unmap_hugepage_range(vma, start, start + length);
  	spin_unlock(&mm->page_table_lock);
  }
-Index: linux-2.6.9-78.0.22/mm/Kconfig
+Index: linux-269-5502/mm/Kconfig
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/Kconfig	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/mm/Kconfig	2009-05-11 23:21:42.000000000 -0600
+--- /dev/null
++++ linux-269-5502/mm/Kconfig
 @@ -0,0 +1,15 @@
 +#
 +# VM subsystem specific config
@@ -968,11 +968,11 @@ Index: linux-2.6.9-78.0.22/mm/Kconfig
 +	incorporate advanced RDMA capabilities can be kept in sync with CPU 
 +	page table changes.
 +	See Documentation/vm/ioproc.txt for more details.
-Index: linux-2.6.9-78.0.22/mm/Makefile
+Index: linux-269-5502/mm/Makefile
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/Makefile	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/Makefile	2009-05-11 23:21:42.000000000 -0600
-@@ -16,6 +16,7 @@
+--- linux-269-5502.orig/mm/Makefile
++++ linux-269-5502/mm/Makefile
+@@ -16,6 +16,7 @@ obj-$(CONFIG_SWAP)	+= page_io.o swap_sta
  obj-$(CONFIG_X86_4G)	+= usercopy.o
  obj-$(CONFIG_HUGETLBFS)	+= hugetlb.o
  obj-$(CONFIG_NUMA) 	+= mempolicy.o
@@ -980,10 +980,10 @@ Index: linux-2.6.9-78.0.22/mm/Makefile
  obj-$(CONFIG_SHMEM) += shmem.o
  obj-$(CONFIG_TINY_SHMEM) += tiny-shmem.o
  
-Index: linux-2.6.9-78.0.22/mm/mprotect.c
+Index: linux-269-5502/mm/mprotect.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/mprotect.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/mprotect.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/mprotect.c
++++ linux-269-5502/mm/mprotect.c
 @@ -10,6 +10,7 @@
  
  #include <linux/mm.h>
@@ -992,7 +992,7 @@ Index: linux-2.6.9-78.0.22/mm/mprotect.c
  #include <linux/slab.h>
  #include <linux/shm.h>
  #include <linux/mman.h>
-@@ -100,6 +101,7 @@
+@@ -100,6 +101,7 @@ change_protection(struct vm_area_struct 
  	if (start >= end)
  		BUG();
  	spin_lock(&current->mm->page_table_lock);
@@ -1000,10 +1000,10 @@ Index: linux-2.6.9-78.0.22/mm/mprotect.c
  	do {
  		change_pmd_range(dir, start, end - start, newprot);
  		start = (start + PGDIR_SIZE) & PGDIR_MASK;
-Index: linux-2.6.9-78.0.22/mm/msync.c
+Index: linux-269-5502/mm/msync.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/msync.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/msync.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/msync.c
++++ linux-269-5502/mm/msync.c
 @@ -12,6 +12,7 @@
  #include <linux/mm.h>
  #include <linux/mman.h>
@@ -1012,7 +1012,7 @@ Index: linux-2.6.9-78.0.22/mm/msync.c
  
  #include <asm/pgtable.h>
  #include <asm/tlbflush.h>
-@@ -115,6 +116,7 @@
+@@ -115,6 +116,7 @@ static int filemap_sync(struct vm_area_s
  
  	if (address >= end)
  		BUG();
@@ -1020,10 +1020,10 @@ Index: linux-2.6.9-78.0.22/mm/msync.c
  	do {
  		error |= filemap_sync_pmd_range(dir, address, end, vma, flags);
  		address = (address + PGDIR_SIZE) & PGDIR_MASK;
-Index: linux-2.6.9-78.0.22/mm/mremap.c
+Index: linux-269-5502/mm/mremap.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/mremap.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/mremap.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/mremap.c
++++ linux-269-5502/mm/mremap.c
 @@ -9,6 +9,7 @@
  
  #include <linux/mm.h>
@@ -1032,7 +1032,7 @@ Index: linux-2.6.9-78.0.22/mm/mremap.c
  #include <linux/slab.h>
  #include <linux/shm.h>
  #include <linux/mman.h>
-@@ -148,6 +149,8 @@
+@@ -148,6 +149,8 @@ static unsigned long move_page_tables(st
  {
  	unsigned long offset;
  
@@ -1041,10 +1041,10 @@ Index: linux-2.6.9-78.0.22/mm/mremap.c
  	flush_cache_range(vma, old_addr, old_addr + len);
  
  	/*
-Index: linux-2.6.9-78.0.22/mm/fremap.c
+Index: linux-269-5502/mm/fremap.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/fremap.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/fremap.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/fremap.c
++++ linux-269-5502/mm/fremap.c
 @@ -12,6 +12,7 @@
  #include <linux/mman.h>
  #include <linux/pagemap.h>
@@ -1053,7 +1053,7 @@ Index: linux-2.6.9-78.0.22/mm/fremap.c
  #include <linux/rmap.h>
  #include <linux/module.h>
  
-@@ -29,6 +30,7 @@
+@@ -29,6 +30,7 @@ static inline void zap_pte(struct mm_str
  	if (pte_present(pte)) {
  		unsigned long pfn = pte_pfn(pte);
  
@@ -1061,7 +1061,7 @@ Index: linux-2.6.9-78.0.22/mm/fremap.c
  		flush_cache_page(vma, addr);
  		pte = ptep_clear_flush(vma, addr, ptep);
  		if (pfn_valid(pfn)) {
-@@ -93,6 +95,7 @@
+@@ -93,6 +95,7 @@ int install_page(struct mm_struct *mm, s
  	pte_val = *pte;
  	pte_unmap(pte);
  	update_mmu_cache(vma, addr, pte_val);
@@ -1069,7 +1069,7 @@ Index: linux-2.6.9-78.0.22/mm/fremap.c
  
  	err = 0;
  err_unlock:
-@@ -132,6 +135,7 @@
+@@ -132,6 +135,7 @@ int install_file_pte(struct mm_struct *m
  	pte_val = *pte;
  	pte_unmap(pte);
  	update_mmu_cache(vma, addr, pte_val);
@@ -1077,10 +1077,10 @@ Index: linux-2.6.9-78.0.22/mm/fremap.c
  	spin_unlock(&mm->page_table_lock);
  	return 0;
  
-Index: linux-2.6.9-78.0.22/mm/rmap.c
+Index: linux-269-5502/mm/rmap.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/rmap.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/rmap.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/rmap.c
++++ linux-269-5502/mm/rmap.c
 @@ -51,6 +51,7 @@
  #include <linux/slab.h>
  #include <linux/init.h>
@@ -1089,7 +1089,7 @@ Index: linux-2.6.9-78.0.22/mm/rmap.c
  #include <linux/rcupdate.h>
  
  #include <asm/tlbflush.h>
-@@ -594,6 +595,7 @@
+@@ -566,6 +567,7 @@ static int try_to_unmap_one(struct page 
  	}
  
  	/* Nuke the page table entry. */
@@ -1097,7 +1097,7 @@ Index: linux-2.6.9-78.0.22/mm/rmap.c
  	flush_cache_page(vma, address);
  	pteval = ptep_clear_flush(vma, address, pte);
  
-@@ -701,6 +703,7 @@
+@@ -673,6 +675,7 @@ static void try_to_unmap_cluster(unsigne
  			continue;
  
  		/* Nuke the page table entry. */
@@ -1105,10 +1105,10 @@ Index: linux-2.6.9-78.0.22/mm/rmap.c
  		flush_cache_page(vma, address);
  		pteval = ptep_clear_flush(vma, address, pte);
  
-Index: linux-2.6.9-78.0.22/mm/memory.c
+Index: linux-269-5502/mm/memory.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/memory.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/memory.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/memory.c
++++ linux-269-5502/mm/memory.c
 @@ -43,6 +43,7 @@
  #include <linux/swap.h>
  #include <linux/highmem.h>
@@ -1117,7 +1117,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  #include <linux/rmap.h>
  #include <linux/module.h>
  #include <linux/init.h>
-@@ -648,6 +649,7 @@
+@@ -630,6 +631,7 @@ void zap_page_range(struct vm_area_struc
  
  	lru_add_drain();
  	spin_lock(&mm->page_table_lock);
@@ -1125,7 +1125,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	tlb = tlb_gather_mmu(mm, 0);
  	unmap_vmas(&tlb, mm, vma, address, end, &nr_accounted, details);
  	tlb_finish_mmu(tlb, address, end);
-@@ -1016,6 +1018,7 @@
+@@ -998,6 +1000,7 @@ int zeromap_page_range(struct vm_area_st
  		BUG();
  
  	spin_lock(&mm->page_table_lock);
@@ -1133,7 +1133,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	do {
  		pmd_t *pmd = pmd_alloc(mm, dir, address);
  		error = -ENOMEM;
-@@ -1030,6 +1033,7 @@
+@@ -1012,6 +1015,7 @@ int zeromap_page_range(struct vm_area_st
  	/*
  	 * Why flush? zeromap_pte_range has a BUG_ON for !pte_none()
  	 */
@@ -1141,7 +1141,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	flush_tlb_range(vma, beg, end);
  	spin_unlock(&mm->page_table_lock);
  	return error;
-@@ -1110,6 +1114,7 @@
+@@ -1092,6 +1096,7 @@ int remap_page_range(struct vm_area_stru
  	vma->vm_flags |= VM_IO | VM_RESERVED;
  
  	spin_lock(&mm->page_table_lock);
@@ -1149,7 +1149,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	do {
  		pmd_t *pmd = pmd_alloc(mm, dir, from);
  		error = -ENOMEM;
-@@ -1124,6 +1129,7 @@
+@@ -1106,6 +1111,7 @@ int remap_page_range(struct vm_area_stru
  	/*
  	 * Why flush? remap_pte_range has a BUG_ON for !pte_none()
  	 */
@@ -1157,7 +1157,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	flush_tlb_range(vma, beg, end);
  	spin_unlock(&mm->page_table_lock);
  	return error;
-@@ -1212,6 +1218,7 @@
+@@ -1194,6 +1200,7 @@ static int do_wp_page(struct mm_struct *
  			update_mmu_cache(vma, address, entry);
  			lazy_mmu_prot_update(entry);
  			pte_unmap(page_table);
@@ -1165,7 +1165,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  			spin_unlock(&mm->page_table_lock);
  			return VM_FAULT_MINOR;
  		}
-@@ -1244,6 +1251,7 @@
+@@ -1226,6 +1233,7 @@ static int do_wp_page(struct mm_struct *
  			++mm->rss;
  		else
  			page_remove_rmap(old_page);
@@ -1173,7 +1173,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  		break_cow(vma, new_page, address, page_table);
  		lru_cache_add_active(new_page);
  		page_add_anon_rmap(new_page, vma, address);
-@@ -1252,6 +1260,7 @@
+@@ -1234,6 +1242,7 @@ static int do_wp_page(struct mm_struct *
  		new_page = old_page;
  	}
  	pte_unmap(page_table);
@@ -1181,7 +1181,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	page_cache_release(new_page);
  	page_cache_release(old_page);
  	spin_unlock(&mm->page_table_lock);
-@@ -1648,6 +1657,7 @@
+@@ -1630,6 +1639,7 @@ static int do_swap_page(struct mm_struct
  	update_mmu_cache(vma, address, pte);
  	lazy_mmu_prot_update(pte);
  	pte_unmap(page_table);
@@ -1189,7 +1189,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	spin_unlock(&mm->page_table_lock);
  out:
  	return ret;
-@@ -1713,6 +1723,7 @@
+@@ -1695,6 +1705,7 @@ do_anonymous_page(struct mm_struct *mm, 
  	/* No need to invalidate - it was non-present before */
  	update_mmu_cache(vma, addr, entry);
  	lazy_mmu_prot_update(entry);
@@ -1197,7 +1197,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	spin_unlock(&mm->page_table_lock);
  out:
  	return VM_FAULT_MINOR;
-@@ -1836,6 +1847,7 @@
+@@ -1813,6 +1824,7 @@ retry:
  
  	/* no need to invalidate: a not-present page shouldn't be cached */
  	update_mmu_cache(vma, address, entry);
@@ -1205,7 +1205,7 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  	spin_unlock(&mm->page_table_lock);
  out:
  	return ret;
-@@ -2021,6 +2033,7 @@
+@@ -1998,6 +2010,7 @@ int make_pages_present(unsigned long add
  		return ret;
  	return ret == len ? 0 : -1;
  }
@@ -1213,10 +1213,10 @@ Index: linux-2.6.9-78.0.22/mm/memory.c
  
  /* 
   * Map a vmalloc()-space virtual address to the physical page.
-Index: linux-2.6.9-78.0.22/mm/mmap.c
+Index: linux-269-5502/mm/mmap.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/mm/mmap.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/mm/mmap.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/mm/mmap.c
++++ linux-269-5502/mm/mmap.c
 @@ -15,6 +15,7 @@
  #include <linux/init.h>
  #include <linux/file.h>
@@ -1225,7 +1225,7 @@ Index: linux-2.6.9-78.0.22/mm/mmap.c
  #include <linux/personality.h>
  #include <linux/security.h>
  #include <linux/hugetlb.h>
-@@ -1721,6 +1722,7 @@
+@@ -1703,6 +1704,7 @@ static void unmap_region(struct mm_struc
  	unsigned long nr_accounted = 0;
  
  	lru_add_drain();
@@ -1233,7 +1233,7 @@ Index: linux-2.6.9-78.0.22/mm/mmap.c
  	tlb = tlb_gather_mmu(mm, 0);
  	unmap_vmas(&tlb, mm, vma, start, end, &nr_accounted, NULL);
  	vm_unacct_memory(nr_accounted);
-@@ -2013,6 +2015,7 @@
+@@ -1995,6 +1997,7 @@ void exit_mmap(struct mm_struct *mm)
  
  	spin_lock(&mm->page_table_lock);
  
@@ -1241,10 +1241,10 @@ Index: linux-2.6.9-78.0.22/mm/mmap.c
  	tlb = tlb_gather_mmu(mm, 1);
  	flush_cache_mm(mm);
  	/* Use ~0UL here to ensure all VMAs in the mm are unmapped */
-Index: linux-2.6.9-78.0.22/ipc/shm.c
+Index: linux-269-5502/ipc/shm.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/ipc/shm.c	2009-05-08 09:59:02.000000000 -0600
-+++ linux-2.6.9-78.0.22/ipc/shm.c	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/ipc/shm.c
++++ linux-269-5502/ipc/shm.c
 @@ -26,6 +26,7 @@
  #include <linux/proc_fs.h>
  #include <linux/shmem_fs.h>
@@ -1253,7 +1253,7 @@ Index: linux-2.6.9-78.0.22/ipc/shm.c
  #include <linux/audit.h>
  #include <asm/uaccess.h>
  
-@@ -856,6 +857,44 @@
+@@ -856,6 +857,44 @@ asmlinkage long sys_shmdt(char __user *s
  	return retval;
  }
  
@@ -1298,10 +1298,10 @@ Index: linux-2.6.9-78.0.22/ipc/shm.c
  #ifdef CONFIG_PROC_FS
  static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
  {
-Index: linux-2.6.9-78.0.22/include/linux/init_task.h
+Index: linux-269-5502/include/linux/init_task.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/init_task.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/init_task.h	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/include/linux/init_task.h
++++ linux-269-5502/include/linux/init_task.h
 @@ -2,6 +2,7 @@
  #define _LINUX__INIT_TASK_H
  
@@ -1310,7 +1310,7 @@ Index: linux-2.6.9-78.0.22/include/linux/init_task.h
  
  #define INIT_FILES \
  { 							\
-@@ -112,6 +113,7 @@
+@@ -112,6 +113,7 @@ extern struct group_info init_groups;
  	.proc_lock	= SPIN_LOCK_UNLOCKED,				\
  	.switch_lock	= SPIN_LOCK_UNLOCKED,				\
  	.journal_info	= NULL,						\
@@ -1318,10 +1318,10 @@ Index: linux-2.6.9-78.0.22/include/linux/init_task.h
  }
  
  
-Index: linux-2.6.9-78.0.22/include/linux/ioproc.h
+Index: linux-269-5502/include/linux/ioproc.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/ioproc.h	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/include/linux/ioproc.h	2009-05-11 23:21:42.000000000 -0600
+--- /dev/null
++++ linux-269-5502/include/linux/ioproc.h
 @@ -0,0 +1,270 @@
 +/*
 + *    Copyright (C) 2006 Quadrics Ltd
@@ -1593,11 +1593,11 @@ Index: linux-2.6.9-78.0.22/include/linux/ioproc.h
 +
 +#endif				/* CONFIG_IOPROC */
 +#endif				/* __LINUX_IOPROC_H__ */
-Index: linux-2.6.9-78.0.22/include/linux/sched.h
+Index: linux-269-5502/include/linux/sched.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/sched.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/sched.h	2009-05-11 23:21:42.000000000 -0600
-@@ -186,6 +186,9 @@
+--- linux-269-5502.orig/include/linux/sched.h
++++ linux-269-5502/include/linux/sched.h
+@@ -185,6 +185,9 @@ extern signed long schedule_timeout_unin
  asmlinkage void schedule(void);
  
  struct namespace;
@@ -1607,7 +1607,7 @@ Index: linux-2.6.9-78.0.22/include/linux/sched.h
  
  /* Maximum number of active map areas.. This is a random (large) number */
  #define DEFAULT_MAX_MAP_COUNT	65536
-@@ -277,6 +280,11 @@
+@@ -260,6 +263,11 @@ struct mm_struct {
  	struct kioctx		*ioctx_list;
  
  	struct kioctx		default_kioctx;
@@ -1619,7 +1619,7 @@ Index: linux-2.6.9-78.0.22/include/linux/sched.h
  };
  
  extern int mmlist_nr;
-@@ -655,6 +663,10 @@
+@@ -635,6 +643,10 @@ struct task_struct {
    	struct mempolicy *mempolicy;
    	short il_next;		/* could be shared with used_math */
  #endif
@@ -1630,10 +1630,10 @@ Index: linux-2.6.9-78.0.22/include/linux/sched.h
  };
  
  static inline pid_t process_group(struct task_struct *tsk)
-Index: linux-2.6.9-78.0.22/include/linux/ptrack.h
+Index: linux-269-5502/include/linux/ptrack.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/ptrack.h	2009-04-18 06:33:31.404506136 -0600
-+++ linux-2.6.9-78.0.22/include/linux/ptrack.h	2009-05-11 23:21:42.000000000 -0600
+--- /dev/null
++++ linux-269-5502/include/linux/ptrack.h
 @@ -0,0 +1,65 @@
 +/*
 + *    Copyright (C) 2000  Regents of the University of California
@@ -1700,10 +1700,10 @@ Index: linux-2.6.9-78.0.22/include/linux/ptrack.h
 +#endif
 +
 +#endif /* __LINUX_PTRACK_H */
-Index: linux-2.6.9-78.0.22/include/asm-ia64/param.h
+Index: linux-269-5502/include/asm-ia64/param.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/asm-ia64/param.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/asm-ia64/param.h	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/include/asm-ia64/param.h
++++ linux-269-5502/include/asm-ia64/param.h
 @@ -27,7 +27,7 @@
     */
  #  define HZ	  32
@@ -1713,10 +1713,10 @@ Index: linux-2.6.9-78.0.22/include/asm-ia64/param.h
  # endif
  # define USER_HZ	HZ
  # define CLOCKS_PER_SEC	HZ	/* frequency at which times() counts */
-Index: linux-2.6.9-78.0.22/include/asm-i386/param.h
+Index: linux-269-5502/include/asm-i386/param.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/asm-i386/param.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/asm-i386/param.h	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/include/asm-i386/param.h
++++ linux-269-5502/include/asm-i386/param.h
 @@ -2,7 +2,7 @@
  #define _ASMi386_PARAM_H
  
@@ -1726,10 +1726,10 @@ Index: linux-2.6.9-78.0.22/include/asm-i386/param.h
  # define USER_HZ	100		/* .. some user interfaces are in "ticks" */
  # define CLOCKS_PER_SEC		(USER_HZ)	/* like times() */
  #endif
-Index: linux-2.6.9-78.0.22/include/asm-x86_64/param.h
+Index: linux-269-5502/include/asm-x86_64/param.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/asm-x86_64/param.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/asm-x86_64/param.h	2009-05-11 23:21:42.000000000 -0600
+--- linux-269-5502.orig/include/asm-x86_64/param.h
++++ linux-269-5502/include/asm-x86_64/param.h
 @@ -2,7 +2,7 @@
  #define _ASMx86_64_PARAM_H
  
diff --git a/lustre/kernel_patches/patches/qsnet-suse-2.6.patch b/lustre/kernel_patches/patches/qsnet-suse-2.6.patch
index 27b5a52..5f0967a 100644
--- a/lustre/kernel_patches/patches/qsnet-suse-2.6.patch
+++ b/lustre/kernel_patches/patches/qsnet-suse-2.6.patch
@@ -1025,9 +1025,9 @@ Index: LINUX-SRC-TREE/include/linux/sched.h
  
  extern int mmlist_nr;
 @@ -603,6 +611,10 @@ struct task_struct {
- 	struct rw_semaphore pagg_sem;
+ #ifndef __GENKSYMS__
+ 	struct list_head	*scm_work_list;
  #endif
- 
 +#ifdef CONFIG_PTRACK
 +/* process tracking callback */
 +	struct list_head ptrack_list;
diff --git a/lustre/kernel_patches/patches/quota-large-limits-rhel5.patch b/lustre/kernel_patches/patches/quota-large-limits-rhel5.patch
index 4f3a3bc..1f11fcc 100644
--- a/lustre/kernel_patches/patches/quota-large-limits-rhel5.patch
+++ b/lustre/kernel_patches/patches/quota-large-limits-rhel5.patch
@@ -1,7 +1,8 @@
-diff -rNpu linux-2.6.16.54-0.2.5/fs/dquot.c linux-2.6.16.54-0.2.5-quota/fs/dquot.c
---- linux-2.6.16.54-0.2.5/fs/dquot.c	2008-03-18 15:48:26.000000000 +0300
-+++ linux-2.6.16.54-0.2.5-quota/fs/dquot.c	2008-03-17 22:43:11.000000000 +0300
-@@ -1588,10 +1588,19 @@ int vfs_get_dqblk(struct super_block *sb
+Index: linux-2.6.18-128.1.14/fs/dquot.c
+===================================================================
+--- linux-2.6.18-128.1.14.orig/fs/dquot.c	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/dquot.c	2009-06-19 12:35:20.000000000 -0600
+@@ -1592,10 +1592,19 @@
  }
  
  /* Generic routine for setting common part of quota structure */
@@ -22,7 +23,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/dquot.c linux-2.6.16.54-0.2.5-quota/fs/dquot
  
  	spin_lock(&dq_data_lock);
  	if (di->dqb_valid & QIF_SPACE) {
-@@ -1623,7 +1632,7 @@ static void do_set_dqblk(struct dquot *d
+@@ -1627,7 +1636,7 @@
  			clear_bit(DQ_BLKS_B, &dquot->dq_flags);
  		}
  		else if (!(di->dqb_valid & QIF_BTIME))	/* Set grace only if user hasn't provided his own... */
@@ -31,7 +32,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/dquot.c linux-2.6.16.54-0.2.5-quota/fs/dquot
  	}
  	if (check_ilim) {
  		if (!dm->dqb_isoftlimit || dm->dqb_curinodes < dm->dqb_isoftlimit) {
-@@ -1631,7 +1640,7 @@ static void do_set_dqblk(struct dquot *d
+@@ -1635,7 +1644,7 @@
  			clear_bit(DQ_INODES_B, &dquot->dq_flags);
  		}
  		else if (!(di->dqb_valid & QIF_ITIME))	/* Set grace only if user hasn't provided his own... */
@@ -40,7 +41,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/dquot.c linux-2.6.16.54-0.2.5-quota/fs/dquot
  	}
  	if (dm->dqb_bhardlimit || dm->dqb_bsoftlimit || dm->dqb_ihardlimit || dm->dqb_isoftlimit)
  		clear_bit(DQ_FAKE_B, &dquot->dq_flags);
-@@ -1639,21 +1648,24 @@ static void do_set_dqblk(struct dquot *d
+@@ -1643,21 +1652,24 @@
  		set_bit(DQ_FAKE_B, &dquot->dq_flags);
  	spin_unlock(&dq_data_lock);
  	mark_dquot_dirty(dquot);
@@ -67,10 +68,11 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/dquot.c linux-2.6.16.54-0.2.5-quota/fs/dquot
  }
  
  /* Generic routine for getting common part of quota file information */
-diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v1.c linux-2.6.16.54-0.2.5-quota/fs/quota_v1.c
---- linux-2.6.16.54-0.2.5/fs/quota_v1.c	2006-03-20 08:53:29.000000000 +0300
-+++ linux-2.6.16.54-0.2.5-quota/fs/quota_v1.c	2008-03-17 22:42:47.000000000 +0300
-@@ -139,6 +139,9 @@ static int v1_read_file_info(struct supe
+Index: linux-2.6.18-128.1.14/fs/quota_v1.c
+===================================================================
+--- linux-2.6.18-128.1.14.orig/fs/quota_v1.c	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/quota_v1.c	2009-06-19 12:35:20.000000000 -0600
+@@ -139,6 +139,9 @@
  		goto out;
  	}
  	ret = 0;
@@ -80,10 +82,11 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v1.c linux-2.6.16.54-0.2.5-quota/fs/qu
  	dqopt->info[type].dqi_igrace = dqblk.dqb_itime ? dqblk.dqb_itime : MAX_IQ_TIME;
  	dqopt->info[type].dqi_bgrace = dqblk.dqb_btime ? dqblk.dqb_btime : MAX_DQ_TIME;
  out:
-diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/quota_v2.c
---- linux-2.6.16.54-0.2.5/fs/quota_v2.c	2006-03-20 08:53:29.000000000 +0300
-+++ linux-2.6.16.54-0.2.5-quota/fs/quota_v2.c	2008-03-18 11:58:02.000000000 +0300
-@@ -23,26 +23,64 @@ MODULE_LICENSE("GPL");
+Index: linux-2.6.18-128.1.14/fs/quota_v2.c
+===================================================================
+--- linux-2.6.18-128.1.14.orig/fs/quota_v2.c	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/fs/quota_v2.c	2009-06-19 12:35:20.000000000 -0600
+@@ -23,26 +23,64 @@
  typedef char *dqbuf_t;
  
  #define GETIDINDEX(id, depth) (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff)
@@ -157,7 +160,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  }
  
  /* Read information header from quota file */
-@@ -51,6 +89,13 @@ static int v2_read_file_info(struct supe
+@@ -51,6 +89,13 @@
  	struct v2_disk_dqinfo dinfo;
  	struct mem_dqinfo *info = sb_dqopt(sb)->info+type;
  	ssize_t size;
@@ -171,7 +174,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  
  	size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
  	       sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
-@@ -65,6 +110,16 @@ static int v2_read_file_info(struct supe
+@@ -65,6 +110,16 @@
  	info->u.v2_i.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
  	info->u.v2_i.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
  	info->u.v2_i.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
@@ -188,7 +191,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  	return 0;
  }
  
-@@ -94,29 +149,61 @@ static int v2_write_file_info(struct sup
+@@ -94,29 +149,61 @@
  	return 0;
  }
  
@@ -272,7 +275,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  }
  
  static dqbuf_t getdqbuf(void)
-@@ -268,10 +355,10 @@ static uint find_free_dqentry(struct dqu
+@@ -268,10 +355,10 @@
  {
  	struct super_block *sb = dquot->dq_sb;
  	struct mem_dqinfo *info = sb_dqopt(sb)->info+dquot->dq_type;
@@ -286,7 +289,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  	dqbuf_t buf;
  
  	*err = 0;
-@@ -298,17 +385,18 @@ static uint find_free_dqentry(struct dqu
+@@ -298,17 +385,18 @@
  		info->u.v2_i.dqi_free_entry = blk;
  		mark_info_dirty(sb, dquot->dq_type);
  	}
@@ -309,7 +312,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  		printk(KERN_ERR "VFS: find_free_dqentry(): Data block full but it shouldn't.\n");
  		*err = -EIO;
  		goto out_buf;
-@@ -318,7 +406,8 @@ static uint find_free_dqentry(struct dqu
+@@ -318,7 +406,8 @@
  		printk(KERN_ERR "VFS: find_free_dqentry(): Can't write quota data block %u.\n", blk);
  		goto out_buf;
  	}
@@ -319,7 +322,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  	freedqbuf(buf);
  	return blk;
  out_buf:
-@@ -392,7 +481,9 @@ static int v2_write_dquot(struct dquot *
+@@ -392,7 +481,9 @@
  {
  	int type = dquot->dq_type;
  	ssize_t ret;
@@ -328,9 +331,9 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
 +	uint rev = sb_dqopt(dquot->dq_sb)->info[type].u.v2_i.dqi_revision;
 +	uint dqblksz = v2_dqblksz(rev);
  
- 	/* dq_off is guarded by dqio_sem */
+ 	/* dq_off is guarded by dqio_mutex */
  	if (!dquot->dq_off)
-@@ -401,18 +492,22 @@ static int v2_write_dquot(struct dquot *
+@@ -401,18 +492,22 @@
  			return ret;
  		}
  	spin_lock(&dq_data_lock);
@@ -360,7 +363,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  		if (ret >= 0)
  			ret = -ENOSPC;
  	}
-@@ -431,6 +526,7 @@ static int free_dqentry(struct dquot *dq
+@@ -431,6 +526,7 @@
  	struct v2_disk_dqdbheader *dh;
  	dqbuf_t buf = getdqbuf();
  	int ret = 0;
@@ -368,7 +371,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  
  	if (!buf)
  		return -ENOMEM;
-@@ -456,8 +552,8 @@ static int free_dqentry(struct dquot *dq
+@@ -456,8 +552,8 @@
  	}
  	else {
  		memset(buf+(dquot->dq_off & ((1 << V2_DQBLKSIZE_BITS)-1)), 0,
@@ -379,7 +382,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  			/* Insert will write block itself */
  			if ((ret = insert_free_dqentry(sb, type, buf, blk)) < 0) {
  				printk(KERN_ERR "VFS: Can't insert quota data block (%u) to free entry list.\n", blk);
-@@ -529,41 +625,56 @@ static int v2_delete_dquot(struct dquot 
+@@ -529,41 +625,56 @@
  	return remove_tree(dquot, &tmp, 0);
  }
  
@@ -449,7 +452,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  out_buf:
  	freedqbuf(buf);
  	return ret;
-@@ -605,7 +716,7 @@ static int v2_read_dquot(struct dquot *d
+@@ -605,7 +716,7 @@
  {
  	int type = dquot->dq_type;
  	loff_t offset;
@@ -458,7 +461,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  	int ret = 0;
  
  #ifdef __QUOTA_V2_PARANOIA
-@@ -626,25 +737,30 @@ static int v2_read_dquot(struct dquot *d
+@@ -626,25 +737,30 @@
  		ret = offset;
  	}
  	else {
@@ -498,10 +501,11 @@ diff -rNpu linux-2.6.16.54-0.2.5/fs/quota_v2.c linux-2.6.16.54-0.2.5-quota/fs/qu
  		if (!dquot->dq_dqb.dqb_bhardlimit &&
  			!dquot->dq_dqb.dqb_bsoftlimit &&
  			!dquot->dq_dqb.dqb_ihardlimit &&
-diff -rNpu linux-2.6.16.54-0.2.5/include/linux/dqblk_v2.h linux-2.6.16.54-0.2.5-quota/include/linux/dqblk_v2.h
---- linux-2.6.16.54-0.2.5/include/linux/dqblk_v2.h	2006-03-20 08:53:29.000000000 +0300
-+++ linux-2.6.16.54-0.2.5-quota/include/linux/dqblk_v2.h	2008-03-17 23:39:54.000000000 +0300
-@@ -21,6 +21,7 @@ struct v2_mem_dqinfo {
+Index: linux-2.6.18-128.1.14/include/linux/dqblk_v2.h
+===================================================================
+--- linux-2.6.18-128.1.14.orig/include/linux/dqblk_v2.h	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/dqblk_v2.h	2009-06-19 12:35:20.000000000 -0600
+@@ -21,6 +21,7 @@
  	unsigned int dqi_blocks;
  	unsigned int dqi_free_blk;
  	unsigned int dqi_free_entry;
@@ -509,10 +513,11 @@ diff -rNpu linux-2.6.16.54-0.2.5/include/linux/dqblk_v2.h linux-2.6.16.54-0.2.5-
  };
  
  #endif /* _LINUX_DQBLK_V2_H */
-diff -rNpu linux-2.6.16.54-0.2.5/include/linux/quota.h linux-2.6.16.54-0.2.5-quota/include/linux/quota.h
---- linux-2.6.16.54-0.2.5/include/linux/quota.h	2006-03-20 08:53:29.000000000 +0300
-+++ linux-2.6.16.54-0.2.5-quota/include/linux/quota.h	2008-03-17 23:39:54.000000000 +0300
-@@ -148,12 +148,12 @@ struct if_dqinfo {
+Index: linux-2.6.18-128.1.14/include/linux/quota.h
+===================================================================
+--- linux-2.6.18-128.1.14.orig/include/linux/quota.h	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/quota.h	2009-06-19 12:35:20.000000000 -0600
+@@ -149,12 +149,12 @@
   * Data for one user/group kept in memory
   */
  struct mem_dqblk {
@@ -530,7 +535,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/include/linux/quota.h linux-2.6.16.54-0.2.5-quo
  	time_t dqb_btime;	/* time limit for excessive disk use */
  	time_t dqb_itime;	/* time limit for excessive inode use */
  };
-@@ -169,6 +169,8 @@ struct mem_dqinfo {
+@@ -170,6 +170,8 @@
  	unsigned long dqi_flags;
  	unsigned int dqi_bgrace;
  	unsigned int dqi_igrace;
@@ -539,9 +544,10 @@ diff -rNpu linux-2.6.16.54-0.2.5/include/linux/quota.h linux-2.6.16.54-0.2.5-quo
  	union {
  		struct v1_mem_dqinfo v1_i;
  		struct v2_mem_dqinfo v2_i;
-diff -rNpu linux-2.6.16.54-0.2.5/include/linux/quotaio_v2.h linux-2.6.16.54-0.2.5-quota/include/linux/quotaio_v2.h
---- linux-2.6.16.54-0.2.5/include/linux/quotaio_v2.h	2006-03-20 08:53:29.000000000 +0300
-+++ linux-2.6.16.54-0.2.5-quota/include/linux/quotaio_v2.h	2008-03-17 23:39:54.000000000 +0300
+Index: linux-2.6.18-128.1.14/include/linux/quotaio_v2.h
+===================================================================
+--- linux-2.6.18-128.1.14.orig/include/linux/quotaio_v2.h	2009-06-19 12:33:10.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/quotaio_v2.h	2009-06-19 12:35:20.000000000 -0600
 @@ -16,28 +16,51 @@
  	0xd9c01927	/* GRPQUOTA */\
  }
@@ -598,7 +604,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/include/linux/quotaio_v2.h linux-2.6.16.54-0.2.
  /*
   * Here are header structures as written on disk and their in-memory copies
   */
-@@ -59,7 +82,7 @@ struct v2_disk_dqinfo {
+@@ -59,7 +82,7 @@
  
  /*
   *  Structure of header of block with quota structures. It is padded to 16 bytes so
@@ -607,7 +613,7 @@ diff -rNpu linux-2.6.16.54-0.2.5/include/linux/quotaio_v2.h linux-2.6.16.54-0.2.
   */
  struct v2_disk_dqdbheader {
  	__le32 dqdh_next_free;	/* Number of next block with free entry */
-@@ -74,6 +97,5 @@ struct v2_disk_dqdbheader {
+@@ -74,6 +97,5 @@
  #define V2_DQBLKSIZE	(1 << V2_DQBLKSIZE_BITS)	/* Size of block with quota structures */
  #define V2_DQTREEOFF	1		/* Offset of tree in file in blocks */
  #define V2_DQTREEDEPTH	4		/* Depth of quota tree */
diff --git a/lustre/kernel_patches/patches/quota-support-64-bit-quota-format.patch b/lustre/kernel_patches/patches/quota-support-64-bit-quota-format.patch
new file mode 100644
index 0000000..14fe9a8
--- /dev/null
+++ b/lustre/kernel_patches/patches/quota-support-64-bit-quota-format.patch
@@ -0,0 +1,282 @@
+From: Jan Kara <jack at suse.cz>
+
+Implement conversion functions for new version (version 1) of quota format
+which supports 64-bit block and inode limits and 64-bit inode usage.  The
+original implementation has been written by Andrew Perepechko.
+
+Signed-off-by: Andrew Perepechko <andrew.perepechko at sun.com>
+Signed-off-by: Jan Kara <jack at suse.cz>
+Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
+---
+
+ fs/quota_v2.c   |  140 ++++++++++++++++++++++++++++++++++++----------
+ fs/quotaio_v2.h |   26 ++++++--
+ 2 files changed, 132 insertions(+), 34 deletions(-)
+
+diff -puN fs/quota_v2.c~quota-support-64-bit-quota-format fs/quota_v2.c
+--- a/fs/quota_v2.c~quota-support-64-bit-quota-format
++++ a/fs/quota_v2.c
+@@ -23,14 +23,24 @@ MODULE_LICENSE("GPL");
+ 
+ #define __QUOTA_V2_PARANOIA
+ 
+-static void v2_mem2diskdqb(void *dp, struct dquot *dquot);
+-static void v2_disk2memdqb(struct dquot *dquot, void *dp);
+-static int v2_is_id(void *dp, struct dquot *dquot);
+-
+-static struct qtree_fmt_operations v2_qtree_ops = {
+-	.mem2disk_dqblk = v2_mem2diskdqb,
+-	.disk2mem_dqblk = v2_disk2memdqb,
+-	.is_id = v2_is_id,
++static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot);
++static void v2r0_disk2memdqb(struct dquot *dquot, void *dp);
++static int v2r0_is_id(void *dp, struct dquot *dquot);
++
++static struct qtree_fmt_operations v2r0_qtree_ops = {
++	.mem2disk_dqblk = v2r0_mem2diskdqb,
++	.disk2mem_dqblk = v2r0_disk2memdqb,
++	.is_id = v2r0_is_id,
++};
++
++static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot);
++static void v2r1_disk2memdqb(struct dquot *dquot, void *dp);
++static int v2r1_is_id(void *dp, struct dquot *dquot);
++
++static struct qtree_fmt_operations v2r1_qtree_ops = {
++	.mem2disk_dqblk = v2r1_mem2diskdqb,
++	.disk2mem_dqblk = v2r1_disk2memdqb,
++	.is_id = v2r1_is_id,
+ };
+ 
+ #define QUOTABLOCK_BITS 10
+@@ -46,8 +56,7 @@ static inline qsize_t v2_qbtos(qsize_t b
+ 	return blocks << QUOTABLOCK_BITS;
+ }
+ 
+-/* Check whether given file is really vfsv0 quotafile */
+-static int v2_check_quota_file(struct super_block *sb, int type)
++static int v2_check_quota_file_header(struct super_block *sb, int type)
+ {
+ 	struct v2_disk_dqheader dqhead;
+ 	ssize_t size;
+@@ -58,12 +67,20 @@ static int v2_check_quota_file(struct su
+ 	if (size != sizeof(struct v2_disk_dqheader)) {
+ 		printk("quota_v2: failed read expected=%zd got=%zd\n",
+ 			sizeof(struct v2_disk_dqheader), size);
+-		return 0;
++		return -EIO;
+ 	}
+-	if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] ||
+-	    le32_to_cpu(dqhead.dqh_version) != quota_versions[type])
+-		return 0;
+-	return 1;
++	if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type])
++		return -ENOENT;
++	if (le32_to_cpu(dqhead.dqh_version) > quota_versions[type])
++		return -EOPNOTSUPP;
++	return le32_to_cpu(dqhead.dqh_version);
++}
++
++
++/* Check whether given file is really vfsv0 quotafile */
++static int v2_check_quota_file(struct super_block *sb, int type)
++{
++	return v2_check_quota_file_header(sb, type) >= 0;
+ }
+ 
+ /* Read information header from quota file */
+@@ -73,7 +90,13 @@ static int v2_read_file_info(struct supe
+ 	struct mem_dqinfo *info = sb_dqinfo(sb, type);
+ 	struct qtree_mem_dqinfo *qinfo;
+ 	ssize_t size;
++	int version = v2_check_quota_file_header(sb, type);
+ 
++	if (version < 0) {
++		printk(KERN_WARNING "Cannot identify quota file version on "
++		       "device %s: %d\n", sb->s_id, version);
++		return -1;
++	}
+ 	size = sb->s_op->quota_read(sb, type, (char *)&dinfo,
+ 	       sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF);
+ 	if (size != sizeof(struct v2_disk_dqinfo)) {
+@@ -88,9 +111,14 @@ static int v2_read_file_info(struct supe
+ 		return -1;
+ 	}
+ 	qinfo = info->dqi_priv;
+-	/* limits are stored as unsigned 32-bit data */
+-	info->dqi_maxblimit = 0xffffffff;
+-	info->dqi_maxilimit = 0xffffffff;
++	if (version == 0) {
++		/* limits are stored as unsigned 32-bit data */
++		info->dqi_maxblimit = 0xffffffff;
++		info->dqi_maxilimit = 0xffffffff;
++	} else {
++		info->dqi_maxblimit = 0x7fffffffffffffffULL;
++		info->dqi_maxilimit = 0x7fffffffffffffffULL;
++	}
+ 	info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
+ 	info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
+ 	info->dqi_flags = le32_to_cpu(dinfo.dqi_flags);
+@@ -102,8 +130,13 @@ static int v2_read_file_info(struct supe
+ 	qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS;
+ 	qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS;
+ 	qinfo->dqi_qtree_depth = qtree_depth(qinfo);
+-	qinfo->dqi_entry_size = sizeof(struct v2_disk_dqblk);
+-	qinfo->dqi_ops = &v2_qtree_ops;
++	if (version == 0) {
++		qinfo->dqi_entry_size = sizeof(struct v2r0_disk_dqblk);
++		qinfo->dqi_ops = &v2r0_qtree_ops;
++	} else {
++		qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
++		qinfo->dqi_ops = &v2r1_qtree_ops;
++	}
+ 	return 0;
+ }
+ 
+@@ -134,9 +167,9 @@ static int v2_write_file_info(struct sup
+ 	return 0;
+ }
+ 
+-static void v2_disk2memdqb(struct dquot *dquot, void *dp)
++static void v2r0_disk2memdqb(struct dquot *dquot, void *dp)
+ {
+-	struct v2_disk_dqblk *d = dp, empty;
++	struct v2r0_disk_dqblk *d = dp, empty;
+ 	struct mem_dqblk *m = &dquot->dq_dqb;
+ 
+ 	m->dqb_ihardlimit = le32_to_cpu(d->dqb_ihardlimit);
+@@ -148,15 +181,15 @@ static void v2_disk2memdqb(struct dquot 
+ 	m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
+ 	m->dqb_btime = le64_to_cpu(d->dqb_btime);
+ 	/* We need to escape back all-zero structure */
+-	memset(&empty, 0, sizeof(struct v2_disk_dqblk));
++	memset(&empty, 0, sizeof(struct v2r0_disk_dqblk));
+ 	empty.dqb_itime = cpu_to_le64(1);
+-	if (!memcmp(&empty, dp, sizeof(struct v2_disk_dqblk)))
++	if (!memcmp(&empty, dp, sizeof(struct v2r0_disk_dqblk)))
+ 		m->dqb_itime = 0;
+ }
+ 
+-static void v2_mem2diskdqb(void *dp, struct dquot *dquot)
++static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot)
+ {
+-	struct v2_disk_dqblk *d = dp;
++	struct v2r0_disk_dqblk *d = dp;
+ 	struct mem_dqblk *m = &dquot->dq_dqb;
+ 	struct qtree_mem_dqinfo *info =
+ 			sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
+@@ -174,9 +207,60 @@ static void v2_mem2diskdqb(void *dp, str
+ 		d->dqb_itime = cpu_to_le64(1);
+ }
+ 
+-static int v2_is_id(void *dp, struct dquot *dquot)
++static int v2r0_is_id(void *dp, struct dquot *dquot)
++{
++	struct v2r0_disk_dqblk *d = dp;
++	struct qtree_mem_dqinfo *info =
++			sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
++
++	if (qtree_entry_unused(info, dp))
++		return 0;
++	return le32_to_cpu(d->dqb_id) == dquot->dq_id;
++}
++
++static void v2r1_disk2memdqb(struct dquot *dquot, void *dp)
++{
++	struct v2r1_disk_dqblk *d = dp, empty;
++	struct mem_dqblk *m = &dquot->dq_dqb;
++
++	m->dqb_ihardlimit = le64_to_cpu(d->dqb_ihardlimit);
++	m->dqb_isoftlimit = le64_to_cpu(d->dqb_isoftlimit);
++	m->dqb_curinodes = le64_to_cpu(d->dqb_curinodes);
++	m->dqb_itime = le64_to_cpu(d->dqb_itime);
++	m->dqb_bhardlimit = v2_qbtos(le64_to_cpu(d->dqb_bhardlimit));
++	m->dqb_bsoftlimit = v2_qbtos(le64_to_cpu(d->dqb_bsoftlimit));
++	m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
++	m->dqb_btime = le64_to_cpu(d->dqb_btime);
++	/* We need to escape back all-zero structure */
++	memset(&empty, 0, sizeof(struct v2r1_disk_dqblk));
++	empty.dqb_itime = cpu_to_le64(1);
++	if (!memcmp(&empty, dp, sizeof(struct v2r1_disk_dqblk)))
++		m->dqb_itime = 0;
++}
++
++static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot)
++{
++	struct v2r1_disk_dqblk *d = dp;
++	struct mem_dqblk *m = &dquot->dq_dqb;
++	struct qtree_mem_dqinfo *info =
++			sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
++
++	d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit);
++	d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit);
++	d->dqb_curinodes = cpu_to_le64(m->dqb_curinodes);
++	d->dqb_itime = cpu_to_le64(m->dqb_itime);
++	d->dqb_bhardlimit = cpu_to_le64(v2_stoqb(m->dqb_bhardlimit));
++	d->dqb_bsoftlimit = cpu_to_le64(v2_stoqb(m->dqb_bsoftlimit));
++	d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
++	d->dqb_btime = cpu_to_le64(m->dqb_btime);
++	d->dqb_id = cpu_to_le32(dquot->dq_id);
++	if (qtree_entry_unused(info, dp))
++		d->dqb_itime = cpu_to_le64(1);
++}
++
++static int v2r1_is_id(void *dp, struct dquot *dquot)
+ {
+-	struct v2_disk_dqblk *d = dp;
++	struct v2r1_disk_dqblk *d = dp;
+ 	struct qtree_mem_dqinfo *info =
+ 			sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
+ 
+diff -puN fs/quotaio_v2.h~quota-support-64-bit-quota-format fs/quotaio_v2.h
+--- a/fs/quotaio_v2.h~quota-support-64-bit-quota-format
++++ a/fs/quotaio_v2.h
+@@ -17,8 +17,8 @@
+ }
+ 
+ #define V2_INITQVERSIONS {\
+-	0,		/* USRQUOTA */\
+-	0		/* GRPQUOTA */\
++	1,		/* USRQUOTA */\
++	1		/* GRPQUOTA */\
+ }
+ 
+ /* First generic header */
+@@ -28,11 +28,11 @@ struct v2_disk_dqheader {
+ };
+ 
+ /*
+- * The following structure defines the format of the disk quota file
+- * (as it appears on disk) - the file is a radix tree whose leaves point
+- * to blocks of these structures.
++ * The following structure defines the format of the disk quota file in version
++ * 0 - the file is a radix tree whose leaves point to blocks of these
++ * structures.
+  */
+-struct v2_disk_dqblk {
++struct v2r0_disk_dqblk {
+ 	__le32 dqb_id;		/* id this quota applies to */
+ 	__le32 dqb_ihardlimit;	/* absolute limit on allocated inodes */
+ 	__le32 dqb_isoftlimit;	/* preferred inode limit */
+@@ -44,6 +44,20 @@ struct v2_disk_dqblk {
+ 	__le64 dqb_itime;	/* time limit for excessive inode use */
+ };
+ 
++/* The same structure in quota file version 1 */
++struct v2r1_disk_dqblk {
++	__le32 dqb_id;		/* id this quota applies to */
++	__le32 dqb_padding;	/* padding field */
++	__le64 dqb_ihardlimit;	/* absolute limit on allocated inodes */
++	__le64 dqb_isoftlimit;	/* preferred inode limit */
++	__le64 dqb_curinodes;	/* current # allocated inodes */
++	__le64 dqb_bhardlimit;	/* absolute limit on disk space */
++	__le64 dqb_bsoftlimit;	/* preferred limit on disk space */
++	__le64 dqb_curspace;	/* current space occupied (in bytes) */
++	__le64 dqb_btime;	/* time limit for excessive disk use */
++	__le64 dqb_itime;	/* time limit for excessive inode use */
++};
++
+ /* Header with type and version specific information */
+ struct v2_disk_dqinfo {
+ 	__le32 dqi_bgrace;	/* Time before block soft limit becomes hard limit */
+_
diff --git a/lustre/kernel_patches/patches/raid5-merge-ios.patch b/lustre/kernel_patches/patches/raid5-merge-ios.patch
index 74d13e9..3f5cbbc 100644
--- a/lustre/kernel_patches/patches/raid5-merge-ios.patch
+++ b/lustre/kernel_patches/patches/raid5-merge-ios.patch
@@ -1,10 +1,10 @@
 Merge IO requests to try and get larger requests on underlying drives.
 
-Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
+Index: linux-2.6.9/drivers/md/raid5.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/md/raid5.c	2009-05-11 23:23:22.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/md/raid5.c	2009-05-11 23:23:25.000000000 -0600
-@@ -852,6 +852,26 @@
+--- linux-2.6.9.orig/drivers/md/raid5.c	2006-05-22 00:10:04.000000000 +0400
++++ linux-2.6.9/drivers/md/raid5.c	2006-05-22 00:10:06.000000000 +0400
+@@ -934,6 +934,26 @@ static void add_stripe_bio (struct strip
  	}
  }
  
@@ -31,7 +31,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  
  /*
   * handle_stripe - do things to a stripe.
-@@ -871,7 +891,7 @@
+@@ -953,7 +973,7 @@ static void add_stripe_bio (struct strip
   *
   */
   
@@ -40,7 +40,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  {
  	raid5_conf_t *conf = sh->raid_conf;
  	int disks = conf->raid_disks;
-@@ -1291,7 +1311,11 @@
+@@ -1376,7 +1396,11 @@ static void handle_stripe(struct stripe_
  			bi->bi_size = STRIPE_SIZE;
  			bi->bi_next = NULL;
  			atomic_inc(&conf->out_reqs_in_queue);
@@ -53,23 +53,23 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  		} else {
  			PRINTK("skip op %ld on disc %d for sector %llu\n",
  				bi->bi_rw, i, (unsigned long long)sh->sector);
-@@ -1416,6 +1440,7 @@
+@@ -1501,6 +1525,7 @@ static int make_request (request_queue_t
  	int sectors_per_chunk = conf->chunk_size >> 9;
  	int stripes_per_chunk, sectors_per_block;
  	int sectors_per_stripe;
 +	struct bio *bios[MD_SB_DISKS];
  	int i, j;
  
- 	if (unlikely(bio_barrier(bi))) {
-@@ -1450,6 +1475,7 @@
+ 	atomic_inc(&conf->in_reqs_in_queue);
+@@ -1530,6 +1555,7 @@ static int make_request (request_queue_t
  	sector_div(block, sectors_per_block);
  	sectors = bi->bi_size >> 9;
  
 +	memset(&bios, 0, sizeof(bios));
  repeat:
- 	stripe = block * (sectors_per_block / data_disks);
+ 	stripe = block * sectors_per_block / data_disks;
  	b_sector = stripe * data_disks;
-@@ -1469,9 +1495,17 @@
+@@ -1549,9 +1575,17 @@ repeat:
  			new_sector = raid5_compute_sector(r_sector, raid_disks,
  							data_disks, &dd_idx, 
  							&pd_idx, conf);
@@ -90,7 +90,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  			if (sh) {
  				add_stripe_bio(sh, bi, dd_idx, (bi->bi_rw&RW_MASK));
  			} else {
-@@ -1491,7 +1525,7 @@
+@@ -1571,7 +1605,7 @@ repeat:
  		}
  		if (sh) {
  			raid5_plug_device(conf);
@@ -99,7 +99,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  			release_stripe(sh);
  			sh = NULL;
  		}
-@@ -1501,6 +1535,9 @@
+@@ -1581,6 +1615,9 @@ repeat:
  	if (sectors > 0)
  		goto repeat;
  
@@ -109,7 +109,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  	spin_lock_irq(&conf->device_lock);
  	if (--bi->bi_phys_segments == 0) {
  		int bytes = bi->bi_size;
-@@ -1556,7 +1593,7 @@
+@@ -1636,7 +1673,7 @@ static int sync_request (mddev_t *mddev,
  	clear_bit(STRIPE_INSYNC, &sh->state);
  	spin_unlock(&sh->lock);
  
@@ -118,7 +118,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  	release_stripe(sh);
  
  	return STRIPE_SECTORS;
-@@ -1605,7 +1642,7 @@
+@@ -1685,7 +1722,7 @@ static void raid5d (mddev_t *mddev)
  		
  		handled++;
  		atomic_inc(&conf->handled_in_raid5d);
diff --git a/lustre/kernel_patches/patches/raid5-stats.patch b/lustre/kernel_patches/patches/raid5-stats.patch
index 2707270..1308009 100644
--- a/lustre/kernel_patches/patches/raid5-stats.patch
+++ b/lustre/kernel_patches/patches/raid5-stats.patch
@@ -1,10 +1,10 @@
 Add RAID statistics counters to /proc/mdstat
 
-Index: linux-2.6.9-78.0.22/include/linux/raid/raid5.h
+Index: linux-2.6.9/include/linux/raid/raid5.h
 ===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/raid/raid5.h	2009-05-11 23:22:54.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/raid/raid5.h	2009-05-11 23:22:55.000000000 -0600
-@@ -222,6 +222,22 @@
+--- linux-2.6.9.orig/include/linux/raid/raid5.h	2004-10-19 01:54:55.000000000 +0400
++++ linux-2.6.9/include/linux/raid/raid5.h	2006-05-17 14:10:53.000000000 +0400
+@@ -222,6 +222,22 @@ struct raid5_private_data {
  	int			inactive_blocked;	/* release of inactive stripes blocked,
  							 * waiting for 25% to be free
  							 */        
@@ -27,11 +27,11 @@ Index: linux-2.6.9-78.0.22/include/linux/raid/raid5.h
  	spinlock_t		device_lock;
  	struct disk_info	disks[0];
  };
-Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
+Index: linux-2.6.9/drivers/md/raid5.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/md/raid5.c	2009-05-11 23:22:54.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/md/raid5.c	2009-05-11 23:22:55.000000000 -0600
-@@ -77,9 +77,10 @@
+--- linux-2.6.9.orig/drivers/md/raid5.c	2006-03-10 18:20:48.000000000 +0300
++++ linux-2.6.9/drivers/md/raid5.c	2006-05-17 14:10:53.000000000 +0400
+@@ -77,9 +77,10 @@ static inline void __release_stripe(raid
  		if (atomic_read(&conf->active_stripes)==0)
  			BUG();
  		if (test_bit(STRIPE_HANDLE, &sh->state)) {
@@ -44,7 +44,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  				list_add_tail(&sh->lru, &conf->handle_list);
  			md_wakeup_thread(conf->mddev->thread);
  		} else {
-@@ -250,6 +251,7 @@
+@@ -250,6 +251,7 @@ static struct stripe_head *get_active_st
  			if (noblock && sh == NULL)
  				break;
  			if (!sh) {
@@ -52,7 +52,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  				conf->inactive_blocked = 1;
  				wait_event_lock_irq(conf->wait_for_stripe,
  						    !list_empty(&conf->inactive_list) &&
-@@ -271,6 +273,8 @@
+@@ -271,6 +273,8 @@ static struct stripe_head *get_active_st
  				if (list_empty(&sh->lru))
  					BUG();
  				list_del_init(&sh->lru);
@@ -61,7 +61,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  			}
  		}
  	} while (sh == NULL);
-@@ -349,6 +353,8 @@
+@@ -349,6 +353,8 @@ static int raid5_end_read_request (struc
  	if (bi->bi_size)
  		return 1;
  
@@ -70,7 +70,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  	for (i=0 ; i<disks; i++)
  		if (bi == &sh->dev[i].req)
  			break;
-@@ -422,6 +428,8 @@
+@@ -422,6 +428,8 @@ static int raid5_end_write_request (stru
  	if (bi->bi_size)
  		return 1;
  
@@ -79,7 +79,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  	for (i=0 ; i<disks; i++)
  		if (bi == &sh->dev[i].req)
  			break;
-@@ -882,6 +890,7 @@
+@@ -882,6 +890,7 @@ static void handle_stripe(struct stripe_
  	spin_lock(&sh->lock);
  	clear_bit(STRIPE_HANDLE, &sh->state);
  	clear_bit(STRIPE_DELAYED, &sh->state);
@@ -87,7 +87,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  
  	syncing = test_bit(STRIPE_SYNCING, &sh->state);
  	/* Now to look around and see what can be done */
-@@ -1127,6 +1136,7 @@
+@@ -1127,6 +1136,7 @@ static void handle_stripe(struct stripe_
  						set_bit(R5_LOCKED, &dev->flags);
  						set_bit(R5_Wantread, &dev->flags);
  						locked++;
@@ -95,7 +95,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  					} else {
  						set_bit(STRIPE_DELAYED, &sh->state);
  						set_bit(STRIPE_HANDLE, &sh->state);
-@@ -1146,6 +1156,7 @@
+@@ -1146,6 +1156,7 @@ static void handle_stripe(struct stripe_
  						set_bit(R5_LOCKED, &dev->flags);
  						set_bit(R5_Wantread, &dev->flags);
  						locked++;
@@ -103,7 +103,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  					} else {
  						set_bit(STRIPE_DELAYED, &sh->state);
  						set_bit(STRIPE_HANDLE, &sh->state);
-@@ -1228,6 +1239,7 @@
+@@ -1228,6 +1239,7 @@ static void handle_stripe(struct stripe_
  		bi->bi_next = NULL;
  		bi->bi_size = 0;
  		bi->bi_end_io(bi, bytes, 0);
@@ -111,7 +111,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  	}
  	for (i=disks; i-- ;) {
  		int rw;
-@@ -1243,10 +1255,13 @@
+@@ -1243,10 +1255,13 @@ static void handle_stripe(struct stripe_
  		bi = &sh->dev[i].req;
   
  		bi->bi_rw = rw;
@@ -127,7 +127,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
   
  		spin_lock_irq(&conf->device_lock);
  		rdev = conf->disks[i].rdev;
-@@ -1274,6 +1289,7 @@
+@@ -1274,6 +1289,7 @@ static void handle_stripe(struct stripe_
  			bi->bi_io_vec[0].bv_offset = 0;
  			bi->bi_size = STRIPE_SIZE;
  			bi->bi_next = NULL;
@@ -135,7 +135,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  			generic_make_request(bi);
  		} else {
  			PRINTK("skip op %ld on disc %d for sector %llu\n",
-@@ -1296,6 +1312,7 @@
+@@ -1296,6 +1312,7 @@ static inline void raid5_activate_delaye
  			if (!test_and_set_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
  				atomic_inc(&conf->preread_active_stripes);
  			list_add_tail(&sh->lru, &conf->handle_list);
@@ -143,9 +143,9 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  		}
  	}
  }
-@@ -1400,12 +1417,16 @@
- 		return 0;
- 	}
+@@ -1395,12 +1412,16 @@ static int make_request (request_queue_t
+ 	sector_t logical_sector, last_sector;
+ 	struct stripe_head *sh;
  
 +	atomic_inc(&conf->in_reqs_in_queue);
 +
@@ -160,7 +160,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  	}
  
  	logical_sector = bi->bi_sector & ~((sector_t)STRIPE_SECTORS-1);
-@@ -1444,6 +1465,7 @@
+@@ -1439,6 +1460,7 @@ static int make_request (request_queue_t
  
  		if ( bio_data_dir(bi) == WRITE )
  			md_write_end(mddev);
@@ -168,7 +168,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  		bi->bi_size = 0;
  		bi->bi_end_io(bi, bytes, 0);
  	}
-@@ -1540,6 +1562,7 @@
+@@ -1535,6 +1557,7 @@ static void raid5d (mddev_t *mddev)
  		spin_unlock_irq(&conf->device_lock);
  		
  		handled++;
@@ -176,7 +176,7 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
  		handle_stripe(sh);
  		release_stripe(sh);
  
-@@ -1773,6 +1796,21 @@
+@@ -1767,6 +1790,21 @@ static void status (struct seq_file *seq
  			       conf->disks[i].rdev &&
  			       conf->disks[i].rdev->in_sync ? "U" : "_");
  	seq_printf (seq, "]");
diff --git a/lustre/kernel_patches/patches/raid5-stripe-by-stripe-handling.patch b/lustre/kernel_patches/patches/raid5-stripe-by-stripe-handling.patch
index eadd998..d86a42a 100644
--- a/lustre/kernel_patches/patches/raid5-stripe-by-stripe-handling.patch
+++ b/lustre/kernel_patches/patches/raid5-stripe-by-stripe-handling.patch
@@ -2,11 +2,11 @@ Helps to avoid unnesessary reads if request covers full stripe.
 
 Note that reads needed to update parity hurt performance badly
 
-Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
+Index: linux-2.6.9/drivers/md/raid5.c
 ===================================================================
---- linux-2.6.9-78.0.22.orig/drivers/md/raid5.c	2009-05-11 23:23:12.000000000 -0600
-+++ linux-2.6.9-78.0.22/drivers/md/raid5.c	2009-05-11 23:23:13.000000000 -0600
-@@ -1412,6 +1412,11 @@
+--- linux-2.6.9.orig/drivers/md/raid5.c	2006-05-22 00:09:56.000000000 +0400
++++ linux-2.6.9/drivers/md/raid5.c	2006-05-22 00:10:01.000000000 +0400
+@@ -1412,6 +1412,11 @@ static int make_request (request_queue_t
  	sector_t new_sector;
  	sector_t logical_sector, last_sector;
  	struct stripe_head *sh;
@@ -16,9 +16,9 @@ Index: linux-2.6.9-78.0.22/drivers/md/raid5.c
 +	int sectors_per_stripe;
 +	int i, j;
  
- 	if (unlikely(bio_barrier(bi))) {
- 		bio_endio(bi, bi->bi_size, -EOPNOTSUPP);
-@@ -1436,30 +1441,66 @@
+ 	atomic_inc(&conf->in_reqs_in_queue);
+ 
+@@ -1431,30 +1436,66 @@ static int make_request (request_queue_t
  	bi->bi_phys_segments = 1;	/* over-loaded to count active stripes */
  	if ( bio_data_dir(bi) == WRITE )
  		md_write_start(mddev);
diff --git a/lustre/kernel_patches/patches/raid5-zerocopy-rhel5.patch b/lustre/kernel_patches/patches/raid5-zerocopy-rhel5.patch
index 31b825e..e66bf54 100644
--- a/lustre/kernel_patches/patches/raid5-zerocopy-rhel5.patch
+++ b/lustre/kernel_patches/patches/raid5-zerocopy-rhel5.patch
@@ -1,7 +1,8 @@
-diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/drivers/md/raid5.c
---- linux-2.6.18-92.1.22.orig/drivers/md/raid5.c	2009-02-10 13:47:54.000000000 +0800
-+++ linux-2.6.18-92.1.22/drivers/md/raid5.c	2009-02-10 14:44:24.000000000 +0800
-@@ -633,6 +633,9 @@ static int raid5_end_read_request(struct
+Index: linux-2.6.18-128.1.14/drivers/md/raid5.c
+===================================================================
+--- linux-2.6.18-128.1.14.orig/drivers/md/raid5.c	2009-06-19 12:34:46.000000000 -0600
++++ linux-2.6.18-128.1.14/drivers/md/raid5.c	2009-06-19 12:34:50.000000000 -0600
+@@ -633,6 +633,9 @@
  		clear_buffer_uptodate(bh);
  	}
  #endif
@@ -11,7 +12,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  	clear_bit(R5_LOCKED, &sh->dev[i].flags);
  	set_bit(STRIPE_HANDLE, &sh->state);
  	release_stripe(sh);
-@@ -671,6 +674,10 @@ static int raid5_end_write_request (stru
+@@ -669,6 +672,10 @@
  
  	rdev_dec_pending(conf->disks[i].rdev, conf->mddev);
  	
@@ -21,8 +22,8 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
 +	}
  	clear_bit(R5_LOCKED, &sh->dev[i].flags);
  	set_bit(STRIPE_HANDLE, &sh->state);
- 	__release_stripe(conf, sh);
-@@ -911,7 +918,27 @@ static sector_t compute_blocknr(struct s
+ 	release_stripe(sh);
+@@ -910,7 +917,27 @@
  	return r_sector;
  }
  
@@ -50,7 +51,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  
  /*
   * Copy data between a page in the stripe cache, and one or more bion
-@@ -1003,8 +1030,9 @@ static void compute_parity5(struct strip
+@@ -1002,8 +1029,9 @@
  {
  	raid5_conf_t *conf = sh->raid_conf;
  	int i, pd_idx = sh->pd_idx, disks = sh->disks, count;
@@ -61,7 +62,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  
  	PRINTK("compute_parity5, stripe %llu, method %d\n",
  		(unsigned long long)sh->sector, method);
-@@ -1054,34 +1082,92 @@ static void compute_parity5(struct strip
+@@ -1053,34 +1081,92 @@
  		count = 1;
  	}
  	
@@ -171,7 +172,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  	}
  	if (count != 1)
  		xor_block(count, STRIPE_SIZE, ptr);
-@@ -1098,6 +1184,7 @@ static void compute_parity6(struct strip
+@@ -1097,6 +1183,7 @@
  	raid6_conf_t *conf = sh->raid_conf;
  	int i, pd_idx = sh->pd_idx, qd_idx, d0_idx, disks = conf->raid_disks, count;
  	struct bio *chosen;
@@ -179,7 +180,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  	/**** FIX THIS: This could be very bad if disks is close to 256 ****/
  	void *ptrs[disks];
  
-@@ -1127,18 +1214,49 @@ static void compute_parity6(struct strip
+@@ -1126,18 +1213,49 @@
  		BUG();		/* Not implemented yet */
  	}
  
@@ -238,7 +239,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  
  //	switch(method) {
  //	case RECONSTRUCT_WRITE:
-@@ -1149,8 +1267,12 @@ static void compute_parity6(struct strip
+@@ -1148,8 +1266,12 @@
  		count = 0;
  		i = d0_idx;
  		do {
@@ -253,7 +254,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  				printk("block %d/%d not uptodate on parity calc\n", i,count);
  			i = raid6_next_disk(i, disks);
  		} while ( i != d0_idx );
-@@ -1599,7 +1721,8 @@ static void handle_stripe5(struct stripe
+@@ -1596,7 +1718,8 @@
  		if (sh->dev[i].written) {
  		    dev = &sh->dev[i];
  		    if (!test_bit(R5_LOCKED, &dev->flags) &&
@@ -263,7 +264,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  			/* We can return any write requests */
  			    struct bio *wbi, *wbi2;
  			    int bitmap_end = 0;
-@@ -1607,6 +1730,7 @@ static void handle_stripe5(struct stripe
+@@ -1604,6 +1727,7 @@
  			    spin_lock_irq(&conf->device_lock);
  			    wbi = dev->written;
  			    dev->written = NULL;
@@ -271,7 +272,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  			    while (wbi && wbi->bi_sector < dev->sector + STRIPE_SECTORS) {
  				    wbi2 = r5_next_bio(wbi, dev->sector);
  				    if (--wbi->bi_phys_segments == 0) {
-@@ -1970,6 +2094,15 @@ static void handle_stripe5(struct stripe
+@@ -1967,6 +2091,15 @@
  				set_bit(STRIPE_DEGRADED, &sh->state);
  			PRINTK("skip op %ld on disc %d for sector %llu\n",
  				bi->bi_rw, i, (unsigned long long)sh->sector);
@@ -287,7 +288,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  			clear_bit(R5_LOCKED, &sh->dev[i].flags);
  			set_bit(STRIPE_HANDLE, &sh->state);
  		}
-@@ -2175,7 +2308,8 @@ static void handle_stripe6(struct stripe
+@@ -2172,7 +2305,8 @@
  			if (sh->dev[i].written) {
  				dev = &sh->dev[i];
  				if (!test_bit(R5_LOCKED, &dev->flags) &&
@@ -297,7 +298,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  					/* We can return any write requests */
  					int bitmap_end = 0;
  					struct bio *wbi, *wbi2;
-@@ -2184,6 +2318,7 @@ static void handle_stripe6(struct stripe
+@@ -2181,6 +2315,7 @@
  					spin_lock_irq(&conf->device_lock);
  					wbi = dev->written;
  					dev->written = NULL;
@@ -305,7 +306,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  					while (wbi && wbi->bi_sector < dev->sector + STRIPE_SECTORS) {
  						wbi2 = r5_next_bio(wbi, dev->sector);
  						if (--wbi->bi_phys_segments == 0) {
-@@ -2535,6 +2670,15 @@ static void handle_stripe6(struct stripe
+@@ -2532,6 +2667,15 @@
  				set_bit(STRIPE_DEGRADED, &sh->state);
  			PRINTK("skip op %ld on disc %d for sector %llu\n",
  				bi->bi_rw, i, (unsigned long long)sh->sector);
@@ -321,7 +322,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  			clear_bit(R5_LOCKED, &sh->dev[i].flags);
  			set_bit(STRIPE_HANDLE, &sh->state);
  		}
-@@ -3456,6 +3600,9 @@ static int run(mddev_t *mddev)
+@@ -3449,6 +3593,9 @@
  	mddev->queue->max_phys_segments = conf->chunk_size * conf->previous_raid_disks >> PAGE_SHIFT;
  	mddev->queue->max_hw_segments = conf->chunk_size * conf->previous_raid_disks >> PAGE_SHIFT;;
  
@@ -331,7 +332,7 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  	return 0;
  abort:
  	if (conf) {
-@@ -3542,9 +3689,11 @@ static void status (struct seq_file *seq
+@@ -3535,9 +3682,11 @@
  			atomic_read(&conf->handled_in_raid5d),
  			atomic_read(&conf->out_of_stripes),
  			atomic_read(&conf->handle_called));
@@ -345,10 +346,11 @@ diff -pur linux-2.6.18-92.1.22.orig/drivers/md/raid5.c linux-2.6.18-92.1.22/driv
  	seq_printf (seq, "\n\t\t%u delayed, %u bit delayed, %u active, queues: %u in, %u out\n",
  			atomic_read(&conf->delayed), atomic_read(&conf->bit_delayed),
  			atomic_read(&conf->active_stripes),
-diff -pur linux-2.6.18-92.1.22.orig/include/linux/backing-dev.h linux-2.6.18-92.1.22/include/linux/backing-dev.h
---- linux-2.6.18-92.1.22.orig/include/linux/backing-dev.h	2009-02-10 13:47:54.000000000 +0800
-+++ linux-2.6.18-92.1.22/include/linux/backing-dev.h	2009-02-10 14:44:14.000000000 +0800
-@@ -48,6 +48,7 @@ struct backing_dev_info {
+Index: linux-2.6.18-128.1.14/include/linux/backing-dev.h
+===================================================================
+--- linux-2.6.18-128.1.14.orig/include/linux/backing-dev.h	2009-06-19 12:33:11.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/backing-dev.h	2009-06-19 12:34:50.000000000 -0600
+@@ -48,6 +48,7 @@
  #define BDI_CAP_READ_MAP	0x00000010	/* Can be mapped for reading */
  #define BDI_CAP_WRITE_MAP	0x00000020	/* Can be mapped for writing */
  #define BDI_CAP_EXEC_MAP	0x00000040	/* Can be mapped for execution */
@@ -356,7 +358,7 @@ diff -pur linux-2.6.18-92.1.22.orig/include/linux/backing-dev.h linux-2.6.18-92.
  #define BDI_CAP_VMFLAGS \
  	(BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
  
-@@ -94,11 +95,18 @@ static inline int bdi_rw_congested(struc
+@@ -94,11 +95,18 @@
  #define bdi_cap_account_dirty(bdi) \
  	(!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY))
  
@@ -375,18 +377,19 @@ diff -pur linux-2.6.18-92.1.22.orig/include/linux/backing-dev.h linux-2.6.18-92.
 +
  
  #endif		/* _LINUX_BACKING_DEV_H */
-diff -pur linux-2.6.18-92.1.22.orig/include/linux/page-flags.h linux-2.6.18-92.1.22/include/linux/page-flags.h
---- linux-2.6.18-92.1.22.orig/include/linux/page-flags.h	2009-02-10 13:47:54.000000000 +0800
-+++ linux-2.6.18-92.1.22/include/linux/page-flags.h	2009-02-10 14:44:14.000000000 +0800
-@@ -86,6 +86,7 @@
- #define PG_reclaim		17	/* To be reclaimed asap */
+Index: linux-2.6.18-128.1.14/include/linux/page-flags.h
+===================================================================
+--- linux-2.6.18-128.1.14.orig/include/linux/page-flags.h	2009-06-19 12:33:11.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/page-flags.h	2009-06-19 12:34:50.000000000 -0600
+@@ -87,6 +87,7 @@
  #define PG_nosave_free		18	/* Free, should not be written */
  #define PG_buddy		19	/* Page is free, on buddy lists */
-+#define PG_constant		20	/* To mark if the page is constant */
+ #define PG_gup			20	/* Page pin may be because of gup */
++#define PG_constant		21	/* To mark if the page is constant */
  #define PG_xpmem		27	/* Testing for xpmem. */
  
  /* PG_owner_priv_1 users should have descriptive aliases */
-@@ -283,6 +284,14 @@
+@@ -288,6 +289,14 @@
  
  struct page;	/* forward declaration */
  
@@ -401,10 +404,11 @@ diff -pur linux-2.6.18-92.1.22.orig/include/linux/page-flags.h linux-2.6.18-92.1
  int test_clear_page_dirty(struct page *page);
  int test_clear_page_writeback(struct page *page);
  int test_set_page_writeback(struct page *page);
-diff -pur linux-2.6.18-92.1.22.orig/include/linux/raid/raid5.h linux-2.6.18-92.1.22/include/linux/raid/raid5.h
---- linux-2.6.18-92.1.22.orig/include/linux/raid/raid5.h	2009-02-10 13:47:54.000000000 +0800
-+++ linux-2.6.18-92.1.22/include/linux/raid/raid5.h	2009-02-10 14:44:14.000000000 +0800
-@@ -156,8 +156,9 @@ struct stripe_head {
+Index: linux-2.6.18-128.1.14/include/linux/raid/raid5.h
+===================================================================
+--- linux-2.6.18-128.1.14.orig/include/linux/raid/raid5.h	2009-06-19 12:34:42.000000000 -0600
++++ linux-2.6.18-128.1.14/include/linux/raid/raid5.h	2009-06-19 12:34:50.000000000 -0600
+@@ -156,8 +156,9 @@
  #define	R5_Overlap	7	/* There is a pending overlapping request on this block */
  #define	R5_ReadError	8	/* seen a read error here recently */
  #define	R5_ReWrite	9	/* have tried to over-write the readerror */
@@ -415,9 +419,10 @@ diff -pur linux-2.6.18-92.1.22.orig/include/linux/raid/raid5.h linux-2.6.18-92.1
  /*
   * Write method
   */
-diff -pur linux-2.6.18-92.1.22.orig/mm/filemap.c linux-2.6.18-92.1.22/mm/filemap.c
---- linux-2.6.18-92.1.22.orig/mm/filemap.c	2009-02-10 13:47:54.000000000 +0800
-+++ linux-2.6.18-92.1.22/mm/filemap.c	2009-02-10 14:44:14.000000000 +0800
+Index: linux-2.6.18-128.1.14/mm/filemap.c
+===================================================================
+--- linux-2.6.18-128.1.14.orig/mm/filemap.c	2009-06-19 12:33:11.000000000 -0600
++++ linux-2.6.18-128.1.14/mm/filemap.c	2009-06-19 12:34:50.000000000 -0600
 @@ -30,6 +30,7 @@
  #include <linux/security.h>
  #include <linux/syscalls.h>
@@ -426,7 +431,7 @@ diff -pur linux-2.6.18-92.1.22.orig/mm/filemap.c linux-2.6.18-92.1.22/mm/filemap
  #include "filemap.h"
  #include "internal.h"
  
-@@ -566,11 +567,55 @@ void end_page_writeback(struct page *pag
+@@ -567,11 +568,55 @@
  		if (!test_clear_page_writeback(page))
  			BUG();
  	}
diff --git a/lustre/kernel_patches/patches/remove-suid-2.6-suse.patch b/lustre/kernel_patches/patches/remove-suid-2.6-suse.patch
index 495f228..4a4e10f 100644
--- a/lustre/kernel_patches/patches/remove-suid-2.6-suse.patch
+++ b/lustre/kernel_patches/patches/remove-suid-2.6-suse.patch
@@ -1,24 +1,22 @@
 --- linux-2.6.5-7.141/mm/filemap.c.orig	2005-02-18 14:53:26.000000000 +0200
 +++ linux-2.6.5-7.141/mm/filemap.c	2005-02-18 22:37:28.727492096 +0200
-@@ -1816,6 +1816,21 @@
- int __remove_suid(struct dentry *dentry, int kill)
- {
-	struct iattr newattrs;
-+	struct inode_operations *op = dentry->d_inode->i_op;
+@@ -1816,6 +1816,19 @@ int remove_suid(struct dentry *dentry)
+ 
+ 	if (unlikely(kill && !capable(CAP_FSETID))) {
+ 		struct iattr newattrs;
++		struct inode_operations *op = dentry->d_inode->i_op;
 +
-+	if (op && op->setattr_raw) {
-+		int result;
-+		mode_t mode = dentry->d_inode->i_mode;
-+		newattrs.ia_mode = mode & ~S_ISUID;
-+		if (kill & ATTR_KILL_SGID)
-+			newattrs.ia_mode &= ~S_ISGID;
++		if (op && op->setattr_raw) {
++			newattrs.ia_mode = mode & ~S_ISUID;
++			if (kill & ATTR_KILL_SGID)
++				newattrs.ia_mode &= ~S_ISGID;
 +
-+		newattrs.ia_valid = ATTR_FORCE | ATTR_MODE;
-+		result = op->setattr_raw(dentry->d_inode, &newattrs);
-+		/* the file system wants to use normal vfs path now */
-+		if (result != -EOPNOTSUPP)
-+			return result;
-+	}
++			newattrs.ia_valid = ATTR_FORCE | ATTR_MODE;
++			result = op->setattr_raw(dentry->d_inode, &newattrs);
++			/* the file system wants to use normal vfs path now */
++			if (result != -EOPNOTSUPP)
++				return result;
++		}
  
-	newattrs.ia_valid = ATTR_FORCE | kill;
-	return notify_change(dentry, &newattrs);
+ 		newattrs.ia_valid = ATTR_FORCE | kill;
+ 		result = notify_change(dentry, &newattrs);
diff --git a/lustre/kernel_patches/patches/sd_iostats-2.6-rhel5.patch b/lustre/kernel_patches/patches/sd_iostats-2.6-rhel5.patch
index d0cc6f6..d15a630 100644
--- a/lustre/kernel_patches/patches/sd_iostats-2.6-rhel5.patch
+++ b/lustre/kernel_patches/patches/sd_iostats-2.6-rhel5.patch
@@ -1,8 +1,8 @@
-Index: linux-2.6.18-53.1.21/drivers/scsi/Kconfig
+Index: linux-2.6.18-128.1.14/drivers/scsi/Kconfig
 ===================================================================
---- linux-2.6.18-53.1.21.orig/drivers/scsi/Kconfig
-+++ linux-2.6.18-53.1.21/drivers/scsi/Kconfig
-@@ -66,6 +66,14 @@ config BLK_DEV_SD
+--- linux-2.6.18-128.1.14.orig/drivers/scsi/Kconfig	2009-06-19 12:33:12.000000000 -0600
++++ linux-2.6.18-128.1.14/drivers/scsi/Kconfig	2009-06-19 12:34:05.000000000 -0600
+@@ -71,6 +71,14 @@
  	  In this case, do not compile the driver for your SCSI host adapter
  	  (below) as a module either.
  
@@ -17,10 +17,10 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/Kconfig
  config CHR_DEV_ST
  	tristate "SCSI tape support"
  	depends on SCSI
-Index: linux-2.6.18-53.1.21/drivers/scsi/scsi_proc.c
+Index: linux-2.6.18-128.1.14/drivers/scsi/scsi_proc.c
 ===================================================================
---- linux-2.6.18-53.1.21.orig/drivers/scsi/scsi_proc.c
-+++ linux-2.6.18-53.1.21/drivers/scsi/scsi_proc.c
+--- linux-2.6.18-128.1.14.orig/drivers/scsi/scsi_proc.c	2009-06-19 12:33:12.000000000 -0600
++++ linux-2.6.18-128.1.14/drivers/scsi/scsi_proc.c	2009-06-19 12:34:05.000000000 -0600
 @@ -40,7 +40,8 @@
  /* 4K page size, but our output routines, use some slack for overruns */
  #define PROC_BLOCK_SIZE (3*1024)
@@ -31,10 +31,10 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/scsi_proc.c
  
  /* Protect sht->present and sht->proc_dir */
  static DEFINE_MUTEX(global_host_template_mutex);
-Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
+Index: linux-2.6.18-128.1.14/drivers/scsi/sd.c
 ===================================================================
---- linux-2.6.18-53.1.21.orig/drivers/scsi/sd.c
-+++ linux-2.6.18-53.1.21/drivers/scsi/sd.c
+--- linux-2.6.18-128.1.14.orig/drivers/scsi/sd.c	2009-06-19 12:33:12.000000000 -0600
++++ linux-2.6.18-128.1.14/drivers/scsi/sd.c	2009-06-19 12:34:05.000000000 -0600
 @@ -62,6 +62,63 @@
  
  #include "scsi_logging.h"
@@ -99,7 +99,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  /*
   * More than enough for everybody ;)  The huge number of majors
   * is a leftover from 16bit dev_t days, we don't really need that
-@@ -126,6 +183,9 @@ struct scsi_disk {
+@@ -126,6 +183,9 @@
  	unsigned	WCE : 1;	/* state of disk WCE bit */
  	unsigned	RCD : 1;	/* state of disk RCD bit, unused */
  	unsigned	DPOFUA : 1;	/* state of disk DPOFUA bit */
@@ -109,7 +109,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  };
  #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
  
-@@ -557,6 +617,8 @@ static int sd_init_command(struct scsi_c
+@@ -557,6 +617,8 @@
  	 */
  	SCpnt->done = sd_rw_intr;
  
@@ -118,7 +118,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  	/*
  	 * This indicates that the command is ready from our end to be
  	 * queued.
-@@ -1040,6 +1102,7 @@ static void sd_rw_intr(struct scsi_cmnd 
+@@ -1038,6 +1100,7 @@
  		break;
  	}
   out:
@@ -126,7 +126,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  	scsi_io_completion(SCpnt, good_bytes);
  }
  
-@@ -1735,6 +1798,36 @@ static int sd_probe(struct device *dev)
+@@ -1733,6 +1796,36 @@
  	if (sdp->removable)
  		gd->flags |= GENHD_FL_REMOVABLE;
  
@@ -163,7 +163,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  	dev_set_drvdata(dev, sdkp);
  	add_disk(gd);
  
-@@ -1778,6 +1871,366 @@ static int sd_remove(struct device *dev)
+@@ -1776,6 +1869,366 @@
  	return 0;
  }
  
@@ -530,7 +530,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  /**
   *	scsi_disk_release - Called to free the scsi_disk structure
   *	@cdev: pointer to embedded class device
-@@ -1796,10 +2249,16 @@ static void scsi_disk_release(struct cla
+@@ -1794,10 +2247,16 @@
  	idr_remove(&sd_index_idr, sdkp->index);
  	spin_unlock(&sd_index_lock);
  
@@ -548,7 +548,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  	kfree(sdkp);
  }
  
-@@ -1907,6 +2366,7 @@ done:
+@@ -1905,6 +2364,7 @@
  static int __init init_sd(void)
  {
  	int majors = 0, i;
@@ -556,7 +556,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  
  	SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n"));
  
-@@ -1917,9 +2377,13 @@ static int __init init_sd(void)
+@@ -1915,9 +2375,13 @@
  	if (!majors)
  		return -ENODEV;
  
@@ -571,7 +571,7 @@ Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
  }
  
  /**
-@@ -1938,6 +2402,7 @@ static void __exit exit_sd(void)
+@@ -1936,6 +2400,7 @@
  		unregister_blkdev(sd_major(i), "sd");
  
  	class_unregister(&sd_disk_class);
diff --git a/lustre/kernel_patches/patches/sd_iostats-2.6-sles10.patch b/lustre/kernel_patches/patches/sd_iostats-2.6-sles10.patch
new file mode 100644
index 0000000..ced2c53
--- /dev/null
+++ b/lustre/kernel_patches/patches/sd_iostats-2.6-sles10.patch
@@ -0,0 +1,581 @@
+Index: linux-2.6.18-53.1.21/drivers/scsi/Kconfig
+===================================================================
+--- linux-2.6.18-53.1.21.orig/drivers/scsi/Kconfig
++++ linux-2.6.18-53.1.21/drivers/scsi/Kconfig
+@@ -66,6 +66,14 @@ config BLK_DEV_SD
+ 	   polling I/O.  If it doesn't, LKCD will fall back to ordinary
+ 	   interrupt-driven I/O.
+ 
++config SD_IOSTATS
++   bool "Enable SCSI disk I/O stats"
++   depends on BLK_DEV_SD
++   default y
++   ---help---
++     This enables SCSI disk I/O stats collection.  You must also enable
++     /proc file system support if you want this feature.
++
+ config CHR_DEV_ST
+ 	tristate "SCSI tape support"
+ 	depends on SCSI
+Index: linux-2.6.18-53.1.21/drivers/scsi/scsi_proc.c
+===================================================================
+--- linux-2.6.18-53.1.21.orig/drivers/scsi/scsi_proc.c
++++ linux-2.6.18-53.1.21/drivers/scsi/scsi_proc.c
+@@ -40,7 +40,8 @@
+ /* 4K page size, but our output routines, use some slack for overruns */
+ #define PROC_BLOCK_SIZE (3*1024)
+ 
+-static struct proc_dir_entry *proc_scsi;
++struct proc_dir_entry *proc_scsi;
++EXPORT_SYMBOL(proc_scsi);
+ 
+ /* Protect sht->present and sht->proc_dir */
+ static DEFINE_MUTEX(global_host_template_mutex);
+Index: linux-2.6.18-53.1.21/drivers/scsi/sd.c
+===================================================================
+--- linux-2.6.18-53.1.21.orig/drivers/scsi/sd.c
++++ linux-2.6.18-53.1.21/drivers/scsi/sd.c
+@@ -62,6 +62,63 @@
+ 
+ #include "scsi_logging.h"
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++# include <linux/proc_fs.h>
++# include <linux/seq_file.h>
++
++typedef struct {
++	unsigned long long iostat_size;
++	unsigned long long iostat_count;
++} iostat_counter_t;
++
++#define IOSTAT_NCOUNTERS 16
++typedef struct {
++	iostat_counter_t	iostat_read_histogram[IOSTAT_NCOUNTERS];
++	iostat_counter_t	iostat_write_histogram[IOSTAT_NCOUNTERS];
++	struct timeval		iostat_timeval;
++
++	/* queue depth: how well the pipe is filled up */
++	unsigned long long	iostat_queue_ticks[IOSTAT_NCOUNTERS];
++	unsigned long long	iostat_queue_ticks_sum;
++	unsigned long		iostat_queue_depth;
++	unsigned long		iostat_queue_stamp;
++
++	/* seeks: how linear the traffic is */
++	unsigned long long	iostat_next_sector;
++	unsigned long long	iostat_seek_sectors;
++	unsigned long long	iostat_seeks;
++	unsigned long long	iostat_sectors;
++	unsigned long long	iostat_reqs;
++	unsigned long		iostat_read_reqs;
++	unsigned long		iostat_write_reqs;
++
++	/* process time: how long it takes to process requests */
++	unsigned long		iostat_rtime[IOSTAT_NCOUNTERS];
++	unsigned long		iostat_wtime[IOSTAT_NCOUNTERS];
++
++	/* queue time: how long process spent in elevator's queue */
++	unsigned long		iostat_rtime_in_queue[IOSTAT_NCOUNTERS];
++	unsigned long		iostat_wtime_in_queue[IOSTAT_NCOUNTERS];
++
++	/* must be the last field, as it's used to know size to be memset'ed */
++	spinlock_t		iostat_lock;
++} ____cacheline_aligned_in_smp iostat_stats_t;
++
++struct proc_dir_entry *sd_iostats_procdir = NULL;
++char sd_iostats_procdir_name[] = "sd_iostats";
++static struct file_operations sd_iostats_proc_fops;
++
++extern void sd_iostats_init(void);
++extern void sd_iostats_fini(void);
++void sd_iostats_start_req(struct scsi_cmnd *SCpnt);
++void sd_iostats_finish_req(struct scsi_cmnd *SCpnt);
++#else
++static inline void sd_iostats_init(void) {}
++static inline void sd_iostats_fini(void) {}
++static inline void sd_iostats_start_req(struct scsi_cmnd *SCpnt) {}
++static inline void sd_iostats_finish_req(struct scsi_cmnd *SCpnt) {}
++#endif
++
+ /*
+  * More than enough for everybody ;)  The huge number of majors
+  * is a leftover from 16bit dev_t days, we don't really need that
+@@ -126,6 +183,9 @@ struct scsi_disk {
+ 	unsigned	WCE : 1;	/* state of disk WCE bit */
+ 	unsigned	RCD : 1;	/* state of disk RCD bit, unused */
+ 	unsigned	DPOFUA : 1;	/* state of disk DPOFUA bit */
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++	iostat_stats_t	*stats;		/* scsi disk statistics */
++#endif
+ };
+ #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
+ 
+@@ -557,6 +617,8 @@ static int sd_init_command(struct scsi_c
+ 	 */
+ 	SCpnt->done = sd_rw_intr;
+ 
++	sd_iostats_start_req(SCpnt);
++
+ 	/*
+ 	 * This indicates that the command is ready from our end to be
+ 	 * queued.
+@@ -1040,6 +1102,7 @@ static void sd_rw_intr(struct scsi_cmnd 
+ 		break;
+ 	}
+  out:
++	sd_iostats_finish_req(SCpnt);
+ 	scsi_io_completion(SCpnt, good_bytes);
+ }
+ 
+@@ -1735,6 +1798,36 @@ static int sd_probe(struct device *dev)
+ 	if (sdp->removable)
+ 		gd->flags |= GENHD_FL_REMOVABLE;
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++	sdkp->stats = kzalloc(sizeof(iostat_stats_t), GFP_KERNEL);
++	if (!sdkp->stats) {
++		printk(KERN_WARNING "cannot allocate iostat structure for"
++				    "%s\n", gd->disk_name);
++	} else {
++		do_gettimeofday(&sdkp->stats->iostat_timeval);
++		sdkp->stats->iostat_queue_stamp = jiffies;
++		spin_lock_init(&sdkp->stats->iostat_lock);
++		if (sd_iostats_procdir) {
++			struct proc_dir_entry *pde;
++			pde = create_proc_entry(gd->disk_name, S_IRUGO | S_IWUSR,
++					        sd_iostats_procdir);
++			if (!pde) {
++				printk(KERN_WARNING "Can't create /proc/scsi/"
++						    "%s/%s\n",
++						    sd_iostats_procdir_name,
++						    gd->disk_name);
++				kfree(sdkp->stats);
++				sdkp->stats = NULL;
++			} else {
++				pde->proc_fops = &sd_iostats_proc_fops;
++				pde->data = gd;
++			}
++		} else {
++			kfree(sdkp->stats);
++			sdkp->stats = NULL;
++		}
++	}
++#endif
+ 	dev_set_drvdata(dev, sdkp);
+ 	add_disk(gd);
+ 
+@@ -1778,6 +1871,366 @@ static int sd_remove(struct device *dev)
+ 	return 0;
+ }
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++static int
++sd_iostats_seq_show(struct seq_file *seq, void *v)
++{
++	struct timeval     now;
++	struct gendisk *disk = seq->private;
++	iostat_stats_t    *stats;
++	unsigned long long read_len;
++	unsigned long long read_len_tot;
++	unsigned long      read_num;
++	unsigned long      read_num_tot;
++	unsigned long long write_len;
++	unsigned long long write_len_tot;
++	unsigned long      write_num;
++	unsigned long      write_num_tot;
++	int                i;
++	int                maxi;
++
++	stats = scsi_disk(disk)->stats;
++	if (stats == NULL) {
++		printk(KERN_ERR "sd_iostats_seq_show: NULL stats entry\n");
++		BUG();
++	}
++
++	do_gettimeofday(&now);
++	now.tv_sec -= stats->iostat_timeval.tv_sec;
++	now.tv_usec -= stats->iostat_timeval.tv_usec;
++	if (now.tv_usec < 0) {
++		now.tv_usec += 1000000;
++		now.tv_sec--;
++	}
++
++	/* this sampling races with updates */
++	seq_printf(seq, "index:        %lu   snapshot_time:         %lu.%06lu\n",
++			(unsigned long) scsi_disk(disk)->index,
++			now.tv_sec, now.tv_usec);
++
++	for (i = IOSTAT_NCOUNTERS - 1; i > 0; i--)
++		if (stats->iostat_read_histogram[i].iostat_count != 0 ||
++				stats->iostat_write_histogram[i].iostat_count != 0)
++			break;
++	maxi = i;
++
++	seq_printf(seq, "%8s %8s %12s %8s %12s\n", "size", 
++			"reads", "total", "writes", "total");
++
++	read_len_tot = write_len_tot = 0;
++	read_num_tot = write_num_tot = 0;
++	for (i = 0; i <= maxi; i++) {
++		read_len = stats->iostat_read_histogram[i].iostat_size;
++		read_len_tot += read_len;
++		read_num = stats->iostat_read_histogram[i].iostat_count;
++		read_num_tot += read_num;
++
++		write_len = stats->iostat_write_histogram[i].iostat_size;
++		write_len_tot += write_len;
++		write_num = stats->iostat_write_histogram[i].iostat_count;
++		write_num_tot += write_num;
++
++		seq_printf (seq, "%8d %8lu %12llu %8lu %12llu\n", 
++				512<<i, read_num, read_len, write_num, write_len);
++	}
++
++	seq_printf(seq, "%8s %8lu %12llu %8lu %12llu\n\n", "total",
++			read_num_tot, read_len_tot, 
++			write_num_tot, write_len_tot);
++
++	seq_printf(seq, "%8s %8s %8s\n", "qdepth", "ticks", "%");
++	for (i = 0; i < IOSTAT_NCOUNTERS; i++) {
++		unsigned long long ticks, percent;
++		ticks = stats->iostat_queue_ticks[i];
++		if (ticks == 0)
++			continue;
++		percent = stats->iostat_queue_ticks[i] * 100;
++		do_div(percent, stats->iostat_queue_ticks_sum);
++		seq_printf(seq, "%8d %8llu %8llu\n", i, ticks, percent);
++	}
++
++	if (stats->iostat_reqs != 0) {
++		unsigned long long aveseek = 0, percent = 0;
++
++		if (stats->iostat_seeks) {
++			aveseek = stats->iostat_seek_sectors;
++			do_div(aveseek, stats->iostat_seeks);
++			percent = stats->iostat_seeks * 100;
++			do_div(percent, stats->iostat_reqs);
++		}
++
++		seq_printf(seq, "\n%llu sectors in %llu reqs: %llu seek(s) over "
++				"%llu sectors in ave, %llu%% of all reqs\n",
++				stats->iostat_sectors, stats->iostat_reqs,
++				stats->iostat_seeks, aveseek, percent);
++	}
++
++	seq_printf(seq, "\n%16s %8s %8s %8s %8s\n", "process time", "reads",
++			"%%", "writes", "%%");
++	for (i = 0; i < IOSTAT_NCOUNTERS; i++) {
++		unsigned long read_percent = 0, write_percent = 0;
++		if (stats->iostat_wtime[i] == 0 &&
++				stats->iostat_rtime[i] == 0)
++			continue;
++		if (stats->iostat_read_reqs)
++			read_percent = stats->iostat_rtime[i] * 100 / 
++				stats->iostat_read_reqs;
++		if (stats->iostat_write_reqs)
++			write_percent = stats->iostat_wtime[i] * 100 / 
++				stats->iostat_write_reqs;
++		seq_printf(seq, "%16u %8lu %8lu %8lu %8lu\n",
++				jiffies_to_msecs(((1UL << i) >> 1) << 1),
++				stats->iostat_rtime[i], read_percent,
++				stats->iostat_wtime[i], write_percent);
++	}
++
++	seq_printf(seq, "\n%16s %8s %8s %8s %8s\n", "time in queue", "reads",
++			"%%", "writes", "%%");
++	for (i = 0; i < IOSTAT_NCOUNTERS; i++) {
++		unsigned long read_percent = 0, write_percent = 0;
++		if (stats->iostat_wtime_in_queue[i] == 0 &&
++				stats->iostat_rtime_in_queue[i] == 0)
++			continue;
++		if (stats->iostat_read_reqs)
++			read_percent = stats->iostat_rtime_in_queue[i] * 100 / 
++				stats->iostat_read_reqs;
++		if (stats->iostat_write_reqs)
++			write_percent = stats->iostat_wtime_in_queue[i] * 100 / 
++				stats->iostat_write_reqs;
++		seq_printf(seq, "%16u %8lu %8lu %8lu %8lu\n",
++				jiffies_to_msecs(((1UL << i) >> 1) << 1),
++				stats->iostat_rtime_in_queue[i],
++				read_percent,
++				stats->iostat_wtime_in_queue[i],
++				write_percent);
++	}
++
++	return 0;
++}
++
++static void *
++sd_iostats_seq_start(struct seq_file *p, loff_t *pos)
++{
++	return (*pos == 0) ? (void *)1 : NULL;
++}
++
++static void *
++sd_iostats_seq_next(struct seq_file *p, void *v, loff_t *pos)
++{
++	++*pos;
++	return NULL;
++}
++
++static void
++sd_iostats_seq_stop(struct seq_file *p, void *v)
++{
++}
++
++static struct seq_operations sd_iostats_seqops = {
++	.start = sd_iostats_seq_start,
++	.stop  = sd_iostats_seq_stop,
++	.next  = sd_iostats_seq_next,
++	.show  = sd_iostats_seq_show,
++};
++
++static int
++sd_iostats_seq_open (struct inode *inode, struct file *file)
++{
++	int rc;
++
++	rc = seq_open(file, &sd_iostats_seqops);
++	if (rc != 0)
++		return rc;
++
++	((struct seq_file *)file->private_data)->private = PDE(inode)->data;
++	return 0;
++}
++
++static ssize_t
++sd_iostats_seq_write(struct file *file, const char *buffer,
++		     size_t len, loff_t *off)
++{
++	struct seq_file   *seq = file->private_data;
++	struct gendisk *disk = seq->private;
++	iostat_stats_t    *stats = scsi_disk(disk)->stats;
++	unsigned long      flags;
++	unsigned long      qdepth;
++
++
++	spin_lock_irqsave (&stats->iostat_lock, flags);
++	qdepth = stats->iostat_queue_depth;
++	memset (stats, 0, offsetof(iostat_stats_t, iostat_lock));
++	do_gettimeofday(&stats->iostat_timeval);
++	stats->iostat_queue_stamp = jiffies;
++	stats->iostat_queue_depth = qdepth;
++	spin_unlock_irqrestore (&stats->iostat_lock, flags);
++
++	return len;
++}
++
++static struct file_operations sd_iostats_proc_fops = {
++	.owner   = THIS_MODULE,
++	.open    = sd_iostats_seq_open,
++	.read    = seq_read,
++	.write   = sd_iostats_seq_write,
++	.llseek  = seq_lseek,
++	.release = seq_release,
++};
++
++extern struct proc_dir_entry *proc_scsi;
++
++void
++sd_iostats_init(void)
++{
++	if (proc_scsi == NULL) {
++		printk(KERN_WARNING "No access to sd iostats: "
++			"proc_scsi is NULL\n");
++		return;
++	}
++
++	sd_iostats_procdir = create_proc_entry(sd_iostats_procdir_name,
++					       S_IFDIR | S_IRUGO | S_IXUGO,
++					        proc_scsi);
++	if (sd_iostats_procdir == NULL) {
++		printk(KERN_WARNING "No access to sd iostats: "
++			"can't create /proc/scsi/%s\n", sd_iostats_procdir_name);
++		return;
++	}
++}
++
++void sd_iostats_fini(void)
++{
++	if (proc_scsi != NULL && sd_iostats_procdir != NULL)
++		remove_proc_entry(sd_iostats_procdir_name, proc_scsi);
++
++	sd_iostats_procdir = NULL;
++}
++
++void sd_iostats_finish_req(struct scsi_cmnd *SCpnt)
++{
++	struct request		*rq = SCpnt->request;
++	iostat_stats_t		*stats;
++	unsigned long		*tcounter;
++	int			tbucket;
++	int			tmp;
++	unsigned long		irqflags;
++	unsigned long		i;
++
++	stats = scsi_disk(rq->rq_disk)->stats;
++	if (stats == NULL)
++		return;
++
++	tmp = jiffies - rq->start_time;
++	for (tbucket = 0; tmp > 1; tbucket++)
++		tmp >>= 1;
++	if (tbucket >= IOSTAT_NCOUNTERS)
++		tbucket = IOSTAT_NCOUNTERS - 1;
++	//printk("%u ticks in D to %u\n", jiffies - rq->start_time, tbucket);
++
++	tcounter = rq_data_dir(rq) == WRITE ?
++		&stats->iostat_wtime[tbucket] : &stats->iostat_rtime[tbucket];
++
++	spin_lock_irqsave(&stats->iostat_lock, irqflags);
++
++	/* update delay stats */
++	(*tcounter)++;
++
++	/* update queue depth stats */
++	i = stats->iostat_queue_depth;
++	if (i >= IOSTAT_NCOUNTERS)
++		i = IOSTAT_NCOUNTERS - 1;
++	stats->iostat_queue_ticks[i] += jiffies - stats->iostat_queue_stamp;
++	stats->iostat_queue_ticks_sum += jiffies - stats->iostat_queue_stamp;
++	BUG_ON(stats->iostat_queue_depth == 0);
++	stats->iostat_queue_depth--;
++
++	/* update seek stats. XXX: not sure about nr_sectors */
++	stats->iostat_sectors += rq->nr_sectors;
++	stats->iostat_reqs++;
++	if (rq->sector != stats->iostat_next_sector) {
++		stats->iostat_seek_sectors +=
++			rq->sector > stats->iostat_next_sector ?
++			rq->sector - stats->iostat_next_sector :
++			stats->iostat_next_sector - rq->sector;
++		stats->iostat_seeks++;
++	}
++	stats->iostat_next_sector = rq->sector + rq->nr_sectors;
++
++	stats->iostat_queue_stamp = jiffies;
++
++	spin_unlock_irqrestore(&stats->iostat_lock, irqflags);
++}
++
++void sd_iostats_start_req(struct scsi_cmnd *SCpnt)
++{
++	struct request		*rq = SCpnt->request;
++	iostat_stats_t		*stats;
++	iostat_counter_t	*counter;
++	int			bucket;
++	int			tbucket;
++	int			tmp;
++	unsigned long		irqflags;
++	unsigned long		i;
++	int			nsect;
++
++	stats = scsi_disk(rq->rq_disk)->stats;
++	if (stats == NULL)
++		return;
++
++	nsect = SCpnt->request_bufflen >> 9;
++	for (bucket = 0, tmp = nsect; tmp > 1; bucket++)
++		tmp >>= 1;
++
++	if (bucket >= IOSTAT_NCOUNTERS) {
++		printk (KERN_ERR "sd_iostats_bump: nsect %d too big\n", nsect);
++		BUG();
++	}
++
++	counter = rq_data_dir(rq) == WRITE ?
++		&stats->iostat_write_histogram[bucket] :
++		&stats->iostat_read_histogram[bucket];
++
++	tmp = jiffies - rq->start_time;
++	for (tbucket = 0; tmp > 1; tbucket++)
++		tmp >>= 1;
++	if (tbucket >= IOSTAT_NCOUNTERS)
++		tbucket = IOSTAT_NCOUNTERS - 1;
++	//printk("%u ticks in Q to %u\n", jiffies - rq->start_time, tbucket);
++
++	/* an ugly hack to know exact processing time. the right
++	 * solution is to add one more field to struct request
++	 * hopefully it will break nothing ... */
++	rq->start_time = jiffies;
++
++	spin_lock_irqsave(&stats->iostat_lock, irqflags);
++
++	/* update queue depth stats */
++	i = stats->iostat_queue_depth;
++	if (i >= IOSTAT_NCOUNTERS)
++		i = IOSTAT_NCOUNTERS - 1;
++	stats->iostat_queue_ticks[i] += jiffies - stats->iostat_queue_stamp;
++	stats->iostat_queue_ticks_sum += jiffies - stats->iostat_queue_stamp;
++	stats->iostat_queue_depth++;
++
++	/* update delay stats */
++	if (rq_data_dir(rq) == WRITE) {
++		stats->iostat_wtime_in_queue[tbucket]++;
++		stats->iostat_write_reqs++;
++	} else {
++		stats->iostat_rtime_in_queue[tbucket]++;
++		stats->iostat_read_reqs++;
++	}
++
++	/* update size stats */
++	counter->iostat_size += nsect;
++	counter->iostat_count++;
++
++	stats->iostat_queue_stamp = jiffies;
++
++	spin_unlock_irqrestore(&stats->iostat_lock, irqflags);
++}
++#endif
++
+ /**
+  *	scsi_disk_release - Called to free the scsi_disk structure
+  *	@cdev: pointer to embedded class device
+@@ -1796,10 +2249,16 @@ static void scsi_disk_release(struct cla
+ 	idr_remove(&sd_index_idr, sdkp->index);
+ 	spin_unlock(&sd_index_lock);
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++	if (sdkp->stats) {
++		remove_proc_entry(disk->disk_name, sd_iostats_procdir);
++		kfree(sdkp->stats);
++		sdkp->stats = NULL;
++	}
++#endif
+ 	disk->private_data = NULL;
+ 	put_disk(disk);
+ 	put_device(&sdkp->device->sdev_gendev);
+-
+ 	kfree(sdkp);
+ }
+ 
+@@ -1907,6 +2366,7 @@ done:
+ static int __init init_sd(void)
+ {
+ 	int majors = 0, i;
++	int rc = 0;
+ 
+ 	SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n"));
+ 
+@@ -1917,9 +2377,13 @@ static int __init init_sd(void)
+ 	if (!majors)
+ 		return -ENODEV;
+ 
++	sd_iostats_init();
+ 	class_register(&sd_disk_class);
+ 
+-	return scsi_register_driver(&sd_template.gendrv);
++	rc = scsi_register_driver(&sd_template.gendrv);
++	if (rc)
++		sd_iostats_fini();
++	return rc;
+ }
+ 
+ /**
+@@ -1938,6 +2402,7 @@ static void __exit exit_sd(void)
+ 		unregister_blkdev(sd_major(i), "sd");
+ 
+ 	class_unregister(&sd_disk_class);
++	sd_iostats_fini();
+ }
+ 
+ module_init(init_sd);
diff --git a/lustre/kernel_patches/patches/sd_iostats-2.6.27-vanilla.patch b/lustre/kernel_patches/patches/sd_iostats-2.6.27-vanilla.patch
new file mode 100644
index 0000000..33faa8e
--- /dev/null
+++ b/lustre/kernel_patches/patches/sd_iostats-2.6.27-vanilla.patch
@@ -0,0 +1,579 @@
+Index: linux-2.6.27.21-0.1/drivers/scsi/Kconfig
+===================================================================
+--- linux-2.6.27.21-0.1.orig/drivers/scsi/Kconfig	2009-04-23 02:12:56.000000000 -0600
++++ linux-2.6.27.21-0.1/drivers/scsi/Kconfig	2009-05-22 08:38:28.000000000 -0600
+@@ -82,6 +82,14 @@
+ 	  In this case, do not compile the driver for your SCSI host adapter
+ 	  (below) as a module either.
+ 
++config SD_IOSTATS
++   bool "Enable SCSI disk I/O stats"
++   depends on BLK_DEV_SD
++   default y
++   ---help---
++     This enables SCSI disk I/O stats collection.  You must also enable
++     /proc file system support if you want this feature.
++
+ config CHR_DEV_ST
+ 	tristate "SCSI tape support"
+ 	depends on SCSI
+Index: linux-2.6.27.21-0.1/drivers/scsi/scsi_proc.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/drivers/scsi/scsi_proc.c	2009-04-23 02:12:56.000000000 -0600
++++ linux-2.6.27.21-0.1/drivers/scsi/scsi_proc.c	2009-05-22 08:38:28.000000000 -0600
+@@ -40,7 +40,8 @@
+ /* 4K page size, but our output routines, use some slack for overruns */
+ #define PROC_BLOCK_SIZE (3*1024)
+ 
+-static struct proc_dir_entry *proc_scsi;
++struct proc_dir_entry *proc_scsi;
++EXPORT_SYMBOL(proc_scsi);
+ 
+ /* Protect sht->present and sht->proc_dir */
+ static DEFINE_MUTEX(global_host_template_mutex);
+Index: linux-2.6.27.21-0.1/drivers/scsi/sd.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/drivers/scsi/sd.c	2009-04-23 02:12:56.000000000 -0600
++++ linux-2.6.27.21-0.1/drivers/scsi/sd.c	2009-05-22 08:38:28.000000000 -0600
+@@ -108,6 +108,24 @@
+  * object after last put) */
+ static DEFINE_MUTEX(sd_ref_mutex);
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++# include <linux/proc_fs.h>
++# include <linux/seq_file.h>
++struct proc_dir_entry *sd_iostats_procdir = NULL;
++char sd_iostats_procdir_name[] = "sd_iostats";
++static struct file_operations sd_iostats_proc_fops;
++
++extern void sd_iostats_init(void);
++extern void sd_iostats_fini(void);
++void sd_iostats_start_req(struct scsi_cmnd *SCpnt);
++void sd_iostats_finish_req(struct scsi_cmnd *SCpnt);
++#else
++static inline void sd_iostats_init(void) {}
++static inline void sd_iostats_fini(void) {}
++static inline void sd_iostats_start_req(struct scsi_cmnd *SCpnt) {}
++static inline void sd_iostats_finish_req(struct scsi_cmnd *SCpnt) {}
++#endif
++
+ static const char *sd_cache_types[] = {
+ 	"write through", "none", "write back",
+ 	"write back, no read (daft)"
+@@ -571,6 +589,8 @@
+ 	if (sdkp->protection_type || scsi_prot_sg_count(SCpnt))
+ 		sd_dif_op(SCpnt, sdkp->protection_type, scsi_prot_sg_count(SCpnt));
+ 
++	sd_iostats_start_req(SCpnt);
++
+ 	/*
+ 	 * We shouldn't disconnect in the middle of a sector, so with a dumb
+ 	 * host adapter, it's safe to assume that we can at least transfer
+@@ -1091,6 +1111,7 @@
+ 		break;
+ 	}
+  out:
++	sd_iostats_finish_req(SCpnt);
+ 	if (rq_data_dir(SCpnt->request) == READ && scsi_prot_sg_count(SCpnt))
+ 		sd_dif_complete(SCpnt, good_bytes);
+ 
+@@ -1873,6 +1894,36 @@
+ 	if (sdp->removable)
+ 		gd->flags |= GENHD_FL_REMOVABLE;
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++	sdkp->stats = kzalloc(sizeof(iostat_stats_t), GFP_KERNEL);
++	if (!sdkp->stats) {
++		printk(KERN_WARNING "cannot allocate iostat structure for"
++				    "%s\n", gd->disk_name);
++	} else {
++		do_gettimeofday(&sdkp->stats->iostat_timeval);
++		sdkp->stats->iostat_queue_stamp = jiffies;
++		spin_lock_init(&sdkp->stats->iostat_lock);
++		if (sd_iostats_procdir) {
++			struct proc_dir_entry *pde;
++			pde = create_proc_entry(gd->disk_name, S_IRUGO | S_IWUSR,
++					        sd_iostats_procdir);
++			if (!pde) {
++				printk(KERN_WARNING "Can't create /proc/scsi/"
++						    "%s/%s\n",
++						    sd_iostats_procdir_name,
++						    gd->disk_name);
++				kfree(sdkp->stats);
++				sdkp->stats = NULL;
++			} else {
++				pde->proc_fops = &sd_iostats_proc_fops;
++				pde->data = gd;
++			}
++		} else {
++			kfree(sdkp->stats);
++			sdkp->stats = NULL;
++		}
++	}
++#endif
+ 	dev_set_drvdata(dev, sdkp);
+ 	add_disk(gd);
+ 	sd_dif_config_host(sdkp);
+@@ -1923,6 +1974,366 @@
+ 	return 0;
+ }
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++static int
++sd_iostats_seq_show(struct seq_file *seq, void *v)
++{
++	struct timeval     now;
++	struct gendisk *disk = seq->private;
++	iostat_stats_t    *stats;
++	unsigned long long read_len;
++	unsigned long long read_len_tot;
++	unsigned long      read_num;
++	unsigned long      read_num_tot;
++	unsigned long long write_len;
++	unsigned long long write_len_tot;
++	unsigned long      write_num;
++	unsigned long      write_num_tot;
++	int                i;
++	int                maxi;
++
++	stats = scsi_disk(disk)->stats;
++	if (stats == NULL) {
++		printk(KERN_ERR "sd_iostats_seq_show: NULL stats entry\n");
++		BUG();
++	}
++
++	do_gettimeofday(&now);
++	now.tv_sec -= stats->iostat_timeval.tv_sec;
++	now.tv_usec -= stats->iostat_timeval.tv_usec;
++	if (now.tv_usec < 0) {
++		now.tv_usec += 1000000;
++		now.tv_sec--;
++	}
++
++	/* this sampling races with updates */
++	seq_printf(seq, "index:        %lu   snapshot_time:         %lu.%06lu\n",
++			(unsigned long) scsi_disk(disk)->index,
++			now.tv_sec, now.tv_usec);
++
++	for (i = IOSTAT_NCOUNTERS - 1; i > 0; i--)
++		if (stats->iostat_read_histogram[i].iostat_count != 0 ||
++				stats->iostat_write_histogram[i].iostat_count != 0)
++			break;
++	maxi = i;
++
++	seq_printf(seq, "%8s %8s %12s %8s %12s\n", "size", 
++			"reads", "total", "writes", "total");
++
++	read_len_tot = write_len_tot = 0;
++	read_num_tot = write_num_tot = 0;
++	for (i = 0; i <= maxi; i++) {
++		read_len = stats->iostat_read_histogram[i].iostat_size;
++		read_len_tot += read_len;
++		read_num = stats->iostat_read_histogram[i].iostat_count;
++		read_num_tot += read_num;
++
++		write_len = stats->iostat_write_histogram[i].iostat_size;
++		write_len_tot += write_len;
++		write_num = stats->iostat_write_histogram[i].iostat_count;
++		write_num_tot += write_num;
++
++		seq_printf (seq, "%8d %8lu %12llu %8lu %12llu\n", 
++				512<<i, read_num, read_len, write_num, write_len);
++	}
++
++	seq_printf(seq, "%8s %8lu %12llu %8lu %12llu\n\n", "total",
++			read_num_tot, read_len_tot, 
++			write_num_tot, write_len_tot);
++
++	seq_printf(seq, "%8s %8s %8s\n", "qdepth", "ticks", "%");
++	for (i = 0; i < IOSTAT_NCOUNTERS; i++) {
++		unsigned long long ticks, percent;
++		ticks = stats->iostat_queue_ticks[i];
++		if (ticks == 0)
++			continue;
++		percent = stats->iostat_queue_ticks[i] * 100;
++		do_div(percent, stats->iostat_queue_ticks_sum);
++		seq_printf(seq, "%8d %8llu %8llu\n", i, ticks, percent);
++	}
++
++	if (stats->iostat_reqs != 0) {
++		unsigned long long aveseek = 0, percent = 0;
++
++		if (stats->iostat_seeks) {
++			aveseek = stats->iostat_seek_sectors;
++			do_div(aveseek, stats->iostat_seeks);
++			percent = stats->iostat_seeks * 100;
++			do_div(percent, stats->iostat_reqs);
++		}
++
++		seq_printf(seq, "\n%llu sectors in %llu reqs: %llu seek(s) over "
++				"%llu sectors in ave, %llu%% of all reqs\n",
++				stats->iostat_sectors, stats->iostat_reqs,
++				stats->iostat_seeks, aveseek, percent);
++	}
++
++	seq_printf(seq, "\n%16s %8s %8s %8s %8s\n", "process time", "reads",
++			"%%", "writes", "%%");
++	for (i = 0; i < IOSTAT_NCOUNTERS; i++) {
++		unsigned long read_percent = 0, write_percent = 0;
++		if (stats->iostat_wtime[i] == 0 &&
++				stats->iostat_rtime[i] == 0)
++			continue;
++		if (stats->iostat_read_reqs)
++			read_percent = stats->iostat_rtime[i] * 100 / 
++				stats->iostat_read_reqs;
++		if (stats->iostat_write_reqs)
++			write_percent = stats->iostat_wtime[i] * 100 / 
++				stats->iostat_write_reqs;
++		seq_printf(seq, "%16u %8lu %8lu %8lu %8lu\n",
++				jiffies_to_msecs(((1UL << i) >> 1) << 1),
++				stats->iostat_rtime[i], read_percent,
++				stats->iostat_wtime[i], write_percent);
++	}
++
++	seq_printf(seq, "\n%16s %8s %8s %8s %8s\n", "time in queue", "reads",
++			"%%", "writes", "%%");
++	for (i = 0; i < IOSTAT_NCOUNTERS; i++) {
++		unsigned long read_percent = 0, write_percent = 0;
++		if (stats->iostat_wtime_in_queue[i] == 0 &&
++				stats->iostat_rtime_in_queue[i] == 0)
++			continue;
++		if (stats->iostat_read_reqs)
++			read_percent = stats->iostat_rtime_in_queue[i] * 100 / 
++				stats->iostat_read_reqs;
++		if (stats->iostat_write_reqs)
++			write_percent = stats->iostat_wtime_in_queue[i] * 100 / 
++				stats->iostat_write_reqs;
++		seq_printf(seq, "%16u %8lu %8lu %8lu %8lu\n",
++				jiffies_to_msecs(((1UL << i) >> 1) << 1),
++				stats->iostat_rtime_in_queue[i],
++				read_percent,
++				stats->iostat_wtime_in_queue[i],
++				write_percent);
++	}
++
++	return 0;
++}
++
++static void *
++sd_iostats_seq_start(struct seq_file *p, loff_t *pos)
++{
++	return (*pos == 0) ? (void *)1 : NULL;
++}
++
++static void *
++sd_iostats_seq_next(struct seq_file *p, void *v, loff_t *pos)
++{
++	++*pos;
++	return NULL;
++}
++
++static void
++sd_iostats_seq_stop(struct seq_file *p, void *v)
++{
++}
++
++static struct seq_operations sd_iostats_seqops = {
++	.start = sd_iostats_seq_start,
++	.stop  = sd_iostats_seq_stop,
++	.next  = sd_iostats_seq_next,
++	.show  = sd_iostats_seq_show,
++};
++
++static int
++sd_iostats_seq_open (struct inode *inode, struct file *file)
++{
++	int rc;
++
++	rc = seq_open(file, &sd_iostats_seqops);
++	if (rc != 0)
++		return rc;
++
++	((struct seq_file *)file->private_data)->private = PDE(inode)->data;
++	return 0;
++}
++
++static ssize_t
++sd_iostats_seq_write(struct file *file, const char *buffer,
++		     size_t len, loff_t *off)
++{
++	struct seq_file   *seq = file->private_data;
++	struct gendisk *disk = seq->private;
++	iostat_stats_t    *stats = scsi_disk(disk)->stats;
++	unsigned long      flags;
++	unsigned long      qdepth;
++
++
++	spin_lock_irqsave (&stats->iostat_lock, flags);
++	qdepth = stats->iostat_queue_depth;
++	memset (stats, 0, offsetof(iostat_stats_t, iostat_lock));
++	do_gettimeofday(&stats->iostat_timeval);
++	stats->iostat_queue_stamp = jiffies;
++	stats->iostat_queue_depth = qdepth;
++	spin_unlock_irqrestore (&stats->iostat_lock, flags);
++
++	return len;
++}
++
++static struct file_operations sd_iostats_proc_fops = {
++	.owner   = THIS_MODULE,
++	.open    = sd_iostats_seq_open,
++	.read    = seq_read,
++	.write   = sd_iostats_seq_write,
++	.llseek  = seq_lseek,
++	.release = seq_release,
++};
++
++extern struct proc_dir_entry *proc_scsi;
++
++void
++sd_iostats_init(void)
++{
++	if (proc_scsi == NULL) {
++		printk(KERN_WARNING "No access to sd iostats: "
++			"proc_scsi is NULL\n");
++		return;
++	}
++
++	sd_iostats_procdir = create_proc_entry(sd_iostats_procdir_name,
++					       S_IFDIR | S_IRUGO | S_IXUGO,
++					        proc_scsi);
++	if (sd_iostats_procdir == NULL) {
++		printk(KERN_WARNING "No access to sd iostats: "
++			"can't create /proc/scsi/%s\n", sd_iostats_procdir_name);
++		return;
++	}
++}
++
++void sd_iostats_fini(void)
++{
++	if (proc_scsi != NULL && sd_iostats_procdir != NULL)
++		remove_proc_entry(sd_iostats_procdir_name, proc_scsi);
++
++	sd_iostats_procdir = NULL;
++}
++
++void sd_iostats_finish_req(struct scsi_cmnd *SCpnt)
++{
++	struct request		*rq = SCpnt->request;
++	iostat_stats_t		*stats;
++	unsigned long		*tcounter;
++	int			tbucket;
++	int			tmp;
++	unsigned long		irqflags;
++	unsigned long		i;
++
++	stats = scsi_disk(rq->rq_disk)->stats;
++	if (stats == NULL)
++		return;
++
++	tmp = jiffies - rq->start_time;
++	for (tbucket = 0; tmp > 1; tbucket++)
++		tmp >>= 1;
++	if (tbucket >= IOSTAT_NCOUNTERS)
++		tbucket = IOSTAT_NCOUNTERS - 1;
++	//printk("%u ticks in D to %u\n", jiffies - rq->start_time, tbucket);
++
++	tcounter = rq_data_dir(rq) == WRITE ?
++		&stats->iostat_wtime[tbucket] : &stats->iostat_rtime[tbucket];
++
++	spin_lock_irqsave(&stats->iostat_lock, irqflags);
++
++	/* update delay stats */
++	(*tcounter)++;
++
++	/* update queue depth stats */
++	i = stats->iostat_queue_depth;
++	if (i >= IOSTAT_NCOUNTERS)
++		i = IOSTAT_NCOUNTERS - 1;
++	stats->iostat_queue_ticks[i] += jiffies - stats->iostat_queue_stamp;
++	stats->iostat_queue_ticks_sum += jiffies - stats->iostat_queue_stamp;
++	BUG_ON(stats->iostat_queue_depth == 0);
++	stats->iostat_queue_depth--;
++
++	/* update seek stats. XXX: not sure about nr_sectors */
++	stats->iostat_sectors += rq->nr_sectors;
++	stats->iostat_reqs++;
++	if (rq->sector != stats->iostat_next_sector) {
++		stats->iostat_seek_sectors +=
++			rq->sector > stats->iostat_next_sector ?
++			rq->sector - stats->iostat_next_sector :
++			stats->iostat_next_sector - rq->sector;
++		stats->iostat_seeks++;
++	}
++	stats->iostat_next_sector = rq->sector + rq->nr_sectors;
++
++	stats->iostat_queue_stamp = jiffies;
++
++	spin_unlock_irqrestore(&stats->iostat_lock, irqflags);
++}
++
++void sd_iostats_start_req(struct scsi_cmnd *SCpnt)
++{
++	struct request		*rq = SCpnt->request;
++	iostat_stats_t		*stats;
++	iostat_counter_t	*counter;
++	int			bucket;
++	int			tbucket;
++	int			tmp;
++	unsigned long		irqflags;
++	unsigned long		i;
++	int			nsect;
++
++	stats = scsi_disk(rq->rq_disk)->stats;
++	if (stats == NULL)
++		return;
++
++	nsect = scsi_bufflen(SCpnt) >> 9;
++	for (bucket = 0, tmp = nsect; tmp > 1; bucket++)
++		tmp >>= 1;
++
++	if (bucket >= IOSTAT_NCOUNTERS) {
++		printk (KERN_ERR "sd_iostats_bump: nsect %d too big\n", nsect);
++		BUG();
++	}
++
++	counter = rq_data_dir(rq) == WRITE ?
++		&stats->iostat_write_histogram[bucket] :
++		&stats->iostat_read_histogram[bucket];
++
++	tmp = jiffies - rq->start_time;
++	for (tbucket = 0; tmp > 1; tbucket++)
++		tmp >>= 1;
++	if (tbucket >= IOSTAT_NCOUNTERS)
++		tbucket = IOSTAT_NCOUNTERS - 1;
++	//printk("%u ticks in Q to %u\n", jiffies - rq->start_time, tbucket);
++
++	/* an ugly hack to know exact processing time. the right
++	 * solution is to add one more field to struct request
++	 * hopefully it will break nothing ... */
++	rq->start_time = jiffies;
++
++	spin_lock_irqsave(&stats->iostat_lock, irqflags);
++
++	/* update queue depth stats */
++	i = stats->iostat_queue_depth;
++	if (i >= IOSTAT_NCOUNTERS)
++		i = IOSTAT_NCOUNTERS - 1;
++	stats->iostat_queue_ticks[i] += jiffies - stats->iostat_queue_stamp;
++	stats->iostat_queue_ticks_sum += jiffies - stats->iostat_queue_stamp;
++	stats->iostat_queue_depth++;
++
++	/* update delay stats */
++	if (rq_data_dir(rq) == WRITE) {
++		stats->iostat_wtime_in_queue[tbucket]++;
++		stats->iostat_write_reqs++;
++	} else {
++		stats->iostat_rtime_in_queue[tbucket]++;
++		stats->iostat_read_reqs++;
++	}
++
++	/* update size stats */
++	counter->iostat_size += nsect;
++	counter->iostat_count++;
++
++	stats->iostat_queue_stamp = jiffies;
++
++	spin_unlock_irqrestore(&stats->iostat_lock, irqflags);
++}
++#endif
++
+ /**
+  *	scsi_disk_release - Called to free the scsi_disk structure
+  *	@dev: pointer to embedded class device
+@@ -1941,10 +2352,16 @@
+ 	ida_remove(&sd_index_ida, sdkp->index);
+ 	spin_unlock(&sd_index_lock);
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++	if (sdkp->stats) {
++		remove_proc_entry(disk->disk_name, sd_iostats_procdir);
++		kfree(sdkp->stats);
++		sdkp->stats = NULL;
++	}
++#endif
+ 	disk->private_data = NULL;
+ 	put_disk(disk);
+ 	put_device(&sdkp->device->sdev_gendev);
+-
+ 	kfree(sdkp);
+ }
+ 
+@@ -2061,6 +2478,8 @@
+ 	if (!majors)
+ 		return -ENODEV;
+ 
++	sd_iostats_init();
++
+ 	err = class_register(&sd_disk_class);
+ 	if (err)
+ 		goto err_out;
+@@ -2076,6 +2495,7 @@
+ err_out:
+ 	for (i = 0; i < SD_MAJORS; i++)
+ 		unregister_blkdev(sd_major(i), "sd");
++	sd_iostats_fini();
+ 	return err;
+ }
+ 
+Index: linux-2.6.27.21-0.1/drivers/scsi/sd.h
+===================================================================
+--- linux-2.6.27.21-0.1.orig/drivers/scsi/sd.h	2009-04-23 02:12:56.000000000 -0600
++++ linux-2.6.27.21-0.1/drivers/scsi/sd.h	2009-05-22 08:38:28.000000000 -0600
+@@ -37,6 +37,46 @@
+  */
+ #define SD_LAST_BUGGY_SECTORS	8
+ 
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++typedef struct {
++	unsigned long long iostat_size;
++	unsigned long long iostat_count;
++} iostat_counter_t;
++
++#define IOSTAT_NCOUNTERS 16
++typedef struct {
++	iostat_counter_t	iostat_read_histogram[IOSTAT_NCOUNTERS];
++	iostat_counter_t	iostat_write_histogram[IOSTAT_NCOUNTERS];
++	struct timeval		iostat_timeval;
++
++	/* queue depth: how well the pipe is filled up */
++	unsigned long long	iostat_queue_ticks[IOSTAT_NCOUNTERS];
++	unsigned long long	iostat_queue_ticks_sum;
++	unsigned long		iostat_queue_depth;
++	unsigned long		iostat_queue_stamp;
++
++	/* seeks: how linear the traffic is */
++	unsigned long long	iostat_next_sector;
++	unsigned long long	iostat_seek_sectors;
++	unsigned long long	iostat_seeks;
++	unsigned long long	iostat_sectors;
++	unsigned long long	iostat_reqs;
++	unsigned long		iostat_read_reqs;
++	unsigned long		iostat_write_reqs;
++
++	/* process time: how long it takes to process requests */
++	unsigned long		iostat_rtime[IOSTAT_NCOUNTERS];
++	unsigned long		iostat_wtime[IOSTAT_NCOUNTERS];
++
++	/* queue time: how long process spent in elevator's queue */
++	unsigned long		iostat_rtime_in_queue[IOSTAT_NCOUNTERS];
++	unsigned long		iostat_wtime_in_queue[IOSTAT_NCOUNTERS];
++
++	/* must be the last field, as it's used to know size to be memset'ed */
++	spinlock_t		iostat_lock;
++} ____cacheline_aligned_in_smp iostat_stats_t;
++#endif
++
+ struct scsi_disk {
+ 	struct scsi_driver *driver;	/* always &sd_template */
+ 	struct scsi_device *device;
+@@ -53,6 +93,9 @@
+ 	unsigned	WCE : 1;	/* state of disk WCE bit */
+ 	unsigned	RCD : 1;	/* state of disk RCD bit, unused */
+ 	unsigned	DPOFUA : 1;	/* state of disk DPOFUA bit */
++#if (defined(CONFIG_SD_IOSTATS) && defined(CONFIG_PROC_FS))
++	iostat_stats_t	*stats;		/* scsi disk statistics */
++#endif
+ };
+ #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
+ 
diff --git a/lustre/kernel_patches/patches/vfs_intent-2.6-rhel4.patch b/lustre/kernel_patches/patches/vfs_intent-2.6-rhel4.patch
index 7b9806f..66e65fb 100644
--- a/lustre/kernel_patches/patches/vfs_intent-2.6-rhel4.patch
+++ b/lustre/kernel_patches/patches/vfs_intent-2.6-rhel4.patch
@@ -1,24 +1,22 @@
-Index: linux-2.6.9-78.0.22/fs/cifs/dir.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/cifs/dir.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/cifs/dir.c	2009-05-11 23:20:11.000000000 -0600
-@@ -167,11 +167,7 @@
- 
+diff -rup RH_2_6_9_55.orig/fs/cifs/dir.c RH_2_6_9_55/fs/cifs/dir.c
+--- RH_2_6_9_55.orig/fs/cifs/dir.c
++++ RH_2_6_9_55/fs/cifs/dir.c
+@@ -157,11 +157,7 @@ cifs_create(struct inode *inode, struct 
+
  #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0)
- 	if(nd && (nd->flags & LOOKUP_OPEN)) {
+	if(nd && (nd->flags & LOOKUP_OPEN)) {
 -#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,5) /* SUSE included Lustre patch */
- 		int oflags = nd->intent.it_flags;
+		int oflags = nd->intent.it_flags;
 -#else
 -		int oflags = nd->intent.open.flags;
 -#endif
- 
- 		desiredAccess = 0;
- 		if (oflags & FMODE_READ)
-Index: linux-2.6.9-78.0.22/fs/exec.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/exec.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/exec.c	2009-05-11 23:20:11.000000000 -0600
-@@ -126,9 +126,10 @@
+
+		desiredAccess = 0;
+		if (oflags & FMODE_READ)
+diff -rup RH_2_6_9_55.orig/fs/exec.c RH_2_6_9_55/fs/exec.c
+--- RH_2_6_9_55.orig/fs/exec.c
++++ RH_2_6_9_55/fs/exec.c
+@@ -126,9 +126,10 @@ asmlinkage long sys_uselib(const char __
  	struct file * file;
  	struct nameidata nd;
  	int error;
@@ -32,7 +30,7 @@ Index: linux-2.6.9-78.0.22/fs/exec.c
  	if (error)
  		goto out;
  
-@@ -140,7 +141,7 @@
+@@ -140,7 +141,7 @@ asmlinkage long sys_uselib(const char __
  	if (error)
  		goto exit;
  
@@ -41,7 +39,7 @@ Index: linux-2.6.9-78.0.22/fs/exec.c
  	error = PTR_ERR(file);
  	if (IS_ERR(file))
  		goto out;
-@@ -484,8 +485,9 @@
+@@ -489,8 +490,9 @@ struct file *open_exec(const char *name)
  	int err;
  	struct file *file;
  
@@ -53,24 +51,19 @@ Index: linux-2.6.9-78.0.22/fs/exec.c
  	file = ERR_PTR(err);
  
  	if (!err) {
-@@ -496,9 +498,10 @@
- 			int err = permission(inode, MAY_EXEC, &nd);
+@@ -501,7 +503,7 @@ struct file *open_exec(const char *name)
+			int err = permission(inode, MAY_EXEC, &nd);
  			file = ERR_PTR(err);
  			if (!err) {
--				file = dentry_open(nd.dentry, nd.mnt, 
-+				file = dentry_open_it(nd.dentry, nd.mnt, 
- 					force_o_largefile() ? 
--					O_RDONLY|O_LARGEFILE : O_RDONLY);
-+					O_RDONLY|O_LARGEFILE : O_RDONLY,
-+                                       &nd.intent);
+-				file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
++				file = dentry_open_it(nd.dentry, nd.mnt, O_RDONLY, &nd.intent);
  				if (!IS_ERR(file)) {
  					err = deny_write_access(file);
  					if (err) {
-Index: linux-2.6.9-78.0.22/fs/inode.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/inode.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/inode.c	2009-05-11 23:20:11.000000000 -0600
-@@ -235,6 +235,7 @@
+diff -rup RH_2_6_9_55.orig/fs/inode.c RH_2_6_9_55/fs/inode.c
+--- RH_2_6_9_55.orig/fs/inode.c
++++ RH_2_6_9_55/fs/inode.c
+@@ -235,6 +235,7 @@ void __iget(struct inode * inode)
  	inodes_stat.nr_unused--;
  }
  
@@ -78,11 +71,10 @@ Index: linux-2.6.9-78.0.22/fs/inode.c
  /**
   * clear_inode - clear an inode
   * @inode: inode to clear
-Index: linux-2.6.9-78.0.22/fs/namei.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/namei.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/namei.c	2009-05-11 23:20:11.000000000 -0600
-@@ -282,8 +282,19 @@
+diff -rup RH_2_6_9_55.orig/fs/namei.c RH_2_6_9_55/fs/namei.c
+--- RH_2_6_9_55.orig/fs/namei.c
++++ RH_2_6_9_55/fs/namei.c
+@@ -282,8 +282,19 @@ int deny_write_access(struct file * file
  	return 0;
  }
  
@@ -102,7 +94,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	dput(nd->dentry);
  	mntput(nd->mnt);
  }
-@@ -395,8 +406,12 @@
+@@ -395,8 +406,12 @@ static struct dentry * real_lookup(struc
  {
  	struct dentry * result;
  	struct inode *dir = parent->d_inode;
@@ -115,11 +107,11 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
 +
  	/*
  	 * First re-do the cached lookup just in case it was created
- 	 * while we waited for the directory semaphore..
-@@ -441,8 +456,12 @@
- 	up(&dir->i_sem);
+	 * while we waited for the directory semaphore..
+@@ -433,8 +448,12 @@ static struct dentry * real_lookup(struc
+	up(&dir->i_sem);
  	if (result->d_op && result->d_op->d_revalidate) {
- 		result = do_revalidate(result, nd);
+		result = do_revalidate(result, nd);
 -		if (!result)
 -			result = ERR_PTR(-ENOENT);
 +		if (!result) {
@@ -131,7 +123,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	}
  	return result;
  }
-@@ -472,6 +491,7 @@
+@@ -464,6 +483,7 @@ static inline int __vfs_follow_link(stru
  {
  	int res = 0;
  	char *name;
@@ -139,7 +131,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	if (IS_ERR(link))
  		goto fail;
  
-@@ -481,6 +501,7 @@
+@@ -473,6 +493,7 @@ static inline int __vfs_follow_link(stru
  			/* weird __emul_prefix() stuff did it */
  			goto out;
  	}
@@ -147,7 +139,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	res = link_path_walk(link, nd);
  out:
  	if (nd->depth || res || nd->last_type!=LAST_NORM)
-@@ -691,6 +712,33 @@
+@@ -681,6 +702,33 @@ fail:
  	return PTR_ERR(dentry);
  }
  
@@ -181,17 +173,17 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  /*
   * Name resolution.
   * This is the basic name resolution function, turning a pathname into
-@@ -792,13 +840,17 @@
+@@ -782,13 +830,17 @@ static fastcall int __link_path_walk(con
  			goto out_dput;
  
  		if (inode->i_op->follow_link) {
 +			int save_flags = nd->flags;
  			mntget(next.mnt);
- 			if (next.mnt != nd->mnt) {
- 				dput(nd->dentry);
- 				nd->mnt = next.mnt;
- 				nd->dentry = dget(next.dentry);
- 			}
+			if (next.mnt != nd->mnt) {
+				dput(nd->dentry);
+				nd->mnt = next.mnt;
+				nd->dentry = dget(next.dentry);
+			}
 +			nd->flags |= LOOKUP_LINK_NOTLAST;
  			err = do_follow_link(next.dentry, nd);
 +			if (!(save_flags & LOOKUP_LINK_NOTLAST))
@@ -199,7 +191,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  			dput(next.dentry);
  			mntput(next.mnt);
  			if (err)
-@@ -838,14 +890,34 @@
+@@ -828,14 +880,34 @@ last_component:
  				inode = nd->dentry->d_inode;
  				/* fallthrough */
  			case 1:
@@ -234,7 +226,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  		if (err)
  			break;
  		follow_mount(&next.mnt, &next.dentry);
-@@ -1019,7 +1091,7 @@
+@@ -1007,7 +1079,7 @@ set_it:
  }
  
  /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
@@ -243,7 +235,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  {
  	int retval = 0;
  
-@@ -1053,6 +1125,12 @@
+@@ -1041,6 +1113,12 @@ out:
  	return retval;
  }
  
@@ -256,7 +248,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  /*
   * Restricted form of lookup. Doesn't follow links, single-component only,
   * needs parent already locked. Doesn't follow mounts.
-@@ -1110,7 +1188,7 @@
+@@ -1091,7 +1169,7 @@ struct dentry * lookup_hash(struct qstr 
  }
  
  /* SMP-safe */
@@ -265,7 +257,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  {
  	unsigned long hash;
  	struct qstr this;
-@@ -1130,11 +1208,16 @@
+@@ -1111,11 +1189,16 @@ struct dentry * lookup_one_len(const cha
  	}
  	this.hash = end_name_hash(hash);
  
@@ -283,7 +275,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  /*
   *	namei()
   *
-@@ -1146,18 +1229,24 @@
+@@ -1127,18 +1210,24 @@ access:
   * that namei follows links, while lnamei does not.
   * SMP-safe
   */
@@ -310,7 +302,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  /*
   * It's inline, so penalty for filesystems that don't use sticky bit is
   * minimal.
-@@ -1401,7 +1490,7 @@
+@@ -1384,7 +1473,7 @@ int may_open(struct nameidata *nd, int a
  		if (!error) {
  			DQUOT_INIT(inode);
  			
@@ -319,7 +311,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  		}
  		put_write_access(inode);
  		if (error)
-@@ -1447,14 +1536,14 @@
+@@ -1425,14 +1514,14 @@ int open_namei(const char * pathname, in
  		acc_mode |= MAY_APPEND;
  
  	/* Fill in the open() intent data */
@@ -337,7 +329,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  		if (error)
  			return error;
  		goto ok;
-@@ -1463,7 +1552,8 @@
+@@ -1441,7 +1530,8 @@ int open_namei(const char * pathname, in
  	/*
  	 * Create - we need to know the parent.
  	 */
@@ -347,7 +339,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	if (error)
  		return error;
  
-@@ -1479,7 +1569,9 @@
+@@ -1457,7 +1547,9 @@ int open_namei(const char * pathname, in
  	dir = nd->dentry;
  	nd->flags &= ~LOOKUP_PARENT;
  	down(&dir->d_inode->i_sem);
@@ -357,7 +349,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  
  do_last:
  	error = PTR_ERR(dentry);
-@@ -1595,7 +1687,9 @@
+@@ -1570,7 +1662,9 @@ do_link:
  	}
  	dir = nd->dentry;
  	down(&dir->d_inode->i_sem);
@@ -367,7 +359,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	__putname(nd->last.name);
  	goto do_last;
  }
-@@ -1669,10 +1763,20 @@
+@@ -1644,10 +1738,20 @@ asmlinkage long sys_mknod(const char __u
  	tmp = getname(filename);
  	if (IS_ERR(tmp))
  		return PTR_ERR(tmp);
@@ -390,7 +382,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	dentry = lookup_create(&nd, 0);
  	error = PTR_ERR(dentry);
  
-@@ -1699,6 +1803,7 @@
+@@ -1674,6 +1778,7 @@ asmlinkage long sys_mknod(const char __u
  		dput(dentry);
  	}
  	up(&nd.dentry->d_inode->i_sem);
@@ -398,7 +390,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	path_release(&nd);
  out:
  	putname(tmp);
-@@ -1741,10 +1846,20 @@
+@@ -1716,10 +1821,20 @@ asmlinkage long sys_mkdir(const char __u
  	if (!IS_ERR(tmp)) {
  		struct dentry *dentry;
  		struct nameidata nd;
@@ -420,7 +412,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  		dentry = lookup_create(&nd, 1);
  		error = PTR_ERR(dentry);
  		if (!IS_ERR(dentry)) {
-@@ -1754,6 +1869,7 @@
+@@ -1729,6 +1844,7 @@ asmlinkage long sys_mkdir(const char __u
  			dput(dentry);
  		}
  		up(&nd.dentry->d_inode->i_sem);
@@ -428,7 +420,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  		path_release(&nd);
  out:
  		putname(tmp);
-@@ -1839,7 +1955,8 @@
+@@ -1814,7 +1930,8 @@ asmlinkage long sys_rmdir(const char __u
  	if(IS_ERR(name))
  		return PTR_ERR(name);
  
@@ -438,7 +430,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	if (error)
  		goto exit;
  
-@@ -1854,6 +1971,16 @@
+@@ -1829,6 +1946,16 @@ asmlinkage long sys_rmdir(const char __u
  			error = -EBUSY;
  			goto exit1;
  	}
@@ -455,7 +447,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	down(&nd.dentry->d_inode->i_sem);
  	dentry = lookup_hash(&nd.last, nd.dentry);
  	error = PTR_ERR(dentry);
-@@ -1917,12 +2044,22 @@
+@@ -1892,12 +2019,22 @@ asmlinkage long sys_unlink(const char __
  	if(IS_ERR(name))
  		return PTR_ERR(name);
  
@@ -479,7 +471,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	down(&nd.dentry->d_inode->i_sem);
  	dentry = lookup_hash(&nd.last, nd.dentry);
  	error = PTR_ERR(dentry);
-@@ -1990,10 +2127,20 @@
+@@ -1965,10 +2102,20 @@ asmlinkage long sys_symlink(const char _
  	if (!IS_ERR(to)) {
  		struct dentry *dentry;
  		struct nameidata nd;
@@ -501,7 +493,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  		dentry = lookup_create(&nd, 0);
  		error = PTR_ERR(dentry);
  		if (!IS_ERR(dentry)) {
-@@ -2001,6 +2148,7 @@
+@@ -1976,6 +2123,7 @@ asmlinkage long sys_symlink(const char _
  			dput(dentry);
  		}
  		up(&nd.dentry->d_inode->i_sem);
@@ -509,7 +501,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  		path_release(&nd);
  out:
  		putname(to);
-@@ -2070,15 +2218,26 @@
+@@ -2045,15 +2193,26 @@ asmlinkage long sys_link(const char __us
  	if (IS_ERR(to))
  		return PTR_ERR(to);
  
@@ -538,7 +530,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	new_dentry = lookup_create(&nd, 0);
  	error = PTR_ERR(new_dentry);
  	if (!IS_ERR(new_dentry)) {
-@@ -2254,11 +2413,13 @@
+@@ -2229,11 +2388,13 @@ static inline int do_rename(const char *
  	struct dentry * trap;
  	struct nameidata oldnd, newnd;
  
@@ -554,7 +546,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	if (error)
  		goto exit1;
  
-@@ -2275,6 +2436,13 @@
+@@ -2250,6 +2411,13 @@ static inline int do_rename(const char *
  	if (newnd.last_type != LAST_NORM)
  		goto exit2;
  
@@ -568,7 +560,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  	trap = lock_rename(new_dir, old_dir);
  
  	old_dentry = lookup_hash(&oldnd.last, old_dir);
-@@ -2306,8 +2474,7 @@
+@@ -2281,8 +2449,7 @@ static inline int do_rename(const char *
  	if (new_dentry == trap)
  		goto exit5;
  
@@ -578,7 +570,7 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  exit5:
  	dput(new_dentry);
  exit4:
-@@ -2507,6 +2674,7 @@
+@@ -2473,6 +2640,7 @@ EXPORT_SYMBOL(page_readlink);
  EXPORT_SYMBOL(page_symlink);
  EXPORT_SYMBOL(page_symlink_inode_operations);
  EXPORT_SYMBOL(path_lookup);
@@ -586,11 +578,10 @@ Index: linux-2.6.9-78.0.22/fs/namei.c
  EXPORT_SYMBOL(path_release);
  EXPORT_SYMBOL(path_walk);
  EXPORT_SYMBOL(permission);
-Index: linux-2.6.9-78.0.22/fs/namespace.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/namespace.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/namespace.c	2009-05-11 23:20:11.000000000 -0600
-@@ -114,6 +114,7 @@
+diff -urNp RH_2_6_9_42_0_3.orig/fs/namespace.c RH_2_6_9_42_0_3/fs/namespace.c
+--- RH_2_6_9_42_0_3.orig/fs/namespace.c
++++ RH_2_6_9_42_0_3/fs/namespace.c
+@@ -114,6 +115,7 @@ static inline int check_mnt(struct vfsmo
  
  static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
  {
@@ -598,7 +589,7 @@ Index: linux-2.6.9-78.0.22/fs/namespace.c
  	old_nd->dentry = mnt->mnt_mountpoint;
  	old_nd->mnt = mnt->mnt_parent;
  	mnt->mnt_parent = mnt;
-@@ -441,6 +442,8 @@
+@@ -441,6 +442,8 @@ static int do_umount(struct vfsmount *mn
  	 */
  
  	lock_kernel();
@@ -607,7 +598,7 @@ Index: linux-2.6.9-78.0.22/fs/namespace.c
  	if( (flags&MNT_FORCE) && sb->s_op->umount_begin)
  		sb->s_op->umount_begin(sb);
  	unlock_kernel();
-@@ -665,7 +668,8 @@
+@@ -665,7 +668,8 @@ static int do_loopback(struct nameidata 
  		return err;
  	if (!old_name || !*old_name)
  		return -EINVAL;
@@ -617,7 +608,7 @@ Index: linux-2.6.9-78.0.22/fs/namespace.c
  	if (err)
  		return err;
  
-@@ -739,7 +743,8 @@
+@@ -739,7 +743,8 @@ static int do_move_mount(struct nameidat
  		return -EPERM;
  	if (!old_name || !*old_name)
  		return -EINVAL;
@@ -627,7 +618,7 @@ Index: linux-2.6.9-78.0.22/fs/namespace.c
  	if (err)
  		return err;
  
-@@ -1074,7 +1079,8 @@
+@@ -1074,7 +1079,8 @@ long do_mount(char * dev_name, char * di
  	flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
  
  	/* ... and get the mountpoint */
@@ -637,11 +628,10 @@ Index: linux-2.6.9-78.0.22/fs/namespace.c
  	if (retval)
  		return retval;
  
-Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/nfs/dir.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/nfs/dir.c	2009-05-11 23:20:11.000000000 -0600
-@@ -935,7 +935,7 @@
+diff -rup RH_2_6_9_55.orig/fs/nfs/dir.c RH_2_6_9_55/fs/nfs/dir.c
+--- RH_2_6_9_55.orig/fs/nfs/dir.c
++++ RH_2_6_9_55/fs/nfs/dir.c
+@@ -839,7 +839,7 @@ int nfs_is_exclusive_create(struct inode
  		return 0;
  	if (!nd || (nd->flags & LOOKUP_CONTINUE) || !(nd->flags & LOOKUP_CREATE))
  		return 0;
@@ -650,7 +640,7 @@ Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
  }
  
  static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
-@@ -1032,7 +1032,7 @@
+@@ -915,7 +915,7 @@ static int is_atomic_open(struct inode *
  	if (nd->flags & LOOKUP_DIRECTORY)
  		return 0;
  	/* Are we trying to write to a read only partition? */
@@ -659,7 +649,7 @@ Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
  		return 0;
  	return 1;
  }
-@@ -1053,7 +1053,7 @@
+@@ -936,7 +936,7 @@ static struct dentry *nfs_atomic_lookup(
  	dentry->d_op = NFS_PROTO(dir)->dentry_ops;
  
  	/* Let vfs_create() deal with O_EXCL */
@@ -668,7 +658,7 @@ Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
  		goto no_entry;
  
  	/* Open the file on the server */
-@@ -1065,7 +1065,7 @@
+@@ -948,7 +948,7 @@ static struct dentry *nfs_atomic_lookup(
  		goto out;
  	}
  
@@ -677,7 +667,7 @@ Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
  		nfs_begin_data_update(dir);
  		inode = nfs4_atomic_open(dir, dentry, nd);
  		nfs_end_data_update(dir);
-@@ -1084,7 +1084,7 @@
+@@ -967,7 +967,7 @@ static struct dentry *nfs_atomic_lookup(
  			case -ENOTDIR:
  				goto no_open;
  			case -ELOOP:
@@ -686,7 +676,7 @@ Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
  					goto no_open;
  			/* case -EINVAL: */
  			default:
-@@ -1122,7 +1122,7 @@
+@@ -1005,7 +1005,7 @@ static int nfs_open_revalidate(struct de
  	/* NFS only supports OPEN on regular files */
  	if (!S_ISREG(inode->i_mode))
  		goto no_open;
@@ -695,7 +685,7 @@ Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
  	/* We cannot do exclusive creation on a positive dentry */
  	if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
  		goto no_open;
-@@ -1338,7 +1338,7 @@
+@@ -1213,7 +1213,7 @@ static int nfs_create(struct inode *dir,
  	attr.ia_valid = ATTR_MODE;
  
  	if (nd && (nd->flags & LOOKUP_CREATE))
@@ -704,11 +694,10 @@ Index: linux-2.6.9-78.0.22/fs/nfs/dir.c
  
  	/*
  	 * The 0 argument passed into the create function should one day
-Index: linux-2.6.9-78.0.22/fs/nfs/nfs4proc.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/nfs/nfs4proc.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/nfs/nfs4proc.c	2009-05-11 23:20:11.000000000 -0600
-@@ -838,27 +838,27 @@
+diff -rup RH_2_6_9_55.orig/fs/nfs/nfs4proc.c RH_2_6_9_55/fs/nfs/nfs4proc.c
+--- RH_2_6_9_55.orig/fs/nfs/nfs4proc.c
++++ RH_2_6_9_55/fs/nfs/nfs4proc.c
+@@ -770,27 +770,27 @@ nfs4_atomic_open(struct inode *dir, stru
  	struct nfs4_inc_open *inc_open;
  
  	if (nd->flags & LOOKUP_CREATE) {
@@ -732,19 +721,18 @@ Index: linux-2.6.9-78.0.22/fs/nfs/nfs4proc.c
  	put_rpccred(cred);
  	if (IS_ERR(state)) {
  		kfree(inc_open);
- 		return (struct inode *)state;
- 	}
- 	inc_open->task = current;
+		return (struct inode *)state;
+	}
+	inc_open->task = current;
 -	inc_open->flags = nd->intent.open.flags;
 +	inc_open->flags = nd->intent.it_flags;
- 	INIT_LIST_HEAD(&inc_open->state);
- 	spin_lock(&state->inode->i_lock);
- 	list_add(&inc_open->state, &state->inc_open);
-Index: linux-2.6.9-78.0.22/fs/open.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/open.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/open.c	2009-05-11 23:20:11.000000000 -0600
-@@ -195,6 +195,7 @@
+	INIT_LIST_HEAD(&inc_open->state);
+	spin_lock(&state->inode->i_lock);
+	list_add(&inc_open->state, &state->inc_open);
+diff -rup RH_2_6_9_55.orig/fs/open.c RH_2_6_9_55/fs/open.c
+--- RH_2_6_9_55.orig/fs/open.c
++++ RH_2_6_9_55/fs/open.c
+@@ -195,6 +195,7 @@ out:
  int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs)
  {
  	int err;
@@ -752,9 +740,9 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	struct iattr newattrs;
  
  	/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
-@@ -208,8 +209,16 @@
- 	newattrs.ia_valid |= should_remove_suid(dentry);
- 
+@@ -204,8 +205,16 @@ int do_truncate(struct dentry *dentry, l
+	newattrs.ia_size = length;
+	newattrs.ia_valid = ATTR_SIZE | time_attrs;
  	down(&dentry->d_inode->i_sem);
 -	err = notify_change(dentry, &newattrs);
 -	up(&dentry->d_inode->i_sem);
@@ -770,8 +758,8 @@ Index: linux-2.6.9-78.0.22/fs/open.c
 +
  	return err;
  }
- 
-@@ -218,12 +227,13 @@
+
+@@ -214,12 +223,13 @@ static inline long do_sys_truncate(const
  	struct nameidata nd;
  	struct inode * inode;
  	int error;
@@ -788,7 +776,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	if (error)
  		goto out;
  	inode = nd.dentry->d_inode;
-@@ -394,9 +404,19 @@
+@@ -390,9 +400,19 @@ asmlinkage long sys_utime(char __user * 
  		    (error = permission(inode,MAY_WRITE,&nd)) != 0)
  			goto dput_and_out;
  	}
@@ -811,7 +799,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  dput_and_out:
  	path_release(&nd);
  out:
-@@ -447,9 +467,19 @@
+@@ -443,9 +463,19 @@ long do_utimes(char __user * filename, s
  		    (error = permission(inode,MAY_WRITE,&nd)) != 0)
  			goto dput_and_out;
  	}
@@ -834,7 +822,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  dput_and_out:
  	path_release(&nd);
  out:
-@@ -477,6 +507,7 @@
+@@ -473,6 +503,7 @@ asmlinkage long sys_access(const char __
  	int old_fsuid, old_fsgid;
  	kernel_cap_t old_cap;
  	int res;
@@ -842,7 +830,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  
  	if (mode & ~S_IRWXO)	/* where's F_OK, X_OK, W_OK, R_OK? */
  		return -EINVAL;
-@@ -501,13 +532,14 @@
+@@ -497,13 +528,14 @@ asmlinkage long sys_access(const char __
  	else
  		current->cap_effective = current->cap_permitted;
  
@@ -858,7 +846,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  		path_release(&nd);
  	}
  
-@@ -522,8 +554,9 @@
+@@ -518,8 +550,9 @@ asmlinkage long sys_chdir(const char __u
  {
  	struct nameidata nd;
  	int error;
@@ -869,7 +857,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	if (error)
  		goto out;
  
-@@ -575,8 +608,9 @@
+@@ -571,8 +604,9 @@ asmlinkage long sys_chroot(const char __
  {
  	struct nameidata nd;
  	int error;
@@ -880,7 +868,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	if (error)
  		goto out;
  
-@@ -599,36 +633,52 @@
+@@ -595,36 +629,52 @@ out:
  
  EXPORT_SYMBOL_GPL(sys_chroot);
  
@@ -949,7 +937,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	fput(file);
  out:
  	return err;
-@@ -637,32 +687,13 @@
+@@ -633,32 +683,13 @@ out:
  asmlinkage long sys_chmod(const char __user * filename, mode_t mode)
  {
  	struct nameidata nd;
@@ -961,7 +949,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	if (error)
  		goto out;
 -	inode = nd.dentry->d_inode;
- 
+
 -	error = -EROFS;
 -	if (IS_RDONLY(inode))
 -		goto dput_and_out;
@@ -983,7 +971,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	path_release(&nd);
  out:
  	return error;
-@@ -683,6 +714,18 @@
+@@ -679,6 +710,18 @@ static int chown_common(struct dentry * 
  	if (IS_RDONLY(inode))
  		goto out;
  	error = -EPERM;
@@ -1002,7 +990,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
  		goto out;
  	newattrs.ia_valid =  ATTR_CTIME;
-@@ -696,6 +739,7 @@
+@@ -692,6 +735,7 @@ static int chown_common(struct dentry * 
  	}
  	if (!S_ISDIR(inode->i_mode))
  		newattrs.ia_valid |= ATTR_KILL_SUID|ATTR_KILL_SGID;
@@ -1010,7 +998,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	down(&inode->i_sem);
  	error = notify_change(dentry, &newattrs);
  	up(&inode->i_sem);
-@@ -743,8 +787,6 @@
+@@ -739,8 +783,6 @@ asmlinkage long sys_fchown(unsigned int 
  	return error;
  }
  
@@ -1019,7 +1007,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  /*
   * Note that while the flag value (low two bits) for sys_open means:
   *	00 - read-only
-@@ -762,23 +804,19 @@
+@@ -758,8 +800,9 @@ static struct file *__dentry_open(struct
  struct file *filp_open(const char * filename, int flags, int mode)
  {
  	int namei_flags, error;
@@ -1030,7 +1018,9 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  
  	namei_flags = flags;
  	if ((namei_flags+1) & O_ACCMODE)
- 		namei_flags++;
+@@ -767,16 +810,11 @@ struct file *filp_open(const char * file
+ 	if (namei_flags & O_TRUNC)
+ 		namei_flags |= 2;
  
 -	error = -ENFILE;
 -	f = get_empty_filp();
@@ -1049,7 +1039,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	return ERR_PTR(error);
  }
  
-@@ -786,29 +824,27 @@
+@@ -784,29 +822,27 @@ EXPORT_SYMBOL(filp_open);
  
  struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
  {
@@ -1089,7 +1079,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	inode = dentry->d_inode;
  	if (f->f_mode & FMODE_WRITE) {
  		error = get_write_access(inode);
-@@ -827,6 +863,7 @@
+@@ -825,6 +861,7 @@ static struct file *__dentry_open(struct
  		error = f->f_op->open(inode,f);
  		if (error)
  			goto cleanup_all;
@@ -1097,7 +1087,7 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	}
  	f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
  
-@@ -851,6 +888,8 @@
+@@ -849,6 +886,8 @@ cleanup_all:
  	f->f_vfsmnt = NULL;
  cleanup_file:
  	put_filp(f);
@@ -1106,11 +1096,10 @@ Index: linux-2.6.9-78.0.22/fs/open.c
  	dput(dentry);
  	mntput(mnt);
  	return ERR_PTR(error);
-Index: linux-2.6.9-78.0.22/fs/stat.c
-===================================================================
---- linux-2.6.9-78.0.22.orig/fs/stat.c	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/fs/stat.c	2009-05-11 23:20:11.000000000 -0600
-@@ -37,7 +37,7 @@
+diff -rup RH_2_6_9_55.orig/fs/stat.c RH_2_6_9_55/fs/stat.c
+--- RH_2_6_9_55.orig/fs/stat.c
++++ RH_2_6_9_55/fs/stat.c
+@@ -37,7 +37,7 @@ void generic_fillattr(struct inode *inod
  
  EXPORT_SYMBOL(generic_fillattr);
  
@@ -1119,7 +1108,7 @@ Index: linux-2.6.9-78.0.22/fs/stat.c
  {
  	struct inode *inode = dentry->d_inode;
  	int retval;
-@@ -46,6 +46,8 @@
+@@ -46,6 +46,8 @@ int vfs_getattr(struct vfsmount *mnt, st
  	if (retval)
  		return retval;
  
@@ -1128,19 +1117,19 @@ Index: linux-2.6.9-78.0.22/fs/stat.c
  	if (inode->i_op->getattr)
  		return inode->i_op->getattr(mnt, dentry, stat);
  
-@@ -62,7 +64,7 @@
+@@ -62,7 +64,7 @@ int vfs_getattr(struct vfsmount *mnt, st
  
  EXPORT_SYMBOL(vfs_getattr);
  
 -int vfs_getattr64(struct vfsmount *mnt, struct dentry *dentry, struct kstat64 *stat)
 +int vfs_getattr64_it(struct vfsmount *mnt, struct dentry *dentry, struct lookup_intent *it, struct kstat64 *stat)
  {
- 	struct inode *inode = dentry->d_inode;
- 	int retval;
-@@ -79,6 +81,13 @@
- 		return ixop->getattr64(mnt, dentry, stat);
- 	}
- 
+	struct inode *inode = dentry->d_inode;
+	int retval;
+@@ -79,6 +81,13 @@ int vfs_getattr64(struct vfsmount *mnt, 
+		return ixop->getattr64(mnt, dentry, stat);
+	}
+
 +	if (inode->i_op->getattr_it) {
 +		retval = inode->i_op->getattr_it(mnt, dentry, it, (struct kstat *) stat);
 +		if (retval == 0)
@@ -1148,16 +1137,16 @@ Index: linux-2.6.9-78.0.22/fs/stat.c
 +		return retval;
 +	}
 +
- 	if (inode->i_op->getattr) {
- 		retval = inode->i_op->getattr(mnt, dentry, (struct kstat *) stat);
- 		if (retval == 0)
-@@ -98,16 +107,28 @@
- 	return 0;
+	if (inode->i_op->getattr) {
+		retval = inode->i_op->getattr(mnt, dentry, (struct kstat *) stat);
+		if (retval == 0)
+@@ -98,16 +107,28 @@ int vfs_getattr64(struct vfsmount *mnt, 
+	return 0;
  }
- 
+
 +
  EXPORT_SYMBOL(vfs_getattr64);
- 
+
 +int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 +{
 +	return vfs_getattr_it(mnt, dentry, NULL, stat);
@@ -1182,7 +1171,7 @@ Index: linux-2.6.9-78.0.22/fs/stat.c
  		path_release(&nd);
  	}
  	return error;
-@@ -119,10 +140,11 @@
+@@ -119,10 +140,11 @@ int vfs_lstat(char __user *name, struct 
  {
  	struct nameidata nd;
  	int error;
@@ -1196,7 +1185,7 @@ Index: linux-2.6.9-78.0.22/fs/stat.c
  		path_release(&nd);
  	}
  	return error;
-@@ -134,9 +156,12 @@
+@@ -134,9 +156,12 @@ int vfs_fstat(unsigned int fd, struct ks
  {
  	struct file *f = fget(fd);
  	int error = -EBADF;
@@ -1210,51 +1199,50 @@ Index: linux-2.6.9-78.0.22/fs/stat.c
  		fput(f);
  	}
  	return error;
-@@ -148,10 +173,11 @@
+@@ -148,10 +173,11 @@ int vfs_stat64(char __user *name, struct
  {
- 	struct nameidata nd;
- 	int error;
+	struct nameidata nd;
+	int error;
 +	intent_init(&nd.intent, IT_GETATTR);
- 
+
 -	error = user_path_walk(name, &nd);
 +	error = user_path_walk_it(name, &nd);
  	if (!error) {
 -		error = vfs_getattr64(nd.mnt, nd.dentry, stat);
 +		error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);
- 		path_release(&nd);
- 	}
- 	return error;
-@@ -163,10 +189,11 @@
+		path_release(&nd);
+	}
+	return error;
+@@ -163,10 +189,11 @@ int vfs_lstat64(char __user *name, struc
  {
- 	struct nameidata nd;
- 	int error;
+	struct nameidata nd;
+	int error;
 +	intent_init(&nd.intent, IT_GETATTR);
- 
+
 -	error = user_path_walk_link(name, &nd);
 +	error = user_path_walk_link_it(name, &nd);
  	if (!error) {
 -		error = vfs_getattr64(nd.mnt, nd.dentry, stat);
 +		error = vfs_getattr64_it(nd.mnt, nd.dentry, &nd.intent, stat);
- 		path_release(&nd);
- 	}
- 	return error;
-@@ -178,9 +205,11 @@
+		path_release(&nd);
+	}
+	return error;
+@@ -178,9 +205,11 @@ int vfs_fstat64(unsigned int fd, struct 
  {
- 	struct file *f = fget(fd);
- 	int error = -EBADF;
+	struct file *f = fget(fd);
+	int error = -EBADF;
 +	struct nameidata nd;
 +	intent_init(&nd.intent, IT_GETATTR);
- 
- 	if (f) {
+
+	if (f) {
 -		error = vfs_getattr64(f->f_vfsmnt, f->f_dentry, stat);
 +		error = vfs_getattr64_it(f->f_vfsmnt, f->f_dentry, &nd.intent, stat);
- 		fput(f);
- 	}
- 	return error;
-Index: linux-2.6.9-78.0.22/include/linux/dcache.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/dcache.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/dcache.h	2009-05-11 23:20:11.000000000 -0600
+		fput(f);
+	}
+	return error;
+diff -rup RH_2_6_9_55.orig/include/linux/dcache.h RH_2_6_9_55/include/linux/dcache.h
+--- RH_2_6_9_55.orig/include/linux/dcache.h
++++ RH_2_6_9_55/include/linux/dcache.h
 @@ -4,6 +4,7 @@
  #ifdef __KERNEL__
  
@@ -1263,7 +1251,7 @@ Index: linux-2.6.9-78.0.22/include/linux/dcache.h
  #include <linux/list.h>
  #include <linux/spinlock.h>
  #include <linux/cache.h>
-@@ -37,6 +38,8 @@
+@@ -37,6 +38,8 @@ struct qstr {
  	const unsigned char *name;
  };
  
@@ -1272,11 +1260,10 @@ Index: linux-2.6.9-78.0.22/include/linux/dcache.h
  struct dentry_stat_t {
  	int nr_dentry;
  	int nr_unused;
-Index: linux-2.6.9-78.0.22/include/linux/fs.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/fs.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/fs.h	2009-05-11 23:20:11.000000000 -0600
-@@ -271,6 +271,8 @@
+diff -rup RH_2_6_9_55.orig/include/linux/fs.h RH_2_6_9_55/include/linux/fs.h
+--- RH_2_6_9_55.orig/include/linux/fs.h
++++ RH_2_6_9_55/include/linux/fs.h
+@@ -266,6 +266,8 @@ typedef void (dio_iodone_t)(struct inode
  #define ATTR_ATTR_FLAG	1024
  #define ATTR_KILL_SUID	2048
  #define ATTR_KILL_SGID	4096
@@ -1285,7 +1272,7 @@ Index: linux-2.6.9-78.0.22/include/linux/fs.h
  
  /*
   * This is the Inode Attributes structure, used for notify_change().  It
-@@ -469,6 +471,7 @@
+@@ -464,6 +466,7 @@ struct inode {
  	struct block_device	*i_bdev;
  	struct cdev		*i_cdev;
  	int			i_cindex;
@@ -1293,7 +1280,7 @@ Index: linux-2.6.9-78.0.22/include/linux/fs.h
  
  	__u32			i_generation;
  
-@@ -602,6 +605,7 @@
+@@ -597,6 +600,7 @@ struct file {
  	spinlock_t		f_ep_lock;
  #endif /* #ifdef CONFIG_EPOLL */
  	struct address_space	*f_mapping;
@@ -1301,7 +1288,7 @@ Index: linux-2.6.9-78.0.22/include/linux/fs.h
  };
  extern spinlock_t files_lock;
  #define file_list_lock() spin_lock(&files_lock);
-@@ -972,20 +976,29 @@
+@@ -967,20 +971,29 @@ struct inode_operations {
  	int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
  	struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
  	int (*link) (struct dentry *,struct inode *,struct dentry *);
@@ -1331,7 +1318,7 @@ Index: linux-2.6.9-78.0.22/include/linux/fs.h
  	int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
  	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
  	ssize_t (*listxattr) (struct dentry *, char *, size_t);
-@@ -1030,6 +1043,7 @@
+@@ -1025,6 +1038,7 @@ struct super_operations {
  	int (*remount_fs) (struct super_block *, int *, char *);
  	void (*clear_inode) (struct inode *);
  	void (*umount_begin) (struct super_block *);
@@ -1339,7 +1326,7 @@ Index: linux-2.6.9-78.0.22/include/linux/fs.h
  
  	int (*show_options)(struct seq_file *, struct vfsmount *);
  };
-@@ -1222,6 +1236,7 @@
+@@ -1217,6 +1231,7 @@ extern int unregister_filesystem(struct 
  extern struct vfsmount *kern_mount(struct file_system_type *);
  extern int may_umount_tree(struct vfsmount *);
  extern int may_umount(struct vfsmount *);
@@ -1347,7 +1334,7 @@ Index: linux-2.6.9-78.0.22/include/linux/fs.h
  extern long do_mount(char *, char *, char *, unsigned long, void *);
  
  extern int vfs_statfs(struct super_block *, struct kstatfs *);
-@@ -1282,10 +1297,10 @@
+@@ -1277,10 +1292,10 @@ static inline int break_lease(struct ino
  }
  
  /* fs/open.c */
@@ -1359,11 +1346,10 @@ Index: linux-2.6.9-78.0.22/include/linux/fs.h
  extern int filp_close(struct file *, fl_owner_t id);
  extern char * getname(const char __user *);
  
-Index: linux-2.6.9-78.0.22/include/linux/mount.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/mount.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/mount.h	2009-05-11 23:20:11.000000000 -0600
-@@ -34,6 +34,7 @@
+diff -rup RH_2_6_9_55.orig/include/linux/mount.h RH_2_6_9_55/include/linux/mount.h
+--- RH_2_6_9_55.orig/include/linux/mount.h
++++ RH_2_6_9_55/include/linux/mount.h
+@@ -34,6 +34,7 @@ struct vfsmount
  	struct list_head mnt_list;
  	struct list_head mnt_fslink;	/* link in fs-specific expiry list */
  	struct namespace *mnt_namespace; /* containing namespace */
@@ -1371,10 +1357,9 @@ Index: linux-2.6.9-78.0.22/include/linux/mount.h
  };
  
  static inline struct vfsmount *mntget(struct vfsmount *mnt)
-Index: linux-2.6.9-78.0.22/include/linux/namei.h
-===================================================================
---- linux-2.6.9-78.0.22.orig/include/linux/namei.h	2009-05-08 09:59:03.000000000 -0600
-+++ linux-2.6.9-78.0.22/include/linux/namei.h	2009-05-11 23:20:11.000000000 -0600
+diff -rup RH_2_6_9_55.orig/include/linux/namei.h RH_2_6_9_55/include/linux/namei.h
+--- RH_2_6_9_55.orig/include/linux/namei.h
++++ RH_2_6_9_55/include/linux/namei.h
 @@ -2,14 +2,55 @@
  #define _LINUX_NAMEI_H
  
@@ -1434,7 +1419,7 @@ Index: linux-2.6.9-78.0.22/include/linux/namei.h
  enum { MAX_NESTED_LINKS = 8 };
  
  struct nameidata {
-@@ -21,10 +62,7 @@
+@@ -21,10 +62,7 @@ struct nameidata {
  	unsigned	depth;
  	char *saved_names[MAX_NESTED_LINKS + 1];
  
@@ -1446,7 +1431,7 @@ Index: linux-2.6.9-78.0.22/include/linux/namei.h
  };
  
  /*
-@@ -47,6 +85,8 @@
+@@ -47,6 +85,8 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
  #define LOOKUP_NOALT		32
  #define LOOKUP_ATOMIC		64
  #define LOOKUP_REVAL		128
@@ -1455,7 +1440,7 @@ Index: linux-2.6.9-78.0.22/include/linux/namei.h
  
  /*
   * Intent data
-@@ -56,11 +96,18 @@
+@@ -56,11 +96,18 @@ enum {LAST_NORM, LAST_ROOT, LAST_DOT, LA
  #define LOOKUP_ACCESS		(0x0400)
  
  extern int FASTCALL(__user_walk(const char __user *, unsigned, struct nameidata *));
diff --git a/lustre/kernel_patches/series/2.6-rhel4.series b/lustre/kernel_patches/series/2.6-rhel4.series
index 828b7b3..6f7c5dd 100644
--- a/lustre/kernel_patches/series/2.6-rhel4.series
+++ b/lustre/kernel_patches/series/2.6-rhel4.series
@@ -1,10 +1,10 @@
 lustre_version.patch
-vfs_intent-2.6-rhel4.patch 
+vfs_intent-2.6-rhel4.patch
 vfs_races-2.6-rhel4.patch
 iopen-misc-2.6-suse.patch 
 export_symbols-2.6-rhel4.patch 
 dev_read_only-2.6-suse.patch 
-export-log-2.6-rhel4.patch 
+export-log-2.6-rhel4.patch
 lookup_bdev_init_intent.patch
 remove-suid-2.6-suse.patch
 export-show_task-2.6-vanilla.patch
@@ -12,15 +12,16 @@ sd_iostats-2.6-rhel4.patch
 blkdev_tunables-2.6-suse.patch
 fsprivate-2.6.patch
 export_symbol_numa.patch 
-qsnet-rhel4-2.6.patch 
+qsnet-rhel4-2.6.patch
+linux-2.6-binutils-2.16.patch
 vm-tunables-rhel4.patch 
 tcp-rto_proc-2.6.9.patch
 rollback-raid5ch-to-55.patch
-raid5-stats.patch 
+raid5-stats.patch
 raid5-configurable-cachesize.patch
 raid5-large-io.patch
-raid5-stripe-by-stripe-handling.patch 
-raid5-merge-ios.patch 
+raid5-stripe-by-stripe-handling.patch
+raid5-merge-ios.patch
 raid5-serialize-ovelapping-reqs.patch
 raid5-zerocopy.patch
 raid6-stats.patch
@@ -37,5 +38,5 @@ quota-umount-race-fix.patch
 quota-deadlock-on-pagelock-ext3.patch
 vfs-keep-inode-hashed-for-clear-inode.patch
 modpost_external_module_updates_rhel4.patch
-mpt-fusion-downgrade-to-3_02_73-rhel4.patch 
-md-mmp-unplug-dev-sles10.patch 
+mpt-fusion-downgrade-to-3_02_73-rhel4.patch
+md-mmp-unplug-dev-sles10.patch
diff --git a/lustre/kernel_patches/series/2.6-rhel5.series b/lustre/kernel_patches/series/2.6-rhel5.series
index 71e15ef..41f55fc 100644
--- a/lustre/kernel_patches/series/2.6-rhel5.series
+++ b/lustre/kernel_patches/series/2.6-rhel5.series
@@ -5,7 +5,6 @@ jbd-jcberr-2.6.18-vanilla.patch
 export_symbols-2.6.18-vanilla.patch
 dev_read_only-2.6.18-vanilla.patch
 export-2.6.18-vanilla.patch
-8kstack-2.6.12.patch
 export-show_task-2.6.18-vanilla.patch
 sd_iostats-2.6-rhel5.patch
 export_symbol_numa-2.6-fc5.patch
@@ -21,3 +20,8 @@ md-soft-lockups.patch
 jbd-journal-chksum-2.6.18-vanilla.patch
 quota-large-limits-rhel5.patch
 md-mmp-unplug-dev.patch
+prune-icache-use-trylock-rhel5.patch
+jbd-slab-race-2.6-rhel5.patch
+mpt-fusion-max-sge.patch
+jbd2-jcberr-2.6-rhel5.patch
+jbd2-commit-timer-no-jiffies-rounding.diff
diff --git a/lustre/kernel_patches/series/2.6-sles10.series b/lustre/kernel_patches/series/2.6-sles10.series
index f36093d..7003a52 100644
--- a/lustre/kernel_patches/series/2.6-sles10.series
+++ b/lustre/kernel_patches/series/2.6-sles10.series
@@ -5,13 +5,11 @@ export_symbols-2.6.12.patch
 dev_read_only-2.6-fc5.patch 
 export-2.6-fc5.patch 
 export-show_task-2.6-fc5.patch 
-sd_iostats-2.6-rhel5.patch 
+sd_iostats-2.6-sles10.patch 
 export_symbol_numa-2.6-fc5.patch 
 blkdev_tunables-2.6-sles10.patch
 jbd-stats-2.6-sles10.patch
-i_filter_data.patch
 quota-fix-oops-in-invalidate_dquots.patch
-fmode-exec-2.6-sles10.patch
-jbd-journal-chksum-2.6-sles10.patch
 quota-large-limits-sles10.patch
 md-mmp-unplug-dev-sles10.patch
+prune-icache-use-trylock-sles10.patch
diff --git a/lustre/kernel_patches/series/2.6-sles11.series b/lustre/kernel_patches/series/2.6-sles11.series
new file mode 100644
index 0000000..860be33
--- /dev/null
+++ b/lustre/kernel_patches/series/2.6-sles11.series
@@ -0,0 +1,13 @@
+lustre_version.patch
+vfs_races-2.6.22-vanilla.patch
+iopen-misc-2.6.22-vanilla.patch
+export-truncate-2.6.18-vanilla.patch 
+export_symbols-2.6.22-vanilla.patch 
+dev_read_only-2.6.27-vanilla.patch 
+export-2.6.27-vanilla.patch 
+export-show_task-2.6.27-vanilla.patch 
+sd_iostats-2.6.27-vanilla.patch
+md-mmp-unplug-dev-sles11.patch
+quota-support-64-bit-quota-format.patch
+jbd2-jcberr-2.6-sles11.patch
+jbd2-commit-timer-no-jiffies-rounding.diff
diff --git a/lustre/kernel_patches/series/2.6.22-vanilla.series b/lustre/kernel_patches/series/2.6.22-vanilla.series
index b1f1b08..53997ba 100644
--- a/lustre/kernel_patches/series/2.6.22-vanilla.series
+++ b/lustre/kernel_patches/series/2.6.22-vanilla.series
@@ -7,8 +7,8 @@ export-truncate-2.6.18-vanilla.patch
 export_symbols-2.6.22-vanilla.patch 
 dev_read_only-2.6.22-vanilla.patch 
 export-2.6.18-vanilla.patch 
-8kstack-2.6.12.patch
 export-show_task-2.6.18-vanilla.patch 
 sd_iostats-2.6.22-vanilla.patch
 quota-large-limits-rhel5.patch
 md-mmp-unplug-dev.patch
+jbd-commit-timer-no-jiffies-rounding.diff
diff --git a/lustre/kernel_patches/targets/2.6-fc5.target b/lustre/kernel_patches/targets/2.6-fc5.target
index 94a4ba0..685f398 100644
--- a/lustre/kernel_patches/targets/2.6-fc5.target
+++ b/lustre/kernel_patches/targets/2.6-fc5.target
@@ -4,10 +4,10 @@ lnxrel="fc5"
 KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2
 SERIES=2.6-fc5.series
 VERSION=${lnxmaj}
-EXTRA_VERSION=${lnxrel}_lustre.1.6.7.2
+EXTRA_VERSION=${lnxrel}_lustre.1.8.1
 RHBUILD=1
 LINUX26=1
-LUSTRE_VERSION=1.6.7.2
+LUSTRE_VERSION=1.8.1
 
 BASE_ARCHS="i686"
 BIGMEM_ARCHS=""
diff --git a/lustre/kernel_patches/targets/2.6-patchless.target b/lustre/kernel_patches/targets/2.6-patchless.target
index bd17114..610b642 100644
--- a/lustre/kernel_patches/targets/2.6-patchless.target
+++ b/lustre/kernel_patches/targets/2.6-patchless.target
@@ -7,7 +7,7 @@ VERSION=${lnxmaj}
 EXTRA_VERSION=${lnxrel}
 RHBUILD=1
 LINUX26=1
-LUSTRE_VERSION=1.6.7.2
+LUSTRE_VERSION=1.8.1
 
 BASE_ARCHS="i686 x86_64 ia64"
 BIGMEM_ARCHS=""
diff --git a/lustre/kernel_patches/targets/2.6-rhel4.target b/lustre/kernel_patches/targets/2.6-rhel4.target
index a57c450..78758d6 100644
--- a/lustre/kernel_patches/targets/2.6-rhel4.target
+++ b/lustre/kernel_patches/targets/2.6-rhel4.target
@@ -1,15 +1,15 @@
 lnxmaj="2.6.9"
-lnxrel="78.0.22.EL"
+lnxrel="67.0.22.EL"
 
 KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2
 SERIES=2.6-rhel4.series
 VERSION=${lnxmaj}
-EXTRA_VERSION=${lnxrel}_lustre.1.6.7.2
+EXTRA_VERSION=${lnxrel}_lustre.1.8.1
 RHBUILD=1
 LINUX26=1
-LUSTRE_VERSION=1.6.7.2
+LUSTRE_VERSION=1.8.1
 
-OFED_VERSION=inkernel
+OFED_VERSION=1.4.1
 
 BASE_ARCHS="i686 x86_64 ia64"
 BIGMEM_ARCHS=""
diff --git a/lustre/kernel_patches/targets/2.6-rhel4.target.in b/lustre/kernel_patches/targets/2.6-rhel4.target.in
index 1049dd9..187cdea 100644
--- a/lustre/kernel_patches/targets/2.6-rhel4.target.in
+++ b/lustre/kernel_patches/targets/2.6-rhel4.target.in
@@ -1,5 +1,5 @@
 lnxmaj="2.6.9"
-lnxrel="78.0.22.EL"
+lnxrel="67.0.22.EL"
 
 KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2
 SERIES=2.6-rhel4.series
@@ -9,7 +9,7 @@ RHBUILD=1
 LINUX26=1
 LUSTRE_VERSION=@VERSION@
 
-OFED_VERSION=inkernel
+OFED_VERSION=1.4.1
 
 BASE_ARCHS="i686 x86_64 ia64"
 BIGMEM_ARCHS=""
diff --git a/lustre/kernel_patches/targets/2.6-rhel5.target b/lustre/kernel_patches/targets/2.6-rhel5.target
index f433a07..36f0a0a 100644
--- a/lustre/kernel_patches/targets/2.6-rhel5.target
+++ b/lustre/kernel_patches/targets/2.6-rhel5.target
@@ -1,21 +1,20 @@
 lnxmaj="2.6.18"
-lnxrel="92.1.26.el5"
+lnxrel="128.1.14.el5"
 
-KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2
+KERNEL_SRPM=kernel-$lnxmaj-$lnxrel.src.rpm
 SERIES=2.6-rhel5.series
-VERSION=${lnxmaj}
-EXTRA_VERSION=${lnxrel}_lustre.1.6.7.2
-RHBUILD=1
-LINUX26=1
-LUSTRE_VERSION=1.6.7.2
+EXTRA_VERSION=${lnxrel}_lustre.1.8.1
+LUSTRE_VERSION=1.8.1
 
-OFED_VERSION=inkernel
+OFED_VERSION=1.4.1
 
 BASE_ARCHS="i686 x86_64 ia64 ppc64"
 BIGMEM_ARCHS=""
 BOOT_ARCHS=""
 JENSEN_ARCHS=""
-SMP_ARCHS="i686 x86_64 ia64 ppc64"
+#SMP_ARCHS="i686 x86_64 ia64 ppc64"
+# RHEL5 doesn't use smp specific kernels
+SMP_ARCHS=""
 UP_ARCHS=""
 
 for cc in gcc ; do
diff --git a/lustre/kernel_patches/targets/2.6-rhel5.target.in b/lustre/kernel_patches/targets/2.6-rhel5.target.in
index 6ff82c3..a1fbdf3 100644
--- a/lustre/kernel_patches/targets/2.6-rhel5.target.in
+++ b/lustre/kernel_patches/targets/2.6-rhel5.target.in
@@ -1,21 +1,20 @@
 lnxmaj="2.6.18"
-lnxrel="92.1.26.el5"
+lnxrel="128.1.14.el5"
 
-KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2
+KERNEL_SRPM=kernel-$lnxmaj-$lnxrel.src.rpm
 SERIES=2.6-rhel5.series
-VERSION=${lnxmaj}
 EXTRA_VERSION=${lnxrel}_lustre. at VERSION@
-RHBUILD=1
-LINUX26=1
 LUSTRE_VERSION=@VERSION@
 
-OFED_VERSION=inkernel
+OFED_VERSION=1.4.1
 
 BASE_ARCHS="i686 x86_64 ia64 ppc64"
 BIGMEM_ARCHS=""
 BOOT_ARCHS=""
 JENSEN_ARCHS=""
-SMP_ARCHS="i686 x86_64 ia64 ppc64"
+#SMP_ARCHS="i686 x86_64 ia64 ppc64"
+# RHEL5 doesn't use smp specific kernels
+SMP_ARCHS=""
 UP_ARCHS=""
 
 for cc in gcc ; do
diff --git a/lustre/kernel_patches/targets/2.6-sles10.target b/lustre/kernel_patches/targets/2.6-sles10.target
index b97a475..383bdaf 100644
--- a/lustre/kernel_patches/targets/2.6-sles10.target
+++ b/lustre/kernel_patches/targets/2.6-sles10.target
@@ -1,5 +1,9 @@
 lnxmaj="2.6.16"
-lnxrel="60-0.37_f594963d"
+lnxmin=".60"
+# when we fix up this lnxmaj/lnxmin/lnxrel business...
+#lnxrel="0.37_f594963d"
+# and note that this means we get rid of the EXTRA_VERSION_DELIMITER crap!!
+lnxrel="60-0.39.3"
 
 # this is the delimeter that goes between $lnxmaj and $lnxrel
 # defaults to "-"
@@ -9,17 +13,13 @@ EXTRA_VERSION_DELIMITER="."
 # defaults to empty
 TARGET_DELIMITER="-"
 
-KERNEL=linux-$lnxmaj.$lnxrel.tar.bz2
+KERNEL_SRPM=kernel-source-$lnxmaj.$lnxrel.src.rpm
 SERIES=2.6-sles10.series
 VERSION=$lnxmaj
-EXTRA_VERSION="${lnxrel}_lustre.1.6.7.2"
-LUSTRE_VERSION=1.6.7.2
-RHBUILD=0
-LINUX26=1
-# No /boot/Kerntypes* in SLES10
-SUSEBUILD=0
+EXTRA_VERSION="${lnxrel}_lustre.1.8.1"
+LUSTRE_VERSION=1.8.1
 
-OFED_VERSION=1.3.1
+OFED_VERSION=1.4.1
 
 BASE_ARCHS="i686 ppc x86_64 ia64 ppc64"
 BIGMEM_ARCHS=""
@@ -30,6 +30,7 @@ BIGSMP_ARCHS="i686"
 PSERIES64_ARCHS="ppc"
 UP_ARCHS=""
 SRC_ARCHS=""
+#RPMSMPTYPE="smp"
 
 for cc in gcc ; do
     if which $cc >/dev/null 2>/dev/null ; then
diff --git a/lustre/kernel_patches/targets/2.6-sles10.target.in b/lustre/kernel_patches/targets/2.6-sles10.target.in
index e2873eb..120fca2 100644
--- a/lustre/kernel_patches/targets/2.6-sles10.target.in
+++ b/lustre/kernel_patches/targets/2.6-sles10.target.in
@@ -1,5 +1,9 @@
 lnxmaj="2.6.16"
-lnxrel="60-0.37_f594963d"
+lnxmin=".60"
+# when we fix up this lnxmaj/lnxmin/lnxrel business...
+#lnxrel="0.37_f594963d"
+# and note that this means we get rid of the EXTRA_VERSION_DELIMITER crap!!
+lnxrel="60-0.39.3"
 
 # this is the delimeter that goes between $lnxmaj and $lnxrel
 # defaults to "-"
@@ -9,17 +13,13 @@ EXTRA_VERSION_DELIMITER="."
 # defaults to empty
 TARGET_DELIMITER="-"
 
-KERNEL=linux-$lnxmaj.$lnxrel.tar.bz2
+KERNEL_SRPM=kernel-source-$lnxmaj.$lnxrel.src.rpm
 SERIES=2.6-sles10.series
 VERSION=$lnxmaj
 EXTRA_VERSION="${lnxrel}_lustre. at VERSION@"
 LUSTRE_VERSION=@VERSION@
-RHBUILD=0
-LINUX26=1
-# No /boot/Kerntypes* in SLES10
-SUSEBUILD=0
 
-OFED_VERSION=1.3.1
+OFED_VERSION=1.4.1
 
 BASE_ARCHS="i686 ppc x86_64 ia64 ppc64"
 BIGMEM_ARCHS=""
@@ -30,6 +30,7 @@ BIGSMP_ARCHS="i686"
 PSERIES64_ARCHS="ppc"
 UP_ARCHS=""
 SRC_ARCHS=""
+#RPMSMPTYPE="smp"
 
 for cc in gcc ; do
     if which $cc >/dev/null 2>/dev/null ; then
diff --git a/lustre/kernel_patches/targets/2.6-sles11.target b/lustre/kernel_patches/targets/2.6-sles11.target
new file mode 100644
index 0000000..0194a51
--- /dev/null
+++ b/lustre/kernel_patches/targets/2.6-sles11.target
@@ -0,0 +1,40 @@
+lnxmaj="2.6.27"
+lnxmin=".23"
+# when we fix up this lnxmaj/lnxmin/lnxrel business...
+#lnxrel="0.37_f594963d"
+# and note that this means we get rid of the EXTRA_VERSION_DELIMITER crap!!
+lnxrel="23-0.1"
+
+# this is the delimeter that goes between $lnxmaj and $lnxrel
+# defaults to "-"
+EXTRA_VERSION_DELIMITER="."
+
+# this is the delimeter that goes before the "smp" at the end of the version
+# defaults to empty
+TARGET_DELIMITER="-"
+
+KERNEL_SRPM=kernel-source-$lnxmaj.$lnxrel.1.src.rpm
+SERIES=2.6-sles11.series
+VERSION=$lnxmaj
+EXTRA_VERSION="${lnxrel}_lustre.1.8.1"
+LUSTRE_VERSION=1.8.1
+
+OFED_VERSION=1.4.1
+
+BASE_ARCHS="i686 ppc x86_64 ia64 ppc64"
+BIGMEM_ARCHS=""
+BOOT_ARCHS=""
+JENSEN_ARCHS=""
+DEFAULT_ARCHS="i686 x86_64 ia64 ppc64"
+BIGSMP_ARCHS=""
+PSERIES64_ARCHS="ppc"
+UP_ARCHS=""
+SRC_ARCHS=""
+#RPMSMPTYPE="smp"
+
+for cc in gcc ; do
+    if which $cc >/dev/null 2>/dev/null ; then
+        export CC=$cc
+        break
+    fi
+done
diff --git a/lustre/kernel_patches/targets/2.6-sles11.target.in b/lustre/kernel_patches/targets/2.6-sles11.target.in
new file mode 100644
index 0000000..5080070
--- /dev/null
+++ b/lustre/kernel_patches/targets/2.6-sles11.target.in
@@ -0,0 +1,40 @@
+lnxmaj="2.6.27"
+lnxmin=".23"
+# when we fix up this lnxmaj/lnxmin/lnxrel business...
+#lnxrel="0.37_f594963d"
+# and note that this means we get rid of the EXTRA_VERSION_DELIMITER crap!!
+lnxrel="23-0.1"
+
+# this is the delimeter that goes between $lnxmaj and $lnxrel
+# defaults to "-"
+EXTRA_VERSION_DELIMITER="."
+
+# this is the delimeter that goes before the "smp" at the end of the version
+# defaults to empty
+TARGET_DELIMITER="-"
+
+KERNEL_SRPM=kernel-source-$lnxmaj.$lnxrel.1.src.rpm
+SERIES=2.6-sles11.series
+VERSION=$lnxmaj
+EXTRA_VERSION="${lnxrel}_lustre. at VERSION@"
+LUSTRE_VERSION=@VERSION@
+
+OFED_VERSION=1.4.1
+
+BASE_ARCHS="i686 ppc x86_64 ia64 ppc64"
+BIGMEM_ARCHS=""
+BOOT_ARCHS=""
+JENSEN_ARCHS=""
+DEFAULT_ARCHS="i686 x86_64 ia64 ppc64"
+BIGSMP_ARCHS=""
+PSERIES64_ARCHS="ppc"
+UP_ARCHS=""
+SRC_ARCHS=""
+#RPMSMPTYPE="smp"
+
+for cc in gcc ; do
+    if which $cc >/dev/null 2>/dev/null ; then
+        export CC=$cc
+        break
+    fi
+done
diff --git a/lustre/kernel_patches/targets/2.6-suse.target b/lustre/kernel_patches/targets/2.6-suse.target
index 29f4225..5cf206a 100644
--- a/lustre/kernel_patches/targets/2.6-suse.target
+++ b/lustre/kernel_patches/targets/2.6-suse.target
@@ -1,16 +1,20 @@
 lnxmaj="2.6.5"
-lnxrel="7.314"
+lnxrel="7.317"
 
 KERNEL=linux-$lnxmaj-$lnxrel.tar.bz2
 # they include our patches
 SERIES=2.6-suse-newer.series
 VERSION=$lnxmaj
-EXTRA_VERSION="${lnxrel}_lustre.1.6.7.2"
-LUSTRE_VERSION=1.6.7.2
+EXTRA_VERSION="${lnxrel}_lustre.1.8.1"
+LUSTRE_VERSION=1.8.1
 RHBUILD=0
 LINUX26=1
 SUSEBUILD=1
 
+# this is the delimeter that goes before the "smp" at the end of the version
+# defaults to empty
+TARGET_DELIMITER="-"
+
 BASE_ARCHS="i686 ppc x86_64 ia64"
 BIGMEM_ARCHS=""
 BOOT_ARCHS=""
diff --git a/lustre/kernel_patches/targets/2.6-suse.target.in b/lustre/kernel_patches/targets/2.6-suse.target.in
index be6dcb8..fd5eeed 100644
--- a/lustre/kernel_patches/targets/2.6-suse.target.in
+++ b/lustre/kernel_patches/targets/2.6-suse.target.in
@@ -1,5 +1,5 @@
 lnxmaj="2.6.5"
-lnxrel="7.314"
+lnxrel="7.317"
 
 KERNEL=linux-$lnxmaj-$lnxrel.tar.bz2
 # they include our patches
@@ -11,6 +11,10 @@ RHBUILD=0
 LINUX26=1
 SUSEBUILD=1
 
+# this is the delimeter that goes before the "smp" at the end of the version
+# defaults to empty
+TARGET_DELIMITER="-"
+
 BASE_ARCHS="i686 ppc x86_64 ia64"
 BIGMEM_ARCHS=""
 BOOT_ARCHS=""
diff --git a/lustre/kernel_patches/targets/2.6-vanilla.target b/lustre/kernel_patches/targets/2.6-vanilla.target
index be0f6ac..db7ec0a 100644
--- a/lustre/kernel_patches/targets/2.6-vanilla.target
+++ b/lustre/kernel_patches/targets/2.6-vanilla.target
@@ -12,8 +12,8 @@ TARGET_DELIMITER="-"
 KERNEL=linux-$lnxmaj.$lnxrel.tar.bz2
 SERIES=2.6.22-vanilla.series
 VERSION=$lnxmaj
-EXTRA_VERSION="${lnxrel}_lustre.1.6.7.2"
-LUSTRE_VERSION=1.6.7.2
+EXTRA_VERSION="${lnxrel}_lustre.1.8.1"
+LUSTRE_VERSION=1.8.1
 RHBUILD=0
 LINUX26=1
 # No /boot/Kerntypes* in SLES10
diff --git a/lustre/kernel_patches/targets/hp_pnnl-2.4.target b/lustre/kernel_patches/targets/hp_pnnl-2.4.target
index 9e7cdc0..7436e93 100644
--- a/lustre/kernel_patches/targets/hp_pnnl-2.4.target
+++ b/lustre/kernel_patches/targets/hp_pnnl-2.4.target
@@ -4,8 +4,8 @@ lnxrel=hp_pnnl
 KERNEL=linux-$lnxmaj-$lnxrel.tar.gz
 SERIES=hp-pnnl-2.4.20
 VERSION=$lnxmaj
-EXTRA_VERSION=$lnxrel_lustre.1.6.7.2
-LUSTRE_VERSION=1.6.7.2
+EXTRA_VERSION=$lnxrel_lustre.1.8.1
+LUSTRE_VERSION=1.8.1
 RHBUILD=0
 
 BASE_ARCHS="ia64"
diff --git a/lustre/kernel_patches/targets/rh-2.4.target b/lustre/kernel_patches/targets/rh-2.4.target
index 877f281..3d69c3b 100644
--- a/lustre/kernel_patches/targets/rh-2.4.target
+++ b/lustre/kernel_patches/targets/rh-2.4.target
@@ -4,8 +4,8 @@ lnxrel="31.9"
 KERNEL=linux-${lnxmaj}-${lnxrel}.tar.gz
 SERIES=rh-2.4.20
 VERSION=$lnxmaj
-EXTRA_VERSION=${lnxrel}_lustre.1.6.7.2
-LUSTRE_VERSION=1.6.7.2
+EXTRA_VERSION=${lnxrel}_lustre.1.8.1
+LUSTRE_VERSION=1.8.1
 RHBUILD=1
 
 BASE_ARCHS="i686"
diff --git a/lustre/kernel_patches/targets/rhel-2.4.target b/lustre/kernel_patches/targets/rhel-2.4.target
index 263d7c7..79a5fcc 100644
--- a/lustre/kernel_patches/targets/rhel-2.4.target
+++ b/lustre/kernel_patches/targets/rhel-2.4.target
@@ -4,8 +4,8 @@ lnxrel="47.0.1.EL"
 KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2
 SERIES=rhel-2.4.21
 VERSION=${lnxmaj}
-LUSTRE_VERSION=1.6.7.2
-EXTRA_VERSION=${lnxrel}_lustre.1.6.7.2
+LUSTRE_VERSION=1.8.1
+EXTRA_VERSION=${lnxrel}_lustre.1.8.1
 RHBUILD=1
 
 BASE_ARCHS="i686 x86_64 ia64"
diff --git a/lustre/kernel_patches/targets/sles-2.4.target b/lustre/kernel_patches/targets/sles-2.4.target
index ea3c092..d320ac0 100644
--- a/lustre/kernel_patches/targets/sles-2.4.target
+++ b/lustre/kernel_patches/targets/sles-2.4.target
@@ -4,8 +4,8 @@ lnxrel="273"
 KERNEL=linux-${lnxmaj}-${lnxrel}.tar.bz2
 SERIES=suse-2.4.21-jvn
 VERSION=${lnxmaj}
-EXTRA_VERSION=${lnxrel}_lustre.1.6.7.2
-LUSTRE_VERSION=1.6.7.2
+EXTRA_VERSION=${lnxrel}_lustre.1.8.1
+LUSTRE_VERSION=1.8.1
 RHBUILD=0
 LINUX26=0
 SUSEBUILD=1
diff --git a/lustre/kernel_patches/targets/suse-2.4.21-2.target b/lustre/kernel_patches/targets/suse-2.4.21-2.target
index c4a67e3..9c05e1f 100644
--- a/lustre/kernel_patches/targets/suse-2.4.21-2.target
+++ b/lustre/kernel_patches/targets/suse-2.4.21-2.target
@@ -1,8 +1,8 @@
 KERNEL=linux-2.4.21-x86_64.tar.gz
 SERIES=suse-2.4.21-2
 VERSION=2.4.21
-EXTRA_VERSION=lustre.1.6.7.2
-LUSTRE_VERSION=1.6.7.2
+EXTRA_VERSION=lustre.1.8.1
+LUSTRE_VERSION=1.8.1
 RHBUILD=0
 
 BASE_ARCHS="x86_64"
diff --git a/lustre/kernel_patches/which_patch b/lustre/kernel_patches/which_patch
index 1144357..d3261ff 100644
--- a/lustre/kernel_patches/which_patch
+++ b/lustre/kernel_patches/which_patch
@@ -1,20 +1,9 @@
 SERIES                VERSION                  COMMENT
 
 SUPPORTED KERNELS:
-2.6-suse              SLES9 before SP1         already in SLES9 SP1 kernel
-2.6-suse-newer        SLES9: 2.6.5-7.314       extra patches for SLES9 after SP1
-2.6-rhel4             RHEL4: 2.6.9-78.0.22.EL
-2.6-sles10            SLES10: 2.6.16.60-0.37
-2.6-rhel5             RHEL5: 2.6.18-92.1.26.el5
-2.6.18-vanilla        kernel.org: 2.6.18.8
-2.6.22-vanilla        kernel.org: 2.6.22.14
+2.6-sles10            SLES10: 2.6.16.60-0.39.3
+2.6-rhel5             RHEL5: 2.6.18-128.1.14.el5
+2.6-sles11            SLES11: 2.6.27.23-0.1
 
 CLIENT SUPPORT FOR UNPATCHED KERNELS:
-                   kernel.org 2.6.16-2.6.22
-                   RHEL4: 2.6.9-42.0.8EL
-
-NB - The patches in the 2.6-suse series are already in the SLES9 SP1
-     kernel.  The patches in the 2.6-suse-newer series are patches that
-     have been created since the SP1 kernel was released and should be
-     applied to the already-patched SP1 kernel.  Only the 2.6-suse-newer
-     series needs to be applied via quilt to any recent SLES9 kernel.
+                   kernel.org 2.6.16-2.6.27
diff --git a/lustre/ldlm/Makefile.am b/lustre/ldlm/Makefile.am
index 600c679..57897f2 100644
--- a/lustre/ldlm/Makefile.am
+++ b/lustre/ldlm/Makefile.am
@@ -39,7 +39,7 @@
 #
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES = ldlm_extent.c ldlm_flock.c ldlm_internal.h ldlm_lib.c \
+EXTRA_DIST = ldlm_extent.c ldlm_flock.c ldlm_internal.h ldlm_lib.c \
 	ldlm_lock.c ldlm_lockd.c ldlm_plain.c ldlm_request.c	     \
 	ldlm_resource.c l_lock.c ldlm_inodebits.c ldlm_pool.c 	     \
 	interval_tree.c
diff --git a/lustre/ldlm/Makefile.in b/lustre/ldlm/Makefile.in
index 2a1ada7..1560f66 100644
--- a/lustre/ldlm/Makefile.in
+++ b/lustre/ldlm/Makefile.in
@@ -215,9 +215,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -332,7 +332,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-DIST_SOURCES = ldlm_extent.c ldlm_flock.c ldlm_internal.h ldlm_lib.c \
+EXTRA_DIST = ldlm_extent.c ldlm_flock.c ldlm_internal.h ldlm_lib.c \
 	ldlm_lock.c ldlm_lockd.c ldlm_plain.c ldlm_request.c	     \
 	ldlm_resource.c l_lock.c ldlm_inodebits.c ldlm_pool.c 	     \
 	interval_tree.c
@@ -342,6 +342,7 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
+DIST_SOURCES =
 DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
 all: all-am
 
diff --git a/lustre/ldlm/interval_tree.c b/lustre/ldlm/interval_tree.c
index 21fa9e0..9154748 100644
--- a/lustre/ldlm/interval_tree.c
+++ b/lustre/ldlm/interval_tree.c
@@ -102,7 +102,7 @@ static inline int extent_equal(struct interval_node_extent *e1,
         return (e1->start == e2->start) && (e1->end == e2->end);
 }
 
-static inline int extent_overlapped(struct interval_node_extent *e1, 
+static inline int extent_overlapped(struct interval_node_extent *e1,
                                     struct interval_node_extent *e2)
 {
         return (e1->start <= e2->end) && (e2->start <= e1->end);
@@ -196,7 +196,7 @@ enum interval_iter interval_iterate(struct interval_node *root,
         struct interval_node *node;
         enum interval_iter rc = INTERVAL_ITER_CONT;
         ENTRY;
-        
+
         interval_for_each(node, root) {
                 rc = func(node, data);
                 if (rc == INTERVAL_ITER_STOP)
@@ -214,7 +214,7 @@ enum interval_iter interval_iterate_reverse(struct interval_node *root,
         struct interval_node *node;
         enum interval_iter rc = INTERVAL_ITER_CONT;
         ENTRY;
-        
+
         interval_for_each_reverse(node, root) {
                 rc = func(node, data);
                 if (rc == INTERVAL_ITER_STOP)
@@ -323,10 +323,10 @@ static void __rotate_right(struct interval_node *node,
 } while (0)
 
 /*
- * Operations INSERT and DELETE, when run on a tree with n keys, 
- * take O(logN) time.Because they modify the tree, the result 
- * may violate the red-black properties.To restore these properties, 
- * we must change the colors of some of the nodes in the tree 
+ * Operations INSERT and DELETE, when run on a tree with n keys,
+ * take O(logN) time.Because they modify the tree, the result
+ * may violate the red-black properties.To restore these properties,
+ * we must change the colors of some of the nodes in the tree
  * and also change the pointer structure.
  */
 static void interval_insert_color(struct interval_node *node,
@@ -385,7 +385,6 @@ static void interval_insert_color(struct interval_node *node,
 
 struct interval_node *interval_insert(struct interval_node *node,
                                       struct interval_node **root)
-                     
 {
         struct interval_node **p, *parent = NULL;
         ENTRY;
@@ -403,7 +402,7 @@ struct interval_node *interval_insert(struct interval_node *node,
 
                 if (node_compare(node, parent) < 0)
                         p = &parent->in_left;
-                else 
+                else
                         p = &parent->in_right;
         }
 
@@ -500,8 +499,8 @@ static void interval_erase_color(struct interval_node *node,
         EXIT;
 }
 
-/* 
- * if the @max_high value of @node is changed, this function traverse  a path 
+/*
+ * if the @max_high value of @node is changed, this function traverse  a path
  * from node  up to the root to update max_high for the whole tree.
  */
 static void update_maxhigh(struct interval_node *node,
@@ -657,13 +656,13 @@ enum interval_iter interval_search(struct interval_node *node,
                                 node = node->in_right;
                                 continue;
                         }
-                } 
+                }
 
                 parent = node->in_parent;
                 while (parent) {
                         if (node_is_left_child(node) &&
                             parent->in_right) {
-                                /* If we ever got the left, it means that the 
+                                /* If we ever got the left, it means that the
                                  * parent met ext->end<interval_low(parent), or
                                  * may_overlap(parent). If the former is true,
                                  * we needn't go back. So stop early and check
@@ -702,7 +701,7 @@ EXPORT_SYMBOL(interval_is_overlapped);
  * some extents, because programs seldom do IO backward.
  *
  * The recursive algorithm of expanding low:
- * expand_low {
+ * interval_expand_low {
  *        struct interval_node *tmp;
  *        static __u64 res = 0;
  *
@@ -724,7 +723,7 @@ EXPORT_SYMBOL(interval_is_overlapped);
  *        return res;
  * }
  *
- * It's much easy to eliminate the recursion, see interval_search for 
+ * It's much easy to eliminate the recursion, see interval_search for
  * an example. -jay
  */
 static inline __u64 interval_expand_low(struct interval_node *root, __u64 low)
@@ -742,7 +741,7 @@ static inline __u64 interval_expand_high(struct interval_node *node, __u64 high)
         while (node != NULL) {
                 if (node->in_max_high < high)
                         break;
-                        
+
                 if (interval_low(node) > high) {
                         result = interval_low(node) - 1;
                         node = node->in_left;
diff --git a/lustre/ldlm/l_lock.c b/lustre/ldlm/l_lock.c
index ac268ec..cb08f5b 100644
--- a/lustre/ldlm/l_lock.c
+++ b/lustre/ldlm/l_lock.c
@@ -52,16 +52,15 @@
  */
 struct ldlm_resource * lock_res_and_lock(struct ldlm_lock *lock)
 {
-        struct ldlm_resource *res = lock->l_resource;
-
-        if (ns_is_server(res->lr_namespace)) {
-                /* on server-side resource of lock doesn't change */
-                lock_res(res);
-                return res;
-        } 
+        struct ldlm_resource *res = NULL;
 
         spin_lock(&lock->l_lock);
         res = lock->l_resource;
+
+        if (ns_is_server(res->lr_namespace))
+                /* on server-side resource of lock doesn't change */
+                spin_unlock(&lock->l_lock);
+
         lock_res(res);
         return res;
 }
diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c
index c77b40c..10be102 100644
--- a/lustre/ldlm/ldlm_flock.c
+++ b/lustre/ldlm/ldlm_flock.c
@@ -101,11 +101,12 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, int flags)
         LASSERT(list_empty(&lock->l_flock_waitq));
 
         list_del_init(&lock->l_res_link);
-        if (flags == LDLM_FL_WAIT_NOREPROC) {
+        if (flags == LDLM_FL_WAIT_NOREPROC &&
+            !(lock->l_flags & LDLM_FL_FAILED)) {
                 /* client side - set a flag to prevent sending a CANCEL */
                 lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_CBPENDING;
 
-                /* when reaching here, it is under lock_res_and_lock(). Thus, 
+                /* when reaching here, it is under lock_res_and_lock(). Thus,
                    need call the nolock version of ldlm_lock_decref_internal*/
                 ldlm_lock_decref_internal_nolock(lock, mode);
         }
@@ -370,7 +371,8 @@ reprocess:
                                         NULL, 0);
                         lock_res_and_lock(req);
                         if (!new2) {
-                                ldlm_flock_destroy(req, lock->l_granted_mode, *flags);
+                                ldlm_flock_destroy(req, lock->l_granted_mode,
+                                                   *flags);
                                 *err = -ENOLCK;
                                 RETURN(LDLM_ITER_STOP);
                         }
@@ -391,14 +393,15 @@ reprocess:
                 new2->l_conn_export = lock->l_conn_export;
                 if (lock->l_export != NULL) {
                         new2->l_export = class_export_get(lock->l_export);
-                        if (new2->l_export->exp_lock_hash && 
+                        if (new2->l_export->exp_lock_hash &&
                             hlist_unhashed(&new2->l_exp_hash))
                                 lustre_hash_add(new2->l_export->exp_lock_hash,
                                                 &new2->l_remote_handle,
                                                 &new2->l_exp_hash);
                 }
                 if (*flags == LDLM_FL_WAIT_NOREPROC)
-                        ldlm_lock_addref_internal_nolock(new2, lock->l_granted_mode);
+                        ldlm_lock_addref_internal_nolock(new2,
+                                                         lock->l_granted_mode);
 
                 /* insert new2 at lock */
                 ldlm_resource_add_lock(res, ownlocks, new2);
@@ -423,7 +426,7 @@ reprocess:
         if (*flags != LDLM_FL_WAIT_NOREPROC) {
                 if (first_enq) {
                         /* If this is an unlock, reprocess the waitq and
-                         * send completions ASTs for locks that can now be 
+                         * send completions ASTs for locks that can now be
                          * granted. The only problem with doing this
                          * reprocessing here is that the completion ASTs for
                          * newly granted locks will be sent before the unlock
@@ -433,7 +436,7 @@ reprocess:
                          * ldlm_reprocess_queue. */
                         if ((mode == LCK_NL) && overlaps) {
                                 struct list_head rpc_list
-                                                    = CFS_LIST_HEAD_INIT(rpc_list);
+                                                 = CFS_LIST_HEAD_INIT(rpc_list);
                                 int rc;
 restart:
                                 ldlm_reprocess_queue(res, &res->lr_waiting,
@@ -494,17 +497,26 @@ ldlm_flock_interrupted_wait(void *data)
         EXIT;
 }
 
+/**
+ * Flock completion calback function.
+ *
+ * \param lock [in,out]: A lock to be handled
+ * \param flags    [in]: flags
+ * \param *data    [in]: ldlm_run_cp_ast_work() will use ldlm_cb_set_arg
+ *
+ * \retval 0    : success
+ * \retval <0   : failure
+ */
 int
 ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data)
 {
-        struct ldlm_namespace *ns;
-        cfs_flock_t *getlk = lock->l_ast_data;
-        struct ldlm_flock_wait_data fwd;
-        struct obd_device *obd;
-        struct obd_import *imp = NULL;
-        ldlm_error_t err;
-        int rc = 0;
-        struct l_wait_info lwi;
+        cfs_flock_t                    *getlk = lock->l_ast_data;
+        struct obd_device              *obd;
+        struct obd_import              *imp = NULL;
+        struct ldlm_flock_wait_data     fwd;
+        struct l_wait_info              lwi;
+        ldlm_error_t                    err;
+        int                             rc = 0;
         ENTRY;
 
         CDEBUG(D_DLMTRACE, "flags: 0x%x data: %p getlk: %p\n",
@@ -515,11 +527,12 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data)
          * holding the lock even if app still believes it has it, since
          * server already dropped it anyway. Only for granted locks too. */
         lock_res_and_lock(lock);
-        if ((lock->l_flags & (LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) == 
+        if ((lock->l_flags & (LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) ==
             (LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) {
                 unlock_res_and_lock(lock);
                 if (lock->l_req_mode == lock->l_granted_mode &&
-                    lock->l_granted_mode != LCK_NL)
+                    lock->l_granted_mode != LCK_NL &&
+                    NULL == data)
                         ldlm_lock_decref_internal(lock, lock->l_req_mode);
                 RETURN(0);
         }
@@ -528,20 +541,25 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data)
         LASSERT(flags != LDLM_FL_WAIT_NOREPROC);
 
         if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
-                       LDLM_FL_BLOCK_CONV)))
-                goto  granted;
+                       LDLM_FL_BLOCK_CONV))) {
+                if (NULL == data)
+                        /* mds granted the lock in the reply */
+                        goto granted;
+                /* CP AST RPC: lock get granted, wake it up */
+                cfs_waitq_signal(&lock->l_waitq);
+                RETURN(0);
+        }
 
         LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, "
                    "sleeping");
-
         fwd.fwd_lock = lock;
         obd = class_exp2obd(lock->l_conn_export);
 
-        /* if this is a local lock, then there is no import */
-        if (obd != NULL)
+        /* if this is a local lock, there is no import */
+        if (NULL != obd)
                 imp = obd->u.cli.cl_import;
 
-        if (imp != NULL) {
+        if (NULL != imp) {
                 spin_lock(&imp->imp_lock);
                 fwd.fwd_generation = imp->imp_generation;
                 spin_unlock(&imp->imp_lock);
@@ -550,27 +568,31 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data)
         lwi = LWI_TIMEOUT_INTR(0, NULL, ldlm_flock_interrupted_wait, &fwd);
 
         /* Go to sleep until the lock is granted. */
-        rc = l_wait_event(lock->l_waitq,
-                          ((lock->l_req_mode == lock->l_granted_mode) ||
-                           lock->l_destroyed), &lwi);
+        rc = l_wait_event(lock->l_waitq, is_granted_or_cancelled(lock), &lwi);
+
+        if (rc) {
+                LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)",
+                           rc);
+                RETURN(rc);
+        }
 
-        LDLM_DEBUG(lock, "client-side enqueue waking up: rc = %d", rc);
-        RETURN(rc);
- 
 granted:
         OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT, 10);
-        LDLM_DEBUG(lock, "client-side enqueue granted");
-        ns = lock->l_resource->lr_namespace;
-        lock_res_and_lock(lock);
 
-        /* before flock's complete ast gets here, the flock
-         * can possibly be freed by another thread
-         */
-        if (lock->l_destroyed) {
-                LDLM_DEBUG(lock, "already destroyed by another thread");
+        lock_res_and_lock(lock);
+        if (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED) {
+                LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed");
                 unlock_res_and_lock(lock);
-                RETURN(0);
+                RETURN(-EIO);
         }
+        if (rc) {
+                LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)",
+                           rc);
+                unlock_res_and_lock(lock);
+                RETURN(rc);
+        }
+
+        LDLM_DEBUG(lock, "client-side enqueue granted");
 
         /* take lock off the deadlock detection waitq. */
         spin_lock(&ldlm_flock_waitq_lock);
@@ -583,8 +605,9 @@ granted:
         if (flags & LDLM_FL_TEST_LOCK) {
                 /* fcntl(F_GETLK) request */
                 /* The old mode was saved in getlk->fl_type so that if the mode
-                 * in the lock changes we can decref the approprate refcount. */
-                ldlm_flock_destroy(lock, cfs_flock_type(getlk), LDLM_FL_WAIT_NOREPROC);
+                 * in the lock changes we can decref the appropriate refcount.*/
+                ldlm_flock_destroy(lock, cfs_flock_type(getlk),
+                                   LDLM_FL_WAIT_NOREPROC);
                 switch (lock->l_granted_mode) {
                 case LCK_PR:
                         cfs_flock_set_type(getlk, F_RDLCK);
@@ -595,17 +618,18 @@ granted:
                 default:
                         cfs_flock_set_type(getlk, F_UNLCK);
                 }
-                cfs_flock_set_pid(getlk, (pid_t)lock->l_policy_data.l_flock.pid);
-                cfs_flock_set_start(getlk, (loff_t)lock->l_policy_data.l_flock.start);
-                cfs_flock_set_end(getlk, (loff_t)lock->l_policy_data.l_flock.end);
+                cfs_flock_set_pid(getlk,
+                                  (pid_t)lock->l_policy_data.l_flock.pid);
+                cfs_flock_set_start(getlk,
+                                    (loff_t)lock->l_policy_data.l_flock.start);
+                cfs_flock_set_end(getlk,
+                                  (loff_t)lock->l_policy_data.l_flock.end);
         } else {
                 int noreproc = LDLM_FL_WAIT_NOREPROC;
 
                 /* We need to reprocess the lock to do merges or splits
                  * with existing locks owned by this process. */
                 ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL);
-                if (flags == 0)
-                        cfs_waitq_signal(&lock->l_waitq);
         }
         unlock_res_and_lock(lock);
         RETURN(0);
diff --git a/lustre/ldlm/ldlm_internal.h b/lustre/ldlm/ldlm_internal.h
index c316918..f6b4d30 100644
--- a/lustre/ldlm/ldlm_internal.h
+++ b/lustre/ldlm/ldlm_internal.h
@@ -45,19 +45,19 @@ extern struct list_head ldlm_cli_namespace_list;
 
 static inline atomic_t *ldlm_namespace_nr(ldlm_side_t client)
 {
-        return client == LDLM_NAMESPACE_SERVER ? 
+        return client == LDLM_NAMESPACE_SERVER ?
                 &ldlm_srv_namespace_nr : &ldlm_cli_namespace_nr;
 }
 
 static inline struct list_head *ldlm_namespace_list(ldlm_side_t client)
 {
-        return client == LDLM_NAMESPACE_SERVER ? 
+        return client == LDLM_NAMESPACE_SERVER ?
                 &ldlm_srv_namespace_list : &ldlm_cli_namespace_list;
 }
 
 static inline struct semaphore *ldlm_namespace_lock(ldlm_side_t client)
 {
-        return client == LDLM_NAMESPACE_SERVER ? 
+        return client == LDLM_NAMESPACE_SERVER ?
                 &ldlm_srv_namespace_lock : &ldlm_cli_namespace_lock;
 }
 
@@ -75,12 +75,10 @@ enum {
         LDLM_CANCEL_LRUR   = 1 << 3  /* Cancel locks from lru resize. */
 };
 
-int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, ldlm_sync_t sync, 
+int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, ldlm_sync_t sync,
                     int flags);
 int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels,
                           int count, int max, int cancel_flags, int flags);
-int ldlm_cancel_lru_estimate(struct ldlm_namespace *ns, int count, int max, 
-                             int flags);
 extern int ldlm_enqueue_min;
 int ldlm_get_enq_timeout(struct ldlm_lock *lock);
 
@@ -88,7 +86,7 @@ int ldlm_get_enq_timeout(struct ldlm_lock *lock);
 int ldlm_resource_putref_locked(struct ldlm_resource *res);
 void ldlm_resource_insert_lock_after(struct ldlm_lock *original,
                                      struct ldlm_lock *new);
-void ldlm_namespace_free_prior(struct ldlm_namespace *ns, 
+void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
                                struct obd_import *imp, int force);
 void ldlm_namespace_free_post(struct ldlm_namespace *ns);
 
@@ -235,3 +233,17 @@ typedef enum ldlm_policy_res ldlm_policy_res_t;
                 return rc;                                                  \
         }                                                                   \
         struct __##var##__dummy_write {;} /* semicolon catcher */
+
+static inline int is_granted_or_cancelled(struct ldlm_lock *lock)
+{
+        int ret = 0;
+
+        lock_res_and_lock(lock);
+        if (((lock->l_req_mode == lock->l_granted_mode) &&
+             !(lock->l_flags & LDLM_FL_CP_REQD)) ||
+            (lock->l_flags & LDLM_FL_FAILED))
+                ret = 1;
+        unlock_res_and_lock(lock);
+
+        return ret;
+}
diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c
index 1fc4a1a..f6f842b 100644
--- a/lustre/ldlm/ldlm_lib.c
+++ b/lustre/ldlm/ldlm_lib.c
@@ -209,12 +209,7 @@ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
         /* In a more perfect world, we would hang a ptlrpc_client off of
          * obd_type and just use the values from there. */
         if (!strcmp(name, LUSTRE_OSC_NAME)) {
-#ifdef __KERNEL__
-                /* Can be removed in Lustre 1.8, for compatibility only */
-                rq_portal = OST_IO_PORTAL;
-#else
                 rq_portal = OST_REQUEST_PORTAL;
-#endif
                 rp_portal = OSC_REPLY_PORTAL;
                 connect_op = OST_CONNECT;
         } else if (!strcmp(name, LUSTRE_MDC_NAME)) {
@@ -337,7 +332,7 @@ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
 
         cli->cl_import = imp;
         /* cli->cl_max_mds_{easize,cookiesize} updated by mdc_init_ea_size() */
-        cli->cl_max_mds_easize = sizeof(struct lov_mds_md);
+        cli->cl_max_mds_easize = sizeof(struct lov_mds_md_v3);
         cli->cl_max_mds_cookiesize = sizeof(struct llog_cookie);
 
         if (LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) {
@@ -385,13 +380,14 @@ int client_connect_import(struct lustre_handle *dlm_handle,
         ENTRY;
 
         down_write(&cli->cl_sem);
+        if (cli->cl_conn_count > 0)
+                GOTO(out_sem, rc = -EALREADY);
+        
         rc = class_connect(dlm_handle, obd, cluuid);
         if (rc)
                 GOTO(out_sem, rc);
 
         cli->cl_conn_count++;
-        if (cli->cl_conn_count > 1)
-                GOTO(out_sem, rc);
         *exp = class_conn2export(dlm_handle);
 
         if (obd->obd_namespace != NULL)
@@ -468,12 +464,12 @@ int client_disconnect_export(struct obd_export *exp)
         if (!cli->cl_conn_count) {
                 CERROR("disconnecting disconnected device (%s)\n",
                        obd->obd_name);
-                GOTO(out_sem, rc = -EINVAL);
+                GOTO(out_disconnect, rc = -EINVAL);
         }
 
         cli->cl_conn_count--;
         if (cli->cl_conn_count)
-                GOTO(out_no_disconnect, rc = 0);
+                GOTO(out_disconnect, rc = 0);
 
         /* Mark import deactivated now, so we don't try to reconnect if any
          * of the cleanup RPCs fails (e.g. ldlm cancel, etc).  We don't
@@ -513,11 +509,14 @@ int client_disconnect_export(struct obd_export *exp)
         cli->cl_import = NULL;
 
         EXIT;
- out_no_disconnect:
+
+ out_disconnect:
+        /* use server style - class_disconnect should be always called for
+         * o_disconnect */
         err = class_disconnect(exp);
         if (!rc && err)
                 rc = err;
- out_sem:
+
         up_write(&cli->cl_sem);
         if (to_be_freed)
                 ldlm_namespace_free_post(to_be_freed);
@@ -528,11 +527,12 @@ int client_disconnect_export(struct obd_export *exp)
  * from old lib/target.c
  * -------------------------------------------------------------------------- */
 
-int target_handle_reconnect(struct lustre_handle *conn, struct obd_export *exp,
-                            struct obd_uuid *cluuid, int mds_conn)
+static int target_handle_reconnect(struct lustre_handle *conn,
+                                   struct obd_export *exp,
+                                   struct obd_uuid *cluuid)
 {
         ENTRY;
-        if (exp->exp_connection && exp->exp_imp_reverse && !mds_conn) {
+        if (exp->exp_connection && exp->exp_imp_reverse) {
                 struct lustre_handle *hdl;
                 hdl = &exp->exp_imp_reverse->imp_remote_handle;
                 /* Might be a re-connect after a partition. */
@@ -583,6 +583,41 @@ target_start_and_reset_recovery_timer(struct obd_device *obd,
                                       svc_handler_t handler,
                                       struct ptlrpc_request *req,
                                       int new_client);
+void target_stop_recovery(void *, int);
+static void reset_recovery_timer(struct obd_device *obd, int duration,
+                                 int extend);
+int target_recovery_check_and_stop(struct obd_device *obd)
+{
+        int abort_recovery = 0;
+
+        spin_lock_bh(&obd->obd_processing_task_lock);
+        abort_recovery = obd->obd_abort_recovery;
+        obd->obd_abort_recovery = 0;
+        spin_unlock_bh(&obd->obd_processing_task_lock);
+        if (!abort_recovery)
+                return 0;
+        /** check is fs version-capable */
+        if (target_fs_version_capable(obd)) {
+                class_handle_stale_exports(obd);
+        } else {
+                CWARN("Versions are not supported by ldiskfs, VBR is OFF\n");
+                class_disconnect_stale_exports(obd, exp_flags_from_obd(obd));
+        }
+        /* VBR: no clients are remained to replay, stop recovery */
+        spin_lock_bh(&obd->obd_processing_task_lock);
+        if (obd->obd_recovering && obd->obd_recoverable_clients == 0) {
+                spin_unlock_bh(&obd->obd_processing_task_lock);
+                target_stop_recovery(obd, 0);
+                return 1;
+        }
+        /* always check versions now */
+        obd->obd_version_recov = 1;
+        spin_unlock_bh(&obd->obd_processing_task_lock);
+        /* reset timer, recovery will proceed with versions now */
+        reset_recovery_timer(obd, OBD_RECOVERY_FACTOR * obd_timeout, 1);
+        return 0;
+}
+EXPORT_SYMBOL(target_recovery_check_and_stop);
 
 int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
 {
@@ -594,7 +629,7 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
         struct obd_uuid cluuid;
         struct obd_uuid remote_uuid;
         char *str, *tmp;
-        int rc = 0, abort_recovery;
+        int rc = 0;
         struct obd_connect_data *data;
         __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*data) };
         lnet_nid_t *client_nid = NULL;
@@ -669,11 +704,7 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
                 LBUG();
         }
 
-        spin_lock_bh(&target->obd_processing_task_lock);
-        abort_recovery = target->obd_abort_recovery;
-        spin_unlock_bh(&target->obd_processing_task_lock);
-        if (abort_recovery)
-                target_abort_recovery(target);
+        target_recovery_check_and_stop(target);
 
         tmp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn);
         if (tmp == NULL)
@@ -724,18 +755,36 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
         if (obd_uuid_equals(&cluuid, &target->obd_uuid))
                 goto dont_check_exports;
 
-        spin_lock(&target->obd_dev_lock);
         export = lustre_hash_lookup(target->obd_uuid_hash, &cluuid);
+        if (!export)
+                goto no_export;
 
-        if (export != NULL && export->exp_connecting) { /* bug 9635, et. al. */
+        /* we've found an export in the hash */
+        if (export->exp_connecting) {
+                /* bug 9635, et. al. */
                 CWARN("%s: exp %p already connecting\n",
                       export->exp_obd->obd_name, export);
                 class_export_put(export);
                 export = NULL;
                 rc = -EALREADY;
-        } else if (export != NULL && export->exp_connection != NULL &&
-                   req->rq_peer.nid != export->exp_connection->c_peer.nid &&
-                   !mds_conn) {
+        } else if (mds_conn && export->exp_connection) {
+                if (req->rq_peer.nid != export->exp_connection->c_peer.nid)
+                        /* mds reconnected after failover */
+                        CWARN("%s: received MDS connection from NID %s,"
+                              " removing former export from NID %s\n",
+                            target->obd_name, libcfs_nid2str(req->rq_peer.nid),
+                            libcfs_nid2str(export->exp_connection->c_peer.nid));
+                else
+                        /* new mds connection from the same nid */
+                        CWARN("%s: received new MDS connection from NID %s,"
+                              " removing former export from same NID\n",
+                            target->obd_name, libcfs_nid2str(req->rq_peer.nid));
+                class_fail_export(export);
+                class_export_put(export);
+                export = NULL;
+                rc = 0;
+        } else if (export->exp_connection &&
+                   req->rq_peer.nid != export->exp_connection->c_peer.nid) {
                 CWARN("%s: cookie %s seen on new NID %s when "
                       "existing NID %s is already connected\n",
                       target->obd_name, cluuid.uuid,
@@ -744,26 +793,31 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
                 rc = -EALREADY;
                 class_export_put(export);
                 export = NULL;
-        } else if (export != NULL && export->exp_failed) { /* bug 11327 */
+        } else if (export->exp_failed) { /* bug 11327 */
                 CDEBUG(D_HA, "%s: exp %p evict in progress - new cookie needed "
                       "for connect\n", export->exp_obd->obd_name, export);
                 class_export_put(export);
                 export = NULL;
                 rc = -ENODEV;
-        } else if (export != NULL) {
+        } else if (export->exp_delayed &&
+                   !(data && data->ocd_connect_flags & OBD_CONNECT_VBR)) {
+                class_fail_export(export);
+                class_export_put(export);
+                export = NULL;
+                GOTO(out, rc = -ENODEV);
+        } else {
                 spin_lock(&export->exp_lock);
                 export->exp_connecting = 1;
                 spin_unlock(&export->exp_lock);
                 class_export_put(export);
-                spin_unlock(&target->obd_dev_lock);
                 LASSERT(export->exp_obd == target);
 
-                rc = target_handle_reconnect(&conn, export, &cluuid, mds_conn);
+                rc = target_handle_reconnect(&conn, export, &cluuid);
         }
 
         /* If we found an export, we already unlocked. */
         if (!export) {
-                spin_unlock(&target->obd_dev_lock);
+no_export:
                 OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_CONNECT, 2 * obd_timeout);
         } else if (req->rq_export == NULL &&
                    atomic_read(&export->exp_rpc_count) > 0) {
@@ -774,23 +828,25 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
                 GOTO(out, rc = -EBUSY);
         } else if (req->rq_export != NULL &&
                    atomic_read(&export->exp_rpc_count) > 1) {
+                /* the current connect rpc has increased exp_rpc_count */
                 CWARN("%s: refuse reconnection from %s@%s to 0x%p; still busy "
                       "with %d active RPCs\n", target->obd_name, cluuid.uuid,
                       libcfs_nid2str(req->rq_peer.nid),
-                      export, atomic_read(&export->exp_rpc_count));
+                      export, atomic_read(&export->exp_rpc_count) - 1);
                 GOTO(out, rc = -EBUSY);
-        } else if (lustre_msg_get_conn_cnt(req->rq_reqmsg) == 1 &&
-                   !mds_conn) {
+        } else if (lustre_msg_get_conn_cnt(req->rq_reqmsg) == 1) {
                 CERROR("%s: NID %s (%s) reconnected with 1 conn_cnt; "
                        "cookies not random?\n", target->obd_name,
                        libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
                 GOTO(out, rc = -EALREADY);
+        } else if (export->exp_delayed && target->obd_recovering) {
+                /* VBR: don't allow delayed connection during recovery */
+                CWARN("%s: NID %s (%s) export was already marked as delayed "
+                      "and will wait for end of recovery\n", target->obd_name,
+                       libcfs_nid2str(req->rq_peer.nid), cluuid.uuid);
+                GOTO(out, rc = -EBUSY);
         } else {
                 OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_RECONNECT, 2 * obd_timeout);
-                if (req->rq_export == NULL && mds_conn)
-                       export->exp_last_request_time =
-                               max(export->exp_last_request_time,
-                                   (time_t)cfs_time_current_sec());
         }
 
         if (rc < 0)
@@ -820,6 +876,18 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
                 lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_REPLAYABLE);
         client_nid = &req->rq_peer.nid;
 
+        /* VBR: for delayed connections we start recovery */
+        if (export && export->exp_delayed && !export->exp_in_recovery) {
+                LASSERT(!target->obd_recovering);
+                LASSERT(data && data->ocd_connect_flags & OBD_CONNECT_VBR);
+                lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_DELAYED |
+                                        MSG_CONNECT_RECOVERING);
+                spin_lock_bh(&target->obd_processing_task_lock);
+                target->obd_version_recov = 1;
+                spin_unlock_bh(&target->obd_processing_task_lock);
+                target_start_and_reset_recovery_timer(target, handler, req, 1);
+        }
+
         if (export == NULL) {
                 if (target->obd_recovering) {
                         CERROR("%s: denying connection for new client %s (%s): "
@@ -876,9 +944,7 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
         req->rq_export = export;
 
         spin_lock(&export->exp_lock);
-        if (mds_conn) {
-                lustre_msg_set_conn_cnt(req->rq_reqmsg, export->exp_conn_cnt + 1);
-        } else if (export->exp_conn_cnt >= lustre_msg_get_conn_cnt(req->rq_reqmsg)) {
+        if (export->exp_conn_cnt >= lustre_msg_get_conn_cnt(req->rq_reqmsg)) {
                 CERROR("%s: %s already connected at higher conn_cnt: %d > %d\n",
                        cluuid.uuid, libcfs_nid2str(req->rq_peer.nid),
                        export->exp_conn_cnt,
@@ -918,9 +984,12 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
                 GOTO(set_flags, rc = 0);
         }
 
-        if (target->obd_recovering)
+        if (target->obd_recovering && !export->exp_in_recovery) {
+                spin_lock(&export->exp_lock);
+                export->exp_in_recovery = 1;
+                spin_unlock(&export->exp_lock);
                 target->obd_connected_clients++;
-
+        }
         memcpy(&conn,
                lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2, sizeof conn),
                sizeof conn);
@@ -1047,26 +1116,26 @@ static void target_release_saved_req(struct ptlrpc_request *req)
         OBD_FREE(req, sizeof *req);
 }
 
-static void target_finish_recovery(struct obd_device *obd)
+static void target_send_delayed_replies(struct obd_device *obd)
 {
-        struct list_head *tmp, *n;
+        int max_clients = obd->obd_max_recoverable_clients;
+        struct ptlrpc_request *req, *tmp;
+        time_t elapsed_time = max_t(time_t, 1, cfs_time_current_sec() -
+                                    obd->obd_recovery_start);
+
+        LCONSOLE_INFO("%s: Recovery period over after %d:%.02d, of %d clients "
+                      "%d recovered and %d %s evicted.\n", obd->obd_name,
+                      (int)elapsed_time/60, (int)elapsed_time%60, max_clients,
+                      obd->obd_connected_clients,
+                      obd->obd_stale_clients,
+                      obd->obd_stale_clients == 1 ? "was" : "were");
 
         LCONSOLE_INFO("%s: sending delayed replies to recovered clients\n",
                       obd->obd_name);
 
-        ldlm_reprocess_all_ns(obd->obd_namespace);
-
-        /* when recovery finished, cleanup orphans on mds and ost */
-        if (OBT(obd) && OBP(obd, postrecov)) {
-                int rc = OBP(obd, postrecov)(obd);
-                LCONSOLE_WARN("%s: recovery %s: rc %d\n", obd->obd_name,
-                              rc < 0 ? "failed" : "complete", rc);
-        }
-
-        list_for_each_safe(tmp, n, &obd->obd_delayed_reply_queue) {
-                struct ptlrpc_request *req;
-                req = list_entry(tmp, struct ptlrpc_request, rq_list);
-                list_del(&req->rq_list);
+        list_for_each_entry_safe(req, tmp, &obd->obd_delayed_reply_queue,
+                                 rq_list) {
+                list_del_init(&req->rq_list);
                 DEBUG_REQ(D_HA, req, "delayed:");
                 ptlrpc_reply(req);
                 target_release_saved_req(req);
@@ -1074,16 +1143,46 @@ static void target_finish_recovery(struct obd_device *obd)
         obd->obd_recovery_end = cfs_time_current_sec();
 }
 
+static void target_finish_recovery(struct obd_device *obd)
+{
+        OBD_RACE(OBD_FAIL_TGT_REPLAY_DELAY);
+
+        ldlm_reprocess_all_ns(obd->obd_namespace);
+        spin_lock_bh(&obd->obd_processing_task_lock);
+        if (list_empty(&obd->obd_recovery_queue)) {
+                obd->obd_recovery_thread = NULL;
+                obd->obd_processing_task = 0;
+        } else {
+                spin_unlock_bh(&obd->obd_processing_task_lock);
+                CERROR("%s: Recovery queue isn't empty\n", obd->obd_name);
+                LBUG();
+        }
+        spin_unlock_bh(&obd->obd_processing_task_lock);
+                ;
+        /* when recovery finished, cleanup orphans on mds and ost */
+        if (OBT(obd) && OBP(obd, postrecov)) {
+                int rc = OBP(obd, postrecov)(obd);
+                if (rc < 0)
+                        LCONSOLE_WARN("%s: Post recovery failed, rc %d\n",
+                                      obd->obd_name, rc);
+        }
+        target_send_delayed_replies(obd);
+}
+
 static void abort_recovery_queue(struct obd_device *obd)
 {
-        struct ptlrpc_request *req;
-        struct list_head *tmp, *n;
+        struct ptlrpc_request *req, *n;
+        struct list_head abort_list;
         int rc;
 
-        list_for_each_safe(tmp, n, &obd->obd_recovery_queue) {
-                req = list_entry(tmp, struct ptlrpc_request, rq_list);
+        CFS_INIT_LIST_HEAD(&abort_list);
+        spin_lock_bh(&obd->obd_processing_task_lock);
+        list_splice_init(&obd->obd_recovery_queue, &abort_list);
+        spin_unlock_bh(&obd->obd_processing_task_lock);
+        /* process abort list unlocked */
+        list_for_each_entry_safe(req, n, &abort_list, rq_list) {
                 target_exp_dequeue_req_replay(req);
-                list_del(&req->rq_list);
+                list_del_init(&req->rq_list);
                 DEBUG_REQ(D_ERROR, req, "aborted:");
                 req->rq_status = -ENOTCONN;
                 req->rq_type = PTL_RPC_MSG_ERR;
@@ -1110,6 +1209,7 @@ void target_cleanup_recovery(struct obd_device *obd)
 {
         struct list_head *tmp, *n;
         struct ptlrpc_request *req;
+        struct list_head clean_list;
         ENTRY;
 
         LASSERT(obd->obd_stopping);
@@ -1130,16 +1230,20 @@ void target_cleanup_recovery(struct obd_device *obd)
                 target_release_saved_req(req);
         }
 
-        list_for_each_safe(tmp, n, &obd->obd_recovery_queue) {
+        CFS_INIT_LIST_HEAD(&clean_list);
+        spin_lock_bh(&obd->obd_processing_task_lock);
+        list_splice_init(&obd->obd_recovery_queue, &clean_list);
+        spin_unlock_bh(&obd->obd_processing_task_lock);
+        list_for_each_safe(tmp, n, &clean_list) {
                 req = list_entry(tmp, struct ptlrpc_request, rq_list);
                 target_exp_dequeue_req_replay(req);
-                list_del(&req->rq_list);
+                list_del_init(&req->rq_list);
                 target_release_saved_req(req);
         }
         EXIT;
 }
 
-void target_abort_recovery(void *data)
+void target_stop_recovery(void *data, int abort)
 {
         struct obd_device *obd = data;
         enum obd_option flags;
@@ -1152,35 +1256,50 @@ void target_abort_recovery(void *data)
                 return;
         }
         flags = exp_flags_from_obd(obd) | OBD_OPT_ABORT_RECOV;
-        obd->obd_recovering = obd->obd_abort_recovery = 0;
+        obd->obd_recovering = 0;
+        obd->obd_abort_recovery = 0;
+        obd->obd_processing_task = 0;
+        if (abort == 0)
+                LASSERT(obd->obd_recoverable_clients == 0);
+
         target_cancel_recovery_timer(obd);
         spin_unlock_bh(&obd->obd_processing_task_lock);
 
-        LCONSOLE_WARN("%s: recovery period over; %d clients never reconnected "
-                      "after %lds (%d clients did)\n",
-                      obd->obd_name, obd->obd_recoverable_clients,
-                      cfs_time_current_sec()- obd->obd_recovery_start,
-                      obd->obd_connected_clients);
-        class_disconnect_stale_exports(obd, flags);
+        if (abort) {
+                LCONSOLE_WARN("%s: recovery is aborted by administrative "
+                              "request; %d clients are not recovered "
+                              "(%d clients did)\n", obd->obd_name,
+                              obd->obd_recoverable_clients,
+                              obd->obd_connected_clients);
+                class_disconnect_stale_exports(obd, flags);
+        }
         abort_recovery_queue(obd);
-
         target_finish_recovery(obd);
         CDEBUG(D_HA, "%s: recovery complete\n", obd_uuid2str(&obd->obd_uuid));
         EXIT;
 }
 
+void target_abort_recovery(void *data)
+{
+        target_stop_recovery(data, 1);
+}
+
+static void reset_recovery_timer(struct obd_device *, int, int);
 static void target_recovery_expired(unsigned long castmeharder)
 {
         struct obd_device *obd = (struct obd_device *)castmeharder;
-        CERROR("%s: recovery timed out, aborting\n", obd->obd_name);
+        CDEBUG(D_HA, "%s: recovery period over; %d clients never reconnected "
+               "after %lds (%d clients did)\n", obd->obd_name,
+               obd->obd_recoverable_clients,
+               cfs_time_current_sec() - obd->obd_recovery_start,
+               obd->obd_connected_clients);
+
         spin_lock_bh(&obd->obd_processing_task_lock);
-        if (obd->obd_recovering)
-                obd->obd_abort_recovery = 1;
+        obd->obd_abort_recovery = 1;
         cfs_waitq_signal(&obd->obd_next_transno_waitq);
         spin_unlock_bh(&obd->obd_processing_task_lock);
 }
 
-
 /* obd_processing_task_lock should be held */
 void target_cancel_recovery_timer(struct obd_device *obd)
 {
@@ -1237,7 +1356,7 @@ static void check_and_start_recovery_timer(struct obd_device *obd,
                 spin_unlock_bh(&obd->obd_processing_task_lock);
                 return;
         }
-        CWARN("%s: starting recovery timer\n", obd->obd_name);
+        CDEBUG(D_HA, "%s: starting recovery timer\n", obd->obd_name);
         obd->obd_recovery_start = cfs_time_current_sec();
         /* minimum */
         obd->obd_recovery_timeout = OBD_RECOVERY_FACTOR * obd_timeout;
@@ -1269,7 +1388,7 @@ target_start_and_reset_recovery_timer(struct obd_device *obd,
 
         if (!new_client && service_time)
                 /* Teach server about old server's estimates, as first guess
-                 * at how long new requests will take. */
+                   at how long new requests will take. */
                 at_add(&req->rq_rqbd->rqbd_service->srv_at_estimate,
                        service_time);
 
@@ -1300,13 +1419,15 @@ static int check_for_next_transno(struct obd_device *obd)
         max = obd->obd_max_recoverable_clients;
         req_transno = lustre_msg_get_transno(req->rq_reqmsg);
         connected = obd->obd_connected_clients;
-        completed = max - obd->obd_recoverable_clients;
+        completed = max - obd->obd_recoverable_clients -
+                    obd->obd_delayed_clients;
         queue_len = obd->obd_requests_queued_for_recovery;
         next_transno = obd->obd_next_recovery_transno;
 
-        CDEBUG(D_HA,"max: %d, connected: %d, completed: %d, queue_len: %d, "
-               "req_transno: "LPU64", next_transno: "LPU64"\n",
-               max, connected, completed, queue_len, req_transno, next_transno);
+        CDEBUG(D_HA,"max: %d, connected: %d, delayed %d, completed: %d, "
+               "queue_len: %d, req_transno: "LPU64", next_transno: "LPU64"\n",
+               max, connected, obd->obd_delayed_clients, completed, queue_len,
+               req_transno, next_transno);
         if (obd->obd_abort_recovery) {
                 CDEBUG(D_HA, "waking for aborted recovery\n");
                 wake_up = 1;
@@ -1316,7 +1437,7 @@ static int check_for_next_transno(struct obd_device *obd)
         } else if (req_transno == next_transno) {
                 CDEBUG(D_HA, "waking for next ("LPD64")\n", next_transno);
                 wake_up = 1;
-        } else if (queue_len + completed == max) {
+        } else if (queue_len == obd->obd_recoverable_clients) {
                 CDEBUG(D_ERROR,
                        "waking for skipped transno (skip: "LPD64
                        ", ql: %d, comp: %d, conn: %d, next: "LPD64")\n",
@@ -1332,7 +1453,6 @@ static int check_for_next_transno(struct obd_device *obd)
 static void process_recovery_queue(struct obd_device *obd)
 {
         struct ptlrpc_request *req;
-        int abort_recovery = 0;
         struct l_wait_info lwi = { 0 };
         ENTRY;
 
@@ -1352,17 +1472,14 @@ static void process_recovery_queue(struct obd_device *obd)
                                req->rq_xid);
                         l_wait_event(obd->obd_next_transno_waitq,
                                      check_for_next_transno(obd), &lwi);
-                        spin_lock_bh(&obd->obd_processing_task_lock);
-                        abort_recovery = obd->obd_abort_recovery;
-                        spin_unlock_bh(&obd->obd_processing_task_lock);
-                        if (abort_recovery) {
-                                target_abort_recovery(obd);
+                        if (target_recovery_check_and_stop(obd))
                                 return;
-                        }
                         continue;
                 }
-                target_exp_dequeue_req_replay(req);
                 list_del_init(&req->rq_list);
+                LASSERT(obd->obd_recovery_thread);
+                /* replace request initial thread with current one, bug #18221 */
+                req->rq_svc_thread = obd->obd_recovery_thread;
                 obd->obd_requests_queued_for_recovery--;
                 spin_unlock_bh(&obd->obd_processing_task_lock);
 
@@ -1375,14 +1492,19 @@ static void process_recovery_queue(struct obd_device *obd)
                        at_get(&req->rq_rqbd->rqbd_service->srv_at_estimate), 1);
                 /* bug 1580: decide how to properly sync() in recovery */
                 //mds_fsync_super(obd->u.obt.obt_sb);
+                spin_lock_bh(&obd->obd_processing_task_lock);
+                obd->obd_next_recovery_transno++;
+                spin_unlock_bh(&obd->obd_processing_task_lock);
+                target_exp_dequeue_req_replay(req);
                 class_export_put(req->rq_export);
                 ptlrpc_req_drop_rs(req);
                 OBD_FREE(req->rq_reqmsg, req->rq_reqlen);
                 OBD_FREE(req, sizeof *req);
+                OBD_RACE(OBD_FAIL_TGT_REPLAY_DELAY);
                 spin_lock_bh(&obd->obd_processing_task_lock);
-                obd->obd_next_recovery_transno++;
                 if (list_empty(&obd->obd_recovery_queue)) {
                         obd->obd_processing_task = 0;
+                        obd->obd_recovery_thread = NULL;
                         spin_unlock_bh(&obd->obd_processing_task_lock);
                         break;
                 }
@@ -1499,6 +1621,8 @@ int target_queue_recovery_request(struct ptlrpc_request *req,
          * now, so we'll do the honours.
          */
         obd->obd_processing_task = cfs_curproc_pid();
+        /* save thread that handle recovery queue */
+        obd->obd_recovery_thread = req->rq_svc_thread;
         spin_unlock_bh(&obd->obd_processing_task_lock);
 
         process_recovery_queue(obd);
@@ -1522,7 +1646,8 @@ int target_queue_last_replay_reply(struct ptlrpc_request *req, int rc)
         struct obd_device *obd = target_req2obd(req);
         struct ptlrpc_request *saved_req;
         struct lustre_msg *reqmsg;
-        int recovery_done = 0;
+        struct obd_export *exp = req->rq_export;
+        int recovery_done = 0, delayed_done = 0;
 
         LASSERT ((rc == 0) == req->rq_packed_final);
 
@@ -1552,47 +1677,129 @@ int target_queue_last_replay_reply(struct ptlrpc_request *req, int rc)
         spin_lock_bh(&obd->obd_processing_task_lock);
         if (obd->obd_stopping) {
                 spin_unlock_bh(&obd->obd_processing_task_lock);
-                OBD_FREE(reqmsg, req->rq_reqlen);
-                OBD_FREE(saved_req, sizeof *req);
-                req->rq_status = -ENOTCONN;
-                /* rv is ignored anyhow */
-                return -ENOTCONN;
+                goto out_noconn;
+        }
+
+        if (!exp->exp_vbr_failed) {
+                ptlrpc_rs_addref(req->rq_reply_state);  /* +1 ref for saved reply */
+                req = saved_req;
+                req->rq_reqmsg = reqmsg;
+                CFS_INIT_LIST_HEAD(&req->rq_list);
+                CFS_INIT_LIST_HEAD(&req->rq_replay_list);
+                class_export_get(exp);
+                list_add(&req->rq_list, &obd->obd_delayed_reply_queue);
         }
-        ptlrpc_rs_addref(req->rq_reply_state);  /* +1 ref for saved reply */
-        req = saved_req;
-        req->rq_reqmsg = reqmsg;
-        class_export_get(req->rq_export);
-        list_add(&req->rq_list, &obd->obd_delayed_reply_queue);
 
         /* only count the first "replay over" request from each
            export */
-        if (req->rq_export->exp_replay_needed) {
-                --obd->obd_recoverable_clients;
+        if (exp->exp_replay_needed) {
+                spin_lock(&exp->exp_lock);
+                exp->exp_replay_needed = 0;
+                spin_unlock(&exp->exp_lock);
 
-                spin_lock(&req->rq_export->exp_lock);
-                req->rq_export->exp_replay_needed = 0;
-                spin_unlock(&req->rq_export->exp_lock);
+                if (!exp->exp_delayed) {
+                        --obd->obd_recoverable_clients;
+                } else {
+                        spin_lock(&exp->exp_lock);
+                        exp->exp_delayed = 0;
+                        spin_unlock(&exp->exp_lock);
+                        delayed_done = 1;
+                        if (obd->obd_delayed_clients == 0) {
+                                spin_unlock_bh(&obd->obd_processing_task_lock);
+                                LBUG();
+                        }
+                        --obd->obd_delayed_clients;
+                }
         }
         recovery_done = (obd->obd_recoverable_clients == 0);
         spin_unlock_bh(&obd->obd_processing_task_lock);
 
+        if (delayed_done) {
+                /* start pinging export */
+                spin_lock(&obd->obd_dev_lock);
+                list_add_tail(&exp->exp_obd_chain_timed,
+                              &obd->obd_exports_timed);
+                list_move_tail(&exp->exp_obd_chain, &obd->obd_exports);
+                spin_unlock(&obd->obd_dev_lock);
+                target_send_delayed_replies(obd);
+        }
+
         OBD_RACE(OBD_FAIL_LDLM_RECOV_CLIENTS);
         if (recovery_done) {
                 spin_lock_bh(&obd->obd_processing_task_lock);
-                obd->obd_recovering = obd->obd_abort_recovery = 0;
+                obd->obd_recovering = 0;
+                obd->obd_version_recov = 0;
+                obd->obd_abort_recovery = 0;
                 target_cancel_recovery_timer(obd);
                 spin_unlock_bh(&obd->obd_processing_task_lock);
 
-                target_finish_recovery(obd);
+                if (!delayed_done)
+                        target_finish_recovery(obd);
                 CDEBUG(D_HA, "%s: recovery complete\n",
                        obd_uuid2str(&obd->obd_uuid));
         } else {
                 CWARN("%s: %d recoverable clients remain\n",
-                       obd->obd_name, obd->obd_recoverable_clients);
+                      obd->obd_name, obd->obd_recoverable_clients);
                 cfs_waitq_signal(&obd->obd_next_transno_waitq);
         }
 
+        /* VBR: disconnect export with failed recovery */
+        if (exp->exp_vbr_failed) {
+                CWARN("%s: disconnect export %s\n", obd->obd_name,
+                      exp->exp_client_uuid.uuid);
+                class_fail_export(exp);
+                OBD_FREE(reqmsg, req->rq_reqlen);
+                OBD_FREE(saved_req, sizeof *req);
+                req->rq_status = 0;
+                ptlrpc_send_reply(req, 0);
+        }
+
         return 1;
+
+out_noconn:
+        OBD_FREE(reqmsg, req->rq_reqlen);
+        OBD_FREE(saved_req, sizeof *req);
+        req->rq_status = -ENOTCONN;
+        /* rv is ignored anyhow */
+        return -ENOTCONN;
+}
+
+int target_handle_reply(struct ptlrpc_request *req, int rc, int fail)
+{
+        struct obd_device *obd = NULL;
+
+        if (req->rq_export)
+                obd = target_req2obd(req);
+
+        /* handle replay reply for version recovery */
+        if (obd && obd->obd_version_recov &&
+            (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)) {
+                LASSERT(req->rq_repmsg);
+                lustre_msg_add_flags(req->rq_repmsg, MSG_VERSION_REPLAY);
+        }
+
+        /* handle last replay */
+        if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY) {
+                if (obd &&
+                    lustre_msg_get_flags(req->rq_reqmsg) & MSG_DELAY_REPLAY) {
+                        DEBUG_REQ(D_HA, req,
+                                  "delayed LAST_REPLAY, queuing reply");
+                        rc = target_queue_last_replay_reply(req, rc);
+                        LASSERT(req->rq_export->exp_delayed == 0);
+                        return rc;
+                }
+
+                if (obd && obd->obd_recovering) { /* normal recovery */
+                        DEBUG_REQ(D_HA, req, "LAST_REPLAY, queuing reply");
+                        rc = target_queue_last_replay_reply(req, rc);
+                        return rc;
+                }
+
+                /* Lost a race with recovery; let the error path DTRT. */
+                rc = req->rq_status = -ENOTCONN;
+        }
+        target_send_reply(req, rc, fail);
+        return 0;
 }
 
 static inline struct ldlm_pool *ldlm_exp2pl(struct obd_export *exp)
@@ -1681,7 +1888,7 @@ target_send_reply(struct ptlrpc_request *req, int rc, int fail_id)
         LASSERT (list_empty(&rs->rs_obd_list));
         LASSERT (list_empty(&rs->rs_exp_list));
 
-        exp = class_export_get (req->rq_export);
+        exp = class_export_get(req->rq_export);
         obd = exp->exp_obd;
 
         /* disable reply scheduling onto srv_reply_queue while I'm setting up */
@@ -1691,15 +1898,16 @@ target_send_reply(struct ptlrpc_request *req, int rc, int fail_id)
         rs->rs_transno   = req->rq_transno;
         rs->rs_export    = exp;
 
-        spin_lock(&obd->obd_uncommitted_replies_lock);
+        spin_lock(&exp->exp_uncommitted_replies_lock);
 
-        if (rs->rs_transno > obd->obd_last_committed) {
+        /* VBR: use exp_last_committed */
+        if (rs->rs_transno > exp->exp_last_committed) {
                 /* not committed already */
                 list_add_tail (&rs->rs_obd_list,
-                               &obd->obd_uncommitted_replies);
+                               &exp->exp_uncommitted_replies);
         }
 
-        spin_unlock (&obd->obd_uncommitted_replies_lock);
+        spin_unlock (&exp->exp_uncommitted_replies_lock);
         spin_lock (&exp->exp_lock);
 
         list_add_tail (&rs->rs_exp_list, &exp->exp_outstanding_replies);
@@ -1738,23 +1946,29 @@ target_send_reply(struct ptlrpc_request *req, int rc, int fail_id)
 
 int target_handle_ping(struct ptlrpc_request *req)
 {
+        if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY &&
+            req->rq_export->exp_in_recovery) {
+                spin_lock(&req->rq_export->exp_lock);
+                req->rq_export->exp_in_recovery = 0;
+                spin_unlock(&req->rq_export->exp_lock);
+        }
         obd_ping(req->rq_export);
         return lustre_pack_reply(req, 1, NULL, NULL);
 }
 
 void target_committed_to_req(struct ptlrpc_request *req)
 {
-        struct obd_device *obd = req->rq_export->exp_obd;
-
-        if (!obd->obd_no_transno && req->rq_repmsg != NULL)
+        struct obd_export *exp = req->rq_export;
+        if (!exp->exp_obd->obd_no_transno && req->rq_repmsg != NULL) {
                 lustre_msg_set_last_committed(req->rq_repmsg,
-                                              obd->obd_last_committed);
-        else
+                                              exp->exp_last_committed);
+        } else {
                 DEBUG_REQ(D_IOCTL, req, "not sending last_committed update (%d/"
-                          "%d)", obd->obd_no_transno, req->rq_repmsg == NULL);
-
+                          "%d)", exp->exp_obd->obd_no_transno,
+                          req->rq_repmsg == NULL);
+        }
         CDEBUG(D_INFO, "last_committed x"LPU64", this req x"LPU64"\n",
-               obd->obd_last_committed, req->rq_xid);
+               exp->exp_obd->obd_last_committed, req->rq_xid);
 }
 
 EXPORT_SYMBOL(target_committed_to_req);
@@ -1767,7 +1981,7 @@ int target_handle_qc_callback(struct ptlrpc_request *req)
         oqctl = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*oqctl),
                                    lustre_swab_obd_quotactl);
         if (oqctl == NULL) {
-                CERROR("Can't unpack obd_quotactl\n");
+                CERROR("Can't unpack obd_quatactl\n");
                 RETURN(-EPROTO);
         }
 
diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c
index f2d1045..4dbe222 100644
--- a/lustre/ldlm/ldlm_lock.c
+++ b/lustre/ldlm/ldlm_lock.c
@@ -170,8 +170,8 @@ void ldlm_lock_put(struct ldlm_lock *lock)
                         OBD_FREE(lock->l_lvb_data, lock->l_lvb_len);
 
                 ldlm_interval_free(ldlm_interval_detach(lock));
-                OBD_FREE_RCU_CB(lock, sizeof(*lock), &lock->l_handle, 
-                      	        ldlm_lock_free);
+                OBD_FREE_RCU_CB(lock, sizeof(*lock), &lock->l_handle,
+                                ldlm_lock_free);
         }
 
         EXIT;
@@ -184,8 +184,8 @@ int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock)
                 struct ldlm_namespace *ns = lock->l_resource->lr_namespace;
                 LASSERT(lock->l_resource->lr_type != LDLM_FLOCK);
                 list_del_init(&lock->l_lru);
+                LASSERT(ns->ns_nr_unused > 0);
                 ns->ns_nr_unused--;
-                LASSERT(ns->ns_nr_unused >= 0);
                 rc = 1;
         }
         return rc;
@@ -265,8 +265,7 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock)
         }
         lock->l_destroyed = 1;
 
-        if (lock->l_export && lock->l_export->exp_lock_hash && 
-            !hlist_unhashed(&lock->l_exp_hash))
+        if (lock->l_export && lock->l_export->exp_lock_hash)
                 lustre_hash_del(lock->l_export->exp_lock_hash,
                                 &lock->l_remote_handle, &lock->l_exp_hash);
 
@@ -554,7 +553,7 @@ void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
         check_res_locked(lock->l_resource);
         if (new)
                 ldlm_add_bl_work_item(lock, new, work_list);
-        else 
+        else
                 ldlm_add_cp_work_item(lock, work_list);
         EXIT;
 }
@@ -590,7 +589,7 @@ void ldlm_lock_addref_internal(struct ldlm_lock *lock, __u32 mode)
 
 /* only called in ldlm_flock_destroy and for local locks.
  * for LDLM_FLOCK type locks, l_blocking_ast is null, and
- * ldlm_lock_remove_from_lru() does nothing, it is safe 
+ * ldlm_lock_remove_from_lru() does nothing, it is safe
  * for ldlm_flock_destroy usage by dropping some code */
 void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock, __u32 mode)
 {
@@ -658,10 +657,10 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode)
                 if (lock->l_flags & LDLM_FL_FAIL_LOC)
                         OBD_RACE(OBD_FAIL_LDLM_CP_BL_RACE);
 
-                /* Call ldlm_cancel_lru() only if EARLY_CANCEL and LRU RESIZE 
-                 * are not supported by the server, otherwise, it is done on 
+                /* Call ldlm_cancel_lru() only if EARLY_CANCEL and LRU RESIZE
+                 * are not supported by the server, otherwise, it is done on
                  * enqueue. */
-                if (!exp_connect_cancelset(lock->l_conn_export) && 
+                if (!exp_connect_cancelset(lock->l_conn_export) &&
                     !ns_connect_lru_resize(ns))
                         ldlm_cancel_lru(ns, 0, LDLM_ASYNC, 0);
         } else {
@@ -770,7 +769,7 @@ static void search_granted_lock(struct list_head *queue,
 
                                 /* jump to next policy group within the mode group */
                                 tmp = policy_end->l_res_link.next;
-                                lock = list_entry(tmp, struct ldlm_lock, 
+                                lock = list_entry(tmp, struct ldlm_lock,
                                                   l_res_link);
                         }  /* loop over policy groups within the mode group */
 
@@ -796,7 +795,7 @@ static void search_granted_lock(struct list_head *queue,
         return;
 }
 
-static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, 
+static void ldlm_granted_list_add_lock(struct ldlm_lock *lock,
                                        struct sl_insert_point *prev)
 {
         struct ldlm_resource *res = lock->l_resource;
@@ -1226,6 +1225,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
 
         ldlm_resource_unlink_lock(lock);
         if (res->lr_type == LDLM_EXTENT && lock->l_tree_node == NULL) {
+                LASSERT(!local && (*flags & LDLM_FL_REPLAY));
                 if (node == NULL) {
                         ldlm_lock_destroy_nolock(lock);
                         GOTO(out, rc = -ENOMEM);
@@ -1315,7 +1315,7 @@ int ldlm_reprocess_queue(struct ldlm_resource *res, struct list_head *queue,
 }
 
 /* Helper function for pair ldlm_run_{bl,cp}_ast_work().
- * 
+ *
  * Send an existing rpc set specified by @arg->set and then
  * destroy it. Create new one if @do_create flag is set. */
 static void
@@ -1364,7 +1364,7 @@ int ldlm_run_bl_ast_work(struct list_head *rpc_list)
 
                 LDLM_LOCK_PUT(lock->l_blocking_lock);
                 lock->l_blocking_lock = NULL;
-                rc = lock->l_blocking_ast(lock, &d, (void *)&arg, 
+                rc = lock->l_blocking_ast(lock, &d, (void *)&arg,
                                           LDLM_CB_BLOCKING);
                 LDLM_LOCK_PUT(lock);
                 ast_count++;
@@ -1383,7 +1383,7 @@ int ldlm_run_bl_ast_work(struct list_head *rpc_list)
         else
                 /* In case when number of ASTs is multiply of
                  * PARALLEL_AST_LIMIT or @rpc_list was initially empty,
-                 * @arg.set must be destroyed here, otherwise we get 
+                 * @arg.set must be destroyed here, otherwise we get
                  * write memory leaking. */
                 ptlrpc_set_destroy(arg.set);
 
@@ -1412,7 +1412,7 @@ int ldlm_run_cp_ast_work(struct list_head *rpc_list)
          * will never call the local blocking_ast until we drop our
          * reader/writer reference, which we won't do until we get the
          * reply and finish enqueueing. */
-        
+
         ast_count = 0;
         list_for_each_safe(tmp, pos, rpc_list) {
                 struct ldlm_lock *lock =
@@ -1449,7 +1449,7 @@ int ldlm_run_cp_ast_work(struct list_head *rpc_list)
         else
                 /* In case when number of ASTs is multiply of
                  * PARALLEL_AST_LIMIT or @rpc_list was initially empty,
-                 * @arg.set must be destroyed here, otherwise we get 
+                 * @arg.set must be destroyed here, otherwise we get
                  * write memory leaking. */
                 ptlrpc_set_destroy(arg.set);
 
@@ -1573,7 +1573,7 @@ void ldlm_lock_cancel(struct ldlm_lock *lock)
 
         /* Yes, second time, just in case it was added again while we were
            running with no res lock in ldlm_cancel_callback */
-        ldlm_del_waiting_lock(lock); 
+        ldlm_del_waiting_lock(lock);
         ldlm_resource_unlink_lock(lock);
         ldlm_lock_destroy_nolock(lock);
 
@@ -1665,8 +1665,8 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
         old_mode = lock->l_req_mode;
         lock->l_req_mode = new_mode;
         if (res->lr_type == LDLM_PLAIN || res->lr_type == LDLM_IBITS) {
-                /* remember the lock position where the lock might be 
-                 * added back to the granted list later and also 
+                /* remember the lock position where the lock might be
+                 * added back to the granted list later and also
                  * remember the join mode for skiplist fixing. */
                 prev.res_link = lock->l_res_link.prev;
                 prev.mode_link = lock->l_sl_mode.prev;
@@ -1675,7 +1675,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
         } else {
                 ldlm_resource_unlink_lock(lock);
                 if (res->lr_type == LDLM_EXTENT) {
-                        /* FIXME: ugly code, I have to attach the lock to a 
+                        /* FIXME: ugly code, I have to attach the lock to a
                          * interval node again since perhaps it will be granted
                          * soon */
                         CFS_INIT_LIST_HEAD(&node->li_group);
@@ -1798,13 +1798,13 @@ void ldlm_lock_dump_handle(int level, struct lustre_handle *lockh)
 }
 
 void _ldlm_lock_debug(struct ldlm_lock *lock, __u32 level,
-		      struct libcfs_debug_msg_data *data, const char *fmt,
+                      struct libcfs_debug_msg_data *data, const char *fmt,
                       ...)
 {
         va_list args;
         cfs_debug_limit_state_t *cdls = data->msg_cdls;
 
-	va_start(args, fmt);
+        va_start(args, fmt);
         if (lock->l_resource == NULL) {
                 libcfs_debug_vmsg2(cdls, data->msg_subsys, level, data->msg_file,
                                    data->msg_fn, data->msg_line, fmt, args,
@@ -1819,7 +1819,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, __u32 level,
                                    lock->l_export ?
                                         atomic_read(&lock->l_export->exp_refcount) : -99,
                                    lock->l_pid, lock->l_callback_timeout);
-		va_end(args);
+                va_end(args);
                 return;
         }
 
diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c
index 7fd5fa2..3c06d8f 100644
--- a/lustre/ldlm/ldlm_lockd.c
+++ b/lustre/ldlm/ldlm_lockd.c
@@ -140,8 +140,8 @@ struct ldlm_bl_work_item {
 static inline int have_expired_locks(void)
 {
         int need_to_run;
-
         ENTRY;
+
         spin_lock_bh(&waiting_locks_spinlock);
         need_to_run = !list_empty(&expired_lock_thread.elt_expired_locks);
         spin_unlock_bh(&waiting_locks_spinlock);
@@ -373,7 +373,7 @@ static int __ldlm_add_waiting_lock(struct ldlm_lock *lock, int seconds)
 
         if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT) ||
             OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_HPREQ_TIMEOUT))
-                seconds = 2;
+                seconds = 1;
 
         timeout = cfs_time_shift(seconds);
         if (likely(cfs_time_after(timeout, lock->l_callback_timeout)))
@@ -395,6 +395,7 @@ static int __ldlm_add_waiting_lock(struct ldlm_lock *lock, int seconds)
 static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
 {
         int ret;
+        int timeout = ldlm_get_enq_timeout(lock);
 
         LASSERT(!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK));
 
@@ -410,15 +411,16 @@ static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
                 return 0;
         }
 
-        ret = __ldlm_add_waiting_lock(lock, ldlm_get_enq_timeout(lock));
+        ret = __ldlm_add_waiting_lock(lock, timeout);
         if (ret)
                 /* grab ref on the lock if it has been added to the
                  * waiting list */
                 LDLM_LOCK_GET(lock);
         spin_unlock_bh(&waiting_locks_spinlock);
 
-        LDLM_DEBUG(lock, "%sadding to wait list",
-                   ret == 0 ? "not re-" : "");
+        LDLM_DEBUG(lock, "%sadding to wait list(timeout: %d, AT: %s)",
+                   ret == 0 ? "not re-" : "", timeout,
+                   AT_OFF ? "off" : "on");
         return ret;
 }
 
@@ -803,7 +805,7 @@ int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data)
         if (total_enqueue_wait > obd_timeout)
                 /* non-fatal with AT - change to LDLM_DEBUG? */
                 LDLM_WARN(lock, "enqueue wait took %lus from %lu",
-                           total_enqueue_wait, lock->l_last_activity);
+                          total_enqueue_wait, lock->l_last_activity);
 
         lock_res_and_lock(lock);
         if (lock->l_resource->lr_lvb_len) {
@@ -858,6 +860,8 @@ int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data)
         lock_res_and_lock(lock);
         if (lock->l_flags & LDLM_FL_AST_SENT) {
                 body->lock_flags |= LDLM_FL_AST_SENT;
+                /* copy ast flags like LDLM_FL_DISCARD_DATA */
+                body->lock_flags |= (lock->l_flags & LDLM_AST_FLAGS);
 
                 /* We might get here prior to ldlm_handle_enqueue setting
                  * LDLM_FL_CANCEL_ON_BLOCK flag. Then we will put this lock
@@ -898,7 +902,7 @@ int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
         int rc = 0;
         ENTRY;
 
-        LASSERT(lock != NULL);
+        LASSERT(lock != NULL && lock->l_export != NULL);
 
         req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
                               LUSTRE_DLM_VERSION, LDLM_GL_CALLBACK, 2, size,
@@ -1099,10 +1103,9 @@ int ldlm_handle_enqueue(struct ptlrpc_request *req,
         }
         lock->l_export = class_export_get(req->rq_export);
 
-        if (lock->l_export->exp_lock_hash) {
+        if (lock->l_export->exp_lock_hash)
                 lustre_hash_add(lock->l_export->exp_lock_hash,
                                 &lock->l_remote_handle, &lock->l_exp_hash);
-        }
 
 existing_lock:
 
@@ -1133,8 +1136,7 @@ existing_lock:
         if (dlm_req->lock_desc.l_resource.lr_type == LDLM_EXTENT)
                 lock->l_req_extent = lock->l_policy_data.l_extent;
 
-        err = ldlm_lock_enqueue(obddev->obd_namespace, &lock, cookie, 
-                                (int *)&flags);
+        err = ldlm_lock_enqueue(obddev->obd_namespace, &lock, cookie, (int *)&flags);
         if (err)
                 GOTO(out, err);
 
@@ -1649,22 +1651,6 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
          * message buffers. */
 
         if (req->rq_export == NULL) {
-                struct ldlm_request *dlm_req;
-
-                CDEBUG(D_RPCTRACE, "operation %d from %s with bad "
-                       "export cookie "LPX64"; this is "
-                       "normal if this node rebooted with a lock held\n",
-                       lustre_msg_get_opc(req->rq_reqmsg),
-                       libcfs_id2str(req->rq_peer),
-                       lustre_msg_get_handle(req->rq_reqmsg)->cookie);
-
-                dlm_req = lustre_swab_reqbuf(req, DLM_LOCKREQ_OFF,
-                                             sizeof(*dlm_req),
-                                             lustre_swab_ldlm_request);
-                if (dlm_req != NULL)
-                        CDEBUG(D_RPCTRACE, "--> lock cookie: "LPX64"\n",
-                               dlm_req->lock_handle[0].cookie);
-
                 ldlm_callback_reply(req, -ENOTCONN);
                 RETURN(0);
         }
@@ -1753,7 +1739,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
                 RETURN(0);
         }
 
-        if ((lock->l_flags & LDLM_FL_FAIL_LOC) && 
+        if ((lock->l_flags & LDLM_FL_FAIL_LOC) &&
             lustre_msg_get_opc(req->rq_reqmsg) == LDLM_BL_CALLBACK)
                 OBD_RACE(OBD_FAIL_LDLM_CP_BL_RACE);
 
@@ -1997,8 +1983,8 @@ static int ldlm_bl_thread_main(void *arg)
 
 #endif
 
-/* 
- * Export handle<->lock hash operations. 
+/*
+ * Export handle<->lock hash operations.
  */
 static unsigned
 ldlm_export_lock_hash(lustre_hash_t *lh, void *key, unsigned mask)
@@ -2153,7 +2139,7 @@ static int ldlm_setup(void)
         ldlm_state->ldlm_cb_service =
                 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
                                 LDLM_MAXREPSIZE, LDLM_CB_REQUEST_PORTAL,
-                                LDLM_CB_REPLY_PORTAL, 1800,
+                                LDLM_CB_REPLY_PORTAL, 2,
                                 ldlm_callback_handler, "ldlm_cbd",
                                 ldlm_svc_proc_dir, NULL,
                                 ldlm_min_threads, ldlm_max_threads,
@@ -2167,7 +2153,7 @@ static int ldlm_setup(void)
         ldlm_state->ldlm_cancel_service =
                 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
                                 LDLM_MAXREPSIZE, LDLM_CANCEL_REQUEST_PORTAL,
-                                LDLM_CANCEL_REPLY_PORTAL, 6000,
+                                LDLM_CANCEL_REPLY_PORTAL, 6,
                                 ldlm_cancel_handler, "ldlm_canceld",
                                 ldlm_svc_proc_dir, NULL,
                                 ldlm_min_threads, ldlm_max_threads,
@@ -2314,8 +2300,8 @@ int __init ldlm_init(void)
                 return -ENOMEM;
 
         ldlm_lock_slab = cfs_mem_cache_create("ldlm_locks",
-                                           sizeof(struct ldlm_lock), 0,
-                                           SLAB_HWCACHE_ALIGN);
+                                      sizeof(struct ldlm_lock), 0,
+                                      SLAB_HWCACHE_ALIGN | SLAB_DESTROY_BY_RCU);
         if (ldlm_lock_slab == NULL) {
                 cfs_mem_cache_destroy(ldlm_resource_slab);
                 return -ENOMEM;
@@ -2340,6 +2326,12 @@ void __exit ldlm_exit(void)
                 CERROR("ldlm_refcount is %d in ldlm_exit!\n", ldlm_refcount);
         rc = cfs_mem_cache_destroy(ldlm_resource_slab);
         LASSERTF(rc == 0, "couldn't free ldlm resource slab\n");
+#ifdef __KERNEL__
+        /* ldlm_lock_put() use RCU to call ldlm_lock_free, so need call
+         * synchronize_rcu() to wait a grace period elapsed, so that
+         * ldlm_lock_free() get a chance to be called. */
+        synchronize_rcu();
+#endif
         rc = cfs_mem_cache_destroy(ldlm_lock_slab);
         LASSERTF(rc == 0, "couldn't free ldlm lock slab\n");
         rc = cfs_mem_cache_destroy(ldlm_interval_slab);
@@ -2438,7 +2430,7 @@ EXPORT_SYMBOL(target_queue_recovery_request);
 EXPORT_SYMBOL(target_handle_ping);
 EXPORT_SYMBOL(target_pack_pool_reply);
 EXPORT_SYMBOL(target_handle_disconnect);
-EXPORT_SYMBOL(target_queue_last_replay_reply);
+EXPORT_SYMBOL(target_handle_reply);
 
 /* l_lock.c */
 EXPORT_SYMBOL(lock_res_and_lock);
diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c
index d3a9dc2..f8908f6 100644
--- a/lustre/ldlm/ldlm_pool.c
+++ b/lustre/ldlm/ldlm_pool.c
@@ -38,7 +38,7 @@
  * Author: Yury Umanets <umka at clusterfs.com>
  */
 
-/* 
+/*
  * Idea of this code is rather simple. Each second, for each server namespace
  * we have SLV - server lock volume which is calculated on current number of
  * granted locks, grant speed for past period, etc - that is, locking load.
@@ -111,17 +111,17 @@
 #ifdef HAVE_LRU_RESIZE_SUPPORT
 
 /*
- * 50 ldlm locks for 1MB of RAM. 
+ * 50 ldlm locks for 1MB of RAM.
  */
 #define LDLM_POOL_HOST_L ((num_physpages >> (20 - CFS_PAGE_SHIFT)) * 50)
 
 /*
- * Maximal possible grant step plan in %. 
+ * Maximal possible grant step plan in %.
  */
 #define LDLM_POOL_MAX_GSP (30)
 
 /*
- * Minimal possible grant step plan in %. 
+ * Minimal possible grant step plan in %.
  */
 #define LDLM_POOL_MIN_GSP (1)
 
@@ -133,13 +133,13 @@
  */
 #define LDLM_POOL_GSP_STEP (4)
 
-/* 
- * LDLM_POOL_GSP% of all locks is default GP. 
+/*
+ * LDLM_POOL_GSP% of all locks is default GP.
  */
 #define LDLM_POOL_GP(L)   (((L) * LDLM_POOL_MAX_GSP) / 100)
 
-/* 
- * Max age for locks on clients. 
+/*
+ * Max age for locks on clients.
  */
 #define LDLM_POOL_MAX_AGE (36000)
 
@@ -161,7 +161,7 @@ static inline __u64 ldlm_pool_slv_max(__u32 L)
 {
         /*
          * Allow to have all locks for 1 client for 10 hrs.
-         * Formula is the following: limit * 10h / 1 client. 
+         * Formula is the following: limit * 10h / 1 client.
          */
         __u64 lim = L *  LDLM_POOL_MAX_AGE / 1;
         return lim;
@@ -194,7 +194,7 @@ static inline struct ldlm_namespace *ldlm_pl2ns(struct ldlm_pool *pl)
 }
 
 /**
- * Calculates suggested grant_step in % of available locks for passed 
+ * Calculates suggested grant_step in % of available locks for passed
  * \a period. This is later used in grant_plan calculations.
  */
 static inline int ldlm_pool_t2gsp(int t)
@@ -202,7 +202,7 @@ static inline int ldlm_pool_t2gsp(int t)
         /*
          * This yeilds 1% grant step for anything below LDLM_POOL_GSP_STEP
          * and up to 30% for anything higher than LDLM_POOL_GSP_STEP.
-         * 
+         *
          * How this will affect execution is the following:
          *
          * - for thread peroid 1s we will have grant_step 1% which good from
@@ -214,25 +214,25 @@ static inline int ldlm_pool_t2gsp(int t)
          *
          * - for thread period 10s (which is default) we will have 23% which
          * means that clients will have enough of room to take some new locks
-         * without getting some back. All locks from this 23% which were not 
+         * without getting some back. All locks from this 23% which were not
          * taken by clients in current period will contribute in SLV growing.
          * SLV growing means more locks cached on clients until limit or grant
          * plan is reached.
          */
-        return LDLM_POOL_MAX_GSP - 
-                (LDLM_POOL_MAX_GSP - LDLM_POOL_MIN_GSP) / 
+        return LDLM_POOL_MAX_GSP -
+                (LDLM_POOL_MAX_GSP - LDLM_POOL_MIN_GSP) /
                 (1 << (t / LDLM_POOL_GSP_STEP));
 }
 
 /**
  * Recalculates next grant limit on passed \a pl.
  *
- * \pre ->pl_lock is locked. 
+ * \pre ->pl_lock is locked.
  */
 static inline void ldlm_pool_recalc_grant_plan(struct ldlm_pool *pl)
 {
         int granted, grant_step, limit;
-        
+
         limit = ldlm_pool_get_limit(pl);
         granted = atomic_read(&pl->pl_granted);
 
@@ -244,7 +244,7 @@ static inline void ldlm_pool_recalc_grant_plan(struct ldlm_pool *pl)
 /**
  * Recalculates next SLV on passed \a pl.
  *
- * \pre ->pl_lock is locked. 
+ * \pre ->pl_lock is locked.
  */
 static inline void ldlm_pool_recalc_slv(struct ldlm_pool *pl)
 {
@@ -261,13 +261,13 @@ static inline void ldlm_pool_recalc_slv(struct ldlm_pool *pl)
         if (grant_usage <= 0)
                 grant_usage = 1;
 
-        /* 
-         * Find out SLV change factor which is the ratio of grant usage 
-         * from limit. SLV changes as fast as the ratio of grant plan 
-         * consumtion. The more locks from grant plan are not consumed 
-         * by clients in last interval (idle time), the faster grows 
+        /*
+         * Find out SLV change factor which is the ratio of grant usage
+         * from limit. SLV changes as fast as the ratio of grant plan
+         * consumtion. The more locks from grant plan are not consumed
+         * by clients in last interval (idle time), the faster grows
          * SLV. And the opposite, the more grant plan is over-consumed
-         * (load time) the faster drops SLV. 
+         * (load time) the faster drops SLV.
          */
         slv_factor = (grant_usage * 100) / limit;
         if (2 * abs(granted - limit) > limit) {
@@ -289,7 +289,7 @@ static inline void ldlm_pool_recalc_slv(struct ldlm_pool *pl)
 /**
  * Recalculates next stats on passed \a pl.
  *
- * \pre ->pl_lock is locked. 
+ * \pre ->pl_lock is locked.
  */
 static inline void ldlm_pool_recalc_stats(struct ldlm_pool *pl)
 {
@@ -299,7 +299,7 @@ static inline void ldlm_pool_recalc_stats(struct ldlm_pool *pl)
         int grant_rate = atomic_read(&pl->pl_grant_rate);
         int cancel_rate = atomic_read(&pl->pl_cancel_rate);
 
-        lprocfs_counter_add(pl->pl_stats, LDLM_POOL_SLV_STAT, 
+        lprocfs_counter_add(pl->pl_stats, LDLM_POOL_SLV_STAT,
                             slv);
         lprocfs_counter_add(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
                             granted);
@@ -318,12 +318,12 @@ static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl)
 {
         struct obd_device *obd;
 
-        /* 
+        /*
          * Set new SLV in obd field for using it later without accessing the
          * pool. This is required to avoid race between sending reply to client
          * with new SLV and cleanup server stack in which we can't guarantee
          * that namespace is still alive. We know only that obd is alive as
-         * long as valid export is alive. 
+         * long as valid export is alive.
          */
         obd = ldlm_pl2ns(pl)->ns_obd;
         LASSERT(obd != NULL);
@@ -335,7 +335,7 @@ static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl)
 /**
  * Recalculates all pool fields on passed \a pl.
  *
- * \pre ->pl_lock is not locked. 
+ * \pre ->pl_lock is not locked.
  */
 static int ldlm_srv_pool_recalc(struct ldlm_pool *pl)
 {
@@ -347,25 +347,24 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl)
         if (recalc_interval_sec >= pl->pl_recalc_period) {
                 /*
                  * Recalc SLV after last period. This should be done
-                 * _before_ recalculating new grant plan. 
+                 * _before_ recalculating new grant plan.
                  */
                 ldlm_pool_recalc_slv(pl);
-                
+
                 /*
-                 * Make sure that pool informed obd of last SLV changes. 
+                 * Make sure that pool informed obd of last SLV changes.
                  */
                 ldlm_srv_pool_push_slv(pl);
 
                 /*
-                 * Update grant_plan for new period. 
+                 * Update grant_plan for new period.
                  */
                 ldlm_pool_recalc_grant_plan(pl);
 
                 pl->pl_recalc_time = cfs_time_current_sec();
-                lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, 
+                lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
                                     recalc_interval_sec);
         }
-
         spin_unlock(&pl->pl_lock);
         RETURN(0);
 }
@@ -374,32 +373,31 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl)
  * This function is used on server side as main entry point for memory
  * preasure handling. It decreases SLV on \a pl according to passed
  * \a nr and \a gfp_mask.
- * 
+ *
  * Our goal here is to decrease SLV such a way that clients hold \a nr
- * locks smaller in next 10h. 
+ * locks smaller in next 10h.
  */
 static int ldlm_srv_pool_shrink(struct ldlm_pool *pl,
                                 int nr, unsigned int gfp_mask)
 {
         __u32 limit;
-        ENTRY;
 
-        /* 
-         * VM is asking how many entries may be potentially freed. 
+        /*
+         * VM is asking how many entries may be potentially freed.
          */
         if (nr == 0)
-                RETURN(atomic_read(&pl->pl_granted));
+                return atomic_read(&pl->pl_granted);
 
-        /* 
+        /*
          * Client already canceled locks but server is already in shrinker
-         * and can't cancel anything. Let's catch this race. 
+         * and can't cancel anything. Let's catch this race.
          */
         if (atomic_read(&pl->pl_granted) == 0)
                 RETURN(0);
 
         spin_lock(&pl->pl_lock);
 
-        /* 
+        /*
          * We want shrinker to possibly cause cancelation of @nr locks from
          * clients or grant approximately @nr locks smaller next intervals.
          *
@@ -409,7 +407,7 @@ static int ldlm_srv_pool_shrink(struct ldlm_pool *pl,
          * interval pool will either increase SLV if locks load is not high
          * or will keep on same level or even decrease again, thus, shrinker
          * decreased SLV will affect next recalc intervals and this way will
-         * make locking load lower. 
+         * make locking load lower.
          */
         if (nr < pl->pl_server_lock_volume) {
                 pl->pl_server_lock_volume = pl->pl_server_lock_volume - nr;
@@ -418,17 +416,17 @@ static int ldlm_srv_pool_shrink(struct ldlm_pool *pl,
                 pl->pl_server_lock_volume = ldlm_pool_slv_min(limit);
         }
 
-        /* 
-         * Make sure that pool informed obd of last SLV changes. 
+        /*
+         * Make sure that pool informed obd of last SLV changes.
          */
         ldlm_srv_pool_push_slv(pl);
         spin_unlock(&pl->pl_lock);
 
-        /* 
+        /*
          * We did not really free any memory here so far, it only will be
-         * freed later may be, so that we return 0 to not confuse VM. 
+         * freed later may be, so that we return 0 to not confuse VM.
          */
-        RETURN(0);
+        return 0;
 }
 
 /**
@@ -438,7 +436,7 @@ static int ldlm_srv_pool_setup(struct ldlm_pool *pl, int limit)
 {
         struct obd_device *obd;
         ENTRY;
-        
+
         obd = ldlm_pl2ns(pl)->ns_obd;
         LASSERT(obd != NULL && obd != LP_POISON);
         LASSERT(obd->obd_type != LP_POISON);
@@ -457,9 +455,9 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl)
 {
         struct obd_device *obd;
 
-        /* 
-         * Get new SLV and Limit from obd which is updated with comming 
-         * RPCs. 
+        /*
+         * Get new SLV and Limit from obd which is updated with comming
+         * RPCs.
          */
         obd = ldlm_pl2ns(pl)->ns_obd;
         LASSERT(obd != NULL);
@@ -487,29 +485,29 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
                 RETURN(0);
         }
 
-        /* 
-         * Make sure that pool knows last SLV and Limit from obd. 
+        /*
+         * Make sure that pool knows last SLV and Limit from obd.
          */
         ldlm_cli_pool_pop_slv(pl);
 
         pl->pl_recalc_time = cfs_time_current_sec();
-        lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, 
+        lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT,
                             recalc_interval_sec);
         spin_unlock(&pl->pl_lock);
 
-        /* 
-         * Do not cancel locks in case lru resize is disabled for this ns. 
+        /*
+         * Do not cancel locks in case lru resize is disabled for this ns.
          */
         if (!ns_connect_lru_resize(ldlm_pl2ns(pl)))
                 RETURN(0);
 
-        /* 
+        /*
          * In the time of canceling locks on client we do not need to maintain
          * sharp timing, we only want to cancel locks asap according to new SLV.
          * It may be called when SLV has changed much, this is why we do not
-         * take into account pl->pl_recalc_time here. 
+         * take into account pl->pl_recalc_time here.
          */
-        RETURN(ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LDLM_ASYNC, 
+        RETURN(ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LDLM_SYNC,
                                LDLM_CANCEL_LRUR));
 }
 
@@ -521,32 +519,38 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl)
 static int ldlm_cli_pool_shrink(struct ldlm_pool *pl,
                                 int nr, unsigned int gfp_mask)
 {
-        ENTRY;
-        
-        /* 
-         * Do not cancel locks in case lru resize is disabled for this ns. 
+        struct ldlm_namespace *ns;
+        int canceled = 0, unused;
+
+        ns = ldlm_pl2ns(pl);
+
+        /*
+         * Do not cancel locks in case lru resize is disabled for this ns.
          */
-        if (!ns_connect_lru_resize(ldlm_pl2ns(pl)))
+        if (!ns_connect_lru_resize(ns))
                 RETURN(0);
 
-        /* 
-         * Make sure that pool knows last SLV and Limit from obd. 
+        /*
+         * Make sure that pool knows last SLV and Limit from obd.
          */
         ldlm_cli_pool_pop_slv(pl);
 
-        /* 
-         * Find out how many locks may be released according to shrink 
-         * policy. 
-         */
-        if (nr == 0)
-                RETURN(ldlm_cancel_lru_estimate(ldlm_pl2ns(pl), 0, 0, 
-                                                LDLM_CANCEL_SHRINK));
+        spin_lock(&ns->ns_unused_lock);
+        unused = ns->ns_nr_unused;
+        spin_unlock(&ns->ns_unused_lock);
 
-        /* 
-         * Cancel @nr locks accoding to shrink policy. 
+        if (nr) {
+                canceled = ldlm_cancel_lru(ns, nr, LDLM_SYNC,
+                                           LDLM_CANCEL_SHRINK);
+        }
+#ifdef __KERNEL__
+        /*
+         * Retrun the number of potentially reclaimable locks.
          */
-        RETURN(ldlm_cancel_lru(ldlm_pl2ns(pl), nr, LDLM_SYNC, 
-                               LDLM_CANCEL_SHRINK));
+        return ((unused - canceled) / 100) * sysctl_vfs_cache_pressure;
+#else
+        return unused - canceled;
+#endif
 }
 
 struct ldlm_pool_ops ldlm_srv_pool_ops = {
@@ -578,7 +582,7 @@ int ldlm_pool_recalc(struct ldlm_pool *pl)
                 ldlm_pool_recalc_stats(pl);
 
                 /*
-                 * Zero out all rates and speed for the last period. 
+                 * Zero out all rates and speed for the last period.
                  */
                 atomic_set(&pl->pl_grant_rate, 0);
                 atomic_set(&pl->pl_cancel_rate, 0);
@@ -588,7 +592,7 @@ int ldlm_pool_recalc(struct ldlm_pool *pl)
 
         if (pl->pl_ops->po_recalc != NULL) {
                 count = pl->pl_ops->po_recalc(pl);
-                lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT, 
+                lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT,
                                     count);
                 return count;
         }
@@ -605,14 +609,14 @@ int ldlm_pool_shrink(struct ldlm_pool *pl, int nr,
                      unsigned int gfp_mask)
 {
         int cancel = 0;
-        
+
         if (pl->pl_ops->po_shrink != NULL) {
                 cancel = pl->pl_ops->po_shrink(pl, nr, gfp_mask);
                 if (nr > 0) {
-                        lprocfs_counter_add(pl->pl_stats, 
+                        lprocfs_counter_add(pl->pl_stats,
                                             LDLM_POOL_SHRINK_REQTD_STAT,
                                             nr);
-                        lprocfs_counter_add(pl->pl_stats, 
+                        lprocfs_counter_add(pl->pl_stats,
                                             LDLM_POOL_SHRINK_FREED_STAT,
                                             cancel);
                         CDEBUG(D_DLMTRACE, "%s: request to shrink %d locks, "
@@ -782,10 +786,10 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
         lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
                              LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
                              "granted", "locks");
-        lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_STAT, 
+        lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_STAT,
                              LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
                              "grant", "locks");
-        lprocfs_counter_init(pl->pl_stats, LDLM_POOL_CANCEL_STAT, 
+        lprocfs_counter_init(pl->pl_stats, LDLM_POOL_CANCEL_STAT,
                              LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
                              "cancel", "locks");
         lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANT_RATE_STAT,
@@ -881,8 +885,8 @@ void ldlm_pool_fini(struct ldlm_pool *pl)
 {
         ENTRY;
         ldlm_pool_proc_fini(pl);
-        
-        /* 
+
+        /*
          * Pool should not be used after this point. We can't free it here as
          * it lives in struct ldlm_namespace, but still interested in catching
          * any abnormal using cases.
@@ -897,27 +901,27 @@ EXPORT_SYMBOL(ldlm_pool_fini);
  */
 void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock)
 {
-        /* 
+        /*
          * FLOCK locks are special in a sense that they are almost never
          * cancelled, instead special kind of lock is used to drop them.
          * also there is no LRU for flock locks, so no point in tracking
-         * them anyway. 
+         * them anyway.
          */
         if (lock->l_resource->lr_type == LDLM_FLOCK)
                 return;
         ENTRY;
-                
+
         atomic_inc(&pl->pl_granted);
         atomic_inc(&pl->pl_grant_rate);
         atomic_inc(&pl->pl_grant_speed);
 
         lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_GRANT_STAT);
- 
-        /* 
+
+        /*
          * Do not do pool recalc for client side as all locks which
-         * potentially may be canceled has already been packed into 
+         * potentially may be canceled has already been packed into
          * enqueue/cancel rpc. Also we do not want to run out of stack
-         * with too long call paths. 
+         * with too long call paths.
          */
         if (ns_is_server(ldlm_pl2ns(pl)))
                 ldlm_pool_recalc(pl);
@@ -941,7 +945,7 @@ void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock)
         atomic_dec(&pl->pl_granted);
         atomic_inc(&pl->pl_cancel_rate);
         atomic_dec(&pl->pl_grant_speed);
-        
+
         lprocfs_counter_incr(pl->pl_stats, LDLM_POOL_CANCEL_STAT);
 
         if (ns_is_server(ldlm_pl2ns(pl)))
@@ -953,7 +957,7 @@ EXPORT_SYMBOL(ldlm_pool_del);
 /**
  * Returns current \a pl SLV.
  *
- * \pre ->pl_lock is not locked. 
+ * \pre ->pl_lock is not locked.
  */
 __u64 ldlm_pool_get_slv(struct ldlm_pool *pl)
 {
@@ -968,7 +972,7 @@ EXPORT_SYMBOL(ldlm_pool_get_slv);
 /**
  * Sets passed \a slv to \a pl.
  *
- * \pre ->pl_lock is not locked. 
+ * \pre ->pl_lock is not locked.
  */
 void ldlm_pool_set_slv(struct ldlm_pool *pl, __u64 slv)
 {
@@ -981,7 +985,7 @@ EXPORT_SYMBOL(ldlm_pool_set_slv);
 /**
  * Returns current \a pl CLV.
  *
- * \pre ->pl_lock is not locked. 
+ * \pre ->pl_lock is not locked.
  */
 __u64 ldlm_pool_get_clv(struct ldlm_pool *pl)
 {
@@ -996,7 +1000,7 @@ EXPORT_SYMBOL(ldlm_pool_get_clv);
 /**
  * Sets passed \a clv to \a pl.
  *
- * \pre ->pl_lock is not locked. 
+ * \pre ->pl_lock is not locked.
  */
 void ldlm_pool_set_clv(struct ldlm_pool *pl, __u64 clv)
 {
@@ -1044,12 +1048,12 @@ static struct shrinker *ldlm_pools_srv_shrinker;
 static struct shrinker *ldlm_pools_cli_shrinker;
 static struct completion ldlm_pools_comp;
 
-/* 
+/*
  * Cancel \a nr locks from all namespaces (if possible). Returns number of
  * cached locks after shrink is finished. All namespaces are asked to
  * cancel approximately equal amount of locks to keep balancing.
  */
-static int ldlm_pools_shrink(ldlm_side_t client, int nr, 
+static int ldlm_pools_shrink(ldlm_side_t client, int nr,
                              unsigned int gfp_mask)
 {
         int total = 0, cached = 0, nr_ns;
@@ -1058,14 +1062,15 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr,
         if (nr != 0 && !(gfp_mask & __GFP_FS))
                 return -1;
 
-        CDEBUG(D_DLMTRACE, "Request to shrink %d %s locks from all pools\n",
-               nr, client == LDLM_NAMESPACE_CLIENT ? "client" : "server");
+        if (nr != 0)
+                CDEBUG(D_DLMTRACE, "Request to shrink %d %s locks\n",
+                       nr, client == LDLM_NAMESPACE_CLIENT ? "client":"server");
 
-        /* 
-         * Find out how many resources we may release. 
+        /*
+         * Find out how many resources we may release.
          */
-        for (nr_ns = atomic_read(ldlm_namespace_nr(client)); 
-             nr_ns > 0; nr_ns--) 
+        for (nr_ns = atomic_read(ldlm_namespace_nr(client));
+             nr_ns > 0; nr_ns--)
         {
                 mutex_down(ldlm_namespace_lock(client));
                 if (list_empty(ldlm_namespace_list(client))) {
@@ -1083,24 +1088,24 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr,
         if (nr == 0 || total == 0)
                 return total;
 
-        /* 
-         * Shrink at least ldlm_namespace_nr(client) namespaces. 
+        /*
+         * Shrink at least ldlm_namespace_nr(client) namespaces.
          */
-        for (nr_ns = atomic_read(ldlm_namespace_nr(client)); 
-             nr_ns > 0; nr_ns--) 
+        for (nr_ns = atomic_read(ldlm_namespace_nr(client));
+             nr_ns > 0; nr_ns--)
         {
                 int cancel, nr_locks;
 
-                /* 
-                 * Do not call shrink under ldlm_namespace_lock(client) 
+                /*
+                 * Do not call shrink under ldlm_namespace_lock(client)
                  */
                 mutex_down(ldlm_namespace_lock(client));
                 if (list_empty(ldlm_namespace_list(client))) {
                         mutex_up(ldlm_namespace_lock(client));
-                        /* 
+                        /*
                          * If list is empty, we can't return any @cached > 0,
                          * that probably would cause needless shrinker
-                         * call. 
+                         * call.
                          */
                         cached = 0;
                         break;
@@ -1109,7 +1114,7 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr,
                 ldlm_namespace_get(ns);
                 ldlm_namespace_move_locked(ns, client);
                 mutex_up(ldlm_namespace_lock(client));
-                
+
                 nr_locks = ldlm_pool_granted(&ns->ns_pool);
                 cancel = 1 + nr_locks * nr / total;
                 ldlm_pool_shrink(&ns->ns_pool, cancel, gfp_mask);
@@ -1135,16 +1140,16 @@ void ldlm_pools_recalc(ldlm_side_t client)
         struct ldlm_namespace *ns;
         int nr, equal = 0;
 
-        /* 
+        /*
          * No need to setup pool limit for client pools.
          */
         if (client == LDLM_NAMESPACE_SERVER) {
-                /* 
-                 * Check all modest namespaces first. 
+                /*
+                 * Check all modest namespaces first.
                  */
                 mutex_down(ldlm_namespace_lock(client));
-                list_for_each_entry(ns, ldlm_namespace_list(client), 
-                                    ns_list_chain) 
+                list_for_each_entry(ns, ldlm_namespace_list(client),
+                                    ns_list_chain)
                 {
                         if (ns->ns_appetite != LDLM_NAMESPACE_MODEST)
                                 continue;
@@ -1153,9 +1158,9 @@ void ldlm_pools_recalc(ldlm_side_t client)
                         if (l == 0)
                                 l = 1;
 
-                        /* 
+                        /*
                          * Set the modest pools limit equal to their avg granted
-                         * locks + 5%. 
+                         * locks + 5%.
                          */
                         l += dru(l * LDLM_POOLS_MODEST_MARGIN, 100);
                         ldlm_pool_setup(&ns->ns_pool, l);
@@ -1163,9 +1168,9 @@ void ldlm_pools_recalc(ldlm_side_t client)
                         nr_p++;
                 }
 
-                /* 
-                 * Make sure that modest namespaces did not eat more that 2/3 
-                 * of limit. 
+                /*
+                 * Make sure that modest namespaces did not eat more that 2/3
+                 * of limit.
                  */
                 if (nr_l >= 2 * (LDLM_POOL_HOST_L / 3)) {
                         CWARN("\"Modest\" pools eat out 2/3 of server locks "
@@ -1175,25 +1180,25 @@ void ldlm_pools_recalc(ldlm_side_t client)
                         equal = 1;
                 }
 
-                /* 
-                 * The rest is given to greedy namespaces. 
+                /*
+                 * The rest is given to greedy namespaces.
                  */
-                list_for_each_entry(ns, ldlm_namespace_list(client), 
-                                    ns_list_chain) 
+                list_for_each_entry(ns, ldlm_namespace_list(client),
+                                    ns_list_chain)
                 {
                         if (!equal && ns->ns_appetite != LDLM_NAMESPACE_GREEDY)
                                 continue;
 
                         if (equal) {
-                                /* 
+                                /*
                                  * In the case 2/3 locks are eaten out by
                                  * modest pools, we re-setup equal limit
-                                 * for _all_ pools. 
+                                 * for _all_ pools.
                                  */
                                 l = LDLM_POOL_HOST_L /
                                         atomic_read(ldlm_namespace_nr(client));
                         } else {
-                                /* 
+                                /*
                                  * All the rest of greedy pools will have
                                  * all locks in equal parts.
                                  */
@@ -1206,16 +1211,16 @@ void ldlm_pools_recalc(ldlm_side_t client)
                 mutex_up(ldlm_namespace_lock(client));
         }
 
-        /* 
-         * Recalc at least ldlm_namespace_nr(client) namespaces. 
+        /*
+         * Recalc at least ldlm_namespace_nr(client) namespaces.
          */
         for (nr = atomic_read(ldlm_namespace_nr(client)); nr > 0; nr--) {
-                /* 
+                /*
                  * Lock the list, get first @ns in the list, getref, move it
                  * to the tail, unlock and call pool recalc. This way we avoid
                  * calling recalc under @ns lock what is really good as we get
                  * rid of potential deadlock on client nodes when canceling
-                 * locks synchronously. 
+                 * locks synchronously.
                  */
                 mutex_down(ldlm_namespace_lock(client));
                 if (list_empty(ldlm_namespace_list(client))) {
@@ -1227,8 +1232,8 @@ void ldlm_pools_recalc(ldlm_side_t client)
                 ldlm_namespace_move_locked(ns, client);
                 mutex_up(ldlm_namespace_lock(client));
 
-                /* 
-                 * After setup is done - recalc the pool. 
+                /*
+                 * After setup is done - recalc the pool.
                  */
                 ldlm_pool_recalc(&ns->ns_pool);
                 ldlm_namespace_put(ns, 1);
@@ -1253,14 +1258,14 @@ static int ldlm_pools_thread_main(void *arg)
                 struct l_wait_info lwi;
 
                 /*
-                 * Recal all pools on this tick. 
+                 * Recal all pools on this tick.
                  */
                 ldlm_pools_recalc(LDLM_NAMESPACE_SERVER);
                 ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT);
-                
+
                 /*
                  * Wait until the next check time, or until we're
-                 * stopped. 
+                 * stopped.
                  */
                 lwi = LWI_TIMEOUT(cfs_time_seconds(LDLM_POOLS_THREAD_PERIOD),
                                   NULL, NULL);
@@ -1301,9 +1306,9 @@ static int ldlm_pools_thread_start(void)
         init_completion(&ldlm_pools_comp);
         cfs_waitq_init(&ldlm_pools_thread->t_ctl_waitq);
 
-        /* 
+        /*
          * CLONE_VM and CLONE_FILES just avoid a needless copy, because we
-         * just drop the VM and FILES in ptlrpc_daemonize() right away. 
+         * just drop the VM and FILES in ptlrpc_daemonize() right away.
          */
         rc = cfs_kernel_thread(ldlm_pools_thread_main, ldlm_pools_thread,
                                CLONE_VM | CLONE_FILES);
@@ -1331,10 +1336,10 @@ static void ldlm_pools_thread_stop(void)
         ldlm_pools_thread->t_flags = SVC_STOPPING;
         cfs_waitq_signal(&ldlm_pools_thread->t_ctl_waitq);
 
-        /* 
+        /*
          * Make sure that pools thread is finished before freeing @thread.
          * This fixes possible race and oops due to accessing freed memory
-         * in pools thread. 
+         * in pools thread.
          */
         wait_for_completion(&ldlm_pools_comp);
         OBD_FREE_PTR(ldlm_pools_thread);
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index 29286cf..cd85edd 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -115,20 +115,6 @@ int ldlm_get_enq_timeout(struct ldlm_lock *lock)
 }
 EXPORT_SYMBOL(ldlm_get_enq_timeout);
 
-static int is_granted_or_cancelled(struct ldlm_lock *lock)
-{
-        int ret = 0;
-
-        lock_res_and_lock(lock);
-        if (((lock->l_req_mode == lock->l_granted_mode) &&
-             !(lock->l_flags & LDLM_FL_CP_REQD)) ||
-            (lock->l_flags & LDLM_FL_FAILED))
-                ret = 1;
-        unlock_res_and_lock(lock);
-
-        return ret;
-}
-
 int ldlm_completion_ast(struct ldlm_lock *lock, int flags, void *data)
 {
         /* XXX ALLOCATE - 160 bytes */
@@ -187,14 +173,14 @@ noreproc:
                 spin_unlock(&imp->imp_lock);
         }
 
-        if (ns_is_client(lock->l_resource->lr_namespace) && 
+        if (ns_is_client(lock->l_resource->lr_namespace) &&
             OBD_FAIL_CHECK(OBD_FAIL_LDLM_INTR_CP_AST | OBD_FAIL_ONCE)) {
                 obd_fail_loc = OBD_FAIL_LDLM_CP_BL_RACE | OBD_FAIL_ONCE;
                 lock->l_flags |= LDLM_FL_FAIL_LOC;
                 rc = -EINTR;
         } else {
                 /* Go to sleep until the lock is granted or cancelled. */
-                rc = l_wait_event(lock->l_waitq, 
+                rc = l_wait_event(lock->l_waitq,
                                   is_granted_or_cancelled(lock), &lwi);
         }
 
@@ -362,20 +348,20 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns,
         /* Set a flag to prevent us from sending a CANCEL (bug 407) */
         lock_res_and_lock(lock);
         /* Check that lock is not granted or failed, we might race. */
-        if ((lock->l_req_mode != lock->l_granted_mode) && 
+        if ((lock->l_req_mode != lock->l_granted_mode) &&
             !(lock->l_flags & LDLM_FL_FAILED)) {
                 /* Make sure that this lock will not be found by raced
-                 * bl_ast and -EINVAL reply is sent to server anyways. 
+                 * bl_ast and -EINVAL reply is sent to server anyways.
                  * bug 17645 */
-                lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_FAILED | 
+                lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_FAILED |
                                  LDLM_FL_ATOMIC_CB;
                 need_cancel = 1;
         }
         unlock_res_and_lock(lock);
-  
+
         if (need_cancel) {
-                LDLM_DEBUG(lock, 
-                           "setting FL_LOCAL_ONLY | LDLM_FL_FAILED | " 
+                LDLM_DEBUG(lock,
+                           "setting FL_LOCAL_ONLY | LDLM_FL_FAILED | "
                            "LDLM_FL_ATOMIC_CB");
                 ldlm_lock_decref_and_cancel(lockh, mode);
         } else {
@@ -385,8 +371,9 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns,
 
         /* XXX - HACK because we shouldn't call ldlm_lock_destroy()
          *       from llite/file.c/ll_file_flock(). */
-        if (lock->l_resource->lr_type == LDLM_FLOCK)
+        if (lock->l_resource->lr_type == LDLM_FLOCK) {
                 ldlm_lock_destroy(lock);
+        }
 }
 
 int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
@@ -479,12 +466,18 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
                         lock->l_req_mode = newmode;
                 }
 
-                if (reply->lock_desc.l_resource.lr_name.name[0] !=
-                    lock->l_resource->lr_name.name[0]) {
-                        CDEBUG(D_INFO, "remote intent success, locking %ld "
-                               "instead of %ld\n",
-                              (long)reply->lock_desc.l_resource.lr_name.name[0],
-                               (long)lock->l_resource->lr_name.name[0]);
+                if (memcmp(reply->lock_desc.l_resource.lr_name.name,
+                          lock->l_resource->lr_name.name,
+                          sizeof(struct ldlm_res_id))) {
+                        CDEBUG(D_INFO, "remote intent success, locking "
+                                        "("LPU64"/"LPU64"/"LPU64") instead of "
+                                        "("LPU64"/"LPU64"/"LPU64")\n",
+                               reply->lock_desc.l_resource.lr_name.name[0],
+                               reply->lock_desc.l_resource.lr_name.name[1],
+                               reply->lock_desc.l_resource.lr_name.name[2],
+                               lock->l_resource->lr_name.name[0],
+                               lock->l_resource->lr_name.name[1],
+                               lock->l_resource->lr_name.name[2]);
 
                         rc = ldlm_lock_change_resource(ns, lock,
                                            reply->lock_desc.l_resource.lr_name);
@@ -615,8 +608,10 @@ struct ptlrpc_request *ldlm_prep_elc_req(struct obd_export *exp, int version,
                         pack = avail;
                 size[bufoff] = ldlm_request_bufsize(pack, opc);
         }
+
         req = ptlrpc_prep_req(class_exp2cliimp(exp), version,
                               opc, bufcount, size, NULL);
+        req->rq_export = class_export_get(exp);
         if (exp_connect_cancelset(exp) && req) {
                 if (canceloff) {
                         dlm = lustre_msg_buf(req->rq_reqmsg, bufoff,
@@ -665,7 +660,8 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
         struct ldlm_reply *reply;
         __u32 size[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                         [DLM_LOCKREQ_OFF]     = sizeof(*body),
-                        [DLM_REPLY_REC_OFF]   = lvb_len };
+                        [DLM_REPLY_REC_OFF]   = lvb_len ? lvb_len :
+                                                sizeof(struct ost_lvb) };
         int is_replay = *flags & LDLM_FL_REPLAY;
         int req_passed_in = 1, rc, err;
         struct ptlrpc_request *req;
@@ -745,7 +741,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
         /* Continue as normal. */
         if (!req_passed_in) {
                 size[DLM_LOCKREPLY_OFF] = sizeof(*reply);
-                ptlrpc_req_set_repsize(req, 2 + (lvb_len > 0), size);
+                ptlrpc_req_set_repsize(req, 3, size);
         }
 
         /*
@@ -970,9 +966,8 @@ int ldlm_cli_cancel_req(struct obd_export *exp,
                         struct list_head *cancels, int count)
 {
         struct ptlrpc_request *req = NULL;
-        struct ldlm_request *body;
         __u32 size[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
-                        [DLM_LOCKREQ_OFF]     = sizeof(*body) };
+                        [DLM_LOCKREQ_OFF]     = sizeof(struct ldlm_request) };
         struct obd_import *imp;
         int free, sent = 0;
         int rc = 0;
@@ -1011,8 +1006,10 @@ int ldlm_cli_cancel_req(struct obd_export *exp,
                 req->rq_reply_portal = LDLM_CANCEL_REPLY_PORTAL;
                 ptlrpc_at_set_req_timeout(req);
 
+                /*
                 body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF,
                                       sizeof(*body));
+                */
                 ldlm_cancel_pack(req, DLM_LOCKREQ_OFF, cancels, count);
 
                 ptlrpc_req_set_repsize(req, 1, NULL);
@@ -1186,54 +1183,6 @@ static int ldlm_cancel_list(struct list_head *cancels, int count, int flags)
 
 /* Return 1 to stop lru processing and keep current lock cached. Return zero
  * otherwise. */
-static ldlm_policy_res_t ldlm_cancel_shrink_policy(struct ldlm_namespace *ns,
-                                                   struct ldlm_lock *lock,
-                                                   int unused, int added,
-                                                   int count)
-{
-        int lock_cost;
-        __u64 page_nr;
-
-        /* Stop lru processing when we reached passed @count or checked all
-         * locks in lru. */
-        if (count && added >= count)
-                return LDLM_POLICY_KEEP_LOCK;
-
-        if (lock->l_resource->lr_type == LDLM_EXTENT) {
-                struct ldlm_extent *l_extent;
-
-                /* For all extent locks cost is 1 + number of pages in
-                 * their extent. */
-                l_extent = &lock->l_policy_data.l_extent;
-                page_nr = (l_extent->end - l_extent->start);
-                do_div(page_nr, CFS_PAGE_SIZE);
-
-#ifdef __KERNEL__
-                /* XXX: In fact this is evil hack, we can't access inode
-                 * here. For doing it right we need somehow to have number
-                 * of covered by lock. This should be fixed later when 10718
-                 * is landed. */
-                if (lock->l_ast_data != NULL) {
-                        struct inode *inode = lock->l_ast_data;
-                        if (page_nr > inode->i_mapping->nrpages)
-                                page_nr = inode->i_mapping->nrpages;
-                }
-#endif
-                lock_cost = 1 + page_nr;
-        } else {
-                /* For all locks which are not extent ones cost is 1 */
-                lock_cost = 1;
-        }
-
-        /* Keep all expensive locks in lru for the memory pressure time
-         * cancel policy. They anyways may be canceled by lru resize
-         * pplicy if they have not small enough CLV. */
-        return lock_cost > ns->ns_shrink_thumb ?
-                LDLM_POLICY_KEEP_LOCK : LDLM_POLICY_CANCEL_LOCK;
-}
-
-/* Return 1 to stop lru processing and keep current lock cached. Return zero
- * otherwise. */
 static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
                                                  struct ldlm_lock *lock,
                                                  int unused, int added,
@@ -1316,7 +1265,8 @@ ldlm_cancel_lru_policy(struct ldlm_namespace *ns, int flags)
 {
         if (ns_connect_lru_resize(ns)) {
                 if (flags & LDLM_CANCEL_SHRINK)
-                        return ldlm_cancel_shrink_policy;
+                        /* We kill passed number of old locks. */
+                        return ldlm_cancel_passed_policy;
                 else if (flags & LDLM_CANCEL_LRUR)
                         return ldlm_cancel_lrur_policy;
                 else if (flags & LDLM_CANCEL_PASSED)
@@ -1458,45 +1408,6 @@ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels,
         RETURN(ldlm_cancel_list(cancels, added, cancel_flags));
 }
 
-/* Returns number of locks which could be canceled next time when
- * ldlm_cancel_lru() is called. Used from locks pool shrinker. */
-int ldlm_cancel_lru_estimate(struct ldlm_namespace *ns,
-                             int count, int max, int flags)
-{
-        ldlm_cancel_lru_policy_t pf;
-        struct ldlm_lock *lock;
-        int added = 0, unused;
-        ENTRY;
-
-        pf = ldlm_cancel_lru_policy(ns, flags);
-        LASSERT(pf != NULL);
-        spin_lock(&ns->ns_unused_lock);
-        unused = ns->ns_nr_unused;
-
-        list_for_each_entry(lock, &ns->ns_unused_list, l_lru) {
-                /* For any flags, stop scanning if @max is reached. */
-                if (max && added >= max)
-                        break;
-
-                /* Somebody is already doing CANCEL or there is a
-                 * blocking request will send cancel. Let's not count
-                 * this lock. */
-                if ((lock->l_flags & LDLM_FL_CANCELING) ||
-                    (lock->l_flags & LDLM_FL_BL_AST))
-                        continue;
-
-                /* Pass the lock through the policy filter and see if it
-                 * should stay in lru. */
-                if (pf(ns, lock, unused, added, count) == LDLM_POLICY_KEEP_LOCK)
-                        break;
-
-                added++;
-                unused--;
-        }
-        spin_unlock(&ns->ns_unused_lock);
-        RETURN(added);
-}
-
 /* when called with LDLM_ASYNC the blocking callback will be handled
  * in a thread and this function will return after the thread has been
  * asked to call the callback.  when called with LDLM_SYNC the blocking
@@ -1518,8 +1429,8 @@ int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, ldlm_sync_t sync,
                         RETURN(count);
         }
 
-        /* If an error occured in ASYNC mode, or
-         * this is SYNC mode, cancel the list. */
+        /* If an error occured in ASYNC mode, or this is SYNC mode,
+         * cancel the list. */
         ldlm_cli_cancel_list(&cancels, count, NULL, 0);
         RETURN(count);
 }
@@ -1890,9 +1801,15 @@ static int ldlm_chain_lock_for_replay(struct ldlm_lock *lock, void *closure)
         /* we use l_pending_chain here, because it's unused on clients. */
         LASSERTF(list_empty(&lock->l_pending_chain),"lock %p next %p prev %p\n",
                  lock, &lock->l_pending_chain.next,&lock->l_pending_chain.prev);
-        /* bug 9573: don't replay locks left after eviction */
-        if (!(lock->l_flags & LDLM_FL_FAILED))
+        /* bug 9573: don't replay locks left after eviction, or
+         * bug 17614: locks being actively cancelled. Get a reference
+         * on a lock so that it does not disapear under us (e.g. due to cancel)
+         */
+        if (!(lock->l_flags & (LDLM_FL_FAILED|LDLM_FL_CANCELING))) {
                 list_add(&lock->l_pending_chain, list);
+                LDLM_LOCK_GET(lock);
+        }
+
         return LDLM_ITER_CONTINUE;
 }
 
@@ -1930,10 +1847,10 @@ static int replay_lock_interpret(struct ptlrpc_request *req,
         lock->l_remote_handle = reply->lock_handle;
 
         /* Key change rehash lock in per-export hash with new key */
-	exp = req->rq_export;
+        exp = req->rq_export;
         if (exp && exp->exp_lock_hash)
                 lustre_hash_rehash_key(exp->exp_lock_hash, &old_hash_key,
-				       &lock->l_remote_handle,
+                                       &lock->l_remote_handle,
                                        &lock->l_exp_hash);
 
         LDLM_DEBUG(lock, "replayed lock:");
@@ -1973,6 +1890,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
                 ldlm_lock_cancel(lock);
                 RETURN(0);
         }
+
         /*
          * If granted mode matches the requested mode, this lock is granted.
          *
@@ -2011,10 +1929,11 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
 
         ldlm_lock2handle(lock, &body->lock_handle[0]);
         size[DLM_LOCKREPLY_OFF] = sizeof(*reply);
+        buffers = 3;
         if (lock->l_lvb_len != 0) {
-                buffers = 3;
                 size[DLM_REPLY_REC_OFF] = lock->l_lvb_len;
-        }
+        } else
+                size[DLM_REPLY_REC_OFF] = sizeof (struct ost_lvb);
         ptlrpc_req_set_repsize(req, buffers, size);
 
         LDLM_DEBUG(lock, "replaying lock:");
@@ -2044,15 +1963,25 @@ int ldlm_replay_locks(struct obd_import *imp)
         /* ensure this doesn't fall to 0 before all have been queued */
         atomic_inc(&imp->imp_replay_inflight);
 
-        (void)ldlm_namespace_foreach(ns, ldlm_chain_lock_for_replay, &list);
-
-        list_for_each_entry_safe(lock, next, &list, l_pending_chain) {
-                list_del_init(&lock->l_pending_chain);
-                if (rc)
-                        continue; /* or try to do the rest? */
-                rc = replay_one_lock(imp, lock);
+        if (imp->imp_no_lock_replay) {
+                /* VBR: locks should be cancelled here */
+                ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
+                spin_lock(&imp->imp_lock);
+                imp->imp_no_lock_replay = 0;
+                spin_unlock(&imp->imp_lock);
+        } else {
+                (void)ldlm_namespace_foreach(ns, ldlm_chain_lock_for_replay,
+                                             &list);
+                list_for_each_entry_safe(lock, next, &list, l_pending_chain) {
+                        list_del_init(&lock->l_pending_chain);
+                        if (rc) {
+                                LDLM_LOCK_PUT(lock);
+                                continue; /* or try to do the rest? */
+                        }
+                        rc = replay_one_lock(imp, lock);
+                        LDLM_LOCK_PUT(lock);
+                }
         }
-
         atomic_dec(&imp->imp_replay_inflight);
 
         RETURN(rc);
diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c
index bdf0468..9857485 100644
--- a/lustre/ldlm/ldlm_resource.c
+++ b/lustre/ldlm/ldlm_resource.c
@@ -269,13 +269,6 @@ void ldlm_proc_namespace(struct ldlm_namespace *ns)
                 lock_vars[0].write_fptr = lprocfs_wr_lru_size;
                 lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
 
-                snprintf(lock_name, MAX_STRING_SIZE, "%s/shrink_thumb",
-                         ns->ns_name);
-                lock_vars[0].data = ns;
-                lock_vars[0].read_fptr = lprocfs_rd_uint;
-                lock_vars[0].write_fptr = lprocfs_wr_uint;
-                lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
-
                 snprintf(lock_name, MAX_STRING_SIZE, "%s/lru_max_age",
                          ns->ns_name);
                 lock_vars[0].data = &ns->ns_max_age;
@@ -344,7 +337,6 @@ ldlm_namespace_new(struct obd_device *obd, char *name,
         if (!ns->ns_name)
                 GOTO(out_hash, NULL);
 
-        ns->ns_shrink_thumb = LDLM_LOCK_SHRINK_THUMB;
         ns->ns_appetite = apt;
 
         LASSERT(obd != NULL);
@@ -369,6 +361,7 @@ ldlm_namespace_new(struct obd_device *obd, char *name,
                 CFS_INIT_LIST_HEAD(bucket);
 
         CFS_INIT_LIST_HEAD(&ns->ns_unused_list);
+        CFS_INIT_LIST_HEAD(&ns->ns_list_chain);
         ns->ns_nr_unused = 0;
         ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
         ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE;
@@ -417,7 +410,6 @@ static void cleanup_resource(struct ldlm_resource *res, struct list_head *q,
         int local_only = (flags & LDLM_FL_LOCAL_ONLY);
         ENTRY;
 
-
         do {
                 struct ldlm_lock *lock = NULL;
 
@@ -663,7 +655,6 @@ void ldlm_namespace_free(struct ldlm_namespace *ns,
 
 void ldlm_namespace_get_locked(struct ldlm_namespace *ns)
 {
-        LASSERT(ns->ns_refcount >= 0);
         ns->ns_refcount++;
 }
 
diff --git a/lustre/liblustre/Makefile.in b/lustre/liblustre/Makefile.in
index 47e8181..8a22a08 100644
--- a/lustre/liblustre/Makefile.in
+++ b/lustre/liblustre/Makefile.in
@@ -176,9 +176,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c
index 659efcd..62538d4 100644
--- a/lustre/liblustre/dir.c
+++ b/lustre/liblustre/dir.c
@@ -119,7 +119,7 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page)
         }
         ldlm_lock_dump_handle(D_OTHER, &lockh);
 
-        mdc_pack_fid(&mdc_fid, st->st_ino, lli->lli_st_generation, S_IFDIR);
+        ll_pack_fid(&mdc_fid, st->st_ino, lli->lli_st_generation, S_IFDIR);
 
         offset = (__u64)page->index << CFS_PAGE_SHIFT;
         rc = mdc_readpage(sbi->ll_mdc_exp, &mdc_fid,
diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c
index 94710cf..bfbb3fe 100644
--- a/lustre/liblustre/file.c
+++ b/lustre/liblustre/file.c
@@ -99,14 +99,14 @@ void llu_prepare_mdc_op_data(struct mdc_op_data *data,
 
         if (i1) {
                 ll_i2gids(data->suppgids, i1, i2);
-                ll_inode2fid(&data->fid1, i1);
+                llu_inode2fid(&data->fid1, i1);
         }else {
                 ll_i2gids(data->suppgids, i2, i1);
-                ll_inode2fid(&data->fid1, i2);
+                llu_inode2fid(&data->fid1, i2);
         }
 
         if (i2)
-                ll_inode2fid(&data->fid2, i2);
+                llu_inode2fid(&data->fid2, i2);
         else
                 memset(&data->fid2, 0, sizeof(data->fid2));
 
@@ -132,16 +132,10 @@ void obdo_refresh_inode(struct inode *dst,
 
         if (valid & OBD_MD_FLATIME && src->o_atime > LTIME_S(st->st_atime))
                 LTIME_S(st->st_atime) = src->o_atime;
-        
-        /* mtime is always updated with ctime, but can be set in past.
-           As write and utime(2) may happen within 1 second, and utime's
-           mtime has a priority over write's one, leave mtime from mds 
-           for the same ctimes. */
-        if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(st->st_ctime)) {
+        if (valid & OBD_MD_FLMTIME && src->o_mtime > LTIME_S(st->st_mtime))
+                LTIME_S(st->st_mtime) = src->o_mtime;
+        if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(st->st_ctime))
                 LTIME_S(st->st_ctime) = src->o_ctime;
-                if (valid & OBD_MD_FLMTIME)
-                        LTIME_S(st->st_mtime) = src->o_mtime;
-        }
         if (valid & OBD_MD_FLSIZE && src->o_size > st->st_size)
                 st->st_size = src->o_size;
         /* optimum IO size */
@@ -335,7 +329,8 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode)
         struct ll_file_data *fd = lli->lli_file_data;
         struct ptlrpc_request *req = NULL;
         struct obd_client_handle *och = &fd->fd_mds_och;
-        struct obdo obdo;
+        struct obdo obdo = { 0 };
+        struct mdc_op_data data = { { 0 } };
         int rc, valid;
         ENTRY;
 
@@ -360,7 +355,8 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode)
                 obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES;
                 obdo.o_valid |= OBD_MD_FLFLAGS;
         }
-        rc = mdc_close(mdc_exp, &obdo, och, &req);
+        data.fid1 = lli->lli_fid;
+        rc = mdc_close(mdc_exp, &data, &obdo, och, &req);
         if (rc == EAGAIN) {
                 /* We are the last writer, so the MDS has instructed us to get
                  * the file size and any write cookies, then close again. */
@@ -478,6 +474,7 @@ static void llu_truncate(struct inode *inode, obd_flag flags)
         struct intnl_stat *st = llu_i2stat(inode);
         struct obd_info oinfo = { { { 0 } } };
         struct obdo oa = { 0 };
+        obd_valid valid;
         int rc;
         ENTRY;
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu/%lu(%p) to %llu\n",
@@ -499,9 +496,41 @@ static void llu_truncate(struct inode *inode, obd_flag flags)
         oa.o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS;
         oa.o_flags = flags; /* We don't actually want to copy inode flags */
  
-        obdo_from_inode(&oa, inode,
-                        OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLATIME |
-                        OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+        valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLATIME;
+        if (flags & OBD_FL_TRUNCLOCK) {
+                /* lockless truncate
+                 *
+                 * 1. do not use inode's timestamps because concurrent
+                 * stat might fill the inode with out-of-date times,
+                 * send current instead
+                 *
+                 * 2.do no update lsm, as long as stat (via
+                 * llu_glimpse_size) will bring attributes from osts
+                 * anyway */
+                oa.o_mtime = oa.o_ctime = CURRENT_TIME;
+                oa.o_valid |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
+        } else {
+                /* truncate under locks
+                 *
+                 * 1. update inode's mtime and ctime as long as
+                 * concurrent stat (via llu_glimpse_size) might bring
+                 * out-of-date ones
+                 *
+                 * 2. update lsm so that next stat (via
+                 * llu_glimpse_size) could get correct values in lsm */
+                struct ost_lvb xtimes;
+
+                lov_stripe_lock(lli->lli_smd);
+                st->st_mtime = st->st_ctime = CURRENT_TIME;
+                xtimes.lvb_mtime = st->st_mtime;
+                xtimes.lvb_ctime = st->st_ctime;
+                obd_update_lvb(llu_i2obdexp(inode), lli->lli_smd, &xtimes,
+                               OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+                lov_stripe_unlock(lli->lli_smd);
+
+                valid |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
+        }
+        obdo_from_inode(&oa, inode, valid);
 
         obd_adjust_kms(llu_i2obdexp(inode), lli->lli_smd, st->st_size, 1);
 
diff --git a/lustre/liblustre/llite_lib.c b/lustre/liblustre/llite_lib.c
index 34d0c46..651d9f2 100644
--- a/lustre/liblustre/llite_lib.c
+++ b/lustre/liblustre/llite_lib.c
@@ -173,7 +173,8 @@ int liblustre_process_log(struct config_llog_instance *cfg,
         if (ocd == NULL)
                 GOTO(out_cleanup, rc = -ENOMEM);
 
-        ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT;
+        ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT |
+                                 OBD_CONNECT_VBR;
 #ifdef LIBLUSTRE_POSIX_ACL
         ocd->ocd_connect_flags |= OBD_CONNECT_ACL;
 #endif
diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h
index 8429b6c..a40098a 100644
--- a/lustre/liblustre/llite_lib.h
+++ b/lustre/liblustre/llite_lib.h
@@ -107,6 +107,9 @@ struct llu_inode_info {
         /* not for stat, change it later */
         int                     lli_st_flags;
         unsigned long           lli_st_generation;
+        /* the most recent attributes from mds, it is used for timestampts
+         * only so far */
+        struct ost_lvb         lli_lvb;
 };
 
 static inline struct llu_sb_info *llu_fs2sbi(struct filesys *fs)
@@ -171,7 +174,7 @@ do {                                                                           \
 #define LL_LOOKUP_POSITIVE 1
 #define LL_LOOKUP_NEGATIVE 2
 
-static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
+static inline void llu_inode2fid(struct ll_fid *fid, struct inode *inode)
 {
         *fid = llu_i2info(inode)->lli_fid;
 }
diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c
index 711a11e..12e52e1 100644
--- a/lustre/liblustre/rw.c
+++ b/lustre/liblustre/rw.c
@@ -272,7 +272,11 @@ int llu_glimpse_size(struct inode *inode)
                 RETURN(rc > 0 ? -EIO : rc);
         }
 
+        lov_stripe_lock(lli->lli_smd);
         inode_init_lvb(inode, &lvb);
+        /* merge timestamps the most resently obtained from mds with
+           timestamps obtained from osts */
+        lvb = lli->lli_lvb;
         rc = obd_merge_lvb(sbi->ll_osc_exp, lli->lli_smd, &lvb, 0);
         st->st_size = lvb.lvb_size;
         st->st_blocks = lvb.lvb_blocks;
@@ -282,6 +286,7 @@ int llu_glimpse_size(struct inode *inode)
         st->st_mtime = lvb.lvb_mtime;
         st->st_atime = lvb.lvb_atime;
         st->st_ctime = lvb.lvb_ctime;
+        lov_stripe_unlock(lli->lli_smd);
 
         CDEBUG(D_DLMTRACE, "glimpse: size: "LPU64", blocks: "LPU64"\n",
                (__u64)st->st_size, (__u64)st->st_blocks);
@@ -702,7 +707,7 @@ ssize_t llu_file_prwv(const struct iovec *iovec, int iovlen,
                         } else {
                                 /* If objective page index exceed end-of-file
                                  * page index, return directly. --bug 17336 */
-                                loff_t size = st->st_size;
+                                size_t size = st->st_size;
                                 unsigned long cur_index = pos >> CFS_PAGE_SHIFT;
 
                                 if ((size == 0 && cur_index != 0) ||
@@ -716,6 +721,23 @@ ssize_t llu_file_prwv(const struct iovec *iovec, int iovlen,
                 pos = st->st_size;
         }
 
+        if (local_lock) {
+                struct ost_lvb xtimes;
+
+                lov_stripe_lock(lsm);
+                /* inode might mtime and ctime set earlier in race with stat
+                 * which merged into inode timestamps obtained from mds and
+                 * osts */
+                st->st_atime = st->st_mtime = st->st_ctime = CURRENT_TIME;
+                xtimes.lvb_atime = st->st_atime;
+                xtimes.lvb_mtime = st->st_mtime;
+                xtimes.lvb_ctime = st->st_ctime;
+                obd_update_lvb(exp, lsm, &xtimes,
+                               is_read ? OBD_MD_FLATIME :
+                               (OBD_MD_FLMTIME | OBD_MD_FLCTIME));
+                lov_stripe_unlock(lsm);
+        }
+
         for (iovidx = 0; iovidx < iovlen; iovidx++) {
                 char *buf = (char *) iovec[iovidx].iov_base;
                 size_t count = iovec[iovidx].iov_len;
diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c
index 39374c2..a8b94c4 100644
--- a/lustre/liblustre/super.c
+++ b/lustre/liblustre/super.c
@@ -154,19 +154,22 @@ void llu_update_inode(struct inode *inode, struct mds_body *body,
 
         if (body->valid & OBD_MD_FLID)
                 st->st_ino = body->ino;
-        if (body->valid & OBD_MD_FLATIME &&
-            body->atime > LTIME_S(st->st_atime))
-                LTIME_S(st->st_atime) = body->atime;
-        
-        /* mtime is always updated with ctime, but can be set in past.
-           As write and utime(2) may happen within 1 second, and utime's
-           mtime has a priority over write's one, so take mtime from mds 
-           for the same ctimes. */
-        if (body->valid & OBD_MD_FLCTIME &&
-            body->ctime >= LTIME_S(st->st_ctime)) {
-                LTIME_S(st->st_ctime) = body->ctime;
-                if (body->valid & OBD_MD_FLMTIME)
+        if (body->valid & OBD_MD_FLGENER)
+                lli->lli_st_generation = body->generation;
+        if (body->valid & OBD_MD_FLMTIME) {
+                if (body->mtime > LTIME_S(st->st_mtime))
                         LTIME_S(st->st_mtime) = body->mtime;
+                lli->lli_lvb.lvb_mtime = body->mtime;
+        }
+        if (body->valid & OBD_MD_FLATIME) {
+                if (body->atime > LTIME_S(st->st_atime))
+                        LTIME_S(st->st_atime) = body->atime;
+                lli->lli_lvb.lvb_atime = body->atime;
+        }
+        if (body->valid & OBD_MD_FLCTIME) {
+                if (body->ctime > LTIME_S(st->st_ctime))
+                        LTIME_S(st->st_ctime) = body->ctime;
+                lli->lli_lvb.lvb_ctime = body->ctime;
         }
         if (body->valid & OBD_MD_FLMODE)
                 st->st_mode = (st->st_mode & S_IFMT)|(body->mode & ~S_IFMT);
@@ -190,16 +193,8 @@ void llu_update_inode(struct inode *inode, struct mds_body *body,
                 st->st_blocks = body->blocks;
         if (body->valid & OBD_MD_FLFLAGS)
                 lli->lli_st_flags = body->flags;
-        if (body->valid & OBD_MD_FLGENER)
-                lli->lli_st_generation = body->generation;
 
-        /* fillin fid */
-        if (body->valid & OBD_MD_FLID)
-                lli->lli_fid.id = body->ino;
-        if (body->valid & OBD_MD_FLGENER)
-                lli->lli_fid.generation = body->generation;
-        if (body->valid & OBD_MD_FLTYPE)
-                lli->lli_fid.f_type = body->mode & S_IFMT;
+        lli->lli_fid = body->fid1;
 }
 
 void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
@@ -429,6 +424,8 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart)
 static int llu_inode_revalidate(struct inode *inode)
 {
         struct lov_stripe_md *lsm = NULL;
+        struct llu_inode_info *lli = llu_i2info(inode);
+        struct intnl_stat *st = llu_i2stat(inode);
         ENTRY;
 
         if (!inode) {
@@ -446,15 +443,15 @@ static int llu_inode_revalidate(struct inode *inode)
 
                 /* Why don't we update all valid MDS fields here, if we're
                  * doing an RPC anyways?  -phil */
-                if (S_ISREG(llu_i2stat(inode)->st_mode)) {
+                if (S_ISREG(st->st_mode)) {
                         ealen = obd_size_diskmd(sbi->ll_osc_exp, NULL);
                         valid |= OBD_MD_FLEASIZE;
                 }
-                ll_inode2fid(&fid, inode);
+                llu_inode2fid(&fid, inode);
                 rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, ealen, &req);
                 if (rc) {
                         CERROR("failure %d inode %llu\n", rc,
-                               (long long)llu_i2stat(inode)->st_ino);
+                               (long long)st->st_ino);
                         RETURN(-abs(rc));
                 }
                 rc = mdc_req2lustre_md(req, REPLY_REC_OFF, sbi->ll_osc_exp,&md);
@@ -475,18 +472,23 @@ static int llu_inode_revalidate(struct inode *inode)
 
 
                 llu_update_inode(inode, md.body, md.lsm);
-                if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm)
+                if (md.lsm != NULL && lli->lli_smd != md.lsm)
                         obd_free_memmd(sbi->ll_osc_exp, &md.lsm);
 
                 if (md.body->valid & OBD_MD_FLSIZE)
                         set_bit(LLI_F_HAVE_MDS_SIZE_LOCK,
-                                &llu_i2info(inode)->lli_flags);
+                                &lli->lli_flags);
                 ptlrpc_req_finished(req);
         }
 
-        lsm = llu_i2info(inode)->lli_smd;
-        if (!lsm)       /* object not yet allocated, don't validate size */
+        lsm = lli->lli_smd;
+        if (!lsm) {
+                /* object not yet allocated, don't validate size */
+                st->st_atime = lli->lli_lvb.lvb_atime;
+                st->st_mtime = lli->lli_lvb.lvb_mtime;
+                st->st_ctime = lli->lli_lvb.lvb_ctime;
                 RETURN(0);
+        }
 
         /* ll_glimpse_size will prefer locally cached writes if they extend
          * the file */
@@ -551,7 +553,7 @@ void llu_clear_inode(struct inode *inode)
                (long long)llu_i2stat(inode)->st_ino, lli->lli_st_generation,
                inode);
 
-        ll_inode2fid(&fid, inode);
+        llu_inode2fid(&fid, inode);
         clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(lli->lli_flags));
         mdc_change_cbdata(sbi->ll_mdc_exp, &fid, null_if_equal, inode);
 
@@ -668,16 +670,6 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                 attr->ia_mtime = CURRENT_TIME;
                 attr->ia_valid |= ATTR_MTIME_SET;
         }
-        if ((attr->ia_valid & ATTR_CTIME) && !(attr->ia_valid & ATTR_MTIME)) {
-                /* To avoid stale mtime on mds, obtain it from ost and send 
-                   to mds. */
-                rc = llu_glimpse_size(inode);
-                if (rc) 
-                        RETURN(rc);
-                
-                attr->ia_valid |= ATTR_MTIME_SET | ATTR_MTIME;
-                attr->ia_mtime = inode->i_stbuf.st_mtime;
-        }
 
         if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
                 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
@@ -760,7 +752,8 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
 
                 /* check that there are no matching locks */
                 LASSERT(obd_match(sbi->ll_osc_exp, lsm, LDLM_EXTENT, &policy,
-                                  LCK_PW, &flags, inode, &match_lockh) <= 0);
+                                  LCK_PW, &flags, inode, &match_lockh, NULL)
+                                  <= 0);
 
                 /* XXX when we fix the AST intents to pass the discard-range
                  * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
@@ -797,15 +790,87 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                 }
         } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
                 struct obd_info oinfo = { { { 0 } } };
-                struct obdo oa;
+                struct obdo oa = { 0 };
+                struct lustre_handle lockh = { 0 };
+                obd_valid valid;
 
                 CDEBUG(D_INODE, "set mtime on OST inode %llu to %lu\n",
                        (long long)st->st_ino, LTIME_S(attr->ia_mtime));
+
                 oa.o_id = lsm->lsm_object_id;
                 oa.o_valid = OBD_MD_FLID;
 
-                obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
-                                            OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+                valid = OBD_MD_FLTYPE;
+
+                if (LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime)){
+                        struct ost_lvb xtimes;
+
+                        /* setting mtime to past is performed under PW
+                         * EOF extent lock */
+                        oinfo.oi_policy.l_extent.start = 0;
+                        oinfo.oi_policy.l_extent.end = OBD_OBJECT_EOF;
+                        rc = llu_extent_lock(NULL, inode, lsm, LCK_PW,
+                                             &oinfo.oi_policy,
+                                             &lockh, 0);
+                        if (rc)
+                                RETURN(rc);
+
+                        /* setattr under locks
+                         *
+                         * 1. restore inode's timestamps which are
+                         * about to be set as long as concurrent stat
+                         * (via llu_glimpse_size) might bring
+                         * out-of-date ones
+                         *
+                         * 2. update lsm so that next stat (via
+                         * llu_glimpse_size) could get correct values
+                         * in lsm */
+                        lov_stripe_lock(lsm);
+                        if (ia_valid & ATTR_ATIME) {
+                                st->st_atime = xtimes.lvb_atime =
+                                        attr->ia_atime;
+                                valid |= OBD_MD_FLATIME;
+                        }
+                        if (ia_valid & ATTR_MTIME) {
+                                st->st_mtime = xtimes.lvb_mtime =
+                                        attr->ia_mtime;
+                                valid |= OBD_MD_FLMTIME;
+                        }
+                        if (ia_valid & ATTR_CTIME) {
+                                st->st_ctime = xtimes.lvb_ctime =
+                                        attr->ia_mtime;
+                                valid |= OBD_MD_FLCTIME;
+                        }
+
+                        obd_update_lvb(sbi->ll_osc_exp, lsm,
+                                       &xtimes, valid);
+                        lov_stripe_unlock(lsm);
+                } else {
+                        /* lockless setattr
+                         *
+                         * 1. do not use inode's timestamps because
+                         * concurrent stat might fill the inode with
+                         * out-of-date times, send values from attr
+                         * instead
+                         *
+                         * 2.do no update lsm, as long as stat (via
+                         * ll_glimpse_size) will bring attributes from
+                         * osts anyway */
+                        if (ia_valid & ATTR_ATIME) {
+                                oa.o_atime = attr->ia_atime;
+                                oa.o_valid |= OBD_MD_FLATIME;
+                        }
+                        if (ia_valid & ATTR_MTIME) {
+                                oa.o_mtime = attr->ia_mtime;
+                                oa.o_valid |= OBD_MD_FLMTIME;
+                        }
+                        if (ia_valid & ATTR_CTIME) {
+                                oa.o_ctime = attr->ia_ctime;
+                                oa.o_valid |= OBD_MD_FLCTIME;
+                        }
+                }
+
+                obdo_from_inode(&oa, inode, valid);
 
                 oinfo.oi_oa = &oa;
                 oinfo.oi_md = lsm;
@@ -813,6 +878,19 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                 rc = obd_setattr_rqset(sbi->ll_osc_exp, &oinfo, NULL);
                 if (rc)
                         CERROR("obd_setattr_async fails: rc=%d\n", rc);
+
+                if (LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime)){
+                        int err;
+
+                        err = llu_extent_unlock(NULL, inode, lsm,
+                                               LCK_PW, &lockh);
+                        if (unlikely(err != 0)) {
+                                CERROR("extent unlock failed: "
+                                       "err=%d\n", err);
+                                if (rc == 0)
+                                        rc = err;
+                        }
+                }
         }
         RETURN(rc);
 }
@@ -909,6 +987,7 @@ static int llu_readlink_internal(struct inode *inode,
         ENTRY;
 
         *request = NULL;
+        *symname = NULL;
 
         if (lli->lli_symlink_name) {
                 *symname = lli->lli_symlink_name;
@@ -916,7 +995,7 @@ static int llu_readlink_internal(struct inode *inode,
                 RETURN(0);
         }
 
-        ll_inode2fid(&fid, inode);
+        llu_inode2fid(&fid, inode);
         rc = mdc_getattr(sbi->ll_mdc_exp, &fid,
                          OBD_MD_LINKNAME, symlen, request);
         if (rc) {
@@ -1606,27 +1685,35 @@ static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg)
         struct ptlrpc_request *request = NULL;
         struct mdc_op_data op_data;
         struct iattr attr = { 0 };
-        struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
-        int rc = 0;
+        struct lov_user_md_v3 lum;
+        struct lov_user_md *lump = (struct lov_user_md *)arg;
+        int rc = 0, lum_size = 0;
 
         llu_prepare_mdc_op_data(&op_data, ino, NULL, NULL, 0, 0);
 
-        LASSERT(sizeof(lum) == sizeof(*lump));
         LASSERT(sizeof(lum.lmm_objects[0]) ==
                 sizeof(lump->lmm_objects[0]));
-        rc = copy_from_user(&lum, lump, sizeof(lum));
+        rc = copy_from_user(&lum, lump, sizeof(*lump));
         if (rc)
                 return(-EFAULT);
+        lum_size = sizeof(struct lov_user_md_v1);
+        if (lum.lmm_magic == LOV_USER_MAGIC_V3) {
+                rc = copy_from_user(&lum, lump, sizeof(lum));
+                if (rc)
+                        return(-EFAULT);
+                lum_size = sizeof(struct lov_user_md_v3);
+        }
 
-        if (lum.lmm_magic != LOV_USER_MAGIC)
-                RETURN(-EINVAL);
-
-        if (lum.lmm_magic != cpu_to_le32(LOV_USER_MAGIC))
-                lustre_swab_lov_user_md(&lum);
+        if ((lum.lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V1)) &&
+            (lum.lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V3))) {
+                rc = lustre_swab_lov_user_md((struct lov_user_md_v1 *)&lum);
+                if (rc) 
+                        RETURN(rc);
+        }
 
         /* swabbing is done in lov_setstripe() on server side */
         rc = mdc_setattr(sbi->ll_mdc_exp, &op_data,
-                         &attr, &lum, sizeof(lum), NULL, 0, &request);
+                         &attr, &lum, lum_size, NULL, 0, &request);
         if (rc) {
                 ptlrpc_req_finished(request);
                 if (rc != -EPERM && rc != -EACCES)
@@ -1832,9 +1919,7 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md)
         }
 
         /* try to find existing inode */
-        fid.id = md->body->ino;
-        fid.generation = md->body->generation;
-        fid.f_type = md->body->mode & S_IFMT;
+        fid = md->body->fid1;
 
         inode = _sysio_i_find(fs, &fileid);
         if (inode) {
@@ -1956,7 +2041,7 @@ llu_fsswop_mount(const char *source,
                            sizeof(async), &async, NULL);
 
         ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION |
-                OBD_CONNECT_AT;
+                                OBD_CONNECT_AT | OBD_CONNECT_VBR;
 #ifdef LIBLUSTRE_POSIX_ACL
         ocd.ocd_connect_flags |= OBD_CONNECT_ACL;
 #endif
diff --git a/lustre/liblustre/tests/Makefile.am b/lustre/liblustre/tests/Makefile.am
index bbc30e8..07726dd 100644
--- a/lustre/liblustre/tests/Makefile.am
+++ b/lustre/liblustre/tests/Makefile.am
@@ -10,16 +10,16 @@ if LIBLUSTRE
 noinst_LIBRARIES = libtestcommon.a
 
 if LIBLUSTRE_TESTS
+if MPITESTS
+SUBDIRS = mpi
+endif # MPITESTS
+
 noinst_PROGRAMS = sanity
 
 if !CRAY_XT3
 noinst_PROGRAMS += recovery_small replay_single replay_ost_single
 endif # !CRAY_XT3
 
-if MPITESTS
-noinst_PROGRAMS += test_lock_cancel
-endif # MPITESTS
-
 liblustre_testdir=$(libdir)/lustre/liblustre/tests
 liblustre_test_PROGRAMS = $(noinst_PROGRAMS)
 liblustre_test_LIBRARIES = $(noinst_LIBRARIES)
@@ -27,6 +27,8 @@ liblustre_test_LIBRARIES = $(noinst_LIBRARIES)
 endif # LIBLUSTRE_TESTS
 endif # LIBLUSTRE
 
+DIST_SUBDIRS := mpi
+
 libtestcommon_a_SOURCES = test_common.c test_common.h
 
 sanity_SOURCES = sanity.c
@@ -48,12 +50,3 @@ replay_ost_single_SOURCES = replay_ost_single.c
 replay_ost_single_CFLAGS = $(LL_CFLAGS)
 replay_ost_single_LDADD := libtestcommon.a $(LLIB_EXEC)
 replay_ost_single_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a
-
-if MPITESTS
-test_lock_cancel_SOURCES = test_lock_cancel.c
-test_lock_cancel_CFLAGS = $(LL_CFLAGS) -I/opt/lam/include
-#test_lock_cancel_LDADD :=  $(LLIB_EXEC)  -L/opt/lam/lib -lmpi -llam
-test_lock_cancel_LDADD :=  $(LLIB_EXEC)  -lmpich
-endif
-
-
diff --git a/lustre/liblustre/tests/Makefile.in b/lustre/liblustre/tests/Makefile.in
index 54df1bc..ed6768d 100644
--- a/lustre/liblustre/tests/Makefile.in
+++ b/lustre/liblustre/tests/Makefile.in
@@ -39,7 +39,6 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 @CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at am__append_1 = recovery_small replay_single replay_ost_single
- at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at am__append_2 = test_lock_cancel
 ACLOCAL = @ACLOCAL@
 AC_LUSTRE_CLIENT_URN = @AC_LUSTRE_CLIENT_URN@
 AC_LUSTRE_CLI_VER_OFFSET_WARN = @AC_LUSTRE_CLI_VER_OFFSET_WARN@
@@ -176,9 +175,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -302,12 +301,16 @@ LLIB_EXEC = $(top_builddir)/lustre/utils/liblustreapi.a $(top_builddir)/lustre/l
 
 @LIBLUSTRE_TRUE at noinst_LIBRARIES = libtestcommon.a
 
- at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at noinst_PROGRAMS = sanity $(am__append_1) $(am__append_2)
+ at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at SUBDIRS = mpi
+
+ at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at noinst_PROGRAMS = sanity $(am__append_1)
 
 @LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at liblustre_testdir = $(libdir)/lustre/liblustre/tests
 @LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at liblustre_test_PROGRAMS = $(noinst_PROGRAMS)
 @LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at liblustre_test_LIBRARIES = $(noinst_LIBRARIES)
 
+DIST_SUBDIRS := mpi
+
 libtestcommon_a_SOURCES = test_common.c test_common.h
 
 sanity_SOURCES = sanity.c
@@ -329,11 +332,6 @@ replay_ost_single_SOURCES = replay_ost_single.c
 replay_ost_single_CFLAGS = $(LL_CFLAGS)
 replay_ost_single_LDADD := libtestcommon.a $(LLIB_EXEC)
 replay_ost_single_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a
-
- at MPITESTS_TRUE@test_lock_cancel_SOURCES = test_lock_cancel.c
- at MPITESTS_TRUE@test_lock_cancel_CFLAGS = $(LL_CFLAGS) -I/opt/lam/include
-#test_lock_cancel_LDADD :=  $(LLIB_EXEC)  -L/opt/lam/lib -lmpi -llam
- at MPITESTS_TRUE@test_lock_cancel_LDADD := $(LLIB_EXEC)  -lmpich
 subdir = lustre/liblustre/tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -345,62 +343,32 @@ libtestcommon_a_AR = $(AR) cru
 libtestcommon_a_LIBADD =
 am_libtestcommon_a_OBJECTS = test_common.$(OBJEXT)
 libtestcommon_a_OBJECTS = $(am_libtestcommon_a_OBJECTS)
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at liblustre_test_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at liblustre_test_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at liblustre_test_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at liblustre_test_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at liblustre_test_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at liblustre_test_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at liblustre_test_PROGRAMS = \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	sanity$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	recovery_small$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	replay_single$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	replay_ost_single$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	test_lock_cancel$(EXEEXT)
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at liblustre_test_PROGRAMS = \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	sanity$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	recovery_small$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	replay_single$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	replay_ost_single$(EXEEXT)
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at liblustre_test_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at liblustre_test_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at liblustre_test_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at liblustre_test_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at liblustre_test_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at liblustre_test_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at liblustre_test_PROGRAMS = \
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	sanity$(EXEEXT) \
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	test_lock_cancel$(EXEEXT)
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at liblustre_test_PROGRAMS = \
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	sanity$(EXEEXT)
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at noinst_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at noinst_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at noinst_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at noinst_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at noinst_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at noinst_PROGRAMS =
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at noinst_PROGRAMS = \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	sanity$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	recovery_small$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	replay_single$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	replay_ost_single$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	test_lock_cancel$(EXEEXT)
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at noinst_PROGRAMS = \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	sanity$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	recovery_small$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	replay_single$(EXEEXT) \
- at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	replay_ost_single$(EXEEXT)
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at noinst_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at noinst_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at noinst_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at noinst_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_TRUE at noinst_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE@@MPITESTS_FALSE at noinst_PROGRAMS =
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE at noinst_PROGRAMS = \
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	sanity$(EXEEXT) \
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_TRUE@	test_lock_cancel$(EXEEXT)
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE at noinst_PROGRAMS = \
- at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@@MPITESTS_FALSE@	sanity$(EXEEXT)
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE at liblustre_test_PROGRAMS =
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE at liblustre_test_PROGRAMS =
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at liblustre_test_PROGRAMS = \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	sanity$(EXEEXT) \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	recovery_small$(EXEEXT) \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	replay_single$(EXEEXT) \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	replay_ost_single$(EXEEXT)
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE at liblustre_test_PROGRAMS =
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE at liblustre_test_PROGRAMS =
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE at liblustre_test_PROGRAMS =
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at liblustre_test_PROGRAMS = \
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	sanity$(EXEEXT)
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE at liblustre_test_PROGRAMS =
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE at noinst_PROGRAMS =
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE at noinst_PROGRAMS =
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at noinst_PROGRAMS = \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	sanity$(EXEEXT) \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	recovery_small$(EXEEXT) \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	replay_single$(EXEEXT) \
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	replay_ost_single$(EXEEXT)
+ at CRAY_XT3_FALSE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE at noinst_PROGRAMS =
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE at noinst_PROGRAMS =
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE at noinst_PROGRAMS =
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at noinst_PROGRAMS = \
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	sanity$(EXEEXT)
+ at CRAY_XT3_TRUE@@LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE at noinst_PROGRAMS =
 PROGRAMS = $(liblustre_test_PROGRAMS) $(noinst_PROGRAMS)
 
 am_recovery_small_OBJECTS = recovery_small-recovery_small.$(OBJEXT)
@@ -416,15 +384,6 @@ replay_single_LDFLAGS =
 am_sanity_OBJECTS = sanity-sanity.$(OBJEXT)
 sanity_OBJECTS = $(am_sanity_OBJECTS)
 sanity_LDFLAGS =
-am__test_lock_cancel_SOURCES_DIST = test_lock_cancel.c
- at MPITESTS_TRUE@am_test_lock_cancel_OBJECTS = \
- at MPITESTS_TRUE@	test_lock_cancel-test_lock_cancel.$(OBJEXT)
-test_lock_cancel_OBJECTS = $(am_test_lock_cancel_OBJECTS)
- at MPITESTS_TRUE@test_lock_cancel_DEPENDENCIES = \
- at MPITESTS_TRUE@	$(top_builddir)/lustre/utils/liblustreapi.a \
- at MPITESTS_TRUE@	$(top_builddir)/lustre/liblustre/liblustre.a
- at MPITESTS_FALSE@test_lock_cancel_DEPENDENCIES =
-test_lock_cancel_LDFLAGS =
 
 DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -433,19 +392,24 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE@	./$(DEPDIR)/replay_ost_single-replay_ost_single.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/replay_single-replay_single.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/sanity-sanity.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/test_common.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/test_lock_cancel-test_lock_cancel.Po
+ at AMDEP_TRUE@	./$(DEPDIR)/test_common.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 DIST_SOURCES = $(libtestcommon_a_SOURCES) $(recovery_small_SOURCES) \
 	$(replay_ost_single_SOURCES) $(replay_single_SOURCES) \
-	$(sanity_SOURCES) $(am__test_lock_cancel_SOURCES_DIST)
+	$(sanity_SOURCES)
+
+RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
+	ps-recursive install-info-recursive uninstall-info-recursive \
+	all-recursive install-data-recursive install-exec-recursive \
+	installdirs-recursive install-recursive uninstall-recursive \
+	check-recursive installcheck-recursive
 DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
-SOURCES = $(libtestcommon_a_SOURCES) $(recovery_small_SOURCES) $(replay_ost_single_SOURCES) $(replay_single_SOURCES) $(sanity_SOURCES) $(test_lock_cancel_SOURCES)
+SOURCES = $(libtestcommon_a_SOURCES) $(recovery_small_SOURCES) $(replay_ost_single_SOURCES) $(replay_single_SOURCES) $(sanity_SOURCES)
 
-all: all-am
+all: all-recursive
 
 .SUFFIXES:
 .SUFFIXES: .c .o .obj
@@ -532,9 +496,6 @@ replay_single$(EXEEXT): $(replay_single_OBJECTS) $(replay_single_DEPENDENCIES)
 sanity$(EXEEXT): $(sanity_OBJECTS) $(sanity_DEPENDENCIES) 
 	@rm -f sanity$(EXEEXT)
 	$(LINK) $(sanity_LDFLAGS) $(sanity_OBJECTS) $(sanity_LDADD) $(LIBS)
-test_lock_cancel$(EXEEXT): $(test_lock_cancel_OBJECTS) $(test_lock_cancel_DEPENDENCIES) 
-	@rm -f test_lock_cancel$(EXEEXT)
-	$(LINK) $(test_lock_cancel_LDFLAGS) $(test_lock_cancel_OBJECTS) $(test_lock_cancel_LDADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT) core *.core
@@ -547,7 +508,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/replay_single-replay_single.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sanity-sanity.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_common.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_lock_cancel-test_lock_cancel.Po at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@@ -658,30 +618,67 @@ sanity-sanity.obj: sanity.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/sanity-sanity.Po' tmpdepfile='$(DEPDIR)/sanity-sanity.TPo' @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(sanity_CFLAGS) $(CFLAGS) -c -o sanity-sanity.obj `if test -f 'sanity.c'; then $(CYGPATH_W) 'sanity.c'; else $(CYGPATH_W) '$(srcdir)/sanity.c'; fi`
-
-test_lock_cancel-test_lock_cancel.o: test_lock_cancel.c
- at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_cancel_CFLAGS) $(CFLAGS) -MT test_lock_cancel-test_lock_cancel.o -MD -MP -MF "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Tpo" \
- at am__fastdepCC_TRUE@	  -c -o test_lock_cancel-test_lock_cancel.o `test -f 'test_lock_cancel.c' || echo '$(srcdir)/'`test_lock_cancel.c; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Tpo" "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Po"; \
- at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Tpo"; exit 1; \
- at am__fastdepCC_TRUE@	fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='test_lock_cancel.c' object='test_lock_cancel-test_lock_cancel.o' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/test_lock_cancel-test_lock_cancel.Po' tmpdepfile='$(DEPDIR)/test_lock_cancel-test_lock_cancel.TPo' @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_cancel_CFLAGS) $(CFLAGS) -c -o test_lock_cancel-test_lock_cancel.o `test -f 'test_lock_cancel.c' || echo '$(srcdir)/'`test_lock_cancel.c
-
-test_lock_cancel-test_lock_cancel.obj: test_lock_cancel.c
- at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_cancel_CFLAGS) $(CFLAGS) -MT test_lock_cancel-test_lock_cancel.obj -MD -MP -MF "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Tpo" \
- at am__fastdepCC_TRUE@	  -c -o test_lock_cancel-test_lock_cancel.obj `if test -f 'test_lock_cancel.c'; then $(CYGPATH_W) 'test_lock_cancel.c'; else $(CYGPATH_W) '$(srcdir)/test_lock_cancel.c'; fi`; \
- at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Tpo" "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Po"; \
- at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/test_lock_cancel-test_lock_cancel.Tpo"; exit 1; \
- at am__fastdepCC_TRUE@	fi
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='test_lock_cancel.c' object='test_lock_cancel-test_lock_cancel.obj' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/test_lock_cancel-test_lock_cancel.Po' tmpdepfile='$(DEPDIR)/test_lock_cancel-test_lock_cancel.TPo' @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_lock_cancel_CFLAGS) $(CFLAGS) -c -o test_lock_cancel-test_lock_cancel.obj `if test -f 'test_lock_cancel.c'; then $(CYGPATH_W) 'test_lock_cancel.c'; else $(CYGPATH_W) '$(srcdir)/test_lock_cancel.c'; fi`
 uninstall-info-am:
 
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
 ETAGS = etags
 ETAGSFLAGS =
 
@@ -699,10 +696,21 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	       END { for (i in files) print i; }'`; \
 	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
+	if (etags --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	else \
+	  include_option=--include; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -f $$subdir/TAGS && \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@@ -714,7 +722,7 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	     $$tags $$unique
 
 ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
@@ -767,21 +775,35 @@ distdir: $(DISTFILES)
 	    || exit 1; \
 	  fi; \
 	done
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d $(distdir)/$$subdir \
+	    || mkdir $(distdir)/$$subdir \
+	    || exit 1; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$(top_distdir)" \
+	        distdir=../$(distdir)/$$subdir \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
 check-am: all-am
-check: check-am
+check: check-recursive
 all-am: Makefile $(LIBRARIES) $(PROGRAMS)
-
-installdirs:
+installdirs: installdirs-recursive
+installdirs-am:
 	$(mkinstalldirs) $(DESTDIR)$(liblustre_testdir) $(DESTDIR)$(liblustre_testdir)
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
+
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 
-installcheck: installcheck-am
+installcheck: installcheck-recursive
 install-strip:
 	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
 	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@@ -798,23 +820,23 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
+clean: clean-recursive
 
 clean-am: clean-generic clean-liblustre_testLIBRARIES \
 	clean-liblustre_testPROGRAMS clean-noinstLIBRARIES \
 	clean-noinstPROGRAMS mostlyclean-am
 
-distclean: distclean-am
+distclean: distclean-recursive
 	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
 
-dvi: dvi-am
+dvi: dvi-recursive
 
 dvi-am:
 
-info: info-am
+info: info-recursive
 
 info-am:
 
@@ -823,46 +845,54 @@ install-data-am: install-liblustre_testLIBRARIES \
 
 install-exec-am:
 
-install-info: install-info-am
+install-info: install-info-recursive
 
 install-man:
 
 installcheck-am:
 
-maintainer-clean: maintainer-clean-am
+maintainer-clean: maintainer-clean-recursive
 	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
-mostlyclean: mostlyclean-am
+mostlyclean: mostlyclean-recursive
 
 mostlyclean-am: mostlyclean-compile mostlyclean-generic
 
-pdf: pdf-am
+pdf: pdf-recursive
 
 pdf-am:
 
-ps: ps-am
+ps: ps-recursive
 
 ps-am:
 
 uninstall-am: uninstall-info-am uninstall-liblustre_testLIBRARIES \
 	uninstall-liblustre_testPROGRAMS
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-liblustre_testLIBRARIES clean-liblustre_testPROGRAMS \
-	clean-noinstLIBRARIES clean-noinstPROGRAMS ctags distclean \
-	distclean-compile distclean-generic distclean-tags distdir dvi \
-	dvi-am info info-am install install-am install-data \
-	install-data-am install-exec install-exec-am install-info \
-	install-info-am install-liblustre_testLIBRARIES \
-	install-liblustre_testPROGRAMS install-man install-strip \
-	installcheck installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
-	uninstall-am uninstall-info-am \
-	uninstall-liblustre_testLIBRARIES \
-	uninstall-liblustre_testPROGRAMS
+uninstall-info: uninstall-info-recursive
+
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
+	clean-generic clean-liblustre_testLIBRARIES \
+	clean-liblustre_testPROGRAMS clean-noinstLIBRARIES \
+	clean-noinstPROGRAMS clean-recursive ctags ctags-recursive \
+	distclean distclean-compile distclean-generic \
+	distclean-recursive distclean-tags distdir dvi dvi-am \
+	dvi-recursive info info-am info-recursive install install-am \
+	install-data install-data-am install-data-recursive \
+	install-exec install-exec-am install-exec-recursive \
+	install-info install-info-am install-info-recursive \
+	install-liblustre_testLIBRARIES install-liblustre_testPROGRAMS \
+	install-man install-recursive install-strip installcheck \
+	installcheck-am installdirs installdirs-am \
+	installdirs-recursive maintainer-clean maintainer-clean-generic \
+	maintainer-clean-recursive mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-recursive pdf pdf-am \
+	pdf-recursive ps ps-am ps-recursive tags tags-recursive \
+	uninstall uninstall-am uninstall-info-am \
+	uninstall-info-recursive uninstall-liblustre_testLIBRARIES \
+	uninstall-liblustre_testPROGRAMS uninstall-recursive
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/lustre/liblustre/tests/mpi/Makefile.am b/lustre/liblustre/tests/mpi/Makefile.am
new file mode 100644
index 0000000..c9fb909
--- /dev/null
+++ b/lustre/liblustre/tests/mpi/Makefile.am
@@ -0,0 +1,17 @@
+## Liblustre MPI tests Makefile
+
+AM_CPPFLAGS = -I$(SYSIO)/include $(LLCPPFLAGS) -I$(top_srcdir)/lnet/ulnds
+AM_CFLAGS = $(LLCFLAGS)
+
+LLIB_EXEC = $(top_builddir)/lustre/utils/liblustreapi.a $(top_builddir)/lustre/liblustre/liblustre.a $(CAP_LIBS) $(PTHREAD_LIBS) $(ZLIB)
+
+CC = @MPICC_WRAPPER@
+
+if LIBLUSTRE
+if LIBLUSTRE_TESTS
+noinst_PROGRAMS = test_lock_cancel
+endif # LIBLUSTRE_TESTS
+endif # LIBLUSTRE
+
+test_lock_cancel_SOURCES = test_lock_cancel.c
+test_lock_cancel_LDADD :=  $(LLIB_EXEC)
diff --git a/lustre/liblustre/tests/mpi/Makefile.in b/lustre/liblustre/tests/mpi/Makefile.in
new file mode 100644
index 0000000..ee5fef8
--- /dev/null
+++ b/lustre/liblustre/tests/mpi/Makefile.in
@@ -0,0 +1,557 @@
+# Makefile.in generated by automake 1.7.9 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../../../..
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ACLOCAL = @ACLOCAL@
+AC_LUSTRE_CLIENT_URN = @AC_LUSTRE_CLIENT_URN@
+AC_LUSTRE_CLI_VER_OFFSET_WARN = @AC_LUSTRE_CLI_VER_OFFSET_WARN@
+AC_LUSTRE_FIX = @AC_LUSTRE_FIX@
+AC_LUSTRE_LIB_VER_OFFSET_WARN = @AC_LUSTRE_LIB_VER_OFFSET_WARN@
+AC_LUSTRE_MAJOR = @AC_LUSTRE_MAJOR@
+AC_LUSTRE_MDS_URN = @AC_LUSTRE_MDS_URN@
+AC_LUSTRE_MGS_URN = @AC_LUSTRE_MGS_URN@
+AC_LUSTRE_MINOR = @AC_LUSTRE_MINOR@
+AC_LUSTRE_OSS_URN = @AC_LUSTRE_OSS_URN@
+AC_LUSTRE_PATCH = @AC_LUSTRE_PATCH@
+AC_LUSTRE_VERSION_STRING = @AC_LUSTRE_VERSION_STRING@
+AC_LUSTRE_VER_ALLOWED_OFFSET = @AC_LUSTRE_VER_ALLOWED_OFFSET@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+ARCH_UM = @ARCH_UM@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BACKINGFS = @BACKINGFS@
+BLKID_FALSE = @BLKID_FALSE@
+BLKID_TRUE = @BLKID_TRUE@
+BUILD_CIBLND_FALSE = @BUILD_CIBLND_FALSE@
+BUILD_CIBLND_TRUE = @BUILD_CIBLND_TRUE@
+BUILD_GMLND_FALSE = @BUILD_GMLND_FALSE@
+BUILD_GMLND_TRUE = @BUILD_GMLND_TRUE@
+BUILD_IIBLND_FALSE = @BUILD_IIBLND_FALSE@
+BUILD_IIBLND_TRUE = @BUILD_IIBLND_TRUE@
+BUILD_MXLND_FALSE = @BUILD_MXLND_FALSE@
+BUILD_MXLND_TRUE = @BUILD_MXLND_TRUE@
+BUILD_O2IBLND_FALSE = @BUILD_O2IBLND_FALSE@
+BUILD_O2IBLND_TRUE = @BUILD_O2IBLND_TRUE@
+BUILD_OPENIBLND_FALSE = @BUILD_OPENIBLND_FALSE@
+BUILD_OPENIBLND_TRUE = @BUILD_OPENIBLND_TRUE@
+BUILD_PTLLND_FALSE = @BUILD_PTLLND_FALSE@
+BUILD_PTLLND_TRUE = @BUILD_PTLLND_TRUE@
+BUILD_QSWLND_FALSE = @BUILD_QSWLND_FALSE@
+BUILD_QSWLND_TRUE = @BUILD_QSWLND_TRUE@
+BUILD_RALND_FALSE = @BUILD_RALND_FALSE@
+BUILD_RALND_TRUE = @BUILD_RALND_TRUE@
+BUILD_UPTLLND_FALSE = @BUILD_UPTLLND_FALSE@
+BUILD_UPTLLND_TRUE = @BUILD_UPTLLND_TRUE@
+BUILD_USOCKLND_FALSE = @BUILD_USOCKLND_FALSE@
+BUILD_USOCKLND_TRUE = @BUILD_USOCKLND_TRUE@
+BUILD_VIBLND_FALSE = @BUILD_VIBLND_FALSE@
+BUILD_VIBLND_TRUE = @BUILD_VIBLND_TRUE@
+CAP_LIBS = @CAP_LIBS@
+
+CC = @MPICC_WRAPPER@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CIBCPPFLAGS = @CIBCPPFLAGS@
+CIBLND = @CIBLND@
+CLIENT_FALSE = @CLIENT_FALSE@
+CLIENT_TRUE = @CLIENT_TRUE@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CRAY_XT3_FALSE = @CRAY_XT3_FALSE@
+CRAY_XT3_TRUE = @CRAY_XT3_TRUE@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_FALSE = @DARWIN_FALSE@
+DARWIN_TRUE = @DARWIN_TRUE@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DMU_OSD_ENABLED_FALSE = @DMU_OSD_ENABLED_FALSE@
+DMU_OSD_ENABLED_TRUE = @DMU_OSD_ENABLED_TRUE@
+DMU_SRC = @DMU_SRC@
+DOC_FALSE = @DOC_FALSE@
+DOC_TRUE = @DOC_TRUE@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_DOC = @ENABLE_DOC@
+ENABLE_INIT_SCRIPTS = @ENABLE_INIT_SCRIPTS@
+ENABLE_LIBPTHREAD = @ENABLE_LIBPTHREAD@
+EXEEXT = @EXEEXT@
+EXT2FS_DEVEL_FALSE = @EXT2FS_DEVEL_FALSE@
+EXT2FS_DEVEL_TRUE = @EXT2FS_DEVEL_TRUE@
+EXTRA_KCFLAGS = @EXTRA_KCFLAGS@
+EXTRA_KLDFLAGS = @EXTRA_KLDFLAGS@
+EXTRA_KLIBS = @EXTRA_KLIBS@
+EXTRA_LNET_INCLUDE = @EXTRA_LNET_INCLUDE@
+GMCPPFLAGS = @GMCPPFLAGS@
+GMLIBS = @GMLIBS@
+GMLND = @GMLND@
+IIBCPPFLAGS = @IIBCPPFLAGS@
+IIBLND = @IIBLND@
+INCLUDE_RULES = @INCLUDE_RULES@
+INIT_SCRIPTS_FALSE = @INIT_SCRIPTS_FALSE@
+INIT_SCRIPTS_TRUE = @INIT_SCRIPTS_TRUE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDMU_FALSE = @KDMU_FALSE@
+KDMU_TRUE = @KDMU_TRUE@
+KMODEXT = @KMODEXT@
+LDFLAGS = @LDFLAGS@
+LDISKFS_DIR = @LDISKFS_DIR@
+LDISKFS_ENABLED_FALSE = @LDISKFS_ENABLED_FALSE@
+LDISKFS_ENABLED_TRUE = @LDISKFS_ENABLED_TRUE@
+LDISKFS_SUBDIR = @LDISKFS_SUBDIR@
+LIBCFS_INCLUDE_DIR = @LIBCFS_INCLUDE_DIR@
+LIBCFS_SUBDIR = @LIBCFS_SUBDIR@
+LIBEFENCE = @LIBEFENCE@
+LIBLUSTRE_FALSE = @LIBLUSTRE_FALSE@
+LIBLUSTRE_TESTS_FALSE = @LIBLUSTRE_TESTS_FALSE@
+LIBLUSTRE_TESTS_TRUE = @LIBLUSTRE_TESTS_TRUE@
+LIBLUSTRE_TRUE = @LIBLUSTRE_TRUE@
+LIBOBJS = @LIBOBJS@
+LIBPTHREAD_FALSE = @LIBPTHREAD_FALSE@
+LIBPTHREAD_TRUE = @LIBPTHREAD_TRUE@
+LIBREADLINE = @LIBREADLINE@
+LIBS = @LIBS@
+LIBSYSIO_SUBDIR = @LIBSYSIO_SUBDIR@
+LIBWRAP = @LIBWRAP@
+LINUX = @LINUX@
+LINUX25_FALSE = @LINUX25_FALSE@
+LINUX25_TRUE = @LINUX25_TRUE@
+LINUXRELEASE = @LINUXRELEASE@
+LINUX_CONFIG = @LINUX_CONFIG@
+LINUX_FALSE = @LINUX_FALSE@
+LINUX_OBJ = @LINUX_OBJ@
+LINUX_TRUE = @LINUX_TRUE@
+LLCFLAGS = @LLCFLAGS@
+LLCPPFLAGS = @LLCPPFLAGS@
+LTLIBOBJS = @LTLIBOBJS@
+LUSTRE = @LUSTRE@
+LUSTREIOKIT_SUBDIR = @LUSTREIOKIT_SUBDIR@
+MAKEINFO = @MAKEINFO@
+MODULES_FALSE = @MODULES_FALSE@
+MODULES_TRUE = @MODULES_TRUE@
+MODULE_TARGET = @MODULE_TARGET@
+MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
+MPITESTS_FALSE = @MPITESTS_FALSE@
+MPITESTS_TRUE = @MPITESTS_TRUE@
+MXCPPFLAGS = @MXCPPFLAGS@
+MXLIBS = @MXLIBS@
+MXLND = @MXLND@
+NET_SNMP_CFLAGS = @NET_SNMP_CFLAGS@
+NET_SNMP_CONFIG = @NET_SNMP_CONFIG@
+NET_SNMP_LIBS = @NET_SNMP_LIBS@
+O2IBCPPFLAGS = @O2IBCPPFLAGS@
+O2IBLND = @O2IBLND@
+OBJEXT = @OBJEXT@
+OPENIBCPPFLAGS = @OPENIBCPPFLAGS@
+OPENIBLND = @OPENIBLND@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POSIX_OSD_ENABLED_FALSE = @POSIX_OSD_ENABLED_FALSE@
+POSIX_OSD_ENABLED_TRUE = @POSIX_OSD_ENABLED_TRUE@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PTLLND = @PTLLND@
+PTLLNDCPPFLAGS = @PTLLNDCPPFLAGS@
+QSWCPPFLAGS = @QSWCPPFLAGS@
+QSWLND = @QSWLND@
+QUOTA_FALSE = @QUOTA_FALSE@
+QUOTA_TRUE = @QUOTA_TRUE@
+RACPPFLAGS = @RACPPFLAGS@
+RALND = @RALND@
+RANLIB = @RANLIB@
+RELEASE = @RELEASE@
+SERVER_FALSE = @SERVER_FALSE@
+SERVER_TRUE = @SERVER_TRUE@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SNMP_DIST_SUBDIR = @SNMP_DIST_SUBDIR@
+SNMP_SUBDIR = @SNMP_SUBDIR@
+SPL_DIR = @SPL_DIR@
+STRIP = @STRIP@
+SUNOS_FALSE = @SUNOS_FALSE@
+SUNOS_TRUE = @SUNOS_TRUE@
+SYMVERFILE = @SYMVERFILE@
+SYSIO = @SYSIO@
+TESTS_FALSE = @TESTS_FALSE@
+TESTS_TRUE = @TESTS_TRUE@
+UML_CFLAGS = @UML_CFLAGS@
+UPTLLND = @UPTLLND@
+USE_QUILT_FALSE = @USE_QUILT_FALSE@
+USE_QUILT_TRUE = @USE_QUILT_TRUE@
+USOCKLND = @USOCKLND@
+UTILS_FALSE = @UTILS_FALSE@
+UTILS_TRUE = @UTILS_TRUE@
+VERSION = @VERSION@
+VIBCPPFLAGS = @VIBCPPFLAGS@
+VIBLND = @VIBLND@
+ZFS_DIR = @ZFS_DIR@
+ZLIB = @ZLIB@
+ac_configure_args = @ac_configure_args@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+agentdir = @agentdir@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+demodir = @demodir@
+docdir = @docdir@
+enable_uoss = @enable_uoss@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+kextdir = @kextdir@
+lb_target_os = @lb_target_os@
+libdir = @libdir@
+libexecdir = @libexecdir@
+linux25 = @linux25@
+localstatedir = @localstatedir@
+macosdir = @macosdir@
+mandir = @mandir@
+mibdir = @mibdir@
+moduledir = @moduledir@
+modulefsdir = @modulefsdir@
+modulenetdir = @modulenetdir@
+oldincludedir = @oldincludedir@
+pkgexampledir = @pkgexampledir@
+plistdir = @plistdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+rootsbindir = @rootsbindir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spl_src = @spl_src@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+
+AM_CPPFLAGS = -I$(SYSIO)/include $(LLCPPFLAGS) -I$(top_srcdir)/lnet/ulnds
+AM_CFLAGS = $(LLCFLAGS)
+
+LLIB_EXEC = $(top_builddir)/lustre/utils/liblustreapi.a $(top_builddir)/lustre/liblustre/liblustre.a $(CAP_LIBS) $(PTHREAD_LIBS) $(ZLIB)
+
+ at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at noinst_PROGRAMS = test_lock_cancel
+
+test_lock_cancel_SOURCES = test_lock_cancel.c
+test_lock_cancel_LDADD := $(LLIB_EXEC)
+subdir = lustre/liblustre/tests/mpi
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+ at LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_TRUE at noinst_PROGRAMS =
+ at LIBLUSTRE_TESTS_FALSE@@LIBLUSTRE_FALSE at noinst_PROGRAMS =
+ at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE at noinst_PROGRAMS = \
+ at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_TRUE@	test_lock_cancel$(EXEEXT)
+ at LIBLUSTRE_TESTS_TRUE@@LIBLUSTRE_FALSE at noinst_PROGRAMS =
+PROGRAMS = $(noinst_PROGRAMS)
+
+am_test_lock_cancel_OBJECTS = test_lock_cancel.$(OBJEXT)
+test_lock_cancel_OBJECTS = $(am_test_lock_cancel_OBJECTS)
+test_lock_cancel_DEPENDENCIES = \
+	$(top_builddir)/lustre/utils/liblustreapi.a \
+	$(top_builddir)/lustre/liblustre/liblustre.a
+test_lock_cancel_LDFLAGS =
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+ at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/test_lock_cancel.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(test_lock_cancel_SOURCES)
+DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
+SOURCES = $(test_lock_cancel_SOURCES)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  lustre/liblustre/tests/mpi/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+
+clean-noinstPROGRAMS:
+	-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+test_lock_cancel$(EXEEXT): $(test_lock_cancel_OBJECTS) $(test_lock_cancel_DEPENDENCIES) 
+	@rm -f test_lock_cancel$(EXEEXT)
+	$(LINK) $(test_lock_cancel_LDFLAGS) $(test_lock_cancel_OBJECTS) $(test_lock_cancel_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_lock_cancel.Po at am__quote@
+
+.c.o:
+ at am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+ at am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
+
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ../../../..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+	-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+
+distclean-generic:
+	-rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-noinstPROGRAMS ctags distclean distclean-compile \
+	distclean-generic distclean-tags distdir dvi dvi-am info \
+	info-am install install-am install-data install-data-am \
+	install-exec install-exec-am install-info install-info-am \
+	install-man install-strip installcheck installcheck-am \
+	installdirs maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
+	ps ps-am tags uninstall uninstall-am uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/lustre/liblustre/tests/mpi/test_lock_cancel.c b/lustre/liblustre/tests/mpi/test_lock_cancel.c
new file mode 100644
index 0000000..e1d4bc3
--- /dev/null
+++ b/lustre/liblustre/tests/mpi/test_lock_cancel.c
@@ -0,0 +1,211 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/liblustre/tests/test_lock_cancel.c
+ *
+ * Lustre Light user test program
+ */
+
+#define _BSD_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <getopt.h>
+#include <string.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/queue.h>
+
+#include <sysio.h>
+#include <mount.h>
+
+#include <../test_common.h>
+
+#include <mpi.h>
+
+/******************************************************************************/
+/*
+ * MPI_CHECK will display a custom error message as well as an error string
+ * from the MPI_STATUS and then exit the program
+ */
+
+#define MPI_CHECK(MPI_STATUS, MSG) do {                                  \
+    char resultString[MPI_MAX_ERROR_STRING];                             \
+    int resultLength;                                                    \
+                                                                         \
+    if (MPI_STATUS != MPI_SUCCESS) {                                     \
+        fprintf(stdout, "** error **\n");                                \
+        fprintf(stdout, "ERROR in %s (line %d): %s.\n",                  \
+                __FILE__, __LINE__, MSG);                                \
+        MPI_Error_string(MPI_STATUS, resultString, &resultLength);       \
+        fprintf(stdout, "MPI %s\n", resultString);                       \
+        fprintf(stdout, "** exiting **\n");                              \
+        MPI_Abort(MPI_COMM_WORLD, 1);                                    \
+    }                                                                    \
+} while(0)
+
+int		numTasks     = 0,	/* MPI variables */
+		rank         = 0,
+		tasksPerNode = 0;	/* tasks per node */
+
+
+
+
+static char *test_file_name = "/mnt/lustre/test_lock_cancel";
+
+extern void __liblustre_setup_(void);
+extern void __liblustre_cleanup_(void);
+
+void usage(char *cmd)
+{
+        printf("Usage: \t%s --target mdsnid:/mdsname/profile\n", cmd);
+        printf("       \t%s --dumpfile dumpfile\n", cmd);
+        exit(-1);
+}
+
+int main(int argc, char *argv[])
+{
+        int opt_index, c;
+        static struct option long_opts[] = {
+                {"target", 1, 0, 0},
+                {"dumpfile", 1, 0, 0},
+                {0, 0, 0, 0}
+        };
+	int fd = 0;
+        long time1, time2;
+        struct stat statbuf;
+
+        if (argc < 3)
+                usage(argv[0]);
+
+        while ((c = getopt_long(argc, argv, "", long_opts, &opt_index)) != -1) {
+                switch (c) {
+                case 0: {
+                        if (!optarg[0])
+                                usage(argv[0]);
+
+                        if (!strcmp(long_opts[opt_index].name, "target")) {
+                                setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
+                        } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
+                                setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
+                        } else
+                                usage(argv[0]);
+                        break;
+                }
+                default:
+                        usage(argv[0]);
+                }
+        }
+
+        if (optind != argc)
+                usage(argv[0]);
+
+        __liblustre_setup_();
+
+	MPI_CHECK(MPI_Init(&argc, &argv), "MPI_Init()");
+	MPI_CHECK(MPI_Comm_size(MPI_COMM_WORLD, &numTasks), "MPI_Comm_size");
+	MPI_CHECK(MPI_Comm_rank(MPI_COMM_WORLD, &rank), "MPI_Comm_rank");
+
+        if (numTasks < 2) {
+                printf("this demo can't run on single node!\n");
+                goto cleanup;
+        }
+
+        if (rank == 0) {
+                unlink(test_file_name);
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+        if (rank == 1) {
+                printf("Node 1: creating file %s ...\n", test_file_name);
+                fflush(stdout);
+
+                fd = open(test_file_name, O_CREAT|O_RDWR, 0755);
+                if (fd < 0) {
+                        printf("Node %d: creat file err: %d", rank, fd);
+                        fflush(stdout);
+                        goto cleanup;
+                }
+                close(fd);
+                printf("Node 1: done creation. perform stat on file %s ...\n", test_file_name);
+                fflush(stdout);
+
+                if (stat(test_file_name, &statbuf)) {
+                        printf("Node %d: stat file err: %d", rank, fd);
+                        fflush(stdout);
+                        goto cleanup;
+                }
+
+                printf("Node %d: done stat on file\n", rank);
+                fflush(stdout);
+        } else {
+                printf("Node %d: waiting node 1 create & stat file\n", rank);
+                fflush(stdout);
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+        
+        if (rank == 1) {
+                printf("Node 1: file has been create+stat, abort excution here!!!!!!!\n");
+                fflush(stdout);
+                exit(0);
+        }
+        
+        sleep(1);
+        printf("Node %d: synced with Node 1. sleep 5 seconds...\n", rank);
+        fflush(stdout);
+        sleep(5);
+        printf("Node %d: wakeup from sleep. perform unlink()...\n", rank);
+        fflush(stdout);
+
+        time1 = time(NULL);
+        if (unlink(test_file_name)) {
+                printf("Node %d: error unlink file: %d\n", rank, fd);
+                fflush(stdout);
+                goto cleanup;
+        }
+        time2 = time(NULL);
+        printf("Node %d: successfully unlink file, cost %ld seconds.\n",
+                rank, time2 - time1);
+        fflush(stdout);
+
+cleanup:
+        __liblustre_cleanup_();
+        printf("Node %d: end sucessfully.\n", rank);
+	return 0;
+}
diff --git a/lustre/liblustre/tests/replay_single.c b/lustre/liblustre/tests/replay_single.c
index 2a4d4e8..e6f9697 100644
--- a/lustre/liblustre/tests/replay_single.c
+++ b/lustre/liblustre/tests/replay_single.c
@@ -111,9 +111,10 @@ void t0()
 {
         char *path="/mnt/lustre/f0";
         ENTRY("empty replay");
+
         replay_barrier();
         mds_failover();
-        t_check_stat_fail("/mnt/lustre/f0");
+        t_check_stat_fail(path);
         LEAVE();
 }
 
diff --git a/lustre/liblustre/tests/test_lock_cancel.c b/lustre/liblustre/tests/test_lock_cancel.c
deleted file mode 100644
index 8d0c4a3..0000000
--- a/lustre/liblustre/tests/test_lock_cancel.c
+++ /dev/null
@@ -1,211 +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  2008 Sun Microsystems, Inc. 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.
- *
- * lustre/liblustre/tests/test_lock_cancel.c
- *
- * Lustre Light user test program
- */
-
-#define _BSD_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <string.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/queue.h>
-
-#include <sysio.h>
-#include <mount.h>
-
-#include <test_common.h>
-
-#include <mpi.h>
-
-/******************************************************************************/
-/*
- * MPI_CHECK will display a custom error message as well as an error string
- * from the MPI_STATUS and then exit the program
- */
-
-#define MPI_CHECK(MPI_STATUS, MSG) do {                                  \
-    char resultString[MPI_MAX_ERROR_STRING];                             \
-    int resultLength;                                                    \
-                                                                         \
-    if (MPI_STATUS != MPI_SUCCESS) {                                     \
-        fprintf(stdout, "** error **\n");                                \
-        fprintf(stdout, "ERROR in %s (line %d): %s.\n",                  \
-                __FILE__, __LINE__, MSG);                                \
-        MPI_Error_string(MPI_STATUS, resultString, &resultLength);       \
-        fprintf(stdout, "MPI %s\n", resultString);                       \
-        fprintf(stdout, "** exiting **\n");                              \
-        MPI_Abort(MPI_COMM_WORLD, 1);                                    \
-    }                                                                    \
-} while(0)
-
-int		numTasks     = 0,	/* MPI variables */
-		rank         = 0,
-		tasksPerNode = 0;	/* tasks per node */
-
-
-
-
-static char *test_file_name = "/mnt/lustre/test_lock_cancel";
-
-extern void __liblustre_setup_(void);
-extern void __liblustre_cleanup_(void);
-
-void usage(char *cmd)
-{
-        printf("Usage: \t%s --target mdsnid:/mdsname/profile\n", cmd);
-        printf("       \t%s --dumpfile dumpfile\n", cmd);
-        exit(-1);
-}
-
-int main(int argc, char *argv[])
-{
-        int opt_index, c;
-        static struct option long_opts[] = {
-                {"target", 1, 0, 0},
-                {"dumpfile", 1, 0, 0},
-                {0, 0, 0, 0}
-        };
-	int fd;
-        long time1, time2;
-        struct stat statbuf;
-
-        if (argc < 3)
-                usage(argv[0]);
-
-        while ((c = getopt_long(argc, argv, "", long_opts, &opt_index)) != -1) {
-                switch (c) {
-                case 0: {
-                        if (!optarg[0])
-                                usage(argv[0]);
-
-                        if (!strcmp(long_opts[opt_index].name, "target")) {
-                                setenv(ENV_LUSTRE_MNTTGT, optarg, 1);
-                        } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) {
-                                setenv(ENV_LUSTRE_DUMPFILE, optarg, 1);
-                        } else
-                                usage(argv[0]);
-                        break;
-                }
-                default:
-                        usage(argv[0]);
-                }
-        }
-
-        if (optind != argc)
-                usage(argv[0]);
-
-        __liblustre_setup_();
-
-	MPI_CHECK(MPI_Init(&argc, &argv), "MPI_Init()");
-	MPI_CHECK(MPI_Comm_size(MPI_COMM_WORLD, &numTasks), "MPI_Comm_size");
-	MPI_CHECK(MPI_Comm_rank(MPI_COMM_WORLD, &rank), "MPI_Comm_rank");
-
-        if (numTasks < 2) {
-                printf("this demo can't run on single node!\n");
-                goto cleanup;
-        }
-
-        if (rank == 0) {
-                unlink(test_file_name);
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-        if (rank == 1) {
-                printf("Node 1: creating file %s ...\n", test_file_name);
-                fflush(stdout);
-
-                fd = open(test_file_name, O_CREAT|O_RDWR, 0755);
-                if (fd < 0) {
-                        printf("Node %d: creat file err: %d", rank, fd);
-                        fflush(stdout);
-                        goto cleanup;
-                }
-                close(fd);
-                printf("Node 1: done creation. perform stat on file %s ...\n", test_file_name);
-                fflush(stdout);
-
-                if (stat(test_file_name, &statbuf)) {
-                        printf("Node %d: stat file err: %d", rank, fd);
-                        fflush(stdout);
-                        goto cleanup;
-                }
-
-                printf("Node %d: done stat on file\n", rank);
-                fflush(stdout);
-        } else {
-                printf("Node %d: waiting node 1 create & stat file\n", rank);
-                fflush(stdout);
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-        
-        if (rank == 1) {
-                printf("Node 1: file has been create+stat, abort excution here!!!!!!!\n");
-                fflush(stdout);
-                exit(0);
-        }
-        
-        sleep(1);
-        printf("Node %d: synced with Node 1. sleep 5 seconds...\n", rank);
-        fflush(stdout);
-        sleep(5);
-        printf("Node %d: wakeup from sleep. perform unlink()...\n", rank);
-        fflush(stdout);
-
-        time1 = time(NULL);
-        if (unlink(test_file_name)) {
-                printf("Node %d: error unlink file: %d\n", rank, fd);
-                fflush(stdout);
-                goto cleanup;
-        }
-        time2 = time(NULL);
-        printf("Node %d: successfully unlink file, cost %ld seconds.\n",
-                rank, time2 - time1);
-        fflush(stdout);
-
-cleanup:
-        __liblustre_cleanup_();
-        printf("Node %d: end sucessfully.\n", rank);
-	return 0;
-}
diff --git a/lustre/llite/Makefile.in b/lustre/llite/Makefile.in
index b5ed7be..98a829d 100644
--- a/lustre/llite/Makefile.in
+++ b/lustre/llite/Makefile.in
@@ -5,4 +5,7 @@ llite_lloop-objs := lloop.o
 
 lustre-objs += rw26.o super25.o
 
+EXTRA_DIST := $(lustre-objs:.o=.c) llite_internal.h rw26.c super25.c
+EXTRA_DIST += $(llite_lloop-objs:.o=.c)
+
 @INCLUDE_RULES@
diff --git a/lustre/llite/autoMakefile.am b/lustre/llite/autoMakefile.am
index 5dcc0cd..391a8f6 100644
--- a/lustre/llite/autoMakefile.am
+++ b/lustre/llite/autoMakefile.am
@@ -38,6 +38,4 @@ if MODULES
 modulefs_DATA = lustre$(KMODEXT) llite_lloop$(KMODEXT)
 endif
 
-DIST_SOURCES := $(lustre-objs:.o=.c) llite_internal.h rw24.c super.c rw26.c super25.c
-DIST_SOURCES += $(llite_lloop-objs:.o=.c)
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
diff --git a/lustre/llite/autoMakefile.in b/lustre/llite/autoMakefile.in
index b76acf6..c643fbb 100644
--- a/lustre/llite/autoMakefile.in
+++ b/lustre/llite/autoMakefile.in
@@ -209,10 +209,11 @@ MAKEINFO = @MAKEINFO@
 MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
+
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -329,13 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @MODULES_TRUE at modulefs_DATA = lustre$(KMODEXT) llite_lloop$(KMODEXT)
-
-DIST_SOURCES = $(lustre-objs:.o=.c) llite_internal.h rw24.c super.c rw26.c super25.c $(llite_lloop-objs:.o=.c)
 subdir = lustre/llite
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c
index 931213d..d3abbfc 100644
--- a/lustre/llite/dcache.c
+++ b/lustre/llite/dcache.c
@@ -352,7 +352,7 @@ void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft)
 int ll_revalidate_it(struct dentry *de, int lookup_flags,
                      struct lookup_intent *it)
 {
-        struct mdc_op_data op_data;
+        struct mdc_op_data op_data = { { 0 } };
         struct ptlrpc_request *req = NULL;
         struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
         struct obd_export *exp;
@@ -449,9 +449,10 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags,
 
 do_lock:
         it->it_create_mode &= ~current->fs->umask;
-
+        it->it_create_mode |= M_CHECK_STALE;
         rc = mdc_intent_lock(exp, &op_data, NULL, 0, it, lookup_flags,
                              &req, ll_mdc_blocking_ast, 0);
+        it->it_create_mode &= ~M_CHECK_STALE;
         if (it->it_op == IT_GETATTR && !first)
                 /* If there are too many locks on client-side, then some
                  * locks taken by statahead maybe dropped automatically
@@ -625,8 +626,8 @@ out_sa:
         unlock_kernel();
 
         handle = (flag) ? &ldd->lld_mnt_och : &ldd->lld_cwd_och;
-        rc = obd_pin(sbi->ll_mdc_exp, inode->i_ino, inode->i_generation,
-                     inode->i_mode & S_IFMT, handle, flag);
+        rc = obd_pin(sbi->ll_mdc_exp, ll_inode_ll_fid(inode),
+                     handle, flag);
 
         if (rc) {
                 lock_kernel();
@@ -725,16 +726,20 @@ int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
                                                (struct ptlrpc_request *)
                                                   it->d.lustre.it_data);
                         } else {
-                                struct file *filp;
-
-                                nd->intent.open.file->private_data = it;
-                                filp = lookup_instantiate_filp(nd, dentry,NULL);
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
 /* 2.6.1[456] have a bug in open_namei() that forgets to check
  * nd->intent.open.file for error, so we need to return it as lookup's result
  * instead */
-                                if (IS_ERR(filp))
+                                struct file *filp;
+
+                                nd->intent.open.file->private_data = it;
+                                filp = lookup_instantiate_filp(nd, dentry,NULL);
+                                if (IS_ERR(filp)) {
                                         rc = 0;
+                                }
+#else
+                                nd->intent.open.file->private_data = it;
+                                (void)lookup_instantiate_filp(nd, dentry,NULL);
 #endif
                         }
 #else
diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c
index 54cb7a3..301edbf 100644
--- a/lustre/llite/dir.c
+++ b/lustre/llite/dir.c
@@ -80,7 +80,7 @@ static int ll_dir_readpage(struct file *file, struct page *page)
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) off "LPU64"\n",
                inode->i_ino, inode->i_generation, inode, offset);
 
-        mdc_pack_fid(&mdc_fid, inode->i_ino, inode->i_generation, S_IFDIR);
+        ll_pack_fid(&mdc_fid, inode->i_ino, inode->i_generation, S_IFDIR);
 
         rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, &mdc_fid,
                           offset, page, &request);
@@ -209,8 +209,7 @@ static void ll_dir_check_page(struct inode *dir, struct page *page)
 
 struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
 {
-        struct ldlm_res_id res_id =
-                { .name = { dir->i_ino, (__u64)dir->i_generation} };
+        struct ldlm_res_id res_id;
         struct lustre_handle lockh;
         struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_mdc_exp);
         struct address_space *mapping = dir->i_mapping;
@@ -218,6 +217,7 @@ struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
         ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_UPDATE} };
         int rc;
 
+        fid_build_reg_res_name(ll_inode_lu_fid(dir), &res_id);
         rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED,
                              &res_id, LDLM_IBITS, &policy, LCK_CR, &lockh);
         if (!rc) {
@@ -225,7 +225,7 @@ struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
                 struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_CR,
                        ll_mdc_blocking_ast, ldlm_completion_ast, NULL, dir };
                 struct ptlrpc_request *request;
-                struct mdc_op_data data;
+                struct mdc_op_data data = { { 0 } };
 
                 ll_prepare_mdc_op_data(&data, dir, NULL, NULL, 0, 0, NULL);
 
@@ -311,8 +311,8 @@ static unsigned char ll_dir_filetype_table[LL_DIR_FT_MAX] = {
  *       0: no live entries on this page.
  */
 
-int ll_readdir_page(char *addr, __u64 base, unsigned *offset,
-                    filldir_t filldir, void *cookie)
+static int ll_readdir_page(char *addr, __u64 base, unsigned *offset,
+                           filldir_t filldir, void *cookie)
 {
         struct ll_dir_entry *de;
         char *end;
@@ -334,7 +334,7 @@ int ll_readdir_page(char *addr, __u64 base, unsigned *offset,
         return nr;
 }
 
-int ll_readdir(struct file *filp, void *dirent, filldir_t filldir)
+static int ll_readdir_18(struct file *filp, void *dirent, filldir_t filldir)
 {
         struct inode *inode = filp->f_dentry->d_inode;
         loff_t pos          = filp->f_pos;
@@ -419,6 +419,514 @@ int ll_readdir(struct file *filp, void *dirent, filldir_t filldir)
         RETURN(rc);
 }
 
+/*      
+ * Chain of hash overflow pages.
+ */            
+struct ll_dir_chain {
+        /* XXX something. Later */
+};
+  
+static inline void ll_dir_chain_init(struct ll_dir_chain *chain)
+{  
+}
+
+static inline void ll_dir_chain_fini(struct ll_dir_chain *chain)
+{
+}
+
+static inline __u32 hash_x_index(__u32 value)
+{
+        return ((__u32)~0) - value;
+}
+
+/**
+ * Layout of readdir pages, as transmitted on wire.
+ */
+struct lu_dirent {
+        /** valid if LUDA_FID is set. */
+        struct lu_fid lde_fid;
+        /** a unique entry identifier: a hash or an offset. */
+        __u64         lde_hash;
+        /** total record length, including all attributes. */
+        __u16         lde_reclen;
+        /** name length */
+        __u16         lde_namelen;
+        /** optional variable size attributes following this entry.
+         *  taken from enum lu_dirent_attrs.
+         */
+        __u32         lde_attrs;
+        /** name is followed by the attributes indicated in ->ldp_attrs, in
+         *  their natural order. After the last attribute, padding bytes are
+         *  added to make ->lde_reclen a multiple of 8.
+         */
+        char          lde_name[0];
+};
+
+struct lu_dirpage {
+        __u64            ldp_hash_start;
+        __u64            ldp_hash_end;
+        __u16            ldp_flags;
+        __u16            ldp_pad0;
+        __u32            ldp_pad1;
+        struct lu_dirent ldp_entries[0];
+};
+
+/*
+ * Definitions of optional directory entry attributes formats.
+ *
+ * Individual attributes do not have their length encoded in a generic way. It
+ * is assumed that consumer of an attribute knows its format. This means that
+ * it is impossible to skip over an unknown attribute, except by skipping over all
+ * remaining attributes (by using ->lde_reclen), which is not too
+ * constraining, because new server versions will append new attributes at
+ * the end of an entry.
+ */
+
+/**
+ * Fid directory attribute: a fid of an object referenced by the entry. This
+ * will be almost always requested by the client and supplied by the server.
+ *
+ * Aligned to 8 bytes.
+ */
+/* To have compatibility with 1.8, lets have fid in lu_dirent struct. */
+
+/**
+ * File type.
+ *
+ * Aligned to 2 bytes.
+ */
+struct luda_type {
+        __u16 lt_type;
+};
+
+enum lu_dirpage_flags {
+        LDF_EMPTY = 1 << 0
+};
+
+static inline int lu_dirent_calc_size(int namelen, __u16 attr)
+{
+        int size;
+
+        if (attr & LUDA_TYPE) {
+                const unsigned align = sizeof(struct luda_type) - 1;
+                size = (sizeof(struct lu_dirent) + namelen + align) & ~align;
+                size += sizeof(struct luda_type);
+        } else
+                size = sizeof(struct lu_dirent) + namelen;
+
+        return (size + 7) & ~7;
+}
+
+/**
+ * return IF_* type for given lu_dirent entry.
+ * IF_* flag shld be converted to particular OS file type in
+ * platform llite module.
+ */
+__u16 ll_dirent_type_get(struct lu_dirent *ent)
+{
+        __u16 type = 0;
+        struct luda_type *lt;
+        int len = 0;
+
+        if (le32_to_cpu(ent->lde_attrs) & LUDA_TYPE) {
+                const unsigned align = sizeof(struct luda_type) - 1;
+
+                len = le16_to_cpu(ent->lde_namelen);
+                len = (len + align) & ~align;
+                lt = (void *) ent->lde_name + len;
+                type = CFS_IFTODT(le16_to_cpu(lt->lt_type));
+        }
+        return type;
+}
+
+static inline struct lu_dirent *lu_dirent_start(struct lu_dirpage *dp)
+{
+        if (le16_to_cpu(dp->ldp_flags) & LDF_EMPTY)
+                return NULL;
+        else
+                return dp->ldp_entries;
+}
+
+static inline struct lu_dirent *lu_dirent_next(struct lu_dirent *ent)
+{
+        struct lu_dirent *next;
+
+        if (le16_to_cpu(ent->lde_reclen) != 0)
+                next = ((void *)ent) + le16_to_cpu(ent->lde_reclen);
+        else
+                next = NULL;
+
+        return next;
+}
+
+static inline int lu_dirent_size(struct lu_dirent *ent)
+{
+        if (le16_to_cpu(ent->lde_reclen) == 0) {
+                return lu_dirent_calc_size(le16_to_cpu(ent->lde_namelen),
+                                           le32_to_cpu(ent->lde_attrs));
+        }
+        return le16_to_cpu(ent->lde_reclen);
+}
+
+#define DIR_END_OFF              0xfffffffffffffffeULL
+
+#ifdef HAVE_RW_TREE_LOCK
+#define TREE_READ_LOCK_IRQ(mapping)     read_lock_irq(&(mapping)->tree_lock)
+#define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock)
+#else
+#define TREE_READ_LOCK_IRQ(mapping) spin_lock_irq(&(mapping)->tree_lock)
+#define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock)
+#endif
+
+/* returns the page unlocked, but with a reference */
+static int ll_dir_readpage_20(struct file *file, struct page *page)
+{
+        struct inode *inode = page->mapping->host;
+        struct ptlrpc_request *request;
+        struct mdt_body *body;
+        struct ll_fid fid;
+        __u64 hash;
+        int rc;
+        ENTRY;
+
+        hash = hash_x_index(page->index);
+        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) off %lu\n",
+               inode->i_ino, inode->i_generation, inode, (unsigned long)hash);
+
+        ll_inode2fid(&fid, inode);
+        rc = mdc_readpage(ll_i2sbi(inode)->ll_mdc_exp, &fid,
+                          hash, page, &request);
+        if (!rc) {
+                body = lustre_msg_buf(request->rq_repmsg, REPLY_REC_OFF,
+                                      sizeof(*body));
+                /* Checked by mdc_readpage() */
+                LASSERT(body != NULL);
+
+                if (body->valid & OBD_MD_FLSIZE) {
+                        ll_inode_size_lock(inode, 0);
+                        i_size_write(inode, body->size);
+                        ll_inode_size_unlock(inode, 0);
+                }
+                SetPageUptodate(page);
+        }
+        ptlrpc_req_finished(request);
+
+        unlock_page(page);
+        EXIT;
+        return rc;
+}
+
+
+static void ll_check_page(struct inode *dir, struct page *page)
+{
+        /* XXX: check page format later */
+        SetPageChecked(page);
+}
+
+
+/*
+ * Find, kmap and return page that contains given hash.
+ */
+static struct page *ll_dir_page_locate(struct inode *dir, unsigned long hash,
+                                       __u64 *start, __u64 *end)
+{
+        struct address_space *mapping = dir->i_mapping;
+        /*
+         * Complement of hash is used as an index so that
+         * radix_tree_gang_lookup() can be used to find a page with starting
+         * hash _smaller_ than one we are looking for.
+         */
+        unsigned long offset = hash_x_index(hash);
+        struct page *page;
+        int found;
+        ENTRY;
+
+        TREE_READ_LOCK_IRQ(mapping);
+        found = radix_tree_gang_lookup(&mapping->page_tree,
+                                       (void **)&page, offset, 1);
+        if (found > 0) {
+                struct lu_dirpage *dp;
+
+                page_cache_get(page);
+                TREE_READ_UNLOCK_IRQ(mapping);
+                /*
+                 * In contrast to find_lock_page() we are sure that directory
+                 * page cannot be truncated (while DLM lock is held) and,
+                 * hence, can avoid restart.
+                 *
+                 * In fact, page cannot be locked here at all, because
+                 * ll_dir_readpage() does synchronous io.
+                 */
+                wait_on_page(page);
+                if (PageUptodate(page)) {
+                        dp = kmap(page);
+                        *start = le64_to_cpu(dp->ldp_hash_start);
+                        *end   = le64_to_cpu(dp->ldp_hash_end);
+                        LASSERT(*start <= hash);
+                        if (hash > *end || (*end != *start && hash == *end)) {
+                                kunmap(page);
+                                lock_page(page);
+                                ll_truncate_complete_page(page);
+                                unlock_page(page);
+                                page_cache_release(page);
+                                page = NULL;
+                        }
+                } else {
+                        page_cache_release(page);
+                        page = ERR_PTR(-EIO);
+                }
+
+        } else {
+                TREE_READ_UNLOCK_IRQ(mapping);
+                page = NULL;
+        }
+        RETURN(page);
+}
+
+static struct page *ll_get_dir_page_20(struct inode *dir, __u64 hash, int exact,
+                                       struct ll_dir_chain *chain)
+{
+        struct ldlm_res_id res_id;
+        struct lustre_handle lockh;
+        struct obd_device *obddev = class_exp2obd(ll_i2sbi(dir)->ll_mdc_exp);
+        struct address_space *mapping = dir->i_mapping;
+        struct lu_dirpage *dp;
+        struct page *page;
+        ldlm_policy_data_t policy = {.l_inodebits = {MDS_INODELOCK_UPDATE} };
+        ldlm_mode_t mode;
+        int rc;
+        __u64 start = 0;
+        __u64 end = 0;
+        ENTRY;
+ 
+        fid_build_reg_res_name(ll_inode_lu_fid(dir), &res_id);
+        mode = LCK_PR;
+        rc = ldlm_lock_match(obddev->obd_namespace, LDLM_FL_BLOCK_GRANTED,
+                             &res_id, LDLM_IBITS, &policy, mode, &lockh);
+        if (!rc) {
+                struct lookup_intent it = { .it_op = IT_READDIR };
+                struct ldlm_enqueue_info einfo = { LDLM_IBITS, mode,
+                       ll_mdc_blocking_ast, ldlm_completion_ast, NULL, dir };
+                struct ptlrpc_request *request;
+                struct mdc_op_data op_data = { { 0 } };
+
+                ll_prepare_mdc_op_data(&op_data, dir, NULL, NULL, 0, 0, NULL);
+
+                rc = mdc_enqueue(ll_i2sbi(dir)->ll_mdc_exp, &einfo, &it,
+                                 &op_data, &lockh, NULL, 0, 0);
+
+                request = (struct ptlrpc_request *)it.d.lustre.it_data;
+                if (request)
+                        ptlrpc_req_finished(request);
+                if (rc < 0) {
+                        CERROR("lock enqueue: rc: %d\n", rc);
+                        RETURN(ERR_PTR(rc));
+                }
+        }
+        ldlm_lock_dump_handle(D_OTHER, &lockh);
+
+        page = ll_dir_page_locate(dir, hash, &start, &end);
+        if (IS_ERR(page))
+                GOTO(out_unlock, page);
+
+        if (page != NULL) {
+                /*
+                 * XXX nikita: not entirely correct handling of a corner case:
+                 * suppose hash chain of entries with hash value HASH crosses
+                 * border between pages P0 and P1. First both P0 and P1 are
+                 * cached, seekdir() is called for some entry from the P0 part
+                 * of the chain. Later P0 goes out of cache. telldir(HASH)
+                 * happens and finds P1, as it starts with matching hash
+                 * value. Remaining entries from P0 part of the chain are
+                 * skipped. (Is that really a bug?)
+                 *
+                 * Possible solutions: 0. don't cache P1 is such case, handle
+                 * it as an "overflow" page. 1. invalidate all pages at
+                 * once. 2. use HASH|1 as an index for P1.
+                 */
+                if (exact && hash != start) {
+                        /*
+                         * readdir asked for a page starting _exactly_ from
+                         * given hash, but cache contains stale page, with
+                         * entries with smaller hash values. Stale page should
+                         * be invalidated, and new one fetched.
+                         */
+                        CDEBUG(D_INFO, "Stale readpage page %p: %#lx != %#lx\n",
+                              page, (unsigned long)hash, (unsigned long)start);
+                        lock_page(page);
+                        ll_truncate_complete_page(page);
+                        unlock_page(page);
+                        page_cache_release(page);
+                } else {
+                        GOTO(hash_collision, page);
+                }
+        }
+
+        page = read_cache_page(mapping, hash_x_index(hash),
+                               (filler_t*)ll_dir_readpage_20, NULL);
+        if (IS_ERR(page))
+                GOTO(out_unlock, page);
+
+        wait_on_page(page);
+        (void)kmap(page);
+        if (!PageUptodate(page))
+                goto fail;
+        if (!PageChecked(page))
+                ll_check_page(dir, page);
+        if (PageError(page))
+                goto fail;
+hash_collision:
+        dp = page_address(page);
+
+        start = le64_to_cpu(dp->ldp_hash_start);
+        end   = le64_to_cpu(dp->ldp_hash_end);
+        if (end == start) {
+                LASSERT(start == hash);
+                CWARN("Page-wide hash collision: %#lx\n", (unsigned long)end);
+                /*
+                 * Fetch whole overflow chain...
+                 *
+                 * XXX not yet.
+                 */
+                goto fail;
+        }
+out_unlock:
+        ldlm_lock_decref(&lockh, mode);
+        RETURN(page);
+
+fail:
+        ll_put_page(page);
+        page = ERR_PTR(-EIO);
+        goto out_unlock;
+}
+
+static int ll_readdir_20(struct file *filp, void *cookie, filldir_t filldir)
+{
+        struct inode         *inode = filp->f_dentry->d_inode;
+        struct ll_sb_info    *sbi   = ll_i2sbi(inode);
+        __u64                 pos   = filp->f_pos;
+        struct page          *page;
+        struct ll_dir_chain   chain;
+        int rc;
+        int done;
+        int shift;
+        __u16 type;
+        ENTRY;
+
+        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu\n",
+               inode->i_ino, inode->i_generation, inode,
+               (unsigned long)pos, i_size_read(inode));
+
+        if (pos == DIR_END_OFF)
+                /*
+                 * end-of-file.
+                 */
+                RETURN(0);
+
+        rc    = 0;
+        done  = 0;
+        shift = 0;
+        ll_dir_chain_init(&chain);
+
+        page = ll_get_dir_page_20(inode, pos, 0, &chain);
+
+        while (rc == 0 && !done) {
+                struct lu_dirpage *dp;
+                struct lu_dirent  *ent;
+
+                if (!IS_ERR(page)) {
+                        /* 
+                         * If page is empty (end of directoryis reached),
+                         * use this value. 
+                         */
+                        __u64 hash = DIR_END_OFF;
+                        __u64 next;
+
+                        dp = page_address(page);
+                        for (ent = lu_dirent_start(dp); ent != NULL && !done;
+                             ent = lu_dirent_next(ent)) {
+                                char          *name;
+                                int            namelen;
+                                struct lu_fid  fid;
+                                ino_t          ino;
+
+                                hash    = le64_to_cpu(ent->lde_hash);
+                                namelen = le16_to_cpu(ent->lde_namelen);
+
+                                if (hash < pos)
+                                        /*
+                                         * Skip until we find target hash
+                                         * value.
+                                         */
+                                        continue;
+
+                                if (namelen == 0)
+                                        /*
+                                         * Skip dummy record.
+                                         */
+                                        continue;
+
+                                fid  = ent->lde_fid;
+                                name = ent->lde_name;
+                                fid_le_to_cpu(&fid, &fid);
+                                ino  = ll_fid_build_ino(sbi, (struct ll_fid*)&fid);
+                                type = ll_dirent_type_get(ent);
+                                done = filldir(cookie, name, namelen,
+                                               (loff_t)hash, ino, type);
+                        }
+                        next = le64_to_cpu(dp->ldp_hash_end);
+                        ll_put_page(page);
+                        if (!done) {
+                                pos = next;
+                                if (pos == DIR_END_OFF)
+                                        /*
+                                         * End of directory reached.
+                                         */
+                                        done = 1;
+                                else if (1 /* chain is exhausted*/)
+                                        /*
+                                         * Normal case: continue to the next
+                                         * page.
+                                         */
+                                        page = ll_get_dir_page_20(inode, pos, 1,
+                                                                  &chain);
+                                else {
+                                        /*
+                                         * go into overflow page.
+                                         */
+                                }
+                        } else {
+                                pos = hash;
+                        }
+                } else {
+                        rc = PTR_ERR(page);
+                        CERROR("error reading dir "DFID" at %lu: rc %d\n",
+                               PFID(ll_inode_lu_fid(inode)),
+                               (unsigned long)pos, rc);
+                }
+        }
+
+        filp->f_pos = (loff_t)(__s32)pos;
+        filp->f_version = inode->i_version;
+        touch_atime(filp->f_vfsmnt, filp->f_dentry);
+
+        ll_dir_chain_fini(&chain);
+
+        RETURN(rc);
+}
+
+static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
+{
+        struct inode      *inode = filp->f_dentry->d_inode;
+        struct ll_sb_info *sbi = ll_i2sbi(inode);
+
+        if (sbi->ll_mdc_exp->exp_connect_flags & OBD_CONNECT_FID) {
+                return ll_readdir_20(filp, cookie, filldir);
+        } else {
+                return ll_readdir_18(filp, cookie, filldir);
+        }
+}
+
 #define QCTL_COPY(out, in)              \
 do {                                    \
         Q_COPY(out, in, qc_cmd);        \
@@ -429,7 +937,7 @@ do {                                    \
         Q_COPY(out, in, qc_dqblk);      \
 } while (0)
 
-int ll_send_mgc_param(struct obd_export *mgc, char *string)
+static int ll_send_mgc_param(struct obd_export *mgc, char *string)
 {
         struct mgs_send_param *msp;
         int rc = 0;
@@ -448,7 +956,7 @@ int ll_send_mgc_param(struct obd_export *mgc, char *string)
         return rc;
 }
 
-char *ll_get_fsname(struct inode *inode)
+static char *ll_get_fsname(struct inode *inode)
 {
         struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
         char *ptr, *fsname;
@@ -469,31 +977,35 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
                      int set_default)
 {
         struct ll_sb_info *sbi = ll_i2sbi(inode);
-        struct mdc_op_data data;
+        struct mdc_op_data data = { { 0 } };
         struct ptlrpc_request *req = NULL;
         struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
         struct obd_device *mgc = lsi->lsi_mgc;
         char *fsname = NULL, *param = NULL;
+        int lum_size = sizeof(struct lov_user_md_v1);
 
         struct iattr attr = { 0 };
         int rc = 0;
 
+        if (lump->lmm_magic == LOV_USER_MAGIC_V3)
+                lum_size = sizeof(struct lov_user_md_v3);
         /*
          * This is coming from userspace, so should be in
          * local endian.  But the MDS would like it in little
          * endian, so we swab it before we send it.
          */
-        if (lump->lmm_magic != LOV_USER_MAGIC)
-                RETURN(-EINVAL);
-
-        if (lump->lmm_magic != cpu_to_le32(LOV_USER_MAGIC))
-                lustre_swab_lov_user_md(lump);
+        if ((lump->lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V1)) &&
+            (lump->lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V3))) {
+                rc = lustre_swab_lov_user_md(lump);
+                if (rc) 
+                        return rc;
+        }
 
         ll_prepare_mdc_op_data(&data, inode, NULL, NULL, 0, 0, NULL);
 
         /* swabbing is done in lov_setstripe() on server side */
         rc = mdc_setattr(sbi->ll_mdc_exp, &data,
-                         &attr, lump, sizeof(*lump), NULL, 0, &req);
+                         &attr, lump, lum_size, NULL, 0, &req);
         if (rc) {
                 ptlrpc_req_finished(req);
                 if (rc != -EPERM && rc != -EACCES)
@@ -502,6 +1014,9 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
         }
         ptlrpc_req_finished(req);
 
+        /* In the following we use the fact that LOV_USER_MAGIC_V1 and
+         LOV_USER_MAGIC_V3 have the same initial fields so we do not
+         need the make the distiction between the 2 versions */
         if (set_default && mgc->u.cli.cl_mgc_mgsexp) {
                 OBD_ALLOC(param, MGS_PARAM_MAXLEN);
 
@@ -509,21 +1024,21 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
                 fsname = ll_get_fsname(inode);
                 /* Set root stripesize */
                 sprintf(param, "%s-MDT0000.lov.stripesize=%u", fsname,
-                        lump->lmm_stripe_size);
+                        le32_to_cpu(lump->lmm_stripe_size));
                 rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
                 if (rc)
                         goto end;
 
                 /* Set root stripecount */
                 sprintf(param, "%s-MDT0000.lov.stripecount=%u", fsname,
-                        lump->lmm_stripe_count);
+                        le16_to_cpu(lump->lmm_stripe_count));
                 rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
                 if (rc)
                         goto end;
 
                 /* Set root stripeoffset */
                 sprintf(param, "%s-MDT0000.lov.stripeoffset=%u", fsname,
-                        lump->lmm_stripe_offset);
+                        le16_to_cpu(lump->lmm_stripe_offset));
                 rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
                 if (rc)
                         goto end;
@@ -583,9 +1098,15 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
          * little endian.  We convert it to host endian before
          * passing it to userspace.
          */
-        if ((LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) &&
-            (cpu_to_le32(LOV_MAGIC) == lmm->lmm_magic))
-                lustre_swab_lov_user_md((struct lov_user_md *)lmm);
+        /* We don't swab objects for directories */
+        if (((le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V1) ||
+            (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3)) &&
+            (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))) {
+                rc = lustre_swab_lov_user_md((struct lov_user_md*)lmm);
+                if (rc)
+                        GOTO(out, rc);
+        }
+
 out:
         *lmmp = lmm;
         *lmm_size = lmmsize;
@@ -609,11 +1130,11 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
 
         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_IOCTL, 1);
         switch(cmd) {
-        case EXT3_IOC_GETFLAGS:
-        case EXT3_IOC_SETFLAGS:
+        case FSFILT_IOC_GETFLAGS:
+        case FSFILT_IOC_SETFLAGS:
                 RETURN(ll_iocontrol(inode, file, cmd, arg));
-        case EXT3_IOC_GETVERSION_OLD:
-        case EXT3_IOC_GETVERSION:
+        case FSFILT_IOC_GETVERSION_OLD:
+        case FSFILT_IOC_GETVERSION:
                 RETURN(put_user(inode->i_generation, (int *)arg));
         /* We need to special case any other ioctls we want to handle,
          * to send them to the MDS/OST as appropriate and to properly
@@ -657,21 +1178,34 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 return rc;
         }
         case LL_IOC_LOV_SETSTRIPE: {
-                struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
+                struct lov_user_md_v3 lumv3;
+                struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3;
+                struct lov_user_md_v1 *lumv1p = (struct lov_user_md_v1 *)arg;
+                struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg;
+
                 int rc = 0;
                 int set_default = 0;
 
-                LASSERT(sizeof(lum) == sizeof(*lump));
-                LASSERT(sizeof(lum.lmm_objects[0]) ==
-                        sizeof(lump->lmm_objects[0]));
-                rc = copy_from_user(&lum, lump, sizeof(lum));
+                LASSERT(sizeof(lumv3) == sizeof(*lumv3p));
+                LASSERT(sizeof(lumv3.lmm_objects[0]) ==
+                        sizeof(lumv3p->lmm_objects[0]));
+
+                /* first try with v1 which is smaller than v3 */
+                rc = copy_from_user(lumv1, lumv1p, sizeof(*lumv1));
                 if (rc)
                         return(-EFAULT);
 
+                if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) {
+                        rc = copy_from_user(&lumv3, lumv3p, sizeof(lumv3));
+                        if (rc)
+                                RETURN(-EFAULT);
+                }
+
                 if (inode->i_sb->s_root == file->f_dentry)
                         set_default = 1;
 
-                rc = ll_dir_setstripe(inode, &lum, set_default);
+                /* in v1 and v3 cases lumv1 points to data */
+                rc = ll_dir_setstripe(inode, lumv1, set_default);
 
                 return rc;
         }
@@ -785,13 +1319,15 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 if (rc)
                         GOTO(free_lmm, rc = -EFAULT);
 
-                if (lmm->lmm_magic != LOV_USER_MAGIC)
-                        GOTO(free_lmm, rc = -EINVAL);
-
-                if (LOV_USER_MAGIC != cpu_to_le32(LOV_USER_MAGIC) &&
-                    cpu_to_le32(LOV_USER_MAGIC) == cpu_to_le32(lmm->lmm_magic)) {
-                        lustre_swab_lov_user_md_objects((struct lov_user_md *)lmm);
-                        lustre_swab_lov_user_md((struct lov_user_md *)lmm);
+                if (LOV_USER_MAGIC != cpu_to_le32(LOV_USER_MAGIC)) {
+                        rc = lustre_swab_lov_user_md(
+                                                (struct lov_user_md_v1 *)lmm);
+                        if (rc) 
+                                GOTO(free_lmm, rc);
+                        rc = lustre_swab_lov_user_md_objects(
+                                                (struct lov_user_md*)lmm);
+                        if (rc) 
+                                GOTO(free_lmm, rc);
                 }
 
                 rc = obd_unpackmd(sbi->ll_osc_exp, &lsm, lmm, lmmsize);
diff --git a/lustre/llite/file.c b/lustre/llite/file.c
index 79872b1..662d64d 100644
--- a/lustre/llite/file.c
+++ b/lustre/llite/file.c
@@ -69,6 +69,8 @@ static int ll_close_inode_openhandle(struct inode *inode,
         struct ptlrpc_request *req = NULL;
         struct obd_device *obd;
         struct obdo *oa;
+        struct mdc_op_data data = { { 0 } };
+        obd_flag valid;
         int rc;
         ENTRY;
 
@@ -93,16 +95,17 @@ static int ll_close_inode_openhandle(struct inode *inode,
 
         oa->o_id = inode->i_ino;
         oa->o_valid = OBD_MD_FLID;
-        obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLMODE |
-                                   OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
-                                   OBD_MD_FLATIME | OBD_MD_FLMTIME |
-                                   OBD_MD_FLCTIME);
+        valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLATIME |
+                OBD_MD_FLMTIME | OBD_MD_FLCTIME;
+        if (S_ISREG(inode->i_mode))
+                valid |=  OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+        obdo_from_inode(oa, inode, valid);
         if (ll_is_inode_dirty(inode)) {
                 oa->o_flags = MDS_BFLAG_UNCOMMITTED_WRITES;
                 oa->o_valid |= OBD_MD_FLFLAGS;
         }
-
-        rc = mdc_close(ll_i2mdcexp(inode), oa, och, &req);
+        ll_inode2fid(&data.fid1, inode);
+        rc = mdc_close(ll_i2mdcexp(inode), &data, oa, och, &req);
         if (rc == EAGAIN) {
                 /* We are the last writer, so the MDS has instructed us to get
                  * the file size and any write cookies, then close again. */
@@ -195,9 +198,10 @@ int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode,
                 int flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_TEST_LOCK;
                 struct lustre_handle lockh;
                 struct inode *inode = file->f_dentry->d_inode;
-                struct ldlm_res_id file_res_id = {.name={inode->i_ino,
-                                                         inode->i_generation}};
+                struct ldlm_res_id file_res_id;
+
                 ldlm_policy_data_t policy = {.l_inodebits={MDS_INODELOCK_OPEN}};
+                fid_build_reg_res_name(ll_inode_lu_fid(inode), &file_res_id);
 
                 down(&lli->lli_och_sem);
                 if (fd->fd_omode & FMODE_WRITE) {
@@ -281,7 +285,7 @@ static int ll_intent_file_open(struct file *file, void *lmm,
                                int lmmsize, struct lookup_intent *itp)
 {
         struct ll_sb_info *sbi = ll_i2sbi(file->f_dentry->d_inode);
-        struct mdc_op_data data;
+        struct mdc_op_data data = { { 0 } };
         struct dentry *parent = file->f_dentry->d_parent;
         const char *name = file->f_dentry->d_name.name;
         const int len = file->f_dentry->d_name.len;
@@ -522,7 +526,9 @@ restart:
                            would attempt to grab och_sem as well, that would
                            result in a deadlock */
                         up(&lli->lli_och_sem);
+                        it->it_create_mode |= M_CHECK_STALE;
                         rc = ll_intent_file_open(file, NULL, 0, it);
+                        it->it_create_mode &= ~M_CHECK_STALE;
                         if (rc) {
                                 ll_file_data_put(fd);
                                 GOTO(out_openerr, rc);
@@ -611,10 +617,11 @@ int ll_lsm_getattr(struct obd_export *exp, struct lov_stripe_md *lsm,
         oinfo.oi_md = lsm;
         oinfo.oi_oa = oa;
         oa->o_id = lsm->lsm_object_id;
+        oa->o_gr = lsm->lsm_object_gr;
         oa->o_mode = S_IFREG;
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLSIZE |
                 OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
-                OBD_MD_FLCTIME;
+                OBD_MD_FLCTIME | OBD_MD_FLGROUP;
 
         set = ptlrpc_prep_set();
         if (set == NULL) {
@@ -643,6 +650,7 @@ static int ll_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock)
                 struct ldlm_lock *lock;
         } key = { .name = KEY_LOCK_TO_STRIPE, .lock = lock };
         __u32 stripe, vallen = sizeof(stripe);
+        struct lov_oinfo *loinfo;
         int rc;
         ENTRY;
 
@@ -658,11 +666,11 @@ static int ll_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock)
         LASSERT(stripe < lsm->lsm_stripe_count);
 
 check:
-        if (lsm->lsm_oinfo[stripe]->loi_id != lock->l_resource->lr_name.name[0]||
-            lsm->lsm_oinfo[stripe]->loi_gr != lock->l_resource->lr_name.name[1]){
+        loinfo = lsm->lsm_oinfo[stripe];
+        if (!osc_res_name_eq(loinfo->loi_id, loinfo->loi_gr,
+                            &lock->l_resource->lr_name)) {
                 LDLM_ERROR(lock, "resource doesn't match object "LPU64"/"LPU64,
-                           lsm->lsm_oinfo[stripe]->loi_id,
-                           lsm->lsm_oinfo[stripe]->loi_gr);
+                           loinfo->loi_id, loinfo->loi_gr);
                 RETURN(-ELDLM_NO_LOCK_DATA);
         }
 
@@ -887,8 +895,8 @@ static int ll_glimpse_callback(struct ldlm_lock *lock, void *reqp)
 
         LDLM_DEBUG(lock, "i_size: %llu -> stripe number %u -> kms "LPU64
                    " atime "LPU64", mtime "LPU64", ctime "LPU64,
-                   i_size_read(inode), stripe, lvb->lvb_size, lvb->lvb_mtime,
-                   lvb->lvb_atime, lvb->lvb_ctime);
+                   i_size_read(inode), stripe, lvb->lvb_size, lvb->lvb_atime,
+                   lvb->lvb_mtime, lvb->lvb_ctime);
  iput:
         iput(inode);
 
@@ -996,6 +1004,11 @@ int ll_glimpse_size(struct inode *inode, int ast_flags)
 
         ll_inode_size_lock(inode, 1);
         inode_init_lvb(inode, &lvb);
+        /* merge timestamps the most resently obtained from mds with
+           timestamps obtained from osts */
+        lvb.lvb_atime = lli->lli_lvb.lvb_atime;
+        lvb.lvb_mtime = lli->lli_lvb.lvb_mtime;
+        lvb.lvb_ctime = lli->lli_lvb.lvb_ctime;
         rc = obd_merge_lvb(sbi->ll_osc_exp, lli->lli_smd, &lvb, 0);
         i_size_write(inode, lvb.lvb_size);
         inode->i_blocks = lvb.lvb_blocks;
@@ -1134,6 +1147,14 @@ static int ll_is_file_contended(struct file *file)
         }
         if (fd && (fd->fd_flags & LL_FILE_IGNORE_LOCK))
                 RETURN(0);
+
+#if 0
+        /* disabled for now, see bug 20219 */
+        /* server-side locking for dio */
+        if (file->f_flags & O_DIRECT)
+                RETURN(1);
+#endif
+
         if (test_bit(LLI_F_CONTENDED, &lli->lli_flags)) {
                 cfs_time_t cur_time = cfs_time_current();
                 cfs_time_t retry_time;
@@ -1153,12 +1174,13 @@ static int ll_is_file_contended(struct file *file)
 static int ll_file_get_tree_lock_iov(struct ll_lock_tree *tree,
                                      struct file *file, const struct iovec *iov,
                                      unsigned long nr_segs,
-                                     loff_t start, loff_t end, int rw)
+                                     obd_off start, obd_off end, int rw)
 {
         int append;
         int tree_locked = 0;
         int rc;
         struct inode * inode = file->f_dentry->d_inode;
+        ENTRY;
 
         append = (rw == OBD_BRW_WRITE) && (file->f_flags & O_APPEND);
 
@@ -1455,11 +1477,10 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
         }
 
 repeat:
-        if (sbi->ll_max_rw_chunk != 0) {
+        if (sbi->ll_max_rw_chunk != 0 && !(file->f_flags & O_DIRECT)) {
                 /* first, let's know the end of the current stripe */
                 end = *ppos;
-                obd_extent_calc(sbi->ll_osc_exp, lsm, OBD_CALC_STRIPE_END,
-                                (obd_off *)&end);
+                obd_extent_calc(sbi->ll_osc_exp, lsm, OBD_CALC_STRIPE_END,&end);
 
                 /* correct, the end is beyond the request */
                 if (end > *ppos + count - 1)
@@ -1493,9 +1514,13 @@ repeat:
                 nrsegs_copy = nr_segs;
         }
 
+        down_read(&lli->lli_truncate_rwsem); /* Bug 18233 */
+
         lock_style = ll_file_get_lock(file, (obd_off)(*ppos), end,
                                       iov_copy, nrsegs_copy, &cookie, &tree,
                                       OBD_BRW_READ);
+        if (lock_style < 0 || lock_style == LL_LOCK_STYLE_NOLOCK)
+                up_read(&lli->lli_truncate_rwsem);
         if (lock_style < 0)
                 GOTO(out, retval = lock_style);
 
@@ -1528,24 +1553,28 @@ repeat:
                 ll_inode_size_unlock(inode, 1);
                 retval = ll_glimpse_size(inode, LDLM_FL_BLOCK_GRANTED);
                 if (retval) {
-                        if (lock_style != LL_LOCK_STYLE_NOLOCK)
+                        if (lock_style != LL_LOCK_STYLE_NOLOCK) {
                                 ll_file_put_lock(inode, end, lock_style,
                                                  cookie, &tree, OBD_BRW_READ);
+                                up_read(&lli->lli_truncate_rwsem);
+                        }
                         goto out;
                 } else {
                         /* If objective page index exceed the end-of-file page
                          * index, return directly. Do not expect kernel will
                          * check such case correctly. linux-2.6.18-128.1.1 miss
                          * to do that. --bug 17336 */
-                        loff_t size = i_size_read(inode);
+                        size_t size = i_size_read(inode);
                         unsigned long cur_index = *ppos >> CFS_PAGE_SHIFT;
 
                         if ((size == 0 && cur_index != 0) ||
                             (((size - 1) >> CFS_PAGE_SHIFT) < cur_index)) {
-                                if (lock_style != LL_LOCK_STYLE_NOLOCK)
+                                if (lock_style != LL_LOCK_STYLE_NOLOCK) {
                                         ll_file_put_lock(inode, end, lock_style,
                                                          cookie, &tree,
                                                          OBD_BRW_READ);
+                                        up_read(&lli->lli_truncate_rwsem);
+                                }
                                 goto out;
                         }
                 }
@@ -1567,13 +1596,27 @@ repeat:
 
         /* turn off the kernel's read-ahead */
         if (lock_style != LL_LOCK_STYLE_NOLOCK) {
+                /* read under locks
+                 *
+                 * 1. update inode's atime as long as concurrent stat
+                 * (via ll_glimpse_size) might bring out-of-date ones
+                 *
+                 * 2. update lsm so that next stat (via
+                 * ll_glimpse_size) could get correct values in lsm */
+                struct ost_lvb xtimes;
+
+                lov_stripe_lock(lsm);
+                LTIME_S(inode->i_atime) = LTIME_S(CURRENT_TIME);
+                xtimes.lvb_atime = LTIME_S(inode->i_atime);
+                obd_update_lvb(sbi->ll_osc_exp, lsm, &xtimes,
+                               OBD_MD_FLATIME);
+                lov_stripe_unlock(lsm);
+
                 file->f_ra.ra_pages = 0;
                 /* initialize read-ahead window once per syscall */
                 if (ra == 0) {
                         ra = 1;
-                        bead.lrr_start = *ppos >> CFS_PAGE_SHIFT;
-                        bead.lrr_count = (count + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
-                        ll_ra_read_in(file, &bead);
+                        ll_ra_read_init(file, &bead, *ppos, count);
                 }
 
                 /* BUG: 5972 */
@@ -1586,7 +1629,13 @@ repeat:
 #endif
                 ll_file_put_lock(inode, end, lock_style, cookie,
                                  &tree, OBD_BRW_READ);
+                up_read(&lli->lli_truncate_rwsem);
         } else {
+                /* lockless read
+                 *
+                 * current time will get into request as atime
+                 * (lustre/osc/osc_request.c:osc_build_request())
+                 */
                 retval = ll_file_lockless_io(file, iov_copy, nrsegs_copy, ppos,
                                              READ, chunk);
         }
@@ -1676,7 +1725,9 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 
         LASSERT(ll_i2info(inode)->lli_smd != NULL);
 
-        down(&ll_i2info(inode)->lli_write_sem);
+        /* signal(7) specifies that write(2) and writev(2) should be restarted */
+        if (down_interruptible(&ll_i2info(inode)->lli_write_sem))
+                RETURN(-ERESTARTSYS);
 
 repeat:
         chunk = 0; /* just to fix gcc's warning */
@@ -1754,16 +1805,41 @@ repeat:
         chunk = end - *ppos + 1;
         CDEBUG(D_INFO, "Writing inode %lu, "LPSZ" bytes, offset %Lu\n",
                inode->i_ino, chunk, *ppos);
-        if (tree_locked)
+        if (tree_locked) {
+                /* write under locks
+                 *
+                 * 1. update inode's mtime and ctime as long as
+                 * concurrent stat (via ll_glimpse_size) might bring
+                 * out-of-date ones
+                 *
+                 * 2. update lsm so that next stat (via
+                 * ll_glimpse_size) could get correct values in lsm */
+                struct ost_lvb xtimes;
+
+                lov_stripe_lock(lsm);
+                LTIME_S(inode->i_mtime) = LTIME_S(CURRENT_TIME);
+                LTIME_S(inode->i_ctime) = LTIME_S(CURRENT_TIME);
+                xtimes.lvb_mtime = LTIME_S(inode->i_mtime);
+                xtimes.lvb_ctime = LTIME_S(inode->i_ctime);
+                obd_update_lvb(sbi->ll_osc_exp, lsm, &xtimes,
+                               OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+                lov_stripe_unlock(lsm);
+
 #ifdef HAVE_FILE_WRITEV
                 retval = generic_file_writev(file, iov_copy, nrsegs_copy, ppos);
 #else
                 retval = generic_file_aio_write(iocb, iov_copy, nrsegs_copy,
                                                 *ppos);
 #endif
-        else
+        } else {
+                /* lockless write
+                 *
+                 * current time will get into request as mtime and
+                 * ctime (lustre/osc/osc_request.c:osc_build_request())
+                 */
                 retval = ll_file_lockless_io(file, iov_copy, nrsegs_copy,
                                              ppos, WRITE, chunk);
+        }
         ll_rw_stats_tally(ll_i2sbi(inode), current->pid, file, chunk, 1);
 
 out_unlock:
@@ -1812,11 +1888,12 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count,
 #endif
 }
 
+#ifdef HAVE_KERNEL_SENDFILE
 /*
  * Send file content (through pagecache) somewhere with helper
  */
-static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count,
-                                read_actor_t actor, void *target)
+static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,
+                                size_t count, read_actor_t actor, void *target)
 {
         struct inode *inode = in_file->f_dentry->d_inode;
         struct ll_inode_info *lli = ll_i2info(inode);
@@ -1825,10 +1902,10 @@ static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count,
         struct ll_lock_tree_node *node;
         struct ost_lvb lvb;
         struct ll_ra_read bead;
-        int rc;
-        ssize_t retval;
+        ssize_t rc;
         __u64 kms;
         ENTRY;
+
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),size="LPSZ",offset=%Ld\n",
                inode->i_ino, inode->i_generation, inode, count, *ppos);
 
@@ -1842,8 +1919,10 @@ static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count,
         in_file->f_ra.ra_pages = 0;
 
         /* File with no objects, nothing to lock */
-        if (!lsm)
-                RETURN(generic_file_sendfile(in_file, ppos, count, actor, target));
+        if (!lsm) {
+                rc = generic_file_sendfile(in_file, ppos, count, actor, target);
+                RETURN(rc);
+        }
 
         node = ll_node_from_inode(inode, *ppos, *ppos + count - 1, LCK_PR);
         if (IS_ERR(node))
@@ -1883,8 +1962,8 @@ static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count,
                 /* A glimpse is necessary to determine whether we return a
                  * short read (B) or some zeroes at the end of the buffer (C) */
                 ll_inode_size_unlock(inode, 1);
-                retval = ll_glimpse_size(inode, LDLM_FL_BLOCK_GRANTED);
-                if (retval)
+                rc = ll_glimpse_size(inode, LDLM_FL_BLOCK_GRANTED);
+                if (rc)
                         goto out;
         } else {
                 /* region is within kms and, hence, within real file size (A) */
@@ -1895,18 +1974,116 @@ static ssize_t ll_file_sendfile(struct file *in_file, loff_t *ppos,size_t count,
         CDEBUG(D_INFO, "Send ino %lu, "LPSZ" bytes, offset %lld, i_size %llu\n",
                inode->i_ino, count, *ppos, i_size_read(inode));
 
-        bead.lrr_start = *ppos >> CFS_PAGE_SHIFT;
-        bead.lrr_count = (count + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
-        ll_ra_read_in(in_file, &bead);
+        ll_ra_read_init(in_file, &bead, *ppos, count);
         /* BUG: 5972 */
         file_accessed(in_file);
-        retval = generic_file_sendfile(in_file, ppos, count, actor, target);
+        rc = generic_file_sendfile(in_file, ppos, count, actor, target);
         ll_ra_read_ex(in_file, &bead);
 
  out:
         ll_tree_unlock(&tree);
-        RETURN(retval);
+        RETURN(rc);
+}
+#endif
+
+/* change based on 
+ * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f0930fffa99e7fe0a0c4b6c7d9a244dc88288c27
+ */
+#ifdef HAVE_KERNEL_SPLICE_READ
+static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos,
+                                   struct pipe_inode_info *pipe, size_t count,
+                                   unsigned int flags)
+{
+        struct inode *inode = in_file->f_dentry->d_inode;
+        struct ll_inode_info *lli = ll_i2info(inode);
+        struct lov_stripe_md *lsm = lli->lli_smd;
+        struct ll_lock_tree tree;
+        struct ll_lock_tree_node *node;
+        struct ost_lvb lvb;
+        struct ll_ra_read bead;
+        ssize_t rc;
+        __u64 kms;
+        ENTRY;
+
+        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),size="LPSZ",offset=%Ld\n",
+               inode->i_ino, inode->i_generation, inode, count, *ppos);
+
+        /* "If nbyte is 0, read() will return 0 and have no other results."
+         *                      -- Single Unix Spec */
+        if (count == 0)
+                RETURN(0);
+
+        ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_READ_BYTES, count);
+        /* turn off the kernel's read-ahead */
+        in_file->f_ra.ra_pages = 0;
+
+        /* File with no objects, nothing to lock */
+        if (!lsm) {
+                rc = generic_file_splice_read(in_file, ppos, pipe, count, flags);
+                RETURN(rc);
+        }
+
+        node = ll_node_from_inode(inode, *ppos, *ppos + count - 1, LCK_PR);
+        if (IS_ERR(node))
+                RETURN(PTR_ERR(node));
+
+        tree.lt_fd = LUSTRE_FPRIVATE(in_file);
+        rc = ll_tree_lock(&tree, node, NULL, count,
+                          in_file->f_flags & O_NONBLOCK?LDLM_FL_BLOCK_NOWAIT:0);
+        if (rc != 0)
+                RETURN(rc);
+
+        ll_clear_file_contended(inode);
+        ll_inode_size_lock(inode, 1);
+        /*
+         * Consistency guarantees: following possibilities exist for the
+         * relation between region being read and real file size at this
+         * moment:
+         *
+         *  (A): the region is completely inside of the file;
+         *
+         *  (B-x): x bytes of region are inside of the file, the rest is
+         *  outside;
+         *
+         *  (C): the region is completely outside of the file.
+         *
+         * This classification is stable under DLM lock acquired by
+         * ll_tree_lock() above, because to change class, other client has to
+         * take DLM lock conflicting with our lock. Also, any updates to
+         * ->i_size by other threads on this client are serialized by
+         * ll_inode_size_lock(). This guarantees that short reads are handled
+         * correctly in the face of concurrent writes and truncates.
+         */
+        inode_init_lvb(inode, &lvb);
+        obd_merge_lvb(ll_i2sbi(inode)->ll_osc_exp, lsm, &lvb, 1);
+        kms = lvb.lvb_size;
+        if (*ppos + count - 1 > kms) {
+                /* A glimpse is necessary to determine whether we return a
+                 * short read (B) or some zeroes at the end of the buffer (C) */
+                ll_inode_size_unlock(inode, 1);
+                rc = ll_glimpse_size(inode, LDLM_FL_BLOCK_GRANTED);
+                if (rc)
+                        goto out;
+        } else {
+                /* region is within kms and, hence, within real file size (A) */
+                i_size_write(inode, kms);
+                ll_inode_size_unlock(inode, 1);
+        }
+
+        CDEBUG(D_INFO, "Send ino %lu, "LPSZ" bytes, offset %lld, i_size %llu\n",
+               inode->i_ino, count, *ppos, i_size_read(inode));
+
+        ll_ra_read_init(in_file, &bead, *ppos, count);
+        /* BUG: 5972 */
+        file_accessed(in_file);
+        rc = generic_file_splice_read(in_file, ppos, pipe, count, flags);
+        ll_ra_read_ex(in_file, &bead);
+
+ out:
+        ll_tree_unlock(&tree);
+        RETURN(rc);
 }
+#endif
 
 static int ll_lov_recreate_obj(struct inode *inode, struct file *file,
                                unsigned long arg)
@@ -2046,8 +2223,9 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
         LASSERT(lmm != NULL);
         LASSERT(lustre_rep_swabbed(req, REPLY_REC_OFF + 1));
 
-        if ((lmm->lmm_magic != cpu_to_le32(LOV_MAGIC)) &&
-             (lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_JOIN))) {
+        if ((lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_V1)) &&
+            (lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_V3)) &&
+            (lmm->lmm_magic != cpu_to_le32(LOV_MAGIC_JOIN))) {
                 GOTO(out, rc = -EPROTO);
         }
         /*
@@ -2056,12 +2234,14 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
          * passing it to userspace.
          */
         if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) {
-                if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC)) {
-                        lustre_swab_lov_user_md((struct lov_user_md *)lmm);
-                        /* if function called for directory - we should be
-                         * avoid swab not existent lsm objects */
+                /* if function called for directory - we should
+                 * avoid swab not existent lsm objects */
+                if ((lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) ||
+                    (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V3))) {
+                        lustre_swab_lov_user_md((struct lov_user_md*)lmm);
                         if (S_ISREG(body->mode))
-                                lustre_swab_lov_user_md_objects((struct lov_user_md *)lmm);
+                                lustre_swab_lov_user_md_objects(
+                                                (struct lov_user_md*)lmm);
                 } else if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_JOIN)) {
                         lustre_swab_lov_user_md_join((struct lov_user_md_join *)lmm);
                 }
@@ -2156,23 +2336,34 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
 static int ll_lov_setstripe(struct inode *inode, struct file *file,
                             unsigned long arg)
 {
-        struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
+        struct lov_user_md_v3 lumv3;
+        struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3;
+        struct lov_user_md_v1 *lumv1p = (struct lov_user_md_v1 *)arg;
+        struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg;
+        int lum_size;
         int rc;
         int flags = FMODE_WRITE;
         ENTRY;
 
-        /* Bug 1152: copy properly when this is no longer true */
-        LASSERT(sizeof(lum) == sizeof(*lump));
-        LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lump->lmm_objects[0]));
-        rc = copy_from_user(&lum, lump, sizeof(lum));
+        /* first try with v1 which is smaller than v3 */
+        lum_size = sizeof(struct lov_user_md_v1);
+        rc = copy_from_user(lumv1, lumv1p, lum_size);
         if (rc)
                 RETURN(-EFAULT);
 
-        rc = ll_lov_setstripe_ea_info(inode, file, flags, &lum, sizeof(lum));
+        if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) {
+                lum_size = sizeof(struct lov_user_md_v3);
+                rc = copy_from_user(&lumv3, lumv3p, lum_size);
+                if (rc)
+                        RETURN(-EFAULT);
+        }
+
+        rc = ll_lov_setstripe_ea_info(inode, file, flags, lumv1, lum_size);
         if (rc == 0) {
-                 put_user(0, &lump->lmm_stripe_count);
+                 put_user(0, &lumv1p->lmm_stripe_count);
                  rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2obdexp(inode),
-                                    0, ll_i2info(inode)->lli_smd, lump);
+                                    0, ll_i2info(inode)->lli_smd,
+                                    (void *)arg);
         }
         RETURN(rc);
 }
@@ -2277,7 +2468,8 @@ static int join_file(struct inode *head_inode, struct file *head_filp,
 {
         struct dentry *tail_dentry = tail_filp->f_dentry;
         struct lookup_intent oit = {.it_op = IT_OPEN,
-                                   .it_flags = head_filp->f_flags|O_JOIN_FILE};
+                                    .it_flags = head_filp->f_flags,
+                                    .it_create_mode = M_JOIN_FILE};
         struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_PW,
                 ll_mdc_blocking_ast, ldlm_completion_ast, NULL, NULL };
 
@@ -2337,7 +2529,7 @@ static int ll_file_join(struct inode *head, struct file *filp,
         struct file *tail_filp, *first_filp, *second_filp;
         struct ll_lock_tree first_tree, second_tree;
         struct ll_lock_tree_node *first_node, *second_node;
-        struct ll_inode_info *hlli = ll_i2info(head), *tlli;
+        struct ll_inode_info *hlli = ll_i2info(head);
         int rc = 0, cleanup_phase = 0;
         ENTRY;
 
@@ -2352,7 +2544,6 @@ static int ll_file_join(struct inode *head, struct file *filp,
         }
         tail = igrab(tail_filp->f_dentry->d_inode);
 
-        tlli = ll_i2info(tail);
         tail_dentry = tail_filp->f_dentry;
         LASSERT(tail_dentry);
         cleanup_phase = 1;
@@ -2554,7 +2745,7 @@ int ll_file_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                 RETURN(ll_lov_getstripe(inode, arg));
         case LL_IOC_RECREATE_OBJ:
                 RETURN(ll_lov_recreate_obj(inode, file, arg));
-        case EXT3_IOC_FIEMAP: {
+        case FSFILT_IOC_FIEMAP: {
                 struct ll_user_fiemap *fiemap_s;
                 size_t num_bytes, ret_bytes;
                 unsigned int extent_count;
@@ -2620,11 +2811,11 @@ error:
                 OBD_VFREE(fiemap_s, num_bytes);
                 RETURN(rc);
         }
-        case EXT3_IOC_GETFLAGS:
-        case EXT3_IOC_SETFLAGS:
+        case FSFILT_IOC_GETFLAGS:
+        case FSFILT_IOC_SETFLAGS:
                 RETURN(ll_iocontrol(inode, file, cmd, arg));
-        case EXT3_IOC_GETVERSION_OLD:
-        case EXT3_IOC_GETVERSION:
+        case FSFILT_IOC_GETVERSION_OLD:
+        case FSFILT_IOC_GETVERSION:
                 RETURN(put_user(inode->i_generation, (int *)arg));
         case LL_IOC_JOIN: {
 #if LUSTRE_FIX >= 50
@@ -2762,22 +2953,29 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
                 ptlrpc_req_finished(req);
 
         if (data && lsm) {
-                struct obdo *oa;
+                struct obd_info *oinfo;
 
-                OBDO_ALLOC(oa);
-                if (!oa)
+                OBD_ALLOC_PTR(oinfo);
+                if (!oinfo)
                         RETURN(rc ? rc : -ENOMEM);
-
-                oa->o_id = lsm->lsm_object_id;
-                oa->o_valid = OBD_MD_FLID;
-                obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
-                                           OBD_MD_FLMTIME | OBD_MD_FLCTIME);
-
-                err = obd_sync(ll_i2sbi(inode)->ll_osc_exp, oa, lsm,
-                               0, OBD_OBJECT_EOF);
+                OBDO_ALLOC(oinfo->oi_oa);
+                if (!oinfo->oi_oa) {
+                        OBD_FREE_PTR(oinfo);
+                        RETURN(rc ? rc : -ENOMEM);
+                }
+                oinfo->oi_oa->o_id = lsm->lsm_object_id;
+                oinfo->oi_oa->o_gr = lsm->lsm_object_gr;
+                oinfo->oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+                obdo_from_inode(oinfo->oi_oa, inode,
+                                OBD_MD_FLTYPE | OBD_MD_FLATIME |
+                                OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+                oinfo->oi_md = lsm;
+                err = obd_sync_rqset(ll_i2sbi(inode)->ll_osc_exp, oinfo,
+                                     0, OBD_OBJECT_EOF);
                 if (!rc)
                         rc = err;
-                OBDO_FREE(oa);
+                OBDO_FREE(oinfo->oi_oa);
+                OBD_FREE_PTR(oinfo);
         }
 
         RETURN(rc);
@@ -2787,8 +2985,12 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
 {
         struct inode *inode = file->f_dentry->d_inode;
         struct ll_sb_info *sbi = ll_i2sbi(inode);
+        struct lu_fid *fid = ll_inode_lu_fid(inode);
         struct ldlm_res_id res_id =
-                    { .name = {inode->i_ino, inode->i_generation, LDLM_FLOCK} };
+                    { .name = { fid_seq(fid),
+                                fid_oid(fid),
+                                fid_ver(fid),
+                                LDLM_FLOCK} };
         struct ldlm_enqueue_info einfo = { LDLM_FLOCK, 0, NULL,
                 ldlm_flock_completion_ast, NULL, file_lock };
         struct lustre_handle lockh = {0};
@@ -2801,6 +3003,15 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
                inode->i_ino, file_lock);
         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FLOCK, 1);
 
+        if (fid_is_igif(fid)) {
+                /* If this is an IGIF inode, we need to keep the 1.6-style
+                 * flock mapping for compatibility.  If it is a proper FID
+                 * then we know any other client accessing it must also be
+                 * accessing it as a FID and can use the CMD-style flock. */
+                res_id.name[2] = LDLM_FLOCK;
+                res_id.name[3] = 0;
+        }
+
         if (file_lock->fl_flags & FL_FLOCK) {
                 LASSERT((cmd == F_SETLKW) || (cmd == F_SETLK));
                 /* set missing params for flock() calls */
@@ -2890,7 +3101,7 @@ int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
 int ll_have_md_lock(struct inode *inode, __u64 bits)
 {
         struct lustre_handle lockh;
-        struct ldlm_res_id res_id = { .name = {0} };
+        struct ldlm_res_id res_id;
         struct obd_device *obddev;
         ldlm_policy_data_t policy = { .l_inodebits = {bits}};
         int flags;
@@ -2900,10 +3111,12 @@ int ll_have_md_lock(struct inode *inode, __u64 bits)
                RETURN(0);
 
         obddev = ll_i2mdcexp(inode)->exp_obd;
-        res_id.name[0] = inode->i_ino;
-        res_id.name[1] = inode->i_generation;
+        fid_build_reg_res_name(ll_inode_lu_fid(inode), &res_id);
 
-        CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id.name[0]);
+        CDEBUG(D_INFO, "trying to match res "LPU64":"LPU64":"LPU64"\n",
+                res_id.name[0],
+                res_id.name[1],
+                res_id.name[2]);
 
         flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK;
         if (ldlm_lock_match(obddev->obd_namespace, flags, &res_id, LDLM_IBITS,
@@ -2954,16 +3167,18 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it)
 
         if (exp->exp_connect_flags & OBD_CONNECT_ATTRFID) {
                 struct lookup_intent oit = { .it_op = IT_GETATTR };
-                struct mdc_op_data op_data;
+                struct mdc_op_data op_data = { { 0 } };
 
                 /* Call getattr by fid, so do not provide name at all. */
                 ll_prepare_mdc_op_data(&op_data, dentry->d_parent->d_inode,
                                        dentry->d_inode, NULL, 0, 0, NULL);
+                oit.it_create_mode |= M_CHECK_STALE;
                 rc = mdc_intent_lock(exp, &op_data, NULL, 0,
                                      /* we are not interested in name
                                         based lookup */
                                      &oit, 0, &req,
                                      ll_mdc_blocking_ast, 0);
+                oit.it_create_mode &= ~M_CHECK_STALE;
                 if (rc < 0) {
                         rc = ll_inode_revalidate_fini(inode, rc);
                         GOTO (out, rc);
@@ -3015,8 +3230,12 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it)
         }
 
         /* if object not yet allocated, don't validate size */
-        if (ll_i2info(inode)->lli_smd == NULL)
+        if (ll_i2info(inode)->lli_smd == NULL) {
+                LTIME_S(inode->i_atime) = ll_i2info(inode)->lli_lvb.lvb_atime;
+                LTIME_S(inode->i_mtime) = ll_i2info(inode)->lli_lvb.lvb_mtime;
+                LTIME_S(inode->i_ctime) = ll_i2info(inode)->lli_lvb.lvb_ctime;
                 GOTO(out, rc = 0);
+        }
 
         /* ll_glimpse_size will prefer locally cached writes if they extend
          * the file */
@@ -3095,7 +3314,11 @@ int lustre_check_acl(struct inode *inode, int mask)
 }
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
+#ifndef HAVE_INODE_PERMISION_2ARGS
 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
+#else
+int ll_inode_permission(struct inode *inode, int mask)
+#endif
 {
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), mask %o\n",
                inode->i_ino, inode->i_generation, inode, mask);
@@ -3104,7 +3327,7 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
         return generic_permission(inode, mask, lustre_check_acl);
 }
 #else
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+#ifndef HAVE_INODE_PERMISION_2ARGS
 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
 #else
 int ll_inode_permission(struct inode *inode, int mask)
@@ -3174,7 +3397,12 @@ struct file_operations ll_file_operations = {
         .release        = ll_file_release,
         .mmap           = ll_file_mmap,
         .llseek         = ll_file_seek,
+#ifdef HAVE_KERNEL_SPLICE_READ
+        .splice_read    = ll_file_splice_read,
+#endif
+#ifdef HAVE_KERNEL_SENDFILE
         .sendfile       = ll_file_sendfile,
+#endif
         .fsync          = ll_fsync,
 };
 
@@ -3196,7 +3424,12 @@ struct file_operations ll_file_operations_flock = {
         .release        = ll_file_release,
         .mmap           = ll_file_mmap,
         .llseek         = ll_file_seek,
+#ifdef HAVE_KERNEL_SPLICE_READ
+        .splice_read    = ll_file_splice_read,
+#endif
+#ifdef HAVE_KERNEL_SENDFILE
         .sendfile       = ll_file_sendfile,
+#endif
         .fsync          = ll_fsync,
 #ifdef HAVE_F_OP_FLOCK
         .flock          = ll_file_flock,
@@ -3223,7 +3456,12 @@ struct file_operations ll_file_operations_noflock = {
         .release        = ll_file_release,
         .mmap           = ll_file_mmap,
         .llseek         = ll_file_seek,
+#ifdef HAVE_KERNEL_SPLICE_READ
+        .splice_read    = ll_file_splice_read,
+#endif
+#ifdef HAVE_KERNEL_SENDFILE
         .sendfile       = ll_file_sendfile,
+#endif
         .fsync          = ll_fsync,
 #ifdef HAVE_F_OP_FLOCK
         .flock          = ll_file_noflock,
diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c
index f8a96d4..27ce889 100644
--- a/lustre/llite/llite_close.c
+++ b/lustre/llite/llite_close.c
@@ -138,7 +138,8 @@ static void ll_close_done_writing(struct inode *inode)
         struct ll_inode_info *lli = ll_i2info(inode);
         ldlm_policy_data_t policy = { .l_extent = {0, OBD_OBJECT_EOF } };
         struct lustre_handle lockh = { 0 };
-        struct obdo obdo;
+        struct obdo obdo = { 0 };
+        struct mdc_op_data data = { { 0 } };
         obd_flag valid;
         int rc, ast_flags = 0;
         ENTRY;
@@ -183,7 +184,8 @@ static void ll_close_done_writing(struct inode *inode)
         obdo.o_blocks = inode->i_blocks;
         obdo.o_valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
 
-        rc = mdc_done_writing(ll_i2sbi(inode)->ll_mdc_exp, &obdo);
+        ll_inode2fid(&data.fid1, inode);
+        rc = mdc_done_writing(ll_i2sbi(inode)->ll_mdc_exp, &data, &obdo);
  out:
 }
 
diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h
index 43dac19..5631066 100644
--- a/lustre/llite/llite_internal.h
+++ b/lustre/llite/llite_internal.h
@@ -56,7 +56,7 @@
 typedef __u16 __le16;
 typedef __u32 __le32;
 #endif
- 
+
 /*
 struct lustre_intent_data {
         __u64 it_lock_handle[2];
@@ -89,15 +89,15 @@ static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
 
 struct ll_dir_entry {
         /* number of inode, referenced by this entry */
-	__le32	lde_inode;
+        __le32  lde_inode;
         /* total record length, multiple of LL_DIR_PAD */
-	__le16	lde_rec_len;
+        __le16  lde_rec_len;
         /* length of name */
-	__u8	lde_name_len;
+        __u8    lde_name_len;
         /* file type: regular, directory, device, etc. */
-	__u8	lde_file_type;
+        __u8    lde_file_type;
         /* name. NOT NUL-terminated */
-	char	lde_name[LL_DIR_NAME_LEN];
+        char    lde_name[LL_DIR_NAME_LEN];
 };
 
 struct ll_dentry_data {
@@ -160,7 +160,12 @@ struct ll_inode_info {
         __u64                   lli_open_fd_write_count;
         struct obd_client_handle *lli_mds_exec_och;
         __u64                   lli_open_fd_exec_count;
-        struct inode            lli_vfs_inode;
+
+        /** fid of this object. */
+        union {
+                struct lu_fid f20;
+                struct ll_fid f16;
+        } lli_fid;
 
         /* metadata stat-ahead */
         /*
@@ -168,12 +173,17 @@ struct ll_inode_info {
          * dir statahead.
          */
         pid_t                   lli_opendir_pid;
-        /* 
+        /*
          * since parent-child threads can share the same @file struct,
          * "opendir_key" is the token when dir close for case of parent exit
          * before child -- it is me should cleanup the dir readahead. */
         void                   *lli_opendir_key;
         struct ll_statahead_info *lli_sai;
+        struct rw_semaphore     lli_truncate_rwsem;
+        /* the most recent attributes from mds, it is used for timestampts
+         * only so far */
+        struct ost_lvb         lli_lvb;
+        struct inode            lli_vfs_inode;
 };
 
 /*
@@ -217,11 +227,27 @@ enum ra_stat {
         _NR_RA_STAT,
 };
 
+#define LL_RA_STAT      _NR_RA_STAT
+#define LL_RA_STAT_STRINGS           {                                  \
+        [RA_STAT_HIT]               = "hits",                           \
+        [RA_STAT_MISS]              = "misses",                         \
+        [RA_STAT_DISTANT_READPAGE]  = "readpage not consecutive",       \
+        [RA_STAT_MISS_IN_WINDOW]    = "miss inside window",             \
+        [RA_STAT_FAILED_GRAB_PAGE]  = "failed grab_cache_page",         \
+        [RA_STAT_FAILED_MATCH]      = "failed lock match",              \
+        [RA_STAT_DISCARDED]         = "read but discarded",             \
+        [RA_STAT_ZERO_LEN]          = "zero length file",               \
+        [RA_STAT_ZERO_WINDOW]       = "zero size window",               \
+        [RA_STAT_EOF]               = "read-ahead to EOF",              \
+        [RA_STAT_MAX_IN_FLIGHT]     = "hit max r-a issue",              \
+        [RA_STAT_WRONG_GRAB_PAGE]   = "wrong page from grab_cache_page",\
+}
+
 struct ll_ra_info {
-        unsigned long             ra_cur_pages;
+        atomic_t                  ra_cur_pages;
         unsigned long             ra_max_pages;
+        unsigned long             ra_max_pages_per_file;
         unsigned long             ra_max_read_ahead_whole_pages;
-        unsigned long             ra_stats[_NR_RA_STAT];
 };
 
 /* LL_HIST_MAX=32 causes an overflow */
@@ -271,16 +297,37 @@ enum stats_track_type {
 #define LL_SBI_LOCALFLOCK       0x40 /* Local flocks support by kernel */
 #define LL_SBI_LRU_RESIZE       0x80 /* support lru resize */
 #define LL_SBI_LLITE_CHECKSUM  0x100 /* checksum each page in memory */
+#define LL_SBI_LAZYSTATFS      0x200 /* lazystatfs mount option */
 
 /* default value for ll_sb_info->contention_time */
 #define SBI_DEFAULT_CONTENTION_SECONDS     60
 /* default value for lockless_truncate_enable */
 #define SBI_DEFAULT_LOCKLESS_TRUNCATE_ENABLE 1
 
+/* percpu data structure for lustre lru page list */
+struct ll_pglist_data {
+        spinlock_t                llpd_lock; /* lock to protect llpg_list */
+        struct list_head          llpd_list; /* all pages (llap_pglist_item) */
+        unsigned long             llpd_gen;  /* generation # of this list */
+        unsigned long             llpd_count; /* How many pages in this list */
+        atomic_t                  llpd_sample_count;
+        unsigned long             llpd_reblnc_count;
+        /* the pages in this list shouldn't be over this number */
+        unsigned long             llpd_budget;
+        int                       llpd_cpu;
+        /* which page the pglist data is in */
+        struct page              *llpd_page;
+
+        /* stats */
+        unsigned long             llpd_hit;
+        unsigned long             llpd_miss;
+        unsigned long             llpd_cross;
+};
+
 struct ll_sb_info {
         struct list_head          ll_list;
-        /* this protects pglist and ra_info.  It isn't safe to
-         * grab from interrupt contexts */
+        /* this protects pglist(only ll_async_page_max) and ra_info.
+         * It isn't safe to grab from interrupt contexts. */
         spinlock_t                ll_lock;
         spinlock_t                ll_pp_extent_lock; /* Lock for pp_extent entries */
         spinlock_t                ll_process_lock; /* Lock for ll_rw_process_info */
@@ -299,10 +346,19 @@ struct ll_sb_info {
 
         struct lprocfs_stats     *ll_stats; /* lprocfs stats counter */
 
+        /* reblnc lock protects llpd_budget */
+        spinlock_t                ll_async_page_reblnc_lock;
+        unsigned long             ll_async_page_reblnc_count;
+        unsigned long             ll_async_page_sample_max;
+        /* I defined this array here rather than in ll_pglist_data
+         * because it is always accessed by only one cpu. -jay */
+        unsigned long            *ll_async_page_sample;
         unsigned long             ll_async_page_max;
-        unsigned long             ll_async_page_count;
-        unsigned long             ll_pglist_gen;
-        struct list_head          ll_pglist; /* all pages (llap_pglist_item) */
+        unsigned long             ll_async_page_clock_hand;
+        lcounter_t                ll_async_page_count;
+        struct ll_pglist_data   **ll_pglist;
+
+        struct lprocfs_stats     *ll_ra_stats;
 
         unsigned                  ll_contention_time; /* seconds */
         unsigned                  ll_lockless_truncate_enable; /* true/false */
@@ -345,7 +401,69 @@ struct ll_sb_info {
         unsigned long long        ll_sa_miss;    /* miss count */
 };
 
-#define LL_DEFAULT_MAX_RW_CHUNK         (32 * 1024 * 1024)
+#define LL_DEFAULT_MAX_RW_CHUNK      (32 * 1024 * 1024)
+
+#define LL_PGLIST_DATA_CPU(sbi, cpu) ((sbi)->ll_pglist[cpu])
+#define LL_PGLIST_DATA(sbi)          LL_PGLIST_DATA_CPU(sbi, smp_processor_id())
+
+static inline struct ll_pglist_data *ll_pglist_cpu_lock(
+                struct ll_sb_info *sbi,
+                int cpu)
+{
+        spin_lock(&sbi->ll_pglist[cpu]->llpd_lock);
+        return LL_PGLIST_DATA_CPU(sbi, cpu);
+}
+
+static inline void ll_pglist_cpu_unlock(struct ll_sb_info *sbi, int cpu)
+{
+        spin_unlock(&sbi->ll_pglist[cpu]->llpd_lock);
+}
+
+static inline struct ll_pglist_data *ll_pglist_double_lock(
+                struct ll_sb_info *sbi,
+                int cpu, struct ll_pglist_data **pd_cpu)
+{
+        int current_cpu = cfs_get_cpu();
+
+        if (cpu == current_cpu) {
+                ll_pglist_cpu_lock(sbi, cpu);
+        } else if (current_cpu < cpu) {
+                ll_pglist_cpu_lock(sbi, current_cpu);
+                ll_pglist_cpu_lock(sbi, cpu);
+        } else {
+                ll_pglist_cpu_lock(sbi, cpu);
+                ll_pglist_cpu_lock(sbi, current_cpu);
+        }
+
+        if (pd_cpu)
+                *pd_cpu = LL_PGLIST_DATA_CPU(sbi, cpu);
+
+        return LL_PGLIST_DATA(sbi);
+}
+
+static inline void ll_pglist_double_unlock(struct ll_sb_info *sbi, int cpu)
+{
+        int current_cpu = smp_processor_id();
+        if (cpu == current_cpu) {
+                ll_pglist_cpu_unlock(sbi, cpu);
+        } else {
+                ll_pglist_cpu_unlock(sbi, cpu);
+                ll_pglist_cpu_unlock(sbi, current_cpu);
+        }
+        cfs_put_cpu();
+}
+
+static inline struct ll_pglist_data *ll_pglist_lock(struct ll_sb_info *sbi)
+{
+        ll_pglist_cpu_lock(sbi, cfs_get_cpu());
+        return LL_PGLIST_DATA(sbi);
+}
+
+static inline void ll_pglist_unlock(struct ll_sb_info *sbi)
+{
+        ll_pglist_cpu_unlock(sbi, smp_processor_id());
+        cfs_put_cpu();
+}
 
 struct ll_ra_read {
         pgoff_t             lrr_start;
@@ -380,7 +498,7 @@ struct ll_readahead_state {
         unsigned long   ras_consecutive_pages;
         /*
          * number of read requests after the last read-ahead window reset
-         * As window is reset on each seek, this is effectively the number 
+         * As window is reset on each seek, this is effectively the number
          * on consecutive read request and is used to trigger read-ahead.
          */
         unsigned long   ras_consecutive_requests;
@@ -407,7 +525,7 @@ struct ll_readahead_state {
          */
         unsigned long   ras_requests;
         /*
-         * Page index with respect to the current request, these value 
+         * Page index with respect to the current request, these value
          * will not be accurate when dealing with reads issued via mmap.
          */
         unsigned long   ras_request_index;
@@ -417,12 +535,12 @@ struct ll_readahead_state {
          * protected by ->ras_lock.
          */
         struct list_head ras_read_beads;
-        /* 
+        /*
          * The following 3 items are used for detecting the stride I/O
-         * mode. 
- 	 * In stride I/O mode, 
-         * ...............|-----data-----|****gap*****|--------|******|.... 
-         *    offset      |-stride_pages-|-stride_gap-| 
+         * mode.
+         * In stride I/O mode,
+         * ...............|-----data-----|****gap*****|--------|******|....
+         *    offset      |-stride_pages-|-stride_gap-|
          * ras_stride_offset = offset;
          * ras_stride_length = stride_pages + stride_gap;
          * ras_stride_pages = stride_pages;
@@ -431,7 +549,7 @@ struct ll_readahead_state {
         unsigned long ras_stride_length;
         unsigned long ras_stride_pages;
         pgoff_t ras_stride_offset;
-        /* 
+        /*
          * number of consecutive stride request count, and it is similar as
          * ras_consecutive_requests, but used for stride I/O mode.
          * Note: only more than 2 consecutive stride request are detected,
@@ -441,6 +559,7 @@ struct ll_readahead_state {
 };
 
 extern cfs_mem_cache_t *ll_file_data_slab;
+extern struct rw_semaphore ll_sb_sem;
 struct lustre_handle;
 struct ll_file_data {
         struct ll_readahead_state fd_ras;
@@ -482,7 +601,9 @@ struct ll_async_page {
                          llap_ra_used:1,
                          llap_ignore_quota:1,
                          llap_nocache:1,
-                         llap_lockless_io_page:1;
+                         llap_lockless_io_page:1,
+                         llap_reserved:7;
+        unsigned int     llap_pglist_cpu:16;
         void            *llap_cookie;
         struct page     *llap_page;
         struct list_head llap_pending_write;
@@ -508,14 +629,32 @@ enum {
 extern char *llap_origins[];
 
 #ifdef HAVE_REGISTER_CACHE
+#include <linux/cache_def.h>
 #define ll_register_cache(cache) register_cache(cache)
 #define ll_unregister_cache(cache) unregister_cache(cache)
+#elif defined(HAVE_SHRINKER_CACHE)
+struct cache_definition {
+        const char *name;
+        shrinker_t shrink;
+        struct shrinker *shrinker;
+};
+
+#define ll_register_cache(cache) do {                                   \
+        struct cache_definition *c = (cache);                           \
+        c->shrinker = set_shrinker(DEFAULT_SEEKS, c->shrink);           \
+} while(0)
+
+#define ll_unregister_cache(cache) do {                                 \
+        remove_shrinker((cache)->shrinker);                             \
+        (cache)->shrinker = NULL;                                       \
+} while(0)
 #else
 #define ll_register_cache(cache) do {} while (0)
 #define ll_unregister_cache(cache) do {} while (0)
 #endif
 
-void ll_ra_read_in(struct file *f, struct ll_ra_read *rar);
+void ll_ra_read_init(struct file *f, struct ll_ra_read *rar,
+                     loff_t offset, size_t count);
 void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
 struct ll_ra_read *ll_ra_read_get(struct file *f);
 
@@ -612,6 +751,8 @@ void ll_truncate(struct inode *inode);
 int ll_file_punch(struct inode *, loff_t, int);
 ssize_t ll_file_lockless_io(struct file *, const struct iovec *,
                             unsigned long, loff_t *, int, ssize_t);
+ssize_t ll_direct_IO(int rw, struct file *file,const struct iovec *iov,
+                     loff_t file_offset, unsigned long nr_segs, int locked);
 void ll_clear_file_contended(struct inode*);
 int ll_sync_page_range(struct inode *, struct address_space *, loff_t, size_t);
 
@@ -631,7 +772,7 @@ int ll_extent_unlock(struct ll_file_data *, struct inode *,
 int ll_file_open(struct inode *inode, struct file *file);
 int ll_file_release(struct inode *inode, struct file *file);
 int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *);
-int ll_glimpse_ioctl(struct ll_sb_info *sbi, 
+int ll_glimpse_ioctl(struct ll_sb_info *sbi,
                      struct lov_stripe_md *lsm, lstat_t *st);
 int ll_glimpse_size(struct inode *inode, int ast_flags);
 int ll_local_open(struct file *file,
@@ -647,7 +788,7 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
                struct lookup_intent *it, struct kstat *stat);
 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
 struct ll_file_data *ll_file_data_get(void);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
+#ifndef HAVE_INODE_PERMISION_2ARGS
 int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
 #else
 int ll_inode_permission(struct inode *inode, int mask);
@@ -660,7 +801,7 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
                              struct ptlrpc_request **request);
 int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
                      int set_default);
-int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm, 
+int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm,
                      int *lmm_size, struct ptlrpc_request **request);
 int ll_fsync(struct file *file, struct dentry *dentry, int data);
 int ll_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
@@ -718,7 +859,7 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode,
                   struct ptlrpc_request *req, int offset, struct super_block *);
 void lustre_dump_dentry(struct dentry *, int recur);
 void lustre_dump_inode(struct inode *);
-struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
+struct ll_async_page *llite_pglist_next_llap(struct list_head *head,
                                              struct list_head *list);
 int ll_obd_statfs(struct inode *inode, void *arg);
 int ll_get_max_mdsize(struct ll_sb_info *sbi, int *max_mdsize);
@@ -727,9 +868,6 @@ int ll_process_config(struct lustre_cfg *lcfg);
 /* llite/llite_nfs.c */
 extern struct export_operations lustre_export_operations;
 __u32 get_uuid2int(const char *name, int len);
-struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
-                               int fhtype, int parent);
-int ll_dentry_to_fh(struct dentry *, __u32 *datap, int *lenp, int need_parent);
 
 /* llite/special.c */
 extern struct inode_operations ll_special_inode_operations;
@@ -841,10 +979,21 @@ static inline struct obd_export *ll_i2mdcexp(struct inode *inode)
         return ll_s2mdcexp(inode->i_sb);
 }
 
+/** get lu_fid from inode. */
+static inline struct lu_fid *ll_inode_lu_fid(struct inode *inode)
+{
+        return &ll_i2info(inode)->lli_fid.f20;
+}
+
+/** get ll_fid from inode. */
+static inline struct ll_fid *ll_inode_ll_fid(struct inode *inode)
+{
+        return &ll_i2info(inode)->lli_fid.f16;
+}
+
 static inline void ll_inode2fid(struct ll_fid *fid, struct inode *inode)
 {
-        mdc_pack_fid(fid, inode->i_ino, inode->i_generation,
-                     inode->i_mode & S_IFMT);
+        *fid = *ll_inode_ll_fid(inode);
 }
 
 static inline int ll_mds_max_easize(struct super_block *sb)
@@ -936,6 +1085,10 @@ int ll_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup)
         if (sbi->ll_sa_max == 0)
                 return -ENOTSUPP;
 
+        /* temporarily disable dir stat ahead in interoperability mode */
+        if (sbi->ll_mdc_exp->exp_connect_flags & OBD_CONNECT_FID)
+                return -ENOTSUPP;
+
         /* not the same process, don't statahead */
         if (lli->lli_opendir_pid != cfs_curproc_pid())
                 return -EBADF;
@@ -954,7 +1107,7 @@ int ll_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup)
          * "IT_GETATTR" for the first time, and the subsequent "IT_GETATTR"
          * will bypass interacting with statahead thread for checking:
          * "lld_sa_generation == lli_sai->sai_generation"
-         */ 
+         */
         if (ldd && lli->lli_sai &&
             ldd->lld_sa_generation == lli->lli_sai->sai_generation)
                 return -EAGAIN;
@@ -992,36 +1145,41 @@ enum llioc_iter {
  * Parameters:
  *  @magic: Dynamic ioctl call routine will feed this vaule with the pointer
  *      returned to ll_iocontrol_register.  Callback functions should use this
- *      data to check the potential collasion of ioctl cmd. If collasion is 
+ *      data to check the potential collasion of ioctl cmd. If collasion is
  *      found, callback function should return LLIOC_CONT.
  *  @rcp: The result of ioctl command.
  *
  *  Return values:
- *      If @magic matches the pointer returned by ll_iocontrol_data, the 
+ *      If @magic matches the pointer returned by ll_iocontrol_data, the
  *      callback should return LLIOC_STOP; return LLIOC_STOP otherwise.
  */
-typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode, 
+typedef enum llioc_iter (*llioc_callback_t)(struct inode *inode,
                 struct file *file, unsigned int cmd, unsigned long arg,
                 void *magic, int *rcp);
 
-enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file, 
+enum llioc_iter ll_iocontrol_call(struct inode *inode, struct file *file,
                 unsigned int cmd, unsigned long arg, int *rcp);
 
 /* export functions */
-/* Register ioctl block dynamatically for a regular file. 
+/* Register ioctl block dynamatically for a regular file.
  *
  * @cmd: the array of ioctl command set
  * @count: number of commands in the @cmd
- * @cb: callback function, it will be called if an ioctl command is found to 
+ * @cb: callback function, it will be called if an ioctl command is found to
  *      belong to the command list @cmd.
  *
  * Return vaule:
- *      A magic pointer will be returned if success; 
- *      otherwise, NULL will be returned. 
+ *      A magic pointer will be returned if success;
+ *      otherwise, NULL will be returned.
  * */
 void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd);
 void ll_iocontrol_unregister(void *magic);
 
+ino_t ll_fid_build_ino(struct ll_sb_info *sbi,
+                       struct ll_fid *fid);
+__u32 ll_fid_build_gen(struct ll_sb_info *sbi,
+                       struct ll_fid *fid);
+
 #endif
 
 #endif /* LLITE_INTERNAL_H */
diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c
index c6af8e9..7b67bf2 100644
--- a/lustre/llite/llite_lib.c
+++ b/lustre/llite/llite_lib.c
@@ -44,7 +44,6 @@
 #include <linux/types.h>
 #include <linux/random.h>
 #include <linux/version.h>
-#include <linux/mm.h>
 
 #include <lustre_lite.h>
 #include <lustre_ha.h>
@@ -53,12 +52,13 @@
 #include <lustre_disk.h>
 #include <lustre_param.h>
 #include <lustre_cache.h>
+#include <obd_support.h>
 #include "llite_internal.h"
 
 cfs_mem_cache_t *ll_file_data_slab;
 
 LIST_HEAD(ll_super_blocks);
-spinlock_t ll_sb_lock = SPIN_LOCK_UNLOCKED;
+struct rw_semaphore ll_sb_sem;
 
 extern struct address_space_operations ll_aops;
 extern struct address_space_operations ll_dir_aops;
@@ -67,6 +67,64 @@ extern struct address_space_operations ll_dir_aops;
 #define log2(n) ffz(~(n))
 #endif
 
+static void ll_pglist_fini(struct ll_sb_info *sbi)
+{
+        struct page *page;
+        int i;
+
+        if (sbi->ll_pglist == NULL)
+                return;
+
+        for_each_possible_cpu(i) {
+                page = sbi->ll_pglist[i]->llpd_page;
+                if (page) {
+                        sbi->ll_pglist[i] = NULL;
+                        __free_page(page);
+                }
+        }
+
+        OBD_FREE(sbi->ll_pglist, sizeof(void *)*num_possible_cpus());
+        sbi->ll_pglist = NULL;
+}
+
+static int ll_pglist_init(struct ll_sb_info *sbi)
+{
+        struct ll_pglist_data *pd;
+        unsigned long budget;
+        int i, color = 0;
+        ENTRY;
+
+        OBD_ALLOC(sbi->ll_pglist, sizeof(void *) * num_possible_cpus());
+        if (sbi->ll_pglist == NULL)
+                RETURN(-ENOMEM);
+
+        budget = sbi->ll_async_page_max / num_online_cpus();
+        for_each_possible_cpu(i) {
+                struct page *page = alloc_pages_node(cpu_to_node(i),
+                                                    GFP_KERNEL, 0);
+                if (page == NULL) {
+                        ll_pglist_fini(sbi);
+                        RETURN(-ENOMEM);
+                }
+
+                if (color + L1_CACHE_ALIGN(sizeof(*pd)) > PAGE_SIZE)
+                        color = 0;
+
+                pd = (struct ll_pglist_data *)(page_address(page) + color);
+                memset(pd, 0, sizeof(*pd));
+                spin_lock_init(&pd->llpd_lock);
+                INIT_LIST_HEAD(&pd->llpd_list);
+                if (cpu_online(i))
+                        pd->llpd_budget = budget;
+                pd->llpd_cpu = i;
+                pd->llpd_page = page;
+                atomic_set(&pd->llpd_sample_count, 0);
+                sbi->ll_pglist[i] = pd;
+                color += L1_CACHE_ALIGN(sizeof(*pd));
+        }
+
+        RETURN(0);
+}
 
 static struct ll_sb_info *ll_init_sbi(void)
 {
@@ -81,12 +139,15 @@ static struct ll_sb_info *ll_init_sbi(void)
         if (!sbi)
                 RETURN(NULL);
 
+        OBD_ALLOC(sbi->ll_async_page_sample, sizeof(long)*num_possible_cpus());
+        if (sbi->ll_async_page_sample == NULL)
+                GOTO(out, 0);
+
         spin_lock_init(&sbi->ll_lock);
-        spin_lock_init(&sbi->ll_lco.lco_lock);
+        init_mutex(&sbi->ll_lco.lco_lock);
         spin_lock_init(&sbi->ll_pp_extent_lock);
         spin_lock_init(&sbi->ll_process_lock);
         sbi->ll_rw_stats_on = 0;
-        INIT_LIST_HEAD(&sbi->ll_pglist);
 
         si_meminfo(&si);
         pages = si.totalram - si.totalhigh;
@@ -99,8 +160,18 @@ static struct ll_sb_info *ll_init_sbi(void)
         } else {
                 sbi->ll_async_page_max = (pages / 4) * 3;
         }
-        sbi->ll_ra_info.ra_max_pages = min(pages / 32,
+
+        lcounter_init(&sbi->ll_async_page_count);
+        spin_lock_init(&sbi->ll_async_page_reblnc_lock);
+        sbi->ll_async_page_sample_max = 64 * num_online_cpus();
+        sbi->ll_async_page_reblnc_count = 0;
+        sbi->ll_async_page_clock_hand = 0;
+        if (ll_pglist_init(sbi))
+                GOTO(out, 0);
+
+        sbi->ll_ra_info.ra_max_pages_per_file = min(pages / 32,
                                            SBI_DEFAULT_READAHEAD_MAX);
+        sbi->ll_ra_info.ra_max_pages = sbi->ll_ra_info.ra_max_pages_per_file;
         sbi->ll_ra_info.ra_max_read_ahead_whole_pages =
                                            SBI_DEFAULT_READAHEAD_WHOLE_MAX;
         sbi->ll_contention_time = SBI_DEFAULT_CONTENTION_SECONDS;
@@ -112,9 +183,9 @@ static struct ll_sb_info *ll_init_sbi(void)
         class_uuid_unparse(uuid, &sbi->ll_sb_uuid);
         CDEBUG(D_CONFIG, "generated uuid: %s\n", sbi->ll_sb_uuid.uuid);
 
-        spin_lock(&ll_sb_lock);
+        down_write(&ll_sb_sem);
         list_add_tail(&sbi->ll_list, &ll_super_blocks);
-        spin_unlock(&ll_sb_lock);
+        up_write(&ll_sb_sem);
 
 #ifdef ENABLE_CHECKSUM
         sbi->ll_flags |= LL_SBI_DATA_CHECKSUM;
@@ -140,6 +211,14 @@ static struct ll_sb_info *ll_init_sbi(void)
         sbi->ll_sa_max = LL_SA_RPC_DEF;
 
         RETURN(sbi);
+
+out:
+        if (sbi->ll_async_page_sample)
+                OBD_FREE(sbi->ll_async_page_sample,
+                         sizeof(long) * num_possible_cpus());
+        ll_pglist_fini(sbi);
+        OBD_FREE(sbi, sizeof(*sbi));
+        RETURN(NULL);
 }
 
 void ll_free_sbi(struct super_block *sb)
@@ -148,9 +227,14 @@ void ll_free_sbi(struct super_block *sb)
         ENTRY;
 
         if (sbi != NULL) {
-                spin_lock(&ll_sb_lock);
+                down_write(&ll_sb_sem);
                 list_del(&sbi->ll_list);
-                spin_unlock(&ll_sb_lock);
+                up_write(&ll_sb_sem);
+                /* dont allow find cache via sb list first */
+                ll_pglist_fini(sbi);
+                lcounter_destroy(&sbi->ll_async_page_count);
+                OBD_FREE(sbi->ll_async_page_sample,
+                         sizeof(long) * num_possible_cpus());
                 OBD_FREE(sbi, sizeof(*sbi));
         }
         EXIT;
@@ -196,9 +280,11 @@ static int client_common_fill_super(struct super_block *sb,
         }
 
         /* indicate the features supported by this client */
-        data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_IBITS |
-                OBD_CONNECT_JOIN | OBD_CONNECT_ATTRFID | OBD_CONNECT_NODEVOH |
-                OBD_CONNECT_CANCELSET | OBD_CONNECT_AT;
+        data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_IBITS      |
+                                  OBD_CONNECT_JOIN    | OBD_CONNECT_ATTRFID    |
+                                  OBD_CONNECT_NODEVOH | OBD_CONNECT_CANCELSET  |
+                                  OBD_CONNECT_AT      | OBD_CONNECT_FID |
+                                  OBD_CONNECT_VBR     | OBD_CONNECT_LOV_V3;
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
                 data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
@@ -239,6 +325,10 @@ static int client_common_fill_super(struct super_block *sb,
                 GOTO(out, err);
         }
 
+        err = obd_fid_init(sbi->ll_mdc_exp);
+        if (err)
+                GOTO(out_mdc, err);
+
         err = obd_statfs(obd, &osfs, cfs_time_current_64() - HZ, 0);
         if (err)
                 GOTO(out_mdc, err);
@@ -292,10 +382,11 @@ static int client_common_fill_super(struct super_block *sb,
                 GOTO(out_mdc, err = -ENODEV);
         }
 
-        data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_GRANT |
-                OBD_CONNECT_REQPORTAL | OBD_CONNECT_BRW_SIZE | 
-                OBD_CONNECT_SRVLOCK | OBD_CONNECT_CANCELSET | OBD_CONNECT_AT |
-                OBD_CONNECT_TRUNCLOCK;
+        data->ocd_connect_flags = OBD_CONNECT_VERSION   | OBD_CONNECT_GRANT    |
+                                  OBD_CONNECT_REQPORTAL | OBD_CONNECT_BRW_SIZE |
+                                  OBD_CONNECT_SRVLOCK   | OBD_CONNECT_CANCELSET|
+                                  OBD_CONNECT_AT        | OBD_CONNECT_FID      |
+                                  OBD_CONNECT_VBR       | OBD_CONNECT_TRUNCLOCK;
 
         if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_CKSUM)) {
                 /* OBD_CONNECT_CKSUM should always be set, even if checksums are
@@ -327,23 +418,23 @@ static int client_common_fill_super(struct super_block *sb,
         obd_register_lock_cancel_cb(obd, ll_extent_lock_cancel_cb);
         obd_register_page_removal_cb(obd, ll_page_removal_cb, ll_pin_extent_cb);
 
-
         err = obd_connect(&osc_conn, obd, &sbi->ll_sb_uuid, data, &sbi->ll_osc_exp);
         if (err == -EBUSY) {
                 LCONSOLE_ERROR_MSG(0x150, "An OST (osc %s) is performing "
                                    "recovery, of which this client is not a "
                                    "part.  Please wait for recovery to "
                                    "complete, abort, or time out.\n", osc);
-                GOTO(out, err); // need clear cb?
+                GOTO(out, err);
         } else if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", osc, err);
                 GOTO(out_cb, err);
         }
-        spin_lock(&sbi->ll_lco.lco_lock);
+
+        mutex_down(&sbi->ll_lco.lco_lock);
         sbi->ll_lco.lco_flags = data->ocd_connect_flags;
         sbi->ll_lco.lco_mdc_exp = sbi->ll_mdc_exp;
         sbi->ll_lco.lco_osc_exp = sbi->ll_osc_exp;
-        spin_unlock(&sbi->ll_lco.lco_lock);
+        mutex_up(&sbi->ll_lco.lco_lock);
 
         err = mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp);
         if (err) {
@@ -375,7 +466,8 @@ static int client_common_fill_super(struct super_block *sb,
                 CERROR("cannot mds_connect: rc = %d\n", err);
                 GOTO(out_osc, err);
         }
-        CDEBUG(D_SUPER, "rootfid "LPU64"\n", rootfid.id);
+        CDEBUG(D_SUPER, "rootfid "LPU64":"DFID"\n", rootfid.id,
+                        PFID((struct lu_fid*)&rootfid));
         sbi->ll_rootino = rootfid.id;
 
         sb->s_op = &lustre_super_operations;
@@ -404,7 +496,7 @@ static int client_common_fill_super(struct super_block *sb,
         }
 
         LASSERT(sbi->ll_rootino != 0);
-        root = ll_iget(sb, sbi->ll_rootino, &md);
+        root = ll_iget(sb, ll_fid_build_ino(sbi, &rootfid), &md);
 
         ptlrpc_req_finished(request);
 
@@ -461,6 +553,7 @@ out_cb:
         obd_unregister_lock_cancel_cb(obd, ll_extent_lock_cancel_cb);
         obd_unregister_page_removal_cb(obd, ll_page_removal_cb);
 out_mdc:
+        obd_fid_fini(sbi->ll_mdc_exp);
         obd_disconnect(sbi->ll_mdc_exp);
         sbi->ll_mdc_exp = NULL;
 out:
@@ -640,6 +733,7 @@ void client_common_put_super(struct super_block *sb)
         obd_disconnect(sbi->ll_osc_exp);
         sbi->ll_osc_exp = NULL;
 
+        obd_fid_fini(sbi->ll_mdc_exp);
         obd_disconnect(sbi->ll_mdc_exp);
         sbi->ll_mdc_exp = NULL;
 
@@ -658,7 +752,7 @@ void ll_kill_super(struct super_block *sb)
 
         sbi = ll_s2sbi(sb);
         /* we need restore s_dev from changed for clustred NFS before put_super
-         * because new kernels have cached s_dev and change sb->s_dev in 
+         * because new kernels have cached s_dev and change sb->s_dev in
          * put_super not affected real removing devices */
         if (sbi)
                 sb->s_dev = sbi->ll_sdev_orig;
@@ -778,6 +872,16 @@ static int ll_options(char *options, int *flags)
                         *flags &= ~tmp;
                         goto next;
                 }
+                tmp = ll_set_opt("lazystatfs", s1, LL_SBI_LAZYSTATFS);
+                if (tmp) {
+                        *flags |= tmp;
+                        goto next;
+                }
+                tmp = ll_set_opt("nolazystatfs", s1, LL_SBI_LAZYSTATFS);
+                if (tmp) {
+                        *flags &= ~tmp;
+                        goto next;
+                }
                 LCONSOLE_ERROR_MSG(0x152, "Unknown option '%s', won't mount.\n",
                                    s1);
                 RETURN(-EINVAL);
@@ -809,6 +913,7 @@ void ll_lli_init(struct ll_inode_info *lli)
 #ifdef HAVE_CLOSE_THREAD
         INIT_LIST_HEAD(&lli->lli_pending_write_llaps);
 #endif
+        init_rwsem(&lli->lli_truncate_rwsem);
 }
 
 /* COMPAT_146 */
@@ -989,7 +1094,7 @@ out:
 
 int ll_fill_super(struct super_block *sb)
 {
-        struct lustre_profile *lprof;
+        struct lustre_profile *lprof = NULL;
         struct lustre_sb_info *lsi = s2lsi(sb);
         struct ll_sb_info *sbi;
         char  *osc = NULL, *mdc = NULL;
@@ -997,6 +1102,8 @@ int ll_fill_super(struct super_block *sb)
         struct config_llog_instance cfg = {0, };
         char   ll_instance[sizeof(sb) * 2 + 1];
         int    err;
+        char  *save = NULL;
+        char  pseudo[32] = { 0 };
         ENTRY;
 
         CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
@@ -1072,6 +1179,30 @@ int ll_fill_super(struct super_block *sb)
                                    "exist?\n", profilenm);
                 GOTO(out_free, err = -EINVAL);
         }
+
+        /*
+         * The configuration for 1.8 client and 2.0 client are different.
+         * 2.0 introduces lmv, but 1.8 directly uses mdc.
+         * Here, we will hack to use proper name for mdc if needed.
+         */
+        {
+                char *fsname_end;
+                int namelen;
+
+                save = lprof->lp_mdc;
+                fsname_end = strrchr(save, '-');
+                if (fsname_end) {
+                        namelen = fsname_end - save;
+                        if (strcmp(fsname_end, "-clilmv") == 0) {
+                                strncpy(pseudo, save, namelen);
+                                strcat(pseudo, "-MDT0000-mdc");
+                                lprof->lp_mdc = pseudo;
+                                CDEBUG(D_INFO, "1.8.x connecting to 2.0: lmv=%s"
+                                       " new mdc=%s\n", save, pseudo);
+                        }
+                }
+        }
+
         CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
                lprof->lp_mdc, lprof->lp_osc);
 
@@ -1091,6 +1222,8 @@ int ll_fill_super(struct super_block *sb)
         err = client_common_fill_super(sb, mdc, osc);
 
 out_free:
+        if (save && lprof)
+                lprof->lp_mdc = save;
         if (mdc)
                 OBD_FREE(mdc, strlen(mdc) + 1);
         if (osc)
@@ -1123,7 +1256,7 @@ void ll_put_super(struct super_block *sb)
 
         if (sbi->ll_mdc_exp) {
                 obd = class_exp2obd(sbi->ll_mdc_exp);
-                if (obd) 
+                if (obd)
                         force = obd->obd_force;
         }
 
@@ -1162,9 +1295,9 @@ void ll_put_super(struct super_block *sb)
         EXIT;
 } /* client_put_super */
 
-#ifdef HAVE_REGISTER_CACHE
-#include <linux/cache_def.h>
-#ifdef HAVE_CACHE_RETURN_INT
+#if defined(HAVE_REGISTER_CACHE) || defined(HAVE_SHRINKER_CACHE)
+
+#if defined(HAVE_CACHE_RETURN_INT)
 static int
 #else
 static void
@@ -1174,10 +1307,13 @@ ll_shrink_cache(int priority, unsigned int gfp_mask)
         struct ll_sb_info *sbi;
         int count = 0;
 
+        /* don't race with umount */
+        down_read(&ll_sb_sem);
         list_for_each_entry(sbi, &ll_super_blocks, ll_list)
                 count += llap_shrink_cache(sbi, priority);
+        up_read(&ll_sb_sem);
 
-#ifdef HAVE_CACHE_RETURN_INT
+#if defined(HAVE_CACHE_RETURN_INT)
         return count;
 #endif
 }
@@ -1186,7 +1322,7 @@ struct cache_definition ll_cache_definition = {
         .name = "llap_cache",
         .shrink = ll_shrink_cache
 };
-#endif /* HAVE_REGISTER_CACHE */
+#endif /* HAVE_REGISTER_CACHE || HAVE_SHRINKER_CACHE */
 
 struct inode *ll_inode_from_lock(struct ldlm_lock *lock)
 {
@@ -1301,36 +1437,46 @@ static int ll_setattr_do_truncate(struct inode *inode, loff_t new_size)
         ldlm_policy_data_t policy = { .l_extent = {new_size,
                                                    OBD_OBJECT_EOF } };
         struct lustre_handle lockh = { 0 };
-        int local_lock = 0; /* 0 - no local lock;
+        int local_lock = 1; /* 0 - no local lock;
                              * 1 - lock taken by lock_extent;
                              * 2 - by obd_match*/
         int ast_flags;
-        int err;
         ENTRY;
 
         UNLOCK_INODE_MUTEX(inode);
         UP_WRITE_I_ALLOC_SEM(inode);
 
-        if (sbi->ll_lockless_truncate_enable && 
+        down_write(&lli->lli_truncate_rwsem);
+        if (sbi->ll_lockless_truncate_enable &&
             (sbi->ll_lco.lco_flags & OBD_CONNECT_TRUNCLOCK)) {
+                int n_matches = 0;
+
                 ast_flags = LDLM_FL_BLOCK_GRANTED;
                 rc = obd_match(sbi->ll_osc_exp, lsm, LDLM_EXTENT,
-                               &policy, LCK_PW, &ast_flags, inode, &lockh);
+                               &policy, LCK_PW, &ast_flags, inode, &lockh,
+                               &n_matches);
                 if (rc > 0) {
                         local_lock = 2;
                         rc = 0;
-                } else if (rc == 0) {
-                        rc = ll_file_punch(inode, new_size, 1);
+                } else {
+                        /* clear the lock handle as it not cleared
+                         * by obd_match if no matched lock found */
+                        lockh.cookie = 0;
+                        if (rc == 0 && n_matches == 0) {
+                                local_lock = 0;
+                                rc = ll_file_punch(inode, new_size, 1);
+                        }
                 }
-        } else {
+        }
+        if (local_lock == 1) {
                 /* XXX when we fix the AST intents to pass the discard-range
                  * XXX extent, make ast_flags always LDLM_AST_DISCARD_DATA
                  * XXX here. */
                 ast_flags = (new_size == 0) ? LDLM_AST_DISCARD_DATA : 0;
                 rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy,
                                     &lockh, ast_flags);
-                if (likely(rc == 0))
-                        local_lock = 1;
+                if (unlikely(rc != 0))
+                        local_lock = 0;
         }
 
         LOCK_INODE_MUTEX(inode);
@@ -1346,15 +1492,16 @@ static int ll_setattr_do_truncate(struct inode *inode, loff_t new_size)
                 rc = vmtruncate(inode, new_size);
                 clear_bit(LLI_F_SRVLOCK, &lli->lli_flags);
                 if (rc != 0) {
-                        LASSERT(atomic_read(&lli->lli_size_sem.count) <= 0);
+                        LASSERT(SEM_COUNT(&lli->lli_size_sem) <= 0);
                         ll_inode_size_unlock(inode, 0);
                 }
         }
         if (local_lock) {
-                if (local_lock == 2)
-                        err = obd_cancel(sbi->ll_osc_exp, lsm, LCK_PW, &lockh);
-                else
-                        err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
+                int err;
+
+                err = (local_lock == 2) ?
+                        obd_cancel(sbi->ll_osc_exp, lsm, LCK_PW, &lockh):
+                        ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh);
                 if (unlikely(err != 0)){
                         CERROR("extent unlock failed: err=%d,"
                                " unlock method =%d\n", err, local_lock);
@@ -1362,6 +1509,7 @@ static int ll_setattr_do_truncate(struct inode *inode, loff_t new_size)
                                 rc = err;
                 }
         }
+        up_write(&lli->lli_truncate_rwsem);
         RETURN(rc);
 }
 
@@ -1384,7 +1532,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         struct lov_stripe_md *lsm = lli->lli_smd;
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         struct ptlrpc_request *request = NULL;
-        struct mdc_op_data op_data;
+        struct mdc_op_data op_data = { { 0 } };
         struct lustre_md md;
         int ia_valid = attr->ia_valid;
         int rc = 0;
@@ -1424,16 +1572,6 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                 attr->ia_mtime = CURRENT_TIME;
                 attr->ia_valid |= ATTR_MTIME_SET;
         }
-        if ((attr->ia_valid & ATTR_CTIME) && !(attr->ia_valid & ATTR_MTIME)) {
-                /* To avoid stale mtime on mds, obtain it from ost and send
-                   to mds. */
-                rc = ll_glimpse_size(inode, 0);
-                if (rc)
-                        RETURN(rc);
-
-                attr->ia_valid |= ATTR_MTIME_SET | ATTR_MTIME;
-                attr->ia_mtime = inode->i_mtime;
-        }
 
         if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME))
                 CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n",
@@ -1495,23 +1633,95 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         if (ia_valid & ATTR_SIZE) {
                 rc = ll_setattr_do_truncate(inode, attr->ia_size);
         } else if (ia_valid & (ATTR_MTIME | ATTR_MTIME_SET)) {
-                obd_flag flags;
                 struct obd_info oinfo = { { { 0 } } };
                 struct obdo *oa;
-                OBDO_ALLOC(oa);
+                struct lustre_handle lockh = { 0 };
+                obd_valid valid;
 
                 CDEBUG(D_INODE, "set mtime on OST inode %lu to %lu\n",
                        inode->i_ino, LTIME_S(attr->ia_mtime));
 
+                OBDO_ALLOC(oa);
                 if (oa) {
                         oa->o_id = lsm->lsm_object_id;
-                        oa->o_valid = OBD_MD_FLID;
+                        oa->o_gr = lsm->lsm_object_gr;
+                        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+
+                        valid = OBD_MD_FLTYPE | OBD_MD_FLFID | OBD_MD_FLGENER;
+
+                        if (LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime)){
+                                struct ost_lvb xtimes;
+
+                                /* setting mtime to past is performed under PW
+                                 * EOF extent lock */
+                                oinfo.oi_policy.l_extent.start = 0;
+                                oinfo.oi_policy.l_extent.end = OBD_OBJECT_EOF;
+                                rc = ll_extent_lock(NULL, inode, lsm, LCK_PW,
+                                                    &oinfo.oi_policy,
+                                                    &lockh, 0);
+                                if (rc)
+                                        RETURN(rc);
+
+                                /* setattr under locks
+                                 *
+                                 * 1. restore inode's timestamps which
+                                 * are about to be set as long as
+                                 * concurrent stat (via
+                                 * ll_glimpse_size) might bring
+                                 * out-of-date ones
+                                 *
+                                 * 2. update lsm so that next stat
+                                 * (via ll_glimpse_size) could get
+                                 * correct values in lsm */
+                                lov_stripe_lock(lli->lli_smd);
+                                if (ia_valid & ATTR_ATIME) {
+                                        LTIME_S(inode->i_atime) =
+                                                xtimes.lvb_atime =
+                                                LTIME_S(attr->ia_atime);
+                                        valid |= OBD_MD_FLATIME;
+                                }
+                                if (ia_valid & ATTR_MTIME) {
+                                        LTIME_S(inode->i_mtime) =
+                                                xtimes.lvb_mtime =
+                                                LTIME_S(attr->ia_mtime);
+                                        valid |= OBD_MD_FLMTIME;
+                                }
+                                if (ia_valid & ATTR_CTIME) {
+                                        LTIME_S(inode->i_ctime) =
+                                                xtimes.lvb_ctime =
+                                                LTIME_S(attr->ia_ctime);
+                                        valid |= OBD_MD_FLCTIME;
+                                }
 
-                        flags = OBD_MD_FLTYPE | OBD_MD_FLATIME |
-                                OBD_MD_FLMTIME | OBD_MD_FLCTIME |
-                                OBD_MD_FLFID | OBD_MD_FLGENER;
+                                obd_update_lvb(ll_i2obdexp(inode), lli->lli_smd,
+                                               &xtimes, valid);
+                                lov_stripe_unlock(lli->lli_smd);
+                        } else {
+                                /* lockless setattr
+                                 *
+                                 * 1. do not use inode's timestamps
+                                 * because concurrent stat might fill
+                                 * the inode with out-of-date times,
+                                 * send values from attr instead
+                                 *
+                                 * 2.do no update lsm, as long as stat
+                                 * (via ll_glimpse_size) will bring
+                                 * attributes from osts anyway */
+                                if (ia_valid & ATTR_ATIME) {
+                                        oa->o_atime = LTIME_S(attr->ia_atime);
+                                        oa->o_valid |= OBD_MD_FLATIME;
+                                }
+                                if (ia_valid & ATTR_MTIME) {
+                                        oa->o_mtime = LTIME_S(attr->ia_mtime);
+                                        oa->o_valid |= OBD_MD_FLMTIME;
+                                }
+                                if (ia_valid & ATTR_CTIME) {
+                                        oa->o_ctime = LTIME_S(attr->ia_ctime);
+                                        oa->o_valid |= OBD_MD_FLCTIME;
+                                }
+                        }
 
-                        obdo_from_inode(oa, inode, flags);
+                        obdo_from_inode(oa, inode, valid);
 
                         oinfo.oi_oa = oa;
                         oinfo.oi_md = lsm;
@@ -1519,6 +1729,19 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                         rc = obd_setattr_rqset(sbi->ll_osc_exp, &oinfo, NULL);
                         if (rc)
                                 CERROR("obd_setattr_async fails: rc=%d\n", rc);
+
+                        if (LTIME_S(attr->ia_mtime) < LTIME_S(attr->ia_ctime)){
+                                int err;
+
+                                err = ll_extent_unlock(NULL, inode, lsm,
+                                                       LCK_PW, &lockh);
+                                if (unlikely(err != 0)) {
+                                        CERROR("extent unlock failed: "
+                                               "err=%d\n", err);
+                                        if (rc == 0)
+                                                rc = err;
+                                }
+                        }
                         OBDO_FREE(oa);
                 } else {
                         rc = -ENOMEM;
@@ -1529,20 +1752,27 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
 
 int ll_setattr(struct dentry *de, struct iattr *attr)
 {
-        int mode;
+        int mode = de->d_inode->i_mode;
 
         if ((attr->ia_valid & (ATTR_CTIME|ATTR_SIZE|ATTR_MODE)) ==
             (ATTR_CTIME|ATTR_SIZE|ATTR_MODE))
                 attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE;
-        if ((attr->ia_valid & (ATTR_MODE|ATTR_FORCE|ATTR_SIZE)) == 
+        if ((attr->ia_valid & (ATTR_MODE|ATTR_FORCE|ATTR_SIZE)) ==
             (ATTR_SIZE|ATTR_MODE)) {
-                mode = de->d_inode->i_mode;
                 if (((mode & S_ISUID) && (!(attr->ia_mode & S_ISUID))) ||
                     ((mode & S_ISGID) && (mode & S_IXGRP) &&
                     (!(attr->ia_mode & S_ISGID))))
                         attr->ia_valid |= ATTR_FORCE;
         }
 
+        if ((mode & S_ISUID) && S_ISREG(mode) &&
+            !(attr->ia_mode & S_ISUID))
+                attr->ia_valid |= ATTR_KILL_SUID;
+
+        if (((mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP)) &&
+            S_ISREG(mode) && !(attr->ia_mode & S_ISGID))
+                attr->ia_valid |= ATTR_KILL_SGID;
+
         return ll_setattr_raw(de->d_inode, attr);
 }
 
@@ -1565,6 +1795,9 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs,
         CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n",
                osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files);
 
+        if (sbi->ll_flags & LL_SBI_LAZYSTATFS)
+                flags |= OBD_STATFS_NODELAY;
+
         rc = obd_statfs_rqset(class_exp2obd(sbi->ll_osc_exp),
                               &obd_osfs, max_age, flags);
         if (rc) {
@@ -1692,11 +1925,16 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
         struct ll_inode_info *lli = ll_i2info(inode);
         struct mds_body *body = md->body;
         struct lov_stripe_md *lsm = md->lsm;
+        struct ll_sb_info *sbi = ll_i2sbi(inode);
+        ENTRY;
+
+        CDEBUG(D_INODE, "body->valid = "LPX64"\n", body->valid);
 
         LASSERT ((lsm != NULL) == ((body->valid & OBD_MD_FLEASIZE) != 0));
         if (lsm != NULL) {
                 if (lli->lli_smd == NULL) {
-                        if (lsm->lsm_magic != LOV_MAGIC &&
+                        if (lsm->lsm_magic != LOV_MAGIC_V1 &&
+                            lsm->lsm_magic != LOV_MAGIC_V3 &&
                             lsm->lsm_magic != LOV_MAGIC_JOIN) {
                                 dump_lsm(D_ERROR, lsm);
                                 LBUG();
@@ -1741,25 +1979,28 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
         }
 #endif
 
-        if (body->valid & OBD_MD_FLID)
-                inode->i_ino = body->ino;
-        if (body->valid & OBD_MD_FLATIME &&
-            body->atime > LTIME_S(inode->i_atime))
-                LTIME_S(inode->i_atime) = body->atime;
-
-        /* mtime is always updated with ctime, but can be set in past.
-           As write and utime(2) may happen within 1 second, and utime's
-           mtime has a priority over write's one, so take mtime from mds
-           for the same ctimes. */
-        if (body->valid & OBD_MD_FLCTIME &&
-            body->ctime >= LTIME_S(inode->i_ctime)) {
-                LTIME_S(inode->i_ctime) = body->ctime;
-                if (body->valid & OBD_MD_FLMTIME) {
-                        CDEBUG(D_INODE, "setting ino %lu mtime "
-                               "from %lu to "LPU64"\n", inode->i_ino,
+        inode->i_ino = ll_fid_build_ino(sbi, &body->fid1);
+        inode->i_generation = ll_fid_build_gen(sbi, &body->fid1);
+        *ll_inode_lu_fid(inode) = *((struct lu_fid*)&md->body->fid1);
+
+        if (body->valid & OBD_MD_FLATIME) {
+                if (body->atime > LTIME_S(inode->i_atime))
+                        LTIME_S(inode->i_atime) = body->atime;
+                lli->lli_lvb.lvb_atime = body->atime;
+        }
+        if (body->valid & OBD_MD_FLMTIME) {
+                if (body->mtime > LTIME_S(inode->i_mtime)) {
+                        CDEBUG(D_INODE, "setting ino %lu mtime from %lu "
+                               "to "LPU64"\n", inode->i_ino,
                                LTIME_S(inode->i_mtime), body->mtime);
                         LTIME_S(inode->i_mtime) = body->mtime;
                 }
+                lli->lli_lvb.lvb_mtime = body->mtime;
+        }
+        if (body->valid & OBD_MD_FLCTIME) {
+                if (body->ctime > LTIME_S(inode->i_ctime))
+                        LTIME_S(inode->i_ctime) = body->ctime;
+                lli->lli_lvb.lvb_ctime = body->ctime;
         }
         if (body->valid & OBD_MD_FLMODE)
                 inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
@@ -1778,12 +2019,11 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
         if (body->valid & OBD_MD_FLGID)
                 inode->i_gid = body->gid;
         if (body->valid & OBD_MD_FLFLAGS)
-                inode->i_flags = ll_ext_to_inode_flags(body->flags);
-
+                inode->i_flags = ll_ext_to_inode_flags(body->flags |
+                                                       MDS_BFLAG_EXT_FLAGS);
         if (body->valid & OBD_MD_FLNLINK)
                 inode->i_nlink = body->nlink;
-        if (body->valid & OBD_MD_FLGENER)
-                inode->i_generation = body->generation;
+
         if (body->valid & OBD_MD_FLRDEV)
                 inode->i_rdev = old_decode_dev(body->rdev);
         if (body->valid & OBD_MD_FLSIZE) {
@@ -1800,6 +2040,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
 
         if (body->valid & OBD_MD_FLSIZE)
                 set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &lli->lli_flags);
+        EXIT;
 }
 
 static struct backing_dev_info ll_backing_dev_info = {
@@ -1869,7 +2110,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
         ENTRY;
 
         switch(cmd) {
-        case EXT3_IOC_GETFLAGS: {
+        case FSFILT_IOC_GETFLAGS: {
                 struct ll_fid fid;
                 struct mds_body *body;
 
@@ -1886,13 +2127,13 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                 /* We want to return EXT3_*_FL flags to the caller via this
                  * ioctl.  An older MDS may be sending S_* flags, fix it up. */
                 flags = ll_inode_to_ext_flags(body->flags,
-                                              body->flags &MDS_BFLAG_EXT_FLAGS);
+                                              MDS_BFLAG_EXT_FLAGS);
                 ptlrpc_req_finished (req);
 
                 RETURN(put_user(flags, (int *)arg));
         }
-        case EXT3_IOC_SETFLAGS: {
-                struct mdc_op_data op_data;
+        case FSFILT_IOC_SETFLAGS: {
+                struct mdc_op_data op_data = { { 0 } };
                 struct ll_iattr_struct attr;
                 struct obd_info oinfo = { { { 0 } } };
                 struct lov_stripe_md *lsm = ll_i2info(inode)->lli_smd;
@@ -1920,8 +2161,10 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                 }
 
                 oinfo.oi_oa->o_id = lsm->lsm_object_id;
+                oinfo.oi_oa->o_gr = lsm->lsm_object_gr;
                 oinfo.oi_oa->o_flags = flags;
-                oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS;
+                oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP |
+                                       OBD_MD_FLFLAGS;
 
                 obdo_from_inode(oinfo.oi_oa, inode,
                                 OBD_MD_FLFID | OBD_MD_FLGENER);
@@ -2070,7 +2313,10 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode,
                 ll_update_inode(*inode, &md);
         } else {
                 LASSERT(sb);
-                *inode = ll_iget(sb, md.body->ino, &md);
+                /** hashing VFS inode by FIDs.
+                 * IGIF will be used for for compatibility if needed.
+                 */
+                *inode =ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1), &md);
                 if (*inode == NULL || is_bad_inode(*inode)) {
                         mdc_free_lustre_md(exp, &md);
                         rc = -ENOMEM;
@@ -2094,14 +2340,14 @@ char *llap_origins[] = {
         [LLAP_ORIGIN_LOCKLESS_IO] = "ls"
 };
 
-struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi,
+struct ll_async_page *llite_pglist_next_llap(struct list_head *head,
                                              struct list_head *list)
 {
         struct ll_async_page *llap;
         struct list_head *pos;
 
         list_for_each(pos, list) {
-                if (pos == &sbi->ll_pglist)
+                if (pos == head)
                         return NULL;
                 llap = list_entry(pos, struct ll_async_page, llap_pglist_item);
                 if (llap->llap_page == NULL)
@@ -2228,5 +2474,8 @@ int ll_show_options(struct seq_file *seq, struct vfsmount *vfs)
         if (sbi->ll_flags & LL_SBI_ACL)
                 seq_puts(seq, ",acl");
 
+        if (sbi->ll_flags & LL_SBI_LAZYSTATFS)
+                seq_puts(seq, ",lazystatfs");
+
         RETURN(0);
 }
diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c
index 886cf9d..a56b6de 100644
--- a/lustre/llite/llite_mmap.c
+++ b/lustre/llite/llite_mmap.c
@@ -81,8 +81,7 @@ struct ll_lock_tree_node {
 int lt_get_mmap_locks(struct ll_lock_tree *tree,
                       unsigned long addr, size_t count);
 
-struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
-                       int *type);
+static struct vm_operations_struct ll_file_vm_ops;
 
 struct ll_lock_tree_node * ll_node_from_inode(struct inode *inode, __u64 start,
                                               __u64 end, ldlm_mode_t mode)
@@ -285,9 +284,19 @@ static ldlm_mode_t mode_from_vma(struct vm_area_struct *vma)
         return LCK_PR;
 }
 
+static void policy_from_vma_pgoff(ldlm_policy_data_t *policy,
+                                  struct vm_area_struct *vma,
+                                  __u64 pgoff, size_t count)
+{
+        policy->l_extent.start = pgoff << CFS_PAGE_SHIFT;
+        policy->l_extent.end = (policy->l_extent.start + count - 1) |
+                               ~CFS_PAGE_MASK;
+}
+
 static void policy_from_vma(ldlm_policy_data_t *policy,
                             struct vm_area_struct *vma, unsigned long addr,
                             size_t count)
+
 {
         policy->l_extent.start = ((addr - vma->vm_start) & CFS_PAGE_MASK) +
                                  ((__u64)vma->vm_pgoff << CFS_PAGE_SHIFT);
@@ -308,7 +317,7 @@ static struct vm_area_struct * our_vma(unsigned long addr, size_t count)
         spin_lock(&mm->page_table_lock);
         for(vma = find_vma(mm, addr);
             vma != NULL && vma->vm_start < (addr + count); vma = vma->vm_next) {
-                if (vma->vm_ops && vma->vm_ops->nopage == ll_nopage &&
+                if (vma->vm_ops && vma->vm_ops == &ll_file_vm_ops &&
                     vma->vm_flags & VM_SHARED) {
                         ret = vma;
                         break;
@@ -360,44 +369,30 @@ int lt_get_mmap_locks(struct ll_lock_tree *tree,
         }
         RETURN(0);
 }
-/**
- * Page fault handler.
- *
- * \param vma - is virtiual area struct related to page fault
- * \param address - address when hit fault
- * \param type - of fault
- *
- * \return allocated and filled page for address
- * \retval NOPAGE_SIGBUS if page not exist on this address
- * \retval NOPAGE_OOM not have memory for allocate new page
- */
-struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
-                       int *type)
+
+static int ll_get_extent_lock(struct vm_area_struct *vma, unsigned long pgoff,
+                              int *save_flags, struct lustre_handle *lockh)
 {
         struct file *filp = vma->vm_file;
         struct ll_file_data *fd = LUSTRE_FPRIVATE(filp);
         struct inode *inode = filp->f_dentry->d_inode;
-        struct lustre_handle lockh = { 0 };
         ldlm_policy_data_t policy;
         ldlm_mode_t mode;
-        struct page *page = NULL;
         struct ll_inode_info *lli = ll_i2info(inode);
-        struct lov_stripe_md *lsm;
         struct ost_lvb lvb;
         __u64 kms, old_mtime;
-        unsigned long pgoff, size, rand_read, seq_read;
-        int rc = 0;
+        unsigned long size;
         ENTRY;
 
         if (lli->lli_smd == NULL) {
                 CERROR("No lsm on fault?\n");
-                RETURN(NOPAGE_SIGBUS);
+                RETURN(0);
         }
 
         ll_clear_file_contended(inode);
 
         /* start and end the lock on the first and last bytes in the page */
-        policy_from_vma(&policy, vma, address, CFS_PAGE_SIZE);
+        policy_from_vma_pgoff(&policy, vma, pgoff, CFS_PAGE_SIZE);
 
         CDEBUG(D_MMAP, "nopage vma %p inode %lu, locking ["LPU64", "LPU64"]\n",
                vma, inode->i_ino, policy.l_extent.start, policy.l_extent.end);
@@ -405,26 +400,28 @@ struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
         mode = mode_from_vma(vma);
         old_mtime = LTIME_S(inode->i_mtime);
 
-        lsm = lli->lli_smd;
-        rc = ll_extent_lock(fd, inode, lsm, mode, &policy,
-                            &lockh, LDLM_FL_CBPENDING | LDLM_FL_NO_LRU);
-        if (rc != 0)
-                RETURN(NOPAGE_SIGBUS);
+        if(ll_extent_lock(fd, inode, lli->lli_smd, mode, &policy,
+                          lockh, LDLM_FL_CBPENDING | LDLM_FL_NO_LRU) != 0)
+                RETURN(0);
 
         if (vma->vm_flags & VM_EXEC && LTIME_S(inode->i_mtime) != old_mtime)
                 CWARN("binary changed. inode %lu\n", inode->i_ino);
 
-        lov_stripe_lock(lsm);
+        lov_stripe_lock(lli->lli_smd);
         inode_init_lvb(inode, &lvb);
-        obd_merge_lvb(ll_i2obdexp(inode), lsm, &lvb, 1);
+        if(obd_merge_lvb(ll_i2obdexp(inode), lli->lli_smd, &lvb, 1)) {
+                lov_stripe_unlock(lli->lli_smd);
+                RETURN(0);
+        }
         kms = lvb.lvb_size;
 
-        pgoff = ((address - vma->vm_start) >> CFS_PAGE_SHIFT) + vma->vm_pgoff;
         size = (kms + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
+        CDEBUG(D_INFO, "Kms %lu - %lu\n", size, pgoff);
 
         if (pgoff >= size) {
-                lov_stripe_unlock(lsm);
+                lov_stripe_unlock(lli->lli_smd);
                 ll_glimpse_size(inode, LDLM_FL_BLOCK_GRANTED);
+                lov_stripe_lock(lli->lli_smd);
         } else {
                 /* XXX change inode size without ll_inode_size_lock() held!
                  *     there is a race condition with truncate path. (see
@@ -446,29 +443,69 @@ struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
                         CDEBUG(D_INODE, "ino=%lu, updating i_size %llu\n",
                                inode->i_ino, i_size_read(inode));
                 }
-                lov_stripe_unlock(lsm);
         }
 
         /* If mapping is writeable, adjust kms to cover this page,
          * but do not extend kms beyond actual file size.
          * policy.l_extent.end is set to the end of the page by policy_from_vma
          * bug 10919 */
-        lov_stripe_lock(lsm);
         if (mode == LCK_PW)
-                obd_adjust_kms(ll_i2obdexp(inode), lsm,
+                obd_adjust_kms(ll_i2obdexp(inode), lli->lli_smd,
                                min_t(loff_t, policy.l_extent.end + 1,
                                i_size_read(inode)), 0);
-        lov_stripe_unlock(lsm);
+        lov_stripe_unlock(lli->lli_smd);
 
         /* disable VM_SEQ_READ and use VM_RAND_READ to make sure that
          * the kernel will not read other pages not covered by ldlm in
          * filemap_nopage. we do our readahead in ll_readpage.
          */
-        rand_read = vma->vm_flags & VM_RAND_READ;
-        seq_read = vma->vm_flags & VM_SEQ_READ;
+        *save_flags = vma->vm_flags & (VM_RAND_READ | VM_SEQ_READ);
         vma->vm_flags &= ~ VM_SEQ_READ;
         vma->vm_flags |= VM_RAND_READ;
 
+        return 1;
+}
+
+static void ll_put_extent_lock(struct vm_area_struct *vma, int save_flags,
+                             struct lustre_handle *lockh)
+{
+        struct file *filp = vma->vm_file;
+        struct ll_file_data *fd = LUSTRE_FPRIVATE(filp);
+        struct inode *inode = filp->f_dentry->d_inode;
+        ldlm_mode_t mode;
+
+        mode = mode_from_vma(vma);
+        vma->vm_flags &= ~(VM_RAND_READ | VM_SEQ_READ);
+        vma->vm_flags |= save_flags;
+
+        ll_extent_unlock(fd, inode, ll_i2info(inode)->lli_smd, mode, lockh);
+}
+
+#ifndef HAVE_VM_OP_FAULT
+/**
+ * Page fault handler.
+ *
+ * \param vma - is virtiual area struct related to page fault
+ * \param address - address when hit fault
+ * \param type - of fault
+ *
+ * \return allocated and filled page for address
+ * \retval NOPAGE_SIGBUS if page not exist on this address
+ * \retval NOPAGE_OOM not have memory for allocate new page
+ */
+struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
+                       int *type)
+{
+        struct lustre_handle lockh = { 0 };
+        int save_fags = 0;
+        unsigned long pgoff;
+        struct page *page;
+        ENTRY;
+
+        pgoff = ((address - vma->vm_start) >> CFS_PAGE_SHIFT) + vma->vm_pgoff;
+        if(!ll_get_extent_lock(vma, pgoff, &save_fags, &lockh))
+                RETURN(NOPAGE_SIGBUS);
+
         page = filemap_nopage(vma, address, type);
         if (page != NOPAGE_SIGBUS && page != NOPAGE_OOM)
                 LL_CDEBUG_PAGE(D_PAGE, page, "got addr %lu type %lx\n", address,
@@ -477,13 +514,48 @@ struct page *ll_nopage(struct vm_area_struct *vma, unsigned long address,
                 CDEBUG(D_PAGE, "got addr %lu type %lx - SIGBUS\n",  address,
                                (long)type);
 
-        vma->vm_flags &= ~VM_RAND_READ;
-        vma->vm_flags |= (rand_read | seq_read);
+        ll_put_extent_lock(vma, save_fags, &lockh);
 
-        ll_extent_unlock(fd, inode, ll_i2info(inode)->lli_smd, mode, &lockh);
         RETURN(page);
 }
 
+#else
+/* New fault() API*/
+/**
+ * Page fault handler.
+ *
+ * \param vma - is virtiual area struct related to page fault
+ * \param address - address when hit fault
+ * \param type - of fault
+ *
+ * \return allocated and filled page for address
+ * \retval NOPAGE_SIGBUS if page not exist on this address
+ * \retval NOPAGE_OOM not have memory for allocate new page
+ */
+int ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+{
+        struct lustre_handle lockh = { 0 };
+        int save_fags = 0;
+        int rc;
+        ENTRY;
+
+        if(!ll_get_extent_lock(vma, vmf->pgoff, &save_fags, &lockh))
+               RETURN(VM_FAULT_SIGBUS);
+
+        rc = filemap_fault(vma, vmf);
+        if (vmf->page)
+                LL_CDEBUG_PAGE(D_PAGE, vmf->page, "got addr %p type NOPAGE\n",
+                               vmf->virtual_address);
+        else
+                CDEBUG(D_PAGE, "got addr %p - SIGBUS\n",
+                       vmf->virtual_address);
+
+        ll_put_extent_lock(vma, save_fags, &lockh);
+
+        RETURN(rc);
+}
+#endif
+
 /* To avoid cancel the locks covering mmapped region for lock cache pressure,
  * we track the mapped vma count by lli_mmap_cnt.
  * ll_vm_open():  when first vma is linked, split locks from lru.
@@ -548,6 +620,7 @@ static void ll_vm_close(struct vm_area_struct *vma)
         }
 }
 
+#ifndef HAVE_VM_OP_FAULT
 #ifndef HAVE_FILEMAP_POPULATE
 static int (*filemap_populate)(struct vm_area_struct * area, unsigned long address, unsigned long len, pgprot_t prot, unsigned long pgoff, int nonblock);
 #endif
@@ -562,6 +635,7 @@ static int ll_populate(struct vm_area_struct *area, unsigned long address,
         rc = filemap_populate(area, address, len, prot, pgoff, 1);
         RETURN(rc);
 }
+#endif
 
 /* return the user space pointer that maps to a file offset via a vma */
 static inline unsigned long file_to_user(struct vm_area_struct *vma, __u64 byte)
@@ -588,10 +662,14 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last)
 }
 
 static struct vm_operations_struct ll_file_vm_ops = {
-        .nopage         = ll_nopage,
         .open           = ll_vm_open,
         .close          = ll_vm_close,
+#ifdef HAVE_VM_OP_FAULT
+        .fault          = ll_fault,
+#else
+        .nopage         = ll_nopage,
         .populate       = ll_populate,
+#endif
 };
 
 int ll_file_mmap(struct file * file, struct vm_area_struct * vma)
@@ -602,7 +680,7 @@ int ll_file_mmap(struct file * file, struct vm_area_struct * vma)
         ll_stats_ops_tally(ll_i2sbi(file->f_dentry->d_inode), LPROC_LL_MAP, 1);
         rc = generic_file_mmap(file, vma);
         if (rc == 0) {
-#ifndef HAVE_FILEMAP_POPULATE
+#if !defined(HAVE_FILEMAP_POPULATE) && !defined(HAVE_VM_OP_FAULT)
                 if (!filemap_populate)
                         filemap_populate = vma->vm_ops->populate;
 #endif
diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c
index c941d73..c4c1f15 100644
--- a/lustre/llite/llite_nfs.c
+++ b/lustre/llite/llite_nfs.c
@@ -57,6 +57,8 @@ __u32 get_uuid2int(const char *name, int len)
         return (key0 << 1);
 }
 
+#if THREAD_SIZE >= 8192 /* see bug 17630 */
+
 static int ll_nfs_test_inode(struct inode *inode, void *opaque)
 {
         struct ll_fid *iid = opaque;
@@ -68,36 +70,30 @@ static int ll_nfs_test_inode(struct inode *inode, void *opaque)
 }
 
 static struct inode * search_inode_for_lustre(struct super_block *sb,
-                                              unsigned long ino,
-                                              unsigned long generation,
-                                              int mode)
+                                              struct ll_fid *iid)
 {
         struct ptlrpc_request *req = NULL;
         struct ll_sb_info *sbi = ll_s2sbi(sb);
-        struct ll_fid fid;
         unsigned long valid = 0;
         int eadatalen = 0, rc;
         struct inode *inode = NULL;
-        struct ll_fid iid = { .id = ino, .generation = generation };
         ENTRY;
 
-        inode = ILOOKUP(sb, ino, ll_nfs_test_inode, &iid);
+        inode = ILOOKUP(sb, iid->id, ll_nfs_test_inode, iid);
 
         if (inode)
                 RETURN(inode);
-        if (S_ISREG(mode)) {
-                rc = ll_get_max_mdsize(sbi, &eadatalen);
-                if (rc) 
-                        RETURN(ERR_PTR(rc));
-                valid |= OBD_MD_FLEASIZE;
-        }
-        fid.id = (__u64)ino;
-        fid.generation = generation;
-        fid.f_type = mode;
 
-        rc = mdc_getattr(sbi->ll_mdc_exp, &fid, valid, eadatalen, &req);
+        rc = ll_get_max_mdsize(sbi, &eadatalen);
+        if (rc)
+                RETURN(ERR_PTR(rc));
+
+        valid |= OBD_MD_FLEASIZE;
+
+        /* mds_fid2dentry is ignore f_type */
+        rc = mdc_getattr(sbi->ll_mdc_exp, iid, valid, eadatalen, &req);
         if (rc) {
-                CERROR("failure %d inode %lu\n", rc, ino);
+                CERROR("failure %d inode "LPU64"\n", rc, iid->id);
                 RETURN(ERR_PTR(rc));
         }
 
@@ -111,27 +107,27 @@ static struct inode * search_inode_for_lustre(struct super_block *sb,
         RETURN(inode);
 }
 
-static struct dentry *ll_iget_for_nfs(struct super_block *sb, unsigned long ino,
-                                      __u32 generation, umode_t mode)
+static struct dentry *ll_iget_for_nfs(struct super_block *sb,
+                                      struct ll_fid *iid)
 {
         struct inode *inode;
         struct dentry *result;
         ENTRY;
 
-        if (ino == 0)
+        if (iid->id == 0)
                 RETURN(ERR_PTR(-ESTALE));
 
-        inode = search_inode_for_lustre(sb, ino, generation, mode);
-        if (IS_ERR(inode)) {
+        inode = search_inode_for_lustre(sb, iid);
+        if (IS_ERR(inode))
                 RETURN(ERR_PTR(PTR_ERR(inode)));
-        }
+
         if (is_bad_inode(inode) ||
-            (generation && inode->i_generation != generation)){
+            (iid->generation && inode->i_generation != iid->generation)) {
                 /* we didn't find the right inode.. */
                 CERROR("Inode %lu, Bad count: %lu %d or version  %u %u\n",
                        inode->i_ino, (unsigned long)inode->i_nlink,
                        atomic_read(&inode->i_count), inode->i_generation,
-                       generation);
+                       iid->generation);
                 iput(inode);
                 RETURN(ERR_PTR(-ESTALE));
         }
@@ -146,57 +142,103 @@ static struct dentry *ll_iget_for_nfs(struct super_block *sb, unsigned long ino,
         RETURN(result);
 }
 
-struct dentry *ll_fh_to_dentry(struct super_block *sb, __u32 *data, int len,
-                               int fhtype, int parent)
+#define LUSTRE_NFS_FID                0x94
+
+struct lustre_nfs_fid {
+        struct ll_fid   child;
+        struct ll_fid   parent;
+        umode_t         mode;
+};
+
+/* plen is in 32 bit units!
+ * The return value is file handle type:
+ * 1 -- contains child file handle;
+ * 2 -- contains child file handle and parent file handle;
+ * 255 -- error.
+ */
+static int ll_encode_fh(struct dentry *de, __u32 *fh, int *plen,
+                        int connectable)
 {
-        switch (fhtype) {
-                case 2:
-                        if (len < 5)
-                                break;
-                        if (parent)
-                                return ll_iget_for_nfs(sb, data[3], 0, data[4]);
-                case 1:
-                        if (len < 3)
-                                break;
-                        if (parent)
-                                break;
-                        return ll_iget_for_nfs(sb, data[0], data[1], data[2]);
-                default: break;
-        }
-        return ERR_PTR(-EINVAL);
+        struct inode *inode = de->d_inode;
+        struct inode *parent = de->d_parent->d_inode;
+        struct lustre_nfs_fid *nfs_fid = (void *)fh;
+        ENTRY;
+
+        CDEBUG(D_INFO, "encoding for (%lu) maxlen=%d minlen=%u\n",
+              inode->i_ino, *plen*4,
+              (int)sizeof(struct lustre_nfs_fid));
+
+        if (*plen*4 < sizeof(struct lustre_nfs_fid))
+                RETURN(255);
+
+        ll_inode2fid(&nfs_fid->child, inode);
+        ll_inode2fid(&nfs_fid->parent, parent);
+
+        nfs_fid->mode = (S_IFMT & inode->i_mode);
+        *plen = sizeof(struct lustre_nfs_fid)/4;
+
+        RETURN(LUSTRE_NFS_FID);
 }
 
-int ll_dentry_to_fh(struct dentry *dentry, __u32 *datap, int *lenp,
-                    int need_parent)
+#ifdef HAVE_FH_TO_DENTRY
+static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid,
+                                      int fh_len, int fh_type)
 {
-        if (*lenp < 3)
-                return 255;
-        *datap++ = dentry->d_inode->i_ino;
-        *datap++ = dentry->d_inode->i_generation;
-        *datap++ = (__u32)(S_IFMT & dentry->d_inode->i_mode);
-
-        if (*lenp == 3 || S_ISDIR(dentry->d_inode->i_mode)) {
-                *lenp = 3;
-                return 1;
-        }
-        if (dentry->d_parent) {
-                *datap++ = dentry->d_parent->d_inode->i_ino;
-                *datap++ = (__u32)(S_IFMT & dentry->d_parent->d_inode->i_mode);
+        struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid;
 
-                *lenp = 5;
-                return 2;
-        }
-        *lenp = 3;
-        return 1;
+        if (fh_type != LUSTRE_NFS_FID)
+                RETURN(ERR_PTR(-EINVAL));
+
+        RETURN(ll_iget_for_nfs(sb, &nfs_fid->child));
 }
+static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid,
+                                      int fh_len, int fh_type)
+{
+        struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid;
+
+        if (fh_type != LUSTRE_NFS_FID)
+                RETURN(ERR_PTR(-EINVAL));
+        RETURN(ll_iget_for_nfs(sb, &nfs_fid->parent));
+}
+
+#else
+/*
+ * This length is counted as amount of __u32,
+ *  It is composed of a fid and a mode
+ */
+static struct dentry *ll_decode_fh(struct super_block *sb, __u32 *fh, int fh_len,
+                                     int fh_type,
+                                     int (*acceptable)(void *, struct dentry *),
+                                     void *context)
+{
+        struct lustre_nfs_fid *nfs_fid = (void *)fh;
+        struct dentry *entry;
+        ENTRY;
+
+        CDEBUG(D_INFO, "decoding for "LPU64" fh_len=%d fh_type=%x\n",
+                nfs_fid->child.id, fh_len, fh_type);
+
+        if (fh_type != LUSTRE_NFS_FID)
+                  RETURN(ERR_PTR(-ESTALE));
+
+        entry = sb->s_export_op->find_exported_dentry(sb, &nfs_fid->child,
+                                                      &nfs_fid->parent,
+                                                      acceptable, context);
+        RETURN(entry);
+}
+
 
-#if THREAD_SIZE >= 8192
 struct dentry *ll_get_dentry(struct super_block *sb, void *data)
 {
-        __u32 *inump = (__u32*)data;
-        return ll_iget_for_nfs(sb, inump[0], inump[1], S_IFREG);
+        struct lustre_nfs_fid *fid = data;
+        ENTRY;
+
+        RETURN(ll_iget_for_nfs(sb, &fid->child));
+
 }
 
+#endif
+
 struct dentry *ll_get_parent(struct dentry *dchild)
 {
         struct ptlrpc_request *req = NULL;
@@ -208,11 +250,11 @@ struct dentry *ll_get_parent(struct dentry *dchild)
         char dotdot[] = "..";
         int  rc = 0;
         ENTRY;
-        
+
         LASSERT(dir && S_ISDIR(dir->i_mode));
-        
-        sbi = ll_s2sbi(dir->i_sb);       
- 
+
+        sbi = ll_s2sbi(dir->i_sb);
+
         fid.id = (__u64)dir->i_ino;
         fid.generation = dir->i_generation;
         fid.f_type = S_IFDIR;
@@ -223,11 +265,12 @@ struct dentry *ll_get_parent(struct dentry *dchild)
                 CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino);
                 return ERR_PTR(rc);
         }
-        body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof (*body)); 
-       
+        body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF, sizeof (*body));
+
         LASSERT((body->valid & OBD_MD_FLGENER) && (body->valid & OBD_MD_FLID));
-        
-        result = ll_iget_for_nfs(dir->i_sb, body->ino, body->generation, S_IFDIR);
+        fid.id = body->ino;
+        fid.generation = body->generation;
+        result = ll_iget_for_nfs(dir->i_sb, &fid);
 
         if (IS_ERR(result))
                 rc = PTR_ERR(result);
@@ -236,10 +279,17 @@ struct dentry *ll_get_parent(struct dentry *dchild)
         if (rc)
                 return ERR_PTR(rc);
         RETURN(result);
-} 
+}
 
 struct export_operations lustre_export_operations = {
-       .get_parent = ll_get_parent,
-       .get_dentry = ll_get_dentry, 
-};
+        .encode_fh  = ll_encode_fh,
+        .get_parent = ll_get_parent,
+#ifdef HAVE_FH_TO_DENTRY
+        .fh_to_dentry = ll_fh_to_dentry,
+        .fh_to_parent = ll_fh_to_parent,
+#else
+        .get_dentry = ll_get_dentry,
+        .decode_fh  = ll_decode_fh,
 #endif
+};
+#endif /* THREAD_SIZE >= 8192 */
diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c
index 8a683cd..eb1244e 100644
--- a/lustre/llite/lloop.c
+++ b/lustre/llite/lloop.c
@@ -42,9 +42,6 @@
  * Copyright 1993 by Theodore Ts'o.  Redistribution of this file is
  * permitted under the GNU General Public License.
  *
- * DES encryption plus some minor changes by Werner Almesberger, 30-MAY-1993
- * more DES encryption plus IDEA encryption by Nicholas J. Leon, June 20, 1996
- *
  * Modularized and updated for 1.1.16 kernel - Mitch Dsouza 28th May 1994
  * Adapted for 1.3.59 kernel - Andries Brouwer, 1 Feb 1996
  *
@@ -56,10 +53,6 @@
  *
  * Loadable modules and other fixes by AK, 1998
  *
- * Make real block number available to downstream transfer functions, enables
- * CBC (and relatives) mode encryption requiring unique IVs per data block.
- * Reed H. Petty, rhp at draper.net
- *
  * Maximum number of loop devices now dynamic via max_loop module parameter.
  * Russell Kroll <rkroll at exploits.org> 19990701
  *
@@ -119,7 +112,7 @@
 #include <lustre_lite.h>
 #include "llite_internal.h"
 
-#define LLOOP_MAX_SEGMENTS        PTLRPC_MAX_BRW_PAGES
+#define LLOOP_MAX_SEGMENTS    PTLRPC_MAX_BRW_PAGES
 
 /* Possible states of device */
 enum {
@@ -134,8 +127,8 @@ struct lloop_device {
         loff_t             lo_offset;
         loff_t             lo_sizelimit;
         int                lo_flags;
-        int                (*ioctl)(struct lloop_device *, int cmd, 
-                                 unsigned long arg); 
+        int                (*ioctl)(struct lloop_device *, int cmd,
+                                    unsigned long arg);
 
         struct file *      lo_backing_file;
         struct block_device *lo_device;
@@ -149,17 +142,16 @@ struct lloop_device {
         int                lo_state;
         struct semaphore   lo_sem;
         struct semaphore   lo_ctl_mutex;
-        struct semaphore   lo_bh_mutex;
         atomic_t           lo_pending;
+        wait_queue_head_t  lo_bh_wait;
 
-        request_queue_t    *lo_queue;
+        struct request_queue  *lo_queue;
 
         /* data to handle bio for lustre. */
         struct lo_request_data {
                 struct brw_page    lrd_pages[LLOOP_MAX_SEGMENTS];
                 struct obdo        lrd_oa;
         } lo_requests[1];
-
 };
 
 /*
@@ -169,8 +161,9 @@ enum {
         LO_FLAGS_READ_ONLY       = 1,
 };
 
+#define MAX_LOOP_DEFAULT  16
 static int lloop_major;
-static int max_loop = 8;
+static int max_loop = MAX_LOOP_DEFAULT;
 static struct lloop_device *loop_dev;
 static struct gendisk **disks;
 static struct semaphore lloop_mutex;
@@ -194,7 +187,7 @@ static loff_t get_loop_size(struct lloop_device *lo, struct file *file)
         return loopsize >> 9;
 }
 
-static int do_bio_filebacked(struct lloop_device *lo, struct bio *bio)
+static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head)
 {
         struct inode *inode = lo->lo_backing_file->f_dentry->d_inode;
         struct ll_inode_info *lli = ll_i2info(inode);
@@ -203,42 +196,51 @@ static int do_bio_filebacked(struct lloop_device *lo, struct bio *bio)
         struct brw_page *pg = lo->lo_requests[0].lrd_pages;
         struct obdo *oa = &lo->lo_requests[0].lrd_oa;
         pgoff_t offset;
-        int ret, cmd, i;
+        int ret, i, rw;
+        obd_count page_count = 0;
         struct bio_vec *bvec;
+        struct bio *bio;
+
+        LASSERT(head != NULL);
 
-        BUG_ON(bio->bi_hw_segments > LLOOP_MAX_SEGMENTS);
+        rw = head->bi_rw;
+        for (bio = head; bio != NULL; bio = bio->bi_next) {
+                LASSERT(rw == bio->bi_rw);
 
-        offset = (pgoff_t)(bio->bi_sector << 9) + lo->lo_offset;
-        bio_for_each_segment(bvec, bio, i) {
-                BUG_ON(bvec->bv_offset != 0);
-                BUG_ON(bvec->bv_len != CFS_PAGE_SIZE);
+                offset = (pgoff_t)(bio->bi_sector << 9) + lo->lo_offset;
+                bio_for_each_segment(bvec, bio, i) {
+                        BUG_ON(bvec->bv_offset != 0);
+                        BUG_ON(bvec->bv_len != CFS_PAGE_SIZE);
 
-                pg->pg = bvec->bv_page;
-                pg->off = offset;
-                pg->count = bvec->bv_len;
-                pg->flag = OBD_BRW_SRVLOCK;
+                        pg->pg = bvec->bv_page;
+                        pg->off = offset;
+                        pg->count = bvec->bv_len;
+                        pg->flag = OBD_BRW_SRVLOCK;
 
-                pg++;
-                offset += bvec->bv_len;
+                        CDEBUG(D_INFO, "index %lu offset "LPU64", count %u\n",
+                               pg->pg->index, pg->off, pg->count);
+                        pg++;
+                        page_count++;
+                        offset += bvec->bv_len;
+                }
+                LASSERT(page_count <= LLOOP_MAX_SEGMENTS);
         }
 
+        ll_stats_ops_tally(ll_i2sbi(inode),
+                        (rw == WRITE) ? LPROC_LL_BRW_WRITE : LPROC_LL_BRW_READ,
+                        page_count << PAGE_CACHE_SHIFT);
+
         oa->o_mode = inode->i_mode;
         oa->o_id = lsm->lsm_object_id;
-        oa->o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLTYPE;
+        oa->o_gr = lsm->lsm_object_gr;
+        oa->o_valid = OBD_MD_FLID   | OBD_MD_FLGROUP |
+                      OBD_MD_FLMODE | OBD_MD_FLTYPE;
         obdo_from_inode(oa, inode, OBD_MD_FLFID | OBD_MD_FLGENER);
 
-        cmd = OBD_BRW_READ;
-        if (bio_rw(bio) == WRITE)
-                cmd = OBD_BRW_WRITE;
-
-        if (cmd == OBD_BRW_WRITE)
-                ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_BRW_WRITE, bio->bi_size);
-        else
-                ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_BRW_READ, bio->bi_size);
         oinfo.oi_oa = oa;
         oinfo.oi_md = lsm;
-        ret = obd_brw(cmd, ll_i2obdexp(inode), &oinfo, 
-                      (obd_count)(i - bio->bi_idx), 
+        ret = obd_brw((rw == WRITE) ? OBD_BRW_WRITE : OBD_BRW_READ,
+                      ll_i2obdexp(inode), &oinfo, (obd_count)page_count,
                       lo->lo_requests[0].lrd_pages, NULL);
         if (ret == 0)
                 obdo_to_inode(inode, oa, OBD_MD_FLBLOCKS);
@@ -261,41 +263,77 @@ static void loop_add_bio(struct lloop_device *lo, struct bio *bio)
                 lo->lo_bio = lo->lo_biotail = bio;
         spin_unlock_irqrestore(&lo->lo_lock, flags);
 
-        up(&lo->lo_bh_mutex);
+        atomic_inc(&lo->lo_pending);
+        if (waitqueue_active(&lo->lo_bh_wait))
+                wake_up(&lo->lo_bh_wait);
 }
 
 /*
  * Grab first pending buffer
  */
-static struct bio *loop_get_bio(struct lloop_device *lo)
+static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req)
 {
-        struct bio *bio;
+        struct bio *first;
+        struct bio **bio;
+        unsigned int count = 0;
+        unsigned int page_count = 0;
+        int rw;
 
         spin_lock_irq(&lo->lo_lock);
-        if ((bio = lo->lo_bio)) {
-                if (bio == lo->lo_biotail)
-                        lo->lo_biotail = NULL;
-                lo->lo_bio = bio->bi_next;
-                bio->bi_next = NULL;
+        first = lo->lo_bio;
+        if (unlikely(first == NULL)) {
+                spin_unlock_irq(&lo->lo_lock);
+                return 0;
         }
-        spin_unlock_irq(&lo->lo_lock);
 
-        return bio;
+        /* TODO: need to split the bio, too bad. */
+        LASSERT(first->bi_vcnt <= LLOOP_MAX_SEGMENTS);
+
+        rw = first->bi_rw;
+        bio = &lo->lo_bio;
+        while (*bio && (*bio)->bi_rw == rw) {
+                CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u \n",
+                       (unsigned long long)(*bio)->bi_sector, (*bio)->bi_size,
+                       page_count, (*bio)->bi_vcnt);
+                if (page_count + (*bio)->bi_vcnt > LLOOP_MAX_SEGMENTS)
+                        break;
+
+
+                page_count += (*bio)->bi_vcnt;
+                count++;
+                bio = &(*bio)->bi_next;
+        }
+        if (*bio) {
+                /* Some of bios can't be mergable. */
+                lo->lo_bio = *bio;
+                *bio = NULL;
+        } else {
+                /* Hit the end of queue */
+                lo->lo_biotail = NULL;
+                lo->lo_bio = NULL;
+        }
+        *req = first;
+        spin_unlock_irq(&lo->lo_lock);
+        return count;
 }
 
-static int loop_make_request(request_queue_t *q, struct bio *old_bio)
+static int loop_make_request(struct request_queue *q, struct bio *old_bio)
 {
         struct lloop_device *lo = q->queuedata;
         int rw = bio_rw(old_bio);
+        int inactive;
 
         if (!lo)
-                goto out;
+                goto err;
+
+        CDEBUG(D_INFO, "submit bio sector %llu size %u\n",
+               (unsigned long long)old_bio->bi_sector, old_bio->bi_size);
 
         spin_lock_irq(&lo->lo_lock);
-        if (lo->lo_state != LLOOP_BOUND)
-                goto inactive;
-        atomic_inc(&lo->lo_pending);
+        inactive = (lo->lo_state != LLOOP_BOUND);
         spin_unlock_irq(&lo->lo_lock);
+        if (inactive)
+                goto err;
 
         if (rw == WRITE) {
                 if (lo->lo_flags & LO_FLAGS_READ_ONLY)
@@ -309,20 +347,14 @@ static int loop_make_request(request_queue_t *q, struct bio *old_bio)
         loop_add_bio(lo, old_bio);
         return 0;
 err:
-        if (atomic_dec_and_test(&lo->lo_pending))
-                up(&lo->lo_bh_mutex);
-out:
-        bio_io_error(old_bio, old_bio->bi_size);
+        cfs_bio_io_error(old_bio, old_bio->bi_size);
         return 0;
-inactive:
-        spin_unlock_irq(&lo->lo_lock);
-        goto out;
 }
 
 /*
  * kick off io on the underlying address space
  */
-static void loop_unplug(request_queue_t *q)
+static void loop_unplug(struct request_queue *q)
 {
         struct lloop_device *lo = q->queuedata;
 
@@ -333,27 +365,37 @@ static void loop_unplug(request_queue_t *q)
 static inline void loop_handle_bio(struct lloop_device *lo, struct bio *bio)
 {
         int ret;
-        ret = do_bio_filebacked(lo, bio);
-        bio_endio(bio, bio->bi_size, ret);
+        ret = do_bio_lustrebacked(lo, bio);
+        while (bio) {
+                struct bio *tmp = bio->bi_next;
+                bio->bi_next = NULL;
+                cfs_bio_endio(bio, bio->bi_size, ret);
+                bio = tmp;
+        }
+}
+
+static inline int loop_active(struct lloop_device *lo)
+{
+        return atomic_read(&lo->lo_pending) || (lo->lo_state == LLOOP_RUNDOWN);
 }
 
 /*
  * worker thread that handles reads/writes to file backed loop devices,
- * to avoid blocking in our make_request_fn. it also does loop decrypting
- * on reads for block backed loop, as that is too heavy to do from
- * b_end_io context where irqs may be disabled.
+ * to avoid blocking in our make_request_fn.
  */
 static int loop_thread(void *data)
 {
         struct lloop_device *lo = data;
         struct bio *bio;
+        unsigned int count;
+        unsigned long times = 0;
+        unsigned long total_count = 0;
 
         daemonize("lloop%d", lo->lo_number);
 
         set_user_nice(current, -20);
 
         lo->lo_state = LLOOP_BOUND;
-        atomic_inc(&lo->lo_pending);
 
         /*
          * up sem, we are running
@@ -361,27 +403,39 @@ static int loop_thread(void *data)
         up(&lo->lo_sem);
 
         for (;;) {
-                down_interruptible(&lo->lo_bh_mutex);
-                /*
-                 * could be upped because of tear-down, not because of
-                 * pending work
-                 */
-                if (!atomic_read(&lo->lo_pending))
-                        break;
+                wait_event(lo->lo_bh_wait, loop_active(lo));
+                if (!atomic_read(&lo->lo_pending)) {
+                        int exiting = 0;
+                        spin_lock_irq(&lo->lo_lock);
+                        exiting = (lo->lo_state == LLOOP_RUNDOWN);
+                        spin_unlock_irq(&lo->lo_lock);
+                        if (exiting)
+                                break;
+                }
 
-                bio = loop_get_bio(lo);
-                if (!bio) {
+                bio = NULL;
+                count = loop_get_bio(lo, &bio);
+                if (!count) {
                         CWARN("lloop(minor: %d): missing bio\n", lo->lo_number);
                         continue;
                 }
-                loop_handle_bio(lo, bio);
 
-                /*
-                 * upped both for pending work and tear-down, lo_pending
-                 * will hit zero then
-                 */
-                if (atomic_dec_and_test(&lo->lo_pending))
-                        break;
+                total_count += count;
+                if (total_count < count) {      /* overflow */
+                        total_count = count;
+                        times = 1;
+                } else {
+                        times++;
+                }
+                if ((times & 127) == 0) {
+                        CDEBUG(D_INFO, "total: %lu, count: %lu, avg: %lu\n",
+                               total_count, times, total_count / times);
+                }
+
+                LASSERT(bio != NULL);
+                LASSERT(count <= atomic_read(&lo->lo_pending));
+                loop_handle_bio(lo, bio);
+                atomic_sub(count, &lo->lo_pending);
         }
 
         up(&lo->lo_sem);
@@ -391,10 +445,10 @@ static int loop_thread(void *data)
 static int loop_set_fd(struct lloop_device *lo, struct file *unused,
                        struct block_device *bdev, struct file *file)
 {
-        struct inode        *inode;
+        struct inode         *inode;
         struct address_space *mapping;
-        int                lo_flags = 0;
-        int                error;
+        int                   lo_flags = 0;
+        int                   error;
         loff_t                size;
 
         if (!try_module_get(THIS_MODULE))
@@ -447,8 +501,10 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
 
         /* queue parameters */
         blk_queue_hardsect_size(lo->lo_queue, CFS_PAGE_SIZE);
-        blk_queue_max_sectors(lo->lo_queue, LLOOP_MAX_SEGMENTS);
+        blk_queue_max_sectors(lo->lo_queue,
+                              LLOOP_MAX_SEGMENTS << (CFS_PAGE_SHIFT - 9));
         blk_queue_max_phys_segments(lo->lo_queue, LLOOP_MAX_SEGMENTS);
+        blk_queue_max_hw_segments(lo->lo_queue, LLOOP_MAX_SEGMENTS);
 
         set_capacity(disks[lo->lo_number], size);
         bd_set_size(bdev, size << 9);
@@ -465,7 +521,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
         return error;
 }
 
-static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, 
+static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
                        int count)
 {
         struct file *filp = lo->lo_backing_file;
@@ -482,9 +538,8 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev,
 
         spin_lock_irq(&lo->lo_lock);
         lo->lo_state = LLOOP_RUNDOWN;
-        if (atomic_dec_and_test(&lo->lo_pending))
-                up(&lo->lo_bh_mutex);
         spin_unlock_irq(&lo->lo_lock);
+        wake_up(&lo->lo_bh_wait);
 
         down(&lo->lo_sem);
         lo->lo_backing_file = NULL;
@@ -527,8 +582,8 @@ static int lo_release(struct inode *inode, struct file *file)
 }
 
 /* lloop device node's ioctl function. */
-static int lo_ioctl(struct inode *inode, struct file *unused, 
-        unsigned int cmd, unsigned long arg)
+static int lo_ioctl(struct inode *inode, struct file *unused,
+                    unsigned int cmd, unsigned long arg)
 {
         struct lloop_device *lo = inode->i_bdev->bd_disk->private_data;
         struct block_device *bdev = inode->i_bdev;
@@ -551,7 +606,7 @@ static int lo_ioctl(struct inode *inode, struct file *unused,
 
                 if (put_user(ino, (__u64 *)arg))
                         err = -EFAULT;
-                break; 
+                break;
         }
 
         default:
@@ -570,15 +625,16 @@ static struct block_device_operations lo_fops = {
         .ioctl =        lo_ioctl,
 };
 
-/* dynamic iocontrol callback. 
- * This callback is registered in lloop_init and will be called by 
- * ll_iocontrol_call. 
- * This is a llite regular file ioctl function. It takes the responsibility 
- * of attaching a file, and detaching a file by a lloop's device numner. 
+/* dynamic iocontrol callback.
+ * This callback is registered in lloop_init and will be called by
+ * ll_iocontrol_call.
+ *
+ * This is a llite regular file ioctl function. It takes the responsibility
+ * of attaching a file, and detaching a file by a lloop's device numner.
  */
-static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, 
-                unsigned int cmd, unsigned long arg,
-                void *magic, int *rcp)
+static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
+                                   unsigned int cmd, unsigned long arg,
+                                   void *magic, int *rcp)
 {
         struct lloop_device *lo = NULL;
         struct block_device *bdev = NULL;
@@ -604,7 +660,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
                                         lo_free = lo;
                                 continue;
                         }
-                        if (lo->lo_backing_file->f_dentry->d_inode == 
+                        if (lo->lo_backing_file->f_dentry->d_inode ==
                             file->f_dentry->d_inode)
                                 break;
                 }
@@ -634,7 +690,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file,
 
         case LL_IOC_LLOOP_DETACH_BYDEV: {
                 int minor;
-                
+
                 dev = old_decode_dev(arg);
                 if (MAJOR(dev) != lloop_major)
                         GOTO(out, err = -EINVAL);
@@ -677,25 +733,27 @@ static int __init lloop_init(void)
         };
 
         if (max_loop < 1 || max_loop > 256) {
+                max_loop = MAX_LOOP_DEFAULT;
                 CWARN("lloop: invalid max_loop (must be between"
-                      " 1 and 256), using default (8)\n");
-                max_loop = 8;
+                      " 1 and 256), using default (%u)\n", max_loop);
         }
 
         lloop_major = register_blkdev(0, "lloop");
         if (lloop_major < 0)
                 return -EIO;
 
+        CDEBUG(D_CONFIG, "registered lloop major %d with %u minors\n",
+               lloop_major, max_loop);
+
         ll_iocontrol_magic = ll_iocontrol_register(lloop_ioctl, 2, cmdlist);
         if (ll_iocontrol_magic == NULL)
                 goto out_mem1;
 
-        loop_dev = kmalloc(max_loop * sizeof(struct lloop_device), GFP_KERNEL);
+        OBD_ALLOC_WAIT(loop_dev, max_loop * sizeof(*loop_dev));
         if (!loop_dev)
                 goto out_mem1;
-        memset(loop_dev, 0, max_loop * sizeof(struct lloop_device));
 
-        disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL);
+        OBD_ALLOC_WAIT(disks, max_loop * sizeof(*disks));
         if (!disks)
                 goto out_mem2;
 
@@ -711,14 +769,13 @@ static int __init lloop_init(void)
                 struct lloop_device *lo = &loop_dev[i];
                 struct gendisk *disk = disks[i];
 
-                memset(lo, 0, sizeof(*lo));
                 lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
                 if (!lo->lo_queue)
                         goto out_mem4;
 
                 init_MUTEX(&lo->lo_ctl_mutex);
                 init_MUTEX_LOCKED(&lo->lo_sem);
-                init_MUTEX_LOCKED(&lo->lo_bh_mutex);
+                init_waitqueue_head(&lo->lo_bh_wait);
                 lo->lo_number = i;
                 spin_lock_init(&lo->lo_lock);
                 disk->major = lloop_major;
@@ -736,14 +793,14 @@ static int __init lloop_init(void)
 
 out_mem4:
         while (i--)
-                blk_put_queue(loop_dev[i].lo_queue);
+                blk_cleanup_queue(loop_dev[i].lo_queue);
         i = max_loop;
 out_mem3:
         while (i--)
                 put_disk(disks[i]);
-        kfree(disks);
+        OBD_FREE(disks, max_loop * sizeof(*disks));
 out_mem2:
-        kfree(loop_dev);
+        OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
 out_mem1:
         unregister_blkdev(lloop_major, "lloop");
         ll_iocontrol_unregister(ll_iocontrol_magic);
@@ -758,14 +815,16 @@ static void lloop_exit(void)
         ll_iocontrol_unregister(ll_iocontrol_magic);
         for (i = 0; i < max_loop; i++) {
                 del_gendisk(disks[i]);
-                blk_put_queue(loop_dev[i].lo_queue);
+                blk_cleanup_queue(loop_dev[i].lo_queue);
                 put_disk(disks[i]);
         }
         if (ll_unregister_blkdev(lloop_major, "lloop"))
                 CWARN("lloop: cannot unregister blkdev\n");
+        else
+                CDEBUG(D_CONFIG, "unregistered lloop major %d\n", lloop_major);
 
-        kfree(disks);
-        kfree(loop_dev);
+        OBD_FREE(disks, max_loop * sizeof(*disks));
+        OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
 }
 
 module_init(lloop_init);
diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c
index 84298b0..9daf6d4 100644
--- a/lustre/llite/lproc_llite.c
+++ b/lustre/llite/lproc_llite.c
@@ -48,7 +48,6 @@ struct proc_dir_entry *proc_lustre_fs_root;
 #ifdef LPROCFS
 /* /proc/lustre/llite mount point registration */
 struct file_operations llite_dump_pgcache_fops;
-struct file_operations ll_ra_stats_fops;
 struct file_operations ll_rw_extents_stats_fops;
 struct file_operations ll_rw_extents_stats_pp_fops;
 struct file_operations ll_rw_offset_stats_fops;
@@ -237,6 +236,48 @@ static int ll_wr_max_readahead_mb(struct file *file, const char *buffer,
         return count;
 }
 
+static int ll_rd_max_readahead_per_file_mb(char *page, char **start, off_t off,
+                                          int count, int *eof, void *data)
+{
+        struct super_block *sb = data;
+        struct ll_sb_info *sbi = ll_s2sbi(sb);
+        long pages_number;
+        int mult;
+
+        spin_lock(&sbi->ll_lock);
+        pages_number = sbi->ll_ra_info.ra_max_pages_per_file;
+        spin_unlock(&sbi->ll_lock);
+
+        mult = 1 << (20 - CFS_PAGE_SHIFT);
+        return lprocfs_read_frac_helper(page, count, pages_number, mult);
+}
+
+static int ll_wr_max_readahead_per_file_mb(struct file *file, const char *buffer,
+                                          unsigned long count, void *data)
+{
+        struct super_block *sb = data;
+        struct ll_sb_info *sbi = ll_s2sbi(sb);
+        int mult, rc, pages_number;
+
+        mult = 1 << (20 - CFS_PAGE_SHIFT);
+        rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+        if (rc)
+                return rc;
+
+        if (pages_number < 0 ||
+                pages_number > sbi->ll_ra_info.ra_max_pages) {
+                CERROR("can't set file readahead more than"
+                       "max_read_ahead_mb %lu MB\n", sbi->ll_ra_info.ra_max_pages);
+                return -ERANGE;
+        }
+
+        spin_lock(&sbi->ll_lock);
+        sbi->ll_ra_info.ra_max_pages_per_file = pages_number;
+        spin_unlock(&sbi->ll_lock);
+
+        return count;
+}
+
 static int ll_rd_max_read_ahead_whole_mb(char *page, char **start, off_t off,
                                        int count, int *eof, void *data)
 {
@@ -267,10 +308,11 @@ static int ll_wr_max_read_ahead_whole_mb(struct file *file, const char *buffer,
 
         /* Cap this at the current max readahead window size, the readahead
          * algorithm does this anyway so it's pointless to set it larger. */
-        if (pages_number < 0 || pages_number > sbi->ll_ra_info.ra_max_pages) {
+        if (pages_number < 0 ||
+            pages_number > sbi->ll_ra_info.ra_max_pages_per_file) {
                 CERROR("can't set max_read_ahead_whole_mb more than "
-                       "max_read_ahead_mb: %lu\n",
-                       sbi->ll_ra_info.ra_max_pages >> (20 - CFS_PAGE_SHIFT));
+                       "max_read_ahead_per_file_mb: %lu\n",
+                        sbi->ll_ra_info.ra_max_pages_per_file >> (20 - CFS_PAGE_SHIFT));
                 return -ERANGE;
         }
 
@@ -302,7 +344,8 @@ static int ll_wr_max_cached_mb(struct file *file, const char *buffer,
 {
         struct super_block *sb = data;
         struct ll_sb_info *sbi = ll_s2sbi(sb);
-        int mult, rc, pages_number;
+        unsigned long budget;
+        int mult, rc, pages_number, cpu;
 
         mult = 1 << (20 - CFS_PAGE_SHIFT);
         rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
@@ -323,12 +366,47 @@ static int ll_wr_max_cached_mb(struct file *file, const char *buffer,
                 /* Not set up yet, don't call llap_shrink_cache */
                 return count;
 
-        if (sbi->ll_async_page_count >= sbi->ll_async_page_max)
-                llap_shrink_cache(sbi, 0);
+        spin_lock(&sbi->ll_async_page_reblnc_lock);
+        budget = sbi->ll_async_page_max / num_online_cpus();
+        for_each_online_cpu(cpu)
+                LL_PGLIST_DATA_CPU(sbi, cpu)->llpd_budget = budget;
+        spin_unlock(&sbi->ll_async_page_reblnc_lock);
+
+        if (lcounter_read_positive(&sbi->ll_async_page_count) >=
+            sbi->ll_async_page_max)
+                llap_shrink_cache(sbi, -1);
 
         return count;
 }
 
+static int ll_rd_pgcache_balance(char *page, char **start, off_t off,
+                                 int count, int *eof, void *data)
+{
+        struct super_block *sb = data;
+        struct ll_sb_info *sbi = ll_s2sbi(sb);
+        struct ll_pglist_data *pd;
+        unsigned long total_budget = 0;
+        int n = 0, cpu;
+
+        n += snprintf(page +n, count - n, "cpu\tpage count\tbudget"
+                      "\t\treblnc count\tgen\thit\tmiss\tcross\n");
+        for_each_online_cpu(cpu) {
+                pd = LL_PGLIST_DATA_CPU(sbi, cpu);
+                n += snprintf(page + n, count - n,
+                              "%d\t%-8lu\t%-8lu\t%-8lu\t%lu\t%lu\t%lu\t%lu\n",
+                              cpu, pd->llpd_count, pd->llpd_budget,
+                              pd->llpd_reblnc_count, pd->llpd_gen,
+                              pd->llpd_hit, pd->llpd_miss, pd->llpd_cross);
+                total_budget += pd->llpd_budget;
+        }
+        n += snprintf(page + n, count - n,
+                      "Total budget: %lu, page max: %lu, rebalance cnt: %lu\n",
+                      total_budget, sbi->ll_async_page_max,
+                      sbi->ll_async_page_reblnc_count);
+        *eof = 1;
+        return n;
+}
+
 static int ll_rd_checksum(char *page, char **start, off_t off,
                           int count, int *eof, void *data)
 {
@@ -548,6 +626,35 @@ static int ll_rd_statahead_stats(char *page, char **start, off_t off,
                         sbi->ll_sa_miss);
 }
 
+static int ll_rd_lazystatfs(char *page, char **start, off_t off,
+                            int count, int *eof, void *data)
+{
+        struct super_block *sb = data;
+        struct ll_sb_info *sbi = ll_s2sbi(sb);
+
+        return snprintf(page, count, "%u\n",
+                        (sbi->ll_flags & LL_SBI_LAZYSTATFS) ? 1 : 0);
+}
+
+static int ll_wr_lazystatfs(struct file *file, const char *buffer,
+                            unsigned long count, void *data)
+{
+        struct super_block *sb = data;
+        struct ll_sb_info *sbi = ll_s2sbi(sb);
+        int val, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        if (val)
+                sbi->ll_flags |= LL_SBI_LAZYSTATFS;
+        else
+                sbi->ll_flags &= ~LL_SBI_LAZYSTATFS;
+
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
         { "uuid",         ll_rd_sb_uuid,          0, 0 },
         //{ "mntpt_path",   ll_rd_path,             0, 0 },
@@ -561,9 +668,12 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
         //{ "filegroups",   lprocfs_rd_filegroups,  0, 0 },
         { "max_read_ahead_mb", ll_rd_max_readahead_mb,
                                ll_wr_max_readahead_mb, 0 },
+        { "max_read_ahead_per_file_mb", ll_rd_max_readahead_per_file_mb,
+                                        ll_wr_max_readahead_per_file_mb, 0 },
         { "max_read_ahead_whole_mb", ll_rd_max_read_ahead_whole_mb,
                                      ll_wr_max_read_ahead_whole_mb, 0 },
         { "max_cached_mb",  ll_rd_max_cached_mb, ll_wr_max_cached_mb, 0 },
+        { "pgcache_balance",ll_rd_pgcache_balance, 0, 0 },
         { "checksum_pages", ll_rd_checksum, ll_wr_checksum, 0 },
         { "max_rw_chunk",   ll_rd_max_rw_chunk, ll_wr_max_rw_chunk, 0 },
         { "stats_track_pid",  ll_rd_track_pid, ll_wr_track_pid, 0 },
@@ -575,6 +685,7 @@ static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
                                ll_wr_lockless_truncate, 0},
         { "statahead_max",      ll_rd_statahead_max, ll_wr_statahead_max, 0 },
         { "statahead_stats",    ll_rd_statahead_stats, 0, 0 },
+        { "lazystatfs",         ll_rd_lazystatfs, ll_wr_lazystatfs, 0 },
         { 0 }
 };
 
@@ -664,6 +775,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
         char name[MAX_STRING_SIZE + 1], *ptr;
         int err, id, len;
         struct proc_dir_entry *entry;
+        static const char *ra_stats_string[] = LL_RA_STAT_STRINGS;
         ENTRY;
 
         memset(lvars, 0, sizeof(lvars));
@@ -698,11 +810,13 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
         entry->proc_fops = &llite_dump_pgcache_fops;
         entry->data = sbi;
 
-        entry = create_proc_entry("read_ahead_stats", 0644, sbi->ll_proc_root);
-        if (entry == NULL)
-                GOTO(out, err = -ENOMEM);
-        entry->proc_fops = &ll_ra_stats_fops;
-        entry->data = sbi;
+        sbi->ll_ra_stats = lprocfs_alloc_stats(LL_RA_STAT,
+                                               LPROCFS_STATS_FLAG_NONE);
+        for (id = 0; id < LL_RA_STAT; id++)
+                lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
+                        ra_stats_string[id], "pages");
+        lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats",
+                sbi->ll_ra_stats);
 
         entry = create_proc_entry("extents_stats", 0644, sbi->ll_proc_root);
         if (entry == NULL)
@@ -725,7 +839,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
 
         /* File operations stats */
         sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES,
-                                            LPROCFS_STATS_FLAG_PERCPU);
+                                            LPROCFS_STATS_FLAG_NONE);
         if (sbi->ll_stats == NULL)
                 GOTO(out, err = -ENOMEM);
         /* do counter init */
@@ -800,6 +914,7 @@ void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi)
 {
         if (sbi->ll_proc_root) {
                 lprocfs_remove(&sbi->ll_proc_root);
+                lprocfs_free_stats(&sbi->ll_ra_stats);
                 lprocfs_free_stats(&sbi->ll_stats);
         }
 }
@@ -829,6 +944,8 @@ static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
 {
         struct ll_async_page *llap, *dummy_llap = seq->private;
         struct ll_sb_info *sbi = dummy_llap->llap_cookie;
+        struct ll_pglist_data *pd;
+        int cpu = dummy_llap->llap_pglist_cpu;
 
         /* 2.4 doesn't seem to have SEQ_START_TOKEN, so we implement
          * it in our own state */
@@ -838,19 +955,23 @@ static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
                 return 0;
         }
 
-        spin_lock(&sbi->ll_lock);
-
-        llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_pglist_item);
+        pd = ll_pglist_cpu_lock(sbi, cpu);
+        llap = llite_pglist_next_llap(&pd->llpd_list,
+                                      &dummy_llap->llap_pglist_item);
         if (llap != NULL)  {
-                int has_flags = 0;
+                int has_flags = 0, i;
                 struct page *page = llap->llap_page;
+                unsigned long gen = 0UL;
 
                 LASSERTF(llap->llap_origin < LLAP__ORIGIN_MAX, "%u\n",
                          llap->llap_origin);
 
+                for_each_online_cpu(i)
+                         gen += LL_PGLIST_DATA_CPU(sbi, i)->llpd_gen;
+
                 seq_printf(seq," %5lu | %p %p %s %s %s %s | %p %lu/%u(%p) "
                            "%lu %u [",
-                           sbi->ll_pglist_gen,
+                           gen,
                            llap, llap->llap_cookie,
                            llap_origins[llap->llap_origin],
                            llap->llap_write_queued ? "wq" : "- ",
@@ -874,8 +995,7 @@ static int llite_dump_pgcache_seq_show(struct seq_file *seq, void *v)
                 else
                         seq_puts(seq, "]\n");
         }
-
-        spin_unlock(&sbi->ll_lock);
+        ll_pglist_cpu_unlock(sbi, cpu);
 
         return 0;
 }
@@ -885,6 +1005,8 @@ static void *llite_dump_pgcache_seq_next(struct seq_file *seq, void *v,
 {
         struct ll_async_page *llap, *dummy_llap = seq->private;
         struct ll_sb_info *sbi = dummy_llap->llap_cookie;
+        struct ll_pglist_data *pd, *next;
+        int cpu = dummy_llap->llap_pglist_cpu;
 
         /* bail if we just displayed the banner */
         if (dummy_llap->llap_magic == 0) {
@@ -895,14 +1017,35 @@ static void *llite_dump_pgcache_seq_next(struct seq_file *seq, void *v,
         /* we've just displayed the llap that is after us in the list.
          * we advance to a position beyond it, returning null if there
          * isn't another llap in the list beyond that new position. */
-        spin_lock(&sbi->ll_lock);
-        llap = llite_pglist_next_llap(sbi, &dummy_llap->llap_pglist_item);
+        pd = ll_pglist_cpu_lock(sbi, cpu);
+        llap = llite_pglist_next_llap(&pd->llpd_list,
+                        &dummy_llap->llap_pglist_item);
         list_del_init(&dummy_llap->llap_pglist_item);
         if (llap) {
                 list_add(&dummy_llap->llap_pglist_item,&llap->llap_pglist_item);
-                llap =llite_pglist_next_llap(sbi,&dummy_llap->llap_pglist_item);
+                llap = llite_pglist_next_llap(&pd->llpd_list,
+                                &dummy_llap->llap_pglist_item);
         }
-        spin_unlock(&sbi->ll_lock);
+        if (llap == NULL) {
+                int i = cpu + 1;
+                for (next = NULL; i < num_possible_cpus(); i++, next = NULL) {
+                        next = ll_pglist_cpu_lock(sbi, i);
+                        if (!list_empty(&next->llpd_list))
+                                break;
+                        ll_pglist_cpu_unlock(sbi, i);
+                }
+                if (next != NULL) {
+                        list_move(&dummy_llap->llap_pglist_item,
+                                  &next->llpd_list);
+                        dummy_llap->llap_pglist_cpu = i;
+                        ll_pglist_cpu_unlock(sbi, cpu);
+                        llap = llite_pglist_next_llap(&next->llpd_list,
+                                        &dummy_llap->llap_pglist_item);
+                        LASSERT(llap);
+                        cpu = i;
+                }
+        }
+        ll_pglist_cpu_unlock(sbi, cpu);
 
         ++*pos;
         if (llap == NULL) {
@@ -940,6 +1083,7 @@ static int llite_dump_pgcache_seq_open(struct inode *inode, struct file *file)
         struct ll_async_page *dummy_llap;
         struct seq_file *seq;
         struct ll_sb_info *sbi = dp->data;
+        struct ll_pglist_data *pd;
         int rc = -ENOMEM;
 
         LPROCFS_ENTRY_AND_CHECK(dp);
@@ -951,6 +1095,7 @@ static int llite_dump_pgcache_seq_open(struct inode *inode, struct file *file)
         dummy_llap->llap_page = NULL;
         dummy_llap->llap_cookie = sbi;
         dummy_llap->llap_magic = 0;
+        dummy_llap->llap_pglist_cpu = 0;
 
         rc = seq_open(file, &llite_dump_pgcache_seq_sops);
         if (rc) {
@@ -960,9 +1105,9 @@ static int llite_dump_pgcache_seq_open(struct inode *inode, struct file *file)
         seq = file->private_data;
         seq->private = dummy_llap;
 
-        spin_lock(&sbi->ll_lock);
-        list_add(&dummy_llap->llap_pglist_item, &sbi->ll_pglist);
-        spin_unlock(&sbi->ll_lock);
+        pd = ll_pglist_cpu_lock(sbi, 0);
+        list_add(&dummy_llap->llap_pglist_item, &pd->llpd_list);
+        ll_pglist_cpu_unlock(sbi, 0);
 
 out:
         if (rc)
@@ -976,11 +1121,12 @@ static int llite_dump_pgcache_seq_release(struct inode *inode,
         struct seq_file *seq = file->private_data;
         struct ll_async_page *dummy_llap = seq->private;
         struct ll_sb_info *sbi = dummy_llap->llap_cookie;
+        int cpu = dummy_llap->llap_pglist_cpu;
 
-        spin_lock(&sbi->ll_lock);
+        ll_pglist_cpu_lock(sbi, cpu);
         if (!list_empty(&dummy_llap->llap_pglist_item))
                 list_del_init(&dummy_llap->llap_pglist_item);
-        spin_unlock(&sbi->ll_lock);
+        ll_pglist_cpu_unlock(sbi, cpu);
         OBD_FREE(dummy_llap, sizeof(*dummy_llap));
 
         return lprocfs_seq_release(inode, file);
@@ -993,61 +1139,6 @@ struct file_operations llite_dump_pgcache_fops = {
         .release = llite_dump_pgcache_seq_release,
 };
 
-static int ll_ra_stats_seq_show(struct seq_file *seq, void *v)
-{
-        struct timeval now;
-        struct ll_sb_info *sbi = seq->private;
-        struct ll_ra_info *ra = &sbi->ll_ra_info;
-        int i;
-        static char *ra_stat_strings[] = {
-                [RA_STAT_HIT] = "hits",
-                [RA_STAT_MISS] = "misses",
-                [RA_STAT_DISTANT_READPAGE] = "readpage not consecutive",
-                [RA_STAT_MISS_IN_WINDOW] = "miss inside window",
-                [RA_STAT_FAILED_GRAB_PAGE] = "failed grab_cache_page",
-                [RA_STAT_FAILED_MATCH] = "failed lock match",
-                [RA_STAT_DISCARDED] = "read but discarded",
-                [RA_STAT_ZERO_LEN] = "zero length file",
-                [RA_STAT_ZERO_WINDOW] = "zero size window",
-                [RA_STAT_EOF] = "read-ahead to EOF",
-                [RA_STAT_MAX_IN_FLIGHT] = "hit max r-a issue",
-                [RA_STAT_WRONG_GRAB_PAGE] = "wrong page from grab_cache_page",
-        };
-
-        do_gettimeofday(&now);
-
-        spin_lock(&sbi->ll_lock);
-
-        seq_printf(seq, "snapshot_time:         %lu.%lu (secs.usecs)\n",
-                   now.tv_sec, now.tv_usec);
-        seq_printf(seq, "pending issued pages:           %lu\n",
-                   ra->ra_cur_pages);
-
-        for(i = 0; i < _NR_RA_STAT; i++)
-                seq_printf(seq, "%-25s %lu\n", ra_stat_strings[i],
-                           ra->ra_stats[i]);
-
-        spin_unlock(&sbi->ll_lock);
-
-        return 0;
-}
-
-static ssize_t ll_ra_stats_seq_write(struct file *file, const char *buf,
-                                       size_t len, loff_t *off)
-{
-        struct seq_file *seq = file->private_data;
-        struct ll_sb_info *sbi = seq->private;
-        struct ll_ra_info *ra = &sbi->ll_ra_info;
-
-        spin_lock(&sbi->ll_lock);
-        memset(ra->ra_stats, 0, sizeof(ra->ra_stats));
-        spin_unlock(&sbi->ll_lock);
-
-        return len;
-}
-
-LPROC_SEQ_FOPS(ll_ra_stats);
-
 #define pct(a,b) (b ? a * 100 / b : 0)
 
 static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
@@ -1242,7 +1333,7 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct file
         if (cur == -1) {
                 /* new process */
                 sbi->ll_extent_process_count =
-                        (sbi->ll_extent_process_count + 1) % LL_PROCESS_HIST_MAX;
+                        (sbi->ll_extent_process_count+1) % LL_PROCESS_HIST_MAX;
                 cur = sbi->ll_extent_process_count;
                 io_extents->pp_extents[cur].pid = pid;
                 lprocfs_oh_clear(&io_extents->pp_extents[cur].pp_r_hist);
diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c
index 3c577ff..ba48874 100644
--- a/lustre/llite/namei.c
+++ b/lustre/llite/namei.c
@@ -52,116 +52,109 @@
 
 /* methods */
 
-/* called from iget{4,5_locked}->find_inode() under inode_lock spinlock */
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
-static int ll_test_inode(struct inode *inode, unsigned long ino, void *opaque)
-#else
-static int ll_test_inode(struct inode *inode, void *opaque)
-#endif
+int ll_unlock(__u32 mode, struct lustre_handle *lockh)
 {
-        static int last_ino, last_gen, last_count;
-        struct lustre_md *md = opaque;
+        ENTRY;
 
-        if (!(md->body->valid & (OBD_MD_FLGENER | OBD_MD_FLID))) {
-                CERROR("MDS body missing inum or generation\n");
-                return 0;
-        }
+        ldlm_lock_decref(lockh, mode);
 
-        if (last_ino == md->body->ino && last_gen == md->body->generation &&
-            last_count < 500) {
-                last_count++;
-        } else {
-                if (last_count > 1)
-                        CDEBUG(D_VFSTRACE, "compared %u/%u %u times\n",
-                               last_ino, last_gen, last_count);
-                last_count = 0;
-                last_ino = md->body->ino;
-                last_gen = md->body->generation;
-                CDEBUG(D_VFSTRACE,
-                       "comparing inode %p ino %lu/%u to body "LPU64"/%u\n",
-                       inode, inode->i_ino, inode->i_generation,
-                       md->body->ino, md->body->generation);
-        }
+        RETURN(0);
+}
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
-        if (inode->i_ino != md->body->ino)
-                return 0;
-#endif
-        if (inode->i_generation != md->body->generation) {
-#ifdef HAVE_EXPORT___IGET
-                if (inode->i_state & (I_FREEING | I_CLEAR))
-                        return 0;
-                if (inode->i_nlink == 0)
-                        return 0;
-
-                /* add "duplicate" inode into deathrow for destroy */
-                spin_lock(&ll_i2sbi(inode)->ll_deathrow_lock);
-                if (list_empty(&ll_i2info(inode)->lli_dead_list)) {
-                        __iget(inode);
-                        list_add(&ll_i2info(inode)->lli_dead_list,
-                                 &ll_i2sbi(inode)->ll_deathrow);
-                }
-                spin_unlock(&ll_i2sbi(inode)->ll_deathrow_lock);
-#endif
+/* Get an inode by inode number (already instantiated by the intent lookup).
+ * Returns inode or NULL
+ */
 
-                return 0;
+static inline __u64 fid_flatten(const struct lu_fid *fid)
+{                      
+        return (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
+}
+/* Build inode number on passed @fid */
+ino_t ll_fid_build_ino(struct ll_sb_info *sbi,
+                       struct ll_fid *fid)
+{
+        ino_t ino;
+        ENTRY;
+
+        if (fid_is_igif((struct lu_fid*)fid)) {
+                ino = lu_igif_ino((struct lu_fid*)fid);
+                RETURN(ino);
         }
 
-        /* Apply the attributes in 'opaque' to this inode */
-        if (!(inode->i_state & (I_FREEING | I_CLEAR)))
-                ll_update_inode(inode, md);
-        return 1;
+        /*
+         * Very stupid and having many downsides inode allocation algorithm
+         * based on fid.
+         */
+        ino = fid_flatten((struct lu_fid*)fid) & 0xFFFFFFFF;
+
+        if (unlikely(ino == 0))
+                /* the first result ino is 0xFFC001, so this is rarely used */
+                ino = 0xffbcde;
+        ino = ino | 0x80000000;
+        RETURN(ino);
+
 }
 
-int ll_unlock(__u32 mode, struct lustre_handle *lockh)
+__u32 ll_fid_build_gen(struct ll_sb_info *sbi, struct ll_fid *fid)
 {
+        __u32 gen = 0;
         ENTRY;
 
-        ldlm_lock_decref(lockh, mode);
+        if (fid_is_igif((struct lu_fid*)fid)) {
+                gen = lu_igif_gen((struct lu_fid*)fid);
+        }
+        RETURN(gen);
+}
 
-        RETURN(0);
+/* called from iget5_locked->find_inode() under inode_lock spinlock */
+static int fid_test_inode(struct inode *inode, void *opaque)
+{
+        struct lustre_md     *md = opaque;
+        struct lu_fid        *fid = (struct lu_fid*)&md->body->fid1;
+
+        if (unlikely(!(md->body->valid & OBD_MD_FLID))) {
+                CERROR("MDS body missing FID\n");
+                return 0;
+        }
+
+        return fid_seq(ll_inode_lu_fid(inode)) == fid_seq(fid) &&
+               fid_oid(ll_inode_lu_fid(inode)) == fid_oid(fid);
 }
 
-/* Get an inode by inode number (already instantiated by the intent lookup).
- * Returns inode or NULL
- */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
-int ll_set_inode(struct inode *inode, void *opaque)
+static int fid_set_inode(struct inode *inode, void *opaque)
 {
-        ll_read_inode2(inode, opaque);
+        struct lustre_md     *md  = opaque;
+
+        *ll_inode_lu_fid(inode) = *((struct lu_fid*)&md->body->fid1);
         return 0;
 }
 
 struct inode *ll_iget(struct super_block *sb, ino_t hash,
-                      struct lustre_md *md)
+                          struct lustre_md *md)
 {
-        struct inode *inode;
+        struct ll_inode_info *lli;
+        struct inode         *inode;
+        ENTRY;
 
         LASSERT(hash != 0);
-        inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md);
+        inode = iget5_locked(sb, hash, fid_test_inode, fid_set_inode, md);
 
         if (inode) {
-                if (inode->i_state & I_NEW)
+                lli = ll_i2info(inode);
+                if (inode->i_state & I_NEW) {
+                        ll_read_inode2(inode, md);
                         unlock_new_inode(inode);
-                CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
-                       inode->i_generation, inode);
+                } else {
+                        if (!(inode->i_state & (I_FREEING | I_CLEAR)))
+                                ll_update_inode(inode, md);
+                }
+                CDEBUG(D_VFSTRACE, "got inode: %lu/%u(%p) for "DFID"\n",
+                       inode->i_ino, inode->i_generation, inode,
+                       PFID(ll_inode_lu_fid(inode)));
         }
 
-        return inode;
+        RETURN(inode);
 }
-#else
-struct inode *ll_iget(struct super_block *sb, ino_t hash,
-                      struct lustre_md *md)
-{
-        struct inode *inode;
-        LASSERT(hash != 0);
-        inode = iget4(sb, hash, ll_test_inode, md);
-        if (inode)
-                CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p)\n", inode->i_ino,
-                       inode->i_generation, inode);
-        return inode;
-}
-#endif
 
 static void ll_drop_negative_dentry(struct inode *dir)
 { 
@@ -210,11 +203,14 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
         case LDLM_CB_CANCELING: {
                 struct inode *inode = ll_inode_from_lock(lock);
                 __u64 bits = lock->l_policy_data.l_inodebits.bits;
+                struct lu_fid *fid;
 
                 /* Invalidate all dentries associated with this inode */
                 if (inode == NULL)
                         break;
 
+                fid = ll_inode_lu_fid(inode);;
+
                 LASSERT(lock->l_flags & LDLM_FL_CANCELING);
                 if ((bits & MDS_INODELOCK_LOOKUP) &&
                     ll_have_md_lock(inode, MDS_INODELOCK_LOOKUP))
@@ -225,9 +221,8 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                 if ((bits & MDS_INODELOCK_OPEN) &&
                     ll_have_md_lock(inode, MDS_INODELOCK_OPEN))
                         bits &= ~MDS_INODELOCK_OPEN;
-                
-                if (lock->l_resource->lr_name.name[0] != inode->i_ino ||
-                    lock->l_resource->lr_name.name[1] != inode->i_generation) {
+
+                if (!fid_res_name_eq(fid, &lock->l_resource->lr_name)) {
                         LDLM_ERROR(lock, "data mismatch with ino %lu/%u (%p)",
                                    inode->i_ino, inode->i_generation, inode);
                 }
@@ -284,11 +279,11 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 int ll_mdc_cancel_unused(struct lustre_handle *conn, struct inode *inode,
                          int flags, void *opaque)
 {
-        struct ldlm_res_id res_id =
-                { .name = {inode->i_ino, inode->i_generation} };
+        struct ldlm_res_id res_id;
         struct obd_device *obddev = class_conn2obd(conn);
         ENTRY;
 
+        fid_build_reg_res_name(ll_inode_lu_fid(inode), &res_id);
         RETURN(ldlm_cli_cancel_unused(obddev->obd_namespace, &res_id, flags,
                                       opaque));
 }
@@ -407,7 +402,7 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
                 }
 
                 if (dentry->d_flags & DCACHE_DISCONNECTED) {
-                        LASSERT(last_discon == NULL);
+                        /* LASSERT(last_discon == NULL); see bug 20055 */
                         last_discon = dentry;
                         continue;
                 }
@@ -540,7 +535,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
                                    struct lookup_intent *it, int lookup_flags)
 {
         struct dentry *save = dentry, *retval;
-        struct mdc_op_data op_data;
+        struct mdc_op_data op_data = { { 0 } };
         struct it_cb_data icbd;
         struct ptlrpc_request *req = NULL;
         struct lookup_intent lookup_it = { .it_op = IT_LOOKUP };
@@ -701,19 +696,23 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry,
                                                        (struct ptlrpc_request *)
                                                           it->d.lustre.it_data);
                                 } else {
-                                        struct file *filp;
-                                        nd->intent.open.file->private_data = it;
-                                        filp =lookup_instantiate_filp(nd,dentry,
-                                                                      NULL);
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
 /* 2.6.1[456] have a bug in open_namei() that forgets to check
  * nd->intent.open.file for error, so we need to return it as lookup's result
  * instead */
+                                        struct file *filp;
+                                        nd->intent.open.file->private_data = it;
+                                        filp =lookup_instantiate_filp(nd,dentry,
+                                                                      NULL);
                                         if (IS_ERR(filp)) {
                                                 if (de)
                                                         dput(de);
                                                 de = (struct dentry *) filp;
                                         }
+#else
+                                        nd->intent.open.file->private_data = it;
+                                        (void)lookup_instantiate_filp(nd,dentry,
+                                                                      NULL);
 #endif
 
                                 }
@@ -837,21 +836,15 @@ static void ll_update_times(struct ptlrpc_request *request, int offset,
                                                sizeof(*body));
         LASSERT(body);
 
-        /* mtime is always updated with ctime, but can be set in past.
-           As write and utime(2) may happen within 1 second, and utime's
-           mtime has a priority over write's one, so take mtime from mds
-           for the same ctimes. */
+        if (body->valid & OBD_MD_FLMTIME &&
+            body->mtime > LTIME_S(inode->i_mtime)) {
+                CDEBUG(D_INODE, "setting ino %lu mtime from %lu to "LPU64"\n",
+                       inode->i_ino, LTIME_S(inode->i_mtime), body->mtime);
+                LTIME_S(inode->i_mtime) = body->mtime;
+        }
         if (body->valid & OBD_MD_FLCTIME &&
-            body->ctime >= LTIME_S(inode->i_ctime)) {
+            body->ctime > LTIME_S(inode->i_ctime))
                 LTIME_S(inode->i_ctime) = body->ctime;
-
-                if (body->valid & OBD_MD_FLMTIME) {
-                        CDEBUG(D_INODE, "setting ino %lu mtime from %lu "
-                               "to "LPU64"\n", inode->i_ino,
-                               LTIME_S(inode->i_mtime), body->mtime);
-                        LTIME_S(inode->i_mtime) = body->mtime;
-                }
-        }
 }
 
 static int ll_new_node(struct inode *dir, struct qstr *name,
@@ -861,7 +854,7 @@ static int ll_new_node(struct inode *dir, struct qstr *name,
         struct ptlrpc_request *request = NULL;
         struct inode *inode = NULL;
         struct ll_sb_info *sbi = ll_i2sbi(dir);
-        struct mdc_op_data op_data;
+        struct mdc_op_data op_data = { { 0 } };
         int tgt_len = 0;
         int err;
 
@@ -994,7 +987,7 @@ static int ll_link_generic(struct inode *src,  struct inode *dir,
                            struct qstr *name, struct dentry *dchild)
 {
         struct ptlrpc_request *request = NULL;
-        struct mdc_op_data op_data;
+        struct mdc_op_data op_data = { { 0 } };
         int err;
         struct ll_sb_info *sbi = ll_i2sbi(dir);
 
@@ -1059,7 +1052,7 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent,
                             struct qstr *name)
 {
         struct ptlrpc_request *request = NULL;
-        struct mdc_op_data op_data = {{0}};
+        struct mdc_op_data op_data = { { 0 } };
         struct dentry *dentry;
         int rc;
         ENTRY;
@@ -1144,8 +1137,9 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
                 GOTO(out_free_memmd, rc = -ENOMEM);
 
         oa->o_id = lsm->lsm_object_id;
+        oa->o_gr = lsm->lsm_object_gr;
         oa->o_mode = body->mode & S_IFMT;
-        oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE;
+        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP | OBD_MD_FLTYPE;
 
         if (body->valid & OBD_MD_FLCOOKIE) {
                 oa->o_valid |= OBD_MD_FLCOOKIE;
@@ -1162,8 +1156,8 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
         rc = obd_destroy(ll_i2obdexp(dir), oa, lsm, &oti, ll_i2mdcexp(dir));
         OBDO_FREE(oa);
         if (rc)
-                CERROR("obd destroy objid "LPX64" error %d\n",
-                       lsm->lsm_object_id, rc);
+                CERROR("obd destroy objid "LPX64"@"LPX64" error %d\n",
+                       lsm->lsm_object_id, lsm->lsm_object_gr, rc);
  out_free_memmd:
         obd_free_memmd(ll_i2obdexp(dir), &lsm);
  out:
@@ -1173,7 +1167,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir)
 static int ll_unlink_generic(struct inode * dir, struct qstr *name)
 {
         struct ptlrpc_request *request = NULL;
-        struct mdc_op_data op_data = {{0}};
+        struct mdc_op_data op_data = { { 0 } };
         int rc;
         ENTRY;
 
@@ -1206,7 +1200,7 @@ static int ll_rename_generic(struct inode *src, struct qstr *src_name,
 {
         struct ptlrpc_request *request = NULL;
         struct ll_sb_info *sbi = ll_i2sbi(src);
-        struct mdc_op_data op_data = {{0}};
+        struct mdc_op_data op_data = { { 0 } };
         int err;
 
         ENTRY;
diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c
index 7d10cc7..d97ade6 100644
--- a/lustre/llite/rw.c
+++ b/lustre/llite/rw.c
@@ -61,6 +61,8 @@
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
+#include <linux/page-flags.h>
+
 #include <lustre_lite.h>
 #include "llite_internal.h"
 #include <linux/lustre_compat25.h>
@@ -125,7 +127,8 @@ int ll_file_punch(struct inode * inode, loff_t new_size, int srvlock)
 {
         struct ll_inode_info *lli = ll_i2info(inode);
         struct obd_info oinfo = { { { 0 } } };
-        struct obdo oa;
+        struct obdo oa = { 0 };
+        obd_valid valid;
         int rc;
 
         ENTRY;
@@ -137,19 +140,55 @@ int ll_file_punch(struct inode * inode, loff_t new_size, int srvlock)
         oinfo.oi_policy.l_extent.end = OBD_OBJECT_EOF;
         oinfo.oi_oa = &oa;
         oa.o_id = lli->lli_smd->lsm_object_id;
-        oa.o_valid = OBD_MD_FLID;
+        oa.o_gr = lli->lli_smd->lsm_object_gr;
+        oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
+
+        valid = OBD_MD_FLTYPE | OBD_MD_FLMODE |OBD_MD_FLFID |
+                OBD_MD_FLATIME | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLGENER |
+                OBD_MD_FLBLOCKS;
         if (srvlock) {
-                /* set OBD_MD_FLFLAGS in o_valid, only if we 
+                /* set OBD_MD_FLFLAGS in o_valid, only if we
                  * set OBD_FL_TRUNCLOCK, otherwise ost_punch
                  * and filter_setattr get confused, see the comment
                  * in ost_punch */
                 oa.o_flags = OBD_FL_TRUNCLOCK;
                 oa.o_valid |= OBD_MD_FLFLAGS;
+
+                /* lockless truncate
+                 *
+                 * 1. do not use inode's timestamps because concurrent
+                 * stat might fill the inode with out-of-date times,
+                 * send current instead
+                 *
+                 * 2.do no update lsm, as long as stat (via
+                 * ll_glimpse_size) will bring attributes from osts
+                 * anyway */
+                oa.o_mtime = oa.o_ctime = LTIME_S(CURRENT_TIME);
+                oa.o_valid |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
+        } else {
+                /* truncate under locks
+                 *
+                 * 1. update inode's mtime and ctime as long as
+                 * concurrent stat (via ll_glimpse_size) might bring
+                 * out-of-date ones
+                 *
+                 * 2. update lsm so that next stat (via
+                 * ll_glimpse_size) could get correct values in lsm */
+                struct ost_lvb xtimes;
+
+                lov_stripe_lock(lli->lli_smd);
+                LTIME_S(inode->i_mtime) = LTIME_S(CURRENT_TIME);
+                LTIME_S(inode->i_ctime) = LTIME_S(CURRENT_TIME);
+                xtimes.lvb_mtime = LTIME_S(inode->i_mtime);
+                xtimes.lvb_ctime = LTIME_S(inode->i_ctime);
+                obd_update_lvb(ll_i2obdexp(inode), lli->lli_smd, &xtimes,
+                               OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+                lov_stripe_unlock(lli->lli_smd);
+
+                valid |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
         }
-        obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLMODE |OBD_MD_FLFID|
-                        OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME |
-                        OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLGENER |
-                        OBD_MD_FLBLOCKS);
+        obdo_from_inode(&oa, inode, valid);
+
         rc = obd_punch_rqset(ll_i2obdexp(inode), &oinfo, NULL);
         if (rc) {
                 CERROR("obd_truncate fails (%d) ino %lu\n", rc, inode->i_ino);
@@ -171,8 +210,9 @@ void ll_truncate(struct inode *inode)
         int srvlock = test_bit(LLI_F_SRVLOCK, &lli->lli_flags);
         loff_t new_size;
         ENTRY;
-        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) to %Lu=%#Lx\n",inode->i_ino,
-               inode->i_generation, inode, i_size_read(inode), i_size_read(inode));
+        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) to %Lu=%#Lx\n",
+               inode->i_ino, inode->i_generation, inode, i_size_read(inode),
+               i_size_read(inode));
 
         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_TRUNC, 1);
         if (lli->lli_size_sem_owner != current) {
@@ -186,20 +226,21 @@ void ll_truncate(struct inode *inode)
                 GOTO(out_unlock, 0);
         }
 
-        LASSERT(atomic_read(&lli->lli_size_sem.count) <= 0);
+        LASSERT(SEM_COUNT(&lli->lli_size_sem) <= 0);
 
         if (!srvlock) {
                 struct ost_lvb lvb;
                 int rc;
 
-                /* XXX I'm pretty sure this is a hack to paper over a more fundamental
-                 * race condition. */
+                /* XXX I'm pretty sure this is a hack to paper over a more
+                 * fundamental race condition. */
                 lov_stripe_lock(lli->lli_smd);
                 inode_init_lvb(inode, &lvb);
                 rc = obd_merge_lvb(ll_i2obdexp(inode), lli->lli_smd, &lvb, 0);
                 inode->i_blocks = lvb.lvb_blocks;
                 if (lvb.lvb_size == i_size_read(inode) && rc == 0) {
-                        CDEBUG(D_VFSTRACE, "skipping punch for obj "LPX64", %Lu=%#Lx\n",
+                        CDEBUG(D_VFSTRACE, "skipping punch for obj "LPX64
+                               ", %Lu=%#Lx\n",
                                lli->lli_smd->lsm_object_id, i_size_read(inode),
                                i_size_read(inode));
                         lov_stripe_unlock(lli->lli_smd);
@@ -256,7 +297,7 @@ int ll_prepare_write(struct file *file, struct page *page, unsigned from,
         obd_off offset = ((obd_off)page->index) << CFS_PAGE_SHIFT;
         struct obd_info oinfo = { { { 0 } } };
         struct brw_page pga;
-        struct obdo oa;
+        struct obdo oa = { 0 };
         struct ost_lvb lvb;
         int rc = 0;
         ENTRY;
@@ -272,7 +313,9 @@ int ll_prepare_write(struct file *file, struct page *page, unsigned from,
 
         oa.o_mode = inode->i_mode;
         oa.o_id = lsm->lsm_object_id;
-        oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLTYPE;
+        oa.o_gr = lsm->lsm_object_gr;
+        oa.o_valid = OBD_MD_FLID   | OBD_MD_FLMODE |
+                     OBD_MD_FLTYPE | OBD_MD_FLGROUP;
         obdo_from_inode(&oa, inode, OBD_MD_FLFID | OBD_MD_FLGENER);
 
         oinfo.oi_oa = &oa;
@@ -349,7 +392,7 @@ static int ll_ap_make_ready(void *data, int cmd)
 
         LASSERTF(!(cmd & OBD_BRW_READ) || !PageWriteback(page),
                 "cmd %x page %p ino %lu index %lu fl %lx\n", cmd, page,
-                 page->mapping->host->i_ino, page->index, page->flags);
+                 page->mapping->host->i_ino, page->index, (long)page->flags);
 
         /* if we left PageDirty we might get another writepage call
          * in the future.  list walkers are bright enough
@@ -359,9 +402,9 @@ static int ll_ap_make_ready(void *data, int cmd)
          * with the removepage path which gets the page lock then the
          * cli lock */
         if(!clear_page_dirty_for_io(page)) {
-		unlock_page(page);
-		RETURN(-EAGAIN);
-	}
+                unlock_page(page);
+                RETURN(-EAGAIN);
+        }
 
         /* This actually clears the dirty bit in the radix tree.*/
         set_page_writeback(page);
@@ -378,8 +421,8 @@ static int ll_ap_make_ready(void *data, int cmd)
  *
  * 1) Further extending writes may have landed in the page cache
  *    since a partial write first queued this page requiring us
- *    to write more from the page cache.  (No further races are possible, since
- *    by the time this is called, the page is locked.)
+ *    to write more from the page cache.  (No further races are possible,
+ *    since by the time this is called, the page is locked.)
  * 2) We might have raced with truncate and want to avoid performing
  *    write RPCs that are just going to be thrown away by the
  *    truncate's punch on the storage targets.
@@ -432,7 +475,8 @@ void ll_inode_fill_obdo(struct inode *inode, int cmd, struct obdo *oa)
         lsm = ll_i2info(inode)->lli_smd;
 
         oa->o_id = lsm->lsm_object_id;
-        oa->o_valid = OBD_MD_FLID;
+        oa->o_gr = lsm->lsm_object_gr;
+        oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
         valid_flags = OBD_MD_FLTYPE | OBD_MD_FLATIME;
         if (cmd & OBD_BRW_WRITE) {
                 oa->o_valid |= OBD_MD_FLEPOCH;
@@ -488,50 +532,37 @@ struct ll_async_page *llap_cast_private(struct page *page)
         return llap;
 }
 
-/* Try to shrink the page cache for the @sbi filesystem by 1/@shrink_fraction.
+/* Try to reap @target pages in the specific @cpu's async page list.
  *
  * There is an llap attached onto every page in lustre, linked off @sbi.
  * We add an llap to the list so we don't lose our place during list walking.
  * If llaps in the list are being moved they will only move to the end
  * of the LRU, and we aren't terribly interested in those pages here (we
- * start at the beginning of the list where the least-used llaps are.
- */
-int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction)
+ * start at the beginning of the list where the least-used llaps are. */
+static inline int llap_shrink_cache_internal(struct ll_sb_info *sbi,
+        int cpu, int target)
 {
         struct ll_async_page *llap, dummy_llap = { .llap_magic = 0xd11ad11a };
-        unsigned long total, want, count = 0;
-
-        total = sbi->ll_async_page_count;
-
-        /* There can be a large number of llaps (600k or more in a large
-         * memory machine) so the VM 1/6 shrink ratio is likely too much.
-         * Since we are freeing pages also, we don't necessarily want to
-         * shrink so much.  Limit to 40MB of pages + llaps per call. */
-        if (shrink_fraction == 0)
-                want = sbi->ll_async_page_count - sbi->ll_async_page_max + 32;
-        else
-                want = (total + shrink_fraction - 1) / shrink_fraction;
-
-        if (want > 40 << (20 - CFS_PAGE_SHIFT))
-                want = 40 << (20 - CFS_PAGE_SHIFT);
-
-        CDEBUG(D_CACHE, "shrinking %lu of %lu pages (1/%d)\n",
-               want, total, shrink_fraction);
-
-        spin_lock(&sbi->ll_lock);
-        list_add(&dummy_llap.llap_pglist_item, &sbi->ll_pglist);
-
-        while (--total >= 0 && count < want) {
+        struct ll_pglist_data *pd;
+        struct list_head *head;
+        int count = 0;
+
+        pd = ll_pglist_cpu_lock(sbi, cpu);
+        head = &pd->llpd_list;
+        list_add(&dummy_llap.llap_pglist_item, head);
+        while (count < target) {
                 struct page *page;
                 int keep;
 
                 if (unlikely(need_resched())) {
-                        spin_unlock(&sbi->ll_lock);
-                        cond_resched();
-                        spin_lock(&sbi->ll_lock);
+                        list_del(&dummy_llap.llap_pglist_item);
+                        ll_pglist_cpu_unlock(sbi, cpu);
+                        /* vmscan::shrink_slab() have own schedule() */
+                        return count;
                 }
 
-                llap = llite_pglist_next_llap(sbi,&dummy_llap.llap_pglist_item);
+                llap = llite_pglist_next_llap(head,
+                        &dummy_llap.llap_pglist_item);
                 list_del_init(&dummy_llap.llap_pglist_item);
                 if (llap == NULL)
                         break;
@@ -551,7 +582,8 @@ int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction)
                       PageWriteback(page) || (!PageUptodate(page) &&
                       llap->llap_origin != LLAP_ORIGIN_READAHEAD));
 
-                LL_CDEBUG_PAGE(D_PAGE, page,"%s LRU page: %s%s%s%s%s origin %s\n",
+                LL_CDEBUG_PAGE(D_PAGE, page,
+                               "%s LRU page: %s%s%s%s%s origin %s\n",
                                keep ? "keep" : "drop",
                                llap->llap_write_queued ? "wq " : "",
                                PageDirty(page) ? "pd " : "",
@@ -567,7 +599,7 @@ int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction)
                 }
 
                 page_cache_get(page);
-                spin_unlock(&sbi->ll_lock);
+                ll_pglist_cpu_unlock(sbi, cpu);
 
                 if (page->mapping != NULL) {
                         ll_teardown_mmaps(page->mapping,
@@ -579,25 +611,155 @@ int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction)
                                 ll_truncate_complete_page(page);
                                 ++count;
                         } else {
-                                LL_CDEBUG_PAGE(D_PAGE, page, "Not dropping page"
-                                                             " because it is "
-                                                             "%s\n",
-                                                              PageDirty(page)?
-                                                              "dirty":"mapped");
+                                LL_CDEBUG_PAGE(D_PAGE, page,
+                                               "Not dropping page because it is"
+                                               " %s\n", PageDirty(page) ?
+                                               "dirty" : "mapped");
                         }
                 }
                 unlock_page(page);
                 page_cache_release(page);
 
-                spin_lock(&sbi->ll_lock);
+                ll_pglist_cpu_lock(sbi, cpu);
         }
         list_del(&dummy_llap.llap_pglist_item);
-        spin_unlock(&sbi->ll_lock);
+        ll_pglist_cpu_unlock(sbi, cpu);
+
+        CDEBUG(D_CACHE, "shrank %d, expected %d however. \n", count, target);
+        return count;
+}
+
+
+/* Try to shrink the page cache for the @sbi filesystem by 1/@shrink_fraction.
+ *
+ * At first, this code calculates total pages wanted by @shrink_fraction, then
+ * it deduces how many pages should be reaped from each cpu in proportion as
+ * their own # of page count(llpd_count).
+ */
+int llap_shrink_cache(struct ll_sb_info *sbi, int shrink_fraction)
+{
+        unsigned long total, want, percpu_want, count = 0;
+        int cpu, nr_cpus;
+
+        total = lcounter_read_positive(&sbi->ll_async_page_count);
+        if (total == 0)
+                return 0;
+
+#ifdef HAVE_SHRINKER_CACHE
+        want = shrink_fraction;
+        if (want == 0)
+                return total;
+#else
+        /* There can be a large number of llaps (600k or more in a large
+         * memory machine) so the VM 1/6 shrink ratio is likely too much.
+         * Since we are freeing pages also, we don't necessarily want to
+         * shrink so much.  Limit to 40MB of pages + llaps per call. */
+        if (shrink_fraction <= 0)
+                want = total - sbi->ll_async_page_max + 32*num_online_cpus();
+        else
+                want = (total + shrink_fraction - 1) / shrink_fraction;
+#endif
+
+        if (want > 40 << (20 - CFS_PAGE_SHIFT))
+                want = 40 << (20 - CFS_PAGE_SHIFT);
+
+        CDEBUG(D_CACHE, "shrinking %lu of %lu pages (1/%d)\n",
+               want, total, shrink_fraction);
+
+        nr_cpus = num_possible_cpus();
+        cpu = sbi->ll_async_page_clock_hand;
+        /* we at most do one round */
+        do {
+                int c;
+
+                cpu = (cpu + 1) % nr_cpus;
+                c = LL_PGLIST_DATA_CPU(sbi, cpu)->llpd_count;
+                if (!cpu_online(cpu))
+                        percpu_want = c;
+                else
+                        percpu_want = want / ((total / (c + 1)) + 1);
+                if (percpu_want == 0)
+                        continue;
+
+                count += llap_shrink_cache_internal(sbi, cpu, percpu_want);
+                if (count >= want)
+                        sbi->ll_async_page_clock_hand = cpu;
+        } while (cpu != sbi->ll_async_page_clock_hand);
 
         CDEBUG(D_CACHE, "shrank %lu/%lu and left %lu unscanned\n",
                count, want, total);
 
+#ifdef HAVE_SHRINKER_CACHE
+        return lcounter_read_positive(&sbi->ll_async_page_count);
+#else
         return count;
+#endif
+}
+
+/* Rebalance the async page queue len for each cpu. We hope that the cpu
+ * which do much IO job has a relative longer queue len.
+ * This function should be called with preempt disabled.
+ */
+static inline int llap_async_cache_rebalance(struct ll_sb_info *sbi)
+{
+        unsigned long sample = 0, *cpu_sample, bias, slice;
+        struct ll_pglist_data *pd;
+        cpumask_t mask;
+        int cpu, surplus;
+        int w1 = 7, w2 = 3, base = (w1 + w2); /* weight value */
+        atomic_t *pcnt;
+
+        if (!spin_trylock(&sbi->ll_async_page_reblnc_lock)) {
+                /* someone else is doing the job */
+                return 1;
+        }
+
+        pcnt = &LL_PGLIST_DATA(sbi)->llpd_sample_count;
+        if (!atomic_read(pcnt)) {
+                /* rare case, somebody else has gotten this job done */
+                spin_unlock(&sbi->ll_async_page_reblnc_lock);
+                return 1;
+        }
+
+        sbi->ll_async_page_reblnc_count++;
+        cpu_sample = sbi->ll_async_page_sample;
+        memset(cpu_sample, 0, num_possible_cpus() * sizeof(unsigned long));
+        for_each_online_cpu(cpu) {
+                pcnt = &LL_PGLIST_DATA_CPU(sbi, cpu)->llpd_sample_count;
+                cpu_sample[cpu] = atomic_read(pcnt);
+                atomic_set(pcnt, 0);
+                sample += cpu_sample[cpu];
+        }
+
+        cpus_clear(mask);
+        surplus = sbi->ll_async_page_max;
+        slice = surplus / sample + 1;
+        sample /= num_online_cpus();
+        bias = sample >> 4;
+        for_each_online_cpu(cpu) {
+                pd = LL_PGLIST_DATA_CPU(sbi, cpu);
+                if (labs((long int)sample - cpu_sample[cpu]) > bias) {
+                        unsigned long budget = pd->llpd_budget;
+                        /* weighted original queue length and expected queue
+                         * length to avoid thrashing. */
+                        pd->llpd_budget = (budget * w1) / base +
+                                        (slice * cpu_sample[cpu]) * w2 / base;
+                        cpu_set(cpu, mask);
+                }
+                surplus -= pd->llpd_budget;
+        }
+        surplus /= cpus_weight(mask) ?: 1;
+        for_each_cpu_mask(cpu, mask)
+                LL_PGLIST_DATA_CPU(sbi, cpu)->llpd_budget += surplus;
+        spin_unlock(&sbi->ll_async_page_reblnc_lock);
+
+        /* TODO: do we really need to call llap_shrink_cache_internal
+         * for every cpus with its page_count greater than budget?
+         * for_each_cpu_mask(cpu, mask)
+         *      ll_shrink_cache_internal(...)
+         */
+
+        return 0;
 }
 
 static struct ll_async_page *llap_from_page_with_lockh(struct page *page,
@@ -608,7 +770,8 @@ static struct ll_async_page *llap_from_page_with_lockh(struct page *page,
         struct obd_export *exp;
         struct inode *inode = page->mapping->host;
         struct ll_sb_info *sbi;
-        int rc;
+        struct ll_pglist_data *pd;
+        int rc, cpu, target;
         ENTRY;
 
         if (!inode) {
@@ -631,11 +794,30 @@ static struct ll_async_page *llap_from_page_with_lockh(struct page *page,
                 /* move to end of LRU list, except when page is just about to
                  * die */
                 if (origin != LLAP_ORIGIN_REMOVEPAGE) {
-                        spin_lock(&sbi->ll_lock);
-                        sbi->ll_pglist_gen++;
-                        list_del_init(&llap->llap_pglist_item);
-                        list_add_tail(&llap->llap_pglist_item, &sbi->ll_pglist);
-                        spin_unlock(&sbi->ll_lock);
+                        int old_cpu = llap->llap_pglist_cpu;
+                        struct ll_pglist_data *old_pd;
+
+                        pd = ll_pglist_double_lock(sbi, old_cpu, &old_pd);
+                        pd->llpd_hit++;
+                        while (old_cpu != llap->llap_pglist_cpu) {
+                                /* rarely case, someone else is touching this
+                                 * page too. */
+                                ll_pglist_double_unlock(sbi, old_cpu);
+                                old_cpu = llap->llap_pglist_cpu;
+                                pd=ll_pglist_double_lock(sbi, old_cpu, &old_pd);
+                        }
+
+                        list_move(&llap->llap_pglist_item,
+                                  &pd->llpd_list);
+                        old_pd->llpd_gen++;
+                        if (pd->llpd_cpu != old_cpu) {
+                                pd->llpd_count++;
+                                old_pd->llpd_count--;
+                                old_pd->llpd_gen++;
+                                llap->llap_pglist_cpu = pd->llpd_cpu;
+                                pd->llpd_cross++;
+                        }
+                        ll_pglist_double_unlock(sbi, old_cpu);
                 }
                 GOTO(out, llap);
         }
@@ -645,8 +827,28 @@ static struct ll_async_page *llap_from_page_with_lockh(struct page *page,
                 RETURN(ERR_PTR(-EINVAL));
 
         /* limit the number of lustre-cached pages */
-        if (sbi->ll_async_page_count >= sbi->ll_async_page_max)
-                llap_shrink_cache(sbi, 0);
+        cpu = cfs_get_cpu();
+        pd = LL_PGLIST_DATA(sbi);
+        target = pd->llpd_count - pd->llpd_budget;
+        if (target > 0) {
+                rc = 0;
+                atomic_inc(&pd->llpd_sample_count);
+                if (atomic_read(&pd->llpd_sample_count) >
+                    sbi->ll_async_page_sample_max) {
+                        pd->llpd_reblnc_count++;
+                        rc = llap_async_cache_rebalance(sbi);
+                        if (rc == 0)
+                                target = pd->llpd_count - pd->llpd_budget;
+                }
+                /* if rc equals 1, it means other cpu is doing the rebalance
+                 * job, and our budget # would be modified when we read it.
+                 * Furthermore, it is much likely being increased because
+                 * we have already reached the rebalance threshold. In this
+                 * case, we skip to shrink cache here. */
+                if ((rc == 0) && target > 0)
+                        llap_shrink_cache_internal(sbi, cpu, target + 32);
+        }
+        cfs_put_cpu();
 
         OBD_SLAB_ALLOC(llap, ll_async_page_slab, CFS_ALLOC_STD,
                        ll_async_page_slab_size);
@@ -675,11 +877,14 @@ static struct ll_async_page *llap_from_page_with_lockh(struct page *page,
         __set_page_ll_data(page, llap);
         llap->llap_page = page;
 
-        spin_lock(&sbi->ll_lock);
-        sbi->ll_pglist_gen++;
-        sbi->ll_async_page_count++;
-        list_add_tail(&llap->llap_pglist_item, &sbi->ll_pglist);
-        spin_unlock(&sbi->ll_lock);
+        lcounter_inc(&sbi->ll_async_page_count);
+        pd = ll_pglist_lock(sbi);
+        list_add_tail(&llap->llap_pglist_item, &pd->llpd_list);
+        pd->llpd_count++;
+        pd->llpd_gen++;
+        pd->llpd_miss++;
+        llap->llap_pglist_cpu = pd->llpd_cpu;
+        ll_pglist_unlock(sbi);
 
  out:
         if (unlikely(sbi->ll_flags & LL_SBI_LLITE_CHECKSUM)) {
@@ -726,13 +931,14 @@ static int queue_or_sync_write(struct obd_export *exp, struct inode *inode,
         struct obd_io_group *oig;
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         int rc, noquot = llap->llap_ignore_quota ? OBD_BRW_NOQUOTA : 0;
+        int brwflags = OBD_BRW_ASYNC;
         ENTRY;
 
         /* _make_ready only sees llap once we've unlocked the page */
         llap->llap_write_queued = 1;
         rc = obd_queue_async_io(exp, ll_i2info(inode)->lli_smd, NULL,
                                 llap->llap_cookie, OBD_BRW_WRITE | noquot,
-                                0, 0, 0, async_flags);
+                                0, 0, brwflags, async_flags);
         if (rc == 0) {
                 LL_CDEBUG_PAGE(D_PAGE, llap->llap_page, "write queued\n");
                 llap_write_pending(inode, llap);
@@ -883,28 +1089,45 @@ out:
         RETURN(rc);
 }
 
+static void ll_ra_stats_inc_sbi(struct ll_sb_info *sbi, enum ra_stat which);
+
+/* WARNING: This algorithm is used to reduce the contention on
+ * sbi->ll_lock. It should work well if the ra_max_pages is much
+ * greater than the single file's read-ahead window.
+ *
+ * TODO: There may exist a `global sync problem' in this implementation.
+ * Considering the global ra window is 100M, and each file's ra window is 10M,
+ * there are over 10 files trying to get its ra budget and reach
+ * ll_ra_count_get at the exactly same time. All of them will get a zero ra
+ * window, although the global window is 100M. -jay
+ */
 static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, unsigned long len)
 {
         struct ll_ra_info *ra = &sbi->ll_ra_info;
-        unsigned long ret;
+        unsigned long ret = 0;
         ENTRY;
 
-        spin_lock(&sbi->ll_lock);
-        ret = min(ra->ra_max_pages - ra->ra_cur_pages, len);
-        ra->ra_cur_pages += ret;
-        spin_unlock(&sbi->ll_lock);
-
+        /**
+         * If read-ahead pages left are less than 1M, do not do read-ahead,
+         * otherwise it will form small read RPC(< 1M), which hurt server
+         * performance a lot.
+         */
+        ret = min(ra->ra_max_pages - atomic_read(&ra->ra_cur_pages), len);
+        if ((int)ret < min((unsigned long)PTLRPC_MAX_BRW_PAGES, len))
+                GOTO(out, ret = 0);
+
+        if (atomic_add_return(ret, &ra->ra_cur_pages) > ra->ra_max_pages) {
+                atomic_sub(ret, &ra->ra_cur_pages);
+                ret = 0;
+        }
+out:
         RETURN(ret);
 }
 
 static void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len)
 {
         struct ll_ra_info *ra = &sbi->ll_ra_info;
-        spin_lock(&sbi->ll_lock);
-        LASSERTF(ra->ra_cur_pages >= len, "r_c_p %lu len %lu\n",
-                 ra->ra_cur_pages, len);
-        ra->ra_cur_pages -= len;
-        spin_unlock(&sbi->ll_lock);
+        atomic_sub(len, &ra->ra_cur_pages);
 }
 
 /* called for each page in a completed rpc.*/
@@ -970,7 +1193,8 @@ static void __ll_put_llap(struct page *page)
         struct obd_export *exp;
         struct ll_async_page *llap;
         struct ll_sb_info *sbi = ll_i2sbi(inode);
-        int rc;
+        struct ll_pglist_data *pd;
+        int rc, cpu;
         ENTRY;
 
         exp = ll_i2obdexp(inode);
@@ -998,12 +1222,14 @@ static void __ll_put_llap(struct page *page)
          * is providing exclusivity to memory pressure/truncate/writeback..*/
         __clear_page_ll_data(page);
 
-        spin_lock(&sbi->ll_lock);
+        lcounter_dec(&sbi->ll_async_page_count);
+        cpu = llap->llap_pglist_cpu;
+        pd = ll_pglist_cpu_lock(sbi, cpu);
+        pd->llpd_gen++;
+        pd->llpd_count--;
         if (!list_empty(&llap->llap_pglist_item))
                 list_del_init(&llap->llap_pglist_item);
-        sbi->ll_pglist_gen++;
-        sbi->ll_async_page_count--;
-        spin_unlock(&sbi->ll_lock);
+        ll_pglist_cpu_unlock(sbi, cpu);
         OBD_SLAB_FREE(llap, ll_async_page_slab, ll_async_page_slab_size);
 
         EXIT;
@@ -1048,8 +1274,8 @@ static int ll_issue_page_read(struct obd_export *exp,
         llap->llap_ra_used = 0;
         rc = obd_queue_group_io(exp, ll_i2info(page->mapping->host)->lli_smd,
                                 NULL, oig, llap->llap_cookie, OBD_BRW_READ, 0,
-                                CFS_PAGE_SIZE, 0, ASYNC_COUNT_STABLE | ASYNC_READY |
-                                              ASYNC_URGENT);
+                                CFS_PAGE_SIZE, 0, ASYNC_COUNT_STABLE |
+                                ASYNC_READY | ASYNC_URGENT);
         if (rc) {
                 LL_CDEBUG_PAGE(D_ERROR, page, "read queue failed: rc %d\n", rc);
                 page_cache_release(page);
@@ -1057,20 +1283,16 @@ static int ll_issue_page_read(struct obd_export *exp,
         RETURN(rc);
 }
 
-static void ll_ra_stats_inc_unlocked(struct ll_ra_info *ra, enum ra_stat which)
+static void ll_ra_stats_inc_sbi(struct ll_sb_info *sbi, enum ra_stat which)
 {
         LASSERTF(which >= 0 && which < _NR_RA_STAT, "which: %u\n", which);
-        ra->ra_stats[which]++;
+        lprocfs_counter_incr(sbi->ll_ra_stats, which);
 }
 
 static void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which)
 {
         struct ll_sb_info *sbi = ll_i2sbi(mapping->host);
-        struct ll_ra_info *ra = &ll_i2sbi(mapping->host)->ll_ra_info;
-
-        spin_lock(&sbi->ll_lock);
-        ll_ra_stats_inc_unlocked(ra, which);
-        spin_unlock(&sbi->ll_lock);
+        ll_ra_stats_inc_sbi(sbi, which);
 }
 
 void ll_ra_accounting(struct ll_async_page *llap, struct address_space *mapping)
@@ -1084,11 +1306,11 @@ void ll_ra_accounting(struct ll_async_page *llap, struct address_space *mapping)
 #define RAS_CDEBUG(ras) \
         CDEBUG(D_READA,                                                      \
                "lrp %lu cr %lu cp %lu ws %lu wl %lu nra %lu r %lu ri %lu"    \
-               "csr %lu sf %lu sp %lu sl %lu \n", 		     	     \
+               "csr %lu sf %lu sp %lu sl %lu \n",                            \
                ras->ras_last_readpage, ras->ras_consecutive_requests,        \
                ras->ras_consecutive_pages, ras->ras_window_start,            \
                ras->ras_window_len, ras->ras_next_readahead,                 \
-               ras->ras_requests, ras->ras_request_index,		     \
+               ras->ras_requests, ras->ras_request_index,                    \
                ras->ras_consecutive_stride_requests, ras->ras_stride_offset, \
                ras->ras_stride_pages, ras->ras_stride_length)
 
@@ -1113,12 +1335,16 @@ static struct ll_readahead_state *ll_ras_get(struct file *f)
         return &fd->fd_ras;
 }
 
-void ll_ra_read_in(struct file *f, struct ll_ra_read *rar)
+void ll_ra_read_init(struct file *f, struct ll_ra_read *rar,
+                     loff_t offset, size_t count)
 {
         struct ll_readahead_state *ras;
 
         ras = ll_ras_get(f);
 
+        rar->lrr_start = offset >> CFS_PAGE_SHIFT;
+        rar->lrr_count = (count + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
+
         spin_lock(&ras->ras_lock);
         ras->ras_requests++;
         ras->ras_request_index = 0;
@@ -1165,7 +1391,7 @@ struct ll_ra_read *ll_ra_read_get(struct file *f)
 }
 
 static int ll_read_ahead_page(struct obd_export *exp, struct obd_io_group *oig,
-                              int index, struct address_space *mapping)
+                              pgoff_t index, struct address_space *mapping)
 {
         struct ll_async_page *llap;
         struct page *page;
@@ -1187,7 +1413,7 @@ static int ll_read_ahead_page(struct obd_export *exp, struct obd_io_group *oig,
         if (page->mapping != mapping) {
                 ll_ra_stats_inc(mapping, RA_STAT_WRONG_GRAB_PAGE);
                 CDEBUG(D_READA, "g_c_p_n returned invalid page\n");
-                GOTO(unlock_page, rc = 0);	
+                GOTO(unlock_page, rc = 0);
         }
 
         /* we do this first so that we can see the page in the /proc
@@ -1198,17 +1424,17 @@ static int ll_read_ahead_page(struct obd_export *exp, struct obd_io_group *oig,
                         ll_ra_stats_inc(mapping, RA_STAT_FAILED_MATCH);
                         CDEBUG(D_READA | D_PAGE,
                                "Adding page to cache failed index "
-                                "%d\n", index);
+                                "%ld\n", index);
                                 CDEBUG(D_READA, "nolock page\n");
                                 GOTO(unlock_page, rc = -ENOLCK);
                 }
                 CDEBUG(D_READA, "read-ahead page\n");
-                GOTO(unlock_page, rc = 0);	
+                GOTO(unlock_page, rc = 0);
         }
 
         /* skip completed pages */
         if (Page_Uptodate(page))
-                GOTO(unlock_page, rc = 0);	
+                GOTO(unlock_page, rc = 0);
 
         /* bail out when we hit the end of the lock. */
         rc = ll_issue_page_read(exp, llap, oig, 1);
@@ -1216,7 +1442,7 @@ static int ll_read_ahead_page(struct obd_export *exp, struct obd_io_group *oig,
                 LL_CDEBUG_PAGE(D_READA | D_PAGE, page, "started read-ahead\n");
                 rc = 1;
         } else {
-unlock_page:	
+unlock_page:
                 unlock_page(page);
                 LL_CDEBUG_PAGE(D_READA | D_PAGE, page, "skipping read-ahead\n");
         }
@@ -1243,12 +1469,12 @@ struct ra_io_arg {
         unsigned long ria_pages;
 };
 
-#define RIA_DEBUG(ria) 						      \
+#define RIA_DEBUG(ria)                                                \
         CDEBUG(D_READA, "rs %lu re %lu ro %lu rl %lu rp %lu\n",       \
         ria->ria_start, ria->ria_end, ria->ria_stoff, ria->ria_length,\
         ria->ria_pages)
 
-#define RAS_INCREASE_STEP (1024 * 1024 >> CFS_PAGE_SHIFT)
+#define INIT_RAS_WINDOW_PAGES PTLRPC_MAX_BRW_PAGES
 
 static inline int stride_io_mode(struct ll_readahead_state *ras)
 {
@@ -1308,7 +1534,7 @@ static int ras_inside_ra_window(unsigned long idx, struct ra_io_arg *ria)
 
 static int ll_read_ahead_pages(struct obd_export *exp,
                                struct obd_io_group *oig,
-                               struct ra_io_arg *ria,	
+                               struct ra_io_arg *ria,
                                unsigned long *reserved_pages,
                                struct address_space *mapping,
                                unsigned long *ra_end)
@@ -1325,16 +1551,16 @@ static int ll_read_ahead_pages(struct obd_export *exp,
                 if (ras_inside_ra_window(page_idx, ria)) {
                         /* If the page is inside the read-ahead window*/
                         rc = ll_read_ahead_page(exp, oig, page_idx, mapping);
-        		if (rc == 1) {
-	        		(*reserved_pages)--;
-		        	count ++;
-		        } else if (rc == -ENOLCK)
-			        break;
+                        if (rc == 1) {
+                                (*reserved_pages)--;
+                                count ++;
+                        } else if (rc == -ENOLCK)
+                                break;
                 } else if (stride_ria) {
                         /* If it is not in the read-ahead window, and it is
                          * read-ahead mode, then check whether it should skip
                          * the stride gap */
-			pgoff_t offset;
+                        pgoff_t offset;
                         /* FIXME: This assertion only is valid when it is for
                          * forward read-ahead, it will be fixed when backward
                          * read-ahead is implemented */
@@ -1343,9 +1569,9 @@ static int ll_read_ahead_pages(struct obd_export *exp,
                                 " offset %lu \n", page_idx, ria->ria_stoff);
 
                         offset = page_idx - ria->ria_stoff;
-			offset = offset % (ria->ria_length);
-			if (offset > ria->ria_pages) {
-				page_idx += ria->ria_length - offset;
+                        offset = offset % (ria->ria_length);
+                        if (offset > ria->ria_pages) {
+                                page_idx += ria->ria_length - offset;
                                 CDEBUG(D_READA, "i %lu skip %lu \n", page_idx,
                                        ria->ria_length - offset);
                                 continue;
@@ -1389,10 +1615,14 @@ static int ll_readahead(struct ll_readahead_state *ras,
         /* Enlarge the RA window to encompass the full read */
         if (bead != NULL && ras->ras_window_start + ras->ras_window_len <
             bead->lrr_start + bead->lrr_count) {
-                ras->ras_window_len = bead->lrr_start + bead->lrr_count -
+                obd_off read_end = (bead->lrr_start + bead->lrr_count) <<
+                                    CFS_PAGE_SHIFT;
+                obd_extent_calc(exp, lsm, OBD_CALC_STRIPE_RPC_END_ALIGN,
+                                &read_end);
+                ras->ras_window_len = ((read_end + 1) >> CFS_PAGE_SHIFT) -
                                       ras->ras_window_start;
         }
-       	/* Reserve a part of the read-ahead window that we'll be issuing */
+        /* Reserve a part of the read-ahead window that we'll be issuing */
         if (ras->ras_window_len) {
                 start = ras->ras_next_readahead;
                 end = ras->ras_window_start + ras->ras_window_len - 1;
@@ -1450,8 +1680,8 @@ static int ll_readahead(struct ll_readahead_state *ras,
                 if (ra_end < ras->ras_next_readahead &&
                     index_in_window(ra_end, ras->ras_window_start, 0,
                                     ras->ras_window_len)) {
-                	ras->ras_next_readahead = ra_end;
-                       	RAS_CDEBUG(ras);
+                        ras->ras_next_readahead = ra_end;
+                        RAS_CDEBUG(ras);
                 }
                 spin_unlock(&ras->ras_lock);
         }
@@ -1461,7 +1691,7 @@ static int ll_readahead(struct ll_readahead_state *ras,
 
 static void ras_set_start(struct ll_readahead_state *ras, unsigned long index)
 {
-        ras->ras_window_start = index & (~(RAS_INCREASE_STEP - 1));
+        ras->ras_window_start = index & (~(INIT_RAS_WINDOW_PAGES - 1));
 }
 
 /* called with the ras_lock held or from places where it doesn't matter */
@@ -1494,7 +1724,7 @@ void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras)
         INIT_LIST_HEAD(&ras->ras_read_beads);
 }
 
-/* 
+/*
  * Check whether the read request is in the stride window.
  * If it is in the stride window, return 1, otherwise return 0.
  */
@@ -1503,17 +1733,17 @@ static int index_in_stride_window(unsigned long index,
                                   struct inode *inode)
 {
         unsigned long stride_gap = index - ras->ras_last_readpage - 1;
- 
+
         if (ras->ras_stride_length == 0 || ras->ras_stride_pages == 0)
                 return 0;
 
         /* If it is contiguous read */
-        if (stride_gap == 0) 
+        if (stride_gap == 0)
                 return ras->ras_consecutive_pages + 1 <= ras->ras_stride_pages;
-        
+
         /*Otherwise check the stride by itself */
         return (ras->ras_stride_length - ras->ras_stride_pages) == stride_gap &&
-                 ras->ras_consecutive_pages == ras->ras_stride_pages;
+             ras->ras_consecutive_pages == ras->ras_stride_pages;
 }
 
 static void ras_update_stride_detector(struct ll_readahead_state *ras,
@@ -1521,7 +1751,7 @@ static void ras_update_stride_detector(struct ll_readahead_state *ras,
 {
         unsigned long stride_gap = index - ras->ras_last_readpage - 1;
 
-        if (!stride_io_mode(ras) && (stride_gap != 0 || 
+        if (!stride_io_mode(ras) && (stride_gap != 0 ||
              ras->ras_consecutive_stride_requests == 0)) {
                 ras->ras_stride_pages = ras->ras_consecutive_pages;
                 ras->ras_stride_length = stride_gap +ras->ras_consecutive_pages;
@@ -1547,16 +1777,15 @@ static void ras_stride_increase_window(struct ll_readahead_state *ras,
         unsigned long stride_len;
 
         LASSERT(ras->ras_stride_length > 0);
+        LASSERTF(ras->ras_window_start + ras->ras_window_len
+                 >= ras->ras_stride_offset, "window_start %lu, window_len %lu"
+                 " stride_offset %lu\n", ras->ras_window_start,
+                 ras->ras_window_len, ras->ras_stride_offset);
 
         stride_len = ras->ras_window_start + ras->ras_window_len -
                      ras->ras_stride_offset;
 
-        LASSERTF(stride_len >= 0, "window_start %lu, window_len %lu"
-                 " stride_offset %lu\n", ras->ras_window_start,
-                 ras->ras_window_len, ras->ras_stride_offset);
-
         left = stride_len % ras->ras_stride_length;
-
         window_len = ras->ras_window_len - left;
 
         if (left < ras->ras_stride_pages)
@@ -1571,7 +1800,7 @@ static void ras_stride_increase_window(struct ll_readahead_state *ras,
 
         window_len += step * ras->ras_stride_length + left;
 
-        if (stride_page_count(ras, window_len) <= ra->ra_max_pages)
+        if (stride_page_count(ras, window_len) <= ra->ra_max_pages_per_file)
                 ras->ras_window_len = window_len;
 
         RAS_CDEBUG(ras);
@@ -1593,6 +1822,31 @@ static void ras_set_stride_offset(struct ll_readahead_state *ras)
         RAS_CDEBUG(ras);
 }
 
+static void ras_increase_window(struct ll_readahead_state *ras,
+                                struct ll_ra_info *ra, struct inode *inode)
+{
+        __u64 step;
+        __u32 size;
+        int rc;
+
+        step = ((loff_t)(ras->ras_window_start +
+                         ras->ras_window_len)) << CFS_PAGE_SHIFT;
+        size = sizeof(step);
+        /*Get rpc_size for this offset (step) */
+        rc = obd_get_info(ll_i2obdexp(inode), sizeof(KEY_OFF_RPCSIZE),
+                          KEY_OFF_RPCSIZE, &size, &step,
+                          ll_i2info(inode)->lli_smd);
+        if (rc)
+                step = INIT_RAS_WINDOW_PAGES;
+
+        if (stride_io_mode(ras))
+                ras_stride_increase_window(ras, ra, (unsigned long)step);
+        else
+                ras->ras_window_len = min(ras->ras_window_len +
+                                          (unsigned long)step,
+                                          ra->ra_max_pages);
+}
+
 static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
                        struct ll_readahead_state *ras, unsigned long index,
                        unsigned hit)
@@ -1601,10 +1855,9 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
         int zero = 0, stride_detect = 0, ra_miss = 0;
         ENTRY;
 
-        spin_lock(&sbi->ll_lock);
         spin_lock(&ras->ras_lock);
 
-        ll_ra_stats_inc_unlocked(ra, hit ? RA_STAT_HIT : RA_STAT_MISS);
+        ll_ra_stats_inc_sbi(sbi, hit ? RA_STAT_HIT : RA_STAT_MISS);
 
         /* reset the read-ahead window in two cases.  First when the app seeks
          * or reads to some other part of the file.  Secondly if we get a
@@ -1613,19 +1866,19 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
          * reclaiming it before we get to it. */
         if (!index_in_window(index, ras->ras_last_readpage, 8, 8)) {
                 zero = 1;
-                ll_ra_stats_inc_unlocked(ra, RA_STAT_DISTANT_READPAGE);
+                ll_ra_stats_inc_sbi(sbi, RA_STAT_DISTANT_READPAGE);
         } else if (!hit && ras->ras_window_len &&
                    index < ras->ras_next_readahead &&
                    index_in_window(index, ras->ras_window_start, 0,
                                    ras->ras_window_len)) {
-		ra_miss = 1;
-                ll_ra_stats_inc_unlocked(ra, RA_STAT_MISS_IN_WINDOW);
+                ra_miss = 1;
+                ll_ra_stats_inc_sbi(sbi, RA_STAT_MISS_IN_WINDOW);
         }
 
         /* On the second access to a file smaller than the tunable
          * ra_max_read_ahead_whole_pages trigger RA on all pages in the
-         * file up to ra_max_pages.  This is simply a best effort and
-         * only occurs once per open file.  Normal RA behavior is reverted
+         * file up to ra_max_pages_per_file.  This is simply a best effort
+         * and only occurs once per open file.  Normal RA behavior is reverted
          * to for subsequent IO.  The mmap case does not increment
          * ras_requests and thus can never trigger this behavior. */
         if (ras->ras_requests == 2 && !ras->ras_request_index) {
@@ -1635,27 +1888,29 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
                             CFS_PAGE_SHIFT;
 
                 CDEBUG(D_READA, "kmsp "LPU64" mwp %lu mp %lu\n", kms_pages,
-                       ra->ra_max_read_ahead_whole_pages, ra->ra_max_pages);
+                       ra->ra_max_read_ahead_whole_pages,
+                       ra->ra_max_pages_per_file);
 
                 if (kms_pages &&
                     kms_pages <= ra->ra_max_read_ahead_whole_pages) {
                         ras->ras_window_start = 0;
                         ras->ras_last_readpage = 0;
                         ras->ras_next_readahead = 0;
-                        ras->ras_window_len = min(ra->ra_max_pages,
+                        ras->ras_window_len = min(ra->ra_max_pages_per_file,
                                 ra->ra_max_read_ahead_whole_pages);
                         GOTO(out_unlock, 0);
                 }
         }
         if (zero) {
-		/* check whether it is in stride I/O mode*/
+                /* check whether it is in stride I/O mode*/
                 if (!index_in_stride_window(index, ras, inode)) {
                         ras_reset(ras, index);
                         ras->ras_consecutive_pages++;
                         ras_stride_reset(ras);
                         GOTO(out_unlock, 0);
                 } else {
-        	        ras->ras_consecutive_requests = 0;
+                        ras->ras_consecutive_pages = 0;
+                        ras->ras_consecutive_requests = 0;
                         if (++ras->ras_consecutive_stride_requests > 1)
                                 stride_detect = 1;
                         RAS_CDEBUG(ras);
@@ -1664,14 +1919,15 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
                 if (ra_miss) {
                         if (index_in_stride_window(index, ras, inode) &&
                             stride_io_mode(ras)) {
-                                /*If stride-RA hit cache miss, the stride dector 
+                                /*If stride-RA hit cache miss, the stride dector
                                  *will not be reset to avoid the overhead of
                                  *redetecting read-ahead mode */
                                 if (index != ras->ras_last_readpage + 1)
                                        ras->ras_consecutive_pages = 0;
                                 RAS_CDEBUG(ras);
                         } else {
-                                /*Reset both stride window and normal RA window*/ 
+                                /* Reset both stride window and normal RA
+                                 * window */
                                 ras_reset(ras, index);
                                 ras->ras_consecutive_pages++;
                                 ras_stride_reset(ras);
@@ -1680,9 +1936,9 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
                 } else if (stride_io_mode(ras)) {
                         /* If this is contiguous read but in stride I/O mode
                          * currently, check whether stride step still is valid,
-                         * if invalid, it will reset the stride ra window*/ 	
+                         * if invalid, it will reset the stride ra window*/
                         if (!index_in_stride_window(index, ras, inode)) {
-                                /*Shrink stride read-ahead window to be zero*/
+                                /* Shrink stride read-ahead window to be zero */
                                 ras_stride_reset(ras);
                                 ras->ras_window_len = 0;
                                 ras->ras_next_readahead = index;
@@ -1700,7 +1956,7 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
         /* Trigger RA in the mmap case where ras_consecutive_requests
          * is not incremented and thus can't be used to trigger RA */
         if (!ras->ras_window_len && ras->ras_consecutive_pages == 4) {
-                ras->ras_window_len = RAS_INCREASE_STEP;
+                ras->ras_window_len = INIT_RAS_WINDOW_PAGES;
                 GOTO(out_unlock, 0);
         }
 
@@ -1712,20 +1968,13 @@ static void ras_update(struct ll_sb_info *sbi, struct inode *inode,
          * uselessly reading and discarding pages for random IO the window is
          * only increased once per consecutive request received. */
         if ((ras->ras_consecutive_requests > 1 &&
-            !ras->ras_request_index) || stride_detect) {
-                if (stride_io_mode(ras))
-                        ras_stride_increase_window(ras, ra, RAS_INCREASE_STEP);
-                else
-                        ras->ras_window_len = min(ras->ras_window_len +
-                                                  RAS_INCREASE_STEP,
-                                                  ra->ra_max_pages);
-        }
+            !ras->ras_request_index) || stride_detect)
+                ras_increase_window(ras, ra, inode);
         EXIT;
 out_unlock:
         RAS_CDEBUG(ras);
         ras->ras_request_index++;
         spin_unlock(&ras->ras_lock);
-        spin_unlock(&sbi->ll_lock);
         return;
 }
 
@@ -1845,7 +2094,7 @@ int ll_readpage(struct file *filp, struct page *page)
                 GOTO(out, rc = PTR_ERR(llap));
         }
 
-        if (ll_i2sbi(inode)->ll_ra_info.ra_max_pages)
+        if (ll_i2sbi(inode)->ll_ra_info.ra_max_pages_per_file)
                 ras_update(ll_i2sbi(inode), inode, &fd->fd_ras, page->index,
                            llap->llap_defer_uptodate);
 
@@ -1871,7 +2120,7 @@ int ll_readpage(struct file *filp, struct page *page)
         LL_CDEBUG_PAGE(D_PAGE, page, "queued readpage\n");
         /* We have just requested the actual page we want, see if we can tack
          * on some readahead to that page's RPC before it is sent. */
-        if (ll_i2sbi(inode)->ll_ra_info.ra_max_pages)
+        if (ll_i2sbi(inode)->ll_ra_info.ra_max_pages_per_file)
                 ll_readahead(&fd->fd_ras, exp, page->mapping, oig,
                              fd->fd_flags);
 
@@ -1900,9 +2149,11 @@ static void ll_file_put_pages(struct page **pages, int numpages)
                                 CERROR("the llap wasn't freed\n");
                         (*pp)->mapping = NULL;
                         if (page_count(*pp) != 1)
-                                CERROR("page %p, flags %#lx, count %i, private %p\n",
-                                (*pp), (unsigned long)(*pp)->flags, page_count(*pp),
-                                (void*)page_private(*pp));
+                                CERROR("page %p, flags %#lx, count %i, "
+                                       "private %p\n", (*pp),
+                                       (unsigned long)(*pp)->flags,
+                                       page_count(*pp),
+                                       (void*)page_private(*pp));
                         __free_pages(*pp, 0);
                 }
         }
@@ -2046,7 +2297,7 @@ static int ll_file_oig_pages(struct inode * inode, struct page **pages,
 
                 LL_CDEBUG_PAGE(D_PAGE, pages[i], "offset "LPU64","
                                " from %u, bytes = %u\n",
-                               pos, from, bytes);
+                               (__u64)pos, from, bytes);
                 LASSERTF(pos >> CFS_PAGE_SHIFT == pages[i]->index,
                          "wrong page index %lu (%lu)\n",
                          pages[i]->index,
@@ -2122,11 +2373,21 @@ ssize_t ll_file_lockless_io(struct file *file, const struct iovec *iov,
                 rc = generic_write_checks(file, ppos, &count, 0);
                 if (rc)
                         GOTO(out, rc);
-                rc = ll_remove_suid(file->f_dentry, file->f_vfsmnt);
+                rc = ll_remove_suid(file, file->f_vfsmnt);
                 if (rc)
                         GOTO(out, rc);
         }
 
+        if (file->f_flags & O_DIRECT) {
+                if (rw == WRITE)
+                        ll_update_time(file);
+                /* do not copy data for O_DIRECT */
+                rc = ll_direct_IO(rw, file, iov, *ppos, nr_segs, 0);
+                if (rc > 0)
+                        amount = rc;
+                GOTO(out_check, rc);
+        }
+
         pos = *ppos;
         first = pos >> CFS_PAGE_SHIFT;
         last = (pos + count - 1) >> CFS_PAGE_SHIFT;
@@ -2180,9 +2441,6 @@ put_pages:
                 if (nsegs == 0)
                         break;
         }
-        /* NOTE: don't update i_size and KMS in absence of LDLM locks even
-         * write makes the file large */
-        file_accessed(file);
         if (rw == READ && amount < count && rc == 0) {
                 unsigned long not_cleared;
 
@@ -2201,6 +2459,10 @@ put_pages:
                         nsegs--;
                 }
         }
+out_check:
+        /* NOTE: don't update i_size and KMS in absence of LDLM locks even
+         * write makes the file large */
+        file_accessed(file);
         if (amount > 0) {
                 lprocfs_counter_add(ll_i2sbi(inode)->ll_stats,
                                     (rw == WRITE) ?
diff --git a/lustre/llite/rw24.c b/lustre/llite/rw24.c
deleted file mode 100644
index 4652d5f..0000000
--- a/lustre/llite/rw24.c
+++ /dev/null
@@ -1,161 +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  2008 Sun Microsystems, Inc. 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.
- *
- * lustre/llite/rw24.c
- *
- * Lustre Lite I/O page cache for the 2.4 kernel version
- */
-
-#ifndef AUTOCONF_INCLUDED
-#include <linux/config.h>
-#endif
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/smp_lock.h>
-#include <linux/unistd.h>
-#include <linux/version.h>
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/iobuf.h>
-#include <linux/stat.h>
-#include <asm/uaccess.h>
-#include <linux/mm.h>
-#include <linux/pagemap.h>
-#include <linux/smp_lock.h>
-
-#define DEBUG_SUBSYSTEM S_LLITE
-
-#include <lustre_lite.h>
-#include "llite_internal.h"
-#include <linux/lustre_compat25.h>
-
-static int ll_direct_IO_24(int rw,
-#ifdef HAVE_DIO_FILE
-                           struct file *file,
-#else
-                           struct inode *inode,
-#endif
-                           struct kiobuf *iobuf, unsigned long blocknr,
-                           int blocksize)
-{
-#ifdef HAVE_DIO_FILE
-        struct inode *inode = file->f_dentry->d_inode;
-#endif
-        struct ll_inode_info *lli = ll_i2info(inode);
-        struct lov_stripe_md *lsm = lli->lli_smd;
-        struct brw_page *pga;
-        struct obdo oa;
-        int length, i, flags, rc = 0;
-        loff_t offset, offset_orig;
-        ENTRY;
-
-        if (!lsm || !lsm->lsm_object_id)
-                RETURN(-EBADF);
-
-        offset = ((obd_off)blocknr << inode->i_blkbits);
-        offset_orig = offset;
-        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), size="LPSZ
-               ", offset=%lld=%llx, pages %u\n",
-               inode->i_ino, inode->i_generation, inode, iobuf->length,
-               offset, offset, iobuf->nr_pages);
-
-        /* FIXME: io smaller than CFS_PAGE_SIZE is broken on ia64 */
-        if ((iobuf->offset & (~CFS_PAGE_MASK)) ||
-            (iobuf->length & (~CFS_PAGE_MASK)))
-                RETURN(-EINVAL);
-
-        OBD_ALLOC(pga, sizeof(*pga) * iobuf->nr_pages);
-        if (!pga)
-                RETURN(-ENOMEM);
-
-        flags = 0 /* | OBD_BRW_DIRECTIO */;
-        length = iobuf->length;
-        rw = rw ? OBD_BRW_WRITE : OBD_BRW_READ;
-
-        for (i = 0, length = iobuf->length; length > 0;
-             length -= pga[i].count, offset += pga[i].count, i++) { /*i last!*/
-                pga[i].pg = iobuf->maplist[i];
-                pga[i].off = offset;
-                /* To the end of the page, or the length, whatever is less */
-                pga[i].count = min_t(int, CFS_PAGE_SIZE - (offset & ~CFS_PAGE_MASK),
-                                     length);
-                pga[i].flag = flags;
-                if (rw == OBD_BRW_READ)
-                        POISON_PAGE(iobuf->maplist[i], 0x0d);
-        }
-
-        ll_inode_fill_obdo(inode, rw, &oa);
-
-        if (rw == OBD_BRW_WRITE)
-                ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_WRITE, iobuf->length);
-        else
-                ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_READ, iobuf->length);
-        rc = obd_brw_rqset(rw, ll_i2obdexp(inode), &oa, lsm, iobuf->nr_pages,
-                           pga, NULL);
-        if ((rc > 0) && (rw == OBD_BRW_WRITE)) {
-                lov_stripe_lock(lsm);
-                obd_adjust_kms(ll_i2obdexp(inode), lsm, offset_orig + rc, 0);
-                lov_stripe_unlock(lsm);
-        }
-
-        OBD_FREE(pga, sizeof(*pga) * iobuf->nr_pages);
-        RETURN(rc);
-}
-
-#ifdef KERNEL_HAS_AS_MAX_READAHEAD
-static int ll_max_readahead(struct inode *inode)
-{
-        return 0;
-}
-#endif
-
-struct address_space_operations ll_aops = {
-        .readpage       = ll_readpage,
-        .direct_IO      = ll_direct_IO_24,
-        .writepage      = ll_writepage,
-        .prepare_write  = ll_prepare_write,
-        .commit_write   = ll_commit_write,
-        .removepage     = ll_removepage,
-        .sync_page      = NULL,
-        .bmap           = NULL,
-#ifdef KERNEL_HAS_AS_MAX_READAHEAD
-        .max_readahead  = ll_max_readahead,
-#endif
-};
diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c
index aab56fb..9972652 100644
--- a/lustre/llite/rw26.c
+++ b/lustre/llite/rw26.c
@@ -54,7 +54,6 @@
 
 #include <linux/fs.h>
 #include <linux/buffer_head.h>
-#include <linux/mpage.h>
 #include <linux/writeback.h>
 #include <linux/stat.h>
 #include <asm/uaccess.h>
@@ -98,7 +97,12 @@ static void ll_invalidatepage(struct page *page, unsigned long offset)
 }
 #endif
 
-static int ll_releasepage(struct page *page, gfp_t gfp_mask)
+#ifdef HAVE_RELEASEPAGE_WITH_GFP
+#define RELEASEPAGE_ARG_TYPE gfp_t
+#else
+#define RELEASEPAGE_ARG_TYPE int
+#endif
+static int ll_releasepage(struct page *page, RELEASEPAGE_ARG_TYPE gfp_mask)
 {
         if (PagePrivate(page))
                 ll_removepage(page);
@@ -108,10 +112,10 @@ static int ll_releasepage(struct page *page, gfp_t gfp_mask)
 #define MAX_DIRECTIO_SIZE 2*1024*1024*1024UL
 
 static inline int ll_get_user_pages(int rw, unsigned long user_addr,
-                                    size_t size, struct page ***pages)
+                                    size_t size, struct page ***pages,
+                                    int *max_pages)
 {
         int result = -ENOMEM;
-        int page_count;
 
         /* set an arbitrary limit to prevent arithmetic overflow */
         if (size > MAX_DIRECTIO_SIZE) {
@@ -119,18 +123,18 @@ static inline int ll_get_user_pages(int rw, unsigned long user_addr,
                 return -EFBIG;
         }
 
-        page_count = ((user_addr + size + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT)-
+        *max_pages = ((user_addr + size + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT)-
                       (user_addr >> CFS_PAGE_SHIFT);
 
-        OBD_ALLOC_WAIT(*pages, page_count * sizeof(**pages));
+        OBD_ALLOC_WAIT(*pages, *max_pages * sizeof(**pages));
         if (*pages) {
                 down_read(&current->mm->mmap_sem);
                 result = get_user_pages(current, current->mm, user_addr,
-                                        page_count, (rw == READ), 0, *pages,
+                                        *max_pages, (rw == READ), 0, *pages,
                                         NULL);
                 up_read(&current->mm->mmap_sem);
-                if (result < 0)
-                        OBD_FREE(*pages, page_count * sizeof(**pages));
+                if (unlikely(result < 0))
+                        OBD_FREE(*pages, *max_pages * sizeof(**pages));
         }
 
         return result;
@@ -143,11 +147,12 @@ static void ll_free_user_pages(struct page **pages, int npages, int do_dirty)
         int i;
 
         for (i = 0; i < npages; i++) {
+                if (pages[i] == NULL)
+                        break;
                 if (do_dirty)
                         set_page_dirty_lock(pages[i]);
                 page_cache_release(pages[i]);
         }
-
         OBD_FREE(pages, npages * sizeof(*pages));
 }
 
@@ -156,7 +161,8 @@ static ssize_t ll_direct_IO_26_seg(int rw, struct inode *inode,
                                    struct obd_info *oinfo,
                                    struct ptlrpc_request_set *set,
                                    size_t size, loff_t file_offset,
-                                   struct page **pages, int page_count)
+                                   struct page **pages, int page_count,
+                                   int locked)
 {
         struct brw_page *pga;
         int i, rc = 0;
@@ -178,6 +184,8 @@ static ssize_t ll_direct_IO_26_seg(int rw, struct inode *inode,
                 pga[i].count = min_t(int, CFS_PAGE_SIZE -(file_offset & ~CFS_PAGE_MASK),
                                      length);
                 pga[i].flag = OBD_BRW_SYNC;
+                if (!locked)
+                        pga[i].flag |= OBD_BRW_SRVLOCK;
                 if (rw == READ)
                         POISON_PAGE(pages[i], 0x0d);
         }
@@ -198,18 +206,18 @@ static ssize_t ll_direct_IO_26_seg(int rw, struct inode *inode,
  * then truncate this to be a full-sized RPC.  This is 22MB for 4kB pages. */
 #define MAX_DIO_SIZE ((128 * 1024 / sizeof(struct brw_page) * CFS_PAGE_SIZE) & \
                       ~(PTLRPC_MAX_BRW_SIZE - 1))
-static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
-                               const struct iovec *iov, loff_t file_offset,
-                               unsigned long nr_segs)
+ssize_t ll_direct_IO(int rw, struct file *file,
+                     const struct iovec *iov, loff_t file_offset,
+                     unsigned long nr_segs, int locked)
 {
-        struct file *file = iocb->ki_filp;
         struct inode *inode = file->f_mapping->host;
-        ssize_t count = iov_length(iov, nr_segs), tot_bytes = 0;
+        ssize_t count = iov_length(iov, nr_segs);
+        ssize_t tot_bytes = 0, result = 0;
         struct ll_inode_info *lli = ll_i2info(inode);
         struct lov_stripe_md *lsm = lli->lli_smd;
         struct ptlrpc_request_set *set;
         struct obd_info oinfo;
-        struct obdo oa;
+        struct obdo oa = { 0 };
         unsigned long seg;
         size_t size = MAX_DIO_SIZE;
         ENTRY;
@@ -265,31 +273,35 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
 
                 while (iov_left > 0) {
                         struct page **pages;
-                        int page_count;
-                        ssize_t result;
+                        int page_count, max_pages = 0;
+                        size_t bytes;
 
+                        bytes = min(size,iov_left);
                         page_count = ll_get_user_pages(rw, user_addr,
-                                                       min(size, iov_left),
-                                                       &pages);
-                        LASSERT(page_count != 0);
-                        if (page_count > 0) {
+                                                       bytes,
+                                                       &pages, &max_pages);
+                        if (likely(page_count > 0)) {
+                                if (unlikely(page_count <  max_pages))
+                                        bytes = page_count << CFS_PAGE_SHIFT;
                                 result = ll_direct_IO_26_seg(rw, inode,
                                                              file->f_mapping,
                                                              &oinfo, set,
-                                                             min(size,iov_left),
+                                                             bytes,
                                                              file_offset, pages,
-                                                             page_count);
-                                ll_free_user_pages(pages, page_count, rw==READ);
+                                                             page_count, locked);
+                                ll_free_user_pages(pages, max_pages, rw==READ);
+                        } else if (page_count == 0) {
+                                GOTO(out, result = -EFAULT);
                         } else {
-                                result = 0;
+                                result = page_count;
                         }
-                        if (page_count < 0 || result <= 0) {
+                        if (unlikely(result <= 0)) {
                                 /* If we can't allocate a large enough buffer
                                  * for the request, shrink it to a smaller
                                  * PAGE_SIZE multiple and try again.
                                  * We should always be able to kmalloc for a
                                  * page worth of page pointers = 4MB on i386. */
-                                if ((page_count == -ENOMEM||result == -ENOMEM)&&
+                                if (result == -ENOMEM &&
                                     size > (CFS_PAGE_SIZE / sizeof(*pages)) *
                                            CFS_PAGE_SIZE) {
                                         size = ((((size / 2) - 1) |
@@ -299,31 +311,31 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb,
                                                (int)size);
                                         continue;
                                 }
-                                if (tot_bytes > 0)
-                                        GOTO(wait_io, tot_bytes);
-                                GOTO(out, tot_bytes = page_count < 0 ? page_count : result);
+                                GOTO(out, result);
                         }
-
                         tot_bytes += result;
                         file_offset += result;
                         iov_left -= result;
                         user_addr += result;
                 }
         }
-
-        if (tot_bytes > 0) {
+out:
+        if (likely(tot_bytes > 0)) {
                 int rc;
-        wait_io:
+
                 rc = ptlrpc_set_wait(set);
-                if (rc)
-                        GOTO(out, tot_bytes = rc);
+                if (unlikely(rc != 0))
+                        GOTO(unlock_mutex, tot_bytes = rc);
                 if (rw == WRITE) {
                         lov_stripe_lock(lsm);
-                        obd_adjust_kms(ll_i2obdexp(inode), lsm, file_offset, 0);
+                        obd_adjust_kms(ll_i2obdexp(inode),
+                                       lsm, file_offset, 0);
                         lov_stripe_unlock(lsm);
                 }
+        } else {
+                tot_bytes = result;
         }
-out:
+unlock_mutex:
         if (rw == READ)
                 UNLOCK_INODE_MUTEX(inode);
 
@@ -331,6 +343,13 @@ out:
         RETURN(tot_bytes);
 }
 
+static ssize_t ll_direct_IO_26(int rw, struct kiocb *kiocb,
+                               const struct iovec *iov, loff_t file_offset,
+                               unsigned long nr_segs)
+{
+        return ll_direct_IO(rw, kiocb->ki_filp, iov, file_offset, nr_segs, 1);
+}
+
 struct address_space_operations ll_aops = {
         .readpage       = ll_readpage,
 //        .readpages      = ll_readpages,
diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c
index 149b9dd..4118a46 100644
--- a/lustre/llite/statahead.c
+++ b/lustre/llite/statahead.c
@@ -178,7 +178,7 @@ static struct ll_statahead_info *ll_sai_alloc(void)
         return sai;
 }
 
-static inline 
+static inline
 struct ll_statahead_info *ll_sai_get(struct ll_statahead_info *sai)
 {
         LASSERT(sai);
@@ -266,7 +266,7 @@ static void ll_sai_entry_fini(struct ll_statahead_info *sai)
         struct ll_inode_info *lli = ll_i2info(sai->sai_inode);
         struct ll_sai_entry  *entry;
         ENTRY;
-        
+
         spin_lock(&lli->lli_lock);
         sai->sai_index_next++;
         if (likely(!list_empty(&sai->sai_entries_stated))) {
@@ -478,7 +478,7 @@ static int ll_statahead_interpret(struct obd_export *exp,
 
         spin_lock(&lli->lli_lock);
         if (unlikely(lli->lli_sai == NULL ||
-            lli->lli_sai->sai_generation != minfo->mi_generation)) {
+                     lli->lli_sai->sai_generation != minfo->mi_generation)) {
                 spin_unlock(&lli->lli_lock);
                 ll_intent_release(it);
                 dput(dentry);
@@ -563,7 +563,7 @@ static int do_sa_lookup(struct inode *dir, struct dentry *dentry)
 {
         struct md_enqueue_info   *minfo;
         struct ldlm_enqueue_info *einfo;
-        int                       rc;                
+        int                       rc;
         ENTRY;
 
         rc = sa_args_prep(dir, dentry, &minfo, &einfo);
@@ -699,15 +699,9 @@ out:
         return rc;
 }
 
-struct ll_sa_thread_args {
-        struct dentry   *sta_parent;
-        pid_t            sta_pid;
-};
-
 static int ll_statahead_thread(void *arg)
 {
-        struct ll_sa_thread_args *sta = arg;
-        struct dentry            *parent = dget(sta->sta_parent);
+        struct dentry            *parent = (struct dentry *)arg;
         struct inode             *dir = parent->d_inode;
         struct ll_inode_info     *lli = ll_i2info(dir);
         struct ll_sb_info        *sbi = ll_i2sbi(dir);
@@ -721,6 +715,15 @@ static int ll_statahead_thread(void *arg)
         spin_lock(&lli->lli_lock);
         if (unlikely(lli->lli_sai == NULL)) {
                 spin_unlock(&lli->lli_lock);
+                CERROR("ll_statahead_info is NULL, parent maybe exit abnormally, "
+                       "dentry@%p %.*s, inode = %lu, pid = %u\n",
+                       parent, parent->d_name.len, parent->d_name.name,
+                       dir->i_ino, lli->lli_opendir_pid);
+                /* At this point, ll_statahead_info is NULL, and parent maybe
+                 * exit abnormally, I can not notify parent even it is alive
+                 * yet. Just put the reference count on parent dentry. */
+                lli->lli_opendir_key = NULL;
+                lli->lli_opendir_pid = 0;
                 dput(parent);
                 RETURN(-EAGAIN);
         } else {
@@ -730,7 +733,7 @@ static int ll_statahead_thread(void *arg)
 
         {
                 char pname[16];
-                snprintf(pname, 15, "ll_sa_%u", sta->sta_pid);
+                snprintf(pname, 15, "ll_sa_%u", lli->lli_opendir_pid);
                 cfs_daemonize(pname);
         }
 
@@ -1018,9 +1021,8 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup)
         struct ll_sb_info        *sbi = ll_i2sbi(dir);
         struct ll_inode_info     *lli = ll_i2info(dir);
         struct ll_statahead_info *sai = lli->lli_sai;
-        struct ll_sa_thread_args  sta;
-        struct l_wait_info        lwi = { 0 };
-        int                       rc;
+        struct l_wait_info        lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
+        int                       rc = 0;
         ENTRY;
 
         LASSERT(lli->lli_opendir_pid == cfs_curproc_pid());
@@ -1064,9 +1066,10 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup)
                         /*
                          * thread started already, avoid double-stat.
                          */
-                        l_wait_event(sai->sai_waitq,
-                                     ll_sai_entry_stated(sai) || sa_is_stopped(sai),
-                                     &lwi);
+                        rc = l_wait_event(sai->sai_waitq,
+                                          ll_sai_entry_stated(sai) ||
+                                          sa_is_stopped(sai),
+                                          &lwi);
                 }
 
                 if (lookup) {
@@ -1085,12 +1088,12 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup)
                 /*
                  * do nothing for revalidate.
                  */
-                RETURN(0);
+                RETURN(rc);
         }
 
          /*
           * I am the "lli_opendir_pid" owner, only me can set "lli_sai".
-          */ 
+          */
         LASSERT(lli->lli_sai == NULL);
 
         rc = is_first_dirent(dir, *dentryp);
@@ -1120,21 +1123,20 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, int lookup)
 
         LASSERT(sai->sai_inode == (*dentryp)->d_parent->d_inode);
 
-        sta.sta_parent = (*dentryp)->d_parent;
-        sta.sta_pid    = cfs_curproc_pid();
-
         lli->lli_sai = sai;
-        rc = cfs_kernel_thread(ll_statahead_thread, &sta, 0);
+        /* get parent reference count here, and put it in ll_statahead_thread */
+        rc = cfs_kernel_thread(ll_statahead_thread, dget((*dentryp)->d_parent), 0);
         if (rc < 0) {
                 CERROR("can't start ll_sa thread, rc: %d\n", rc);
                 lli->lli_opendir_key = NULL;
                 sai->sai_thread.t_flags = SVC_STOPPED;
                 ll_sai_put(sai);
                 LASSERT(lli->lli_sai == NULL);
+                dput((*dentryp)->d_parent);
                 RETURN(-EAGAIN);
         }
 
-        l_wait_event(sai->sai_thread.t_ctl_waitq, 
+        l_wait_event(sai->sai_thread.t_ctl_waitq,
                      sa_is_running(sai) || sa_is_stopped(sai),
                      &lwi);
 
diff --git a/lustre/llite/super.c b/lustre/llite/super.c
deleted file mode 100644
index 18236ea..0000000
--- a/lustre/llite/super.c
+++ /dev/null
@@ -1,141 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#define DEBUG_SUBSYSTEM S_LLITE
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/random.h>
-#include <linux/version.h>
-#include <lustre_lite.h>
-#include <lustre_ha.h>
-#include <lustre_dlm.h>
-#include <linux/init.h>
-#include <linux/fs.h>
-#include <linux/random.h>
-#include <linux/cache_def.h>
-#include <lprocfs_status.h>
-#include "llite_internal.h"
-#include <lustre/lustre_user.h>
-
-extern struct address_space_operations ll_aops;
-extern struct address_space_operations ll_dir_aops;
-
-
-/* exported operations */
-struct super_operations lustre_super_operations =
-{
-        .read_inode2    = ll_read_inode2,
-        .clear_inode    = ll_clear_inode,
-        .put_super      = ll_put_super,
-        .statfs         = ll_statfs,
-        .umount_begin   = ll_umount_begin,
-        .fh_to_dentry   = ll_fh_to_dentry,
-        .dentry_to_fh   = ll_dentry_to_fh,
-        .remount_fs     = ll_remount_fs,
-        .show_options   = ll_show_options,
-};
-
-
-void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
-
-static int __init init_lustre_lite(void)
-{
-        int i, seed[2];
-        struct timeval tv;
-        lnet_process_id_t lnet_id;
-
-        printk(KERN_INFO "Lustre: Lustre Client File System; "
-               "http://www.lustre.org/\n");
-        ll_file_data_slab = cfs_mem_cache_create("ll_file_data",
-                                                 sizeof(struct ll_file_data), 0,
-                                                 SLAB_HWCACHE_ALIGN);
-        if (ll_file_data_slab == NULL)
-                return -ENOMEM;
-
-        if (proc_lustre_root)
-                proc_lustre_fs_root = proc_mkdir("llite", proc_lustre_root);
-
-        ll_register_cache(&ll_cache_definition);
-
-        lustre_register_client_fill_super(ll_fill_super);
-        lustre_register_client_process_config(ll_process_config);
-
-        get_random_bytes(seed, sizeof(seed));
-
-        /* Nodes with small feet have little entropy
-         * the NID for this node gives the most entropy in the low bits */
-        for (i = 0; ; i++) {
-                if (LNetGetId(i, &lnet_id) == -ENOENT) {
-                        break;
-                }
-                if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) {
-                        seed[0] ^= LNET_NIDADDR(lnet_id.nid);
-                }
-        }
-
-        do_gettimeofday(&tv);
-        ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
-
-        return 0;
-}
-
-static void __exit exit_lustre_lite(void)
-{
-        int rc;
-
-        lustre_register_client_fill_super(NULL);
-        lustre_register_client_process_config(NULL);
-
-        ll_unregister_cache(&ll_cache_definition);
-
-        rc = cfs_mem_cache_destroy(ll_file_data_slab);
-        LASSERTF(rc == 0, "couldn't destroy ll_file_data slab\n");
-        if (ll_async_page_slab) {
-                rc = cfs_mem_cache_destroy(ll_async_page_slab);
-                LASSERTF(rc == 0, "couldn't destroy ll_async_page slab\n");
-        }
-
-        if (proc_lustre_fs_root)
-                lprocfs_remove(&proc_lustre_fs_root);
-}
-
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Lustre Lite Client File System");
-MODULE_LICENSE("GPL");
-
-module_init(init_lustre_lite);
-module_exit(exit_lustre_lite);
diff --git a/lustre/llite/super25.c b/lustre/llite/super25.c
index 2078b04..6d8103a 100644
--- a/lustre/llite/super25.c
+++ b/lustre/llite/super25.c
@@ -126,6 +126,7 @@ static int __init init_lustre_lite(void)
         proc_lustre_fs_root = proc_lustre_root ?
                               proc_mkdir("llite", proc_lustre_root) : NULL;
 
+        init_rwsem(&ll_sb_sem);
         ll_register_cache(&ll_cache_definition);
 
         lustre_register_client_fill_super(ll_fill_super);
diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c
index ec6fcc4..351c837 100644
--- a/lustre/llite/symlink.c
+++ b/lustre/llite/symlink.c
@@ -80,7 +80,7 @@ static int ll_readlink_internal(struct inode *inode,
                 CERROR("OBD_MD_LINKNAME not set on reply\n");
                 GOTO(failed, rc = -EPROTO);
         }
-        
+
         LASSERT(symlen != 0);
         if (body->eadatasize != symlen) {
                 CERROR("inode %lu: symlink length %d not expected %d\n",
@@ -168,8 +168,11 @@ static LL_FOLLOW_LINK_RETURN_TYPE ll_follow_link(struct dentry *dentry, struct n
 
         CDEBUG(D_VFSTRACE, "VFS Op\n");
         /* Limit the recursive symlink depth to 5 instead of default
-         * 8 links when kernel has 4k stack to prevent stack overflow. */
-        if (THREAD_SIZE < 8192 && current->link_count >= 5) {
+         * 8 links when kernel has 4k stack to prevent stack overflow.
+         * For 8k stacks we need to limit it to 7 for local servers. */
+        if (THREAD_SIZE < 8192 && current->link_count >= 6) {
+                rc = -ELOOP;
+        } else if (THREAD_SIZE == 8192 && current->link_count >= 8) {
                 rc = -ELOOP;
         } else {
                 down(&lli->lli_size_sem);
@@ -177,7 +180,7 @@ static LL_FOLLOW_LINK_RETURN_TYPE ll_follow_link(struct dentry *dentry, struct n
                 up(&lli->lli_size_sem);
         }
         if (rc) {
-                path_release(nd); /* Kernel assumes that ->follow_link()
+                cfs_path_put(nd); /* Kernel assumes that ->follow_link()
                                      releases nameidata on error */
                 GOTO(out, rc);
         }
diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c
index 1709d2e..8fbc7bf 100644
--- a/lustre/llite/xattr.c
+++ b/lustre/llite/xattr.c
@@ -180,6 +180,12 @@ int ll_setxattr(struct dentry *dentry, const char *name,
                 struct lov_user_md *lump = (struct lov_user_md *)value;
                 int rc = 0;
 
+                /* Attributes that are saved via getxattr will always have
+                 * the stripe_offset as 0.  Instead, the MDS should be
+                 * allowed to pick the starting OST index.   b=17846 */
+                if (lump->lmm_stripe_offset == 0)
+                        lump->lmm_stripe_offset = -1;
+
                 if (S_ISREG(inode->i_mode)) {
                         struct file f;
                         int flags = FMODE_WRITE;
@@ -194,7 +200,10 @@ int ll_setxattr(struct dentry *dentry, const char *name,
                 }
 
                 return rc;
-        }
+        } else if (strcmp(name, "trusted.lma") == 0 &&
+                   !OBD_FAIL_CHECK(OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING))
+                return 0;
+
 
         return ll_setxattr_common(inode, name, value, size, flags,
                                   OBD_MD_FLXATTR);
diff --git a/lustre/lov/Makefile.in b/lustre/lov/Makefile.in
index f714192..00dbeff 100644
--- a/lustre/lov/Makefile.in
+++ b/lustre/lov/Makefile.in
@@ -1,4 +1,6 @@
 MODULES := lov
-lov-objs := lov_log.o lov_obd.o lov_pack.o lproc_lov.o lov_offset.o lov_merge.o lov_request.o lov_qos.o lov_ea.o
+lov-objs := lov_log.o lov_obd.o lov_pack.o lproc_lov.o lov_offset.o lov_merge.o lov_request.o lov_qos.o lov_ea.o lov_pool.o
+
+EXTRA_DIST = $(lov-objs:.o=.c) lov_internal.h
 
 @INCLUDE_RULES@
diff --git a/lustre/lov/autoMakefile.am b/lustre/lov/autoMakefile.am
index 8c3af02..7335071 100644
--- a/lustre/lov/autoMakefile.am
+++ b/lustre/lov/autoMakefile.am
@@ -36,7 +36,7 @@
 
 if LIBLUSTRE
 noinst_LIBRARIES = liblov.a
-liblov_a_SOURCES = lov_log.c lov_obd.c lov_pack.c lov_request.c lov_offset.c lov_qos.c lov_merge.c lov_ea.c lov_internal.h
+liblov_a_SOURCES = lov_log.c lov_pool.c lov_obd.c lov_pack.c lov_request.c lov_offset.c lov_qos.c lov_merge.c lov_ea.c lov_internal.h
 liblov_a_CPPFLAGS = $(LLCPPFLAGS)
 liblov_a_CFLAGS = $(LLCFLAGS)
 endif
@@ -51,6 +51,7 @@ macos_PROGRAMS := lov
 
 lov_SOURCES :=          \
         lov_log.c       \
+	lov_pool.c	\
         lov_obd.c       \
         lov_pack.c      \
         lov_request.c   \
@@ -73,5 +74,4 @@ endif # MODULES
 
 install-data-hook: $(install_data_hook)
 
-DIST_SOURCES = $(lov-objs:.o=.c) lov_internal.h
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
diff --git a/lustre/lov/autoMakefile.in b/lustre/lov/autoMakefile.in
index c060fa7..cb7f0b6 100644
--- a/lustre/lov/autoMakefile.in
+++ b/lustre/lov/autoMakefile.in
@@ -209,10 +209,11 @@ MAKEINFO = @MAKEINFO@
 MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
+
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -329,7 +330,7 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @LIBLUSTRE_TRUE at noinst_LIBRARIES = liblov.a
- at LIBLUSTRE_TRUE@liblov_a_SOURCES = lov_log.c lov_obd.c lov_pack.c lov_request.c lov_offset.c lov_qos.c lov_merge.c lov_ea.c lov_internal.h
+ at LIBLUSTRE_TRUE@liblov_a_SOURCES = lov_log.c lov_pool.c lov_obd.c lov_pack.c lov_request.c lov_offset.c lov_qos.c lov_merge.c lov_ea.c lov_internal.h
 @LIBLUSTRE_TRUE at liblov_a_CPPFLAGS = $(LLCPPFLAGS)
 @LIBLUSTRE_TRUE at liblov_a_CFLAGS = $(LLCFLAGS)
 
@@ -339,6 +340,7 @@ target_vendor = @target_vendor@
 
 @DARWIN_TRUE@@MODULES_TRUE at lov_SOURCES := \
 @DARWIN_TRUE@@MODULES_TRUE@        lov_log.c       \
+ at DARWIN_TRUE@@MODULES_TRUE@	lov_pool.c	\
 @DARWIN_TRUE@@MODULES_TRUE@        lov_obd.c       \
 @DARWIN_TRUE@@MODULES_TRUE@        lov_pack.c      \
 @DARWIN_TRUE@@MODULES_TRUE@        lov_request.c   \
@@ -355,8 +357,6 @@ target_vendor = @target_vendor@
 @DARWIN_TRUE@@MODULES_TRUE at plist_DATA := Info.plist
 
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
-
-DIST_SOURCES = $(lov-objs:.o=.c) lov_internal.h
 subdir = lustre/lov
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -366,9 +366,11 @@ LIBRARIES = $(noinst_LIBRARIES)
 
 liblov_a_AR = $(AR) cru
 liblov_a_LIBADD =
-am__liblov_a_SOURCES_DIST = lov_log.c lov_obd.c lov_pack.c lov_request.c \
-	lov_offset.c lov_qos.c lov_merge.c lov_ea.c lov_internal.h
+am__liblov_a_SOURCES_DIST = lov_log.c lov_pool.c lov_obd.c lov_pack.c \
+	lov_request.c lov_offset.c lov_qos.c lov_merge.c lov_ea.c \
+	lov_internal.h
 @LIBLUSTRE_TRUE at am_liblov_a_OBJECTS = liblov_a-lov_log.$(OBJEXT) \
+ at LIBLUSTRE_TRUE@	liblov_a-lov_pool.$(OBJEXT) \
 @LIBLUSTRE_TRUE@	liblov_a-lov_obd.$(OBJEXT) \
 @LIBLUSTRE_TRUE@	liblov_a-lov_pack.$(OBJEXT) \
 @LIBLUSTRE_TRUE@	liblov_a-lov_request.$(OBJEXT) \
@@ -383,9 +385,10 @@ liblov_a_OBJECTS = $(am_liblov_a_OBJECTS)
 @DARWIN_TRUE@@MODULES_FALSE at macos_PROGRAMS =
 PROGRAMS = $(macos_PROGRAMS)
 
-am__lov_SOURCES_DIST = lov_log.c lov_obd.c lov_pack.c lov_request.c \
-	lov_merge.c lov_qos.c lov_offset.c lov_internal.h
+am__lov_SOURCES_DIST = lov_log.c lov_pool.c lov_obd.c lov_pack.c \
+	lov_request.c lov_merge.c lov_qos.c lov_offset.c lov_internal.h
 @DARWIN_TRUE@@MODULES_TRUE at am_lov_OBJECTS = lov-lov_log.$(OBJEXT) \
+ at DARWIN_TRUE@@MODULES_TRUE@	lov-lov_pool.$(OBJEXT) \
 @DARWIN_TRUE@@MODULES_TRUE@	lov-lov_obd.$(OBJEXT) \
 @DARWIN_TRUE@@MODULES_TRUE@	lov-lov_pack.$(OBJEXT) \
 @DARWIN_TRUE@@MODULES_TRUE@	lov-lov_request.$(OBJEXT) \
@@ -407,6 +410,7 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE@	./$(DEPDIR)/liblov_a-lov_obd.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/liblov_a-lov_offset.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/liblov_a-lov_pack.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/liblov_a-lov_pool.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/liblov_a-lov_qos.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/liblov_a-lov_request.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/lov-lov_log.Po \
@@ -414,12 +418,14 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE@	./$(DEPDIR)/lov-lov_obd.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/lov-lov_offset.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/lov-lov_pack.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/lov-lov_pool.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/lov-lov_qos.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/lov-lov_request.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__liblov_a_SOURCES_DIST) $(am__lov_SOURCES_DIST)
 DATA = $(modulefs_DATA) $(plist_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
@@ -485,6 +491,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liblov_a-lov_obd.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liblov_a-lov_offset.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liblov_a-lov_pack.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liblov_a-lov_pool.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liblov_a-lov_qos.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/liblov_a-lov_request.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lov-lov_log.Po at am__quote@
@@ -492,6 +499,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lov-lov_obd.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lov-lov_offset.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lov-lov_pack.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lov-lov_pool.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lov-lov_qos.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lov-lov_request.Po at am__quote@
 
@@ -539,6 +547,28 @@ liblov_a-lov_log.obj: lov_log.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblov_a_CPPFLAGS) $(CPPFLAGS) $(liblov_a_CFLAGS) $(CFLAGS) -c -o liblov_a-lov_log.obj `if test -f 'lov_log.c'; then $(CYGPATH_W) 'lov_log.c'; else $(CYGPATH_W) '$(srcdir)/lov_log.c'; fi`
 
+liblov_a-lov_pool.o: lov_pool.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblov_a_CPPFLAGS) $(CPPFLAGS) $(liblov_a_CFLAGS) $(CFLAGS) -MT liblov_a-lov_pool.o -MD -MP -MF "$(DEPDIR)/liblov_a-lov_pool.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o liblov_a-lov_pool.o `test -f 'lov_pool.c' || echo '$(srcdir)/'`lov_pool.c; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/liblov_a-lov_pool.Tpo" "$(DEPDIR)/liblov_a-lov_pool.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/liblov_a-lov_pool.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='lov_pool.c' object='liblov_a-lov_pool.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/liblov_a-lov_pool.Po' tmpdepfile='$(DEPDIR)/liblov_a-lov_pool.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblov_a_CPPFLAGS) $(CPPFLAGS) $(liblov_a_CFLAGS) $(CFLAGS) -c -o liblov_a-lov_pool.o `test -f 'lov_pool.c' || echo '$(srcdir)/'`lov_pool.c
+
+liblov_a-lov_pool.obj: lov_pool.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblov_a_CPPFLAGS) $(CPPFLAGS) $(liblov_a_CFLAGS) $(CFLAGS) -MT liblov_a-lov_pool.obj -MD -MP -MF "$(DEPDIR)/liblov_a-lov_pool.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o liblov_a-lov_pool.obj `if test -f 'lov_pool.c'; then $(CYGPATH_W) 'lov_pool.c'; else $(CYGPATH_W) '$(srcdir)/lov_pool.c'; fi`; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/liblov_a-lov_pool.Tpo" "$(DEPDIR)/liblov_a-lov_pool.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/liblov_a-lov_pool.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='lov_pool.c' object='liblov_a-lov_pool.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/liblov_a-lov_pool.Po' tmpdepfile='$(DEPDIR)/liblov_a-lov_pool.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblov_a_CPPFLAGS) $(CPPFLAGS) $(liblov_a_CFLAGS) $(CFLAGS) -c -o liblov_a-lov_pool.obj `if test -f 'lov_pool.c'; then $(CYGPATH_W) 'lov_pool.c'; else $(CYGPATH_W) '$(srcdir)/lov_pool.c'; fi`
+
 liblov_a-lov_obd.o: lov_obd.c
 @am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(liblov_a_CPPFLAGS) $(CPPFLAGS) $(liblov_a_CFLAGS) $(CFLAGS) -MT liblov_a-lov_obd.o -MD -MP -MF "$(DEPDIR)/liblov_a-lov_obd.Tpo" \
 @am__fastdepCC_TRUE@	  -c -o liblov_a-lov_obd.o `test -f 'lov_obd.c' || echo '$(srcdir)/'`lov_obd.c; \
@@ -715,6 +745,28 @@ lov-lov_log.obj: lov_log.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lov_CFLAGS) $(CFLAGS) -c -o lov-lov_log.obj `if test -f 'lov_log.c'; then $(CYGPATH_W) 'lov_log.c'; else $(CYGPATH_W) '$(srcdir)/lov_log.c'; fi`
 
+lov-lov_pool.o: lov_pool.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lov_CFLAGS) $(CFLAGS) -MT lov-lov_pool.o -MD -MP -MF "$(DEPDIR)/lov-lov_pool.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o lov-lov_pool.o `test -f 'lov_pool.c' || echo '$(srcdir)/'`lov_pool.c; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/lov-lov_pool.Tpo" "$(DEPDIR)/lov-lov_pool.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/lov-lov_pool.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='lov_pool.c' object='lov-lov_pool.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/lov-lov_pool.Po' tmpdepfile='$(DEPDIR)/lov-lov_pool.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lov_CFLAGS) $(CFLAGS) -c -o lov-lov_pool.o `test -f 'lov_pool.c' || echo '$(srcdir)/'`lov_pool.c
+
+lov-lov_pool.obj: lov_pool.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lov_CFLAGS) $(CFLAGS) -MT lov-lov_pool.obj -MD -MP -MF "$(DEPDIR)/lov-lov_pool.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o lov-lov_pool.obj `if test -f 'lov_pool.c'; then $(CYGPATH_W) 'lov_pool.c'; else $(CYGPATH_W) '$(srcdir)/lov_pool.c'; fi`; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/lov-lov_pool.Tpo" "$(DEPDIR)/lov-lov_pool.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/lov-lov_pool.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='lov_pool.c' object='lov-lov_pool.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/lov-lov_pool.Po' tmpdepfile='$(DEPDIR)/lov-lov_pool.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lov_CFLAGS) $(CFLAGS) -c -o lov-lov_pool.obj `if test -f 'lov_pool.c'; then $(CYGPATH_W) 'lov_pool.c'; else $(CYGPATH_W) '$(srcdir)/lov_pool.c'; fi`
+
 lov-lov_obd.o: lov_obd.c
 @am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lov_CFLAGS) $(CFLAGS) -MT lov-lov_obd.o -MD -MP -MF "$(DEPDIR)/lov-lov_obd.Tpo" \
 @am__fastdepCC_TRUE@	  -c -o lov-lov_obd.o `test -f 'lov_obd.c' || echo '$(srcdir)/'`lov_obd.c; \
diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c
index 84da9aa..355c93e 100755
--- a/lustre/lov/lov_ea.c
+++ b/lustre/lov/lov_ea.c
@@ -68,27 +68,28 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes,
 
         if (stripe_count == 0 || stripe_count > LOV_V1_INSANE_STRIPE_COUNT) {
                 CERROR("bad stripe count %d\n", stripe_count);
-                lov_dump_lmm_v1(D_WARNING, lmm);
+                lov_dump_lmm(D_WARNING, lmm);
                 return -EINVAL;
         }
 
         if (lmm->lmm_object_id == 0) {
                 CERROR("zero object id\n");
-                lov_dump_lmm_v1(D_WARNING, lmm);
+                lov_dump_lmm(D_WARNING, lmm);
                 return -EINVAL;
         }
 
         if (lmm->lmm_pattern != cpu_to_le32(LOV_PATTERN_RAID0)) {
                 CERROR("bad striping pattern\n");
-                lov_dump_lmm_v1(D_WARNING, lmm);
+                lov_dump_lmm(D_WARNING, lmm);
                 return -EINVAL;
         }
 
         if (lmm->lmm_stripe_size == 0 ||
-             (le32_to_cpu(lmm->lmm_stripe_size)&(LOV_MIN_STRIPE_SIZE-1)) != 0) {
+            (le32_to_cpu(lmm->lmm_stripe_size)&(LOV_MIN_STRIPE_SIZE-1)) != 0) {
                 CERROR("bad stripe size %u\n",
                        le32_to_cpu(lmm->lmm_stripe_size));
-                lov_dump_lmm_v1(D_WARNING, lmm);
+                if (stripe_count != -1)
+                        lov_dump_lmm(D_WARNING, lmm);
                 return -EINVAL;
         }
         return 0;
@@ -116,6 +117,7 @@ struct lov_stripe_md *lsm_alloc_plain(int stripe_count, int *size)
                 lsm->lsm_oinfo[i] = loi;
         }
         lsm->lsm_stripe_count = stripe_count;
+        lsm->lsm_pool_name[0] = '\0';
         return lsm;
 
 err:
@@ -140,10 +142,15 @@ void lsm_free_plain(struct lov_stripe_md *lsm)
 static void lsm_unpackmd_common(struct lov_stripe_md *lsm,
                                 struct lov_mds_md *lmm)
 {
+        /*
+         * This supposes lov_mds_md_v1/v3 first fields are
+         * are the same
+         */
         lsm->lsm_object_id = le64_to_cpu(lmm->lmm_object_id);
         lsm->lsm_object_gr = le64_to_cpu(lmm->lmm_object_gr);
         lsm->lsm_stripe_size = le32_to_cpu(lmm->lmm_stripe_size);
         lsm->lsm_pattern = le32_to_cpu(lmm->lmm_pattern);
+        lsm->lsm_pool_name[0] = '\0';
 }
 
 static void
@@ -195,20 +202,20 @@ static int lsm_destroy_plain(struct lov_stripe_md *lsm, struct obdo *oa,
         return 0;
 }
 
-static int lsm_lmm_verify_plain(struct lov_mds_md *lmm, int lmm_bytes,
+static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes,
                              int *stripe_count)
 {
         if (lmm_bytes < sizeof(*lmm)) {
-                CERROR("lov_mds_md too small: %d, need at least %d\n",
+                CERROR("lov_mds_md_v1 too small: %d, need at least %d\n",
                        lmm_bytes, (int)sizeof(*lmm));
                 return -EINVAL;
         }
 
         *stripe_count = le32_to_cpu(lmm->lmm_stripe_count);
 
-        if (lmm_bytes < lov_mds_md_v1_size(*stripe_count)) {
-                CERROR("LOV EA too small: %d, need %d\n",
-                       lmm_bytes, lov_mds_md_v1_size(*stripe_count));
+        if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V1)) {
+                CERROR("LOV EA V1 too small: %d, need %d\n",
+                       lmm_bytes, lov_mds_md_size(*stripe_count, LOV_MAGIC_V1));
                 lov_dump_lmm_v1(D_WARNING, lmm);
                 return -EINVAL;
         }
@@ -216,7 +223,7 @@ static int lsm_lmm_verify_plain(struct lov_mds_md *lmm, int lmm_bytes,
         return lsm_lmm_verify_common(lmm, lmm_bytes, *stripe_count);
 }
 
-int lsm_unpackmd_plain(struct lov_obd *lov, struct lov_stripe_md *lsm,
+int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm,
                     struct lov_mds_md_v1 *lmm)
 {
         struct lov_oinfo *loi;
@@ -247,7 +254,7 @@ int lsm_unpackmd_plain(struct lov_obd *lov, struct lov_stripe_md *lsm,
         return 0;
 }
 
-struct lsm_operations lsm_plain_ops = {
+struct lsm_operations lsm_v1_ops = {
         .lsm_free            = lsm_free_plain,
         .lsm_destroy         = lsm_destroy_plain,
         .lsm_stripe_by_index    = lsm_stripe_by_index_plain,
@@ -256,8 +263,8 @@ struct lsm_operations lsm_plain_ops = {
         .lsm_stripe_offset_by_index  = lsm_stripe_offset_by_index_plain,
         .lsm_stripe_offset_by_offset = lsm_stripe_offset_by_offset_plain,
         .lsm_stripe_index_by_offset  = lsm_stripe_index_by_offset_plain,
-        .lsm_lmm_verify         = lsm_lmm_verify_plain,
-        .lsm_unpackmd           = lsm_unpackmd_plain,
+        .lsm_lmm_verify         = lsm_lmm_verify_v1,
+        .lsm_unpackmd           = lsm_unpackmd_v1,
 };
 
 struct lov_extent *lovea_off2le(struct lov_stripe_md *lsm, obd_off lov_off)
@@ -492,7 +499,7 @@ static int lsm_revalidate_join(struct lov_stripe_md *lsm,
         OBD_ALLOC(lsm->lsm_array->lai_ext_array,lsm->lsm_array->lai_ext_count *
                                                 sizeof (struct lov_extent));
         if (!lsm->lsm_array->lai_ext_array)
-                GOTO(release_ctxt, rc = -ENOMEM);        
+                GOTO(release_ctxt, rc = -ENOMEM);
 
         CDEBUG(D_INFO, "get lsm logid: "LPU64":"LPU64"\n",
                lsm->lsm_array->lai_array_id.lgl_oid,
@@ -518,7 +525,7 @@ release_ctxt:
         RETURN(rc);
 }
 
-int lsm_destroy_join(struct lov_stripe_md *lsm, struct obdo *oa, 
+int lsm_destroy_join(struct lov_stripe_md *lsm, struct obdo *oa,
                       struct obd_export *md_exp)
 {
         struct llog_ctxt *ctxt;
@@ -623,3 +630,79 @@ struct lsm_operations lsm_join_ops = {
         .lsm_lmm_verify         = lsm_lmm_verify_join,
         .lsm_unpackmd           = lsm_unpackmd_join,
 };
+
+
+static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes,
+                             int *stripe_count)
+{
+        struct lov_mds_md_v3 *lmm;
+
+        lmm = (struct lov_mds_md_v3 *)lmmv1;
+
+        if (lmm_bytes < sizeof(*lmm)) {
+                CERROR("lov_mds_md_v3 too small: %d, need at least %d\n",
+                       lmm_bytes, (int)sizeof(*lmm));
+                return -EINVAL;
+        }
+
+        *stripe_count = le32_to_cpu(lmm->lmm_stripe_count);
+
+        if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V3)) {
+                CERROR("LOV EA V3 too small: %d, need %d\n",
+                       lmm_bytes, lov_mds_md_size(*stripe_count, LOV_MAGIC_V3));
+                lov_dump_lmm_v3(D_WARNING, lmm);
+                return -EINVAL;
+        }
+
+        return lsm_lmm_verify_common((struct lov_mds_md_v1 *)lmm, lmm_bytes,
+                                     *stripe_count);
+}
+
+int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
+                    struct lov_mds_md *lmmv1)
+{
+        struct lov_mds_md_v3 *lmm;
+        struct lov_oinfo *loi;
+        int i;
+
+        lmm = (struct lov_mds_md_v3 *)lmmv1;
+
+        lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm);
+        strncpy(lsm->lsm_pool_name, lmm->lmm_pool_name, LOV_MAXPOOLNAME);
+
+        for (i = 0; i < lsm->lsm_stripe_count; i++) {
+                /* XXX LOV STACKING call down to osc_unpackmd() */
+                loi = lsm->lsm_oinfo[i];
+                loi->loi_id = le64_to_cpu(lmm->lmm_objects[i].l_object_id);
+                loi->loi_gr = le64_to_cpu(lmm->lmm_objects[i].l_object_gr);
+                loi->loi_ost_idx = le32_to_cpu(lmm->lmm_objects[i].l_ost_idx);
+                loi->loi_ost_gen = le32_to_cpu(lmm->lmm_objects[i].l_ost_gen);
+                if (loi->loi_ost_idx >= lov->desc.ld_tgt_count) {
+                        CERROR("OST index %d more than OST count %d\n",
+                               loi->loi_ost_idx, lov->desc.ld_tgt_count);
+                        lov_dump_lmm_v3(D_WARNING, lmm);
+                        return -EINVAL;
+                }
+                if (!lov->lov_tgts[loi->loi_ost_idx]) {
+                        CERROR("OST index %d missing\n", loi->loi_ost_idx);
+                        lov_dump_lmm_v3(D_WARNING, lmm);
+                        return -EINVAL;
+                }
+        }
+
+        return 0;
+}
+
+struct lsm_operations lsm_v3_ops = {
+        .lsm_free            = lsm_free_plain,
+        .lsm_destroy         = lsm_destroy_plain,
+        .lsm_stripe_by_index    = lsm_stripe_by_index_plain,
+        .lsm_stripe_by_offset   = lsm_stripe_by_offset_plain,
+        .lsm_revalidate         = lsm_revalidate_plain,
+        .lsm_stripe_offset_by_index  = lsm_stripe_offset_by_index_plain,
+        .lsm_stripe_offset_by_offset = lsm_stripe_offset_by_offset_plain,
+        .lsm_stripe_index_by_offset  = lsm_stripe_index_by_offset_plain,
+        .lsm_lmm_verify         = lsm_lmm_verify_v3,
+        .lsm_unpackmd           = lsm_unpackmd_v3,
+};
+
diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h
index 79394c7..c6da00c 100644
--- a/lustre/lov/lov_internal.h
+++ b/lustre/lov/lov_internal.h
@@ -37,6 +37,7 @@
 #ifndef LOV_INTERNAL_H
 #define LOV_INTERNAL_H
 
+#include <obd_class.h>
 #include <lustre/lustre_user.h>
 
 struct lov_lock_handles {
@@ -157,6 +158,8 @@ int lov_merge_lvb(struct obd_export *exp, struct lov_stripe_md *lsm,
                   struct ost_lvb *lvb, int kms_only);
 int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
                    obd_off size, int shrink);
+int lov_update_lvb(struct obd_export *exp, struct lov_stripe_md *lsm,
+                   struct ost_lvb *lvb, obd_flag valid);
 
 /* lov_offset.c */
 obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size,
@@ -174,10 +177,12 @@ int lov_stripe_number(struct lov_stripe_md *lsm, obd_off lov_off);
 #define LOV_USES_ASSIGNED_STRIPE        0
 #define LOV_USES_DEFAULT_STRIPE         1
 int qos_add_tgt(struct obd_device *obd, __u32 index);
-int qos_del_tgt(struct obd_device *obd, __u32 index);
+int qos_del_tgt(struct obd_device *obd, struct lov_tgt_desc *tgt);
 void qos_shrink_lsm(struct lov_request_set *set);
 int qos_prep_create(struct obd_export *exp, struct lov_request_set *set);
 void qos_update(struct lov_obd *lov);
+void qos_statfs_done(struct lov_obd *lov);
+void qos_statfs_update(struct obd_device *obd, __u64 max_age, int wait);
 int qos_remedy_create(struct lov_request_set *set, struct lov_request *req);
 
 /* lov_request.c */
@@ -219,9 +224,8 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo,
                        struct lov_request_set **reqset);
 int lov_fini_punch_set(struct lov_request_set *set);
 int lov_prep_sync_set(struct obd_export *exp, struct obd_info *obd_info,
-                      struct obdo *src_oa,
-                      struct lov_stripe_md *lsm, obd_off start,
-                      obd_off end, struct lov_request_set **reqset);
+                      obd_off start, obd_off end,
+                      struct lov_request_set **reqset);
 int lov_fini_sync_set(struct lov_request_set *set);
 int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo,
                          struct ldlm_enqueue_info *einfo,
@@ -248,6 +252,7 @@ void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs,
 int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,
                     int success);
 int lov_fini_statfs_set(struct lov_request_set *set);
+int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc);
 
 /* lov_obd.c */
 void lov_fix_desc(struct lov_desc *desc);
@@ -256,8 +261,6 @@ void lov_fix_desc_stripe_count(__u32 *val);
 void lov_fix_desc_pattern(__u32 *val);
 void lov_fix_desc_qos_maxage(__u32 *val);
 int lov_get_stripecnt(struct lov_obd *lov, __u32 stripe_count);
-void lov_getref(struct obd_device *obd);
-void lov_putref(struct obd_device *obd);
 
 /* lov_log.c */
 int lov_llog_init(struct obd_device *obd, struct obd_device *tgt,
@@ -281,6 +284,9 @@ void lov_free_memmd(struct lov_stripe_md **lsmp);
 
 void lov_dump_lmm_v1(int level, struct lov_mds_md_v1 *lmm);
 void lov_dump_lmm_join(int level, struct lov_mds_md_join *lmmj);
+void lov_dump_lmm_v3(int level, struct lov_mds_md_v3 *lmm);
+void lov_dump_lmm(int level, void *lmm);
+
 /* lov_ea.c */
 int lov_unpackmd_join(struct lov_obd *lov, struct lov_stripe_md *lsm,
                       struct lov_mds_md *lmm);
@@ -302,6 +308,26 @@ static inline void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
 }
 #endif
 
+/* pools */
+extern lustre_hash_ops_t pool_hash_operations;
+
+/* ost_pool methods */
+int lov_ost_pool_init(struct ost_pool *op, unsigned int count);
+int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count);
+int lov_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count);
+int lov_ost_pool_remove(struct ost_pool *op, __u32 idx);
+int lov_ost_pool_free(struct ost_pool *op);
+
+/* high level pool methods */
+int lov_pool_new(struct obd_device *obd, char *poolname);
+int lov_pool_del(struct obd_device *obd, char *poolname);
+int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname);
+int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname);
+void lov_dump_pool(int level, struct pool_desc *pool);
+struct pool_desc *lov_find_pool(struct lov_obd *lov, char *poolname);
+int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool);
+void lov_pool_putref(struct pool_desc *pool);
+
 #if BITS_PER_LONG == 64
 # define ll_do_div64(n,base) ({                                 \
         uint64_t __base = (base);                               \
diff --git a/lustre/lov/lov_log.c b/lustre/lov/lov_log.c
index d4964b0..57f5ce7 100644
--- a/lustre/lov/lov_log.c
+++ b/lustre/lov/lov_log.c
@@ -92,13 +92,19 @@ static int lov_llog_origin_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
                 case MDS_UNLINK_REC: {
                         struct llog_unlink_rec *lur = (struct llog_unlink_rec *)rec;
                         lur->lur_oid = loi->loi_id;
-                        lur->lur_ogen = loi->loi_gr;
+                        lur->lur_ogr = loi->loi_gr;
                         break;
                 }
                 case MDS_SETATTR_REC: {
                         struct llog_setattr_rec *lsr = (struct llog_setattr_rec *)rec;
                         lsr->lsr_oid = loi->loi_id;
-                        lsr->lsr_ogen = loi->loi_gr;
+                        lsr->lsr_ogr = loi->loi_gr;
+                        break;
+                }
+                case MDS_SETATTR64_REC: {
+                        struct llog_setattr64_rec *lsr = (struct llog_setattr64_rec *)rec;
+                        lsr->lsr_oid = loi->loi_id;
+                        lsr->lsr_ogr = loi->loi_gr;
                         break;
                 }
                 default:
@@ -110,9 +116,17 @@ static int lov_llog_origin_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
                         llog_ctxt_put(cctxt);
                         cctxt = NULL;
                 }
-                rc = llog_add(cctxt, rec, NULL, logcookies + cookies,
-                              numcookies - cookies);
-                llog_ctxt_put(cctxt);
+
+                if (cctxt && cctxt->loc_flags & LLOG_CTXT_FLAG_UNINITIALIZED) {
+                        llog_ctxt_put(cctxt);
+                        rc = -EAGAIN;
+                } else {
+                        /* "cctxt == NULL" will be checked in llog_add */
+                        rc = llog_add(cctxt, rec, NULL, logcookies + cookies,
+                                      numcookies - cookies);
+                        llog_ctxt_put(cctxt);
+                }
+
                 if (rc < 0) {
                         CERROR("Can't add llog (rc = %d) for stripe %i\n",
                                rc, cookies);
@@ -136,7 +150,7 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt,
         int i, rc = 0, err = 0;
         ENTRY;
 
-        lov_getref(obd);
+        obd_getref(obd);
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 struct obd_device *child;
                 struct llog_ctxt *cctxt;
@@ -157,7 +171,7 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt,
                                 err = rc;
                 }
         }
-        lov_putref(obd);
+        obd_putref(obd);
 
         RETURN(err);
 }
@@ -175,7 +189,7 @@ static int lov_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *ls
         LASSERT(count == lsm->lsm_stripe_count);
 
         lov = &obd->u.lov;
-        lov_getref(obd);
+        obd_getref(obd);
         for (i = 0; i < count; i++, cookies++) {
                 struct lov_oinfo *loi = lsm->lsm_oinfo[i];
                 struct obd_device *child = 
@@ -194,7 +208,7 @@ static int lov_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *ls
                                 rc = err;
                 }
         }
-        lov_putref(obd);
+        obd_putref(obd);
         RETURN(rc);
 }
 
@@ -227,7 +241,7 @@ int lov_llog_init(struct obd_device *obd, struct obd_device *tgt,
         if (rc)
                 GOTO(err_cleanup, rc);
 
-        lov_getref(obd);
+        obd_getref(obd);
         for (i = 0; i < lov->desc.ld_tgt_count ; i++) {
                 if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active)
                         continue;
@@ -245,7 +259,7 @@ int lov_llog_init(struct obd_device *obd, struct obd_device *tgt,
                                 err = rc;
                 }
         }
-        lov_putref(obd);
+        obd_putref(obd);
         GOTO(err_cleanup, err);
 err_cleanup:
         if (err) {
diff --git a/lustre/lov/lov_merge.c b/lustre/lov/lov_merge.c
index 9348baa..c30f5f1 100644
--- a/lustre/lov/lov_merge.c
+++ b/lustre/lov/lov_merge.c
@@ -92,19 +92,14 @@ int lov_merge_lvb(struct obd_export *exp, struct lov_stripe_md *lsm,
                 lov_size = lov_stripe_size(lsm, tmpsize, i);
                 if (lov_size > size)
                         size = lov_size;
-                /* merge blocks, mtime, atime */
+                /* merge blocks, mtime, atime, ctime */
                 blocks += loi->loi_lvb.lvb_blocks;
+                if (loi->loi_lvb.lvb_mtime > current_mtime)
+                        current_mtime = loi->loi_lvb.lvb_mtime;
                 if (loi->loi_lvb.lvb_atime > current_atime)
                         current_atime = loi->loi_lvb.lvb_atime;
-
-                /* mtime is always updated with ctime, but can be set in past.
-                   As write and utime(2) may happen within 1 second, and utime's
-                   mtime has a priority over write's one, leave mtime from mds 
-                   for the same ctimes. */
-                if (loi->loi_lvb.lvb_ctime > current_ctime) {
+                if (loi->loi_lvb.lvb_ctime > current_ctime)
                         current_ctime = loi->loi_lvb.lvb_ctime;
-                        current_mtime = loi->loi_lvb.lvb_mtime;
-                }
         }
 
         lvb->lvb_size = size;
@@ -177,8 +172,6 @@ void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_flag valid,
                         tgt->o_blksize += src->o_blksize;
                 if (valid & OBD_MD_FLCTIME && tgt->o_ctime < src->o_ctime)
                         tgt->o_ctime = src->o_ctime;
-                /* Only mtime from OSTs are merged here, as they cannot be set
-                   in past (only MDS's mtime can) do not look at ctime. */
                 if (valid & OBD_MD_FLMTIME && tgt->o_mtime < src->o_mtime)
                         tgt->o_mtime = src->o_mtime;
         } else {
@@ -189,3 +182,24 @@ void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_flag valid,
                 *set = 1;
         }
 }
+
+int lov_update_lvb(struct obd_export *exp, struct lov_stripe_md *lsm,
+                   struct ost_lvb *lvb, obd_flag valid)
+{
+        int i;
+        struct lov_oinfo *loi;
+
+        LASSERT_SPIN_LOCKED(&lsm->lsm_lock);
+        LASSERT(lsm->lsm_lock_owner == cfs_current());
+
+        for (i = 0; i < lsm->lsm_stripe_count; i++) {
+                loi = lsm->lsm_oinfo[i];
+                if (valid & OBD_MD_FLATIME)
+                        loi->loi_lvb.lvb_atime = lvb->lvb_atime;
+                if (valid & OBD_MD_FLMTIME)
+                        loi->loi_lvb.lvb_mtime = lvb->lvb_mtime;
+                if (valid & OBD_MD_FLCTIME)
+                        loi->loi_lvb.lvb_ctime = lvb->lvb_ctime;
+        }
+        return 0;
+}
diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c
index 247fd16..5816890 100644
--- a/lustre/lov/lov_obd.c
+++ b/lustre/lov/lov_obd.c
@@ -71,7 +71,7 @@
 
 /* Keep a refcount of lov->tgt usage to prevent racing with addition/deletion.
    Any function that expects lov_tgts to remain stationary must take a ref. */
-void lov_getref(struct obd_device *obd)
+static void lov_getref(struct obd_device *obd)
 {
         struct lov_obd *lov = &obd->u.lov;
 
@@ -82,26 +82,44 @@ void lov_getref(struct obd_device *obd)
         return;
 }
 
-static void __lov_del_obd(struct obd_device *obd, __u32 index);
+static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt);
 
-void lov_putref(struct obd_device *obd)
+static void lov_putref(struct obd_device *obd)
 {
         struct lov_obd *lov = &obd->u.lov;
+        CFS_LIST_HEAD(kill);
+        struct lov_tgt_desc *tgt;
+
         mutex_down(&lov->lov_lock);
         /* ok to dec to 0 more than once -- ltd_exp's will be null */
         if (atomic_dec_and_test(&lov->lov_refcount) && lov->lov_death_row) {
                 int i;
-                CDEBUG(D_CONFIG, "destroying %d lov targets\n", 
+                struct lov_tgt_desc *n;
+                CDEBUG(D_CONFIG, "destroying %d lov targets\n",
                        lov->lov_death_row);
                 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
-                        if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_reap)
+                        tgt = lov->lov_tgts[i];
+
+                        if (!tgt || !tgt->ltd_reap)
                                 continue;
-                        /* Disconnect and delete from list */
-                        __lov_del_obd(obd, i);
+                        list_add(&tgt->ltd_kill, &kill);
+                        /* XXX - right now there is a dependency on ld_tgt_count
+                         * being the maximum tgt index for computing the
+                         * mds_max_easize. So we can't shrink it. */
+                        lov_ost_pool_remove(&lov->lov_packed, i);
+                        lov->lov_tgts[i] = NULL;
                         lov->lov_death_row--;
                 }
+                mutex_up(&lov->lov_lock);
+
+                list_for_each_entry_safe(tgt, n, &kill, ltd_kill) {
+                        list_del(&tgt->ltd_kill);
+                        /* Disconnect */
+                        __lov_del_obd(obd, tgt);
+                }
+        } else {
+                mutex_up(&lov->lov_lock);
         }
-        mutex_up(&lov->lov_lock);
 }
 
 static int lov_obd_register_page_removal_cb(struct obd_device *obd,
@@ -125,6 +143,7 @@ static int lov_obd_unregister_page_removal_cb(struct obd_device *obd,
                                               obd_page_removal_cb_t func)
 {
         struct lov_obd *lov = &obd->u.lov;
+        int i, rc = 0;
 
         if (lov->lov_page_removal_cb && lov->lov_page_removal_cb != func)
                 return -EINVAL;
@@ -132,7 +151,16 @@ static int lov_obd_unregister_page_removal_cb(struct obd_device *obd,
         lov->lov_page_removal_cb = NULL;
         lov->lov_page_pin_cb = NULL;
 
-        return 0;
+        obd_getref(obd);
+        for (i = 0; i < lov->desc.ld_tgt_count; ++i) {
+                if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_exp)
+                        continue;
+                rc |= obd_unregister_page_removal_cb(
+                                lov->lov_tgts[i]->ltd_exp->exp_obd, func);
+        }
+        obd_putref(obd);
+
+        return rc;
 }
 
 static int lov_obd_register_lock_cancel_cb(struct obd_device *obd,
@@ -210,29 +238,34 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                     (ev == OBD_NOTIFY_SYNC_NONBLOCK))
                         data = &i;
 
-                lov_getref(obd);
+                obd_getref(obd);
                 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
-                        if (!lov->lov_tgts[i])
+
+                        /* don't send sync event if target not
+                         * connected/activated */
+                        if (!lov->lov_tgts[i] ||
+                            !lov->lov_tgts[i]->ltd_active)
                                 continue;
+
                         tgt_obd = class_exp2obd(lov->lov_tgts[i]->ltd_exp);
 
                         rc = obd_notify_observer(obd, tgt_obd, ev, data);
                         if (rc) {
                                 CERROR("%s: notify %s of %s failed %d\n",
-                                       obd->obd_name, 
+                                       obd->obd_name,
                                        obd->obd_observer->obd_name,
                                        tgt_obd->obd_name, rc);
                                 break;
                         }
                 }
-                lov_putref(obd);
+                obd_putref(obd);
         }
 
         RETURN(rc);
 }
 
 #define MAX_STRING_SIZE 128
-static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, 
+static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
                            struct obd_connect_data *data)
 {
         struct lov_obd *lov = &obd->u.lov;
@@ -241,7 +274,6 @@ static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
         struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
         struct lustre_handle conn = {0, };
         struct obd_import *imp;
-
 #ifdef __KERNEL__
         cfs_proc_dir_entry_t *lov_proc_dir;
 #endif
@@ -259,7 +291,7 @@ static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
                 CERROR("Target %s not attached\n", obd_uuid2str(&tgt_uuid));
                 RETURN(-EINVAL);
         }
-        
+
         if (!tgt_obd->obd_set_up) {
                 CERROR("Target %s not set up\n", obd_uuid2str(&tgt_uuid));
                 RETURN(-EINVAL);
@@ -275,7 +307,7 @@ static int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
 
         if (activate) {
                 tgt_obd->obd_no_recov = 0;
-                /* FIXME this is probably supposed to be 
+                /* FIXME this is probably supposed to be
                    ptlrpc_set_import_active.  Horrible naming. */
                 ptlrpc_activate_import(imp);
         }
@@ -364,7 +396,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
         rc = class_connect(conn, obd, cluuid);
         if (rc)
                 RETURN(rc);
-                
+
         *exp = class_conn2export(conn);
 
         /* Why should there ever be more than 1 connect? */
@@ -375,7 +407,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
         if (data)
                 lov->lov_ocd = *data;
 
-        lov_getref(obd);
+        obd_getref(obd);
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 tgt = lov->lov_tgts[i];
                 if (!tgt || obd_uuid_empty(&tgt->ltd_uuid))
@@ -384,7 +416,7 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
                 rc = lov_connect_obd(obd, i, lov->lov_tgts[i]->ltd_activate,
                                      &lov->lov_ocd);
                 if (rc) {
-                        CERROR("%s: lov connect tgt %d failed: %d\n", 
+                        CERROR("%s: lov connect tgt %d failed: %d\n",
                                obd->obd_name, i, rc);
                         continue;
                 }
@@ -399,28 +431,27 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
                                obd->obd_name, rc);
                 }
         }
-        lov_putref(obd);
+        obd_putref(obd);
 
         RETURN(0);
 }
 
-static int lov_disconnect_obd(struct obd_device *obd, __u32 index)
+static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
 {
         cfs_proc_dir_entry_t *lov_proc_dir;
         struct lov_obd *lov = &obd->u.lov;
-        struct obd_device *osc_obd =
-                class_exp2obd(lov->lov_tgts[index]->ltd_exp);
+        struct obd_device *osc_obd = class_exp2obd(tgt->ltd_exp);
         int rc;
 
         ENTRY;
 
-        CDEBUG(D_CONFIG, "%s: disconnecting target %s\n", 
+        CDEBUG(D_CONFIG, "%s: disconnecting target %s\n",
                obd->obd_name, osc_obd->obd_name);
 
-        if (lov->lov_tgts[index]->ltd_active) {
-                lov->lov_tgts[index]->ltd_active = 0;
+        if (tgt->ltd_active) {
+                tgt->ltd_active = 0;
                 lov->desc.ld_active_tgt_count--;
-                lov->lov_tgts[index]->ltd_exp->exp_obd->obd_inactive = 1;
+                tgt->ltd_exp->exp_obd->obd_inactive = 1;
         }
 
         lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
@@ -451,20 +482,21 @@ static int lov_disconnect_obd(struct obd_device *obd, __u32 index)
         obd_unregister_page_removal_cb(osc_obd, lov->lov_page_removal_cb);
         obd_unregister_lock_cancel_cb(osc_obd, lov->lov_lock_cancel_cb);
 
-        rc = obd_disconnect(lov->lov_tgts[index]->ltd_exp);
+        rc = obd_disconnect(tgt->ltd_exp);
         if (rc) {
                 CERROR("Target %s disconnect error %d\n",
-                       lov_uuid2str(lov, index), rc);
+                       tgt->ltd_uuid.uuid, rc);
                 rc = 0;
         }
 
-        qos_del_tgt(obd, index);
+        qos_del_tgt(obd, tgt);
+
+        tgt->ltd_exp = NULL;
 
-        lov->lov_tgts[index]->ltd_exp = NULL;
         RETURN(0);
 }
 
-static int lov_del_target(struct obd_device *obd, __u32 index, 
+static int lov_del_target(struct obd_device *obd, __u32 index,
                           struct obd_uuid *uuidp, int gen);
 
 static int lov_disconnect(struct obd_export *exp)
@@ -487,14 +519,14 @@ static int lov_disconnect(struct obd_export *exp)
 
         /* Let's hold another reference so lov_del_obd doesn't spin through
            putref every time */
-        lov_getref(obd);
+        obd_getref(obd);
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 if (lov->lov_tgts[i] && lov->lov_tgts[i]->ltd_exp) {
                         /* Disconnection is the last we know about an obd */
                         lov_del_target(obd, i, 0, lov->lov_tgts[i]->ltd_gen);
                 }
         }
-        lov_putref(obd);
+        obd_putref(obd);
 
 out:
         rc = class_disconnect(exp); /* bz 9811 */
@@ -519,7 +551,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
         CDEBUG(D_INFO, "Searching in lov %p for uuid %s (activate=%d)\n",
                lov, uuid->uuid, activate);
 
-        lov_getref(obd);
+        obd_getref(obd);
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 tgt = lov->lov_tgts[i];
                 if (!tgt || !tgt->ltd_exp)
@@ -557,7 +589,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
         lov->lov_tgts[i]->ltd_qos.ltq_penalty = 0;
 
  out:
-        lov_putref(obd);
+        obd_putref(obd);
         RETURN(i);
 }
 
@@ -595,7 +627,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                 __u32 newsize, oldsize = 0;
 
                 newsize = max(lov->lov_tgt_size, (__u32)2);
-                while (newsize < index + 1) 
+                while (newsize < index + 1)
                         newsize = newsize << 1;
                 OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
                 if (newtgts == NULL) {
@@ -604,7 +636,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                 }
 
                 if (lov->lov_tgt_size) {
-                        memcpy(newtgts, lov->lov_tgts, sizeof(*newtgts) * 
+                        memcpy(newtgts, lov->lov_tgts, sizeof(*newtgts) *
                                lov->lov_tgt_size);
                         old = lov->lov_tgts;
                         oldsize = lov->lov_tgt_size;
@@ -622,13 +654,19 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                        lov->lov_tgts, lov->lov_tgt_size);
         }
 
-
         OBD_ALLOC_PTR(tgt);
         if (!tgt) {
                 mutex_up(&lov->lov_lock);
                 RETURN(-ENOMEM);
         }
 
+        rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
+        if (rc) {
+                mutex_up(&lov->lov_lock);
+                OBD_FREE_PTR(tgt);
+                RETURN(rc);
+        }
+
         memset(tgt, 0, sizeof(*tgt));
         tgt->ltd_uuid = *uuidp;
         /* XXX - add a sanity check on the generation number. */
@@ -638,19 +676,20 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
         lov->lov_tgts[index] = tgt;
         if (index >= lov->desc.ld_tgt_count)
                 lov->desc.ld_tgt_count = index + 1;
+
         mutex_up(&lov->lov_lock);
 
         CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n",
                 index, tgt->ltd_gen, lov->desc.ld_tgt_count);
-        
-        if (lov->lov_connects == 0) { 
+
+        if (lov->lov_connects == 0) {
                 /* lov_connect hasn't been called yet. We'll do the
                    lov_connect_obd on this target when that fn first runs,
                    because we don't know the connect flags yet. */
                 RETURN(0);
         }
 
-        lov_getref(obd);
+        obd_getref(obd);
 
         rc = lov_connect_obd(obd, index, active, &lov->lov_ocd);
         if (rc)
@@ -660,22 +699,22 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
         if (!tgt->ltd_exp)
                 GOTO(out, rc = 0);
 
-        rc = lov_notify(obd, tgt->ltd_exp->exp_obd, 
+        rc = lov_notify(obd, tgt->ltd_exp->exp_obd,
                         active ? OBD_NOTIFY_CONNECT : OBD_NOTIFY_INACTIVE,
                         (void *)&index);
-
 out:
         if (rc) {
-                CERROR("add failed (%d), deleting %s\n", rc, 
+                /* connect or notify failed - we can try connect later
+                 * instead of complete delete target */
+                CERROR("connect or notify failed (%d) for %s\n", rc,
                        obd_uuid2str(&tgt->ltd_uuid));
-                lov_del_target(obd, index, 0, 0);
         }
-        lov_putref(obd);
+        obd_putref(obd);
         RETURN(rc);
 }
 
 /* Schedule a target for deletion */
-static int lov_del_target(struct obd_device *obd, __u32 index, 
+static int lov_del_target(struct obd_device *obd, __u32 index,
                           struct obd_uuid *uuidp, int gen)
 {
         struct lov_obd *lov = &obd->u.lov;
@@ -689,7 +728,7 @@ static int lov_del_target(struct obd_device *obd, __u32 index,
                 RETURN(-EINVAL);
         }
 
-        lov_getref(obd);
+        obd_getref(obd);
 
         if (!lov->lov_tgts[index]) {
                 CERROR("LOV target at index %d is not setup.\n", index);
@@ -705,24 +744,21 @@ static int lov_del_target(struct obd_device *obd, __u32 index,
 
         CDEBUG(D_CONFIG, "uuid: %s idx: %d gen: %d exp: %p active: %d\n",
                lov_uuid2str(lov, index), index,
-               lov->lov_tgts[index]->ltd_gen, lov->lov_tgts[index]->ltd_exp, 
+               lov->lov_tgts[index]->ltd_gen, lov->lov_tgts[index]->ltd_exp,
                lov->lov_tgts[index]->ltd_active);
 
         lov->lov_tgts[index]->ltd_reap = 1;
         lov->lov_death_row++;
-        /* we really delete it from lov_putref */
+        /* we really delete it from obd_putref */
 out:
-        lov_putref(obd);
+        obd_putref(obd);
 
         RETURN(rc);
 }
 
-/* We are holding lov_lock */
-static void __lov_del_obd(struct obd_device *obd, __u32 index)
+static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
 {
-        struct lov_obd *lov = &obd->u.lov;
         struct obd_device *osc_obd;
-        struct lov_tgt_desc *tgt = lov->lov_tgts[index];
 
         LASSERT(tgt);
         LASSERT(tgt->ltd_reap);
@@ -730,18 +766,13 @@ static void __lov_del_obd(struct obd_device *obd, __u32 index)
         osc_obd = class_exp2obd(tgt->ltd_exp);
 
         CDEBUG(D_CONFIG, "Removing tgt %s : %s\n",
-               lov_uuid2str(lov, index), 
+               tgt->ltd_uuid.uuid,
                osc_obd ? osc_obd->obd_name : "<no obd>");
 
         if (tgt->ltd_exp)
-                lov_disconnect_obd(obd, index);
-
-        /* XXX - right now there is a dependency on ld_tgt_count being the
-         * maximum tgt index for computing the mds_max_easize. So we can't
-         * shrink it. */
+                lov_disconnect_obd(obd, tgt);
 
-        lov->lov_tgts[index] = NULL;
-        OBD_FREE_PTR(tgt);        
+        OBD_FREE_PTR(tgt);
 
         /* Manual cleanup - no cleanup logs to clean up the osc's.  We must
            do it ourselves. And we can't do it from lov_cleanup,
@@ -757,8 +788,9 @@ static void __lov_del_obd(struct obd_device *obd, __u32 index)
 void lov_fix_desc_stripe_size(__u64 *val)
 {
         if (*val < PTLRPC_MAX_BRW_SIZE) {
-                LCONSOLE_WARN("Increasing default stripe size from "LPU64
-                              " to %u\n", *val, PTLRPC_MAX_BRW_SIZE);
+                if (*val)
+                        LCONSOLE_WARN("Increasing default stripe size from "
+                                      LPU64" to %u\n",*val,PTLRPC_MAX_BRW_SIZE);
                 *val = PTLRPC_MAX_BRW_SIZE;
         } else if (*val & (LOV_MIN_STRIPE_SIZE - 1)) {
                 *val &= ~(LOV_MIN_STRIPE_SIZE - 1);
@@ -804,6 +836,7 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
         struct lustre_cfg *lcfg = buf;
         struct lov_desc *desc;
         struct lov_obd *lov = &obd->u.lov;
+        int rc;
         ENTRY;
 
         if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
@@ -836,15 +869,38 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
         desc->ld_active_tgt_count = 0;
         lov->desc = *desc;
         lov->lov_tgt_size = 0;
+
         sema_init(&lov->lov_lock, 1);
         atomic_set(&lov->lov_refcount, 0);
         CFS_INIT_LIST_HEAD(&lov->lov_qos.lq_oss_list);
         init_rwsem(&lov->lov_qos.lq_rw_sem);
         lov->lov_qos.lq_dirty = 1;
-        lov->lov_qos.lq_dirty_rr = 1;
+        lov->lov_qos.lq_rr.lqr_dirty = 1;
         lov->lov_qos.lq_reset = 1;
         /* Default priority is toward free space balance */
         lov->lov_qos.lq_prio_free = 232;
+        /* Default threshold for rr (roughly 17%) */
+        lov->lov_qos.lq_threshold_rr = 43;
+        /* Init statfs fields */
+        OBD_ALLOC_PTR(lov->lov_qos.lq_statfs_data);
+        if (NULL == lov->lov_qos.lq_statfs_data)
+                RETURN(-ENOMEM);
+        cfs_waitq_init(&lov->lov_qos.lq_statfs_waitq);
+
+        lov->lov_pools_hash_body = lustre_hash_init("POOLS",
+                                                    HASH_POOLS_CUR_BITS,
+                                                    HASH_POOLS_MAX_BITS,
+                                                    &pool_hash_operations, 0);
+        CFS_INIT_LIST_HEAD(&lov->lov_pool_list);
+        lov->lov_pool_count = 0;
+        rc = lov_ost_pool_init(&lov->lov_packed, 0);
+        if (rc)
+                RETURN(rc);
+        rc = lov_ost_pool_init(&lov->lov_qos.lq_rr.lqr_pool, 0);
+        if (rc) {
+                lov_ost_pool_free(&lov->lov_packed);
+                RETURN(rc);
+        }
 
         lprocfs_lov_init_vars(&lvars);
         lprocfs_obd_setup(obd, lvars.obd_vars);
@@ -860,6 +916,9 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
                 }
         }
 #endif
+        lov->lov_pool_proc_entry = lprocfs_register("pools",
+                                                    obd->obd_proc_entry,
+                                                    NULL, NULL);
 
         RETURN(0);
 }
@@ -897,33 +956,49 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
 static int lov_cleanup(struct obd_device *obd)
 {
         struct lov_obd *lov = &obd->u.lov;
+        struct list_head *pos, *tmp;
+        struct pool_desc *pool;
+
+        list_for_each_safe(pos, tmp, &lov->lov_pool_list) {
+                pool = list_entry(pos, struct pool_desc, pool_list);
+                /* free the pool structs */
+                CDEBUG(D_INFO, "delete pool %p\n", pool);
+                lov_pool_del(obd, pool->pool_name);
+        }
+
+        lustre_hash_exit(lov->lov_pools_hash_body);
+
+        lov_ost_pool_free(&(lov->lov_qos.lq_rr.lqr_pool));
+        lov_ost_pool_free(&lov->lov_packed);
 
-        lprocfs_obd_cleanup(obd);
         if (lov->lov_tgts) {
                 int i;
+                obd_getref(obd);
                 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                         if (lov->lov_tgts[i]) {
                                 /* Inactive targets may never have connected */
                                 if (lov->lov_tgts[i]->ltd_active ||
-                                    atomic_read(&lov->lov_refcount)) 
-                                        /* We should never get here - these 
-                                           should have been removed in the 
+                                    atomic_read(&lov->lov_refcount))
+                                        /* We should never get here - these
+                                           should have been removed in the
                                            disconnect. */
                                         CERROR("lov tgt %d not cleaned!"
                                                " deathrow=%d, lovrc=%d\n",
-                                               i, lov->lov_death_row, 
+                                               i, lov->lov_death_row,
                                                atomic_read(&lov->lov_refcount));
                                 lov_del_target(obd, i, 0, 0);
                         }
                 }
-                OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) * 
+                obd_putref(obd);
+                OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) *
                          lov->lov_tgt_size);
                 lov->lov_tgt_size = 0;
         }
-        
-        if (lov->lov_qos.lq_rr_size) 
-                OBD_FREE(lov->lov_qos.lq_rr_array, lov->lov_qos.lq_rr_size);
 
+        /* clear pools parent proc entry only after all pools is killed */
+        lprocfs_obd_cleanup(obd);
+
+        OBD_FREE_PTR(lov->lov_qos.lq_statfs_data);
         RETURN(0);
 }
 
@@ -962,16 +1037,22 @@ static int lov_process_config(struct obd_device *obd, obd_count len, void *buf)
         case LCFG_PARAM: {
                 struct lprocfs_static_vars lvars = { 0 };
                 struct lov_desc *desc = &(obd->u.lov.desc);
-                
+
                 if (!desc)
                         GOTO(out, rc = -EINVAL);
-                
+
                 lprocfs_lov_init_vars(&lvars);
-                
+
                 rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars,
                                               lcfg, obd);
                 GOTO(out, rc);
         }
+        case LCFG_POOL_NEW:
+        case LCFG_POOL_ADD:
+        case LCFG_POOL_DEL:
+        case LCFG_POOL_REM:
+                GOTO(out, rc);
+
         default: {
                 CERROR("Unknown command: %d\n", lcfg->lcfg_command);
                 GOTO(out, rc = -EINVAL);
@@ -1011,7 +1092,7 @@ static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa,
                        ost_uuid->uuid);
         }
 
-        lov_getref(export->exp_obd);
+        obd_getref(export->exp_obd);
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 struct lov_stripe_md obj_md;
                 struct lov_stripe_md *obj_mdp = &obj_md;
@@ -1032,14 +1113,14 @@ static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa,
                 if (ost_uuid && !obd_uuid_equals(ost_uuid, &tgt->ltd_uuid))
                         continue;
 
-                CDEBUG(D_CONFIG,"Clear orphans for %d:%s\n", i, 
+                CDEBUG(D_CONFIG,"Clear orphans for %d:%s\n", i,
                        obd_uuid2str(ost_uuid));
 
                 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
 
                 LASSERT(lov->lov_tgts[i]->ltd_exp);
                 /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
-                err = obd_create(lov->lov_tgts[i]->ltd_exp, 
+                err = obd_create(lov->lov_tgts[i]->ltd_exp,
                                  tmp_oa, &obj_mdp, oti);
                 if (err) {
                         /* This export will be disabled until it is recovered,
@@ -1052,7 +1133,7 @@ static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa,
                 if (ost_uuid)
                         break;
         }
-        lov_putref(export->exp_obd);
+        obd_putref(export->exp_obd);
 
         OBDO_FREE(tmp_oa);
         RETURN(rc);
@@ -1106,8 +1187,6 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
         struct obd_info oinfo;
         struct lov_request_set *set = NULL;
         struct lov_request *req;
-        struct obd_statfs osfs;
-        __u64 maxage;
         int rc = 0;
         ENTRY;
 
@@ -1125,7 +1204,7 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
         if (!lov->desc.ld_active_tgt_count)
                 RETURN(-EIO);
 
-        lov_getref(exp->exp_obd);
+        obd_getref(exp->exp_obd);
         /* Recreate a specific object id at the given OST index */
         if ((src_oa->o_valid & OBD_MD_FLFLAGS) &&
             (src_oa->o_flags & OBD_FL_RECREATE_OBJS)) {
@@ -1133,8 +1212,11 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
                  GOTO(out, rc);
         }
 
-        maxage = cfs_time_shift_64(-lov->desc.ld_qos_maxage);
-        obd_statfs_rqset(exp->exp_obd, &osfs, maxage, OBD_STATFS_NODELAY);
+        /* issue statfs rpcs if the osfs data is older than qos_maxage - 1s,
+         * later in alloc_qos(), we will wait for those rpcs to complete if
+         * the osfs age is older than 2 * qos_maxage */
+        qos_statfs_update(exp->exp_obd,
+                          cfs_time_shift_64(-lov->desc.ld_qos_maxage) + HZ, 0);
 
         rc = lov_prep_create_set(exp, &oinfo, ea, src_oa, oti, &set);
         if (rc)
@@ -1148,14 +1230,15 @@ static int lov_create(struct obd_export *exp, struct obdo *src_oa,
         }
         rc = lov_fini_create_set(set, ea);
 out:
-        lov_putref(exp->exp_obd);
+        obd_putref(exp->exp_obd);
         RETURN(rc);
 }
 
 #define ASSERT_LSM_MAGIC(lsmp)                                                  \
 do {                                                                            \
         LASSERT((lsmp) != NULL);                                                \
-        LASSERTF(((lsmp)->lsm_magic == LOV_MAGIC ||                             \
+        LASSERTF(((lsmp)->lsm_magic == LOV_MAGIC_V1 ||                          \
+                 (lsmp)->lsm_magic == LOV_MAGIC_V3 ||                           \
                  (lsmp)->lsm_magic == LOV_MAGIC_JOIN), "%p->lsm_magic=%x\n",    \
                  (lsmp), (lsmp)->lsm_magic);                                    \
 } while (0)
@@ -1183,7 +1266,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa,
         }
 
         lov = &exp->exp_obd->u.lov;
-        lov_getref(exp->exp_obd);
+        obd_getref(exp->exp_obd);
         rc = lov_prep_destroy_set(exp, &oinfo, oa, lsm, oti, &set);
         if (rc)
                 GOTO(out, rc);
@@ -1213,7 +1296,7 @@ static int lov_destroy(struct obd_export *exp, struct obdo *oa,
         }
         err = lov_fini_destroy_set(set);
 out:
-        lov_putref(exp->exp_obd);
+        obd_putref(exp->exp_obd);
         RETURN(rc ? rc : err);
 }
 
@@ -1242,7 +1325,7 @@ static int lov_getattr(struct obd_export *exp, struct obd_info *oinfo)
                 req = list_entry(pos, struct lov_request, rq_link);
 
                 CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx "
-                       "%u\n", oinfo->oi_oa->o_id, req->rq_stripe, 
+                       "%u\n", oinfo->oi_oa->o_id, req->rq_stripe,
                        req->rq_oi.oi_oa->o_id, req->rq_idx);
 
                 rc = obd_getattr(lov->lov_tgts[req->rq_idx]->ltd_exp,
@@ -1263,7 +1346,7 @@ static int lov_getattr(struct obd_export *exp, struct obd_info *oinfo)
         RETURN(rc);
 }
 
-static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, 
+static int lov_getattr_interpret(struct ptlrpc_request_set *rqset,
                                  void *data, int rc)
 {
         struct lov_request_set *lovset = (struct lov_request_set *)data;
@@ -1300,14 +1383,14 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
                 RETURN(rc);
 
         CDEBUG(D_INFO, "objid "LPX64": %ux%u byte stripes\n",
-               oinfo->oi_md->lsm_object_id, oinfo->oi_md->lsm_stripe_count, 
+               oinfo->oi_md->lsm_object_id, oinfo->oi_md->lsm_stripe_count,
                oinfo->oi_md->lsm_stripe_size);
 
         list_for_each (pos, &lovset->set_list) {
                 req = list_entry(pos, struct lov_request, rq_link);
 
                 CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx "
-                       "%u\n", oinfo->oi_oa->o_id, req->rq_stripe, 
+                       "%u\n", oinfo->oi_oa->o_id, req->rq_stripe,
                        req->rq_oi.oi_oa->o_id, req->rq_idx);
                 rc = obd_getattr_async(lov->lov_tgts[req->rq_idx]->ltd_exp,
                                        &req->rq_oi, rqset);
@@ -1351,12 +1434,12 @@ static int lov_setattr(struct obd_export *exp, struct obd_info *oinfo,
                 RETURN(-ENODEV);
 
         /* for now, we only expect the following updates here */
-        LASSERT(!(oinfo->oi_oa->o_valid & ~(OBD_MD_FLID | OBD_MD_FLTYPE | 
-                                            OBD_MD_FLMODE | OBD_MD_FLATIME | 
+        LASSERT(!(oinfo->oi_oa->o_valid & ~(OBD_MD_FLID | OBD_MD_FLTYPE |
+                                            OBD_MD_FLMODE | OBD_MD_FLATIME |
                                             OBD_MD_FLMTIME | OBD_MD_FLCTIME |
-                                            OBD_MD_FLFLAGS | OBD_MD_FLSIZE | 
-                                            OBD_MD_FLGROUP | OBD_MD_FLUID | 
-                                            OBD_MD_FLGID | OBD_MD_FLFID | 
+                                            OBD_MD_FLFLAGS | OBD_MD_FLSIZE |
+                                            OBD_MD_FLGROUP | OBD_MD_FLUID |
+                                            OBD_MD_FLGID | OBD_MD_FLFID |
                                             OBD_MD_FLGENER)));
         lov = &exp->exp_obd->u.lov;
         rc = lov_prep_setattr_set(exp, oinfo, oti, &set);
@@ -1366,13 +1449,13 @@ static int lov_setattr(struct obd_export *exp, struct obd_info *oinfo,
         list_for_each (pos, &set->set_list) {
                 req = list_entry(pos, struct lov_request, rq_link);
 
-                rc = obd_setattr(lov->lov_tgts[req->rq_idx]->ltd_exp, 
+                rc = obd_setattr(lov->lov_tgts[req->rq_idx]->ltd_exp,
                                  &req->rq_oi, NULL);
                 err = lov_update_setattr_set(set, req, rc);
                 if (err) {
                         CERROR("error: setattr objid "LPX64" subobj "
                                LPX64" on OST idx %d: rc = %d\n",
-                               set->set_oi->oi_oa->o_id, 
+                               set->set_oi->oi_oa->o_id,
                                req->rq_oi.oi_oa->o_id, req->rq_idx, err);
                         if (!rc)
                                 rc = err;
@@ -1425,8 +1508,10 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
         if (rc)
                 RETURN(rc);
 
-        CDEBUG(D_INFO, "objid "LPX64": %ux%u byte stripes\n",
-               oinfo->oi_md->lsm_object_id, oinfo->oi_md->lsm_stripe_count,
+        CDEBUG(D_INFO, "objid "LPX64"@"LPX64": %ux%u byte stripes\n",
+               oinfo->oi_md->lsm_object_id,
+               oinfo->oi_md->lsm_object_gr,
+               oinfo->oi_md->lsm_stripe_count,
                oinfo->oi_md->lsm_stripe_size);
 
         list_for_each (pos, &set->set_list) {
@@ -1435,9 +1520,9 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
                 if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE)
                         oti->oti_logcookies = set->set_cookies + req->rq_stripe;
 
-                CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx "
-                       "%u\n", oinfo->oi_oa->o_id, req->rq_stripe,
-                       req->rq_oi.oi_oa->o_id, req->rq_idx);
+                CDEBUG(D_INFO, "objid "LPX64"@"LPX64"[%d] has subobj "LPX64
+                       " at idx %u\n", oinfo->oi_oa->o_id, oinfo->oi_oa->o_gr,
+                       req->rq_stripe, req->rq_oi.oi_oa->o_id, req->rq_idx);
 
                 rc = obd_setattr_async(lov->lov_tgts[req->rq_idx]->ltd_exp,
                                        &req->rq_oi, oti, rqset);
@@ -1532,48 +1617,67 @@ static int lov_punch(struct obd_export *exp, struct obd_info *oinfo,
         RETURN(0);
 }
 
-static int lov_sync(struct obd_export *exp, struct obdo *oa,
-                    struct lov_stripe_md *lsm, obd_off start, obd_off end)
+static int lov_sync_interpret(struct ptlrpc_request_set *rqset,
+                              void *data, int rc)
 {
-        struct lov_request_set *set;
-        struct obd_info oinfo;
+        struct lov_request_set *lovset = (struct lov_request_set *)data;
+        int err;
+        ENTRY;
+
+        if (rc)
+                lovset->set_completes = 0;
+        err = lov_fini_sync_set(lovset);
+        RETURN(rc ? rc : err);
+}
+
+static int lov_sync(struct obd_export *exp, struct obd_info *oinfo,
+                    obd_off start, obd_off end,
+                    struct ptlrpc_request_set *rqset)
+{
+        struct lov_request_set *set = NULL;
         struct lov_obd *lov;
         struct list_head *pos;
         struct lov_request *req;
-        int err = 0, rc = 0;
+        int    rc = 0;
         ENTRY;
 
-        ASSERT_LSM_MAGIC(lsm);
+        ASSERT_LSM_MAGIC(oinfo->oi_md);
+        LASSERT(rqset != NULL);
 
         if (!exp->exp_obd)
                 RETURN(-ENODEV);
 
         lov = &exp->exp_obd->u.lov;
-        rc = lov_prep_sync_set(exp, &oinfo, oa, lsm, start, end, &set);
+        rc = lov_prep_sync_set(exp, oinfo, start, end, &set);
         if (rc)
                 RETURN(rc);
 
         list_for_each (pos, &set->set_list) {
                 req = list_entry(pos, struct lov_request, rq_link);
 
-                rc = obd_sync(lov->lov_tgts[req->rq_idx]->ltd_exp, 
-                              req->rq_oi.oi_oa, NULL, 
+                rc = obd_sync(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi,
                               req->rq_oi.oi_policy.l_extent.start,
-                              req->rq_oi.oi_policy.l_extent.end);
-                err = lov_update_common_set(set, req, rc);
-                if (err) {
+                              req->rq_oi.oi_policy.l_extent.end, rqset);
+                if (rc) {
                         CERROR("error: fsync objid "LPX64" subobj "LPX64
                                " on OST idx %d: rc = %d\n",
                                set->set_oi->oi_oa->o_id,
                                req->rq_oi.oi_oa->o_id, req->rq_idx, rc);
-                        if (!rc)
-                                rc = err;
+                        break;
                 }
         }
-        err = lov_fini_sync_set(set);
-        if (!rc)
-                rc = err;
-        RETURN(rc);
+
+        /* If we are not waiting for responses on async requests, return. */
+        if (rc || list_empty(&rqset->set_requests)) {
+                int err = lov_fini_sync_set(set);
+                RETURN(rc ? rc : err);
+        }
+
+        LASSERT(rqset->set_interpret == NULL);
+        rqset->set_interpret = lov_sync_interpret;
+        rqset->set_arg = (void *)set;
+
+        RETURN(0);
 }
 
 static int lov_brw_check(struct lov_obd *lov, struct obd_info *lov_oinfo,
@@ -1784,12 +1888,12 @@ int lov_prep_async_page(struct obd_export *exp, struct lov_stripe_md *lsm,
         if (!page) {
                 int i = 0;
                 /* Find an existing osc so we can get it's stupid sizeof(*oap).
-                   Only because of this layering limitation will a client 
+                   Only because of this layering limitation will a client
                    mount with no osts fail */
-                while (!lov->lov_tgts || !lov->lov_tgts[i] || 
+                while (!lov->lov_tgts || !lov->lov_tgts[i] ||
                        !lov->lov_tgts[i]->ltd_exp) {
                         i++;
-                        if (i >= lov->desc.ld_tgt_count) 
+                        if (i >= lov->desc.ld_tgt_count)
                                 RETURN(-ENOMEDIUM);
                 }
                 rc = size_round(sizeof(*lap)) +
@@ -1924,7 +2028,7 @@ static int lov_trigger_group_io(struct obd_export *exp,
 
         for (i = 0; i < lsm->lsm_stripe_count; i++) {
                 loi = lsm->lsm_oinfo[i];
-                if (!lov->lov_tgts[loi->loi_ost_idx] || 
+                if (!lov->lov_tgts[loi->loi_ost_idx] ||
                     !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
                         CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
                         continue;
@@ -2023,13 +2127,14 @@ out:
 
 static int lov_match(struct obd_export *exp, struct lov_stripe_md *lsm,
                      __u32 type, ldlm_policy_data_t *policy, __u32 mode,
-                     int *flags, void *data, struct lustre_handle *lockh)
+                     int *flags, void *data, struct lustre_handle *lockh,
+                     int *n_matches)
 {
         struct lov_request_set *set;
         struct obd_info oinfo;
         struct lov_request *req;
         struct list_head *pos;
-        struct lov_obd *lov = &exp->exp_obd->u.lov;
+        struct lov_obd *lov;
         struct lustre_handle *lov_lockhp;
         int lov_flags, rc = 0;
         ENTRY;
@@ -2056,7 +2161,8 @@ static int lov_match(struct obd_export *exp, struct lov_stripe_md *lsm,
 
                 rc = obd_match(lov->lov_tgts[req->rq_idx]->ltd_exp,
                                req->rq_oi.oi_md, type, &sub_policy,
-                               mode, &lov_flags, data, lov_lockhp);
+                               mode, &lov_flags, data, lov_lockhp,
+                               n_matches);
                 rc = lov_update_match_set(set, req, rc);
                 if (rc <= 0)
                         break;
@@ -2089,6 +2195,7 @@ static int lov_change_cbdata(struct obd_export *exp,
                         continue;
                 }
                 submd.lsm_object_id = loi->loi_id;
+                submd.lsm_object_gr = loi->loi_gr;
                 submd.lsm_stripe_count = 0;
                 rc = obd_change_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp,
                                        &submd, it, data);
@@ -2103,7 +2210,7 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm,
         struct obd_info oinfo;
         struct lov_request *req;
         struct list_head *pos;
-        struct lov_obd *lov = &exp->exp_obd->u.lov;
+        struct lov_obd *lov;
         struct lustre_handle *lov_lockhp;
         ldlm_mode_t this_mode;
         int err = 0, rc = 0;
@@ -2248,8 +2355,7 @@ static int lov_join_lru(struct obd_export *exp,
         RETURN(count);
 }
 
-static int lov_statfs_interpret(struct ptlrpc_request_set *rqset,
-                                void *data, int rc)
+int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc)
 {
         struct lov_request_set *lovset = (struct lov_request_set *)data;
         int err;
@@ -2373,7 +2479,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 genp = (__u32 *)data->ioc_inlbuf3;
                 /* the uuid will be empty for deleted OSTs */
                 for (i = 0; i < count; i++, uuidp++, genp++) {
-                        if (!lov->lov_tgts[i]) 
+                        if (!lov->lov_tgts[i])
                                 continue;
                         *uuidp = lov->lov_tgts[i]->ltd_uuid;
                         *genp = lov->lov_tgts[i]->ltd_gen;
@@ -2655,7 +2761,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key,
                                 GOTO(out, rc = -EINVAL);
 
                         /* If OST is inactive, return extent with UNKNOWN flag */
-                        if (lov && !lov->lov_tgts[ost_index]->ltd_active) {
+                        if (!lov->lov_tgts[ost_index]->ltd_active) {
                                 fm_local->fm_flags |= FIEMAP_EXTENT_LAST;
                                 fm_local->fm_mapped_extents = 1;
 
@@ -2767,7 +2873,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen,
         if (!vallen || !val)
                 RETURN(-EFAULT);
 
-        lov_getref(obddev);
+        obd_getref(obddev);
 
         if (KEY_IS(KEY_LOCK_TO_STRIPE)) {
                 struct {
@@ -2794,8 +2900,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen,
                                 continue;
                         if (lov->lov_tgts[loi->loi_ost_idx]->ltd_exp ==
                             data->lock->l_conn_export &&
-                            loi->loi_id == res_id->name[0] &&
-                            loi->loi_gr == res_id->name[1]) {
+                            osc_res_name_eq(loi->loi_id, loi->loi_gr, res_id)) {
                                 *stripe = i;
                                 GOTO(out, rc = 0);
                         }
@@ -2824,11 +2929,25 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen,
         } else if (KEY_IS(KEY_FIEMAP)) {
                 rc = lov_fiemap(lov, keylen, key, vallen, val, lsm);
                 GOTO(out, rc);
+        } else if (KEY_IS(KEY_OFF_RPCSIZE)) {
+                __u64 *offset = val;
+                struct lov_tgt_desc *tgt;
+                struct lov_oinfo *loi;
+                int stripe;
+
+                LASSERT(*vallen == sizeof(__u64));
+                stripe = lov_stripe_number(lsm, *offset);
+                loi = lsm->lsm_oinfo[stripe];
+                tgt = lov->lov_tgts[loi->loi_ost_idx];
+                if (!tgt || !tgt->ltd_active)
+                        GOTO(out, rc = -ESRCH);
+                rc = obd_get_info(tgt->ltd_exp, keylen, key, vallen, val, NULL);
+                GOTO(out, rc);
         }
 
         rc = -EINVAL;
 out:
-        lov_putref(obddev);
+        obd_putref(obddev);
         RETURN(rc);
 }
 
@@ -2852,7 +2971,7 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen,
                         RETURN(-ENOMEM);
         }
 
-        lov_getref(obddev);
+        obd_getref(obddev);
         count = lov->desc.ld_tgt_count;
 
         if (KEY_IS(KEY_NEXT_ID)) {
@@ -2897,7 +3016,7 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen,
                 if (!rc)
                         rc = err;
         }
-        lov_putref(obddev);
+        obd_putref(obddev);
         if (no_set) {
                 err = ptlrpc_set_wait(set);
                 if (!rc)
@@ -2945,19 +3064,22 @@ static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm,
         __u64 start;
         __u32 ssize  = lsm->lsm_stripe_size;
 
+        if (cmd & OBD_CALC_STRIPE_RPC_ALIGN)
+                ssize = ssize > PTLRPC_MAX_BRW_SIZE ?
+                        PTLRPC_MAX_BRW_SIZE : ssize;
+
         start = *offset;
         do_div(start, ssize);
         start = start * ssize;
 
         CDEBUG(D_DLMTRACE, "offset "LPU64", stripe %u, start "LPU64
                ", end "LPU64"\n", *offset, ssize, start, start + ssize - 1);
-        if (cmd == OBD_CALC_STRIPE_END) {
+        if (cmd & OBD_CALC_STRIPE_END)
                 *offset = start + ssize - 1;
-        } else if (cmd == OBD_CALC_STRIPE_START) {
+        else if (cmd & OBD_CALC_STRIPE_START)
                 *offset = start;
-        } else {
+        else
                 LBUG();
-        }
 
         RETURN(0);
 }
@@ -3138,6 +3260,7 @@ struct obd_ops lov_obd_ops = {
         .o_trigger_group_io    = lov_trigger_group_io,
         .o_teardown_async_page = lov_teardown_async_page,
         .o_merge_lvb           = lov_merge_lvb,
+        .o_update_lvb          = lov_update_lvb,
         .o_adjust_kms          = lov_adjust_kms,
         .o_punch               = lov_punch,
         .o_sync                = lov_sync,
@@ -3158,6 +3281,12 @@ struct obd_ops lov_obd_ops = {
         .o_unregister_page_removal_cb = lov_obd_unregister_page_removal_cb,
         .o_register_lock_cancel_cb = lov_obd_register_lock_cancel_cb,
         .o_unregister_lock_cancel_cb = lov_obd_unregister_lock_cancel_cb,
+        .o_pool_new            = lov_pool_new,
+        .o_pool_rem            = lov_pool_remove,
+        .o_pool_add            = lov_pool_add,
+        .o_pool_del            = lov_pool_del,
+        .o_getref              = lov_getref,
+        .o_putref              = lov_putref,
 };
 
 static quota_interface_t *quota_interface;
@@ -3172,7 +3301,7 @@ int __init lov_init(void)
         ENTRY;
 
         lov_oinfo_slab = cfs_mem_cache_create("lov_oinfo",
-                                              sizeof(struct lov_oinfo), 
+                                              sizeof(struct lov_oinfo),
                                               0, SLAB_HWCACHE_ALIGN);
         if (lov_oinfo_slab == NULL)
                 return -ENOMEM;
diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c
index b0ab4a5..df6f3c5 100644
--- a/lustre/lov/lov_pack.c
+++ b/lustre/lov/lov_pack.c
@@ -60,7 +60,7 @@ void lov_dump_lmm_v1(int level, struct lov_mds_md_v1 *lmm)
         int i;
 
         CDEBUG(level, "objid "LPX64", magic 0x%08x, pattern %#x\n",
-               le64_to_cpu(lmm->lmm_object_id), le32_to_cpu(lmm->lmm_magic),
+               (__u64)le64_to_cpu(lmm->lmm_object_id), le32_to_cpu(lmm->lmm_magic),
                le32_to_cpu(lmm->lmm_pattern));
         CDEBUG(level,"stripe_size %u, stripe_count %u\n",
                le32_to_cpu(lmm->lmm_stripe_size),
@@ -72,8 +72,8 @@ void lov_dump_lmm_v1(int level, struct lov_mds_md_v1 *lmm)
                          CDEBUG(level,
                                 "stripe %u idx %u subobj "LPX64"/"LPX64"\n",
                                 i, le32_to_cpu(lod->l_ost_idx),
-                                le64_to_cpu(lod->l_object_gr),
-                                le64_to_cpu(lod->l_object_id));
+                                (__u64)le64_to_cpu(lod->l_object_gr),
+                                (__u64)le64_to_cpu(lod->l_object_id));
         } else {
                 CDEBUG(level, "bad stripe_count %u > max_stripe_count %u\n",
                        le32_to_cpu(lmm->lmm_stripe_count),
@@ -85,15 +85,61 @@ void lov_dump_lmm_join(int level, struct lov_mds_md_join *lmmj)
 {
 
         CDEBUG(level, "objid "LPX64", magic 0x%08X, pattern %#X\n",
-               le64_to_cpu(lmmj->lmmj_md.lmm_object_id), 
+               (__u64)le64_to_cpu(lmmj->lmmj_md.lmm_object_id),
                le32_to_cpu(lmmj->lmmj_md.lmm_magic),
                le32_to_cpu(lmmj->lmmj_md.lmm_pattern));
         CDEBUG(level,"stripe_size %u, stripe_count %u extent_count %u \n",
                le32_to_cpu(lmmj->lmmj_md.lmm_stripe_size),
-               le32_to_cpu(lmmj->lmmj_md.lmm_stripe_count), 
+               le32_to_cpu(lmmj->lmmj_md.lmm_stripe_count),
                le32_to_cpu(lmmj->lmmj_extent_count));
 }
 
+void lov_dump_lmm_v3(int level, struct lov_mds_md_v3 *lmm)
+{
+        struct lov_ost_data_v1 *lod;
+        int i;
+
+        CDEBUG(level, "objid "LPX64", magic 0x%08x, pattern %#x\n",
+               (__u64)le64_to_cpu(lmm->lmm_object_id),
+               le32_to_cpu(lmm->lmm_magic), le32_to_cpu(lmm->lmm_pattern));
+        CDEBUG(level,"stripe_size %u, stripe_count %u\n",
+               le32_to_cpu(lmm->lmm_stripe_size),
+               le32_to_cpu(lmm->lmm_stripe_count));
+        CDEBUG(level,"pool_name "LOV_POOLNAMEF"\n", lmm->lmm_pool_name);
+
+        if (le32_to_cpu(lmm->lmm_stripe_count) <= LOV_V1_INSANE_STRIPE_COUNT) {
+                for (i = 0, lod = lmm->lmm_objects;
+                     i < (int)le32_to_cpu(lmm->lmm_stripe_count); i++, lod++)
+                         CDEBUG(level,
+                                "stripe %u idx %u subobj "LPX64"/"LPX64"\n",
+                                i, le32_to_cpu(lod->l_ost_idx),
+                                (__u64)le64_to_cpu(lod->l_object_gr),
+                                (__u64)le64_to_cpu(lod->l_object_id));
+        } else {
+                CDEBUG(level, "bad stripe_count %u > max_stripe_count %u\n",
+                       le32_to_cpu(lmm->lmm_stripe_count),
+                       LOV_V1_INSANE_STRIPE_COUNT);
+        }
+}
+
+void lov_dump_lmm(int level, void *lmm)
+{
+        int magic;
+
+        magic = ((struct lov_mds_md_v1 *)(lmm))->lmm_magic;
+        switch (magic) {
+        case LOV_MAGIC_V1:
+                return lov_dump_lmm_v1(level, (struct lov_mds_md_v1 *)(lmm));
+        case LOV_MAGIC_JOIN:
+                return lov_dump_lmm_join(level, (struct lov_mds_md_join *)(lmm));
+        case LOV_MAGIC_V3:
+                return lov_dump_lmm_v3(level, (struct lov_mds_md_v3 *)(lmm));
+        default:
+                CERROR("Cannot recognize lmm_magic %x", magic);
+        }
+        return;
+}
+
 #define LMM_ASSERT(test)                                                \
 do {                                                                    \
         if (!(test)) lov_dump_lmm(D_ERROR, lmm);                        \
@@ -113,21 +159,21 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct lov_obd *lov = &obd->u.lov;
+        struct lov_mds_md_v1 *lmmv1;
+        struct lov_mds_md_v3 *lmmv3;
         struct lov_oinfo *loi;
-        struct lov_mds_md *lmm;
         int stripe_count;
-        int lmm_size;
+        struct lov_ost_data_v1 *lmm_objects;
+        int lmm_size, lmm_magic;
         int i;
         ENTRY;
 
         if (lsm) {
-                if (lsm->lsm_magic != LOV_MAGIC) {
-                        CERROR("bad mem LOV MAGIC: 0x%08X != 0x%08X\n",
-                               lsm->lsm_magic, LOV_MAGIC);
-                        RETURN(-EINVAL);
-                }
+                lmm_magic = lsm->lsm_magic;
+
                 if (!lmmp) {
-                        stripe_count = lov_get_stripecnt(lov, lsm->lsm_stripe_count);
+                        stripe_count = lov_get_stripecnt(lov,
+                                                         lsm->lsm_stripe_count);
                         lsm->lsm_stripe_count = stripe_count;
                 } else {
                         stripe_count = lsm->lsm_stripe_count;
@@ -139,17 +185,31 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                  * of OSTs instead */
                 stripe_count = min((__u32)LOV_MAX_STRIPE_COUNT,
                                    lov->desc.ld_tgt_count);
+
+                if (lmmp && *lmmp)
+                        lmm_magic = le32_to_cpu((*lmmp)->lmm_magic);
+                else
+                        /* lsm == NULL and lmmp == NULL */
+                        lmm_magic = LOV_MAGIC;
+        }
+
+        if ((lmm_magic != LOV_MAGIC_V1) &&
+            (lmm_magic != LOV_MAGIC_V3)) {
+                CERROR("bad mem LOV MAGIC: 0x%08X != 0x%08X nor 0x%08X\n",
+                       lmm_magic, LOV_MAGIC_V1, LOV_MAGIC_V3);
+                RETURN(-EINVAL);
         }
 
         /* XXX LOV STACKING call into osc for sizes */
-        lmm_size = lov_mds_md_size(stripe_count);
+        lmm_size = lov_mds_md_size(stripe_count, lmm_magic);
 
         if (!lmmp)
                 RETURN(lmm_size);
 
         if (*lmmp && !lsm) {
                 stripe_count = le32_to_cpu((*lmmp)->lmm_stripe_count);
-                OBD_FREE(*lmmp, lov_mds_md_size(stripe_count));
+                lmm_size = lov_mds_md_size(stripe_count, le32_to_cpu((*lmmp)->lmm_magic));
+                OBD_FREE(*lmmp, lmm_size);
                 *lmmp = NULL;
                 RETURN(0);
         }
@@ -160,27 +220,43 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                         RETURN(-ENOMEM);
         }
 
-        lmm = *lmmp;
-        lmm->lmm_magic = cpu_to_le32(LOV_MAGIC); /* only write new format */
+        CDEBUG(D_INFO, "lov_packmd: LOV_MAGIC 0x%08X, lmm_size = %d \n",
+               lmm_magic, lmm_size);
+
+        lmmv1 = *lmmp;
+        lmmv3 = (struct lov_mds_md_v3 *)*lmmp;
+        if (lmm_magic == LOV_MAGIC_V3)
+                lmmv3->lmm_magic = cpu_to_le32(LOV_MAGIC_V3);
+        else
+                lmmv1->lmm_magic = cpu_to_le32(LOV_MAGIC_V1);
 
         if (!lsm)
                 RETURN(lmm_size);
 
-        lmm->lmm_object_id = cpu_to_le64(lsm->lsm_object_id);
-        lmm->lmm_object_gr = cpu_to_le64(lsm->lsm_object_gr);
-        lmm->lmm_stripe_size = cpu_to_le32(lsm->lsm_stripe_size);
-        lmm->lmm_stripe_count = cpu_to_le32(stripe_count);
-        lmm->lmm_pattern = cpu_to_le32(lsm->lsm_pattern);
+        /* lmmv1 and lmmv3 point to the same struct and have the
+         * same first fields
+         */
+        lmmv1->lmm_pattern = cpu_to_le32(lsm->lsm_pattern);
+        lmmv1->lmm_object_id = cpu_to_le64(lsm->lsm_object_id);
+        lmmv1->lmm_object_gr = cpu_to_le64(lsm->lsm_object_gr);
+        lmmv1->lmm_stripe_size = cpu_to_le32(lsm->lsm_stripe_size);
+        lmmv1->lmm_stripe_count = cpu_to_le32(stripe_count);
+        if (lsm->lsm_magic == LOV_MAGIC_V3) {
+                strncpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name, LOV_MAXPOOLNAME);
+                lmm_objects = lmmv3->lmm_objects;
+        } else {
+                lmm_objects = lmmv1->lmm_objects;
+        }
 
         for (i = 0; i < stripe_count; i++) {
                 loi = lsm->lsm_oinfo[i];
                 /* XXX LOV STACKING call down to osc_packmd() to do packing */
                 LASSERTF(loi->loi_id, "lmm_oid "LPU64" stripe %u/%u idx %u\n",
-                         lmm->lmm_object_id, i, stripe_count, loi->loi_ost_idx);
-                lmm->lmm_objects[i].l_object_id = cpu_to_le64(loi->loi_id);
-                lmm->lmm_objects[i].l_object_gr = cpu_to_le64(loi->loi_gr);
-                lmm->lmm_objects[i].l_ost_gen = cpu_to_le32(loi->loi_ost_gen);
-                lmm->lmm_objects[i].l_ost_idx = cpu_to_le32(loi->loi_ost_idx);
+                         lmmv1->lmm_object_id, i, stripe_count, loi->loi_ost_idx);
+                lmm_objects[i].l_object_id = cpu_to_le64(loi->loi_id);
+                lmm_objects[i].l_object_gr = cpu_to_le64(loi->loi_gr);
+                lmm_objects[i].l_ost_gen = cpu_to_le32(loi->loi_ost_gen);
+                lmm_objects[i].l_ost_idx = cpu_to_le32(loi->loi_ost_idx);
         }
 
         RETURN(lmm_size);
@@ -210,9 +286,22 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, int *stripe_count)
         int rc;
 
         if (lsm_op_find(le32_to_cpu(*(__u32 *)lmm)) == NULL) {
-                CERROR("bad disk LOV MAGIC: 0x%08X; dumping V1 LMM:\n",
-                       le32_to_cpu(*(__u32 *)lmm));
-                lov_dump_lmm_v1(D_WARNING, lmm);
+                char *buffer;
+                int sz;
+
+                CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n",
+                       le32_to_cpu(*(__u32 *)lmm), lmm_bytes);
+                sz = lmm_bytes * 2 + 1;
+                OBD_ALLOC(buffer, sz);
+                if (buffer != NULL) {
+                        int i;
+
+                        for (i = 0; i < lmm_bytes; i++)
+                                sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]);
+                        buffer[sz] = '\0';
+                        CERROR("%s\n", buffer);
+                        OBD_FREE(buffer, sz);
+                }
                 return -EINVAL;
         }
         rc = lsm_op_find(le32_to_cpu(*(__u32 *)lmm))->lsm_lmm_verify(lmm,
@@ -220,7 +309,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, int *stripe_count)
         return rc;
 }
 
-int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count, 
+int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count,
                       int pattern, int magic)
 {
         int i, lsm_size;
@@ -239,6 +328,7 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count,
         (*lsmp)->lsm_stripe_count = stripe_count;
         (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES * stripe_count;
         (*lsmp)->lsm_pattern = pattern;
+        (*lsmp)->lsm_pool_name[0] = '\0';
         (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0;
 
         for (i = 0; i < stripe_count; i++)
@@ -250,10 +340,10 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, int stripe_count,
 void lov_free_memmd(struct lov_stripe_md **lsmp)
 {
         struct lov_stripe_md *lsm = *lsmp;
-        
+
         LASSERT(lsm_op_find(lsm->lsm_magic) != NULL);
         lsm_op_find(lsm->lsm_magic)->lsm_free(lsm);
-        
+
         *lsmp = NULL;
 }
 
@@ -261,7 +351,7 @@ void lov_free_memmd(struct lov_stripe_md **lsmp)
 /* Unpack LOV object metadata from disk storage.  It is packed in LE byte
  * order and is opaque to the networking layer.
  */
-int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp, 
+int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
                  struct lov_mds_md *lmm, int lmm_bytes)
 {
         struct obd_device *obd = class_exp2obd(exp);
@@ -294,7 +384,7 @@ int lov_unpackmd(struct obd_export *exp,  struct lov_stripe_md **lsmp,
                 RETURN(0);
         }
 
-        lsm_size = lov_alloc_memmd(lsmp, stripe_count, LOV_PATTERN_RAID0, 
+        lsm_size = lov_alloc_memmd(lsmp, stripe_count, LOV_PATTERN_RAID0,
                                    magic);
         if (lsm_size < 0)
                 RETURN(lsm_size);
@@ -325,60 +415,101 @@ int lov_setstripe(struct obd_export *exp, struct lov_stripe_md **lsmp,
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct lov_obd *lov = &obd->u.lov;
-        struct lov_user_md lum;
+        struct lov_user_md_v3 lumv3;
+        struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3;
         int stripe_count;
         int rc;
         ENTRY;
 
-        rc = copy_from_user(&lum, lump, sizeof(lum));
+        rc = copy_from_user(&lumv3, lump, sizeof(struct lov_user_md_v1));
         if (rc)
                 RETURN(-EFAULT);
 
-        if (lum.lmm_magic != LOV_USER_MAGIC) {
-                if (lum.lmm_magic == __swab32(LOV_USER_MAGIC)) {
-                        lustre_swab_lov_user_md(&lum);
-                } else {
-                        CDEBUG(D_IOCTL, "bad userland LOV MAGIC:"
-                               " %#08x != %#08x\n",
-                               lum.lmm_magic, LOV_USER_MAGIC);
-                        RETURN(-EINVAL);
-                }
+        switch (lumv1->lmm_magic) {
+        case LOV_USER_MAGIC_V3_SWABBED:
+                rc = copy_from_user(&lumv3, lump, sizeof(lumv3));
+                if (rc)
+                        break;
+        case LOV_USER_MAGIC_V1_SWABBED:
+                rc = lustre_swab_lov_user_md(lumv1);
+                break;
+        case LOV_USER_MAGIC_V3:
+                rc = copy_from_user(&lumv3, lump, sizeof(lumv3));
+        case LOV_USER_MAGIC_V1:
+                break;
+        default:
+                CERROR("bad lsm magic %08x\n", lumv1->lmm_magic);
+                RETURN(-EINVAL);
         }
+        if (rc)
+                RETURN(rc);
+
+        /* in the rest of the tests, as *lumv1 and lumv3 have the same
+         * fields, we use lumv1 to avoid code duplication */
 
-        if (lum.lmm_pattern == 0) {
-                lum.lmm_pattern = lov->desc.ld_pattern ?
+        if (lumv1->lmm_pattern == 0) {
+                lumv1->lmm_pattern = lov->desc.ld_pattern ?
                         lov->desc.ld_pattern : LOV_PATTERN_RAID0;
         }
 
-        if (lum.lmm_pattern != LOV_PATTERN_RAID0) {
+        if (lumv1->lmm_pattern != LOV_PATTERN_RAID0) {
                 CDEBUG(D_IOCTL, "bad userland stripe pattern: %#x\n",
-                       lum.lmm_pattern);
+                       lumv1->lmm_pattern);
                 RETURN(-EINVAL);
         }
 
         /* 64kB is the largest common page size we see (ia64), and matches the
          * check in lfs */
-        if (lum.lmm_stripe_size & (LOV_MIN_STRIPE_SIZE - 1)) {
+        if (lumv1->lmm_stripe_size & (LOV_MIN_STRIPE_SIZE - 1)) {
                 CDEBUG(D_IOCTL, "stripe size %u not multiple of %u, fixing\n",
-                       lum.lmm_stripe_size, LOV_MIN_STRIPE_SIZE);
-                lum.lmm_stripe_size = LOV_MIN_STRIPE_SIZE;
+                       lumv1->lmm_stripe_size, LOV_MIN_STRIPE_SIZE);
+                lumv1->lmm_stripe_size = LOV_MIN_STRIPE_SIZE;
         }
 
-        if ((lum.lmm_stripe_offset >= lov->desc.ld_tgt_count) &&
-            (lum.lmm_stripe_offset != (typeof(lum.lmm_stripe_offset))(-1))) {
+        if ((lumv1->lmm_stripe_offset >= lov->desc.ld_tgt_count) &&
+            (lumv1->lmm_stripe_offset !=
+             (typeof(lumv1->lmm_stripe_offset))(-1))) {
                 CDEBUG(D_IOCTL, "stripe offset %u > number of OSTs %u\n",
-                       lum.lmm_stripe_offset, lov->desc.ld_tgt_count);
+                       lumv1->lmm_stripe_offset, lov->desc.ld_tgt_count);
                 RETURN(-EINVAL);
         }
-        stripe_count = lov_get_stripecnt(lov, lum.lmm_stripe_count);
 
-        rc = lov_alloc_memmd(lsmp, stripe_count, lum.lmm_pattern, LOV_MAGIC);
+        stripe_count = lov_get_stripecnt(lov, lumv1->lmm_stripe_count);
+
+        if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) {
+                struct pool_desc *pool;
+
+                pool = lov_find_pool(lov, lumv3.lmm_pool_name);
+                if (pool != NULL) {
+                        if (lumv1->lmm_stripe_offset !=
+                            (typeof(lumv1->lmm_stripe_offset))(-1)) {
+                                rc = lov_check_index_in_pool(
+                                        lumv1->lmm_stripe_offset, pool);
+                                if (rc < 0) {
+                                        lov_pool_putref(pool);
+                                        RETURN(-EINVAL);
+                                }
+                        }
+
+                        if (stripe_count > pool_tgt_count(pool))
+                                stripe_count = pool_tgt_count(pool);
+
+                        lov_pool_putref(pool);
+                }
+        }
+
+        rc = lov_alloc_memmd(lsmp, stripe_count, lumv1->lmm_pattern,
+                             lumv1->lmm_magic);
 
         if (rc < 0)
                 RETURN(rc);
 
-        (*lsmp)->lsm_oinfo[0]->loi_ost_idx = lum.lmm_stripe_offset;
-        (*lsmp)->lsm_stripe_size = lum.lmm_stripe_size;
+        (*lsmp)->lsm_oinfo[0]->loi_ost_idx = lumv1->lmm_stripe_offset;
+        (*lsmp)->lsm_stripe_size = lumv1->lmm_stripe_size;
+
+        if (lumv1->lmm_magic == LOV_USER_MAGIC_V3)
+                strncpy((*lsmp)->lsm_pool_name, lumv3.lmm_pool_name,
+                        LOV_MAXPOOLNAME);
 
         RETURN(0);
 }
@@ -391,20 +522,27 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
         struct obd_export *oexp;
         struct lov_obd *lov = &exp->exp_obd->u.lov;
         obd_id last_id = 0;
+        struct lov_user_ost_data_v1 *lmm_objects;
 
         ENTRY;
+
+        if (lump->lmm_magic == LOV_USER_MAGIC_V3)
+                lmm_objects = ((struct lov_user_md_v3 *)lump)->lmm_objects;
+        else
+                lmm_objects = lump->lmm_objects;
+
         for (i = 0; i < lump->lmm_stripe_count; i++) {
                 __u32 len = sizeof(last_id);
-                oexp = lov->lov_tgts[lump->lmm_objects[i].l_ost_idx]->ltd_exp;
+                oexp = lov->lov_tgts[lmm_objects[i].l_ost_idx]->ltd_exp;
                 rc = obd_get_info(oexp, sizeof(KEY_LAST_ID), KEY_LAST_ID,
                                   &len, &last_id, NULL);
                 if (rc)
                         RETURN(rc);
-                if (lump->lmm_objects[i].l_object_id > last_id) {
+                if (lmm_objects[i].l_object_id > last_id) {
                         CERROR("Setting EA for object > than last id on "
                                "ost idx %d "LPD64" > "LPD64" \n",
-                               lump->lmm_objects[i].l_ost_idx,
-                               lump->lmm_objects[i].l_object_id, last_id);
+                               lmm_objects[i].l_ost_idx,
+                               lmm_objects[i].l_object_id, last_id);
                         RETURN(-EINVAL);
                 }
         }
@@ -415,9 +553,9 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
 
         for (i = 0; i < lump->lmm_stripe_count; i++) {
                 (*lsmp)->lsm_oinfo[i]->loi_ost_idx =
-                        lump->lmm_objects[i].l_ost_idx;
-                (*lsmp)->lsm_oinfo[i]->loi_id = lump->lmm_objects[i].l_object_id;
-                (*lsmp)->lsm_oinfo[i]->loi_gr = lump->lmm_objects[i].l_object_gr;
+                        lmm_objects[i].l_ost_idx;
+                (*lsmp)->lsm_oinfo[i]->loi_id = lmm_objects[i].l_object_id;
+                (*lsmp)->lsm_oinfo[i]->loi_gr = lmm_objects[i].l_object_gr;
         }
         RETURN(0);
 }
@@ -432,21 +570,36 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
 int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm,
                   struct lov_user_md *lump)
 {
-        struct lov_user_md lum;
+        /* we use lov_user_md_v3 because it is larger than lov_user_md_v1 */
+        struct lov_user_md_v3 lum;
         struct lov_mds_md *lmmk = NULL;
         int rc, lmm_size;
+        int lum_size;
         ENTRY;
 
         if (!lsm)
                 RETURN(-ENODATA);
-
-        rc = copy_from_user(&lum, lump, sizeof(lum));
+        /* we only need the header part from user space to get lmm_magic and
+         * lmm_stripe_count, (the header part is common to v1 and v3) */
+        lum_size = sizeof(struct lov_user_md_v1);
+        rc = copy_from_user(&lum, lump, lum_size);
         if (rc)
                 RETURN(-EFAULT);
+        /* if v3 we just have to update the lum_size */
+        if (lum.lmm_magic == LOV_USER_MAGIC_V3)
+                lum_size = sizeof(struct lov_user_md_v3);
 
-        if (lum.lmm_magic != LOV_USER_MAGIC)
+        if ((lum.lmm_magic != LOV_USER_MAGIC_V1) &&
+            (lum.lmm_magic != LOV_USER_MAGIC_V3))
                 RETURN(-EINVAL);
 
+        if (lum.lmm_stripe_count && 
+            (lum.lmm_stripe_count < lsm->lsm_stripe_count)) {
+                /* Return right size of stripe to user */
+                lum.lmm_stripe_count = lsm->lsm_stripe_count;
+                rc = copy_to_user(lump, &lum, lum_size);
+                RETURN(-EOVERFLOW);
+        }
         rc = lov_packmd(exp, &lmmk, lsm);
         if (rc < 0)
                 RETURN(rc);
@@ -454,19 +607,50 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm,
         rc = 0;
 
         /* FIXME: Bug 1185 - copy fields properly when structs change */
-        LASSERT(sizeof(lum) == sizeof(*lmmk));
+        /* struct lov_user_md_v3 and struct lov_mds_md_v3 must be the same */
+        LASSERT(sizeof(lum) == sizeof(struct lov_mds_md_v3));
         LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lmmk->lmm_objects[0]));
 
+        if ((cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) &&
+            ((lmmk->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) ||
+            (lmmk->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)))) {
+                lustre_swab_lov_user_md_objects((struct lov_user_md*)lmmk);
+                lustre_swab_lov_mds_md(lmmk);
+        }
+        if (lum.lmm_magic == LOV_USER_MAGIC) {
+                /* User request for v1, we need skip lmm_pool_name */
+                if (lmmk->lmm_magic == LOV_MAGIC_V3) {
+                        memmove(((struct lov_mds_md_v1*)lmmk)->lmm_objects,
+                                ((struct lov_mds_md_v3*)lmmk)->lmm_objects,
+                                lmmk->lmm_stripe_count *
+                                sizeof(struct lov_ost_data_v1));
+                        lmm_size -= LOV_MAXPOOLNAME;
+                }
+        } else {
+                /* if v3 we just have to update the lum_size */
+                lum_size = sizeof(struct lov_user_md_v3);
+        }
         /* User wasn't expecting this many OST entries */
-        if (lum.lmm_stripe_count == 0) {
-                if (copy_to_user(lump, lmmk, sizeof(lum)))
-                        rc = -EFAULT;
-        } else if (lum.lmm_stripe_count < lmmk->lmm_stripe_count) {
-                rc = -EOVERFLOW;
-        } else if (copy_to_user(lump, lmmk, lmm_size)) {
+        if (lum.lmm_stripe_count == 0)
+                lmm_size = lum_size;
+        else if (lum.lmm_stripe_count < lmmk->lmm_stripe_count)
+                RETURN(-EOVERFLOW);
+        /* 
+         * Have a difference between lov_mds_md & lov_user_md.
+         * So we have to re-order the data before copy to user.
+         */
+        lum.lmm_stripe_count = lmmk->lmm_stripe_count;
+        ((struct lov_user_md*)lmmk)->lmm_stripe_offset = 0;
+        ((struct lov_user_md*)lmmk)->lmm_stripe_count = lum.lmm_stripe_count;
+        if (copy_to_user(lump, lmmk, lmm_size))
                 rc = -EFAULT;
-        }
 
+        /* Restore the LE endian to ensure obd_free_diskmd works well */
+        if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) {
+                lmmk->lmm_stripe_count = lum.lmm_stripe_count;
+                lustre_swab_lov_mds_md(lmmk);
+        }
+        
         obd_free_diskmd(exp, &lmmk);
 
         RETURN(rc);
diff --git a/lustre/lov/lov_pool.c b/lustre/lov/lov_pool.c
new file mode 100644
index 0000000..e15504c
--- /dev/null
+++ b/lustre/lov/lov_pool.c
@@ -0,0 +1,666 @@
+/* -*- 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 [sun.com URL with a
+ * copy of GPLv2].
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/lov/lov_pool.c
+ *
+ * OST pool methods
+ *
+ * Author: Jacques-Charles LAFOUCRIERE <jc.lafoucriere at cea.fr>
+ * Author: Alex Lyashkov <Alexey.Lyashkov at Sun.COM>
+ * Author: Nathaniel Rutman <Nathan.Rutman at Sun.COM>
+ */
+
+#define DEBUG_SUBSYSTEM S_LOV
+
+#ifdef __KERNEL__
+#include <libcfs/libcfs.h>
+#else
+#include <liblustre.h>
+#endif
+
+#include <obd.h>
+#include "lov_internal.h"
+
+static void lov_pool_getref(struct pool_desc *pool)
+{
+        CDEBUG(D_INFO, "pool %p\n", pool);
+        atomic_inc(&pool->pool_refcount);
+}
+
+void lov_pool_putref(struct pool_desc *pool) 
+{
+        CDEBUG(D_INFO, "pool %p\n", pool);
+        if (atomic_dec_and_test(&pool->pool_refcount)) {
+                LASSERT(hlist_unhashed(&pool->pool_hash));
+                LASSERT(list_empty(&pool->pool_list));
+                LASSERT(pool->pool_proc_entry == NULL);
+                lov_ost_pool_free(&(pool->pool_rr.lqr_pool));
+                lov_ost_pool_free(&(pool->pool_obds));
+                OBD_FREE_PTR(pool);
+                EXIT;
+        }
+}
+
+/*
+ * hash function using a Rotating Hash algorithm
+ * Knuth, D. The Art of Computer Programming,
+ * Volume 3: Sorting and Searching,
+ * Chapter 6.4.
+ * Addison Wesley, 1973
+ */
+static __u32 pool_hashfn(lustre_hash_t *hash_body, void *key, unsigned mask)
+{
+        int i;
+        __u32 result;
+        char *poolname;
+
+        result = 0;
+        poolname = (char *)key;
+        for (i = 0; i < LOV_MAXPOOLNAME; i++) {
+                if (poolname[i] == '\0')
+                        break;
+                result = (result << 4)^(result >> 28) ^  poolname[i];
+        }
+        return (result % mask);
+}
+
+static void *pool_key(struct hlist_node *hnode)
+{
+        struct pool_desc *pool;
+
+        pool = hlist_entry(hnode, struct pool_desc, pool_hash);
+        return (pool->pool_name);
+}
+
+static int pool_hashkey_compare(void *key, struct hlist_node *compared_hnode)
+{
+        char *pool_name;
+        struct pool_desc *pool;
+        int rc;
+
+        pool_name = (char *)key;
+        pool = hlist_entry(compared_hnode, struct pool_desc, pool_hash);
+        rc = strncmp(pool_name, pool->pool_name, LOV_MAXPOOLNAME);
+        return (!rc);
+}
+
+static void *pool_hashrefcount_get(struct hlist_node *hnode)
+{
+        struct pool_desc *pool;
+
+        pool = hlist_entry(hnode, struct pool_desc, pool_hash);
+        lov_pool_getref(pool);
+        return (pool);
+}
+
+static void *pool_hashrefcount_put(struct hlist_node *hnode)
+{
+        struct pool_desc *pool;
+
+        pool = hlist_entry(hnode, struct pool_desc, pool_hash);
+        lov_pool_putref(pool);
+        return (pool);
+}
+
+lustre_hash_ops_t pool_hash_operations = {
+        .lh_hash        = pool_hashfn,
+        .lh_key         = pool_key,
+        .lh_compare     = pool_hashkey_compare,
+        .lh_get         = pool_hashrefcount_get,
+        .lh_put         = pool_hashrefcount_put,
+};
+
+#ifdef LPROCFS
+/* ifdef needed for liblustre support */
+/*
+ * pool /proc seq_file methods
+ */
+/*
+ * iterator is used to go through the target pool entries
+ * index is the current entry index in the lp_array[] array
+ * index >= pos returned to the seq_file interface
+ * pos is from 0 to (pool->pool_obds.op_count - 1)
+ */
+#define POOL_IT_MAGIC 0xB001CEA0
+struct pool_iterator {
+        int magic;
+        struct pool_desc *pool;
+        int idx;        /* from 0 to pool_tgt_size - 1 */
+};
+
+static void *pool_proc_next(struct seq_file *s, void *v, loff_t *pos)
+{
+        struct pool_iterator *iter = (struct pool_iterator *)s->private;
+        int prev_idx;
+
+        LASSERT(iter->magic == POOL_IT_MAGIC);
+
+        /* test if end of file */
+        if (*pos >= pool_tgt_count(iter->pool))
+                return NULL;
+
+        /* iterate to find a non empty entry */
+        prev_idx = iter->idx;
+        down_read(&pool_tgt_rw_sem(iter->pool));
+        iter->idx++;
+        if (iter->idx == pool_tgt_count(iter->pool)) {
+                iter->idx = prev_idx; /* we stay on the last entry */
+                up_read(&pool_tgt_rw_sem(iter->pool));
+                return NULL;
+        }
+        up_read(&pool_tgt_rw_sem(iter->pool));
+        (*pos)++;
+        /* return != NULL to continue */
+        return iter;
+}
+
+static void *pool_proc_start(struct seq_file *s, loff_t *pos)
+{
+        struct pool_desc *pool = (struct pool_desc *)s->private;
+        struct pool_iterator *iter;
+
+        lov_pool_getref(pool);
+        if ((pool_tgt_count(pool) == 0) ||
+            (*pos >= pool_tgt_count(pool))) {
+                /* iter is not created, so stop() has no way to
+                 * find pool to dec ref */
+                lov_pool_putref(pool);
+                return NULL;
+        }
+
+        OBD_ALLOC_PTR(iter);
+        if (!iter)
+                return ERR_PTR(-ENOMEM);
+        iter->magic = POOL_IT_MAGIC;
+        iter->pool = pool;
+        iter->idx = 0;
+
+        /* we use seq_file private field to memorized iterator so
+         * we can free it at stop() */
+        /* /!\ do not forget to restore it to pool before freeing it */
+        s->private = iter;
+        if (*pos > 0) {
+                loff_t i;
+                void *ptr;
+
+                i = 0;
+                do {
+                     ptr = pool_proc_next(s, &iter, &i);
+                } while ((i < *pos) && (ptr != NULL));
+                return ptr;
+        }
+        return iter;
+}
+
+static void pool_proc_stop(struct seq_file *s, void *v)
+{
+        struct pool_iterator *iter = (struct pool_iterator *)s->private;
+
+        /* in some cases stop() method is called 2 times, without
+         * calling start() method (see seq_read() from fs/seq_file.c)
+         * we have to free only if s->private is an iterator */
+        if ((iter) && (iter->magic == POOL_IT_MAGIC)) {
+                /* we restore s->private so next call to pool_proc_start()
+                 * will work */
+                s->private = iter->pool;
+                lov_pool_putref(iter->pool);
+                OBD_FREE_PTR(iter);
+        }
+        return;
+}
+
+static int pool_proc_show(struct seq_file *s, void *v)
+{
+        struct pool_iterator *iter = (struct pool_iterator *)v;
+        struct lov_tgt_desc *tgt;
+
+        LASSERT(iter->magic == POOL_IT_MAGIC);
+        LASSERT(iter->pool != NULL);
+        LASSERT(iter->idx <= pool_tgt_count(iter->pool));
+
+        down_read(&pool_tgt_rw_sem(iter->pool));
+        tgt = pool_tgt(iter->pool, iter->idx);
+        up_read(&pool_tgt_rw_sem(iter->pool));
+        if (tgt)
+                seq_printf(s, "%s\n", obd_uuid2str(&(tgt->ltd_uuid)));
+
+        return 0;
+}
+
+static struct seq_operations pool_proc_ops = {
+        .start          = pool_proc_start,
+        .next           = pool_proc_next,
+        .stop           = pool_proc_stop,
+        .show           = pool_proc_show,
+};
+
+static int pool_proc_open(struct inode *inode, struct file *file)
+{
+        int rc;
+
+        rc = seq_open(file, &pool_proc_ops);
+        if (!rc) {
+                struct seq_file *s = file->private_data;
+                s->private = PROC_I(inode)->pde->data;
+        }
+        return rc;
+}
+
+static struct file_operations pool_proc_operations = {
+        .open           = pool_proc_open,
+        .read           = seq_read,
+        .llseek         = seq_lseek,
+        .release        = seq_release,
+};
+#endif /* LPROCFS */
+
+void lov_dump_pool(int level, struct pool_desc *pool)
+{
+        int i;
+
+        lov_pool_getref(pool);
+
+        CDEBUG(level, "pool "LOV_POOLNAMEF" has %d members\n",
+               pool->pool_name, pool->pool_obds.op_count);
+        down_read(&pool_tgt_rw_sem(pool));
+
+        for (i = 0; i < pool_tgt_count(pool) ; i++) {
+                if (!pool_tgt(pool, i) || !(pool_tgt(pool, i))->ltd_exp)
+                        continue;
+                CDEBUG(level, "pool "LOV_POOLNAMEF"[%d] = %s\n",
+                       pool->pool_name, i,
+                       obd_uuid2str(&((pool_tgt(pool, i))->ltd_uuid)));
+        }
+
+        up_read(&pool_tgt_rw_sem(pool));
+        lov_pool_putref(pool);
+}
+
+#define LOV_POOL_INIT_COUNT 2
+int lov_ost_pool_init(struct ost_pool *op, unsigned int count)
+{
+        ENTRY;
+
+        if (count == 0)
+                count = LOV_POOL_INIT_COUNT;
+        op->op_array = NULL;
+        op->op_count = 0;
+        init_rwsem(&op->op_rw_sem);
+        op->op_size = count;
+        OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0]));
+        if (op->op_array == NULL) {
+                op->op_size = 0;
+                RETURN(-ENOMEM);
+        }
+        EXIT;
+        return 0;
+}
+
+/* Caller must hold write op_rwlock */
+int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count)
+{
+        __u32 *new;
+        int new_size;
+
+        LASSERT(min_count != 0);
+
+        if (op->op_count < op->op_size)
+                return 0;
+
+        new_size = max(min_count, 2 * op->op_size);
+        OBD_ALLOC(new, new_size * sizeof(op->op_array[0]));
+        if (new == NULL)
+                return -ENOMEM;
+
+        /* copy old array to new one */
+        memcpy(new, op->op_array, op->op_size * sizeof(op->op_array[0]));
+        OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+        op->op_array = new;
+        op->op_size = new_size;
+        return 0;
+}
+
+int lov_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count)
+{
+        int rc = 0, i;
+        ENTRY;
+
+        down_write(&op->op_rw_sem);
+
+        rc = lov_ost_pool_extend(op, min_count);
+        if (rc)
+                GOTO(out, rc);
+
+        /* search ost in pool array */
+        for (i = 0; i < op->op_count; i++) {
+                if (op->op_array[i] == idx)
+                        GOTO(out, rc = -EEXIST);
+        }
+        /* ost not found we add it */
+        op->op_array[op->op_count] = idx;
+        op->op_count++;
+        EXIT;
+out:
+        up_write(&op->op_rw_sem);
+        return rc;
+}
+
+int lov_ost_pool_remove(struct ost_pool *op, __u32 idx)
+{
+        int i;
+        ENTRY;
+
+        down_write(&op->op_rw_sem);
+        for (i = 0; i < op->op_count; i++) {
+                if (op->op_array[i] == idx) {
+                        memmove(&op->op_array[i], &op->op_array[i + 1],
+                                (op->op_count - i - 1) * sizeof(op->op_array[0]));
+                        op->op_count--;
+                        up_write(&op->op_rw_sem);
+                        EXIT;
+                        return 0;
+                }
+        }
+        up_write(&op->op_rw_sem);
+        RETURN(-EINVAL);
+}
+
+int lov_ost_pool_free(struct ost_pool *op)
+{
+        ENTRY;
+
+        if (op->op_size == 0)
+                return 0;
+
+        down_write(&op->op_rw_sem);
+        OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+        op->op_array = NULL;
+        op->op_count = 0;
+        op->op_size = 0;
+        up_write(&op->op_rw_sem);
+        return 0;
+}
+
+
+int lov_pool_new(struct obd_device *obd, char *poolname)
+{
+        struct lov_obd *lov;
+        struct pool_desc *new_pool;
+        int rc;
+        ENTRY;
+
+        lov = &(obd->u.lov);
+
+        if (strlen(poolname) > LOV_MAXPOOLNAME)
+                RETURN(-ENAMETOOLONG);
+
+        OBD_ALLOC_PTR(new_pool);
+        if (new_pool == NULL)
+                RETURN(-ENOMEM);
+
+        strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
+        new_pool->pool_name[LOV_MAXPOOLNAME] = '\0';
+        new_pool->pool_lov = lov;
+        /* ref count init to 1 because when created a pool is always used
+         * up to deletion
+         */
+        atomic_set(&new_pool->pool_refcount, 1);
+        rc = lov_ost_pool_init(&new_pool->pool_obds, 0);
+        if (rc)
+               GOTO(out_err, rc);
+
+        memset(&(new_pool->pool_rr), 0, sizeof(struct lov_qos_rr));
+        rc = lov_ost_pool_init(&new_pool->pool_rr.lqr_pool, 0);
+        if (rc)
+                GOTO(out_free_pool_obds, rc);
+
+        INIT_HLIST_NODE(&new_pool->pool_hash);
+
+#ifdef LPROCFS
+        /* we need this ifdef because seq_file is not implementated for liblustre */
+        /* get ref for /proc file */
+        lov_pool_getref(new_pool);
+        new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry,
+                                                       poolname, NULL, NULL,
+                                                       new_pool,
+                                                       &pool_proc_operations);
+        if (IS_ERR(new_pool->pool_proc_entry)) {
+                CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname);
+                new_pool->pool_proc_entry = NULL;
+                lov_pool_putref(new_pool);
+        }
+        CDEBUG(D_INFO, "pool %p - proc %p\n", new_pool, new_pool->pool_proc_entry);
+#endif
+
+        spin_lock(&obd->obd_dev_lock);
+        list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
+        lov->lov_pool_count++;
+        spin_unlock(&obd->obd_dev_lock);
+
+        /* add to find only when it fully ready  */
+        rc = lustre_hash_add_unique(lov->lov_pools_hash_body, poolname,
+                                    &new_pool->pool_hash);
+        if (rc)
+                GOTO(out_err, rc = -EEXIST);
+
+        CDEBUG(D_CONFIG, LOV_POOLNAMEF" is pool #%d\n",
+               poolname, lov->lov_pool_count);
+
+        RETURN(0);
+
+out_err:
+        spin_lock(&obd->obd_dev_lock);
+        list_del_init(&new_pool->pool_list);
+        lov->lov_pool_count--;
+        spin_unlock(&obd->obd_dev_lock);
+
+        lprocfs_remove(&new_pool->pool_proc_entry);
+
+        lov_ost_pool_free(&new_pool->pool_rr.lqr_pool);
+out_free_pool_obds:
+        lov_ost_pool_free(&new_pool->pool_obds);
+        OBD_FREE_PTR(new_pool);
+        return rc;
+}
+
+int lov_pool_del(struct obd_device *obd, char *poolname)
+{
+        struct lov_obd *lov;
+        struct pool_desc *pool;
+        ENTRY;
+
+        lov = &(obd->u.lov);
+
+        /* lookup and kill hash reference */
+        pool = lustre_hash_del_key(lov->lov_pools_hash_body, poolname);
+        if (pool == NULL)
+                RETURN(-ENOENT);
+
+        if (pool->pool_proc_entry != NULL) {
+                CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry);
+                lprocfs_remove(&pool->pool_proc_entry);
+                lov_pool_putref(pool);
+        }
+
+        spin_lock(&obd->obd_dev_lock);
+        list_del_init(&pool->pool_list);
+        lov->lov_pool_count--;
+        spin_unlock(&obd->obd_dev_lock);
+
+        /* release last reference */
+        lov_pool_putref(pool);
+
+        RETURN(0);
+}
+
+
+int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
+{
+        struct obd_uuid ost_uuid;
+        struct lov_obd *lov;
+        struct pool_desc *pool;
+        unsigned int lov_idx;
+        int rc;
+        ENTRY;
+
+        lov = &(obd->u.lov);
+
+        pool = lustre_hash_lookup(lov->lov_pools_hash_body, poolname);
+        if (pool == NULL)
+                RETURN(-ENOENT);
+
+        obd_str2uuid(&ost_uuid, ostname);
+
+        /* search ost in lov array */
+        obd_getref(obd);
+        for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {
+                if (!lov->lov_tgts[lov_idx])
+                        continue;
+                if (obd_uuid_equals(&ost_uuid,
+                                    &(lov->lov_tgts[lov_idx]->ltd_uuid)))
+                        break;
+        }
+        /* test if ost found in lov */
+        if (lov_idx == lov->desc.ld_tgt_count)
+                GOTO(out, rc = -EINVAL);
+
+        rc = lov_ost_pool_add(&pool->pool_obds, lov_idx, lov->lov_tgt_size);
+        if (rc)
+                GOTO(out, rc);
+
+        pool->pool_rr.lqr_dirty = 1;
+
+        CDEBUG(D_CONFIG, "Added %s to "LOV_POOLNAMEF" as member %d\n",
+               ostname, poolname,  pool_tgt_count(pool));
+        rc = 0;
+        EXIT;
+out:
+        obd_putref(obd);
+        lov_pool_putref(pool);
+        return rc;
+}
+
+int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname)
+{
+        struct obd_uuid ost_uuid;
+        struct lov_obd *lov;
+        struct pool_desc *pool;
+        unsigned int lov_idx;
+        int rc;
+        ENTRY;
+
+        lov = &(obd->u.lov);
+
+        /* hash have own locking */
+        pool = lustre_hash_lookup(lov->lov_pools_hash_body, poolname);
+        if (pool == NULL)
+                RETURN(-ENOENT);
+
+        obd_str2uuid(&ost_uuid, ostname);
+
+        /* search ost in lov array, to get index */
+        obd_getref(obd);
+        for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {
+                if (!lov->lov_tgts[lov_idx])
+                        continue;
+
+                if (obd_uuid_equals(&ost_uuid,
+                                    &(lov->lov_tgts[lov_idx]->ltd_uuid)))
+                        break;
+        }
+        /* test if ost found in lov */
+        if (lov_idx == lov->desc.ld_tgt_count)
+               GOTO(out, rc = -EINVAL);
+
+        lov_ost_pool_remove(&pool->pool_obds, lov_idx);
+
+        pool->pool_rr.lqr_dirty = 1;
+
+        CDEBUG(D_CONFIG, "%s removed from "LOV_POOLNAMEF"\n", ostname,
+               poolname);
+        rc = 0;
+        EXIT;
+out:
+        obd_putref(obd);
+        lov_pool_putref(pool);
+        return rc;
+}
+
+int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool)
+{
+        int i, rc;
+        ENTRY;
+
+        /* caller may no have a ref on pool if it got the pool
+         * without calling lov_find_pool() (e.g. go through the lov pool
+         * list)
+         */
+        lov_pool_getref(pool);
+
+        down_read(&pool_tgt_rw_sem(pool));
+        for (i = 0; i < pool_tgt_count(pool); i++) {
+                if (pool_tgt_array(pool)[i] == idx)
+                        GOTO(out, rc = 0);
+        }
+        rc = -ENOENT;
+        EXIT;
+out:
+        up_read(&pool_tgt_rw_sem(pool));
+
+        lov_pool_putref(pool);
+        return rc;
+}
+
+struct pool_desc *lov_find_pool(struct lov_obd *lov, char *poolname)
+{
+        struct pool_desc *pool;
+
+        pool = NULL;
+        if (poolname[0] != '\0') {
+                pool = lustre_hash_lookup(lov->lov_pools_hash_body, poolname);
+                if (pool == NULL)
+                        CWARN("Request for an unknown pool ("LOV_POOLNAMEF")\n",
+                              poolname);
+                if ((pool != NULL) && (pool_tgt_count(pool) == 0)) {
+                        CWARN("Request for an empty pool ("LOV_POOLNAMEF")\n",
+                               poolname);
+                        /* pool is ignored, so we remove ref on it */
+                        lov_pool_putref(pool);
+                        pool = NULL;
+                }
+        }
+        return pool;
+}
+
diff --git a/lustre/lov/lov_qos.c b/lustre/lov/lov_qos.c
index a84137b..fe76e91 100644
--- a/lustre/lov/lov_qos.c
+++ b/lustre/lov/lov_qos.c
@@ -47,6 +47,7 @@
 
 #include <obd_class.h>
 #include <obd_lov.h>
+#include <lustre/lustre_idl.h>
 #include "lov_internal.h"
 
 /* #define QOS_DEBUG 1 */
@@ -108,7 +109,7 @@ int qos_add_tgt(struct obd_device *obd, __u32 index)
         list_add_tail(&oss->lqo_oss_list, &temposs->lqo_oss_list);
 
         lov->lov_qos.lq_dirty = 1;
-        lov->lov_qos.lq_dirty_rr = 1;
+        lov->lov_qos.lq_rr.lqr_dirty = 1;
 
         CDEBUG(D_QOS, "add tgt %s to OSS %s (%d OSTs)\n",
                obd_uuid2str(&lov->lov_tgts[index]->ltd_uuid),
@@ -121,19 +122,16 @@ out:
         RETURN(rc);
 }
 
-int qos_del_tgt(struct obd_device *obd, __u32 index)
+int qos_del_tgt(struct obd_device *obd, struct lov_tgt_desc *tgt)
 {
         struct lov_obd *lov = &obd->u.lov;
         struct lov_qos_oss *oss;
         int rc = 0;
         ENTRY;
 
-        if (!lov->lov_tgts[index])
-                RETURN(0);
-
         down_write(&lov->lov_qos.lq_rw_sem);
 
-        oss = lov->lov_tgts[index]->ltd_qos.ltq_oss;
+        oss = tgt->ltd_qos.ltq_oss;
         if (!oss)
                 GOTO(out, rc = -ENOENT);
 
@@ -146,7 +144,7 @@ int qos_del_tgt(struct obd_device *obd, __u32 index)
         }
 
         lov->lov_qos.lq_dirty = 1;
-        lov->lov_qos.lq_dirty_rr = 1;
+        lov->lov_qos.lq_rr.lqr_dirty = 1;
 out:
         up_write(&lov->lov_qos.lq_rw_sem);
         RETURN(rc);
@@ -254,10 +252,7 @@ static int qos_calc_ppo(struct obd_device *obd)
         /* If each ost has almost same free space,
          * do rr allocation for better creation performance */
         lov->lov_qos.lq_same_space = 0;
-        temp = ba_max - ba_min;
-        ba_min = (ba_min * 51) >> 8;     /* 51/256 = .20 */
-        if (temp < ba_min) {
-                /* Difference is less than 20% */
+        if ((ba_max * (256 - lov->lov_qos.lq_threshold_rr)) >> 8 < ba_min) {
                 lov->lov_qos.lq_same_space = 1;
                 /* Reset weights for the next time we enter qos mode */
                 lov->lov_qos.lq_reset = 1;
@@ -286,10 +281,11 @@ static int qos_calc_weight(struct lov_obd *lov, int i)
 }
 
 /* We just used this index for a stripe; adjust everyone's weights */
-static int qos_used(struct lov_obd *lov, __u32 index, __u64 *total_wt)
+static int qos_used(struct lov_obd *lov, struct ost_pool *osts,
+                    __u32 index, __u64 *total_wt)
 {
         struct lov_qos_oss *oss;
-        int i;
+        int j;
         ENTRY;
 
         /* Don't allocate from this stripe anymore, until the next alloc_qos */
@@ -323,7 +319,10 @@ static int qos_used(struct lov_obd *lov, __u32 index, __u64 *total_wt)
 
         *total_wt = 0;
         /* Decrease all OST penalties */
-        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
+        for (j = 0; j < osts->op_count; j++) {
+                int i;
+
+                i = osts->op_array[j];
                 if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active)
                         continue;
                 if (lov->lov_tgts[i]->ltd_qos.ltq_penalty <
@@ -340,10 +339,11 @@ static int qos_used(struct lov_obd *lov, __u32 index, __u64 *total_wt)
                         *total_wt += lov->lov_tgts[i]->ltd_qos.ltq_weight;
 
 #ifdef QOS_DEBUG
-                CDEBUG(D_QOS, "recalc tgt %d avail="LPU64
+                CDEBUG(D_QOS, "recalc tgt %d usable=%d avail="LPU64
                        " ostppo="LPU64" ostp="LPU64" ossppo="LPU64
                        " ossp="LPU64" wt="LPU64"\n",
-                       i, TGT_BAVAIL(i) >> 10,
+                       i, lov->lov_tgts[i]->ltd_qos.ltq_usable,
+                       TGT_BAVAIL(i) >> 10,
                        lov->lov_tgts[i]->ltd_qos.ltq_penalty_per_obj >> 10,
                        lov->lov_tgts[i]->ltd_qos.ltq_penalty >> 10,
                        lov->lov_tgts[i]->ltd_qos.ltq_oss->lqo_penalty_per_obj>>10,
@@ -356,62 +356,59 @@ static int qos_used(struct lov_obd *lov, __u32 index, __u64 *total_wt)
 }
 
 #define LOV_QOS_EMPTY ((__u32)-1)
-/* compute optimal round-robin order, based on OSTs per OSS */
-static int qos_calc_rr(struct lov_obd *lov)
+/* compute optimal round-robin order, based on OSTs per OSS
+ */
+static int qos_calc_rr(struct lov_obd *lov, struct ost_pool *src_pool,
+                       struct lov_qos_rr *lqr)
 {
         struct lov_qos_oss *oss;
-        unsigned ost_count, placed, real_count;
-        int i;
+        unsigned placed, real_count;
+        int i, rc;
         ENTRY;
 
-        if (!lov->lov_qos.lq_dirty_rr) {
-                LASSERT(lov->lov_qos.lq_rr_size);
+        if (!lqr->lqr_dirty) {
+                LASSERT(lqr->lqr_pool.op_size);
                 RETURN(0);
         }
 
         /* Do actual allocation. */
         down_write(&lov->lov_qos.lq_rw_sem);
-        ost_count = lov->desc.ld_tgt_count;
-
-        if (lov->lov_qos.lq_rr_size)
-                OBD_FREE(lov->lov_qos.lq_rr_array, lov->lov_qos.lq_rr_size);
-        lov->lov_qos.lq_rr_size = ost_count *
-                sizeof(lov->lov_qos.lq_rr_array[0]);
-        OBD_ALLOC(lov->lov_qos.lq_rr_array, lov->lov_qos.lq_rr_size);
-        if (!lov->lov_qos.lq_rr_array) {
-                lov->lov_qos.lq_rr_size = 0;
-                up_write(&lov->lov_qos.lq_rw_sem);
-                RETURN(-ENOMEM);
-        }
 
-        real_count = 0;
-        for (i = 0; i < ost_count; i++) {
-                lov->lov_qos.lq_rr_array[i] = LOV_QOS_EMPTY;
-                if (lov->lov_tgts[i])
-                        real_count++;
+        real_count = src_pool->op_count;
+
+        /* Zero the pool array */
+        /* alloc_rr is holding a read lock on the pool, so nobody is adding/
+           deleting from the pool. The lq_rw_sem insures that nobody else
+           is reading. */
+        lqr->lqr_pool.op_count = real_count;
+        rc = lov_ost_pool_extend(&lqr->lqr_pool, real_count);
+        if (rc) {
+                up_write(&lov->lov_qos.lq_rw_sem);
+                RETURN(rc);
         }
+        for (i = 0; i < lqr->lqr_pool.op_count; i++)
+                lqr->lqr_pool.op_array[i] = LOV_QOS_EMPTY;
 
         /* Place all the OSTs from 1 OSS at the same time. */
         placed = 0;
         list_for_each_entry(oss, &lov->lov_qos.lq_oss_list, lqo_oss_list) {
                 int j = 0;
-                for (i = 0; i < ost_count; i++) {
-                        if (lov->lov_tgts[i] &&
-                            lov->lov_tgts[i]->ltd_qos.ltq_oss == oss) {
+                for (i = 0; i < lqr->lqr_pool.op_count; i++) {
+                        if (lov->lov_tgts[src_pool->op_array[i]] &&
+                            (lov->lov_tgts[src_pool->op_array[i]]->ltd_qos.ltq_oss == oss)) {
                               /* Evenly space these OSTs across arrayspace */
-                              int next = j * ost_count / oss->lqo_ost_count;
-                              while (lov->lov_qos.lq_rr_array[next] !=
+                              int next = j * lqr->lqr_pool.op_count / oss->lqo_ost_count;
+                              while (lqr->lqr_pool.op_array[next] !=
                                      LOV_QOS_EMPTY)
-                                      next = (next + 1) % ost_count;
-                              lov->lov_qos.lq_rr_array[next] = i;
+                                      next = (next + 1) % lqr->lqr_pool.op_count;
+                              lqr->lqr_pool.op_array[next] = src_pool->op_array[i];
                               j++;
                               placed++;
                         }
                 }
-                LASSERT(j == oss->lqo_ost_count);
         }
 
-        lov->lov_qos.lq_dirty_rr = 0;
+        lqr->lqr_dirty = 0;
         up_write(&lov->lov_qos.lq_rw_sem);
 
         if (placed != real_count) {
@@ -419,18 +416,18 @@ static int qos_calc_rr(struct lov_obd *lov)
                 LCONSOLE_ERROR_MSG(0x14e, "Failed to place all OSTs in the "
                                    "round-robin list (%d of %d).\n",
                                    placed, real_count);
-                for (i = 0; i < ost_count; i++) {
+                for (i = 0; i < lqr->lqr_pool.op_count; i++) {
                         LCONSOLE(D_WARNING, "rr #%d ost idx=%d\n", i,
-                                 lov->lov_qos.lq_rr_array[i]);
+                                 lqr->lqr_pool.op_array[i]);
                 }
-                lov->lov_qos.lq_dirty_rr = 1;
+                lqr->lqr_dirty = 1;
                 RETURN(-EAGAIN);
         }
 
 #ifdef QOS_DEBUG
-        for (i = 0; i < ost_count; i++) {
+        for (i = 0; i < lqr->lqr_pool.op_count; i++) {
                 LCONSOLE(D_QOS, "rr #%d ost idx=%d\n", i,
-                         lov->lov_qos.lq_rr_array[i]);
+                         lqr->lqr_pool.op_array[i]);
         }
 #endif
 
@@ -529,54 +526,67 @@ static int min_stripe_count(int stripe_cnt, int flags)
 #define LOV_CREATE_RESEED_MIN  1000
 /* Allocate objects on osts with round-robin algorithm */
 static int alloc_rr(struct lov_obd *lov, int *idx_arr, int *stripe_cnt,
-                    int flags)
+                    char *poolname, int flags)
 {
-        unsigned array_idx, ost_count = lov->desc.ld_tgt_count;
-        unsigned ost_active_count = lov->desc.ld_active_tgt_count;
-        int i, *idx_pos;
+        unsigned array_idx;
+        int i, rc, *idx_pos;
         __u32 ost_idx;
         int ost_start_idx_temp;
         int speed = 0;
         int stripe_cnt_min = min_stripe_count(*stripe_cnt, flags);
+        struct pool_desc *pool;
+        struct ost_pool *osts;
+        struct lov_qos_rr *lqr;
         ENTRY;
 
-        i = qos_calc_rr(lov);
-        if (i)
-                RETURN(i);
-
-        if (--lov->lov_start_count <= 0) {
-                lov->lov_start_idx = ll_rand() % ost_count;
-                lov->lov_start_count =
-                        (LOV_CREATE_RESEED_MIN / max(ost_active_count, 1U) +
-                         LOV_CREATE_RESEED_MULT) * max(ost_active_count, 1U);
-        } else if (stripe_cnt_min >= ost_active_count ||
-                   lov->lov_start_idx > ost_count) {
+        pool = lov_find_pool(lov, poolname);
+        if (pool == NULL) {
+                osts = &(lov->lov_packed);
+                lqr = &(lov->lov_qos.lq_rr);
+        } else {
+                down_read(&pool_tgt_rw_sem(pool));
+                osts = &(pool->pool_obds);
+                lqr = &(pool->pool_rr);
+        }
+
+        rc = qos_calc_rr(lov, osts, lqr);
+        if (rc)
+                GOTO(out, rc);
+
+        if (--lqr->lqr_start_count <= 0) {
+                lqr->lqr_start_idx = ll_rand() % osts->op_count;
+                lqr->lqr_start_count =
+                        (LOV_CREATE_RESEED_MIN / max(osts->op_count, 1U) +
+                         LOV_CREATE_RESEED_MULT) * max(osts->op_count, 1U);
+        } else if (stripe_cnt_min >= osts->op_count ||
+                   lqr->lqr_start_idx > osts->op_count) {
                 /* If we have allocated from all of the OSTs, slowly
                  * precess the next start if the OST/stripe count isn't
                  * already doing this for us. */
-                lov->lov_start_idx %= ost_count;
-                if (*stripe_cnt > 1 && (ost_active_count % (*stripe_cnt)) != 1)
-                        ++lov->lov_offset_idx;
+                lqr->lqr_start_idx %= osts->op_count;
+                if (*stripe_cnt > 1 && (osts->op_count % (*stripe_cnt)) != 1)
+                        ++lqr->lqr_offset_idx;
         }
         down_read(&lov->lov_qos.lq_rw_sem);
-        ost_start_idx_temp = lov->lov_start_idx;
+        ost_start_idx_temp = lqr->lqr_start_idx;
 
 repeat_find:
-        array_idx = (lov->lov_start_idx + lov->lov_offset_idx) % ost_count;
+        array_idx = (lqr->lqr_start_idx + lqr->lqr_offset_idx) % osts->op_count;
         idx_pos = idx_arr;
 #ifdef QOS_DEBUG
-        CDEBUG(D_QOS, "want %d startidx %d startcnt %d offset %d active %d "
-               "count %d arrayidx %d\n",
-               stripe_cnt, lov->lov_start_idx, lov->lov_start_count,
-               lov->lov_offset_idx, ost_active_count, ost_count, array_idx);
+        CDEBUG(D_QOS, "pool '%s' want %d startidx %d startcnt %d offset %d "
+               "active %d count %d arrayidx %d\n", poolname,
+               *stripe_cnt, lqr->lqr_start_idx, lqr->lqr_start_count,
+               lqr->lqr_offset_idx, osts->op_count, osts->op_count, array_idx);
 #endif
 
-        for (i = 0; i < ost_count; i++, array_idx=(array_idx + 1) % ost_count) {
-                ++lov->lov_start_idx;
-                ost_idx = lov->lov_qos.lq_rr_array[array_idx];
+        for (i = 0; i < osts->op_count;
+                    i++, array_idx=(array_idx + 1) % osts->op_count) {
+                ++lqr->lqr_start_idx;
+                ost_idx = lqr->lqr_pool.op_array[array_idx];
 #ifdef QOS_DEBUG
                 CDEBUG(D_QOS, "#%d strt %d act %d strp %d ary %d idx %d\n",
-                       i, lov->lov_start_idx,
+                       i, lqr->lqr_start_idx,
                        ((ost_idx != LOV_QOS_EMPTY) && lov->lov_tgts[ost_idx]) ?
                        lov->lov_tgts[ost_idx]->ltd_active : 0,
                        idx_pos - idx_arr, array_idx, ost_idx);
@@ -603,29 +613,64 @@ repeat_find:
         if ((speed < 2) && (idx_pos - idx_arr < stripe_cnt_min)) {
                 /* Try again, allowing slower OSCs */
                 speed++;
-                lov->lov_start_idx = ost_start_idx_temp;
+                lqr->lqr_start_idx = ost_start_idx_temp;
                 goto repeat_find;
         }
 
         up_read(&lov->lov_qos.lq_rw_sem);
 
         *stripe_cnt = idx_pos - idx_arr;
-        RETURN(0);
+out:
+        if (pool != NULL) {
+                up_read(&pool_tgt_rw_sem(pool));
+                /* put back ref got by lov_find_pool() */
+                lov_pool_putref(pool);
+        }
+
+        RETURN(rc);
 }
 
 /* alloc objects on osts with specific stripe offset */
 static int alloc_specific(struct lov_obd *lov, struct lov_stripe_md *lsm,
                           int *idx_arr)
 {
-        unsigned ost_idx, ost_count = lov->desc.ld_tgt_count;
-        int i, *idx_pos;
+        unsigned ost_idx, array_idx, ost_count;
+        int i, rc, *idx_pos;
         int speed = 0;
+        struct pool_desc *pool;
+        struct ost_pool *osts;
         ENTRY;
 
+        pool = lov_find_pool(lov, lsm->lsm_pool_name);
+        if (pool == NULL) {
+                osts = &(lov->lov_packed);
+        } else {
+                down_read(&pool_tgt_rw_sem(pool));
+                osts = &(pool->pool_obds);
+        }
+
+        ost_count = osts->op_count;
+
 repeat_find:
-        ost_idx = lsm->lsm_oinfo[0]->loi_ost_idx;
+        /* search loi_ost_idx in ost array */
+        array_idx = 0;
+        for (i = 0; i < ost_count; i++) {
+                if (osts->op_array[i] == lsm->lsm_oinfo[0]->loi_ost_idx) {
+                        array_idx = i;
+                        break;
+                }
+        }
+        if (i == ost_count) {
+                CERROR("Start index %d not found in pool '%s'\n",
+                       lsm->lsm_oinfo[0]->loi_ost_idx, lsm->lsm_pool_name);
+                GOTO(out, rc = -EINVAL);
+        }
+
         idx_pos = idx_arr;
-        for (i = 0; i < ost_count; i++, ost_idx = (ost_idx + 1) % ost_count) {
+        for (i = 0; i < ost_count;
+             i++, array_idx = (array_idx + 1) % ost_count) {
+                ost_idx = osts->op_array[array_idx];
+
                 if (!lov->lov_tgts[ost_idx] ||
                     !lov->lov_tgts[ost_idx]->ltd_active) {
                         continue;
@@ -649,7 +694,7 @@ repeat_find:
                 idx_pos++;
                 /* We have enough stripes */
                 if (idx_pos - idx_arr == lsm->lsm_stripe_count)
-                        RETURN(0);
+                        GOTO(out, rc = 0);
         }
         if (speed < 2) {
                 /* Try again, allowing slower OSCs */
@@ -666,7 +711,14 @@ repeat_find:
         CERROR("can't lstripe objid "LPX64": have %d want %u\n",
                lsm->lsm_object_id, (int)(idx_pos - idx_arr),
                lsm->lsm_stripe_count);
-        RETURN(-EFBIG);
+        rc = -EFBIG;
+out:
+        if (pool != NULL) {
+                up_read(&pool_tgt_rw_sem(pool));
+                /* put back ref got by lov_find_pool() */
+                lov_pool_putref(pool);
+        }
+        RETURN(rc);
 }
 
 /* Alloc objects on osts with optimization based on:
@@ -674,24 +726,39 @@ repeat_find:
    - network resources (shared OSS's)
 */
 static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
-                     int flags)
+                     char *poolname, int flags)
 {
         struct lov_obd *lov = &exp->exp_obd->u.lov;
         static time_t last_warn = 0;
         time_t now = cfs_time_current_sec();
         __u64 total_bavail, total_weight = 0;
-        __u32 ost_count;
         int nfound, good_osts, i, warn = 0, rc = 0;
         int stripe_cnt_min = min_stripe_count(*stripe_cnt, flags);
+        struct pool_desc *pool;
+        struct ost_pool *osts;
+        struct lov_qos_rr *lqr;
         ENTRY;
 
         if (stripe_cnt_min < 1)
                 RETURN(-EINVAL);
 
-        lov_getref(exp->exp_obd);
-        down_write(&lov->lov_qos.lq_rw_sem);
+        pool = lov_find_pool(lov, poolname);
+        if (pool == NULL) {
+                osts = &(lov->lov_packed);
+                lqr = &(lov->lov_qos.lq_rr);
+        } else {
+                down_read(&pool_tgt_rw_sem(pool));
+                osts = &(pool->pool_obds);
+                lqr = &(pool->pool_rr);
+        }
+
+        obd_getref(exp->exp_obd);
+        /* wait for fresh statfs info if needed, the rpcs are sent in
+         * lov_create() */
+        qos_statfs_update(exp->exp_obd,
+                          cfs_time_shift_64(-2 * lov->desc.ld_qos_maxage), 1);
 
-        ost_count = lov->desc.ld_tgt_count;
+        down_write(&lov->lov_qos.lq_rw_sem);
 
         if (lov->desc.ld_active_tgt_count < 2)
                 GOTO(out, rc = -EAGAIN);
@@ -706,24 +773,25 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
         if (cfs_time_sub(now, last_warn) > 60 * 30)
                 warn = 1;
         /* Find all the OSTs that are valid stripe candidates */
-        for (i = 0; i < ost_count; i++) {
+        for (i = 0; i < osts->op_count; i++) {
                 __u64 bavail;
 
-                if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active)
+                if (!lov->lov_tgts[osts->op_array[i]] ||
+                    !lov->lov_tgts[osts->op_array[i]]->ltd_active)
                         continue;
-                bavail = TGT_BAVAIL(i);
+                bavail = TGT_BAVAIL(osts->op_array[i]);
                 if (!bavail) {
                         if (warn) {
                                 CDEBUG(D_QOS, "no free space on %s\n",
-                                     obd_uuid2str(&lov->lov_tgts[i]->ltd_uuid));
+                                     obd_uuid2str(&lov->lov_tgts[osts->op_array[i]]->ltd_uuid));
                                 last_warn = now;
                         }
                         continue;
                 }
-                if (!TGT_FFREE(i)) {
+                if (!TGT_FFREE(osts->op_array[i])) {
                         if (warn) {
                                 CDEBUG(D_QOS, "no free inodes on %s\n",
-                                     obd_uuid2str(&lov->lov_tgts[i]->ltd_uuid));
+                                     obd_uuid2str(&lov->lov_tgts[osts->op_array[i]]->ltd_uuid));
                                 last_warn = now;
                         }
                         continue;
@@ -731,20 +799,24 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
 
                 /* Fail Check before osc_precreate() is called
                    so we can only 'fail' single OSC. */
-                if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OSC_PRECREATE) && i == 0)
+                if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OSC_PRECREATE) && osts->op_array[i] == 0)
                         continue;
 
-                if (obd_precreate(lov->lov_tgts[i]->ltd_exp) > 2)
+                if (obd_precreate(lov->lov_tgts[osts->op_array[i]]->ltd_exp) > 2)
                         continue;
 
-                lov->lov_tgts[i]->ltd_qos.ltq_usable = 1;
-                qos_calc_weight(lov, i);
+                lov->lov_tgts[osts->op_array[i]]->ltd_qos.ltq_usable = 1;
+                qos_calc_weight(lov, osts->op_array[i]);
                 total_bavail += bavail;
-                total_weight += lov->lov_tgts[i]->ltd_qos.ltq_weight;
+                total_weight += lov->lov_tgts[osts->op_array[i]]->ltd_qos.ltq_weight;
 
                 good_osts++;
         }
 
+#ifdef QOS_DEBUG
+        CDEBUG(D_QOS, "found %d good osts\n", good_osts);
+#endif
+
         if (good_osts < stripe_cnt_min)
                 GOTO(out, rc = -EAGAIN);
 
@@ -790,38 +862,52 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
 
                 /* On average, this will hit larger-weighted osts more often.
                    0-weight osts will always get used last (only when rand=0).*/
-                for (i = 0; i < ost_count; i++) {
-                        if (!lov->lov_tgts[i] ||
-                            !lov->lov_tgts[i]->ltd_qos.ltq_usable)
+                for (i = 0; i < osts->op_count; i++) {
+                        if (!lov->lov_tgts[osts->op_array[i]] ||
+                            !lov->lov_tgts[osts->op_array[i]]->ltd_qos.ltq_usable)
                                 continue;
 
-                        cur_weight += lov->lov_tgts[i]->ltd_qos.ltq_weight;
+                        cur_weight += lov->lov_tgts[osts->op_array[i]]->ltd_qos.ltq_weight;
+#ifdef QOS_DEBUG
+                        CDEBUG(D_QOS, "stripe_cnt=%d nfound=%d cur_weight="LPU64
+                                      " rand="LPU64" total_weight="LPU64"\n",
+                               *stripe_cnt, nfound, cur_weight, rand, total_weight);
+#endif
                         if (cur_weight >= rand) {
 #ifdef QOS_DEBUG
                                 CDEBUG(D_QOS, "assigned stripe=%d to idx=%d\n",
-                                       nfound, i);
+                                       nfound, osts->op_array[i]);
 #endif
-                                idx_arr[nfound++] = i;
-                                qos_used(lov, i, &total_weight);
+                                idx_arr[nfound++] = osts->op_array[i];
+                                qos_used(lov, osts, osts->op_array[i], &total_weight);
                                 rc = 0;
                                 break;
                         }
                 }
-                /* should never satisfy below condition */
                 if (rc) {
-                        CERROR("Didn't find any OSTs?\n");
-                        break;
+                        CDEBUG(D_QOS, "Didn't find any OSTs? Reduce total weight\n");
+                        if (total_weight == 0)
+                                break;
+                        else
+                                total_weight = 0;
                 }
         }
+
         LASSERT(nfound == *stripe_cnt);
 
 out:
         up_write(&lov->lov_qos.lq_rw_sem);
 
+        if (pool != NULL) {
+                up_read(&pool_tgt_rw_sem(pool));
+                /* put back ref got by lov_find_pool() */
+                lov_pool_putref(pool);
+        }
+
         if (rc == -EAGAIN)
-                rc = alloc_rr(lov, idx_arr, stripe_cnt, flags);
+                rc = alloc_rr(lov, idx_arr, stripe_cnt, poolname, flags);
 
-        lov_putref(exp->exp_obd);
+        obd_putref(exp->exp_obd);
         RETURN(rc);
 }
 
@@ -844,7 +930,8 @@ static int alloc_idx_array(struct obd_export *exp, struct lov_stripe_md *lsm,
 
         if (newea ||
             lsm->lsm_oinfo[0]->loi_ost_idx >= lov->desc.ld_tgt_count)
-                rc = alloc_qos(exp, tmp_arr, &stripe_cnt, flags);
+                rc = alloc_qos(exp, tmp_arr, &stripe_cnt,
+                               lsm->lsm_pool_name, flags);
         else
                 rc = alloc_specific(lov, lsm, tmp_arr);
 
@@ -972,6 +1059,10 @@ int qos_prep_create(struct obd_export *exp, struct lov_request_set *set)
 
         if (stripes < lsm->lsm_stripe_count)
                 qos_shrink_lsm(set);
+        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_LOV_PREP_CREATE)) {
+                qos_shrink_lsm(set);
+                rc = -EIO;
+        }
 
         if (oti && (src_oa->o_valid & OBD_MD_FLCOOKIE)) {
                 oti_alloc_cookies(oti, set->set_count);
@@ -993,3 +1084,110 @@ void qos_update(struct lov_obd *lov)
         ENTRY;
         lov->lov_qos.lq_dirty = 1;
 }
+
+void qos_statfs_done(struct lov_obd *lov)
+{
+        LASSERT(lov->lov_qos.lq_statfs_in_progress);
+        down_write(&lov->lov_qos.lq_rw_sem);
+        lov->lov_qos.lq_statfs_in_progress = 0;
+        /* wake up any threads waiting for the statfs rpcs to complete */
+        cfs_waitq_signal(&lov->lov_qos.lq_statfs_waitq);
+        up_write(&lov->lov_qos.lq_rw_sem);
+}
+
+static int qos_statfs_ready(struct obd_device *obd, __u64 max_age)
+{
+        struct lov_obd         *lov = &obd->u.lov;
+        int rc;
+        ENTRY;
+        down_read(&lov->lov_qos.lq_rw_sem);
+        rc = lov->lov_qos.lq_statfs_in_progress == 0 ||
+             cfs_time_beforeq_64(max_age, obd->obd_osfs_age);
+        up_read(&lov->lov_qos.lq_rw_sem);
+        RETURN(rc);
+}
+
+/*
+ * Update statfs data if the current osfs age is older than max_age.
+ * If wait is not set, it means that we are called from lov_create()
+ * and we should just issue the rpcs without waiting for them to complete.
+ * If wait is set, we are called from alloc_qos() and we just have
+ * to wait for the request set to complete.
+ */
+void qos_statfs_update(struct obd_device *obd, __u64 max_age, int wait)
+{
+        struct lov_obd         *lov = &obd->u.lov;
+        struct obd_info        *oinfo;
+        int                     rc = 0;
+        struct ptlrpc_request_set *set = NULL;
+        ENTRY;
+
+        if (cfs_time_beforeq_64(max_age, obd->obd_osfs_age))
+                /* statfs data are quite recent, don't need to refresh it */
+                RETURN_EXIT;
+
+        if (!wait && lov->lov_qos.lq_statfs_in_progress)
+                /* statfs already in progress */
+                RETURN_EXIT;
+
+        down_write(&lov->lov_qos.lq_rw_sem);
+        if (lov->lov_qos.lq_statfs_in_progress) {
+                up_write(&lov->lov_qos.lq_rw_sem);
+                GOTO(out, rc = 0);
+        }
+        /* no statfs in flight, send rpcs */
+        lov->lov_qos.lq_statfs_in_progress = 1;
+        up_write(&lov->lov_qos.lq_rw_sem);
+
+        if (wait)
+                CDEBUG(D_QOS, "%s: did not manage to get fresh statfs data "
+                       "in a timely manner (osfs age "LPU64", max age "LPU64")"
+                       ", sending new statfs rpcs\n",
+                       obd_uuid2str(&lov->desc.ld_uuid), obd->obd_osfs_age,
+                       max_age);
+
+        /* need to send statfs rpcs */
+        CDEBUG(D_QOS, "sending new statfs requests\n");
+        memset(lov->lov_qos.lq_statfs_data, 0,
+               sizeof(*lov->lov_qos.lq_statfs_data));
+        oinfo = &lov->lov_qos.lq_statfs_data->lsd_oi;
+        oinfo->oi_osfs = &lov->lov_qos.lq_statfs_data->lsd_statfs;
+        oinfo->oi_flags = OBD_STATFS_NODELAY;
+        set = ptlrpc_prep_set();
+        if (!set)
+                GOTO(out_failed, rc = -ENOMEM);
+
+        rc = obd_statfs_async(obd, oinfo, max_age, set);
+        if (rc || list_empty(&set->set_requests)) {
+                if (rc)
+                        CWARN("statfs failed with %d\n", rc);
+                GOTO(out_failed, rc);
+        }
+        /* send requests via ptlrpcd */
+        oinfo->oi_flags |= OBD_STATFS_PTLRPCD;
+        ptlrpcd_add_rqset(set);
+        GOTO(out, rc);
+
+out_failed:
+        down_write(&lov->lov_qos.lq_rw_sem);
+        lov->lov_qos.lq_statfs_in_progress = 0;
+        /* wake up any threads waiting for the statfs rpcs to complete */
+        cfs_waitq_signal(&lov->lov_qos.lq_statfs_waitq);
+        up_write(&lov->lov_qos.lq_rw_sem);
+        wait = 0;
+out:
+        if (set)
+                ptlrpc_set_destroy(set);
+        if (wait) {
+                struct l_wait_info lwi = { 0 };
+                CDEBUG(D_QOS, "waiting for statfs requests to complete\n");
+                l_wait_event(lov->lov_qos.lq_statfs_waitq,
+                             qos_statfs_ready(obd, max_age), &lwi);
+                if (cfs_time_before_64(obd->obd_osfs_age, max_age))
+                        CDEBUG(D_QOS, "%s: still no fresh statfs data after "
+                                      "waiting (osfs age "LPU64", max age "
+                                      LPU64")\n",
+                                      obd_uuid2str(&lov->desc.ld_uuid),
+                                      obd->obd_osfs_age, max_age);
+        }
+}
diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c
index 9fde960..83e7238 100644
--- a/lustre/lov/lov_request.c
+++ b/lustre/lov/lov_request.c
@@ -113,7 +113,7 @@ int lov_update_common_set(struct lov_request_set *set,
         lov_update_set(set, req, rc);
 
         /* grace error on inactive ost */
-        if (rc && !(lov->lov_tgts[req->rq_idx] && 
+        if (rc && !(lov->lov_tgts[req->rq_idx] &&
                     lov->lov_tgts[req->rq_idx]->ltd_active))
                 rc = 0;
 
@@ -349,6 +349,7 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo,
 
                 /* XXX LOV STACKING: submd should be from the subobj */
                 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
+                req->rq_oi.oi_md->lsm_object_gr = loi->loi_gr;
                 req->rq_oi.oi_md->lsm_stripe_count = 0;
                 req->rq_oi.oi_md->lsm_oinfo[0]->loi_kms_valid =
                         loi->loi_kms_valid;
@@ -459,6 +460,7 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo,
 
                 /* XXX LOV STACKING: submd should be from the subobj */
                 req->rq_oi.oi_md->lsm_object_id = loi->loi_id;
+                req->rq_oi.oi_md->lsm_object_gr = loi->loi_gr;
                 req->rq_oi.oi_md->lsm_stripe_count = 0;
 
                 lov_set_add_req(req, set);
@@ -734,6 +736,8 @@ int lov_prep_create_set(struct obd_export *exp, struct obd_info *oinfo,
         set->set_oti = oti;
 
         rc = qos_prep_create(exp, set);
+        /* qos_shrink_lsm() may have allocated a new lsm */
+        *lsmp = oinfo->oi_md;
         if (rc)
                 lov_fini_create_set(set, lsmp);
         else
@@ -874,7 +878,7 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo,
                         continue;
 
                 loi = oinfo->oi_md->lsm_oinfo[i];
-                if (!lov->lov_tgts[loi->loi_ost_idx] || 
+                if (!lov->lov_tgts[loi->loi_ost_idx] ||
                     !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
                         CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
                         GOTO(out, rc = -EIO);
@@ -1015,6 +1019,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
                        sizeof(*req->rq_oi.oi_oa));
                 req->rq_oi.oi_oa->o_id = loi->loi_id;
                 req->rq_oi.oi_cb_up = cb_getattr_update;
+                req->rq_rqset = set;
 
                 lov_set_add_req(req, set);
         }
@@ -1072,7 +1077,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
                 struct lov_request *req;
 
                 loi = lsm->lsm_oinfo[i];
-                if (!lov->lov_tgts[loi->loi_ost_idx] || 
+                if (!lov->lov_tgts[loi->loi_ost_idx] ||
                     !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
                         CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
                         continue;
@@ -1131,7 +1136,7 @@ int lov_update_setattr_set(struct lov_request_set *set,
         lov_update_set(set, req, rc);
 
         /* grace error on inactive ost */
-        if (rc && !(lov->lov_tgts[req->rq_idx] && 
+        if (rc && !(lov->lov_tgts[req->rq_idx] &&
                     lov->lov_tgts[req->rq_idx]->ltd_active))
                 rc = 0;
 
@@ -1377,8 +1382,16 @@ int lov_fini_sync_set(struct lov_request_set *set)
         RETURN(rc);
 }
 
+/* The callback for osc_sync that finilizes a request info when a
+ * response is recieved. */
+static int cb_sync_update(struct obd_info *oinfo, int rc)
+{
+        struct lov_request *lovreq;
+        lovreq = container_of(oinfo, struct lov_request, rq_oi);
+        return lov_update_common_set(lovreq->rq_rqset, lovreq, rc);
+}
+
 int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo,
-                      struct obdo *src_oa, struct lov_stripe_md *lsm,
                       obd_off start, obd_off end,
                       struct lov_request_set **reqset)
 {
@@ -1395,21 +1408,22 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo,
 
         set->set_exp = exp;
         set->set_oi = oinfo;
-        set->set_oi->oi_md = lsm;
-        set->set_oi->oi_oa = src_oa;
+        set->set_oi->oi_md = oinfo->oi_md;
+        set->set_oi->oi_oa = oinfo->oi_oa;
 
-        for (i = 0; i < lsm->lsm_stripe_count; i++) {
+        for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
                 struct lov_request *req;
                 obd_off rs, re;
 
-                loi = lsm->lsm_oinfo[i];
+                loi = oinfo->oi_md->lsm_oinfo[i];
                 if (!lov->lov_tgts[loi->loi_ost_idx] ||
                     !lov->lov_tgts[loi->loi_ost_idx]->ltd_active) {
                         CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
                         continue;
                 }
 
-                if (!lov_stripe_intersects(lsm, i, start, end, &rs, &re))
+                if (!lov_stripe_intersects(oinfo->oi_md, i, start,
+                                           end, &rs, &re))
                         continue;
 
                 OBD_ALLOC(req, sizeof(*req));
@@ -1423,13 +1437,16 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo,
                         OBD_FREE(req, sizeof(*req));
                         GOTO(out_set, rc = -ENOMEM);
                 }
-                memcpy(req->rq_oi.oi_oa, src_oa, sizeof(*req->rq_oi.oi_oa));
+                memcpy(req->rq_oi.oi_oa, oinfo->oi_oa,
+                       sizeof(*req->rq_oi.oi_oa));
                 req->rq_oi.oi_oa->o_id = loi->loi_id;
                 req->rq_oi.oi_oa->o_stripe_idx = i;
 
                 req->rq_oi.oi_policy.l_extent.start = rs;
                 req->rq_oi.oi_policy.l_extent.end = re;
                 req->rq_oi.oi_policy.l_extent.gid = -1;
+                req->rq_oi.oi_cb_up = cb_sync_update;
+                req->rq_rqset = set;
 
                 lov_set_add_req(req, set);
         }
@@ -1561,7 +1578,7 @@ void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs,
 }
 
 /* The callback for osc_statfs_async that finilizes a request info when a
- * response is recieved. */
+ * response is received. */
 static int cb_statfs_update(struct obd_info *oinfo, int rc)
 {
         struct lov_request *lovreq;
@@ -1579,15 +1596,15 @@ static int cb_statfs_update(struct obd_info *oinfo, int rc)
         lov_sfs = oinfo->oi_osfs;
 
         success = lovreq->rq_rqset->set_success;
-
         /* XXX: the same is done in lov_update_common_set, however
            lovset->set_exp is not initialized. */
         lov_update_set(lovreq->rq_rqset, lovreq, rc);
         if (rc) {
+                /* XXX ignore error for disconnected ost ? */
                 if (rc && !(lov->lov_tgts[lovreq->rq_idx] &&
                             lov->lov_tgts[lovreq->rq_idx]->ltd_active))
                         rc = 0;
-                RETURN(rc);
+                GOTO(out, rc);
         }
 
         spin_lock(&obd->obd_osfs_lock);
@@ -1598,6 +1615,14 @@ static int cb_statfs_update(struct obd_info *oinfo, int rc)
 
         lov_update_statfs(osfs, lov_sfs, success);
         qos_update(lov);
+out:
+        if (lovreq->rq_rqset->set_oi->oi_flags & OBD_STATFS_PTLRPCD &&
+            lovreq->rq_rqset->set_count == lovreq->rq_rqset->set_completes) {
+               lov_statfs_interpret(NULL, lovreq->rq_rqset,
+                                    lovreq->rq_rqset->set_success !=
+                                                  lovreq->rq_rqset->set_count);
+               qos_statfs_done(lov);
+        }
 
         RETURN(0);
 }
@@ -1622,7 +1647,8 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 struct lov_request *req;
 
-                if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active) {
+                if (!lov->lov_tgts[i] || (!lov->lov_tgts[i]->ltd_active
+                                          && (oinfo->oi_flags & OBD_STATFS_NODELAY))) {
                         CDEBUG(D_HA, "lov idx %d inactive\n", i);
                         continue;
                 }
diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c
index 71ab80f..7526bd8 100644
--- a/lustre/lov/lproc_lov.c
+++ b/lustre/lov/lproc_lov.c
@@ -237,6 +237,40 @@ static int lov_wr_qos_priofree(struct file *file, const char *buffer,
         return count;
 }
 
+static int lov_rd_qos_thresholdrr(char *page, char **start, off_t off,
+                                  int count, int *eof, void *data)
+{
+        struct obd_device *dev = (struct obd_device*) data;
+        struct lov_obd *lov;
+
+        LASSERT(dev != NULL);
+        lov = &dev->u.lov;
+        *eof = 1;
+        return snprintf(page, count, "%d%%\n",
+                        (lov->lov_qos.lq_threshold_rr * 100) >> 8);
+}
+
+static int lov_wr_qos_thresholdrr(struct file *file, const char *buffer,
+                                  unsigned long count, void *data)
+{
+        struct obd_device *dev = (struct obd_device *)data;
+        struct lov_obd *lov;
+        int val, rc;
+        LASSERT(dev != NULL);
+
+        lov = &dev->u.lov;
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        if (val > 100 || val < 0)
+                return -EINVAL;
+
+        lov->lov_qos.lq_threshold_rr = (val << 8) / 100;
+        lov->lov_qos.lq_dirty = 1;
+        return count;
+}
+
 static int lov_rd_qos_maxage(char *page, char **start, off_t off, int count,
                              int *eof, void *data)
 {
@@ -347,6 +381,7 @@ struct lprocfs_vars lprocfs_lov_obd_vars[] = {
         { "kbytesavail",  lprocfs_rd_kbytesavail, 0, 0 },
         { "desc_uuid",    lov_rd_desc_uuid,       0, 0 },
         { "qos_prio_free",lov_rd_qos_priofree,    lov_wr_qos_priofree, 0 },
+        { "qos_threshold_rr",  lov_rd_qos_thresholdrr, lov_wr_qos_thresholdrr, 0 },
         { "qos_maxage",   lov_rd_qos_maxage,      lov_wr_qos_maxage, 0 },
         { 0 }
 };
diff --git a/lustre/lvfs/Makefile.in b/lustre/lvfs/Makefile.in
index de72dbd..b9e4644 100644
--- a/lustre/lvfs/Makefile.in
+++ b/lustre/lvfs/Makefile.in
@@ -7,12 +7,16 @@ lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o upcall_cache.o prng.o lvfs_lib.
 
 @QUOTA_TRUE at quotafmt-objs := quotafmt_test.o
 
-ifeq ($(PATCHLEVEL),6)
 fsfilt_ at BACKINGFS@-objs := fsfilt- at BACKINGFS@.o
 
 $(obj)/fsfilt-%.c: $(obj)/fsfilt_%.c
 	ln -s $< $@
-endif
+
+EXTRA_DIST = $(lvfs-objs:.o=.c)  $(quotafmt-objs:.o=.c) \
+	fsfilt_ext3.c fsfilt_reiserfs.c \
+	lvfs_internal.h lvfs_userfs.c \
+	lustre_quota_fmt.c lustre_quota_fmt.h quotafmt_test.c \
+	lustre_quota_fmt_convert.c
 
 # for <ext3/xattr.h> on 2.6
 EXTRA_PRE_CFLAGS := -I at LINUX@/fs -I at LDISKFS_DIR@ -I at LDISKFS_DIR@/ldiskfs
diff --git a/lustre/lvfs/autoMakefile.am b/lustre/lvfs/autoMakefile.am
index 37ab888..2443191 100644
--- a/lustre/lvfs/autoMakefile.am
+++ b/lustre/lvfs/autoMakefile.am
@@ -71,10 +71,15 @@ ldiskfs_sed_flags = \
 	-e "s/DX_HASH/EXT3_DX_HASH/g" \
 	-e "s/reserve_window/ext3_reserve_window/g" \
 	-e "s/rsv_window_add/ext3_rsv_window_add/g" \
-	-e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g"
+	-e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g" \
+	-e "s/EXT4/LDISKFS/g" -e "s/ext4/ldiskfs/g" \
+	-e "s/HAVE_LDISKFS_LDISKFS/HAVE_EXT4_LDISKFS/g"
 
 fsfilt_ldiskfs.c: fsfilt_ext3.c
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
+	if grep -q '^#define\(.*\)HAVE_EXT4_LDISKFS' @LDISKFS_DIR@/config.h ; then \
+		sed -i -e "/DEBUG_SUBSYSTEM\(.*\)S_FILTER/a\#define HAVE_EXT4_LDISKFS 1" $@ ;\
+	fi
 fsfilt_ldiskfs_quota.h: fsfilt_ext3_quota.h
 	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
@@ -104,12 +109,5 @@ endif # MODULES
 
 install-data-hook: $(install_data_hook)
 
-DIST_SOURCES = fsfilt.c fsfilt_ext3.c fsfilt_reiserfs.c lvfs_common.c \
-	lvfs_internal.h lvfs_linux.c lvfs_userfs.c \
-	upcall_cache.c prng.c lvfs_lib.c\
-	lustre_quota_fmt.c lustre_quota_fmt.h quotafmt_test.c \
-	lustre_quota_fmt_convert.c \
-        # quotacheck_test.c quotactl_test.c fsfilt_ext3_quota.h
-
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
 CLEANFILES = fsfilt-*.c fsfilt_ldiskfs*.c fsfilt_extN.c sources
diff --git a/lustre/lvfs/autoMakefile.in b/lustre/lvfs/autoMakefile.in
index 7dd448b..5092aef 100644
--- a/lustre/lvfs/autoMakefile.in
+++ b/lustre/lvfs/autoMakefile.in
@@ -212,9 +212,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -347,7 +347,9 @@ target_vendor = @target_vendor@
 @LINUX_TRUE@@MODULES_TRUE@	-e "s/DX_HASH/EXT3_DX_HASH/g" \
 @LINUX_TRUE@@MODULES_TRUE@	-e "s/reserve_window/ext3_reserve_window/g" \
 @LINUX_TRUE@@MODULES_TRUE@	-e "s/rsv_window_add/ext3_rsv_window_add/g" \
- at LINUX_TRUE@@MODULES_TRUE@	-e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g"
+ at LINUX_TRUE@@MODULES_TRUE@	-e "s/EXT3/LDISKFS/g" -e "s/ext3/ldiskfs/g" \
+ at LINUX_TRUE@@MODULES_TRUE@	-e "s/EXT4/LDISKFS/g" -e "s/ext4/ldiskfs/g" \
+ at LINUX_TRUE@@MODULES_TRUE@	-e "s/HAVE_LDISKFS_LDISKFS/HAVE_EXT4_LDISKFS/g"
 
 
 @DARWIN_TRUE@@MODULES_TRUE at macos_PROGRAMS := lvfs
@@ -361,14 +363,6 @@ target_vendor = @target_vendor@
 @DARWIN_TRUE@@MODULES_TRUE at plist_DATA := Info.plist
 
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
-
-DIST_SOURCES = fsfilt.c fsfilt_ext3.c fsfilt_reiserfs.c lvfs_common.c \
-	lvfs_internal.h lvfs_linux.c lvfs_userfs.c \
-	upcall_cache.c prng.c lvfs_lib.c\
-	lustre_quota_fmt.c lustre_quota_fmt.h quotafmt_test.c \
-	lustre_quota_fmt_convert.c \
-        # quotacheck_test.c quotactl_test.c fsfilt_ext3_quota.h
-
 CLEANFILES = fsfilt-*.c fsfilt_ldiskfs*.c fsfilt_extN.c sources
 subdir = lustre/lvfs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -409,6 +403,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__liblvfs_a_SOURCES_DIST) $(am__lvfs_SOURCES_DIST)
 DATA = $(modulefs_DATA) $(plist_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
@@ -813,6 +808,9 @@ uninstall-am: uninstall-info-am uninstall-macosPROGRAMS \
 
 @LINUX_TRUE@@MODULES_TRUE at fsfilt_ldiskfs.c: fsfilt_ext3.c
 @LINUX_TRUE@@MODULES_TRUE@	sed $(strip $(ldiskfs_sed_flags)) $< > $@
+ at LINUX_TRUE@@MODULES_TRUE@	if grep -q '^#define\(.*\)HAVE_EXT4_LDISKFS' @LDISKFS_DIR@/config.h ; then \
+ at LINUX_TRUE@@MODULES_TRUE@		sed -i -e "/DEBUG_SUBSYSTEM\(.*\)S_FILTER/a\#define HAVE_EXT4_LDISKFS 1" $@ ;\
+ at LINUX_TRUE@@MODULES_TRUE@	fi
 @LINUX_TRUE@@MODULES_TRUE at fsfilt_ldiskfs_quota.h: fsfilt_ext3_quota.h
 @LINUX_TRUE@@MODULES_TRUE@	sed $(strip $(ldiskfs_sed_flags)) $< > $@
 
diff --git a/lustre/lvfs/fsfilt.c b/lustre/lvfs/fsfilt.c
index e9d365b..e650f8e 100644
--- a/lustre/lvfs/fsfilt.c
+++ b/lustre/lvfs/fsfilt.c
@@ -40,7 +40,6 @@
 #define DEBUG_SUBSYSTEM S_FILTER
 
 #include <linux/fs.h>
-#include <linux/jbd.h>
 #include <linux/module.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c
index 79e31dd..4bffe85 100644
--- a/lustre/lvfs/fsfilt_ext3.c
+++ b/lustre/lvfs/fsfilt_ext3.c
@@ -43,17 +43,29 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/fs.h>
-#include <linux/jbd.h>
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
+#ifdef HAVE_EXT4_LDISKFS
+#include <ext4/ext4.h>
+#include <ext4/ext4_jbd2.h>
+#else
+#include <linux/jbd.h>
 #include <linux/ext3_fs.h>
 #include <linux/ext3_jbd.h>
+#endif
 #include <linux/version.h>
 #include <linux/bitops.h>
 #include <linux/quota.h>
-#include <linux/quotaio_v1.h>
-#include <linux/quotaio_v2.h>
+#ifdef HAVE_QUOTAIO_V1_H
+# include <linux/quotaio_v1.h>
+# include <linux/quotaio_v2.h>
+#else
+# include <quotaio_v1.h>
+# include <quotaio_v2.h>
+# include <quota_tree.h>
+# define V2_DQTREEOFF    QT_TREEOFF
+#endif
 #include <linux/parser.h>
 #include <ext3/xattr.h>
 
@@ -65,8 +77,12 @@
 #include <linux/lprocfs_status.h>
 
 #ifdef EXT3_MULTIBLOCK_ALLOCATOR
+#ifdef HAVE_EXT4_LDISKFS
+#include <ext4/ext4_extents.h>
+#else
 #include <linux/ext3_extents.h>
 #endif
+#endif
 
 #include "lustre_quota_fmt.h"
 
@@ -102,6 +118,19 @@ struct fsfilt_cb_data {
 #define XATTR_NO_CTIME 0x80
 #endif
 
+#ifdef HAVE_EXT4_LDISKFS
+#define fsfilt_log_start_commit(journal, tid) jbd2_log_start_commit(journal, tid)
+#define fsfilt_log_wait_commit(journal, tid) jbd2_log_wait_commit(journal, tid)
+#define fsfilt_journal_callback_set(handle, func, jcb) jbd2_journal_callback_set(handle, func, jcb)
+#else
+#define fsfilt_log_start_commit(journal, tid) log_start_commit(journal, tid)
+#define fsfilt_log_wait_commit(journal, tid) log_wait_commit(journal, tid)
+#define fsfilt_journal_callback_set(handle, func, jcb) journal_callback_set(handle, func, jcb)
+#define ext_pblock(ex) le32_to_cpu((ex)->ee_start)
+#define ext3_ext_store_pblock(ex, pblock)  ((ex)->ee_start = cpu_to_le32(pblock))
+#define ext3_inode_bitmap(sb,desc) le32_to_cpu((desc)->bg_inode_bitmap)
+#endif
+
 static char *fsfilt_ext3_get_label(struct super_block *sb)
 {
         return EXT3_SB(sb)->s_es->s_volume_name;
@@ -115,7 +144,7 @@ static int fsfilt_ext3_set_label(struct super_block *sb, char *label)
         int err;
 
         journal = EXT3_SB(sb)->s_journal;
-        handle = journal_start(journal, 1);
+        handle = ext3_journal_start_sb(sb, 1);
         if (IS_ERR(handle)) {
                 CERROR("can't start transaction\n");
                 return(PTR_ERR(handle));
@@ -131,7 +160,7 @@ static int fsfilt_ext3_set_label(struct super_block *sb, char *label)
         err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
 
 out:
-        journal_stop(handle);
+        ext3_journal_stop(handle);
 
         return(err);
 }
@@ -142,12 +171,33 @@ static char *fsfilt_ext3_uuid(struct super_block *sb)
 }
 
 #ifdef HAVE_DISK_INODE_VERSION
+
+static __u64 get_i_version(struct inode *inode)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) && !defined(USE_I_FS_VERSION)
+        return inode->i_version;
+#else
+        return EXT3_I(inode)->i_fs_version;
+#endif
+}
+
+static void set_i_version(struct inode *inode, __u64 new_version)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) && !defined(USE_I_FS_VERSION)
+        inode->i_version = new_version;
+#else
+        (EXT3_I(inode))->i_fs_version = new_version;
+#endif
+}
+
 /*
  * Get the 64-bit version for an inode.
  */
 static __u64 fsfilt_ext3_get_version(struct inode *inode)
 {
-        return EXT3_I(inode)->i_fs_version;
+        CDEBUG(D_INFO, "Get version "LPX64" for inode %lu\n",
+               get_i_version(inode), inode->i_ino);
+        return get_i_version(inode);
 }
 
 /*
@@ -155,9 +205,14 @@ static __u64 fsfilt_ext3_get_version(struct inode *inode)
  */
 static __u64 fsfilt_ext3_set_version(struct inode *inode, __u64 new_version)
 {
-        __u64 old_version = EXT3_I(inode)->i_fs_version;
-
-        (EXT3_I(inode))->i_fs_version = new_version;
+        __u64 old_version = get_i_version(inode);
+
+        CDEBUG(D_INFO, "Set version "LPX64" (old "LPX64") for inode %lu\n",
+               new_version, old_version, inode->i_ino);
+        set_i_version(inode, new_version);
+        /* version is set after all inode operations are finished, so we should
+         * mark it dirty here */
+        inode->i_sb->s_op->dirty_inode(inode);
         return old_version;
 }
 
@@ -200,7 +255,7 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private,
                 nblocks += 3;
                 /* no break */
         case FSFILT_OP_CREATE: {
-#if defined(EXT3_EXTENTS_FL) && defined(EXT3_INDEX_FL)
+#if defined(EXT3_EXTENTS_FL) && defined(EXT3_INDEX_FL) && !defined(HAVE_EXT4_LDISKFS)
                 static int warned;
                 if (!warned) {
                         if (!test_opt(inode->i_sb, EXTENTS)) {
@@ -208,7 +263,8 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private,
                         } else if (((EXT3_I(inode)->i_flags &
                               cpu_to_le32(EXT3_EXTENTS_FL | EXT3_INDEX_FL)) ==
                               cpu_to_le32(EXT3_EXTENTS_FL | EXT3_INDEX_FL))) {
-                                CWARN("extent-mapped directory found - contact "
+                                CWARN("extent-mapped directory found with "
+                                      "ext3-based ldiskfs - contact "
                                       "http://bugzilla.lustre.org/\n");
                                 warned = 1;
                         }
@@ -357,7 +413,7 @@ static int fsfilt_ext3_credits_needed(int objcount, struct fsfilt_objinfo *fso,
         /* We assume that there will be 1 bit set in s_dquot.flags for each
          * quota file that is active.  This is at least true for now.
          */
-        needed += hweight32(sb_any_quota_enabled(sb)) *
+        needed += hweight32(ll_sb_any_quota_active(sb)) *
                 FSFILT_SINGLEDATA_TRANS_BLOCKS(sb);
 #endif
 
@@ -432,11 +488,11 @@ static int fsfilt_ext3_extend(struct inode *inode, unsigned int nblocks,void *h)
 
        if (handle->h_buffer_credits > nblocks)
                 return 0;
-       if (journal_extend(handle, nblocks) == 0)
+       if (ext3_journal_extend(handle, nblocks) == 0)
                 return 0;
 
        ext3_mark_inode_dirty(handle, inode);
-       return journal_restart(handle, nblocks);
+       return ext3_journal_restart(handle, nblocks);
 }
 
 static int fsfilt_ext3_commit(struct inode *inode, void *h, int force_sync)
@@ -474,7 +530,7 @@ static int fsfilt_ext3_commit_async(struct inode *inode, void *h,
                 CERROR("error while stopping transaction: %d\n", rc);
                 return rc;
         }
-        log_start_commit(journal, tid);
+        fsfilt_log_start_commit(journal, tid);
 
         *wait_handle = (void *) tid;
         CDEBUG(D_INODE, "commit async: %lu\n", (unsigned long) tid);
@@ -490,7 +546,7 @@ static int fsfilt_ext3_commit_wait(struct inode *inode, void *h)
         if (unlikely(is_journal_aborted(journal)))
                 return -EIO;
 
-        log_wait_commit(EXT3_JOURNAL(inode), tid);
+        fsfilt_log_wait_commit(EXT3_JOURNAL(inode), tid);
 
         if (unlikely(is_journal_aborted(journal)))
                 return -EIO;
@@ -504,9 +560,8 @@ static int fsfilt_ext3_setattr(struct dentry *dentry, void *handle,
         int rc = 0;
 
         LASSERTF(!(iattr->ia_valid & ATTR_SIZE) || !S_ISDIR(inode->i_mode),
-                 "changing i_size on directory #%llu (%p) new %llu old %llu\n",
-                 (long long)inode->i_ino, inode, (long long)iattr->ia_size,
-                 (long long)i_size_read(inode));
+                 "changing i_size on directory #%lu (%p) new "LPU64" old "LPU64"\n",
+                 inode->i_ino, inode, iattr->ia_size, i_size_read(inode));
 
         /* Avoid marking the inode dirty on the superblock list unnecessarily.
          * We are already writing the inode to disk as part of this
@@ -561,7 +616,7 @@ static int fsfilt_ext3_setattr(struct dentry *dentry, void *handle,
         RETURN(rc);
 }
 
-static int fsfilt_ext3_iocontrol(struct inode * inode, struct file *file,
+static int fsfilt_ext3_iocontrol(struct inode *inode, struct file *file,
                                  unsigned int cmd, unsigned long arg)
 {
         int rc = 0;
@@ -573,8 +628,14 @@ static int fsfilt_ext3_iocontrol(struct inode * inode, struct file *file,
                 RETURN(-EPERM);
         }
 
+#ifdef HAVE_EXT4_LDISKFS
+        /* ext4_ioctl does not have a inode argument */
+        if (inode->i_fop->unlocked_ioctl)
+                rc = inode->i_fop->unlocked_ioctl(file, cmd, arg);
+#else
         if (inode->i_fop->ioctl)
                 rc = inode->i_fop->ioctl(inode, file, cmd, arg);
+#endif
         else
                 RETURN(-ENOTTY);
 
@@ -709,8 +770,8 @@ static int fsfilt_ext3_add_journal_cb(struct obd_device *obd, __u64 last_rcvd,
         fcb->cb_data = cb_data;
 
         CDEBUG(D_EXT2, "set callback for last_rcvd: "LPD64"\n", last_rcvd);
-        journal_callback_set(handle, fsfilt_ext3_cb_func,
-                             (struct journal_callback *)fcb);
+        fsfilt_journal_callback_set(handle, fsfilt_ext3_cb_func,
+                                    (struct journal_callback *)fcb);
 
         return 0;
 }
@@ -754,11 +815,16 @@ static int fsfilt_ext3_sync(struct super_block *sb)
 
 #ifdef EXT3_MULTIBLOCK_ALLOCATOR
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
-#define ext3_up_truncate_sem(inode)  up(&EXT3_I(inode)->truncate_sem);
-#define ext3_down_truncate_sem(inode)  down(&EXT3_I(inode)->truncate_sem);
+#define fsfilt_up_truncate_sem(inode)  up(&EXT3_I(inode)->truncate_sem);
+#define fsfilt_down_truncate_sem(inode)  down(&EXT3_I(inode)->truncate_sem);
+#else
+#ifdef HAVE_EXT4_LDISKFS
+#define fsfilt_up_truncate_sem(inode) up_write((&EXT4_I(inode)->i_data_sem));
+#define fsfilt_down_truncate_sem(inode) down_write((&EXT4_I(inode)->i_data_sem));
 #else
-#define ext3_up_truncate_sem(inode)  mutex_unlock(&EXT3_I(inode)->truncate_mutex);
-#define ext3_down_truncate_sem(inode)  mutex_lock(&EXT3_I(inode)->truncate_mutex);
+#define fsfilt_up_truncate_sem(inode)  mutex_unlock(&EXT3_I(inode)->truncate_mutex);
+#define fsfilt_down_truncate_sem(inode)  mutex_lock(&EXT3_I(inode)->truncate_mutex);
+#endif
 #endif
 
 #ifndef EXT_ASSERT
@@ -767,10 +833,14 @@ static int fsfilt_ext3_sync(struct super_block *sb)
 
 #ifdef EXT3_EXT_HAS_NO_TREE
 /* for kernels 2.6.18 and later */
+#ifdef HAVE_EXT4_LDISKFS
+#define EXT_GENERATION(inode)           (EXT4_I(inode)->i_ext_generation)
+#else
+#define EXT_GENERATION(inode)           ext_generation(inode)
+#endif
 #define ext3_ext_base                   inode
 #define ext3_ext_base2inode(inode)      (inode)
 #define EXT_DEPTH(inode)                ext_depth(inode)
-#define EXT_GENERATION(inode)           ext_generation(inode)
 #define fsfilt_ext3_ext_walk_space(inode, block, num, cb, cbdata) \
                         ext3_ext_walk_space(inode, block, num, cb, cbdata);
 #else
@@ -781,15 +851,6 @@ static int fsfilt_ext3_sync(struct super_block *sb)
 #endif
 
 #include <linux/lustre_version.h>
-#if EXT3_EXT_MAGIC == 0xf301
-#define ee_start e_start
-#define ee_block e_block
-#define ee_len   e_num
-#endif
-#ifndef EXT3_BB_MAX_BLOCKS
-#define ext3_mb_new_blocks(handle, inode, goal, count, aflags, err) \
-        ext3_new_blocks(handle, inode, count, goal, err)
-#endif
 
 struct bpointers {
         unsigned long *blocks;
@@ -813,18 +874,8 @@ static int ext3_ext_find_goal(struct inode *inode, struct ext3_ext_path *path,
                 depth = path->p_depth;
 
                 /* try to predict block placement */
-                if ((ex = path[depth].p_ext)) {
-#if 0
-                        /* This prefers to eat into a contiguous extent
-                         * rather than find an extent that the whole
-                         * request will fit into.  This can fragment data
-                         * block allocation and prevents our lovely 1M I/Os
-                         * from reaching the disk intact. */
-                        if (ex->ee_block + ex->ee_len == block)
-                                *aflags |= 1;
-#endif
-                        return ex->ee_start + (block - ex->ee_block);
-                }
+                if ((ex = path[depth].p_ext))
+                        return ext_pblock(ex) + (block - le32_to_cpu(ex->ee_block));
 
                 /* it looks index is empty
                  * try to find starting from index itself */
@@ -949,15 +1000,14 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base,
 
         tgen = EXT_GENERATION(base);
         count = ext3_ext_calc_credits_for_insert(base, path);
-        ext3_up_truncate_sem(inode);
-
+        fsfilt_up_truncate_sem(inode);
         handle = ext3_journal_start(inode, count+EXT3_ALLOC_NEEDED+1);
         if (IS_ERR(handle)) {
-                ext3_down_truncate_sem(inode);
+                fsfilt_down_truncate_sem(inode);
                 return PTR_ERR(handle);
         }
 
-        ext3_down_truncate_sem(inode);
+        fsfilt_down_truncate_sem(inode);
         if (tgen != EXT_GENERATION(base)) {
                 /* the tree has changed. so path can be invalid at moment */
                 ext3_journal_stop(handle);
@@ -971,9 +1021,9 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base,
         EXT_ASSERT(count <= cex->ec_len);
 
         /* insert new extent */
-        nex.ee_block = cex->ec_block;
-        nex.ee_start = pblock;
-        nex.ee_len = count;
+        nex.ee_block = cpu_to_le32(cex->ec_block);
+        ext3_ext_store_pblock(&nex, pblock);
+        nex.ee_len = cpu_to_le16(count);
         err = ext3_ext_insert_extent(handle, base, path, &nex);
         if (err) {
                 /* free data blocks we just allocated */
@@ -982,7 +1032,8 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base,
 #ifdef EXT3_MB_HINT_GROUP_ALLOC
                 ext3_mb_discard_inode_preallocations(inode);
 #endif
-                ext3_free_blocks(handle, inode, nex.ee_start, nex.ee_len, 0);
+                ext3_free_blocks(handle, inode, ext_pblock(&nex),
+                                 cpu_to_le16(nex.ee_len), 0);
                 goto out;
         }
 
@@ -991,10 +1042,10 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base,
          * we are asking ext3_ext_walk_space() to continue
          * scaning after that block
          */
-        cex->ec_len = nex.ee_len;
-        cex->ec_start = nex.ee_start;
-        BUG_ON(nex.ee_len == 0);
-        BUG_ON(nex.ee_block != cex->ec_block);
+        cex->ec_len = le16_to_cpu(nex.ee_len);
+        cex->ec_start = ext_pblock(&nex);
+        BUG_ON(le16_to_cpu(nex.ee_len) == 0);
+        BUG_ON(le32_to_cpu(nex.ee_block) != cex->ec_block);
 
 out:
         ext3_journal_stop(handle);
@@ -1005,9 +1056,10 @@ map:
                         CERROR("hmm. why do we find this extent?\n");
                         CERROR("initial space: %lu:%u\n",
                                 bp->start, bp->init_num);
-                        CERROR("current extent: %u/%u/%u %d\n",
+                        CERROR("current extent: %u/%u/%llu %d\n",
                                 cex->ec_block, cex->ec_len,
-                                cex->ec_start, cex->ec_type);
+                                (unsigned long long)cex->ec_start,
+                                cex->ec_type);
                 }
                 i = 0;
                 if (cex->ec_block < bp->start)
@@ -1061,10 +1113,10 @@ int fsfilt_map_nblocks(struct inode *inode, unsigned long block,
         bp.init_num = bp.num = num;
         bp.create = create;
 
-        ext3_down_truncate_sem(inode);
+        fsfilt_down_truncate_sem(inode);
         err = fsfilt_ext3_ext_walk_space(base, block, num, ext3_ext_new_extent_cb, &bp);
         ext3_ext_invalidate_cache(base);
-        ext3_up_truncate_sem(inode);
+        fsfilt_up_truncate_sem(inode);
 
         return err;
 }
@@ -1298,7 +1350,7 @@ out:
 
 static int fsfilt_ext3_setup(struct super_block *sb)
 {
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) && defined(HAVE_QUOTA_SUPPORT)
+#if !defined(S_PDIROPS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,6)) && defined(HAVE_QUOTA_SUPPORT)
         struct ext3_sb_info *sbi = EXT3_SB(sb);
 #endif
 #if 0
@@ -1421,28 +1473,22 @@ static int fsfilt_ext3_quotactl(struct super_block *sb,
                                 lustre_quota_version_t qfmt = oqc->qc_id;
                                 char *name[][MAXQUOTAS] = LUSTRE_OPQFILES_NAMES;
 
-                                if (!qcop->quota_on)
-                                        GOTO(out, rc = -ENOSYS);
-
-                                rc = qcop->quota_on(sb, i, QFMT_VFS_V0,
-                                                    name[qfmt][i]);
+                                rc = ll_quota_on(sb, i, QFMT_VFS_V0,
+                                                 name[qfmt][i], 0);
 #ifdef HAVE_QUOTA64
                                 if (rc == -ENOENT || rc == -EINVAL) {
                                         /* see bug 13904 */
                                         rc = lustre_slave_quota_convert(qfmt, i);
                                         if (!rc)
-                                                rc = qcop->quota_on(sb, i,
-                                                                QFMT_VFS_V0,
-                                                                name[qfmt][i]);
+                                                rc = ll_quota_on(sb, i,
+                                                              QFMT_VFS_V0,
+                                                              name[qfmt][i], 0);
                                         else if (rc == -ESTALE)
                                                 rc = -ENOENT;
                                 }
 #endif
-                        } else if (oqc->qc_cmd == Q_QUOTAOFF) {
-                                if (!qcop->quota_off)
-                                        GOTO(out, rc = -ENOSYS);
-                                rc = qcop->quota_off(sb, i);
-                        }
+                        } else if (oqc->qc_cmd == Q_QUOTAOFF)
+                                rc = ll_quota_off(sb, i, 0);
 
                         if (rc == -EBUSY)
                                 error = rc;
@@ -1659,17 +1705,18 @@ get_group_desc(struct super_block *sb, int group)
         return gdp + desc;
 }
 
+#ifndef HAVE_EXT4_LDISKFS
 static inline struct buffer_head *
-read_inode_bitmap(struct super_block *sb, unsigned long group)
+ext3_read_inode_bitmap(struct super_block *sb, unsigned long group)
 {
         struct ext3_group_desc *desc;
         struct buffer_head *bh;
 
         desc = get_group_desc(sb, group);
-        bh = sb_bread(sb, le32_to_cpu(desc->bg_inode_bitmap));
-
+        bh = sb_bread(sb, ext3_inode_bitmap(sb, desc));
         return bh;
 }
+#endif
 
 static inline struct inode *ext3_iget_inuse(struct super_block *sb,
                                      struct buffer_head *bitmap_bh,
@@ -1678,8 +1725,14 @@ static inline struct inode *ext3_iget_inuse(struct super_block *sb,
         struct inode *inode = NULL;
 
         if (ext3_test_bit(index, bitmap_bh->b_data))
+#ifdef HAVE_READ_INODE_IN_SBOPS
                 inode = iget(sb, ino);
-
+#else
+                inode = ext3_iget(sb, ino);
+#endif
+        if (IS_ERR(inode))
+	        /* Newer kernels return an error instead of a NULL pointer */
+                inode = NULL;
         return inode;
 }
 
@@ -1741,11 +1794,7 @@ static int add_inode_quota(struct inode *inode, struct qchk_ctxt *qctxt,
 static int v2_write_dqheader(struct file *f, int type)
 {
         static const __u32 quota_magics[] = V2_INITQMAGICS;
-#ifdef HAVE_QUOTA64
-        static const __u32 quota_versions[] = V2_INITQVERSIONS_R0;
-#else
-        static const __u32 quota_versions[] = V2_INITQVERSIONS;
-#endif
+        static const __u32 quota_versions[] = LUSTRE_INITQVERSIONS_V1;
         struct v2_disk_dqheader dqhead;
         loff_t offset = 0;
 
@@ -1787,7 +1836,7 @@ static int v2_write_dqinfo(struct file *f, int type, struct if_dqinfo *info)
 static int v3_write_dqheader(struct file *f, int type)
 {
         static const __u32 quota_magics[] = V2_INITQMAGICS;
-        static const __u32 quota_versions[] = V2_INITQVERSIONS_R1;
+        static const __u32 quota_versions[] = LUSTRE_INITQVERSIONS_V2;
         struct v2_disk_dqheader dqhead;
         loff_t offset = 0;
 
@@ -1971,9 +2020,9 @@ static int fsfilt_ext3_quotacheck(struct super_block *sb,
         /* check quota and update in hash */
         for (group = 0; group < sbi->s_groups_count; group++) {
                 ino = group * sbi->s_inodes_per_group + 1;
-                bitmap_bh = read_inode_bitmap(sb, group);
+                bitmap_bh = ext3_read_inode_bitmap(sb, group);
                 if (!bitmap_bh) {
-                        CERROR("read_inode_bitmap group %d failed", group);
+                        CERROR("ext3_read_inode_bitmap group %d failed", group);
                         GOTO(out, -EIO);
                 }
 
@@ -2024,7 +2073,7 @@ static int fsfilt_ext3_quotacheck(struct super_block *sb,
                                 cqget(sb, qctxt->qckt_hash, &qctxt->qckt_list,
                                       dqid->di_id, i,
                                       qctxt->qckt_first_check[i]);
-                        kfree(dqid);
+                        OBD_FREE_PTR(dqid);
                 }
         }
 #endif
diff --git a/lustre/lvfs/lustre_quota_fmt.c b/lustre/lvfs/lustre_quota_fmt.c
index e168c99..47ae3db 100644
--- a/lustre/lvfs/lustre_quota_fmt.c
+++ b/lustre/lvfs/lustre_quota_fmt.c
@@ -50,7 +50,9 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/quotaio_v1.h>
+#ifdef HAVE_QUOTAIO_V1_H
+# include <linux/quotaio_v1.h>
+#endif
 
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
@@ -62,7 +64,7 @@
 #ifdef HAVE_QUOTA_SUPPORT
 
 static const uint lustre_initqversions[][MAXQUOTAS] = {
-        [LUSTRE_QUOTA_V1] = LUSTRE_INITQVERSIONS,
+        [LUSTRE_QUOTA_V1] = LUSTRE_INITQVERSIONS_V1,
         [LUSTRE_QUOTA_V2] = LUSTRE_INITQVERSIONS_V2
 };
 
@@ -76,6 +78,24 @@ static const int lustre_disk_dqblk_sz[] = {
         [LUSTRE_QUOTA_V2] = sizeof(struct lustre_disk_dqblk_v2)
 };
 
+static const union
+{
+        struct lustre_disk_dqblk    r0;
+        struct lustre_disk_dqblk_v2 r1;
+} fakedquot[] = {
+        [LUSTRE_QUOTA_V1] = {.r0 = {.dqb_itime = __constant_cpu_to_le64(1LLU)} },
+        [LUSTRE_QUOTA_V2] = {.r1 = {.dqb_itime = __constant_cpu_to_le64(1LLU)} }
+};
+
+static const union
+{
+        struct lustre_disk_dqblk    r0;
+        struct lustre_disk_dqblk_v2 r1;
+} emptydquot[] = {
+        [LUSTRE_QUOTA_V1] = {.r0 = { 0 } },
+        [LUSTRE_QUOTA_V2] = {.r1 = { 0 } }
+};
+
 int check_quota_file(struct file *f, struct inode *inode, int type, 
                      lustre_quota_version_t version)
 {
@@ -86,6 +106,12 @@ int check_quota_file(struct file *f, struct inode *inode, int type,
         static const uint quota_magics[] = LUSTRE_INITQMAGICS;
         const uint *quota_versions = lustre_initqversions[version];
 
+        if (!inode && !f) {
+                CERROR("check_quota_file failed!\n");
+                libcfs_debug_dumpstack(NULL);
+                return -EINVAL;
+        }
+
         if (f) {
                 fs = get_fs();
                 set_fs(KERNEL_DS);
@@ -422,7 +448,6 @@ static uint find_free_dqentry(struct lustre_dquot *dquot, int *err,
         void *ddquot;
         int dqblk_sz = lustre_disk_dqblk_sz[version];
         int dqstrinblk = lustre_dqstrinblk[version];
-        char fakedquot[dqblk_sz];
         dqbuf_t buf;
 
         *err = 0;
@@ -458,11 +483,11 @@ static uint find_free_dqentry(struct lustre_dquot *dquot, int *err,
                         goto out_buf;
                 }
         dh->dqdh_entries = cpu_to_le16(le16_to_cpu(dh->dqdh_entries) + 1);
-        memset(fakedquot, 0, dqblk_sz);
         /* Find free structure in block */
         for (i = 0; i < dqstrinblk &&
-             memcmp(fakedquot, (char*)ddquot + i * dqblk_sz, 
-                    sizeof(fakedquot)); i++);
+             memcmp((char *)&emptydquot[version],
+                    (char*)ddquot + i * dqblk_sz,
+                    dqblk_sz); i++);
 
         if (i == dqstrinblk) {
                 CERROR("VFS: Data block full but it shouldn't.\n");
@@ -560,7 +585,7 @@ static int lustre_write_dquot(struct lustre_dquot *dquot,
         loff_t offset;
         ssize_t ret;
         int dqblk_sz = lustre_disk_dqblk_sz[version];
-        char ddquot[dqblk_sz], empty[dqblk_sz];
+        char ddquot[dqblk_sz];
 
         ret = mem2diskdqb(ddquot, &dquot->dq_dqb, dquot->dq_id, version);
         if (ret < 0)
@@ -577,8 +602,7 @@ static int lustre_write_dquot(struct lustre_dquot *dquot,
         /* Argh... We may need to write structure full of zeroes but that would be
          * treated as an empty place by the rest of the code. Format change would
          * be definitely cleaner but the problems probably are not worth it */
-        memset(empty, 0, dqblk_sz);
-        if (!memcmp(empty, ddquot, dqblk_sz))
+        if (!memcmp((char *)&emptydquot[version], ddquot, dqblk_sz))
                 DQF_PUT(ddquot, version, dqb_itime, 1);
         fs = get_fs();
         set_fs(KERNEL_DS);
@@ -726,12 +750,10 @@ static loff_t find_block_dqentry(struct lustre_dquot *dquot, uint blk,
                      DQF_GET(ddquot+i*dqblk_sz, version, dqb_id) != dquot->dq_id;
                      i++) ;
         else {                  /* ID 0 as a bit more complicated searching... */
-                char fakedquot[dqblk_sz];
-
-                memset(fakedquot, 0, sizeof(fakedquot));
                 for (i = 0; i < dqstrinblk; i++)
                         if (!DQF_GET(ddquot + i*dqblk_sz, version, dqb_id)
-                            && memcmp(fakedquot, ddquot + i*dqblk_sz,
+                            && memcmp((char *)&emptydquot[version],
+                                      ddquot + i*dqblk_sz,
                                       dqblk_sz))
                                 break;
         }
@@ -785,6 +807,7 @@ static inline loff_t find_dqentry(struct lustre_dquot *dquot,
         return find_tree_dqentry(dquot, LUSTRE_DQTREEOFF, 0, version);
 }
 
+
 int lustre_read_dquot(struct lustre_dquot *dquot)
 {
         int type = dquot->dq_type;
@@ -813,7 +836,7 @@ int lustre_read_dquot(struct lustre_dquot *dquot)
                 memset(&dquot->dq_dqb, 0, sizeof(struct lustre_mem_dqblk));
                 ret = offset;
         } else {
-                char ddquot[dqblk_sz], empty[dqblk_sz];
+                char ddquot[dqblk_sz];
 
                 dquot->dq_off = offset;
                 fs = get_fs();
@@ -828,9 +851,8 @@ int lustre_read_dquot(struct lustre_dquot *dquot)
                 } else {
                         ret = 0;
                         /* We need to escape back all-zero structure */
-                        memset(empty, 0, dqblk_sz);
-                        DQF_PUT(empty, version, dqb_itime, 1);
-                        if (!memcmp(empty, ddquot, dqblk_sz))
+                        if (!memcmp((char *)&fakedquot[version],
+                                    ddquot, dqblk_sz))
                                 DQF_PUT(ddquot, version, dqb_itime, 0);
                 }
                 set_fs(fs);
@@ -1032,6 +1054,8 @@ int lustre_get_qids(struct file *fp, struct inode *inode, int type,
 
         ENTRY;
 
+        LASSERT(ergo(fp == NULL, inode != NULL));
+
         if (check_quota_file(fp, inode, type, LUSTRE_QUOTA_V1) == 0)
                 version = LUSTRE_QUOTA_V1;
         else if (check_quota_file(fp, inode, type, LUSTRE_QUOTA_V2) == 0)
@@ -1063,7 +1087,6 @@ int lustre_get_qids(struct file *fp, struct inode *inode, int type,
         list_for_each_entry(blk_item, &blk_list, link) {
                 loff_t ret = 0;
                 int i, dqblk_sz = lustre_disk_dqblk_sz[version];
-                char fakedquot[dqblk_sz];
 
                 memset(buf, 0, LUSTRE_DQBLKSIZE);
                 if ((ret = quota_read(fp, inode, type, blk_item->blk, buf))<0) {
@@ -1072,19 +1095,23 @@ int lustre_get_qids(struct file *fp, struct inode *inode, int type,
                         GOTO(out_free, rc = ret);
                 }
 
-                memset(fakedquot, 0, dqblk_sz);
                 for (i = 0; i < lustre_dqstrinblk[version]; i++) {
                         struct dquot_id *dqid;
                         /* skip empty entry */
-                        if (!memcmp(fakedquot, ddquot + i*dqblk_sz, dqblk_sz))
+                        if (!memcmp((char *)&emptydquot[version],
+                                    ddquot + i*dqblk_sz, dqblk_sz))
                                 continue;
 
-                        dqid = kmalloc(sizeof(*dqid), GFP_NOFS);
-                        if (!dqid) 
+                        OBD_ALLOC_GFP(dqid, sizeof(*dqid), GFP_NOFS);
+                        if (!dqid)
                                 GOTO(out_free, rc = -ENOMEM);
 
-                        dqid->di_id = DQF_GET(ddquot + i * dqblk_sz, 
+                        dqid->di_id = DQF_GET(ddquot + i * dqblk_sz,
                                               version, dqb_id);
+                        dqid->di_flag = DQF_GET(ddquot + i * dqblk_sz, version,
+                                                dqb_ihardlimit) ? QI_SET : 0;
+                        dqid->di_flag |= DQF_GET(ddquot + i * dqblk_sz, version,
+                                                 dqb_bhardlimit) ? QB_SET : 0;
                         INIT_LIST_HEAD(&dqid->di_link);
                         list_add(&dqid->di_link, list);
                 }
diff --git a/lustre/lvfs/lustre_quota_fmt.h b/lustre/lvfs/lustre_quota_fmt.h
index a9fbcfc..ab43160 100644
--- a/lustre/lvfs/lustre_quota_fmt.h
+++ b/lustre/lvfs/lustre_quota_fmt.h
@@ -62,7 +62,7 @@
 }
 
 /* for the verson 1 of lustre_disk_dqblk*/
-#define LUSTRE_INITQVERSIONS {\
+#define LUSTRE_INITQVERSIONS_V1 {\
         0,              /* USRQUOTA */\
         0               /* GRPQUOTA */\
 }
diff --git a/lustre/lvfs/lustre_quota_fmt_convert.c b/lustre/lvfs/lustre_quota_fmt_convert.c
index de85f8b..9737e3b 100644
--- a/lustre/lvfs/lustre_quota_fmt_convert.c
+++ b/lustre/lvfs/lustre_quota_fmt_convert.c
@@ -50,7 +50,9 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/quotaio_v1.h>
+#ifdef HAVE_QUOTAIO_V1_H
+# include <linux/quotaio_v1.h>
+#endif
 
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
diff --git a/lustre/lvfs/lvfs_darwin.c b/lustre/lvfs/lvfs_darwin.c
new file mode 100644
index 0000000..cec260b
--- /dev/null
+++ b/lustre/lvfs/lvfs_darwin.c
@@ -0,0 +1,80 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ */
+
+#define DEBUG_SUBSYSTEM S_FILTER
+
+#include <libcfs/libcfs.h>
+#include <obd.h>
+#include <lvfs.h>
+#include <lustre_lib.h>
+
+atomic_t obd_memory;
+int obd_memmax;
+
+/* XXX currently ctxt functions should not be used ?? */
+void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
+	       struct lvfs_ucred *cred)
+{
+	LBUG();
+}
+
+void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
+              struct lvfs_ucred *cred)
+{
+	LBUG();
+}
+
+static int __init lvfs_init(void)
+{
+	int ret = 0;
+	ENTRY;
+
+	RETURN(ret);
+}
+
+static void __exit lvfs_exit(void)
+{
+	int leaked;
+	ENTRY;
+	
+	leaked = atomic_read(&obd_memory);
+	CDEBUG(leaked ? D_ERROR : D_INFO,
+	       "obd mem max: %d leaked: %d\n", obd_memmax, leaked);
+
+	return;
+}
+
+cfs_module(lvfs, "1.0.0", lvfs_init, lvfs_exit);
diff --git a/lustre/lvfs/lvfs_linux.c b/lustre/lvfs/lvfs_linux.c
index 631d8bc..5a77267 100644
--- a/lustre/lvfs/lvfs_linux.c
+++ b/lustre/lvfs/lvfs_linux.c
@@ -148,10 +148,10 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
         */
 
         save->fs = get_fs();
-        LASSERT(atomic_read(&current->fs->pwd->d_count));
+        LASSERT(atomic_read(&cfs_fs_pwd(current->fs)->d_count));
         LASSERT(atomic_read(&new_ctx->pwd->d_count));
-        save->pwd = dget(current->fs->pwd);
-        save->pwdmnt = mntget(current->fs->pwdmnt);
+        save->pwd = dget(cfs_fs_pwd(current->fs));
+        save->pwdmnt = mntget(cfs_fs_mnt(current->fs));
         save->luc.luc_umask = current->fs->umask;
 
         LASSERT(save->pwd);
@@ -205,10 +205,10 @@ void pop_ctxt(struct lvfs_run_ctxt *saved, struct lvfs_run_ctxt *new_ctx,
                atomic_read(&current->fs->pwdmnt->mnt_count));
         */
 
-        LASSERTF(current->fs->pwd == new_ctx->pwd, "%p != %p\n",
-                 current->fs->pwd, new_ctx->pwd);
-        LASSERTF(current->fs->pwdmnt == new_ctx->pwdmnt, "%p != %p\n",
-                 current->fs->pwdmnt, new_ctx->pwdmnt);
+        LASSERTF(cfs_fs_pwd(current->fs) == new_ctx->pwd, "%p != %p\n",
+                 cfs_fs_pwd(current->fs), new_ctx->pwd);
+        LASSERTF(cfs_fs_mnt(current->fs) == new_ctx->pwdmnt, "%p != %p\n",
+                 cfs_fs_mnt(current->fs), new_ctx->pwdmnt);
 
         set_fs(saved->fs);
         ll_set_fs_pwd(current->fs, saved->pwdmnt, saved->pwd);
diff --git a/lustre/lvfs/quotafmt_test.c b/lustre/lvfs/quotafmt_test.c
index a371193..0690ca3 100644
--- a/lustre/lvfs/quotafmt_test.c
+++ b/lustre/lvfs/quotafmt_test.c
@@ -67,7 +67,7 @@ static int quotfmt_initialize(struct lustre_quota_info *lqi,
 {
         struct lustre_disk_dqheader dqhead;
         static const uint quota_magics[] = LUSTRE_INITQMAGICS;
-        static const uint quota_versions[] = LUSTRE_INITQVERSIONS;
+        static const uint quota_versions[] = LUSTRE_INITQVERSIONS_V1;
         struct file *fp;
         struct inode *parent_inode = tgt->obd_lvfs_ctxt.pwd->d_inode;
         size_t size;
diff --git a/lustre/lvfs/upcall_cache.c b/lustre/lvfs/upcall_cache.c
index 8894557..6ad44b2 100644
--- a/lustre/lvfs/upcall_cache.c
+++ b/lustre/lvfs/upcall_cache.c
@@ -112,7 +112,7 @@ static struct upcall_cache_entry *alloc_entry(__u64 key)
 static void free_entry(struct upcall_cache_entry *entry)
 {
         if (entry->ue_group_info)
-                groups_free(entry->ue_group_info);
+                put_group_info(entry->ue_group_info);
         list_del(&entry->ue_hash);
         CDEBUG(D_OTHER, "destroy cache entry %p for key "LPU64"\n",
                entry, entry->ue_key);
@@ -216,7 +216,7 @@ static int entry_set_group_info(struct upcall_cache_entry *entry, __u32 primary,
         entry->ue_primary = primary;
 
         for (i = 0; i < ginfo->nblocks; i++) {
-                int cp_count = min(NGROUPS_PER_BLOCK, (int)ngroups);
+                int cp_count = min_t(int, NGROUPS_PER_BLOCK, ngroups);
                 int off = i * NGROUPS_PER_BLOCK;
 
                 for (j = 0; j < cp_count; j++)
diff --git a/lustre/mdc/Makefile.in b/lustre/mdc/Makefile.in
index b9b9793..cdaef27 100644
--- a/lustre/mdc/Makefile.in
+++ b/lustre/mdc/Makefile.in
@@ -1,4 +1,6 @@
 MODULES := mdc
-mdc-objs := mdc_request.o mdc_reint.o lproc_mdc.o mdc_lib.o mdc_locks.o
+mdc-objs := mdc_request.o mdc_reint.o lproc_mdc.o mdc_lib.o mdc_locks.o mdc_fid.o
+
+EXTRA_DIST = $(mdc-objs:.o=.c) mdc_internal.h
 
 @INCLUDE_RULES@
diff --git a/lustre/mdc/autoMakefile.am b/lustre/mdc/autoMakefile.am
index 65be657..4ba9946 100644
--- a/lustre/mdc/autoMakefile.am
+++ b/lustre/mdc/autoMakefile.am
@@ -36,7 +36,7 @@
 
 if LIBLUSTRE
 noinst_LIBRARIES = libmdc.a
-libmdc_a_SOURCES = mdc_request.c mdc_reint.c mdc_lib.c mdc_internal.h mdc_locks.c
+libmdc_a_SOURCES = mdc_request.c mdc_reint.c mdc_lib.c mdc_internal.h mdc_locks.c mdc_fid.c
 libmdc_a_CPPFLAGS = $(LLCPPFLAGS)
 libmdc_a_CFLAGS = $(LLCFLAGS)
 endif
@@ -45,5 +45,4 @@ if MODULES
 modulefs_DATA = mdc$(KMODEXT)
 endif
 
-DIST_SOURCES = $(mdc-objs:.o=.c) mdc_internal.h
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
diff --git a/lustre/mdc/autoMakefile.in b/lustre/mdc/autoMakefile.in
index 02d31bc..a14977f 100644
--- a/lustre/mdc/autoMakefile.in
+++ b/lustre/mdc/autoMakefile.in
@@ -209,10 +209,11 @@ MAKEINFO = @MAKEINFO@
 MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
+
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -329,13 +330,11 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @LIBLUSTRE_TRUE at noinst_LIBRARIES = libmdc.a
- at LIBLUSTRE_TRUE@libmdc_a_SOURCES = mdc_request.c mdc_reint.c mdc_lib.c mdc_internal.h mdc_locks.c
+ at LIBLUSTRE_TRUE@libmdc_a_SOURCES = mdc_request.c mdc_reint.c mdc_lib.c mdc_internal.h mdc_locks.c mdc_fid.c
 @LIBLUSTRE_TRUE at libmdc_a_CPPFLAGS = $(LLCPPFLAGS)
 @LIBLUSTRE_TRUE at libmdc_a_CFLAGS = $(LLCFLAGS)
 
 @MODULES_TRUE at modulefs_DATA = mdc$(KMODEXT)
-
-DIST_SOURCES = $(mdc-objs:.o=.c) mdc_internal.h
 subdir = lustre/mdc
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -346,17 +345,19 @@ LIBRARIES = $(noinst_LIBRARIES)
 libmdc_a_AR = $(AR) cru
 libmdc_a_LIBADD =
 am__libmdc_a_SOURCES_DIST = mdc_request.c mdc_reint.c mdc_lib.c \
-	mdc_internal.h mdc_locks.c
+	mdc_internal.h mdc_locks.c mdc_fid.c
 @LIBLUSTRE_TRUE at am_libmdc_a_OBJECTS = libmdc_a-mdc_request.$(OBJEXT) \
 @LIBLUSTRE_TRUE@	libmdc_a-mdc_reint.$(OBJEXT) \
 @LIBLUSTRE_TRUE@	libmdc_a-mdc_lib.$(OBJEXT) \
- at LIBLUSTRE_TRUE@	libmdc_a-mdc_locks.$(OBJEXT)
+ at LIBLUSTRE_TRUE@	libmdc_a-mdc_locks.$(OBJEXT) \
+ at LIBLUSTRE_TRUE@	libmdc_a-mdc_fid.$(OBJEXT)
 libmdc_a_OBJECTS = $(am_libmdc_a_OBJECTS)
 
 DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
- at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/libmdc_a-mdc_lib.Po \
+ at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/libmdc_a-mdc_fid.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/libmdc_a-mdc_lib.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/libmdc_a-mdc_locks.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/libmdc_a-mdc_reint.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/libmdc_a-mdc_request.Po
@@ -364,6 +365,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libmdc_a_SOURCES_DIST)
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
@@ -396,6 +398,7 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libmdc_a-mdc_fid.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libmdc_a-mdc_lib.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libmdc_a-mdc_locks.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libmdc_a-mdc_reint.Po at am__quote@
@@ -510,6 +513,28 @@ libmdc_a-mdc_locks.obj: mdc_locks.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/libmdc_a-mdc_locks.Po' tmpdepfile='$(DEPDIR)/libmdc_a-mdc_locks.TPo' @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmdc_a_CPPFLAGS) $(CPPFLAGS) $(libmdc_a_CFLAGS) $(CFLAGS) -c -o libmdc_a-mdc_locks.obj `if test -f 'mdc_locks.c'; then $(CYGPATH_W) 'mdc_locks.c'; else $(CYGPATH_W) '$(srcdir)/mdc_locks.c'; fi`
+
+libmdc_a-mdc_fid.o: mdc_fid.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmdc_a_CPPFLAGS) $(CPPFLAGS) $(libmdc_a_CFLAGS) $(CFLAGS) -MT libmdc_a-mdc_fid.o -MD -MP -MF "$(DEPDIR)/libmdc_a-mdc_fid.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o libmdc_a-mdc_fid.o `test -f 'mdc_fid.c' || echo '$(srcdir)/'`mdc_fid.c; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libmdc_a-mdc_fid.Tpo" "$(DEPDIR)/libmdc_a-mdc_fid.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/libmdc_a-mdc_fid.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mdc_fid.c' object='libmdc_a-mdc_fid.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/libmdc_a-mdc_fid.Po' tmpdepfile='$(DEPDIR)/libmdc_a-mdc_fid.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmdc_a_CPPFLAGS) $(CPPFLAGS) $(libmdc_a_CFLAGS) $(CFLAGS) -c -o libmdc_a-mdc_fid.o `test -f 'mdc_fid.c' || echo '$(srcdir)/'`mdc_fid.c
+
+libmdc_a-mdc_fid.obj: mdc_fid.c
+ at am__fastdepCC_TRUE@	if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmdc_a_CPPFLAGS) $(CPPFLAGS) $(libmdc_a_CFLAGS) $(CFLAGS) -MT libmdc_a-mdc_fid.obj -MD -MP -MF "$(DEPDIR)/libmdc_a-mdc_fid.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o libmdc_a-mdc_fid.obj `if test -f 'mdc_fid.c'; then $(CYGPATH_W) 'mdc_fid.c'; else $(CYGPATH_W) '$(srcdir)/mdc_fid.c'; fi`; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/libmdc_a-mdc_fid.Tpo" "$(DEPDIR)/libmdc_a-mdc_fid.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/libmdc_a-mdc_fid.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='mdc_fid.c' object='libmdc_a-mdc_fid.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/libmdc_a-mdc_fid.Po' tmpdepfile='$(DEPDIR)/libmdc_a-mdc_fid.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmdc_a_CPPFLAGS) $(CPPFLAGS) $(libmdc_a_CFLAGS) $(CFLAGS) -c -o libmdc_a-mdc_fid.obj `if test -f 'mdc_fid.c'; then $(CYGPATH_W) 'mdc_fid.c'; else $(CYGPATH_W) '$(srcdir)/mdc_fid.c'; fi`
 uninstall-info-am:
 modulefsDATA_INSTALL = $(INSTALL_DATA)
 install-modulefsDATA: $(modulefs_DATA)
diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c
index accb538..46aae45 100644
--- a/lustre/mdc/lproc_mdc.c
+++ b/lustre/mdc/lproc_mdc.c
@@ -91,7 +91,8 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
         { "max_rpcs_in_flight", mdc_rd_max_rpcs_in_flight,
                                 mdc_wr_max_rpcs_in_flight, 0 },
         { "timeouts",        lprocfs_rd_timeouts,    0, 0 },
-        { "import",          lprocfs_rd_import,    0, 0 },
+        { "import",          lprocfs_rd_import,      0, 0 },
+        { "state",           lprocfs_rd_state,       0, 0 },
         { 0 }
 };
 
diff --git a/lustre/mdc/mdc_fid.c b/lustre/mdc/mdc_fid.c
new file mode 100644
index 0000000..ac3379c
--- /dev/null
+++ b/lustre/mdc/mdc_fid.c
@@ -0,0 +1,414 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/mdc/mdc_fid.c
+ *
+ * MDC fid management
+ *
+ * Author: Yury Umanets <umka at clusterfs.com>
+ */
+
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+#define DEBUG_SUBSYSTEM S_FID
+
+#ifdef __KERNEL__
+# include <libcfs/libcfs.h>
+# include <linux/module.h>
+#else /* __KERNEL__ */
+# include <liblustre.h>
+#endif
+
+#include <obd.h>
+#include <obd_class.h>
+#include <obd_support.h>
+#include "mdc_internal.h"
+
+static int seq_client_rpc(struct lu_client_seq *seq, struct lu_seq_range *input,
+                          struct lu_seq_range *output, __u32 opc,
+                          const char *opcname)
+{
+        int rc;
+        __u32 size[3] = { sizeof(struct ptlrpc_body),
+                            sizeof(__u32),
+                            sizeof(struct lu_seq_range) };
+        struct obd_export *exp = seq->lcs_exp;
+        struct ptlrpc_request *req;
+        struct lu_seq_range *out, *in;
+        __u32 *op;
+        ENTRY;
+
+        req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
+                              SEQ_QUERY, 3, size, NULL);
+        if (req == NULL)
+                RETURN(-ENOMEM);
+
+        req->rq_export = class_export_get(exp);
+        op = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(__u32));
+        *op = opc;
+
+        /* Zero out input range, this is not recovery yet. */
+        in = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1,
+                            sizeof(struct lu_seq_range));
+        if (input != NULL)
+                *in = *input;
+        else
+                range_init(in);
+
+        size[1] = sizeof(struct lu_seq_range);
+        ptlrpc_req_set_repsize(req, 2, size);
+
+        LASSERT(seq->lcs_type == LUSTRE_SEQ_METADATA);
+        req->rq_request_portal = SEQ_METADATA_PORTAL;
+
+        mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+        rc = ptlrpc_queue_wait(req);
+        mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+
+        if (rc)
+                GOTO(out_req, rc);
+
+        out = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
+                            sizeof(struct lu_seq_range));
+        *output = *out;
+
+        if (!range_is_sane(output)) {
+                CERROR("%s: Invalid range received from server: "
+                       DRANGE"\n", seq->lcs_name, PRANGE(output));
+                GOTO(out_req, rc = -EINVAL);
+        }
+
+        if (range_is_exhausted(output)) {
+                CERROR("%s: Range received from server is exhausted: "
+                       DRANGE"]\n", seq->lcs_name, PRANGE(output));
+                GOTO(out_req, rc = -EINVAL);
+        }
+        *in = *out;
+
+        CDEBUG(D_INFO, "%s: Allocated %s-sequence "DRANGE"]\n",
+               seq->lcs_name, opcname, PRANGE(output));
+
+        EXIT;
+out_req:
+        ptlrpc_req_finished(req);
+        return rc;
+}
+
+
+/* Request sequence-controller node to allocate new meta-sequence. */
+static int seq_client_alloc_meta(struct lu_client_seq *seq)
+{
+        int rc;
+        ENTRY;
+
+        rc = seq_client_rpc(seq, NULL, &seq->lcs_space,
+                            SEQ_ALLOC_META, "meta");
+        RETURN(rc);
+}
+
+/* Allocate new sequence for client. */
+static int seq_client_alloc_seq(struct lu_client_seq *seq, seqno_t *seqnr)
+{
+        int rc;
+        ENTRY;
+
+        LASSERT(range_is_sane(&seq->lcs_space));
+
+        if (range_is_exhausted(&seq->lcs_space)) {
+                rc = seq_client_alloc_meta(seq);
+                if (rc) {
+                        CERROR("%s: Can't allocate new meta-sequence, "
+                               "rc %d\n", seq->lcs_name, rc);
+                        RETURN(rc);
+                } else {
+                        CDEBUG(D_INFO, "%s: New range - "DRANGE"\n",
+                               seq->lcs_name, PRANGE(&seq->lcs_space));
+                }
+        } else {
+                rc = 0;
+        }
+
+        LASSERT(!range_is_exhausted(&seq->lcs_space));
+        *seqnr = seq->lcs_space.lsr_start;
+        seq->lcs_space.lsr_start += 1;
+
+        CDEBUG(D_INFO, "%s: Allocated sequence ["LPX64"]\n", seq->lcs_name,
+               *seqnr);
+
+        RETURN(rc);
+}
+
+/* Allocate new fid on passed client @seq and save it to @fid. */
+static int seq_client_alloc_fid(struct lu_client_seq *seq, struct lu_fid *fid)
+{
+        int rc;
+        ENTRY;
+
+        LASSERT(seq != NULL);
+        LASSERT(fid != NULL);
+
+        down(&seq->lcs_sem);
+
+        if (fid_is_zero(&seq->lcs_fid) ||
+            fid_oid(&seq->lcs_fid) >= seq->lcs_width)
+        {
+                seqno_t seqnr;
+
+                rc = seq_client_alloc_seq(seq, &seqnr);
+                if (rc) {
+                        CERROR("%s: Can't allocate new sequence, "
+                               "rc %d\n", seq->lcs_name, rc);
+                        up(&seq->lcs_sem);
+                        RETURN(rc);
+                }
+
+                CDEBUG(D_INFO, "%s: Switch to sequence "
+                       "[0x%16.16"LPF64"x]\n", seq->lcs_name, seqnr);
+
+                seq->lcs_fid.f_seq = seqnr;
+                seq->lcs_fid.f_oid = LUSTRE_FID_INIT_OID;
+                seq->lcs_fid.f_ver = 0;
+
+                /*
+                 * Inform caller that sequence switch is performed to allow it
+                 * to setup FLD for it.
+                 */
+                rc = 1;
+        } else {
+                /* Just bump last allocated fid and return to caller. */
+                seq->lcs_fid.f_oid += 1;
+                rc = 0;
+        }
+
+        *fid = seq->lcs_fid;
+        up(&seq->lcs_sem);
+
+        CDEBUG(D_INFO, "%s: Allocated FID "DFID"\n", seq->lcs_name,  PFID(fid));
+        RETURN(rc);
+}
+
+/*
+ * Finish the current sequence due to disconnect.
+ * See mdc_import_event()
+ */
+static void seq_client_flush(struct lu_client_seq *seq)
+{
+        LASSERT(seq != NULL);
+        down(&seq->lcs_sem);
+        fid_init(&seq->lcs_fid);
+        range_init(&seq->lcs_space);
+        up(&seq->lcs_sem);
+}
+
+static int seq_client_proc_init(struct lu_client_seq *seq)
+{
+        return 0;
+}
+
+static void seq_client_proc_fini(struct lu_client_seq *seq)
+{
+        return;
+}
+
+int seq_client_init(struct lu_client_seq *seq,
+                    struct obd_export *exp,
+                    enum lu_cli_type type,
+                    __u64 width,
+                    const char *prefix)
+{
+        int rc;
+        ENTRY;
+
+        LASSERT(seq != NULL);
+        LASSERT(prefix != NULL);
+
+        seq->lcs_exp = exp;
+        seq->lcs_type = type;
+        sema_init(&seq->lcs_sem, 1);
+        seq->lcs_width = width;
+
+        /* Make sure that things are clear before work is started. */
+        seq_client_flush(seq);
+
+        LASSERT(seq->lcs_exp != NULL);
+        seq->lcs_exp = class_export_get(seq->lcs_exp);
+
+        snprintf(seq->lcs_name, sizeof(seq->lcs_name),
+                 "cli-%s", prefix);
+
+        rc = seq_client_proc_init(seq);
+        if (rc)
+                seq_client_fini(seq);
+        RETURN(rc);
+}
+
+void seq_client_fini(struct lu_client_seq *seq)
+{
+        ENTRY;
+
+        seq_client_proc_fini(seq);
+        LASSERT(seq->lcs_exp != NULL);
+
+        if (seq->lcs_exp != NULL) {
+                class_export_put(seq->lcs_exp);
+                seq->lcs_exp = NULL;
+        }
+
+        EXIT;
+}
+
+/* Allocate new fid on passed client @seq and save it to @fid. */
+int mdc_fid_alloc(struct lu_client_seq *seq, struct lu_fid *fid)
+{
+        int rc;
+        ENTRY;
+        
+        rc = seq_client_alloc_fid(seq, fid);
+        if (rc > 0)
+                rc = 0;
+        RETURN(rc);
+}
+
+void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src)
+{
+        /* check that all fields are converted */
+        CLASSERT(sizeof *src ==
+                 sizeof fid_seq(src) +
+                 sizeof fid_oid(src) + sizeof fid_ver(src));
+        LASSERTF(fid_is_igif(src) || fid_ver(src) == 0, DFID"\n", PFID(src));
+        dst->f_seq = cpu_to_le64(fid_seq(src));
+        dst->f_oid = cpu_to_le32(fid_oid(src));
+        dst->f_ver = cpu_to_le32(fid_ver(src));
+}
+EXPORT_SYMBOL(fid_cpu_to_le);
+
+void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
+{
+        /* check that all fields are converted */
+        CLASSERT(sizeof *src ==
+                 sizeof fid_seq(src) +
+                 sizeof fid_oid(src) + sizeof fid_ver(src));
+        dst->f_seq = le64_to_cpu(fid_seq(src));
+        dst->f_oid = le32_to_cpu(fid_oid(src));
+        dst->f_ver = le32_to_cpu(fid_ver(src));
+        LASSERTF(fid_is_igif(dst) || fid_ver(dst) == 0, DFID"\n", PFID(dst));
+}
+EXPORT_SYMBOL(fid_le_to_cpu);
+
+void range_cpu_to_le(struct lu_seq_range *dst, const struct lu_seq_range *src)
+{
+        /* check that all fields are converted */
+        CLASSERT(sizeof(*src) ==
+                 sizeof(src->lsr_start) +
+                 sizeof(src->lsr_end) +
+                 sizeof(src->lsr_mdt) +
+                 sizeof(src->lsr_padding));
+        dst->lsr_start = cpu_to_le64(src->lsr_start);
+        dst->lsr_end = cpu_to_le64(src->lsr_end);
+}
+EXPORT_SYMBOL(range_cpu_to_le);
+
+void range_le_to_cpu(struct lu_seq_range *dst, const struct lu_seq_range *src)
+{
+        /* check that all fields are converted */
+        CLASSERT(sizeof(*src) ==
+                 sizeof(src->lsr_start) +
+                 sizeof(src->lsr_end) +
+                 sizeof(src->lsr_mdt) +
+                 sizeof(src->lsr_padding));
+
+        dst->lsr_start = le64_to_cpu(src->lsr_start);
+        dst->lsr_end = le64_to_cpu(src->lsr_end);
+}
+EXPORT_SYMBOL(range_le_to_cpu);
+
+void range_cpu_to_be(struct lu_seq_range *dst, const struct lu_seq_range *src)
+{
+        /* check that all fields are converted */
+        CLASSERT(sizeof(*src) ==
+                 sizeof(src->lsr_start) +
+                 sizeof(src->lsr_end) +
+                 sizeof(src->lsr_mdt) +
+                 sizeof(src->lsr_padding));
+
+        dst->lsr_start = cpu_to_be64(src->lsr_start);
+        dst->lsr_end = cpu_to_be64(src->lsr_end);
+}
+EXPORT_SYMBOL(range_cpu_to_be);
+
+void range_be_to_cpu(struct lu_seq_range *dst, const struct lu_seq_range *src)
+{
+        /* check that all fields are converted */
+        CLASSERT(sizeof(*src) ==
+                 sizeof(src->lsr_start) +
+                 sizeof(src->lsr_end) +
+                 sizeof(src->lsr_mdt) +
+                 sizeof(src->lsr_padding));
+
+        dst->lsr_start = be64_to_cpu(src->lsr_start);
+        dst->lsr_end = be64_to_cpu(src->lsr_end);
+}
+EXPORT_SYMBOL(range_be_to_cpu);
+
+/**     
+ * Build (DLM) resource name from fid.
+ */
+struct ldlm_res_id *
+fid_build_reg_res_name(const struct lu_fid *f, struct ldlm_res_id *name)
+{       
+        memset(name, 0, sizeof *name);
+        name->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(f);
+        name->name[LUSTRE_RES_ID_OID_OFF] = fid_oid(f);
+        if (!fid_is_igif(f))
+                name->name[LUSTRE_RES_ID_VER_OFF] = fid_ver(f);
+        return name;
+}
+EXPORT_SYMBOL(fid_build_reg_res_name);
+
+/**
+ * Return true if resource is for object identified by fid.
+ */
+int fid_res_name_eq(const struct lu_fid *f, const struct ldlm_res_id *name)
+{
+        int ret;
+        
+        ret = name->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(f) &&
+              name->name[LUSTRE_RES_ID_OID_OFF] == fid_oid(f);
+        if (!fid_is_igif(f))
+                ret = ret && name->name[LUSTRE_RES_ID_VER_OFF] == fid_ver(f);
+        return ret;
+}
+EXPORT_SYMBOL(fid_res_name_eq);
diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h
index 0497276..9104238 100644
--- a/lustre/mdc/mdc_internal.h
+++ b/lustre/mdc/mdc_internal.h
@@ -74,11 +74,23 @@ void mdc_link_pack(struct ptlrpc_request *req, int offset,
 void mdc_rename_pack(struct ptlrpc_request *req, int offset,
                      struct mdc_op_data *data,
                      const char *old, int oldlen, const char *new, int newlen);
-void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa,
+void mdc_close_pack(struct ptlrpc_request *req, int offset,
+                    struct mdc_op_data *data,
+                    struct obdo *oa,
                     __u64 valid, struct obd_client_handle *och);
 void mdc_exit_request(struct client_obd *cli);
 void mdc_enter_request(struct client_obd *cli);
 
+int seq_client_init(struct lu_client_seq *seq,
+                    struct obd_export *exp,
+                    enum lu_cli_type type,
+                    __u64 width,
+                    const char *prefix);
+
+void seq_client_fini(struct lu_client_seq *seq);
+
+int mdc_fid_alloc(struct lu_client_seq *seq, struct lu_fid *fid);
+
 struct mdc_open_data {
         struct obd_client_handle *mod_och;
         struct ptlrpc_request    *mod_open_req;
@@ -117,3 +129,13 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck,
         }
         EXIT;
 }
+
+static inline int mdc_exp_is_2_0_server(struct obd_export *exp) {
+       LASSERT(exp);
+       return !!(exp->exp_connect_flags & OBD_CONNECT_FID);
+}
+
+static inline int mdc_req_is_2_0_server(struct ptlrpc_request *req) {
+       LASSERT(req);
+        return mdc_exp_is_2_0_server(req->rq_export);
+}
diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c
index f5106bd..a7f4e83 100644
--- a/lustre/mdc/mdc_lib.c
+++ b/lustre/mdc/mdc_lib.c
@@ -39,8 +39,8 @@
 # include <fcntl.h>
 # include <liblustre.h>
 #endif
-#include <lustre/lustre_idl.h>
 #include <lustre_net.h>
+#include <lustre/lustre_idl.h>
 #include "mdc_internal.h"
 
 #ifndef __KERNEL__
@@ -50,10 +50,17 @@
 #endif
 #endif
 
-void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pg_off,
-                      __u32 size, struct ll_fid *fid)
+static void mdc_readdir_pack_18(struct ptlrpc_request *req, int offset,
+                                __u64 pg_off, __u32 size, struct ll_fid *fid)
 {
         struct mds_body *b;
+        ENTRY;
+
+        CLASSERT(sizeof(struct ll_fid)   == sizeof(struct lu_fid));
+        CLASSERT(sizeof(struct mds_body) <= sizeof(struct mdt_body));
+        CLASSERT((int)offsetof(struct mds_body, max_cookiesize) == 
+                 (int)offsetof(struct mdt_body, max_cookiesize));
+
 
         b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
         b->fsuid = current->fsuid;
@@ -63,49 +70,112 @@ void mdc_readdir_pack(struct ptlrpc_request *req, int offset, __u64 pg_off,
         b->size = pg_off;                       /* !! */
         b->suppgid = -1;
         b->nlink = size;                        /* !! */
+        EXIT;
 }
 
-static void mdc_pack_body(struct mds_body *b)
+static void mdc_readdir_pack_20(struct ptlrpc_request *req, int offset,
+                                __u64 pg_off, __u32 size, struct ll_fid *fid)
 {
-        LASSERT (b != NULL);
+        struct mdt_body *b;
+        ENTRY;
 
+        b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
         b->fsuid = current->fsuid;
         b->fsgid = current->fsgid;
         b->capability = cfs_curproc_cap_pack();
+
+        if (fid) {
+                b->fid1 = *((struct lu_fid*)fid);
+                b->valid |= OBD_MD_FLID;
+        }
+        b->size = pg_off;                       /* !! */
+        b->suppgid = -1;
+        b->nlink = size;                        /* !! */
+        b->mode = LUDA_FID | LUDA_TYPE;
+        EXIT;
 }
 
-void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
-                       __u64 valid, struct ll_fid *fid, int ea_size, int flags)
+void mdc_readdir_pack(struct ptlrpc_request *req, int offset,
+                      __u64 pg_off, __u32 size, struct ll_fid *fid)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_readdir_pack_20(req, offset, pg_off, size, fid);
+        else
+                mdc_readdir_pack_18(req, offset, pg_off, size, fid);
+}
+
+static void mdc_pack_req_body_18(struct ptlrpc_request *req, int offset,
+                                 __u64 valid, struct ll_fid *fid, int ea_size,
+                                 int flags)
 {
         struct mds_body *b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
+        ENTRY;
+        LASSERT (b != NULL);
 
         if (fid)
                 b->fid1 = *fid;
         b->valid = valid;
         b->eadatasize = ea_size;
         b->flags = flags;
-        mdc_pack_body(b);
+        b->fsuid = current->fsuid;
+        b->fsgid = current->fsgid;
+        b->capability = cfs_curproc_cap_pack();
+        EXIT;
+}
+
+static void mdc_pack_req_body_20(struct ptlrpc_request *req, int offset,
+                                 __u64 valid, struct ll_fid *fid, int ea_size,
+                                 int flags)
+{
+        struct mdt_body *b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
+        ENTRY;
+        LASSERT (b != NULL);
+
+        b->valid      = valid;
+        b->eadatasize = ea_size;
+        b->flags      = flags;
+        if (fid) {
+                b->fid1 = *((struct lu_fid*)fid);
+                b->valid |= OBD_MD_FLID;
+        }
+
+        b->fsuid = current->fsuid;
+        b->fsgid = current->fsgid;
+        b->capability = cfs_curproc_cap_pack();
+        EXIT;
+}
+
+void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
+                       __u64 valid, struct ll_fid *fid, int ea_size,
+                       int flags)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_pack_req_body_20(req, offset, valid, fid, ea_size, flags);
+        else
+                mdc_pack_req_body_18(req, offset, valid, fid, ea_size, flags);
 }
 
 /* packing of MDS records */
-void mdc_create_pack(struct ptlrpc_request *req, int offset,
-                     struct mdc_op_data *op_data, const void *data, int datalen,
-                     __u32 mode, __u32 uid, __u32 gid, cfs_cap_t cap_effective,
-                     __u64 rdev)
+static void mdc_create_pack_18(struct ptlrpc_request *req, int offset,
+                               struct mdc_op_data *op_data, const void *data,
+                               int datalen, __u32 mode, __u32 uid, __u32 gid,
+                               cfs_cap_t cap_effective, __u64 rdev)
 {
         struct mds_rec_create *rec;
         char *tmp;
+        ENTRY;
+
         rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
 
-        rec->cr_opcode = REINT_CREATE;
-        rec->cr_fsuid = uid;
-        rec->cr_fsgid = gid;
-        rec->cr_cap = cap_effective;
-        rec->cr_fid = op_data->fid1;
+        rec->cr_opcode  = REINT_CREATE;
+        rec->cr_fsuid   = uid;
+        rec->cr_fsgid   = gid;
+        rec->cr_cap     = cap_effective;
+        rec->cr_fid     = op_data->fid1;
         memset(&rec->cr_replayfid, 0, sizeof(rec->cr_replayfid));
-        rec->cr_mode = mode;
-        rec->cr_rdev = rdev;
-        rec->cr_time = op_data->mod_time;
+        rec->cr_mode    = mode;
+        rec->cr_rdev    = rdev;
+        rec->cr_time    = op_data->mod_time;
         rec->cr_suppgid = op_data->suppgids[0];
 
         tmp = lustre_msg_buf(req->rq_reqmsg, offset + 1, op_data->namelen + 1);
@@ -115,14 +185,60 @@ void mdc_create_pack(struct ptlrpc_request *req, int offset,
                 tmp = lustre_msg_buf(req->rq_reqmsg, offset + 2, datalen);
                 memcpy (tmp, data, datalen);
         }
+        EXIT;
+}
+
+static void mdc_create_pack_20(struct ptlrpc_request *req, int offset,
+                               struct mdc_op_data *op_data, const void *data,
+                               int datalen, __u32 mode, __u32 uid, __u32 gid,
+                               cfs_cap_t cap_effective, __u64 rdev)
+{
+        struct mdt_rec_create *rec;
+        char *tmp;
+        ENTRY;
+
+        rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
+
+        rec->cr_opcode   = REINT_CREATE;
+        rec->cr_fsuid    = uid;
+        rec->cr_fsgid    = gid;
+        rec->cr_cap      = cap_effective;
+        memcpy(&rec->cr_fid1, &op_data->fid1, sizeof(op_data->fid1));
+        memcpy(&rec->cr_fid2, &op_data->fid2, sizeof(op_data->fid2));
+        rec->cr_mode     = mode;
+        rec->cr_rdev     = rdev;
+        rec->cr_time     = op_data->mod_time;
+        rec->cr_suppgid1 = op_data->suppgids[0];
+
+        /* offset + 1  == capa */
+        tmp = lustre_msg_buf(req->rq_reqmsg, offset + 2, op_data->namelen + 1);
+        LOGL0(op_data->name, op_data->namelen, tmp);
+
+        if (data) {
+                tmp = lustre_msg_buf(req->rq_reqmsg, offset + 3, datalen);
+                memcpy(tmp, data, datalen);
+        }
+        EXIT;
+}
+
+void mdc_create_pack(struct ptlrpc_request *req, int offset,
+                     struct mdc_op_data *op_data, const void *data,
+                     int datalen, __u32 mode, __u32 uid, __u32 gid,
+                     cfs_cap_t cap_effective, __u64 rdev)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_create_pack_20(req, offset, op_data, data, datalen,
+                                   mode, uid, gid, cap_effective, rdev);
+        else
+                mdc_create_pack_18(req, offset, op_data, data, datalen,
+                                   mode, uid, gid, cap_effective, rdev);
 }
 
-static __u32 mds_pack_open_flags(__u32 flags)
+static __u32 mds_pack_open_flags(__u32 flags, __u32 mode)
 {
         __u32 cr_flags = (flags & (FMODE_READ | FMODE_WRITE |
-                                   MDS_OPEN_DELAY_CREATE | MDS_OPEN_HAS_EA |
-                                   MDS_OPEN_HAS_OBJS | MDS_OPEN_OWNEROVERRIDE |
-                                   MDS_OPEN_LOCK));
+                                   MDS_OPEN_DELAY_CREATE | MDS_OPEN_HAS_OBJS |
+                                   MDS_OPEN_OWNEROVERRIDE | MDS_OPEN_LOCK));
         if (flags & O_CREAT)
                 cr_flags |= MDS_OPEN_CREAT;
         if (flags & O_EXCL)
@@ -135,7 +251,7 @@ static __u32 mds_pack_open_flags(__u32 flags)
                 cr_flags |= MDS_OPEN_SYNC;
         if (flags & O_DIRECTORY)
                 cr_flags |= MDS_OPEN_DIRECTORY;
-        if (flags & O_JOIN_FILE)
+        if (mode  & M_JOIN_FILE)
                 cr_flags |= MDS_OPEN_JOIN_FILE;
 #ifdef FMODE_EXEC
         if (flags & FMODE_EXEC)
@@ -145,36 +261,62 @@ static __u32 mds_pack_open_flags(__u32 flags)
 }
 
 /* packing of MDS records */
-void mdc_join_pack(struct ptlrpc_request *req, int offset,
-                   struct mdc_op_data *op_data, __u64 head_size)
+static void mdc_join_pack_18(struct ptlrpc_request *req, int offset,
+                             struct mdc_op_data *op_data, __u64 head_size)
 {
         struct mds_rec_join *rec;
+        ENTRY;
 
         rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*rec));
         LASSERT(rec != NULL);
         rec->jr_fid = op_data->fid2;
         rec->jr_headsize = head_size;
+        EXIT;
 }
 
-void mdc_open_pack(struct ptlrpc_request *req, int offset,
-                   struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
-                   __u32 flags, const void *lmm, int lmmlen)
+static void mdc_join_pack_20(struct ptlrpc_request *req, int offset,
+                             struct mdc_op_data *op_data, __u64 head_size)
+{
+        struct mdt_rec_join *rec;
+        ENTRY;
+
+        rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*rec));
+        LASSERT(rec != NULL);
+        memcpy(&rec->jr_fid, &op_data->fid2, sizeof(op_data->fid2));
+        rec->jr_headsize = head_size;
+        EXIT;
+}
+
+void mdc_join_pack(struct ptlrpc_request *req, int offset,
+                   struct mdc_op_data *op_data, __u64 head_size)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_join_pack_20(req, offset, op_data, head_size);
+        else
+                mdc_join_pack_18(req, offset, op_data, head_size);
+}
+
+static void mdc_open_pack_18(struct ptlrpc_request *req, int offset,
+                            struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
+                             __u32 flags, const void *lmm, int lmmlen)
 {
         struct mds_rec_create *rec;
         char *tmp;
+        ENTRY;
+
         rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
 
         /* XXX do something about time, uid, gid */
-        rec->cr_opcode = REINT_OPEN;
-        rec->cr_fsuid = current->fsuid;
-        rec->cr_fsgid = current->fsgid;
-        rec->cr_cap = cfs_curproc_cap_pack();
-        rec->cr_fid = op_data->fid1;
+        rec->cr_opcode  = REINT_OPEN;
+        rec->cr_fsuid   = current->fsuid;
+        rec->cr_fsgid   = current->fsgid;
+        rec->cr_cap     = cfs_curproc_cap_pack();
+        rec->cr_fid     = op_data->fid1;
         memset(&rec->cr_replayfid, 0, sizeof(rec->cr_replayfid));
-        rec->cr_mode = mode;
-        rec->cr_flags = mds_pack_open_flags(flags);
-        rec->cr_rdev = rdev;
-        rec->cr_time = op_data->mod_time;
+        rec->cr_mode    = mode;
+        rec->cr_flags   = mds_pack_open_flags(flags, mode);
+        rec->cr_rdev    = rdev;
+        rec->cr_time    = op_data->mod_time;
         rec->cr_suppgid = op_data->suppgids[0];
 
         if (op_data->name) {
@@ -192,6 +334,66 @@ void mdc_open_pack(struct ptlrpc_request *req, int offset,
                 tmp = lustre_msg_buf(req->rq_reqmsg, offset + 2, lmmlen);
                 memcpy (tmp, lmm, lmmlen);
         }
+        EXIT;
+}
+
+static void mdc_open_pack_20(struct ptlrpc_request *req, int offset,
+                            struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
+                             __u32 flags, const void *lmm, int lmmlen)
+{
+        struct mdt_rec_create *rec;
+        char *tmp;
+        ENTRY;
+
+        rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
+
+        /* XXX do something about time, uid, gid */
+        rec->cr_opcode = REINT_OPEN;
+        rec->cr_fsuid  = current->fsuid;
+        rec->cr_fsgid  = current->fsgid;
+        rec->cr_cap    = cfs_curproc_cap_pack();
+        memcpy(&rec->cr_fid1, &op_data->fid1, sizeof(op_data->fid1));
+        memcpy(&rec->cr_fid2, &op_data->fid2, sizeof(op_data->fid2));
+        rec->cr_mode   = mode;
+        rec->cr_flags  = mds_pack_open_flags(flags, mode);
+        rec->cr_rdev   = rdev;
+        rec->cr_time   = op_data->mod_time;
+        rec->cr_suppgid1 = op_data->suppgids[0];
+        rec->cr_suppgid2 = op_data->suppgids[1];
+
+        if (op_data->name) {
+                tmp = lustre_msg_buf(req->rq_reqmsg, offset + 3,
+                                     op_data->namelen + 1);
+                CDEBUG(D_INFO, "offset=%d, src=%p(%d):%s, dst=%p\n",
+                        offset, op_data->name, op_data->namelen,
+                        op_data->name, tmp);
+                LASSERT(tmp);
+                LOGL0(op_data->name, op_data->namelen, tmp);
+        }
+
+        if (lmm) {
+                rec->cr_flags |= MDS_OPEN_HAS_EA;
+#ifndef __KERNEL__
+                /*XXX a hack for liblustre to set EA (LL_IOC_LOV_SETSTRIPE) */
+                memcpy(&rec->cr_fid2, &op_data->fid2, sizeof(op_data->fid2));
+#endif
+                tmp = lustre_msg_buf(req->rq_reqmsg, offset + 4, lmmlen);
+                memcpy(tmp, lmm, lmmlen);
+        }
+        EXIT;
+}
+
+void mdc_open_pack(struct ptlrpc_request *req, int offset,
+                   struct mdc_op_data *op_data, __u32 mode, __u64 rdev,
+                   __u32 flags, const void *lmm, int lmmlen)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_open_pack_20(req, offset, op_data, mode, rdev,
+                                 flags, lmm, lmmlen);
+        else
+                mdc_open_pack_18(req, offset, op_data, mode, rdev,
+                                 flags, lmm, lmmlen);
+
 }
 
 static inline __u64 attr_pack(unsigned int ia_valid) {
@@ -233,12 +435,14 @@ static inline __u64 attr_pack(unsigned int ia_valid) {
         return sa_valid;
 }
 
-void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
-                      struct mdc_op_data *data, struct iattr *iattr, void *ea,
-                      int ealen, void *ea2, int ea2len)
+void mdc_setattr_pack_18(struct ptlrpc_request *req, int offset,
+                         struct mdc_op_data *data, struct iattr *iattr, void *ea,
+                         int ealen, void *ea2, int ea2len)
 {
         struct mds_rec_setattr *rec = lustre_msg_buf(req->rq_reqmsg, offset,
                                                      sizeof(*rec));
+        ENTRY;
+
         rec->sa_opcode = REINT_SETATTR;
         rec->sa_fsuid = current->fsuid;
         rec->sa_fsgid = current->fsgid;
@@ -263,22 +467,86 @@ void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
                         rec->sa_suppgid = data->suppgids[0];
         }
 
-        if (ealen == 0)
+        if (ealen == 0) {
+                EXIT;
                 return;
+        }
 
         memcpy(lustre_msg_buf(req->rq_reqmsg, offset + 1, ealen), ea, ealen);
 
-        if (ea2len == 0)
+        if (ea2len == 0) {
+                EXIT;
                 return;
-
+        }
         memcpy(lustre_msg_buf(req->rq_reqmsg, offset + 2, ea2len), ea2, ea2len);
+
+        EXIT;
 }
 
-void mdc_unlink_pack(struct ptlrpc_request *req, int offset,
-                     struct mdc_op_data *data)
+static void mdc_setattr_pack_20(struct ptlrpc_request *req, int offset,
+                                struct mdc_op_data *data, struct iattr *iattr,
+                                void *ea, int ealen, void *ea2, int ea2len)
+{
+        struct mdt_rec_setattr *rec = lustre_msg_buf(req->rq_reqmsg, offset,
+                                                     sizeof(*rec));
+        ENTRY;
+
+        rec->sa_opcode  = REINT_SETATTR;
+        rec->sa_fsuid   = current->fsuid;
+        rec->sa_fsgid   = current->fsgid;
+        rec->sa_cap     = cfs_curproc_cap_pack();
+        memcpy(&rec->sa_fid, &data->fid1, sizeof(data->fid1));
+        rec->sa_suppgid = -1;
+
+        if (iattr) {
+                rec->sa_valid   = attr_pack(iattr->ia_valid);
+                rec->sa_mode    = iattr->ia_mode;
+                rec->sa_uid     = iattr->ia_uid;
+                rec->sa_gid     = iattr->ia_gid;
+                rec->sa_size    = iattr->ia_size;
+//              rec->sa_blocks  = iattr->ia_blocks;
+                rec->sa_atime   = LTIME_S(iattr->ia_atime);
+                rec->sa_mtime   = LTIME_S(iattr->ia_mtime);
+                rec->sa_ctime   = LTIME_S(iattr->ia_ctime);
+                rec->sa_attr_flags = 
+                        ((struct ll_iattr_struct *)iattr)->ia_attr_flags;
+                if ((iattr->ia_valid & ATTR_GID) && in_group_p(iattr->ia_gid))
+                        rec->sa_suppgid = iattr->ia_gid;
+                else
+                        rec->sa_suppgid = data->suppgids[0];
+        }
+        if (ealen == 0) {
+                EXIT;
+                return;
+        }
+        memcpy(lustre_msg_buf(req->rq_reqmsg, offset + 3, ealen), ea, ealen);
+
+        if (ea2len == 0) {
+                EXIT;
+                return;
+        }
+        memcpy(lustre_msg_buf(req->rq_reqmsg, offset + 4, ea2len), ea2, ea2len);
+        EXIT;
+}
+
+void mdc_setattr_pack(struct ptlrpc_request *req, int offset,
+                      struct mdc_op_data *data, struct iattr *iattr,
+                      void *ea, int ealen, void *ea2, int ea2len)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_setattr_pack_20(req, offset, data, iattr,
+                                    ea, ealen, ea2, ea2len);
+        else
+                mdc_setattr_pack_18(req, offset, data, iattr,
+                                    ea, ealen, ea2, ea2len);
+}
+
+static void mdc_unlink_pack_18(struct ptlrpc_request *req, int offset,
+                               struct mdc_op_data *data)
 {
         struct mds_rec_unlink *rec;
         char *tmp;
+        ENTRY;
 
         rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
         LASSERT (rec != NULL);
@@ -296,13 +564,51 @@ void mdc_unlink_pack(struct ptlrpc_request *req, int offset,
         tmp = lustre_msg_buf(req->rq_reqmsg, offset + 1, data->namelen + 1);
         LASSERT (tmp != NULL);
         LOGL0(data->name, data->namelen, tmp);
+        EXIT;
 }
 
-void mdc_link_pack(struct ptlrpc_request *req, int offset,
-                   struct mdc_op_data *data)
+static void mdc_unlink_pack_20(struct ptlrpc_request *req, int offset,
+                               struct mdc_op_data *data)
+{
+        struct mdt_rec_unlink *rec;
+        char *tmp;
+        ENTRY;
+
+        rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
+        LASSERT (rec != NULL);
+
+        rec->ul_opcode  = REINT_UNLINK;
+        rec->ul_fsuid   = current->fsuid;
+        rec->ul_fsgid   = current->fsgid;
+        rec->ul_cap     = cfs_curproc_cap_pack();
+        rec->ul_mode    = data->create_mode;
+        rec->ul_suppgid1= data->suppgids[0];
+        memcpy(&rec->ul_fid1, &data->fid1, sizeof(data->fid1));
+        memcpy(&rec->ul_fid2, &data->fid2, sizeof(data->fid2));
+        rec->ul_time    = data->mod_time;
+
+        /* NULL capa is skipped. */
+
+        tmp = lustre_msg_buf(req->rq_reqmsg, offset + 2, data->namelen + 1);
+        LASSERT (tmp != NULL);
+        LOGL0(data->name, data->namelen, tmp);
+        EXIT;
+}
+
+void mdc_unlink_pack(struct ptlrpc_request *req, int offset,
+                     struct mdc_op_data *data)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_unlink_pack_20(req, offset, data);
+        else
+                mdc_unlink_pack_18(req, offset, data);
+}
+static void mdc_link_pack_18(struct ptlrpc_request *req, int offset,
+                             struct mdc_op_data *data)
 {
         struct mds_rec_link *rec;
         char *tmp;
+        ENTRY;
 
         rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
 
@@ -318,14 +624,53 @@ void mdc_link_pack(struct ptlrpc_request *req, int offset,
 
         tmp = lustre_msg_buf(req->rq_reqmsg, offset + 1, data->namelen + 1);
         LOGL0(data->name, data->namelen, tmp);
+        EXIT;
 }
 
-void mdc_rename_pack(struct ptlrpc_request *req, int offset,
-                     struct mdc_op_data *data,
-                     const char *old, int oldlen, const char *new, int newlen)
+static void mdc_link_pack_20(struct ptlrpc_request *req, int offset,
+                             struct mdc_op_data *data)
+{
+        struct mdt_rec_link *rec;
+        char *tmp;
+        ENTRY;
+
+        rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
+
+        rec->lk_opcode   = REINT_LINK;
+        rec->lk_fsuid    = current->fsuid;
+        rec->lk_fsgid    = current->fsgid;
+        rec->lk_cap      = cfs_curproc_cap_pack();
+        rec->lk_suppgid1 = data->suppgids[0];
+        rec->lk_suppgid2 = data->suppgids[1];
+        memcpy(&rec->lk_fid1, &data->fid1, sizeof(data->fid1));
+        memcpy(&rec->lk_fid2, &data->fid2, sizeof(data->fid2));
+        rec->lk_time     = data->mod_time;
+
+
+        /* capa @ offset + 1; */
+        /* capa @ offset + 2; */
+
+        tmp = lustre_msg_buf(req->rq_reqmsg, offset + 3, data->namelen + 1);
+        LOGL0(data->name, data->namelen, tmp);
+        EXIT;
+}
+
+void mdc_link_pack(struct ptlrpc_request *req, int offset,
+                   struct mdc_op_data *data)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_link_pack_20(req, offset, data);
+        else
+                mdc_link_pack_18(req, offset, data);
+}
+
+static void mdc_rename_pack_18(struct ptlrpc_request *req, int offset,
+                               struct mdc_op_data *data, const char *old, 
+                               int oldlen, const char *new, int newlen)
 {
         struct mds_rec_rename *rec;
         char *tmp;
+        ENTRY;
 
         rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
 
@@ -347,12 +692,61 @@ void mdc_rename_pack(struct ptlrpc_request *req, int offset,
                 tmp = lustre_msg_buf(req->rq_reqmsg, offset + 2, newlen + 1);
                 LOGL0(new, newlen, tmp);
         }
+        EXIT;
+}
+
+static void mdc_rename_pack_20(struct ptlrpc_request *req, int offset,
+                               struct mdc_op_data *data, const char *old,
+                               int oldlen, const char *new, int newlen)
+{
+        struct mdt_rec_rename *rec;
+        char *tmp;
+        ENTRY;
+
+        rec = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*rec));
+
+        /* XXX do something about time, uid, gid */
+        rec->rn_opcode   = REINT_RENAME;
+        rec->rn_fsuid    = current->fsuid;
+        rec->rn_fsgid    = current->fsgid;
+        rec->rn_cap      = cfs_curproc_cap_pack();
+        rec->rn_suppgid1 = data->suppgids[0];
+        rec->rn_suppgid2 = data->suppgids[1];
+        memcpy(&rec->rn_fid1, &data->fid1, sizeof(data->fid1));
+        memcpy(&rec->rn_fid2, &data->fid2, sizeof(data->fid2));
+        rec->rn_time     = data->mod_time;
+        rec->rn_mode     = data->create_mode;
+
+
+        /* skip capa @ offset + 1 */
+        /* skip capa @ offset + 2 */
+
+        tmp = lustre_msg_buf(req->rq_reqmsg, offset + 3, oldlen + 1);
+        LOGL0(old, oldlen, tmp);
+
+        if (new) {
+                tmp = lustre_msg_buf(req->rq_reqmsg, offset + 4, newlen + 1);
+                LOGL0(new, newlen, tmp);
+        }
+        EXIT;
+}
+
+void mdc_rename_pack(struct ptlrpc_request *req, int offset,
+                     struct mdc_op_data *data, const char *old,
+                     int oldlen, const char *new, int newlen)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_rename_pack_20(req, offset, data, old, oldlen, new, newlen);
+        else
+                mdc_rename_pack_18(req, offset, data, old, oldlen, new, newlen);
 }
 
-void mdc_getattr_pack(struct ptlrpc_request *req, int offset, __u64 valid,
-                      int flags, struct mdc_op_data *data)
+static void mdc_getattr_pack_18(struct ptlrpc_request *req, int offset,
+                                __u64 valid, int flags, struct mdc_op_data *data)
 {
         struct mds_body *b;
+        ENTRY;
+
         b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
 
         b->fsuid = current->fsuid;
@@ -376,16 +770,56 @@ void mdc_getattr_pack(struct ptlrpc_request *req, int offset, __u64 valid,
                 memcpy(tmp, data->name, data->namelen);
                 data->name = tmp;
         }
+        EXIT;
 }
 
-void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa,
-                    __u64 valid, struct obd_client_handle *och)
+static void mdc_getattr_pack_20(struct ptlrpc_request *req, int offset,
+                                __u64 valid, int flags, struct mdc_op_data *data)
+{
+        struct mdt_body *b;
+        ENTRY;
+
+        b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof (*b));
+
+        b->fsuid = current->fsuid;
+        b->fsgid = current->fsgid;
+        b->capability = cfs_curproc_cap_pack();
+        b->valid = valid;
+        b->flags = flags | MDS_BFLAG_EXT_FLAGS;
+        b->suppgid = data->suppgids[0];
+
+        memcpy(&b->fid1, &data->fid1, sizeof(data->fid1));
+        memcpy(&b->fid2, &data->fid2, sizeof(data->fid2));
+        b->valid |= OBD_MD_FLID;
+        if (data->name) {
+                char *tmp;
+                tmp = lustre_msg_buf(req->rq_reqmsg, offset + 2,
+                                     data->namelen + 1);
+                LASSERT(tmp);
+                LOGL0(data->name, data->namelen, tmp);
+        }
+        EXIT;
+}
+
+void mdc_getattr_pack(struct ptlrpc_request *req, int offset,
+                      __u64 valid, int flags, struct mdc_op_data *data)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_getattr_pack_20(req, offset, valid, flags, data);
+        else
+                mdc_getattr_pack_18(req, offset, valid, flags, data);
+}
+static void mdc_close_pack_18(struct ptlrpc_request *req, int offset,
+                              struct mdc_op_data *data,
+                              struct obdo *oa, __u64 valid,
+                              struct obd_client_handle *och)
 {
         struct mds_body *body;
+        ENTRY;
 
         body = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*body));
 
-        mdc_pack_fid(&body->fid1, oa->o_id, 0, oa->o_mode);
+        body->fid1 = data->fid1;
         memcpy(&body->handle, &och->och_fh, sizeof(body->handle));
         if (oa->o_valid & OBD_MD_FLATIME) {
                 body->atime = oa->o_atime;
@@ -411,9 +845,73 @@ void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa,
                 body->flags = oa->o_flags;
                 body->valid |= OBD_MD_FLFLAGS;
         }
+        EXIT;
 }
 
-struct mdc_cache_waiter {       
+static void mdc_close_pack_20(struct ptlrpc_request *req, int offset,
+                              struct mdc_op_data *data,
+                              struct obdo *oa, __u64 valid,
+                              struct obd_client_handle *och)
+{
+        struct mdt_epoch *epoch;
+        struct mdt_rec_setattr *rec;
+        ENTRY;
+
+        epoch = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*epoch));
+        rec = lustre_msg_buf(req->rq_reqmsg, offset + 1, sizeof(*rec));
+
+        rec->sa_opcode  = REINT_SETATTR;
+        rec->sa_fsuid   = current->fsuid;
+        rec->sa_fsgid   = current->fsgid;
+        rec->sa_cap     = cfs_curproc_cap_pack();
+        rec->sa_suppgid = -1;
+
+        memcpy(&rec->sa_fid, &data->fid1, sizeof(data->fid1));
+
+        if (oa->o_valid & OBD_MD_FLATIME) {
+                rec->sa_atime = oa->o_atime;
+                rec->sa_valid |= MDS_ATTR_ATIME;
+        }
+        if (oa->o_valid & OBD_MD_FLMTIME) {
+                rec->sa_mtime = oa->o_mtime;
+                rec->sa_valid |= MDS_ATTR_MTIME;
+        }
+        if (oa->o_valid & OBD_MD_FLCTIME) {
+                rec->sa_ctime = oa->o_ctime;
+                rec->sa_valid |= MDS_ATTR_CTIME;
+        }
+        if (oa->o_valid & OBD_MD_FLSIZE) {
+                rec->sa_size = oa->o_size;
+                rec->sa_valid |= MDS_ATTR_SIZE;
+        }
+        if (oa->o_valid & OBD_MD_FLBLOCKS) {
+                rec->sa_blocks = oa->o_blocks;
+                rec->sa_valid |= MDS_ATTR_BLOCKS;
+        }
+        if (oa->o_valid & OBD_MD_FLFLAGS) {
+                rec->sa_attr_flags = oa->o_flags;
+                rec->sa_valid |= MDS_ATTR_ATTR_FLAG;
+        }
+
+        epoch->handle = och->och_fh;
+        epoch->ioepoch = 0;
+        epoch->flags = 0;
+
+        EXIT;
+}
+
+
+void mdc_close_pack(struct ptlrpc_request *req, int offset,
+                    struct mdc_op_data *data,
+                    struct obdo *oa, __u64 valid,
+                    struct obd_client_handle *och)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_close_pack_20(req, offset, data, oa, valid, och);
+        else
+                mdc_close_pack_18(req, offset, data, oa, valid, och);
+}
+struct mdc_cache_waiter {
         struct list_head        mcw_entry;
         wait_queue_head_t       mcw_waitq;
 };
diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c
index 4fa21eb..492eeea 100644
--- a/lustre/mdc/mdc_locks.c
+++ b/lustre/mdc/mdc_locks.c
@@ -128,12 +128,10 @@ EXPORT_SYMBOL(mdc_set_lock_data);
 int mdc_change_cbdata(struct obd_export *exp, struct ll_fid *fid, 
                       ldlm_iterator_t it, void *data)
 {
-        struct ldlm_res_id res_id = { .name = {0} };
+        struct ldlm_res_id res_id;
         ENTRY;
 
-        res_id.name[0] = fid->id;
-        res_id.name[1] = fid->generation;
-
+        fid_build_reg_res_name((struct lu_fid*)fid, &res_id);
         ldlm_resource_iterate(class_exp2obd(exp)->obd_namespace, &res_id,
                               it, data);
 
@@ -182,16 +180,22 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
         int old_len, new_size, old_size;
         struct lustre_msg *old_msg = req->rq_reqmsg;
         struct lustre_msg *new_msg;
+        int offset;
+
+        if (mdc_req_is_2_0_server(req))
+                offset = 4;
+        else
+                offset = 2;
 
-        old_len = lustre_msg_buflen(old_msg, DLM_INTENT_REC_OFF + 2);
+        old_len = lustre_msg_buflen(old_msg, DLM_INTENT_REC_OFF + offset);
         old_size = lustre_packed_msg_size(old_msg);
-        lustre_msg_set_buflen(old_msg, DLM_INTENT_REC_OFF + 2,
+        lustre_msg_set_buflen(old_msg, DLM_INTENT_REC_OFF + offset,
                               body->eadatasize);
         new_size = lustre_packed_msg_size(old_msg);
 
         OBD_ALLOC(new_msg, new_size);
         if (new_msg != NULL) {
-                DEBUG_REQ(D_INFO, req, "replace reqmsg for larger EA %u\n",
+                DEBUG_REQ(D_INFO, req, "replace reqmsg for larger EA %u",
                           body->eadatasize);
                 memcpy(new_msg, old_msg, old_size);
 
@@ -202,7 +206,8 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
 
                 OBD_FREE(old_msg, old_size);
         } else {
-                lustre_msg_set_buflen(old_msg, DLM_INTENT_REC_OFF + 2, old_len);
+                lustre_msg_set_buflen(old_msg,
+                                      DLM_INTENT_REC_OFF + offset, old_len);
                 body->valid &= ~OBD_MD_FLEASIZE;
                 body->eadatasize = 0;
         }
@@ -211,12 +216,12 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
 static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp,
                                                    struct lookup_intent *it,
                                                    struct mdc_op_data *data,
-                                                   void *lmm, unsigned lmmsize)
+                                                   void *lmm, __u32 lmmsize)
 {
         struct ptlrpc_request *req;
         struct ldlm_intent *lit;
         struct obd_device *obddev = class_exp2obd(exp);
-        __u32 size[7] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+        __u32 size[9] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                         [DLM_LOCKREQ_OFF]     = sizeof(struct ldlm_request),
                         [DLM_INTENT_IT_OFF]   = sizeof(*lit),
                         [DLM_INTENT_REC_OFF]  = sizeof(struct mds_rec_create),
@@ -230,27 +235,40 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp,
                          * default-sized LOV EA for open replay. */
                         [DLM_INTENT_REC_OFF+2]= max(lmmsize,
                                          obddev->u.cli.cl_default_mds_easize) };
-        __u32 repsize[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+        __u32 repsize[7] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                            [DLM_LOCKREPLY_OFF]   = sizeof(struct ldlm_reply),
-                           [DLM_REPLY_REC_OFF]   = sizeof(struct mds_body),
+                           [DLM_REPLY_REC_OFF]   = sizeof(struct mdt_body),
                            [DLM_REPLY_REC_OFF+1] = obddev->u.cli.
                                                         cl_max_mds_easize,
                            [DLM_REPLY_REC_OFF+2] = LUSTRE_POSIX_ACL_MAX_SIZE };
         CFS_LIST_HEAD(cancels);
-        int do_join = (it->it_flags & O_JOIN_FILE) && data->data;
+        int do_join = (it->it_create_mode & M_JOIN_FILE) && data->data;
         int count = 0;
+        int bufcount = 6;
+        int repbufcount = 5;
         int mode;
         int rc;
+        ENTRY;
 
-        it->it_create_mode |= S_IFREG;
-
-        rc = lustre_msg_size(class_exp2cliimp(exp)->imp_msg_magic, 6, size);
+        it->it_create_mode = (it->it_create_mode & ~S_IFMT) | S_IFREG;
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[DLM_INTENT_REC_OFF] = sizeof(struct mdt_rec_create);
+                size[DLM_INTENT_REC_OFF+4] = size[DLM_INTENT_REC_OFF+2];
+                size[DLM_INTENT_REC_OFF+3] = size[DLM_INTENT_REC_OFF+1];
+                size[DLM_INTENT_REC_OFF+2] = 0; /* capa */
+                size[DLM_INTENT_REC_OFF+1] = 0; /* capa */
+                bufcount = 8;
+                repsize[DLM_REPLY_REC_OFF+3]=sizeof(struct lustre_capa);
+                repsize[DLM_REPLY_REC_OFF+4]=sizeof(struct lustre_capa);
+                repbufcount = 7;
+        }
+        rc = lustre_msg_size(class_exp2cliimp(exp)->imp_msg_magic,
+                             bufcount, size);
         if (rc & (rc - 1))
-                size[DLM_INTENT_REC_OFF + 2] =
-                         min(size[DLM_INTENT_REC_OFF + 2] + round_up(rc) - rc,
-                                     obddev->u.cli.cl_max_mds_easize);
+                size[bufcount - 1] = min(size[bufcount - 1] + round_up(rc) - rc,
+                                         (__u32)obddev->u.cli.cl_max_mds_easize);
 
-                /* If inode is known, cancel conflicting OPEN locks. */
+        /* If inode is known, cancel conflicting OPEN locks. */
         if (data->fid2.id) {
                 if (it->it_flags & (FMODE_WRITE|MDS_OPEN_TRUNC))
                         mode = LCK_CW;
@@ -273,15 +291,20 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp,
                                          MDS_INODELOCK_UPDATE);
         if (do_join) {
                 __u64 head_size = (*(__u64 *)data->data);
-                        /* join is like an unlink of the tail */
-                size[DLM_INTENT_REC_OFF + 3] = sizeof(struct mds_rec_join);
-                req = ldlm_prep_enqueue_req(exp, 7, size, &cancels, count);
+                /* join is like an unlink of the tail */
+                if (mdc_exp_is_2_0_server(exp)) {
+                        size[DLM_INTENT_REC_OFF+5]=sizeof(struct mdt_rec_join);
+                } else {
+                        size[DLM_INTENT_REC_OFF+3]=sizeof(struct mds_rec_join);
+                }
+                bufcount++;
+
+                req = ldlm_prep_enqueue_req(exp, bufcount, size,&cancels,count);
                 if (req)
-                        mdc_join_pack(req, DLM_INTENT_REC_OFF + 3, data, 
-                                      head_size);
+                        mdc_join_pack(req, bufcount - 1, data, head_size);
         } else {
-                req = ldlm_prep_enqueue_req(exp, 6, size, &cancels, count);
-                it->it_flags &= ~O_JOIN_FILE;
+                req = ldlm_prep_enqueue_req(exp, bufcount, size,&cancels,count);
+                it->it_create_mode &= ~M_JOIN_FILE;
         }
 
         if (req) {
@@ -299,9 +322,9 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp,
                               it->it_create_mode, 0, it->it_flags,
                               lmm, lmmsize);
 
-                ptlrpc_req_set_repsize(req, 5, repsize);
+                ptlrpc_req_set_repsize(req, repbufcount, repsize);
         }
-        return req;
+        RETURN(req);
 }
 
 static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp,
@@ -314,15 +337,18 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp,
         __u32 size[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                         [DLM_LOCKREQ_OFF]     = sizeof(struct ldlm_request),
                         [DLM_INTENT_IT_OFF]   = sizeof(*lit),
-                        [DLM_INTENT_REC_OFF]  = sizeof(struct mds_rec_unlink),
+                        [DLM_INTENT_REC_OFF]  = mdc_exp_is_2_0_server(exp) ?
+                                                sizeof(struct mdt_rec_unlink) :
+                                                sizeof(struct mds_rec_unlink),
                         [DLM_INTENT_REC_OFF+1]= data->namelen + 1 };
         __u32 repsize[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                            [DLM_LOCKREPLY_OFF]   = sizeof(struct ldlm_reply),
-                           [DLM_REPLY_REC_OFF]   = sizeof(struct mds_body),
+                           [DLM_REPLY_REC_OFF]   = sizeof(struct mdt_body),
                            [DLM_REPLY_REC_OFF+1] = obddev->u.cli.
                                                         cl_max_mds_easize,
                            [DLM_REPLY_REC_OFF+2] = obddev->u.cli.
                                                         cl_max_mds_cookiesize };
+        ENTRY;
 
         req = ldlm_prep_enqueue_req(exp, 5, size, NULL, 0);
         if (req) {
@@ -336,7 +362,7 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp,
 
                 ptlrpc_req_set_repsize(req, 5, repsize);
         }
-        return req;
+        RETURN(req);
 }
 
 static struct ptlrpc_request *mdc_intent_lookup_pack(struct obd_export *exp,
@@ -346,21 +372,30 @@ static struct ptlrpc_request *mdc_intent_lookup_pack(struct obd_export *exp,
         struct ptlrpc_request *req;
         struct ldlm_intent *lit;
         struct obd_device *obddev = class_exp2obd(exp);
-        __u32 size[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+        __u32 size[6] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                         [DLM_LOCKREQ_OFF]     = sizeof(struct ldlm_request),
                         [DLM_INTENT_IT_OFF]   = sizeof(*lit),
-                        [DLM_INTENT_REC_OFF]  = sizeof(struct mds_body),
-                        [DLM_INTENT_REC_OFF+1]= data->namelen + 1 };
-        __u32 repsize[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                        [DLM_INTENT_REC_OFF]  = sizeof(struct mdt_body),
+                        [DLM_INTENT_REC_OFF+1]= data->namelen + 1,
+                        [DLM_INTENT_REC_OFF+2]= 0 };
+        __u32 repsize[6] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                            [DLM_LOCKREPLY_OFF]   = sizeof(struct ldlm_reply),
-                           [DLM_REPLY_REC_OFF]   = sizeof(struct mds_body),
+                           [DLM_REPLY_REC_OFF]   = sizeof(struct mdt_body),
                            [DLM_REPLY_REC_OFF+1] = obddev->u.cli.
                                                         cl_max_mds_easize,
-                           [DLM_REPLY_REC_OFF+2] = LUSTRE_POSIX_ACL_MAX_SIZE };
+                           [DLM_REPLY_REC_OFF+2] = LUSTRE_POSIX_ACL_MAX_SIZE,
+                           [DLM_REPLY_REC_OFF+3] = 0 };
         obd_valid valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE | OBD_MD_FLACL |
                           OBD_MD_FLMODEASIZE | OBD_MD_FLDIREA;
+        int bufcount = 5;
+        ENTRY;
 
-                req = ldlm_prep_enqueue_req(exp, 5, size, NULL, 0);
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[DLM_INTENT_REC_OFF+1] = 0; /* capa */
+                size[DLM_INTENT_REC_OFF+2] = data->namelen + 1;
+                bufcount = 6;
+        }
+        req = ldlm_prep_enqueue_req(exp, bufcount, size, NULL, 0);
         if (req) {
                 /* pack the intent */
                 lit = lustre_msg_buf(req->rq_reqmsg, DLM_INTENT_IT_OFF,
@@ -370,9 +405,9 @@ static struct ptlrpc_request *mdc_intent_lookup_pack(struct obd_export *exp,
                 /* pack the intended request */
                 mdc_getattr_pack(req, DLM_INTENT_REC_OFF, valid, it->it_flags,
                                  data);
-                ptlrpc_req_set_repsize(req, 5, repsize);
+                ptlrpc_req_set_repsize(req, bufcount, repsize);
         }
-        return req;
+        RETURN(req);
 }
 
 static struct ptlrpc_request *mdc_intent_readdir_pack(struct obd_export *exp)
@@ -380,13 +415,15 @@ static struct ptlrpc_request *mdc_intent_readdir_pack(struct obd_export *exp)
         struct ptlrpc_request *req;
         __u32 size[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
                         [DLM_LOCKREQ_OFF]     = sizeof(struct ldlm_request) };
-        __u32 repsize[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
-                           [DLM_LOCKREPLY_OFF]   = sizeof(struct ldlm_reply) };
+        __u32 repsize[3] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                           [DLM_LOCKREPLY_OFF]   = sizeof(struct ldlm_reply),
+                           [DLM_REPLY_REC_OFF] = sizeof(struct ost_lvb) };
+        ENTRY;
 
         req = ldlm_prep_enqueue_req(exp, 2, size, NULL, 0);
         if (req)
-                ptlrpc_req_set_repsize(req, 2, repsize);
-        return req;
+                ptlrpc_req_set_repsize(req, 3, repsize);
+        RETURN(req);
 }
 
 static int mdc_finish_enqueue(struct obd_export *exp,
@@ -429,13 +466,14 @@ static int mdc_finish_enqueue(struct obd_export *exp,
 
         lockrep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
                                  sizeof(*lockrep));
-        LASSERT(lockrep != NULL);                 /* checked by ldlm_cli_enqueue() */
+        LASSERT(lockrep != NULL);  /* checked by ldlm_cli_enqueue() */
         /* swabbed by ldlm_cli_enqueue() */
         LASSERT(lustre_rep_swabbed(req, DLM_LOCKREPLY_OFF));
 
         it->d.lustre.it_disposition = (int)lockrep->lock_policy_res1;
         it->d.lustre.it_status = (int)lockrep->lock_policy_res2;
         it->d.lustre.it_lock_mode = einfo->ei_mode;
+        it->d.lustre.it_lock_handle = lockh->cookie;
         it->d.lustre.it_data = req;
 
         if (it->d.lustre.it_status < 0 && req->rq_replay)
@@ -492,9 +530,14 @@ static int mdc_finish_enqueue(struct obd_export *exp,
                          * large enough request buffer above we need to
                          * reallocate it here to hold the actual LOV EA. */
                         if (it->it_op & IT_OPEN) {
-                                int offset = DLM_INTENT_REC_OFF + 2;
+                                int offset = DLM_INTENT_REC_OFF;
                                 void *lmm;
 
+                                if (mdc_req_is_2_0_server(req))
+                                        offset += 4;
+                                else
+                                        offset += 2;
+
                                 if (lustre_msg_buflen(req->rq_reqmsg, offset) <
                                     body->eadatasize)
                                         mdc_realloc_openmsg(req, body);
@@ -519,20 +562,29 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
 {
         struct ptlrpc_request *req;
         struct obd_device *obddev = class_exp2obd(exp);
-        struct ldlm_res_id res_id =
-                { .name = {data->fid1.id, data->fid1.generation} };
+        struct ldlm_res_id res_id;
         ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_LOOKUP } };
         int flags = extra_lock_flags | LDLM_FL_HAS_INTENT;
         int rc;
         ENTRY;
 
+        fid_build_reg_res_name((void *)&data->fid1, &res_id);
         LASSERTF(einfo->ei_type == LDLM_IBITS,"lock type %d\n", einfo->ei_type);
         if (it->it_op & (IT_UNLINK | IT_GETATTR | IT_READDIR))
                 policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
 
         if (it->it_op & IT_OPEN) {
+                if ((it->it_op & IT_CREAT) && mdc_exp_is_2_0_server(exp)) {
+                        struct client_obd *cli = &obddev->u.cli;
+                        data->fid3 = data->fid2;
+                        rc = mdc_fid_alloc(cli->cl_seq, (void *)&data->fid2);
+                        if (rc) {
+                                CERROR("fid allocation result: %d\n", rc);
+                                RETURN(rc);
+                        }
+                }
                 req = mdc_intent_open_pack(exp, it, data, lmm, lmmsize);
-                if (it->it_flags & O_JOIN_FILE) {
+                if (it->it_create_mode & M_JOIN_FILE) {
                         policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
                 }
         } else if (it->it_op & IT_UNLINK) {
@@ -576,11 +628,13 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
                 /* We could just return 1 immediately, but since we should only
                  * be called in revalidate_it if we already have a lock, let's
                  * verify that. */
-        struct ldlm_res_id res_id = {.name ={fid->id, fid->generation}};
+        struct ldlm_res_id res_id;
         struct lustre_handle lockh;
         ldlm_policy_data_t policy;
         ldlm_mode_t mode;
+        ENTRY;
 
+        fid_build_reg_res_name((struct lu_fid*)fid, &res_id);
         /* As not all attributes are kept under update lock, e.g. 
            owner/group/acls are under lookup lock, we need both 
            ibits for GETATTR. */
@@ -596,7 +650,7 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
                 it->d.lustre.it_lock_mode = mode;
         }
 
-        return !!mode;
+        RETURN(!!mode);
 }
 EXPORT_SYMBOL(mdc_revalidate_lock);
 
@@ -635,10 +689,15 @@ static int mdc_finish_intent_lock(struct obd_export *exp,
 
         /* If we were revalidating a fid/name pair, mark the intent in
          * case we fail and get called again from lookup */
-        if (data->fid2.id && (it->it_op != IT_GETATTR)) {
+
+        if (data->fid2.id && (it->it_op != IT_GETATTR) &&
+           ( !mdc_exp_is_2_0_server(exp) ||
+             (mdc_exp_is_2_0_server(exp) && (it->it_create_mode & M_CHECK_STALE)))) {
                 it_set_disposition(it, DISP_ENQ_COMPLETE);
+
                 /* Also: did we find the same inode? */
-                if (memcmp(&data->fid2, &mds_body->fid1, sizeof(data->fid2))) 
+                if (memcmp(&data->fid2, &mds_body->fid1, sizeof(data->fid2)) &&
+                    memcmp(&data->fid3, &mds_body->fid1, sizeof(data->fid3)))
                         RETURN(-ESTALE);
         }
 
@@ -738,8 +797,11 @@ int mdc_intent_lock(struct obd_export *exp, struct mdc_op_data *op_data,
 
         LASSERT(it);
 
-        CDEBUG(D_DLMTRACE,"name: %.*s in inode "LPU64", intent: %s flags %#o\n",
-               op_data->namelen, op_data->name, op_data->fid1.id,
+        CDEBUG(D_DLMTRACE,"name: %.*s("DFID") in inode ("DFID"), "
+               "intent: %s flags %#o\n",
+               op_data->namelen, op_data->name,
+               PFID(((void *)&op_data->fid2)),
+               PFID(((void *)&op_data->fid1)),
                ldlm_it2str(it->it_op), it->it_flags);
 
         lockh.cookie = 0;
@@ -769,7 +831,6 @@ int mdc_intent_lock(struct obd_export *exp, struct mdc_op_data *op_data,
                                  lmm, lmmsize, extra_lock_flags);
                 if (rc < 0)
                         RETURN(rc);
-                memcpy(&it->d.lustre.it_lock_handle, &lockh, sizeof(lockh));
         } else if (!op_data->fid2.id) {
                 /* DISP_ENQ_COMPLETE set means there is extra reference on
                  * request referenced from this intent, saved for subsequent
@@ -818,8 +879,6 @@ static int mdc_intent_getattr_async_interpret(struct ptlrpc_request *req,
         if (rc)
                 GOTO(out, rc);
 
-        memcpy(&it->d.lustre.it_lock_handle, lockh, sizeof(*lockh));
-
         rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh);
         GOTO(out, rc);
 out:
@@ -837,10 +896,7 @@ int mdc_intent_getattr_async(struct obd_export *exp,
         struct lookup_intent    *it = &minfo->mi_it;
         struct ptlrpc_request   *req;
         struct obd_device       *obddev = class_exp2obd(exp);
-        struct ldlm_res_id       res_id = {
-                                        .name = {op_data->fid1.id,
-                                                 op_data->fid1.generation}
-                                 };
+        struct ldlm_res_id res_id;
         ldlm_policy_data_t       policy = {
                                         .l_inodebits = { MDS_INODELOCK_LOOKUP }
                                  };
@@ -852,6 +908,7 @@ int mdc_intent_getattr_async(struct obd_export *exp,
                op_data->namelen, op_data->name, op_data->fid1.id,
                ldlm_it2str(it->it_op), it->it_flags);
 
+        fid_build_reg_res_name((void *)&op_data->fid1, &res_id);
         req = mdc_intent_lookup_pack(exp, it, op_data);
         if (!req)
                 RETURN(-ENOMEM);
diff --git a/lustre/mdc/mdc_reint.c b/lustre/mdc/mdc_reint.c
index a51d03e..8eadea5 100644
--- a/lustre/mdc/mdc_reint.c
+++ b/lustre/mdc/mdc_reint.c
@@ -82,12 +82,15 @@ int mdc_resource_get_unused(struct obd_export *exp, struct ll_fid *fid,
                             __u64 bits)
 {
         struct ldlm_namespace *ns = exp->exp_obd->obd_namespace;
-        struct ldlm_res_id res_id = { .name = {fid->id, fid->generation} };
-        struct ldlm_resource *res = ldlm_resource_get(ns, NULL, res_id, 0, 0);
+        struct ldlm_res_id res_id;
+        struct ldlm_resource *res;
         ldlm_policy_data_t policy = {{0}};
         int count;
         ENTRY;
 
+        fid_build_reg_res_name((struct lu_fid*)fid, &res_id);
+        res = ldlm_resource_get(ns, NULL, res_id, 0, 0);
+
         if (res == NULL)
                 RETURN(0);
 
@@ -119,22 +122,39 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *op_data,
 {
         CFS_LIST_HEAD(cancels);
         struct ptlrpc_request *req;
-        struct mds_rec_setattr *rec;
         struct mdc_rpc_lock *rpc_lock;
         struct obd_device *obd = exp->exp_obd;
-        __u32 size[5] = { sizeof(struct ptlrpc_body),
-                          sizeof(*rec), ealen, ea2len,
-                          sizeof(struct ldlm_request) };
-        int count, bufcount = 2, rc;
+        __u32 size[7] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                        [REQ_REC_OFF] = sizeof(struct mds_rec_setattr),
+                        [REQ_REC_OFF + 1] = ealen,
+                        [REQ_REC_OFF + 2] = ea2len,
+                        [REQ_REC_OFF + 3] = sizeof(struct ldlm_request) };
+        __u32 replysize[6] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                             [REPLY_REC_OFF] = sizeof(struct mdt_body),
+                             [REPLY_REC_OFF+1] = obd->u.cli.cl_max_mds_easize,
+                             [REPLY_REC_OFF+2] = LUSTRE_POSIX_ACL_MAX_SIZE,
+                             [REPLY_REC_OFF+3] = sizeof(struct lustre_capa),
+                             [REPLY_REC_OFF+4] = sizeof(struct lustre_capa)};
+
+        int count, bufcount = 2, rc, replybufcount = 2;
+        int offset = REQ_REC_OFF + 3;
         __u64 bits;
         ENTRY;
 
         LASSERT(iattr != NULL);
 
-        if (ealen > 0) {
-                bufcount++;
-                if (ea2len > 0)
-                        bufcount++;
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[REQ_REC_OFF] = sizeof(struct mdt_rec_setattr);
+                size[REQ_REC_OFF + 1] = 0; /* capa */
+                size[REQ_REC_OFF + 2] = 0; //sizeof (struct mdt_epoch);
+                size[REQ_REC_OFF + 3] = ealen;
+                size[REQ_REC_OFF + 4] = ea2len;
+                size[REQ_REC_OFF + 5] = sizeof(struct ldlm_request);
+                offset = REQ_REC_OFF + 5;
+                bufcount = 6;
+                replybufcount = 6;
+        } else {
+                bufcount = 4;
         }
 
         bits = MDS_INODELOCK_UPDATE;
@@ -143,9 +163,9 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *op_data,
         count = mdc_resource_get_unused(exp, &op_data->fid1,
                                         &cancels, LCK_EX, bits);
         if (exp_connect_cancelset(exp))
-                bufcount = 5;
+                bufcount ++ ;
         req = mdc_prep_elc_req(exp, bufcount, size,
-                               REQ_REC_OFF + 3, &cancels, count);
+                               offset, &cancels, count);
         if (req == NULL)
                 RETURN(-ENOMEM);
 
@@ -163,8 +183,7 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *op_data,
         mdc_setattr_pack(req, REQ_REC_OFF, op_data, iattr,
                          ea, ealen, ea2, ea2len);
 
-        size[REPLY_REC_OFF] = sizeof(struct mds_body);
-        ptlrpc_req_set_repsize(req, 2, size);
+        ptlrpc_req_set_repsize(req, replybufcount, replysize);
 
         rc = mdc_reint(req, rpc_lock, LUSTRE_IMP_FULL);
         *request = req;
@@ -183,12 +202,21 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
         struct obd_device *obd = exp->exp_obd;
         struct ptlrpc_request *req;
         int level, bufcount = 3, rc;
-        __u32 size[5] = { sizeof(struct ptlrpc_body),
-                          sizeof(struct mds_rec_create),
-                          op_data->namelen + 1, 0, sizeof(struct ldlm_request) };
+        __u32 size[6] = { sizeof(struct ptlrpc_body),
+                        sizeof(struct mds_rec_create),
+                        op_data->namelen + 1, 0, sizeof(struct ldlm_request) };
+        int offset = REQ_REC_OFF + 3;
         int count;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[REQ_REC_OFF] = sizeof(struct mdt_rec_create);
+                size[REQ_REC_OFF + 1] = 0; /* capa */
+                size[REQ_REC_OFF + 2] = op_data->namelen + 1;
+                size[REQ_REC_OFF + 4] = sizeof(struct ldlm_request);
+                bufcount++;
+                offset ++;
+        }
         if (data && datalen) {
                 size[bufcount] = datalen;
                 bufcount++;
@@ -196,10 +224,25 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
 
         count = mdc_resource_get_unused(exp, &op_data->fid1, &cancels,
                                         LCK_EX, MDS_INODELOCK_UPDATE);
-        if (exp_connect_cancelset(exp))
-                bufcount = 5;
+        if (exp_connect_cancelset(exp)) {
+                if (mdc_exp_is_2_0_server(exp)) {
+                        bufcount = 6;
+                } else {
+                        bufcount = 5;
+                }
+        }
+
+        if (mdc_exp_is_2_0_server(exp)) {
+                struct client_obd *cli = &obd->u.cli;
+                rc = mdc_fid_alloc(cli->cl_seq, (void *)&op_data->fid2);
+                if (rc) {
+                        CERROR("fid allocation result: %d\n", rc);
+                        RETURN(rc);
+                }
+        }
+
         req = mdc_prep_elc_req(exp, bufcount, size,
-                               REQ_REC_OFF + 3, &cancels, count);
+                               offset, &cancels, count);
         if (req == NULL)
                 RETURN(-ENOMEM);
 
@@ -208,8 +251,9 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
         mdc_create_pack(req, REQ_REC_OFF, op_data, data, datalen, mode, uid,
                         gid, cap_effective, rdev);
 
-        size[REPLY_REC_OFF] = sizeof(struct mds_body);
-        ptlrpc_req_set_repsize(req, 2, size);
+        size[REPLY_REC_OFF] = sizeof(struct mdt_body);
+        size[REPLY_REC_OFF+1] = sizeof(struct ost_lvb);
+        ptlrpc_req_set_repsize(req, 3, size);
 
         level = LUSTRE_IMP_FULL;
  resend:
@@ -233,12 +277,23 @@ int mdc_unlink(struct obd_export *exp, struct mdc_op_data *op_data,
         CFS_LIST_HEAD(cancels);
         struct obd_device *obd = class_exp2obd(exp);
         struct ptlrpc_request *req = *request;
-        __u32 size[4] = { sizeof(struct ptlrpc_body),
-                        sizeof(struct mds_rec_unlink),
-                        op_data->namelen + 1, sizeof(struct ldlm_request) };
+        __u32 size[6] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                        [REQ_REC_OFF] = sizeof(struct mds_rec_unlink),
+                        [REQ_REC_OFF + 1] = op_data->namelen + 1,
+                        [REQ_REC_OFF + 2] = sizeof(struct ldlm_request) };
         int count, rc, bufcount = 3;
+        int offset = REQ_REC_OFF + 2;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[REQ_REC_OFF] = sizeof(struct mdt_rec_unlink);
+                size[REQ_REC_OFF + 1] = 0 /* capa */;
+                size[REQ_REC_OFF + 2] = op_data->namelen + 1;
+                size[REQ_REC_OFF + 3] = sizeof(struct ldlm_request);
+                bufcount ++;
+                offset ++;
+        }
+
         LASSERT(req == NULL);
         count = mdc_resource_get_unused(exp, &op_data->fid1, &cancels,
                                         LCK_EX, MDS_INODELOCK_UPDATE);
@@ -246,17 +301,20 @@ int mdc_unlink(struct obd_export *exp, struct mdc_op_data *op_data,
                 count += mdc_resource_get_unused(exp, &op_data->fid3, &cancels,
                                                  LCK_EX, MDS_INODELOCK_FULL);
         if (exp_connect_cancelset(exp))
-                bufcount = 4;
+                bufcount ++;
+
         req = mdc_prep_elc_req(exp, bufcount, size,
-                               REQ_REC_OFF + 2, &cancels, count);
+                               offset, &cancels, count);
         if (req == NULL)
                 RETURN(-ENOMEM);
         *request = req;
 
-        size[REPLY_REC_OFF] = sizeof(struct mds_body);
+        size[REPLY_REC_OFF] = sizeof(struct mdt_body);
         size[REPLY_REC_OFF + 1] = obd->u.cli.cl_max_mds_easize;
         size[REPLY_REC_OFF + 2] = obd->u.cli.cl_max_mds_cookiesize;
-        ptlrpc_req_set_repsize(req, 4, size);
+        size[REPLY_REC_OFF + 3] = sizeof(struct lustre_capa);
+        size[REPLY_REC_OFF + 4] = sizeof(struct lustre_capa);
+        ptlrpc_req_set_repsize(req, 6, size);
 
         mdc_unlink_pack(req, REQ_REC_OFF, op_data);
 
@@ -272,26 +330,39 @@ int mdc_link(struct obd_export *exp, struct mdc_op_data *op_data,
         CFS_LIST_HEAD(cancels);
         struct obd_device *obd = exp->exp_obd;
         struct ptlrpc_request *req;
-        __u32 size[4] = { sizeof(struct ptlrpc_body),
-                          sizeof(struct mds_rec_link),
-                          op_data->namelen + 1, sizeof(struct ldlm_request) };
+        __u32 size[6] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                        [REQ_REC_OFF] = sizeof(struct mds_rec_link),
+                        [REQ_REC_OFF + 1] = op_data->namelen + 1,
+                        [REQ_REC_OFF + 2] = sizeof(struct ldlm_request)};
         int count, rc, bufcount = 3;
+        int offset = REQ_REC_OFF + 2;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[REQ_REC_OFF] = sizeof(struct mdt_rec_link);
+                size[REQ_REC_OFF + 1] = 0; /* capa */
+                size[REQ_REC_OFF + 2] = 0; /* capa */
+                size[REQ_REC_OFF + 3] = op_data->namelen + 1;
+                size[REQ_REC_OFF + 4] = sizeof(struct ldlm_request);
+                bufcount = 5;
+                offset += 2;
+        }
+
         count = mdc_resource_get_unused(exp, &op_data->fid1, &cancels,
                                         LCK_EX, MDS_INODELOCK_UPDATE);
         count += mdc_resource_get_unused(exp, &op_data->fid2, &cancels,
                                          LCK_EX, MDS_INODELOCK_UPDATE);
         if (exp_connect_cancelset(exp))
-                bufcount = 4;
+                bufcount++;
+
         req = mdc_prep_elc_req(exp, bufcount, size,
-                               REQ_REC_OFF + 2, &cancels, count);
+                               offset, &cancels, count);
         if (req == NULL)
                 RETURN(-ENOMEM);
 
         mdc_link_pack(req, REQ_REC_OFF, op_data);
 
-        size[REPLY_REC_OFF] = sizeof(struct mds_body);
+        size[REPLY_REC_OFF] = sizeof(struct mdt_body);
         ptlrpc_req_set_repsize(req, 2, size);
 
         rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL);
@@ -309,12 +380,26 @@ int mdc_rename(struct obd_export *exp, struct mdc_op_data *op_data,
         CFS_LIST_HEAD(cancels);
         struct obd_device *obd = exp->exp_obd;
         struct ptlrpc_request *req;
-        __u32 size[5] = { sizeof(struct ptlrpc_body),
-                          sizeof(struct mds_rec_rename),
-                          oldlen + 1, newlen + 1, sizeof(struct ldlm_request) };
+        __u32 size[7] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                        [REQ_REC_OFF] = sizeof(struct mds_rec_rename),
+                        [REQ_REC_OFF + 1] = oldlen + 1,
+                        [REQ_REC_OFF + 2] = newlen + 1,
+                        [REQ_REC_OFF + 3] = sizeof(struct ldlm_request) };
         int count, rc, bufcount = 4;
+        int offset = REQ_REC_OFF + 3;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[REQ_REC_OFF] = sizeof(struct mdt_rec_rename);
+                size[REQ_REC_OFF + 1] = 0; /* capa */
+                size[REQ_REC_OFF + 2] = 0; /* capa */
+                size[REQ_REC_OFF + 3] = oldlen + 1;
+                size[REQ_REC_OFF + 4] = newlen + 1;
+                size[REQ_REC_OFF + 5] = sizeof(struct ldlm_request);
+                bufcount = 6;
+                offset += 2;
+        }
+
         count = mdc_resource_get_unused(exp, &op_data->fid1, &cancels,
                                         LCK_EX, MDS_INODELOCK_UPDATE);
         count += mdc_resource_get_unused(exp, &op_data->fid2, &cancels,
@@ -326,15 +411,16 @@ int mdc_rename(struct obd_export *exp, struct mdc_op_data *op_data,
                 count += mdc_resource_get_unused(exp, &op_data->fid4, &cancels,
                                                  LCK_EX, MDS_INODELOCK_FULL);
         if (exp_connect_cancelset(exp))
-                bufcount = 5;
+                bufcount ++;
+
         req = mdc_prep_elc_req(exp, bufcount, size,
-                               REQ_REC_OFF + 3, &cancels, count);
+                               offset, &cancels, count);
         if (req == NULL)
                 RETURN(-ENOMEM);
 
         mdc_rename_pack(req, REQ_REC_OFF, op_data, old, oldlen, new, newlen);
 
-        size[REPLY_REC_OFF] = sizeof(struct mds_body);
+        size[REPLY_REC_OFF] = sizeof(struct mdt_body);
         size[REPLY_REC_OFF + 1] = obd->u.cli.cl_max_mds_easize;
         size[REPLY_REC_OFF + 2] = obd->u.cli.cl_max_mds_cookiesize;
         ptlrpc_req_set_repsize(req, 4, size);
diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c
index 9cbf3fb..6a3701e 100644
--- a/lustre/mdc/mdc_request.c
+++ b/lustre/mdc/mdc_request.c
@@ -66,22 +66,25 @@ static int mdc_cleanup(struct obd_device *obd);
 extern int mds_queue_req(struct ptlrpc_request *);
 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
-static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid,
+static int send_getstatus(struct obd_export *exp, struct ll_fid *rootfid,
                           int level, int msg_flags)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+        __u32 size[3] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body),
+                          sizeof(struct lustre_capa) };
         int rc;
         ENTRY;
 
-        req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS, 2, size,
+        req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, MDS_GETSTATUS, 2, size,
                               NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         req->rq_send_state = level;
-        ptlrpc_req_set_repsize(req, 2, size);
+        ptlrpc_req_set_repsize(req, 3, size);
 
         mdc_pack_req_body(req, REQ_REC_OFF, 0, NULL, 0, 0);
         lustre_msg_add_flags(req->rq_reqmsg, msg_flags);
@@ -110,11 +113,10 @@ static int send_getstatus(struct obd_import *imp, struct ll_fid *rootfid,
         return rc;
 }
 
-/* This should be mdc_get_info("rootfid") */
+/* This should be mdc_get_info("ROOT") */
 int mdc_getstatus(struct obd_export *exp, struct ll_fid *rootfid)
 {
-        return send_getstatus(class_exp2cliimp(exp), rootfid, LUSTRE_IMP_FULL,
-                              0);
+        return send_getstatus(exp, rootfid, LUSTRE_IMP_FULL, 0);
 }
 
 static
@@ -124,12 +126,12 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
         struct obd_device *obddev = class_exp2obd(exp);
         struct mds_body *body;
         void *eadata;
-        __u32 size[4] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+        __u32 size[6] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body) };
         int bufcount = 2, rc;
         ENTRY;
 
         /* request message already built */
-
         if (ea_size != 0) {
                 size[bufcount++] = ea_size;
                 CDEBUG(D_INODE, "reserved %u bytes for MD/symlink in packet\n",
@@ -140,6 +142,10 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
                 CDEBUG(D_INODE, "reserved %u bytes for ACL\n", acl_size);
         }
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                bufcount = 6;
+        }
+
         ptlrpc_req_set_repsize(req, bufcount, size);
 
         mdc_enter_request(&obddev->u.cli);
@@ -176,7 +182,8 @@ int mdc_getattr(struct obd_export *exp, struct ll_fid *fid,
                 struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(struct mds_body) };
+        __u32 size[2] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body) };
         int acl_size = 0, rc;
         ENTRY;
 
@@ -188,6 +195,7 @@ int mdc_getattr(struct obd_export *exp, struct ll_fid *fid,
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, ea_size,
                           MDS_BFLAG_EXT_FLAGS/*request "new" flags(bug 9486)*/);
 
@@ -210,21 +218,32 @@ int mdc_getattr_name(struct obd_export *exp, struct ll_fid *fid,
                      unsigned int ea_size, struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
-        struct mds_body *body;
-        __u32 size[3] = { sizeof(struct ptlrpc_body), sizeof(*body), namelen};
+        __u32 size[4] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                          [REQ_REC_OFF] = sizeof(struct mdt_body),
+                          [REQ_REC_OFF + 1] = namelen };
         int rc;
+        int bufcount = 3;
+        int nameoffset = REQ_REC_OFF + 1;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                size[REQ_REC_OFF + 1] = 0;
+                size[REQ_REC_OFF + 2] = namelen;
+                bufcount ++;
+                nameoffset ++;
+        }
+
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
-                              MDS_GETATTR_NAME, 3, size, NULL);
+                              MDS_GETATTR_NAME, bufcount, size, NULL);
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, ea_size,
                           MDS_BFLAG_EXT_FLAGS/*request "new" flags(bug 9486)*/);
 
         LASSERT(strnlen(filename, namelen) == namelen - 1);
-        memcpy(lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, namelen),
+        memcpy(lustre_msg_buf(req->rq_reqmsg, nameoffset, namelen),
                filename, namelen);
 
         rc = mdc_getattr_common(exp, ea_size, 0, req);
@@ -245,12 +264,24 @@ int mdc_xattr_common(struct obd_export *exp, struct ll_fid *fid,
 {
         struct obd_device *obddev = class_exp2obd(exp);
         struct ptlrpc_request *req;
-        __u32 size[4] = { sizeof(struct ptlrpc_body), sizeof(struct mds_body) };
-        // int size[3] = {sizeof(struct mds_body)}, bufcnt = 1;
-        int rc, xattr_namelen = 0, bufcnt = 2, offset;
+        __u32 size[5] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
+                        [REQ_REC_OFF] = sizeof(struct mdt_body),
+                        [REQ_REC_OFF + 1] = 0, /* capa */
+                        [REQ_REC_OFF + 2] = 0, /* name */
+                        [REQ_REC_OFF + 3] = 0 };
+        int rc, xattr_namelen = 0, bufcnt = 2, offset = REQ_REC_OFF + 1;
         void *tmp;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                bufcnt++;
+                offset++;
+                if (opcode == MDS_SETXATTR) {
+                        size[REQ_REC_OFF] = sizeof (struct mdt_rec_setxattr);
+                        opcode = MDS_REINT;
+                }
+        }
+
         if (xattr_name) {
                 xattr_namelen = strlen(xattr_name) + 1;
                 size[bufcnt++] = xattr_namelen;
@@ -265,10 +296,26 @@ int mdc_xattr_common(struct obd_export *exp, struct ll_fid *fid,
         if (!req)
                 GOTO(out, rc = -ENOMEM);
 
-        /* request data */
-        mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, output_size, flags);
-
-        offset = REQ_REC_OFF + 1;
+        req->rq_export = class_export_get(exp);
+
+        if (opcode == MDS_REINT && mdc_exp_is_2_0_server(exp)) {
+                struct mdt_rec_setxattr *rec;
+                rec = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
+                                     sizeof(struct mdt_rec_setxattr));
+                rec->sx_opcode = REINT_SETXATTR;
+                rec->sx_fsuid  = current->fsuid;
+                rec->sx_fsgid  = current->fsgid;
+                rec->sx_cap    = cfs_curproc_cap_pack();
+                rec->sx_suppgid1 = -1;
+                rec->sx_suppgid2 = -1;
+                rec->sx_fid    = *((struct lu_fid*)fid);
+                rec->sx_valid  = valid;
+                rec->sx_size   = output_size;
+                rec->sx_flags  = flags;
+        } else {
+                /* request data */
+                mdc_pack_req_body(req, REQ_REC_OFF, valid, fid, output_size, flags);
+        }
 
         if (xattr_name) {
                 tmp = lustre_msg_buf(req->rq_reqmsg, offset++, xattr_namelen);
@@ -279,28 +326,32 @@ int mdc_xattr_common(struct obd_export *exp, struct ll_fid *fid,
                 memcpy(tmp, input, input_size);
         }
 
-        /* reply buffers */
-        if (opcode == MDS_GETXATTR) {
-                size[REPLY_REC_OFF] = sizeof(struct mds_body);
+        size[REPLY_REC_OFF] = sizeof(struct mdt_body);
+        if (mdc_exp_is_2_0_server(exp)) {
                 bufcnt = 2;
         } else {
-                bufcnt = 1;
+                /* reply buffers */
+                if (opcode == MDS_GETXATTR) {
+                        bufcnt = 2;
+                } else {
+                        bufcnt = 1;
+                }
+
         }
 
         /* we do this even output_size is 0, because server is doing that */
         size[bufcnt++] = output_size;
-
         ptlrpc_req_set_repsize(req, bufcnt, size);
 
         /* make rpc */
-        if (opcode == MDS_SETXATTR)
+        if (opcode == MDS_SETXATTR || opcode == MDS_REINT)
                 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
         else
                 mdc_enter_request(&obddev->u.cli);
 
         rc = ptlrpc_queue_wait(req);
 
-        if (opcode == MDS_SETXATTR)
+        if (opcode == MDS_SETXATTR || opcode == MDS_REINT)
                 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
         else
                 mdc_exit_request(&obddev->u.cli);
@@ -345,9 +396,9 @@ int mdc_getxattr(struct obd_export *exp, struct ll_fid *fid,
                                 input, input_size, output_size, 0, request);
 }
 
-/* This should be called with both the request and the reply still packed. */
-void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
-                                int repoff)
+/* For the fid-less server */
+static void mdc_store_inode_generation_18(struct ptlrpc_request *req,
+                                          int reqoff, int repoff)
 {
         struct mds_rec_create *rec = lustre_msg_buf(req->rq_reqmsg, reqoff,
                                                     sizeof(*rec));
@@ -368,6 +419,41 @@ void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
                   rec->cr_replayfid.generation, rec->cr_replayfid.id);
 }
 
+static void mdc_store_inode_generation_20(struct ptlrpc_request *req,
+                                          int reqoff, int repoff)
+{
+        struct mdt_rec_create *rec = lustre_msg_buf(req->rq_reqmsg, reqoff,
+                                                    sizeof(*rec));
+        struct mdt_body *body = lustre_msg_buf(req->rq_repmsg, repoff,
+                                               sizeof(*body));
+
+        LASSERT (rec != NULL);
+        LASSERT (body != NULL);
+
+        rec->cr_fid2 = body->fid1;
+        rec->cr_ioepoch = body->ioepoch;
+        rec->cr_old_handle.cookie = body->handle.cookie;
+
+        if (!fid_is_sane(&body->fid1)) {
+                DEBUG_REQ(D_ERROR, req, "saving replay request with"
+                          "insane fid");
+                LBUG();
+        }
+
+        DEBUG_REQ(D_INODE, req, "storing generation %u for ino "LPU64,
+                  rec->cr_fid1.f_oid, rec->cr_fid2.f_seq);
+}
+
+/* This should be called with both the request and the reply still packed. */
+void mdc_store_inode_generation(struct ptlrpc_request *req, int reqoff,
+                                int repoff)
+{
+        if (mdc_req_is_2_0_server(req))
+                mdc_store_inode_generation_20(req, reqoff, repoff);
+        else
+                mdc_store_inode_generation_18(req, reqoff, repoff);
+}
+
 #ifdef CONFIG_FS_POSIX_ACL
 static
 int mdc_unpack_acl(struct obd_export *exp, struct ptlrpc_request *req,
@@ -416,6 +502,7 @@ int mdc_req2lustre_md(struct ptlrpc_request *req, int offset,
                       struct lustre_md *md)
 {
         int rc = 0;
+        int iop = mdc_req_is_2_0_server(req);
         ENTRY;
 
         LASSERT(md);
@@ -459,17 +546,19 @@ int mdc_req2lustre_md(struct ptlrpc_request *req, int offset,
                 }
                 rc = 0;
 
-                offset++;
-        }
-
-        if (md->body->valid & OBD_MD_FLDIREA) {
+                if (!iop)
+                        offset++;
+        } else if (md->body->valid & OBD_MD_FLDIREA) {
                 if(!S_ISDIR(md->body->mode)) {
                         CERROR("OBD_MD_FLDIREA set, should be a directory, but "
                                "is not\n");
                         GOTO(err_out, rc = -EPROTO);
                 }
-                offset++;
+                if (!iop)
+                        offset++;
         }
+        if (iop)
+                offset++;
 
         /* for ACL, it's possible that FLACL is set but aclsize is zero.
          * only when aclsize != 0 there's an actual segment for ACL in
@@ -509,13 +598,10 @@ static void mdc_commit_open(struct ptlrpc_request *req)
         if (mod == NULL)
                 return;
 
-        if (mod->mod_close_req != NULL)
-                mod->mod_close_req->rq_cb_data = NULL;
-
         if (mod->mod_och != NULL)
                 mod->mod_och->och_mod = NULL;
 
-        OBD_FREE(mod, sizeof(*mod));
+        OBD_FREE_PTR(mod);
         req->rq_cb_data = NULL;
 }
 
@@ -538,7 +624,7 @@ static void mdc_replay_open(struct ptlrpc_request *req)
                 EXIT;
                 return;
         }
-        DEBUG_REQ(D_ERROR, req, "mdc open data found");
+        DEBUG_REQ(D_HA, req, "mdc open data found");
 
         och = mod->mod_och;
         if (och != NULL) {
@@ -547,28 +633,99 @@ static void mdc_replay_open(struct ptlrpc_request *req)
                 file_fh = &och->och_fh;
                 CDEBUG(D_RPCTRACE, "updating handle from "LPX64" to "LPX64"\n",
                        file_fh->cookie, body->handle.cookie);
-                memcpy(&old, file_fh, sizeof(old));
-                memcpy(file_fh, &body->handle, sizeof(*file_fh));
+                old = *file_fh;
+                *file_fh = body->handle;
         }
 
         close_req = mod->mod_close_req;
+
         if (close_req != NULL) {
-                struct mds_body *close_body;
                 LASSERT(lustre_msg_get_opc(close_req->rq_reqmsg) == MDS_CLOSE);
-                close_body = lustre_msg_buf(close_req->rq_reqmsg, REQ_REC_OFF,
-                                            sizeof(*close_body));
-                if (och != NULL)
-                        LASSERT(!memcmp(&old, &close_body->handle, sizeof old));
-                DEBUG_REQ(D_RPCTRACE, close_req, "updating close with new fh");
-                memcpy(&close_body->handle, &body->handle,
-                       sizeof(close_body->handle));
+                if (mdc_req_is_2_0_server(close_req)) {
+                        struct mdt_epoch *epoch = NULL;
+
+                        epoch = lustre_msg_buf(close_req->rq_reqmsg,
+                                               REQ_REC_OFF, sizeof(*epoch));
+                        LASSERT(epoch);
+                        if (och != NULL)
+                                LASSERT(!memcmp(&old, &epoch->handle,
+                                        sizeof(old)));
+                        DEBUG_REQ(D_RPCTRACE, close_req,
+                                  "updating close with new fh");
+                        epoch->handle = body->handle;
+                 } else {
+                        struct mds_body *close_body = NULL;
+
+                        close_body = lustre_msg_buf(close_req->rq_reqmsg,
+                                                    REQ_REC_OFF,
+                                                    sizeof(*close_body));
+                        if (och != NULL)
+                                LASSERT(!memcmp(&old, &close_body->handle,
+                                        sizeof(old)));
+                        DEBUG_REQ(D_RPCTRACE, close_req,
+                                  "updating close with new fh");
+                        close_body->handle = body->handle;
+                 }
         }
 
         EXIT;
 }
 
-void mdc_set_open_replay_data(struct obd_client_handle *och,
-                              struct ptlrpc_request *open_req)
+static void mdc_set_open_replay_data_20(struct obd_client_handle *och,
+                                        struct ptlrpc_request *open_req)
+{
+        struct mdc_open_data  *mod;
+        struct obd_import     *imp = open_req->rq_import;
+        struct mdt_rec_create *rec = lustre_msg_buf(open_req->rq_reqmsg,
+                                                    DLM_INTENT_REC_OFF,
+                                                    sizeof(*rec));
+        struct mdt_body       *body = lustre_msg_buf(open_req->rq_repmsg,
+                                                     DLM_REPLY_REC_OFF,
+                                                     sizeof(*body));
+
+        /* If request is not eligible for replay, just bail out */
+        if (!open_req->rq_replay)
+                return;
+
+        /* incoming message in my byte order (it's been swabbed) */
+        LASSERT(rec != NULL);
+        LASSERT(lustre_rep_swabbed(open_req, DLM_REPLY_REC_OFF));
+        /* outgoing messages always in my byte order */
+        LASSERT(body != NULL);
+
+        /* Only if the import is replayable, we set replay_open data */
+        if (och && imp->imp_replayable) {
+                OBD_ALLOC_PTR(mod);
+                if (mod == NULL) {
+                        DEBUG_REQ(D_ERROR, open_req,
+                                  "can't allocate mdc_open_data");
+                        return;
+                }
+
+                spin_lock(&open_req->rq_lock);
+                och->och_mod = mod;
+                mod->mod_och = och;
+                mod->mod_open_req = open_req;
+                open_req->rq_cb_data = mod;
+                open_req->rq_commit_cb = mdc_commit_open;
+                spin_unlock(&open_req->rq_lock);
+        }
+
+        rec->cr_fid2 = body->fid1;
+        rec->cr_ioepoch = body->ioepoch;
+        rec->cr_old_handle.cookie = body->handle.cookie;
+        open_req->rq_replay_cb = mdc_replay_open;
+        if (!fid_is_sane(&body->fid1)) {
+                DEBUG_REQ(D_ERROR, open_req, "saving replay request with "
+                          "insane fid");
+                LBUG();
+        }
+
+        DEBUG_REQ(D_RPCTRACE, open_req, "set up replay data");
+}
+
+static void mdc_set_open_replay_data_18(struct obd_client_handle *och,
+                                        struct ptlrpc_request *open_req)
 {
         struct mdc_open_data *mod;
         struct mds_rec_create *rec = lustre_msg_buf(open_req->rq_reqmsg,
@@ -615,6 +772,15 @@ void mdc_set_open_replay_data(struct obd_client_handle *och,
         DEBUG_REQ(D_RPCTRACE, open_req, "set up replay data");
 }
 
+void mdc_set_open_replay_data(struct obd_client_handle *och,
+                              struct ptlrpc_request *open_req)
+{
+        if (mdc_req_is_2_0_server(open_req))
+                mdc_set_open_replay_data_20(och, open_req);
+        else
+                mdc_set_open_replay_data_18(och, open_req);
+}
+
 void mdc_clear_open_replay_data(struct obd_client_handle *och)
 {
         struct mdc_open_data *mod = och->och_mod;
@@ -629,55 +795,34 @@ void mdc_clear_open_replay_data(struct obd_client_handle *och)
         och->och_mod = NULL;
 }
 
-static void mdc_commit_close(struct ptlrpc_request *req)
-{
-        struct mdc_open_data *mod = req->rq_cb_data;
-        struct ptlrpc_request *open_req;
-        struct obd_import *imp = req->rq_import;
-
-        DEBUG_REQ(D_RPCTRACE, req, "close req committed");
-        if (mod == NULL)
-                return;
-
-        mod->mod_close_req = NULL;
-        req->rq_cb_data = NULL;
-        req->rq_commit_cb = NULL;
-
-        open_req = mod->mod_open_req;
-        LASSERT(open_req != NULL);
-        LASSERT(open_req != LP_POISON);
-        LASSERT(open_req->rq_type != LI_POISON);
-
-        DEBUG_REQ(D_RPCTRACE, open_req, "open req balanced");
-        LASSERT(open_req->rq_transno != 0);
-        LASSERT(open_req->rq_import == imp);
-
-        /* We no longer want to preserve this for transno-unconditional
-         * replay. */
-        spin_lock(&open_req->rq_lock);
-        open_req->rq_replay = 0;
-        spin_unlock(&open_req->rq_lock);
-}
-
-int mdc_close(struct obd_export *exp, struct obdo *oa,
+int mdc_close(struct obd_export *exp, struct mdc_op_data *data, struct obdo *oa,
               struct obd_client_handle *och, struct ptlrpc_request **request)
 {
         struct obd_device *obd = class_exp2obd(exp);
-        __u32 reqsize[2] = { sizeof(struct ptlrpc_body),
-                           sizeof(struct mds_body) };
-        __u32 repsize[4] = { sizeof(struct ptlrpc_body),
-                               sizeof(struct mds_body),
-                               obd->u.cli.cl_max_mds_easize,
-                               obd->u.cli.cl_max_mds_cookiesize };
+        __u32 reqsize[4] = { sizeof(struct ptlrpc_body),
+                             sizeof(struct mdt_body) };
+        __u32 repsize[6] = { sizeof(struct ptlrpc_body),
+                             sizeof(struct mdt_body),
+                             obd->u.cli.cl_max_mds_easize,
+                             obd->u.cli.cl_max_mds_cookiesize,
+                             sizeof(struct lustre_capa),
+                             sizeof(struct lustre_capa) };
         int rc;
         struct ptlrpc_request *req;
-        struct mdc_open_data *mod;
+        int bufcount = 2;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp)) {
+                reqsize[1] = sizeof(struct mdt_epoch);
+                reqsize[2] = sizeof(struct mdt_rec_create);
+                reqsize[3] = 0; /* capa */
+                bufcount = 4;
+        }
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
-                              MDS_CLOSE, 2, reqsize, NULL);
+                              MDS_CLOSE, bufcount, reqsize, NULL);
         if (req == NULL)
                 GOTO(out, rc = -ENOMEM);
+        req->rq_export = class_export_get(exp);
 
         /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a
          * portal whose threads are not taking any DLM locks and are therefore
@@ -688,27 +833,32 @@ int mdc_close(struct obd_export *exp, struct obdo *oa,
         /* Ensure that this close's handle is fixed up during replay. */
         LASSERT(och != NULL);
         LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
-        mod = och->och_mod;
-        if (likely(mod != NULL)) {
-                if (mod->mod_open_req->rq_type == LI_POISON) {
-                        CERROR("LBUG POISONED open %p!\n", mod->mod_open_req);
+        if (likely(och->och_mod != NULL)) {
+                struct ptlrpc_request *open_req = och->och_mod->mod_open_req;
+
+                if (open_req->rq_type == LI_POISON) {
+                        CERROR("LBUG POISONED open %p!\n", open_req);
                         LBUG();
                         ptlrpc_req_finished(req);
                         req = NULL;
                         GOTO(out, rc = -EIO);
                 }
-                mod->mod_close_req = req;
-                DEBUG_REQ(D_RPCTRACE, mod->mod_open_req, "matched open");
+                och->och_mod->mod_close_req = req;
+                DEBUG_REQ(D_RPCTRACE, req, "close req");
+                DEBUG_REQ(D_RPCTRACE, open_req, "clear open replay");
+
+                /* We no longer want to preserve this open for replay even
+                 * though the open was committed. b=3632, b=3633 */
+                spin_lock(&open_req->rq_lock);
+                open_req->rq_replay = 0;
+                spin_unlock(&open_req->rq_lock);
         } else {
                 CDEBUG(D_RPCTRACE, "couldn't find open req; expecting error\n");
         }
 
-        mdc_close_pack(req, REQ_REC_OFF, oa, oa->o_valid, och);
+        mdc_close_pack(req, REQ_REC_OFF, data, oa, oa->o_valid, och);
 
-        ptlrpc_req_set_repsize(req, 4, repsize);
-        req->rq_commit_cb = mdc_commit_close;
-        LASSERT(req->rq_cb_data == NULL);
-        req->rq_cb_data = mod;
+        ptlrpc_req_set_repsize(req, 6, repsize);
 
         mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
         rc = ptlrpc_queue_wait(req);
@@ -726,10 +876,8 @@ int mdc_close(struct obd_export *exp, struct obdo *oa,
                                   "= %d", rc);
                         if (rc > 0)
                                 rc = -rc;
-                } else if (mod == NULL) {
-                        CERROR("Unexpected: can't find mdc_open_data, but the "
-                               "close succeeded.  Please tell <http://bugzilla.lustre.org/>.\n");
                 }
+
                 if (!lustre_swab_repbuf(req, REPLY_REC_OFF,
                                         sizeof(struct mds_body),
                                         lustre_swab_mds_body)) {
@@ -741,17 +889,19 @@ int mdc_close(struct obd_export *exp, struct obdo *oa,
         EXIT;
         *request = req;
  out:
-        if (rc != 0 && req && req->rq_commit_cb)
-                req->rq_commit_cb(req);
+        if (rc != 0 && och->och_mod)
+                 och->och_mod->mod_close_req = NULL;
 
         return rc;
 }
 
-int mdc_done_writing(struct obd_export *exp, struct obdo *obdo)
+int mdc_done_writing(struct obd_export *exp, struct mdc_op_data *data,
+                     struct obdo *obdo)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+        __u32 size[2] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body) };
         int rc;
         ENTRY;
 
@@ -760,8 +910,9 @@ int mdc_done_writing(struct obd_export *exp, struct obdo *obdo)
         if (req == NULL)
                 RETURN(-ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        mdc_pack_fid(&body->fid1, obdo->o_id, 0, obdo->o_mode);
+        body->fid1 = data->fid1;
         body->size = obdo->o_size;
         body->blocks = obdo->o_blocks;
         body->flags = obdo->o_flags;
@@ -782,7 +933,8 @@ int mdc_readpage(struct obd_export *exp, struct ll_fid *fid, __u64 offset,
         struct ptlrpc_request *req = NULL;
         struct ptlrpc_bulk_desc *desc = NULL;
         struct mds_body *body;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+        __u32 size[2] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body) };
         int rc;
         ENTRY;
 
@@ -793,6 +945,7 @@ int mdc_readpage(struct obd_export *exp, struct ll_fid *fid, __u64 offset,
         if (req == NULL)
                 GOTO(out, rc = -ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         req->rq_request_portal = MDS_READPAGE_PORTAL;
         ptlrpc_at_set_req_timeout(req);
 
@@ -874,6 +1027,9 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 rc = lquota_poll_check(quota_interface, exp,
                                        (struct if_quotacheck *)karg);
                 GOTO(out, rc);
+        case OBD_IOC_PING_TARGET:
+                rc = ptlrpc_obd_ping(obd);
+                GOTO(out, rc);
         default:
                 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
                 GOTO(out, rc = -ENOTTY);
@@ -940,6 +1096,7 @@ int mdc_set_info_async(struct obd_export *exp, obd_count keylen,
                 if (req == NULL)
                         RETURN(-ENOMEM);
 
+                req->rq_export = class_export_get(exp);
                 ptlrpc_req_set_repsize(req, 1, NULL);
                 if (set) {
                         rc = 0;
@@ -995,6 +1152,7 @@ static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
         if (!imp)
                 RETURN(-ENODEV);
 
+
         /* We could possibly pass max_age in the request (as an absolute
          * timestamp or a "seconds.usec ago") so the target can avoid doing
          * extra calls into the filesystem if that isn't necessary (e.g.
@@ -1035,22 +1193,27 @@ output:
         return rc;
 }
 
-static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type,
+static int mdc_pin(struct obd_export *exp, struct ll_fid *fid,
                    struct obd_client_handle *handle, int flag)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+        __u32 size[3] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body), 0 };
         int rc;
+        int bufcount = 2;
         ENTRY;
 
+        if (mdc_exp_is_2_0_server(exp))
+                bufcount = 3;
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
-                              MDS_PIN, 2, size, NULL);
+                              MDS_PIN, bufcount, size, NULL);
         if (req == NULL)
                 RETURN(-ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        mdc_pack_fid(&body->fid1, ino, gen, type);
+        body->fid1 = *fid;
         body->flags = flag;
 
         ptlrpc_req_set_repsize(req, 2, size);
@@ -1089,7 +1252,8 @@ static int mdc_unpin(struct obd_export *exp,
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+        __u32 size[2] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body) };
         int rc;
         ENTRY;
 
@@ -1101,6 +1265,7 @@ static int mdc_unpin(struct obd_export *exp,
         if (req == NULL)
                 RETURN(-ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
         memcpy(&body->handle, &handle->och_fh, sizeof(body->handle));
         body->flags = flag;
@@ -1123,15 +1288,21 @@ int mdc_sync(struct obd_export *exp, struct ll_fid *fid,
              struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(struct mds_body) };
+        __u32 size[3] = { sizeof(struct ptlrpc_body),
+                          sizeof(struct mdt_body), 0 };
+        int bufcount = 2;
         int rc;
         ENTRY;
 
+
+        if (mdc_exp_is_2_0_server(exp))
+                bufcount = 3;
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
-                              MDS_SYNC, 2, size, NULL);
+                              MDS_SYNC, bufcount, size, NULL);
         if (!req)
                 RETURN(rc = -ENOMEM);
 
+        req->rq_export = class_export_get(exp);
         mdc_pack_req_body(req, REQ_REC_OFF, 0, fid, 0, 0);
 
         ptlrpc_req_set_repsize(req, 2, size);
@@ -1240,7 +1411,7 @@ int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp)
 {
         struct obd_device *obd = mdc_exp->exp_obd;
         struct client_obd *cli = &obd->u.cli;
-        struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC };
+        struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC_V3 };
         struct lov_desc desc;
         __u32 valsize = sizeof(desc);
         __u32 stripes;
@@ -1285,16 +1456,17 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         case OBD_CLEANUP_EXPORTS:
                 /* If we set up but never connected, the
                    client import will not have been cleaned. */
+                down_write(&obd->u.cli.cl_sem);
                 if (obd->u.cli.cl_import) {
                         struct obd_import *imp;
-                        down_write(&obd->u.cli.cl_sem);
                         imp = obd->u.cli.cl_import;
                         CERROR("client import never connected\n");
                         ptlrpc_invalidate_import(imp);
                         class_destroy_import(imp);
-                        up_write(&obd->u.cli.cl_sem);
                         obd->u.cli.cl_import = NULL;
                 }
+                up_write(&obd->u.cli.cl_sem);
+
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");
@@ -1392,6 +1564,57 @@ static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
         return(rc);
 }
 
+static int mdc_fid_init(struct obd_export *exp)
+{
+        struct client_obd *cli;
+        char              *prefix;
+        int                rc;
+        ENTRY;
+
+        cli = &exp->exp_obd->u.cli;
+
+        OBD_ALLOC_PTR(cli->cl_seq);
+        if (cli->cl_seq == NULL)
+                RETURN(-ENOMEM);
+
+        OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
+        if (prefix == NULL)
+                GOTO(out_free_seq, rc = -ENOMEM);
+
+        snprintf(prefix, MAX_OBD_NAME + 5, "srv-%s", exp->exp_obd->obd_name);
+
+        /* Init client side sequence-manager */
+        rc = seq_client_init(cli->cl_seq, exp,
+                             LUSTRE_SEQ_METADATA,
+                             LUSTRE_SEQ_MAX_WIDTH,
+                             prefix);
+        OBD_FREE(prefix, MAX_OBD_NAME + 5);
+        if (rc)
+                GOTO(out_free_seq, rc);
+
+        RETURN(rc);
+
+out_free_seq:
+        OBD_FREE_PTR(cli->cl_seq);
+        cli->cl_seq = NULL;
+        return rc;
+}
+
+static int mdc_fid_fini(struct obd_export *exp)
+{
+        struct client_obd *cli = &exp->exp_obd->u.cli;
+        ENTRY;
+
+        if (cli->cl_seq != NULL) {
+                LASSERT(cli->cl_seq->lcs_exp == exp);
+                seq_client_fini(cli->cl_seq);
+                OBD_FREE_PTR(cli->cl_seq);
+                cli->cl_seq = NULL;
+        }
+
+        RETURN(0);
+}
+
 struct obd_ops mdc_obd_ops = {
         .o_owner        = THIS_MODULE,
         .o_setup        = mdc_setup,
@@ -1401,6 +1624,8 @@ struct obd_ops mdc_obd_ops = {
         .o_del_conn     = client_import_del_conn,
         .o_connect      = client_connect_import,
         .o_disconnect   = client_disconnect_export,
+        .o_fid_init     = mdc_fid_init,
+        .o_fid_fini     = mdc_fid_fini,
         .o_iocontrol    = mdc_iocontrol,
         .o_set_info_async = mdc_set_info_async,
         .o_get_info     = mdc_get_info,
diff --git a/lustre/mds/Makefile.in b/lustre/mds/Makefile.in
index 96d7ec7..adbd619 100644
--- a/lustre/mds/Makefile.in
+++ b/lustre/mds/Makefile.in
@@ -2,4 +2,6 @@ MODULES := mds
 mds-objs := mds_log.o mds_unlink_open.o mds_lov.o handler.o mds_reint.o
 mds-objs += mds_fs.o lproc_mds.o mds_open.o mds_lib.o mds_xattr.o mds_join.o
 
+EXTRA_DIST := $(mds-objs:%.o=%.c) mds_internal.h
+
 @INCLUDE_RULES@
diff --git a/lustre/mds/autoMakefile.am b/lustre/mds/autoMakefile.am
index d2aafc6..4cc5dea 100644
--- a/lustre/mds/autoMakefile.am
+++ b/lustre/mds/autoMakefile.am
@@ -39,4 +39,3 @@ modulefs_DATA = mds$(KMODEXT)
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES := $(mds-objs:%.o=%.c) mds_internal.h
diff --git a/lustre/mds/autoMakefile.in b/lustre/mds/autoMakefile.in
index 83ceb15..d2f05c6 100644
--- a/lustre/mds/autoMakefile.in
+++ b/lustre/mds/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @MODULES_TRUE at modulefs_DATA = mds$(KMODEXT)
-DIST_SOURCES := $(mds-objs:%.o=%.c) mds_internal.h
 subdir = lustre/mds
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index b6dbe14..3ca0c35 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -213,6 +213,7 @@ struct dentry *mds_fid2locked_dentry(struct obd_device *obd, struct ll_fid *fid,
 struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
                               struct vfsmount **mnt)
 {
+        struct obd_device *obd = container_of(mds, struct obd_device, u.mds);
         char fid_name[32];
         unsigned long ino = fid->id;
         __u32 generation = fid->generation;
@@ -229,7 +230,7 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
 
         /* under ext3 this is neither supposed to return bad inodes
            nor NULL inodes. */
-        result = ll_lookup_one_len(fid_name, mds->mds_fid_de, strlen(fid_name));
+        result = mds_lookup(obd, fid_name, mds->mds_fid_de, strlen(fid_name));
         if (IS_ERR(result))
                 RETURN(result);
 
@@ -240,8 +241,6 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid,
        if (inode->i_nlink == 0) {
                 if (inode->i_mode == 0 &&
                     LTIME_S(inode->i_ctime) == 0 ) {
-                        struct obd_device *obd = container_of(mds, struct
-                                                              obd_device, u.mds);
                         LCONSOLE_WARN("Found inode with zero nlink, mode and "
                                       "ctime -- this may indicate disk"
                                       "corruption (device %s, inode %lu, link:"
@@ -338,18 +337,14 @@ static int mds_connect(struct lustre_handle *conn, struct obd_device *obd,
         struct obd_export *exp;
         struct mds_export_data *med;
         struct lsd_client_data *lcd = NULL;
-        int rc, abort_recovery;
+        int rc;
         ENTRY;
 
         if (!conn || !obd || !cluuid)
                 RETURN(-EINVAL);
 
         /* Check for aborted recovery. */
-        spin_lock_bh(&obd->obd_processing_task_lock);
-        abort_recovery = obd->obd_abort_recovery;
-        spin_unlock_bh(&obd->obd_processing_task_lock);
-        if (abort_recovery)
-                target_abort_recovery(obd);
+        target_recovery_check_and_stop(obd);
 
         /* XXX There is a small race between checking the list and adding a
          * new connection for the same UUID, but the real threat (list
@@ -389,6 +384,8 @@ out:
                         med->med_lcd = NULL;
                 }
                 class_disconnect(exp);
+                /* release nid stat refererence */
+                lprocfs_exp_cleanup(exp);
         } else {
                 class_export_put(exp);
         }
@@ -411,10 +408,23 @@ int mds_init_export(struct obd_export *exp)
         RETURN(ldlm_init_export(exp));
 }
 
-static int mds_destroy_export(struct obd_export *export)
+static int mds_destroy_export(struct obd_export *exp)
+{
+        ENTRY;
+
+        target_destroy_export(exp);
+        ldlm_destroy_export(exp);
+
+        LASSERT(list_empty(&exp->exp_mds_data.med_open_head));
+        mds_client_free(exp);
+
+        RETURN(0);
+}
+
+static int mds_cleanup_mfd(struct obd_export *exp)
 {
         struct mds_export_data *med;
-        struct obd_device *obd = export->exp_obd;
+        struct obd_device *obd = exp->exp_obd;
         struct mds_obd *mds = &obd->u.mds;
         struct lvfs_run_ctxt saved;
         struct lov_mds_md *lmm;
@@ -425,15 +435,26 @@ static int mds_destroy_export(struct obd_export *export)
         int rc = 0;
         ENTRY;
 
-        med = &export->exp_mds_data;
-        target_destroy_export(export);
-        ldlm_destroy_export(export);
+        med = &exp->exp_mds_data;
 
-        if (obd_uuid_equals(&export->exp_client_uuid, &obd->obd_uuid))
+        spin_lock(&med->med_open_lock);
+        if (list_empty(&med->med_open_head)) {
+                spin_unlock(&med->med_open_lock);
                 RETURN(0);
+        }
 
-        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        /* Close any open files (which may also cause orphan unlinking). */
+        CFS_INIT_LIST_HEAD(&closing_list);
+        while (!list_empty(&med->med_open_head)) {
+                struct list_head *tmp = med->med_open_head.next;
+                struct mds_file_data *mfd =
+                        list_entry(tmp, struct mds_file_data, mfd_list);
+
+                /* Remove mfd handle so it can't be found again.
+                 * We are consuming the mfd_list reference here. */
+                mds_mfd_unlink(mfd, 0);
+                list_add_tail(&mfd->mfd_list, &closing_list);
+        }
+        spin_unlock(&med->med_open_lock);
 
         lmm_sz = mds->mds_max_mdsize;
         OBD_ALLOC(lmm, lmm_sz);
@@ -452,19 +473,8 @@ static int mds_destroy_export(struct obd_export *export)
                 GOTO(out, rc = -ENOMEM);
         }
 
-        CFS_INIT_LIST_HEAD(&closing_list);
-        spin_lock(&med->med_open_lock);
-        while (!list_empty(&med->med_open_head)) {
-                struct list_head *tmp = med->med_open_head.next;
-                mfd = list_entry(tmp, struct mds_file_data, mfd_list);
-
-                /* Remove mfd handle so it can't be found again.
-                 * We are consuming the mfd_list reference here. */
-                mds_mfd_unlink(mfd, 0);
-                list_add_tail(&mfd->mfd_list, &closing_list);
-        }
-        spin_unlock(&med->med_open_lock);
-
+        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+        /* Close any open files (which may also cause orphan unlinking). */
         list_for_each_entry_safe(mfd, n, &closing_list, mfd_list) {
                 int lmm_size = lmm_sz;
                 umode_t mode = mfd->mfd_dentry->d_inode->i_mode;
@@ -478,7 +488,7 @@ static int mds_destroy_export(struct obd_export *export)
                        mfd->mfd_dentry->d_inode->i_ino);
 
                 rc = mds_get_md(obd, mfd->mfd_dentry->d_inode, lmm,
-                                &lmm_size, 1, 0);
+                                &lmm_size, 1, 0, 0);
                 if (rc < 0)
                         CWARN("mds_get_md failure, rc=%d\n", rc);
                 else
@@ -490,7 +500,7 @@ static int mds_destroy_export(struct obd_export *export)
 
                 list_del_init(&mfd->mfd_list);
                 rc = mds_mfd_close(NULL, REQ_REC_OFF, obd, mfd,
-                                   !(export->exp_flags & OBD_OPT_FAILOVER),
+                                   !(exp->exp_flags & OBD_OPT_FAILOVER),
                                    lmm, lmm_size, logcookies,
                                    mds->mds_max_cookiesize,
                                    &valid);
@@ -510,14 +520,10 @@ static int mds_destroy_export(struct obd_export *export)
                 }
 
         }
-
+        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         OBD_FREE(logcookies, cookie_sz);
         OBD_FREE(lmm, lmm_sz);
-
-        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        mds_client_free(export);
-
- out:
+out:
         RETURN(rc);
 }
 
@@ -551,6 +557,7 @@ static int mds_disconnect(struct obd_export *exp)
                 spin_unlock(&svc->srv_lock);
         }
         spin_unlock(&exp->exp_lock);
+        rc = mds_cleanup_mfd(exp);
 
         class_export_put(exp);
         RETURN(rc);
@@ -582,7 +589,8 @@ static int mds_getstatus(struct ptlrpc_request *req)
  * The EA size is also returned on success, and -ve errno on failure.
  * If there is no EA then 0 is returned. */
 int mds_get_md(struct obd_device *obd, struct inode *inode, void *md,
-               int *size, int lock, int flags)
+               int *size, int lock, int flags,
+               __u64 connect_flags)
 {
         int rc = 0;
         int lmm_size = 0;
@@ -591,42 +599,6 @@ int mds_get_md(struct obd_device *obd, struct inode *inode, void *md,
                 LOCK_INODE_MUTEX(inode);
         rc = fsfilt_get_md(obd, inode, md, *size, "lov");
 
-        /* rc == 0 may come from a not large enough buffer if
-         * we downgrade from a pool version and the file
-         * is a large stripe like full stripe
-         */
-        if (rc == 0) {
-                /* get the size of the lov EA */
-                rc = fsfilt_get_md(obd, inode, NULL, *size, "lov");
-                /* test if the difference is from poolname */
-                if (rc == (*size + MAXPOOLNAME)) {
-                        void *buf;
-                        int new_size;
-
-                        new_size = *size + MAXPOOLNAME;
-                        OBD_ALLOC(buf, new_size);
-                        if (buf == NULL) {
-                                rc = -ENOMEM;
-                                goto out;
-                        }
-                        rc = fsfilt_get_md(obd, inode, buf, new_size, "lov");
-                        if (rc <= 0)
-                                goto out_convert;
-
-                        /* convert V3 EA to V1 */
-                        lmm_size = rc;
-                        rc = mds_convert_lov_ea(obd, inode, buf, lmm_size);
-                        if (rc < 0)
-                                goto out_convert;
-                        /* copy converted EA to provided buffer */
-                        memcpy(md, buf, rc);
-                        *size = rc;
-out_convert:
-                        OBD_FREE(buf, new_size);
-                        goto out;
-               }
-        }
-
         if (rc == 0 && flags == MDS_GETATTR)
                 rc = mds_get_default_md(obd, md, &lmm_size);
 
@@ -635,7 +607,8 @@ out_convert:
                        rc, inode->i_ino);
         } else if (rc > 0) {
                 lmm_size = rc;
-                rc = mds_convert_lov_ea(obd, inode, md, lmm_size);
+                rc = mds_convert_lov_ea(obd, inode, md, lmm_size,
+                                        connect_flags);
 
                 if (rc == 0) {
                         *size = lmm_size;
@@ -646,8 +619,6 @@ out_convert:
         } else {
                 *size = 0;
         }
-
-out:
         if (lock)
                 UNLOCK_INODE_MUTEX(inode);
 
@@ -658,7 +629,8 @@ out:
 /* Call with lock=1 if you want mds_pack_md to take the i_mutex.
  * Call with lock=0 if the caller has already taken the i_mutex. */
 int mds_pack_md(struct obd_device *obd, struct lustre_msg *msg, int offset,
-                struct mds_body *body, struct inode *inode, int lock, int flags)
+                struct mds_body *body, struct inode *inode, int lock, int flags,
+                __u64 connect_flags)
 {
         struct mds_obd *mds = &obd->u.mds;
         void *lmm;
@@ -689,7 +661,8 @@ int mds_pack_md(struct obd_device *obd, struct lustre_msg *msg, int offset,
                 // RETURN(-EINVAL);
         }
 
-        rc = mds_get_md(obd, inode, lmm, &lmm_size, lock, flags);
+        rc = mds_get_md(obd, inode, lmm, &lmm_size, lock, flags,
+                        connect_flags);
         if (rc > 0) {
                 if (S_ISDIR(inode->i_mode))
                         body->valid |= OBD_MD_FLDIREA;
@@ -762,20 +735,7 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
         body = lustre_msg_buf(req->rq_repmsg, reply_off, sizeof(*body));
         LASSERT(body != NULL);                 /* caller prepped reply */
 
-        mds_pack_inode2fid(&body->fid1, inode);
         body->flags = reqbody->flags; /* copy MDS_BFLAG_EXT_FLAGS if present */
-
-        /* Compatibility for clients that do not set BLFAG_EXT_FLAGS in
-         * intent lock requests even though they check it in the reply.
-         * In 1.8+ this is set unconditionally, but 1.4.6- clients do
-         * not understand this flag.  b=17465 */
-        if ((reqbody->flags & MDS_BFLAG_EXT_FLAGS) &&
-            !obd->obd_self_export->exp_bflag) {
-                spin_lock(&obd->obd_self_export->exp_lock);
-                obd->obd_self_export->exp_bflag = 1;
-                spin_unlock(&obd->obd_self_export->exp_lock);
-        }
-
         mds_pack_inode2body(body, inode);
         reply_off++;
 
@@ -786,7 +746,8 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
                         flags = MDS_GETATTR;
 
                 rc = mds_pack_md(obd, req->rq_repmsg, reply_off, body,
-                                 inode, 1, flags);
+                                 inode, 1, flags,
+                                 req->rq_export->exp_connect_flags);
 
                 /* If we have LOV EA data, the OST holds size, atime, mtime */
                 if (!(body->valid & OBD_MD_FLEASIZE) &&
@@ -826,7 +787,7 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
 
                 /* We only return the full set of flags on ioctl, otherwise we
                  * get enough flags from the inode in mds_pack_inode2body(). */
-                rc = fsfilt_iocontrol(obd, inode, NULL, EXT3_IOC_GETFLAGS,
+                rc = fsfilt_iocontrol(obd, dentry, FSFILT_IOC_GETFLAGS,
                                       (long)&flags);
                 if (rc == 0)
                         body->flags = flags | MDS_BFLAG_EXT_FLAGS;
@@ -883,7 +844,7 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct inode *inode,
                        rc, inode->i_ino);
                 if ((rc == 0) && (lustre_msg_get_opc(req->rq_reqmsg) == MDS_GETATTR) &&
                      ((S_ISDIR(inode->i_mode) && (body->valid & OBD_MD_FLDIREA))))
-                        rc = sizeof(struct lov_mds_md);
+                        rc = sizeof(struct lov_mds_md_v3);
                 if (rc < 0) {
                         if (rc != -ENODATA) {
                                 CERROR("error getting inode %lu MD: rc = %d\n",
@@ -892,14 +853,9 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct inode *inode,
                         }
                         size[bufcount] = 0;
                 } else if (rc > mds->mds_max_mdsize) {
-                        /* pool downgrade case */
-                        if (rc <= (mds->mds_max_mdsize + MAXPOOLNAME)) {
-                                size[bufcount] = rc;
-                        } else {
-                                size[bufcount] = 0;
-                                CERROR("MD size %d larger than maximum possible %u\n",
-                                       rc, mds->mds_max_mdsize);
-                        }
+                        size[bufcount] = 0;
+                        CERROR("MD size %d larger than maximum possible %u\n",
+                               rc, mds->mds_max_mdsize);
                 } else {
                         size[bufcount] = rc;
                 }
@@ -1126,8 +1082,11 @@ static int mds_getattr_lock(struct ptlrpc_request *req, int offset,
                         if (rc == 0)
                                 rc = rc2;
                         req->rq_status = rc;
+                } else if (rc) {
+                        lustre_shrink_reply(req, offset + 1, 0 , 1);
                 }
         }
+
         return rc;
 }
 
@@ -1163,13 +1122,12 @@ static int mds_getattr(struct ptlrpc_request *req, int offset)
         rc = mds_getattr_pack_msg(req, de->d_inode, offset);
         if (rc != 0) {
                 CERROR("mds_getattr_pack_msg: %d\n", rc);
-                GOTO(out_pop, rc);
+                GOTO(out_dput, rc);
         }
 
         req->rq_status = mds_getattr_internal(obd, de, req, body,REPLY_REC_OFF);
-
+out_dput:
         l_dput(de);
-        GOTO(out_pop, rc);
 out_pop:
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, &uc);
 out_ucred:
@@ -1178,8 +1136,11 @@ out_ucred:
                 if (rc == 0)
                         rc = rc2;
                 req->rq_status = rc;
+        } else if (rc) {
+                lustre_shrink_reply(req, REPLY_REC_OFF + 1, 0, 1);
         }
         mds_exit_ucred(&uc, mds);
+
         return rc;
 }
 
@@ -1208,7 +1169,7 @@ static int mds_statfs(struct ptlrpc_request *req)
         /* This will trigger a watchdog timeout */
         OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_STATFS_LCW_SLEEP,
                          (MDS_SERVICE_WATCHDOG_FACTOR *
-                          at_get(&svc->srv_at_estimate) / 1000) + 1);
+                          at_get(&svc->srv_at_estimate)) + 1);
         OBD_COUNTER_INCREMENT(obd, statfs);
 
         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK))
@@ -1261,7 +1222,6 @@ static int mds_sync(struct ptlrpc_request *req, int offset)
 
                 body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
                                       sizeof(*body));
-                mds_pack_inode2fid(&body->fid1, de->d_inode);
                 mds_pack_inode2body(body, de->d_inode);
 
                 l_dput(de);
@@ -1393,8 +1353,8 @@ static int mds_filter_recovery_request(struct ptlrpc_request *req,
         case MDS_CLOSE:
         case MDS_SYNC: /* used in unmounting */
         case OBD_PING:
-        case MDS_REINT:
         case MDS_SETXATTR:
+        case MDS_REINT:
         case LDLM_ENQUEUE:
                 *process = target_queue_recovery_request(req, obd);
                 RETURN(0);
@@ -1593,7 +1553,7 @@ int mds_handle(struct ptlrpc_request *req)
         /* XXX identical to OST */
         if (lustre_msg_get_opc(req->rq_reqmsg) != MDS_CONNECT) {
                 struct mds_export_data *med;
-                int recovering, abort_recovery;
+                int recovering;
 
                 if (req->rq_export == NULL) {
                         CERROR("operation %d on unconnected MDS from %s\n",
@@ -1628,12 +1588,10 @@ int mds_handle(struct ptlrpc_request *req)
 
                 /* Check for aborted recovery. */
                 spin_lock_bh(&obd->obd_processing_task_lock);
-                abort_recovery = obd->obd_abort_recovery;
                 recovering = obd->obd_recovering;
                 spin_unlock_bh(&obd->obd_processing_task_lock);
-                if (abort_recovery) {
-                        target_abort_recovery(obd);
-                } else if (recovering) {
+                if (recovering &&
+                    target_recovery_check_and_stop(obd) == 0) {
                         rc = mds_filter_recovery_request(req, obd,
                                                          &should_process);
                         if (rc || !should_process)
@@ -1647,9 +1605,8 @@ int mds_handle(struct ptlrpc_request *req)
                 OBD_FAIL_RETURN(OBD_FAIL_MDS_CONNECT_NET, 0);
                 rc = target_handle_connect(req, mds_handle);
                 if (!rc) {
-                        /* Now that we have an export, set mds. */
+                        /* Now that we have an export, set obd. */
                         obd = req->rq_export->exp_obd;
-                        mds = mds_req2mds(req);
                 }
                 break;
 
@@ -1724,9 +1681,9 @@ int mds_handle(struct ptlrpc_request *req)
                 __u32  opc;
                 int op = 0;
                 int size[4] = { sizeof(struct ptlrpc_body),
-                                sizeof(struct mds_body),
-                                mds->mds_max_mdsize,
-                                mds->mds_max_cookiesize };
+                               sizeof(struct mds_body),
+                               mds->mds_max_mdsize,
+                               mds->mds_max_cookiesize };
                 int bufcount;
 
                 /* NB only peek inside req now; mds_reint() will swab it */
@@ -1740,9 +1697,8 @@ int mds_handle(struct ptlrpc_request *req)
                         __swab32s(&opc);
 
                 DEBUG_REQ(D_INODE, req, "reint %d (%s)", opc,
-                          (opc < sizeof(reint_names) / sizeof(reint_names[0]) ||
-                           reint_names[opc] == NULL) ? reint_names[opc] :
-                                                       "unknown opcode");
+                          (opc < REINT_MAX) ? reint_names[opc] :
+                          "unknown opcode");
 
                 switch (opc) {
                 case REINT_CREATE:
@@ -1781,6 +1737,13 @@ int mds_handle(struct ptlrpc_request *req)
                 else
                         bufcount = 2;
 
+                /* if we do recovery we isn't send reply mds state is restored */
+                if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
+                        size[DLM_REPLY_REC_OFF] = 0;
+                        if (opc == REINT_UNLINK || opc == REINT_RENAME)
+                                size[DLM_REPLY_REC_OFF + 1] = 0;
+                }
+
                 rc = lustre_pack_reply(req, bufcount, size, NULL);
                 if (rc)
                         break;
@@ -1835,6 +1798,8 @@ int mds_handle(struct ptlrpc_request *req)
         case OBD_PING:
                 DEBUG_REQ(D_INODE, req, "ping");
                 rc = target_handle_ping(req);
+                if (req->rq_export->exp_delayed)
+                        mds_update_client_epoch(req->rq_export);
                 break;
 
         case OBD_LOG_CANCEL:
@@ -1917,19 +1882,8 @@ int mds_handle(struct ptlrpc_request *req)
         }
 
         EXIT;
- out:
-
-        if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY) {
-                if (obd && obd->obd_recovering) {
-                        DEBUG_REQ(D_HA, req, "LAST_REPLAY, queuing reply");
-                        return target_queue_last_replay_reply(req, rc);
-                }
-                /* Lost a race with recovery; let the error path DTRT. */
-                rc = req->rq_status = -ENOTCONN;
-        }
-
-        target_send_reply(req, rc, fail);
-        return 0;
+out:
+        return target_handle_reply(req, rc, fail);
 }
 
 /* Update the server data on disk.  This stores the new mount_count and
@@ -2065,10 +2019,12 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
 
         sema_init(&mds->mds_epoch_sem, 1);
         spin_lock_init(&mds->mds_transno_lock);
-        mds->mds_max_mdsize = sizeof(struct lov_mds_md);
+        mds->mds_max_mdsize = sizeof(struct lov_mds_md_v3);
         mds->mds_max_cookiesize = sizeof(struct llog_cookie);
         mds->mds_atime_diff = MAX_ATIME_DIFF;
         mds->mds_evict_ost_nids = 1;
+        /* sync permission changes */
+        mds->mds_sync_permission = 0;
 
         sprintf(ns_name, "mds-%s", obd->obd_uuid.uuid);
         obd->obd_namespace = ldlm_namespace_new(obd, ns_name, LDLM_NAMESPACE_SERVER,
@@ -2084,6 +2040,9 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
             lprocfs_alloc_obd_stats(obd, LPROC_MDS_LAST) == 0) {
                 /* Init private stats here */
                 mds_stats_counter_init(obd->obd_stats);
+#ifdef HAVE_DELAYED_RECOVERY
+                lprocfs_obd_attach_stale_exports(obd);
+#endif
                 obd->obd_proc_exports_entry = proc_mkdir("exports",
                                                          obd->obd_proc_entry);
         }
@@ -2098,7 +2057,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         if (obd->obd_proc_exports_entry)
                 lprocfs_add_simple(obd->obd_proc_exports_entry,
                                    "clear", lprocfs_nid_stats_clear_read,
-                                   lprocfs_nid_stats_clear_write, obd);
+                                   lprocfs_nid_stats_clear_write, obd, NULL);
 
         if (lcfg->lcfg_bufcount >= 4 && LUSTRE_CFG_BUFLEN(lcfg, 3) > 0) {
                 class_uuid_t uuid;
@@ -2151,17 +2110,14 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         if (obd->obd_recovering) {
                 LCONSOLE_WARN("MDT %s now serving %s (%s%s%s), but will be in "
                               "recovery for at least %d:%.02d, or until %d "
-                              "client%s reconnect. During this time new clients"
-                              " will not be allowed to connect. "
-                              "Recovery progress can be monitored by watching "
-                              "/proc/fs/lustre/mds/%s/recovery_status.\n",
+                              "client%s reconnect%s. \n",
                               obd->obd_name, lustre_cfg_string(lcfg, 1),
                               label ?: "", label ? "/" : "", str,
                               obd->obd_recovery_timeout / 60,
                               obd->obd_recovery_timeout % 60,
-                              obd->obd_max_recoverable_clients,
-                              (obd->obd_max_recoverable_clients == 1) ? "":"s",
-                              obd->obd_name);
+                              obd->obd_recoverable_clients,
+                              (obd->obd_recoverable_clients == 1) ? "":"s",
+                              (obd->obd_recoverable_clients == 1) ? "s":"");
         } else {
                 LCONSOLE_INFO("MDT %s now serving %s (%s%s%s) with recovery "
                               "%s\n", obd->obd_name, lustre_cfg_string(lcfg, 1),
@@ -2289,11 +2245,13 @@ int mds_postrecov(struct obd_device *obd)
 
         LASSERT(!obd->obd_recovering);
 
+        /* VBR: update boot epoch after recovery */
+        mds_update_last_epoch(obd);
+
         /* clean PENDING dir */
         rc = mds_cleanup_pending(obd);
         if (rc < 0)
                 GOTO(out, rc);
-
         /* FIXME Does target_finish_recovery really need this to block? */
         /* Notify the LOV, which will in turn call mds_notify for each tgt */
         /* This means that we have to hack obd_notify to think we're obd_set_up
@@ -2303,7 +2261,8 @@ int mds_postrecov(struct obd_device *obd)
                    OBD_NOTIFY_SYNC, NULL);
 
         /* quota recovery */
-        lquota_recovery(mds_quota_interface_ref, obd);
+        if (likely(obd->obd_stopping == 0))
+                lquota_recovery(mds_quota_interface_ref, obd);
 
 out:
         RETURN(rc);
@@ -2428,11 +2387,11 @@ static void fixup_handle_for_resent_req(struct ptlrpc_request *req, int offset,
         /* If the xid matches, then we know this is a resent request,
          * and allow it. (It's probably an OPEN, for which we don't
          * send a lock */
-        if (req->rq_xid ==
+        if (req->rq_xid <=
             le64_to_cpu(exp->exp_mds_data.med_lcd->lcd_last_xid))
                 return;
 
-        if (req->rq_xid ==
+        if (req->rq_xid <=
             le64_to_cpu(exp->exp_mds_data.med_lcd->lcd_last_close_xid))
                 return;
 
@@ -2495,7 +2454,7 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
                 repsize[repbufcnt++] = mds->mds_max_cookiesize;
 
         /* if we do recovery we isn't send reply mds state is restored */
-        if(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
+        if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) {
                 repsize[DLM_REPLY_REC_OFF+1] = 0;
                 if (it->opc & IT_UNLINK)
                         repsize[DLM_REPLY_REC_OFF+2] = 0;
@@ -2537,7 +2496,9 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
                          * be replied by rq_stats, otherwise, return it by
                          * intent here
                          */
-                        if (IS_CLIENT_DISCONNECT_ERROR(rep->lock_policy_res2))
+                         /* if VBR failure then return error in rq_stats too */
+                        if (IS_CLIENT_DISCONNECT_ERROR(rep->lock_policy_res2) ||
+                            rep->lock_policy_res2 == -EOVERFLOW)
                                 RETURN(rep->lock_policy_res2);
                         else
                                 RETURN(ELDLM_LOCK_ABORTED);
@@ -2632,6 +2593,7 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
                sizeof(lock->l_remote_handle));
 
         unlock_res_and_lock(new_lock);
+
         lustre_hash_add(new_lock->l_export->exp_lock_hash,
                         &new_lock->l_remote_handle,
                         &new_lock->l_exp_hash);
@@ -2808,8 +2770,8 @@ static int mds_health_check(struct obd_device *obd)
                 rc = 1;
 
 #ifdef USE_HEALTH_CHECK_WRITE
-        LASSERT(mds->mds_health_check_filp != NULL);
-        rc |= !!lvfs_check_io_health(obd, mds->mds_health_check_filp);
+        LASSERT(mds->mds_obt.obt_health_check_filp != NULL);
+        rc |= !!lvfs_check_io_health(obd, mds->mds_obt.obt_health_check_filp);
 #endif
 
         return rc;
diff --git a/lustre/mds/lproc_mds.c b/lustre/mds/lproc_mds.c
index 24e03cd..834b67f 100644
--- a/lustre/mds/lproc_mds.c
+++ b/lustre/mds/lproc_mds.c
@@ -403,6 +403,31 @@ static int lprocfs_rd_nosquash_nid(char *page, char **start, off_t off,
                         libcfs_nid2str(mds->mds_nosquash_nid));
 }
 
+static int lprocfs_mds_rd_sync_perm(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{
+        struct obd_device* obd = (struct obd_device *)data;
+
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%d\n", obd->u.mds.mds_sync_permission);
+}
+
+static int lprocfs_mds_wr_sync_perm(struct file *file, const char *buffer,
+                                    unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        obd->u.mds.mds_sync_permission = !!val;
+
+        return count;
+}
+
 struct lprocfs_vars lprocfs_mds_obd_vars[] = {
         { "uuid",            lprocfs_rd_uuid,        0, 0 },
         { "blocksize",       lprocfs_rd_blksize,     0, 0 },
@@ -451,6 +476,13 @@ struct lprocfs_vars lprocfs_mds_obd_vars[] = {
                              lprocfs_wr_rootsquash, 0 },
         { "nosquash_nid",    lprocfs_rd_nosquash_nid,
                              lprocfs_wr_nosquash_nid, 0 },
+        { "sync_permission", lprocfs_mds_rd_sync_perm,
+                             lprocfs_mds_wr_sync_perm, 0 },
+#ifdef HAVE_DELAYED_RECOVERY
+        { "stale_export_age", lprocfs_obd_rd_stale_export_age,
+                              lprocfs_obd_wr_stale_export_age, 0},
+        { "flush_stale_exports", 0, lprocfs_obd_wr_flush_stale_exports, 0 },
+#endif
         { 0 }
 };
 
diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c
index c3c6ef1..a48a69c 100644
--- a/lustre/mds/mds_fs.c
+++ b/lustre/mds/mds_fs.c
@@ -85,7 +85,7 @@ int mds_export_stats_init(struct obd_device *obd,
                 num_stats = (sizeof(*obd->obd_type->typ_ops) / sizeof(void *)) +
                              LPROC_MDS_LAST - 1;
                 tmp->nid_stats = lprocfs_alloc_stats(num_stats,
-                                                     LPROCFS_STATS_FLAG_NOPERCPU);
+                                            LPROCFS_STATS_FLAG_NOPERCPU);
                 if (tmp->nid_stats == NULL)
                         return -ENOMEM;
 
@@ -98,9 +98,9 @@ int mds_export_stats_init(struct obd_device *obd,
                 mds_stats_counter_init(tmp->nid_stats);
 
                 /* Always add in ldlm_stats */
-                tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC -
-                                                          LDLM_FIRST_OPC,
-                                                          0);
+                tmp->nid_ldlm_stats =
+                        lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC,
+                                            LPROCFS_STATS_FLAG_NOPERCPU);
                 if (tmp->nid_ldlm_stats == NULL)
                         return -ENOMEM;
 
@@ -115,6 +115,58 @@ int mds_export_stats_init(struct obd_device *obd,
         return 0;
 }
 
+/* VBR: to determine the delayed client the lcd should be updated for each new
+ * epoch */
+int mds_update_client_epoch(struct obd_export *exp)
+{
+        struct mds_export_data *med = &exp->exp_mds_data;
+        struct mds_obd *mds = &exp->exp_obd->u.mds;
+        struct lvfs_run_ctxt saved;
+        loff_t off = med->med_lr_off;
+        int rc = 0;
+
+        /* VBR: set client last_epoch to current epoch */
+        if (le32_to_cpu(med->med_lcd->lcd_last_epoch) >=
+                        le32_to_cpu(mds->mds_server_data->lsd_start_epoch))
+                return rc;
+
+        med->med_lcd->lcd_last_epoch = mds->mds_server_data->lsd_start_epoch;
+        push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
+        rc = fsfilt_write_record(exp->exp_obd, mds->mds_rcvd_filp,
+                                 med->med_lcd, sizeof(*med->med_lcd), &off,
+                                 exp->exp_delayed);
+        pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
+
+        CDEBUG(D_INFO, "update client idx %u last_epoch %#x (%#x)\n",
+               med->med_lr_idx, le32_to_cpu(med->med_lcd->lcd_last_epoch),
+               le32_to_cpu(mds->mds_server_data->lsd_start_epoch));
+
+        return rc;
+}
+
+/* Called after recovery is done on server */
+void mds_update_last_epoch(struct obd_device *obd)
+{
+        struct ptlrpc_request *req;
+        struct mds_obd *mds = &obd->u.mds;
+        __u32 start_epoch;
+
+        /* Increase server epoch after recovery */
+        spin_lock(&mds->mds_transno_lock);
+        start_epoch = lr_epoch(mds->mds_last_transno) + 1;
+        mds->mds_last_transno = (__u64)start_epoch << LR_EPOCH_BITS;
+        mds->mds_server_data->lsd_start_epoch = cpu_to_le32(start_epoch);
+        spin_unlock(&mds->mds_transno_lock);
+
+        /* go through delayed reply queue to find all exports participate in
+         * recovery and set new epoch for them */
+        list_for_each_entry(req, &obd->obd_delayed_reply_queue, rq_list) {
+                LASSERT(!req->rq_export->exp_delayed);
+                mds_update_client_epoch(req->rq_export);
+        }
+        mds_update_server_data(obd, 1);
+}
+
 /* Add client data to the MDS.  We use a bitmap to locate a free space
  * in the last_rcvd file if cl_off is -1 (i.e. a new client).
  * Otherwise, we have just read the data from the last_rcvd file and
@@ -130,7 +182,7 @@ int mds_client_add(struct obd_device *obd, struct obd_export *exp,
         struct mds_export_data *med = &exp->exp_mds_data;
         unsigned long *bitmap = mds->mds_client_bitmap;
         int new_client = (cl_idx == -1);
-        int rc;
+        int rc = 0;
         ENTRY;
 
         LASSERT(bitmap != NULL);
@@ -140,6 +192,10 @@ int mds_client_add(struct obd_device *obd, struct obd_export *exp,
         if (!strcmp(med->med_lcd->lcd_uuid, obd->obd_uuid.uuid))
                 RETURN(0);
 
+        /* VBR: remove expired exports before searching for free slot */
+        if (new_client)
+                class_disconnect_expired_exports(obd);
+
         /* the bitmap operations can handle cl_idx > sizeof(long) * 8, so
          * there's no need for extra complication here
          */
@@ -193,6 +249,14 @@ int mds_client_add(struct obd_device *obd, struct obd_export *exp,
                         rc = PTR_ERR(handle);
                         CERROR("unable to start transaction: rc %d\n", rc);
                 } else {
+                        /* VBR: set client last_transno as mds_last_transno to
+                         * remember last epoch for this client */
+                        med->med_lcd->lcd_last_epoch =
+                                        mds->mds_server_data->lsd_start_epoch;
+                        exp->exp_last_request_time = cfs_time_current_sec();
+                        /* remember first epoch of client for orphan handling */
+                        med->med_lcd->lcd_first_epoch =
+                                  cpu_to_le32(lr_epoch(mds->mds_last_transno));
                         rc = fsfilt_add_journal_cb(obd, 0, handle,
                                                    target_client_add_cb, exp);
                         if (rc == 0) {
@@ -215,11 +279,11 @@ int mds_client_add(struct obd_device *obd, struct obd_export *exp,
                        med->med_lr_idx, med->med_lr_off,
                        (unsigned int)sizeof(*med->med_lcd));
         }
-        return 0;
+        return rc;
 }
 
 struct lsd_client_data zero_lcd; /* globals are implicitly zeroed */
-
+ 
 int mds_client_free(struct obd_export *exp)
 {
         struct mds_export_data *med = &exp->exp_mds_data;
@@ -266,7 +330,6 @@ int mds_client_free(struct obd_export *exp)
                  * or it does num_clients * num_osts syncs.  b=17194 */
                 int need_sync = (!exp->exp_libclient || exp->exp_need_sync) &&
                                  !(exp->exp_flags & OBD_OPT_ABORT_RECOV);
-
                 OBD_SLAB_ALLOC_PTR(saved, obd_lvfs_ctxt_cache);
                 if (saved == NULL) {
                         CERROR("cannot allocate memory for run ctxt\n");
@@ -316,6 +379,85 @@ static int mds_server_free_data(struct mds_obd *mds)
         return 0;
 }
 
+static void mds_add_fake_export(struct obd_device *obd, int num,
+                                struct file *file)
+{
+        struct obd_export *exp;
+        struct lvfs_run_ctxt saved;
+        struct obd_device_target *obt = &obd->u.obt;
+        struct lu_export_data *led;
+        unsigned long *bitmap = obt->obt_client_bitmap;
+        struct lsd_client_data *lcd = NULL;
+        unsigned int idx = 0;
+        loff_t off = 0;
+        int rc = 0;
+
+        while (num > 0) {
+                num--;
+                if (!lcd) {
+                        OBD_ALLOC_PTR(lcd);
+                        if (!lcd)
+                                return;
+                }
+                idx = find_next_zero_bit(bitmap, LR_MAX_CLIENTS, idx);
+                if (idx >= LR_MAX_CLIENTS) {
+                        CERROR("no room for %u clients - fix LR_MAX_CLIENTS\n", idx);
+                        OBD_FREE_PTR(lcd);
+                        break;
+                }
+                if (test_and_set_bit(idx, bitmap)) {
+                        CERROR("Bit %u is set already\n", idx);
+                        continue;
+                }
+                off = le32_to_cpu(obt->obt_lsd->lsd_client_start) +
+                      idx * le16_to_cpu(obt->obt_lsd->lsd_client_size);
+
+                sprintf(lcd->lcd_uuid, "dead-%.16u", idx);
+                CDEBUG(D_INFO, "Create fake export %s, index %u, offset %lu\n",
+                       lcd->lcd_uuid, idx, (unsigned long)off);
+
+                exp = class_new_export(obd, (struct obd_uuid *)lcd->lcd_uuid);
+                if (IS_ERR(exp)) {
+                        if (PTR_ERR(exp) == -EALREADY) {
+                                CERROR("Export %s already exists\n",
+                                       lcd->lcd_uuid);
+                        }
+                        CERROR("Failed to create export %lu\n", PTR_ERR(exp));
+                        OBD_FREE_PTR(lcd);
+                        break;
+                }
+                LASSERT(exp);
+                led = &exp->exp_target_data;
+                led->led_lr_idx = idx;
+                led->led_lr_off = off;
+                led->led_lcd = lcd;
+
+                exp->exp_last_request_time = cfs_time_current_sec();
+                exp->exp_replay_needed = 1;
+                exp->exp_connecting = 0;
+                exp->exp_in_recovery = 0;
+
+                spin_lock_bh(&obd->obd_processing_task_lock);
+                obd->obd_recoverable_clients++;
+                obd->obd_max_recoverable_clients++;
+                spin_unlock_bh(&obd->obd_processing_task_lock);
+
+                class_set_export_delayed(exp);
+                class_export_put(exp);
+
+                lcd->lcd_last_epoch = cpu_to_le32(1);
+                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+                rc = fsfilt_write_record(obd, file, lcd, sizeof(*lcd), &off, 0);
+                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+                if (rc) {
+                        CERROR("Failed to create fake client record\n");
+                        OBD_FREE_PTR(lcd);
+                        break;
+                }
+                lcd = NULL;
+        }
+}
+
 static int mds_init_server_data(struct obd_device *obd, struct file *file)
 {
         struct mds_obd *mds = &obd->u.mds;
@@ -324,6 +466,7 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file)
         loff_t off = 0;
         unsigned long last_rcvd_size = i_size_read(file->f_dentry->d_inode);
         __u64 mount_count;
+        __u32 start_epoch;
         int cl_idx, rc = 0;
         ENTRY;
 
@@ -394,9 +537,13 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file)
 
         lsd->lsd_feature_compat = cpu_to_le32(OBD_COMPAT_MDT);
 
+        target_trans_table_init(obd);
         mds->mds_last_transno = le64_to_cpu(lsd->lsd_last_transno);
+        start_epoch = le32_to_cpu(lsd->lsd_start_epoch);
 
-        CDEBUG(D_INODE, "%s: server last_transno: "LPU64"\n",
+        CDEBUG(D_INODE, "%s: server start_epoch: %#x\n",
+               obd->obd_name, start_epoch);
+        CDEBUG(D_INODE, "%s: server last_transno: "LPX64"\n",
                obd->obd_name, mds->mds_last_transno);
         CDEBUG(D_INODE, "%s: server mount_count: "LPU64"\n",
                obd->obd_name, mount_count + 1);
@@ -425,6 +572,7 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file)
         for (cl_idx = 0, off = le32_to_cpu(lsd->lsd_client_start);
              off < last_rcvd_size; cl_idx++) {
                 __u64 last_transno;
+                __u32 last_epoch;
                 struct obd_export *exp;
                 struct mds_export_data *med;
 
@@ -452,10 +600,8 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file)
                         continue;
                 }
 
-                last_transno = le64_to_cpu(lcd->lcd_last_transno) >
-                               le64_to_cpu(lcd->lcd_last_close_transno) ?
-                               le64_to_cpu(lcd->lcd_last_transno) :
-                               le64_to_cpu(lcd->lcd_last_close_transno);
+                last_transno = lsd_last_transno(lcd);
+                last_epoch = le32_to_cpu(lcd->lcd_last_epoch);
 
                 /* These exports are cleaned up by mds_disconnect(), so they
                  * need to be set up like real exports as mds_connect() does.
@@ -480,26 +626,42 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file)
                         /* can't fail for existing client */
                         LASSERTF(rc == 0, "rc = %d\n", rc);
 
+                        /* VBR: set export last committed version */
+                        exp->exp_last_committed = last_transno;
+                        /* read last time from disk */
+                        exp->exp_last_request_time = target_trans_table_last_time(exp);
                         lcd = NULL;
 
                         spin_lock(&exp->exp_lock);
                         exp->exp_replay_needed = 1;
                         exp->exp_connecting = 0;
+                        exp->exp_in_recovery = 0;
                         spin_unlock(&exp->exp_lock);
 
+                        spin_lock_bh(&obd->obd_processing_task_lock);
                         obd->obd_recoverable_clients++;
                         obd->obd_max_recoverable_clients++;
+                        spin_unlock_bh(&obd->obd_processing_task_lock);
+
+                        /* VBR: if epoch too old mark export as delayed,
+                         * if epoch is zero then client is pre-vbr one */
+                        if (start_epoch > last_epoch && last_epoch != 0)
+                                class_set_export_delayed(exp);
                         class_export_put(exp);
                 }
 
                 /* Need to check last_rcvd even for duplicated exports. */
-                CDEBUG(D_OTHER, "client at idx %d has last_transno = "LPU64"\n",
-                       cl_idx, last_transno);
+                CDEBUG(D_OTHER, "client at idx %d has last_transno = "LPX64","
+                       "last_epoch %#x\n", cl_idx, last_transno, last_epoch);
 
                 if (last_transno > mds->mds_last_transno)
                         mds->mds_last_transno = last_transno;
         }
 
+        if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_TGT_FAKE_EXP))) {
+                mds_add_fake_export(obd, obd_fail_val, file);
+        }
+
         if (lcd)
                 OBD_FREE_PTR(lcd);
 
@@ -507,8 +669,9 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file)
 
         if (obd->obd_recoverable_clients) {
                 CWARN("RECOVERY: service %s, %d recoverable clients, "
-                      "last_transno "LPU64"\n", obd->obd_name,
-                      obd->obd_recoverable_clients, mds->mds_last_transno);
+                      "%d delayed clients, last_transno "LPU64"\n",
+                      obd->obd_name, obd->obd_recoverable_clients,
+                      obd->obd_delayed_clients, mds->mds_last_transno);
                 obd->obd_next_recovery_transno = obd->obd_last_committed + 1;
                 obd->obd_recovering = 1;
                 obd->obd_recovery_start = 0;
@@ -518,8 +681,11 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file)
                 /* bz13079: this won't be changed for mds */
                 obd->obd_recovery_max_time = OBD_RECOVERY_MAX_TIME;
 #endif
+        } else {
+                LASSERT(!obd->obd_recovering);
+                /* VBR: update boot epoch after recovery */
+                mds_update_last_epoch(obd);
         }
-
         mds->mds_mount_count = mount_count + 1;
         lsd->lsd_mount_count = lsd->lsd_compat14 =
                 cpu_to_le64(mds->mds_mount_count);
@@ -562,6 +728,8 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
         mds->mds_vfsmnt = mnt;
         /* why not mnt->mnt_sb instead of mnt->mnt_root->d_inode->i_sb? */
         obd->u.obt.obt_sb = mnt->mnt_root->d_inode->i_sb;
+        obd->u.obt.obt_stale_export_age = STALE_EXPORT_MAXTIME_DEFAULT;
+        spin_lock_init(&obd->u.obt.obt_trans_table_lock);
 
         rc = fsfilt_setup(obd, obd->u.obt.obt_sb);
         if (rc)
@@ -575,7 +743,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
 
         /* setup the directory tree */
         push_ctxt(saved, &obd->obd_lvfs_ctxt, NULL);
-        dentry = simple_mkdir(current->fs->pwd, mnt, "ROOT", 0755, 0);
+        dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, "ROOT", 0755, 0);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create ROOT directory: rc = %d\n", rc);
@@ -588,7 +756,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
 
         dput(dentry);
 
-        dentry = lookup_one_len("__iopen__", current->fs->pwd,
+        dentry = lookup_one_len("__iopen__", cfs_fs_pwd(current->fs),
                                 strlen("__iopen__"));
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
@@ -603,7 +771,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
                 GOTO(err_fid, rc);
         }
 
-        dentry = simple_mkdir(current->fs->pwd, mnt, "PENDING", 0777, 1);
+        dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, "PENDING", 0777, 1);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create PENDING directory: rc = %d\n", rc);
@@ -612,7 +780,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
         mds->mds_pending_dir = dentry;
 
         /* COMPAT_146 */
-        dentry = simple_mkdir(current->fs->pwd, mnt, MDT_LOGS_DIR, 0777, 1);
+        dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, MDT_LOGS_DIR, 0777, 1);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create %s directory: rc = %d\n",
@@ -622,7 +790,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
         mds->mds_logs_dir = dentry;
         /* end COMPAT_146 */
 
-        dentry = simple_mkdir(current->fs->pwd, mnt, "OBJECTS", 0777, 1);
+        dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, "OBJECTS", 0777, 1);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
@@ -663,7 +831,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
                 CERROR("cannot open/create %s file: rc = %d\n",HEALTH_CHECK,rc);
                 GOTO(err_lov_objid, rc = PTR_ERR(file));
         }
-        mds->mds_health_check_filp = file;
+        mds->mds_obt.obt_health_check_filp = file;
         if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
                 CERROR("%s is not a regular file!: mode = %o\n", HEALTH_CHECK,
                        file->f_dentry->d_inode->i_mode);
@@ -678,8 +846,8 @@ err_pop:
         return rc;
 
 err_health_check:
-        if (mds->mds_health_check_filp &&
-            filp_close(mds->mds_health_check_filp, 0))
+        if (mds->mds_obt.obt_health_check_filp &&
+            filp_close(mds->mds_obt.obt_health_check_filp, 0))
                 CERROR("can't close %s after error\n", HEALTH_CHECK);
 err_lov_objid:
          mds_lov_destroy_objids(obd);
@@ -728,9 +896,9 @@ int mds_fs_cleanup(struct obd_device *obd)
 
         mds_lov_destroy_objids(obd);
 
-        if (mds->mds_health_check_filp) {
-                rc = filp_close(mds->mds_health_check_filp, 0);
-                mds->mds_health_check_filp = NULL;
+        if (mds->mds_obt.obt_health_check_filp) {
+                rc = filp_close(mds->mds_obt.obt_health_check_filp, 0);
+                mds->mds_obt.obt_health_check_filp = NULL;
                 if (rc)
                         CERROR("%s file won't close, rc=%d\n", HEALTH_CHECK,rc);
         }
@@ -753,7 +921,7 @@ int mds_fs_cleanup(struct obd_device *obd)
         OBD_SLAB_FREE_PTR(saved, obd_lvfs_ctxt_cache);
         shrink_dcache_parent(mds->mds_fid_de);
         dput(mds->mds_fid_de);
-        LL_DQUOT_OFF(obd->u.obt.obt_sb);
+        LL_DQUOT_OFF(obd->u.obt.obt_sb, 0);
 
         return rc;
 }
@@ -767,8 +935,8 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
         struct mds_obd *mds = &exp->exp_obd->u.mds;
         struct inode *parent_inode = mds->mds_objects_dir->d_inode;
         unsigned int tmpname = ll_rand();
-        struct file *filp;
-        struct dentry *new_child;
+        struct dentry *dchild, *new_child;
+        struct lvfs_dentry_params dp = LVFS_DENTRY_PARAMS_INIT;
         struct lvfs_run_ctxt *saved = NULL;
         char fidname[LL_FID_NAMELEN];
         void *handle;
@@ -787,31 +955,32 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
 
         push_ctxt(saved, &exp->exp_obd->obd_lvfs_ctxt, &ucred);
 
-        sprintf(fidname, "OBJECTS/%u.%u", tmpname, current->pid);
-        filp = filp_open(fidname, O_CREAT | O_EXCL, 0666);
-        if (IS_ERR(filp)) {
-                rc = PTR_ERR(filp);
-                if (rc == -EEXIST) {
-                        CERROR("impossible object name collision %u\n",
-                               tmpname);
-                        LBUG();
-                }
-                CERROR("error creating tmp object %u: rc %d\n", tmpname, rc);
-                GOTO(out_pop, rc);
+        sprintf(fidname, "%u.%u", tmpname, current->pid);
+        dchild = lookup_one_len(fidname, mds->mds_objects_dir, strlen(fidname));
+        if (IS_ERR(dchild)) {
+                CERROR("getting neg dentry for obj: %u\n", tmpname);
+                GOTO(out_pop, rc = PTR_ERR(dchild));
+        }
+        if (dchild->d_inode != NULL) {
+                CERROR("impossible non-negative obj dentry: %u\n", tmpname);
+                LBUG();
         }
 
-        LASSERT(mds->mds_objects_dir == filp->f_dentry->d_parent);
+        dchild->d_fsdata = (void *)&dp;
+        dp.ldp_ptr   = (void *)DP_LASTGROUP_REVERSE;
 
-        oa->o_id = filp->f_dentry->d_inode->i_ino;
-        oa->o_generation = filp->f_dentry->d_inode->i_generation;
+        LOCK_INODE_MUTEX(parent_inode);
+        rc = ll_vfs_create(parent_inode, dchild, S_IFREG | 0666, NULL);
+
+        oa->o_id = dchild->d_inode->i_ino;
+        oa->o_generation = dchild->d_inode->i_generation;
         namelen = ll_fid2str(fidname, oa->o_id, oa->o_generation);
 
-        LOCK_INODE_MUTEX(parent_inode);
         new_child = lookup_one_len(fidname, mds->mds_objects_dir, namelen);
 
         if (IS_ERR(new_child)) {
                 CERROR("getting neg dentry for obj rename: %d\n", rc);
-                GOTO(out_close, rc = PTR_ERR(new_child));
+                GOTO(out_dput, rc = PTR_ERR(new_child));
         }
         if (new_child->d_inode != NULL) {
                 CERROR("impossible non-negative obj dentry " LPU64":%u!\n",
@@ -822,12 +991,11 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
         handle = fsfilt_start(exp->exp_obd, mds->mds_objects_dir->d_inode,
                               FSFILT_OP_RENAME, NULL);
         if (IS_ERR(handle))
-                GOTO(out_dput, rc = PTR_ERR(handle));
+                GOTO(out_dput2, rc = PTR_ERR(handle));
 
         lock_kernel();
-        rc = ll_vfs_rename(mds->mds_objects_dir->d_inode, filp->f_dentry,
-                           filp->f_vfsmnt, mds->mds_objects_dir->d_inode,
-                           new_child, filp->f_vfsmnt);
+        rc = ll_vfs_rename(parent_inode, dchild, mds->mds_vfsmnt,
+                           parent_inode, new_child, mds->mds_vfsmnt);
         unlock_kernel();
         if (rc)
                 CERROR("error renaming new object "LPU64":%u: rc %d\n",
@@ -839,16 +1007,11 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
                 oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGENER;
         else if (!rc)
                 rc = err;
-out_dput:
+out_dput2:
         dput(new_child);
-out_close:
+out_dput:
+        dput(dchild);
         UNLOCK_INODE_MUTEX(parent_inode);
-        err = filp_close(filp, 0);
-        if (err) {
-                CERROR("closing tmpfile %u: rc %d\n", tmpname, rc);
-                if (!rc)
-                        rc = err;
-        }
 out_pop:
         pop_ctxt(saved, &exp->exp_obd->obd_lvfs_ctxt, &ucred);
         OBD_SLAB_FREE_PTR(saved, obd_lvfs_ctxt_cache);
diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h
index f8fb96f..3516d6f 100644
--- a/lustre/mds/mds_internal.h
+++ b/lustre/mds/mds_internal.h
@@ -41,9 +41,10 @@
 #include <lustre_mds.h>
 
 #define MDT_ROCOMPAT_SUPP       (OBD_ROCOMPAT_LOVOBJID)
-#define MDT_INCOMPAT_SUPP       (OBD_INCOMPAT_MDT | OBD_INCOMPAT_COMMON_LR)
+#define MDT_INCOMPAT_SUPP       (OBD_INCOMPAT_MDT | OBD_INCOMPAT_COMMON_LR | \
+                                 OBD_INCOMPAT_FID)
 
-#define MDS_SERVICE_WATCHDOG_FACTOR 2000
+#define MDS_SERVICE_WATCHDOG_FACTOR 2
 
 #define MAX_ATIME_DIFF 60
 
@@ -51,7 +52,9 @@ struct mds_filter_data {
         __u64 io_epoch;
 };
 
-#define MDS_FILTERDATA(inode) ((struct mds_filter_data *)(inode)->i_filterdata)
+#define MDS_FILTERDATA(inode) \
+                ((struct mds_filter_data *)INODE_PRIVATE_DATA(inode))
+
 
 static inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
 {
@@ -94,6 +97,13 @@ static inline int mds_orphan_open_count(struct inode *inode)
         return mds_inode_oatomic(inode);
 }
 
+static inline int mds_orphan_needed(struct obd_device *obd,
+                                    struct inode * inode)
+{
+        return (obd->obd_recovering ||
+                mds_orphan_open_count(inode) > 0);
+}
+
 static inline int mds_orphan_open_inc(struct inode *inode)
 {
         LASSERT_MDS_ORPHAN_WRITE_LOCKED(inode);
@@ -150,9 +160,8 @@ int enqueue_ordered_locks(struct obd_device *obd, struct ldlm_res_id *p1_res_id,
                           struct lustre_handle *p2_lockh, int p2_lock_mode,
                           ldlm_policy_data_t *p2_policy);
 void mds_commit_cb(struct obd_device *, __u64 last_rcvd, void *data, int error);
-int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
-                       struct ptlrpc_request *req, int rc, __u32 op_data,
-                       int force_sync);
+int mds_finish_transno(struct mds_obd *, struct inode **, void *,
+                       struct ptlrpc_request *, int, __u32, int force_sync);
 void mds_reconstruct_generic(struct ptlrpc_request *req);
 void mds_req_from_lcd(struct ptlrpc_request *req, struct lsd_client_data *cd);
 int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
@@ -184,9 +193,15 @@ int mds_get_parents_children_locked(struct obd_device *obd,
                                     struct lustre_handle *dlm_handles,
                                     int child_mode);
 
+struct dentry *mds_lookup(struct obd_device *obd,
+                          const char *fid_name,
+                          struct dentry *dparent,
+                          int fid_namelen);
+
 void mds_shrink_reply(struct obd_device *obd, struct ptlrpc_request *req,
                       struct mds_body *body, int md_off);
 int mds_get_cookie_size(struct obd_device *obd, struct lov_mds_md *lmm);
+int mds_version_get_check(struct ptlrpc_request *, struct inode *, int);
 /* mds/mds_lib.c */
 int mds_update_unpack(struct ptlrpc_request *, int offset,
                       struct mds_update_record *);
@@ -202,11 +217,13 @@ int mds_osc_destroy_orphan(struct obd_device *obd, umode_t mode,
                            struct lov_mds_md *lmm, int lmm_size,
                            struct llog_cookie *logcookies, int log_unlink);
 int mds_cleanup_pending(struct obd_device *obd);
+int mds_check_stale_orphan(struct obd_device *obd, struct ll_fid *fid);
 
 /* mds/mds_log.c */
 int mds_log_op_unlink(struct obd_device *obd,
                       struct lov_mds_md *lmm, int lmm_size,
                       struct llog_cookie *logcookies, int cookies_size);
+int mds_log_op_orphan(struct obd_device *, struct lov_stripe_md *, obd_count);
 int mds_log_op_setattr(struct obd_device *obd, struct inode *inode,
                       struct lov_mds_md *lmm, int lmm_size,
                       struct llog_cookie *logcookies, int cookies_size);
@@ -232,7 +249,8 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched,
 int mds_get_default_md(struct obd_device *obd, struct lov_mds_md *lmm,
                        int *lmmsize);
 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
-                       struct lov_mds_md *lmm, int lmm_size);
+                       struct lov_mds_md *lmm, int lmm_size,
+                       __u64 connect_flags);
 int mds_init_lov_desc(struct obd_device *obd, struct obd_export *osc_exp);
 
 /* mds/mds_open.c */
@@ -254,6 +272,8 @@ int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req,
                   struct dentry *dchild, struct lustre_handle *lockh);
 
 /* mds/mds_fs.c */
+int mds_update_client_epoch(struct obd_export *exp);
+void mds_update_last_epoch(struct obd_device *obd);
 int mds_export_stats_init(struct obd_device *obd,
                           struct obd_export *exp,
                           void *client_nid);
@@ -274,10 +294,10 @@ int mds_postrecov(struct obd_device *obd);
 int mds_init_export(struct obd_export *exp);
 #ifdef __KERNEL__
 int mds_get_md(struct obd_device *, struct inode *, void *md, int *size,
-               int lock, int flags);
+               int lock, int flags, __u64 connect_flags);
 int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
-                struct mds_body *, struct inode *, int lock, int flags);
-void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode);
+                struct mds_body *, struct inode *, int lock, int flags,
+                __u64 connect_flags);
 void mds_pack_inode2body(struct mds_body *body, struct inode *inode);
 #endif
 int mds_pack_acl(struct mds_export_data *med, struct inode *inode,
diff --git a/lustre/mds/mds_join.c b/lustre/mds/mds_join.c
index 3064ecb..d5578f6 100644
--- a/lustre/mds/mds_join.c
+++ b/lustre/mds/mds_join.c
@@ -86,7 +86,8 @@ static int mds_insert_join_lmm(struct llog_handle *llh,
         ENTRY;
 
 
-        sz_med = lov_mds_md_size(le32_to_cpu(lmm->lmm_stripe_count));
+        sz_med = lov_mds_md_size(le32_to_cpu(lmm->lmm_stripe_count),
+                                 LOV_MAGIC);
         sz_med += 2 * sizeof(__u64);
         sz_med = size_round(sz_med);
 
@@ -102,7 +103,8 @@ static int mds_insert_join_lmm(struct llog_handle *llh,
         med->med_start = start;
         med->med_len = len;
         memcpy(&med->med_lmm, lmm,
-                lov_mds_md_size(le32_to_cpu(lmm->lmm_stripe_count)));
+                lov_mds_md_size(le32_to_cpu(lmm->lmm_stripe_count),
+                                LOV_MAGIC));
 
         rc = llog_write_rec(llh, &rec, NULL, 0, med, -1);
         OBD_FREE(med, sz_med);
@@ -173,11 +175,12 @@ static int mdsea_cancel_last_extent(struct llog_handle *llh_tail,
                        med->med_start, cbdata->mc_headfile_sz);
                 if (!cbdata->mc_lmm) {
                         int stripe = le32_to_cpu(med->med_lmm.lmm_stripe_count);
-                        OBD_ALLOC(cbdata->mc_lmm, lov_mds_md_size(stripe));
+                        OBD_ALLOC(cbdata->mc_lmm,
+                                  lov_mds_md_size(stripe, LOV_MAGIC));
                         if (!cbdata->mc_lmm)
                                 RETURN(-ENOMEM);
                         memcpy(cbdata->mc_lmm, &med->med_lmm,
-                               lov_mds_md_size(stripe));
+                               lov_mds_md_size(stripe, LOV_MAGIC));
                 }
                 RETURN(LLOG_DEL_RECORD);
         }
@@ -220,7 +223,8 @@ static int  mds_adjust_last_extent(struct llog_handle *llh_head,
 exit:
         if (cbdata && cbdata->mc_lmm)
                 OBD_FREE(cbdata->mc_lmm,
-                         lov_mds_md_size(cbdata->mc_lmm->lmm_stripe_count));
+                         lov_mds_md_size(cbdata->mc_lmm->lmm_stripe_count,
+                                         LOV_MAGIC));
         if (cbdata)
                 OBD_FREE_PTR(cbdata);
 
@@ -254,7 +258,6 @@ static void mds_finish_join(struct mds_obd *mds, struct ptlrpc_request *req,
                 CDEBUG(D_INODE, "updating max_mdsize/max_cookiesize: %d/%d\n",
                        mds->mds_max_mdsize, mds->mds_max_cookiesize);
 
-        mds_pack_inode2fid(&body->fid1, inode);
         mds_pack_inode2body(body, inode);
 }
 
@@ -278,7 +281,7 @@ static int mds_join_unlink_tail_inode(struct mds_update_record *rec,
                 ldlm_lock_decref(lockh, LCK_EX);
 
         head_inode = dchild->d_inode;
-        mdc_pack_fid(&head_fid, head_inode->i_ino, head_inode->i_generation,
+        ll_pack_fid(&head_fid, head_inode->i_ino, head_inode->i_generation,
                       head_inode->i_mode & S_IFMT);
 
         rc = mds_get_parents_children_locked(obd, mds, &join_rec->jr_fid,
@@ -313,7 +316,8 @@ static int mds_join_unlink_tail_inode(struct mds_update_record *rec,
                 GOTO(cleanup, rc);
         }
 
-        rc = mds_get_md(obd, tail_inode, tail_lmm, &lmm_size, 1, 0);
+        rc = mds_get_md(obd, tail_inode, tail_lmm, &lmm_size, 1, 0,
+                        req->rq_export->exp_connect_flags);
         if (rc < 0) /* get md fails */
                 GOTO(cleanup, rc);
 
@@ -356,6 +360,7 @@ int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req,
 {
         struct mds_obd *mds = mds_req2mds(req);
         struct obd_device *obd = req->rq_export->exp_obd;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct inode *head_inode = NULL;
         struct lvfs_run_ctxt saved;
         void *handle = NULL;
@@ -403,7 +408,8 @@ int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req,
 
         LOCK_INODE_MUTEX(head_inode);
         cleanup_phase = 1;
-        rc = mds_get_md(obd, head_inode, head_lmm, &size, 0, 0);
+        rc = mds_get_md(obd, head_inode, head_lmm, &size, 0, 0,
+                        req->rq_export->exp_connect_flags);
         if (rc < 0)
                 GOTO(cleanup, rc);
 
@@ -498,7 +504,8 @@ int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req,
                       sizeof(struct lov_mds_md_join), "lov");
         mds_finish_join(mds, req, head_inode, head_lmmj);
 cleanup:
-        rc = mds_finish_transno(mds, head_inode, handle, req, rc, 0, 0);
+        inodes[0] = head_inode;
+        rc = mds_finish_transno(mds, inodes, handle, req, rc, 0, 0);
         switch(cleanup_phase){
         case 3:
                 llog_close(llh_head);
diff --git a/lustre/mds/mds_lib.c b/lustre/mds/mds_lib.c
index 9c91af7..5b16fba 100644
--- a/lustre/mds/mds_lib.c
+++ b/lustre/mds/mds_lib.c
@@ -61,7 +61,7 @@
 #include <lustre_lib.h>
 #include "mds_internal.h"
 
-void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode)
+static void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode)
 {
         fid->id = inode->i_ino;
         fid->generation = inode->i_generation;
@@ -80,6 +80,7 @@ void mds_pack_inode2body(struct mds_body *b, struct inode *inode)
                 b->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLATIME |
                             OBD_MD_FLMTIME | OBD_MD_FLRDEV;
 
+        mds_pack_inode2fid(&b->fid1, inode);
         b->ino = inode->i_ino;
         b->atime = LTIME_S(inode->i_atime);
         b->mtime = LTIME_S(inode->i_mtime);
@@ -89,9 +90,7 @@ void mds_pack_inode2body(struct mds_body *b, struct inode *inode)
         b->blocks = inode->i_blocks;
         b->uid = inode->i_uid;
         b->gid = inode->i_gid;
-        b->flags = (b->flags & MDS_BFLAG_EXT_FLAGS) |
-                    ll_inode_to_ext_flags(inode->i_flags,
-                                          !(b->flags & MDS_BFLAG_EXT_FLAGS));
+        b->flags = ll_inode_to_ext_flags(inode->i_flags, MDS_BFLAG_EXT_FLAGS);
         b->rdev = inode->i_rdev;
         /* Return the correct link count for orphan inodes */
         b->nlink = mds_inode_is_orphan(inode) ? 0 : inode->i_nlink;
@@ -235,7 +234,7 @@ static int mds_create_unpack(struct ptlrpc_request *req, int offset,
         if (lustre_msg_buflen(req->rq_reqmsg, offset + 3)) {
                 r->ur_dlm = lustre_swab_reqbuf(req, offset + 3,
                                                sizeof(*r->ur_dlm),
-                                               lustre_swab_ldlm_request); 
+                                               lustre_swab_ldlm_request);
                 if (r->ur_dlm == NULL)
                         RETURN (-EFAULT);
         }
@@ -303,7 +302,6 @@ static int mds_unlink_unpack(struct ptlrpc_request *req, int offset,
         if (r->ur_name == NULL)
                 RETURN(-EFAULT);
         r->ur_namelen = lustre_msg_buflen(req->rq_reqmsg, offset + 1);
-        
         if (lustre_msg_buflen(req->rq_reqmsg, offset + 2)) {
                 r->ur_dlm = lustre_swab_reqbuf(req, offset + 2,
                                                sizeof(*r->ur_dlm),
diff --git a/lustre/mds/mds_log.c b/lustre/mds/mds_log.c
index 2432035..ae85df1 100644
--- a/lustre/mds/mds_log.c
+++ b/lustre/mds/mds_log.c
@@ -66,6 +66,11 @@ static int mds_llog_origin_add(struct llog_ctxt *ctxt, struct llog_rec_hdr *rec,
         ENTRY;
 
         lctxt = llog_get_context(lov_obd, ctxt->loc_idx);
+        if (lctxt && lctxt->loc_flags & LLOG_CTXT_FLAG_UNINITIALIZED) {
+                llog_ctxt_put(lctxt);
+                RETURN(-EAGAIN);
+        }
+        /* "lctxt == NULL" will be checked in llog_add */
         rc = llog_add(lctxt, rec, lsm, logcookies, numcookies);
         llog_ctxt_put(lctxt);
 
@@ -104,14 +109,39 @@ static int mds_llog_repl_cancel(struct llog_ctxt *ctxt, struct lov_stripe_md *ls
         RETURN(rc);
 }
 
-int mds_log_op_unlink(struct obd_device *obd, 
+static int mds_llog_add_unlink(struct obd_device *obd,
+                               struct lov_stripe_md *lsm, obd_count count,
+                               struct llog_cookie *logcookie, int cookies)
+{
+        struct llog_unlink_rec *lur;
+        struct llog_ctxt *ctxt;
+        int rc;
+
+        rc = obd_checkmd(obd->u.mds.mds_osc_exp, obd->obd_self_export, lsm);
+        if (rc)
+                RETURN(rc);
+        /* first prepare unlink log record */
+        OBD_ALLOC_PTR(lur);
+        if (!lur)
+                RETURN(rc = -ENOMEM);
+        lur->lur_hdr.lrh_len = lur->lur_tail.lrt_len = sizeof(*lur);
+        lur->lur_hdr.lrh_type = MDS_UNLINK_REC;
+        lur->lur_count = count;
+
+        ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
+        rc = llog_add(ctxt, &lur->lur_hdr, lsm, logcookie, cookies);
+        llog_ctxt_put(ctxt);
+
+        OBD_FREE_PTR(lur);
+        RETURN(rc);
+}
+
+int mds_log_op_unlink(struct obd_device *obd,
                       struct lov_mds_md *lmm, int lmm_size,
                       struct llog_cookie *logcookies, int cookies_size)
 {
         struct mds_obd *mds = &obd->u.mds;
         struct lov_stripe_md *lsm = NULL;
-        struct llog_unlink_rec *lur;
-        struct llog_ctxt *ctxt;
         int rc;
         ENTRY;
 
@@ -121,24 +151,27 @@ int mds_log_op_unlink(struct obd_device *obd,
         rc = obd_unpackmd(mds->mds_osc_exp, &lsm, lmm, lmm_size);
         if (rc < 0)
                 RETURN(rc);
-        rc = obd_checkmd(mds->mds_osc_exp, obd->obd_self_export, lsm);
-        if (rc)
-                GOTO(out, rc);
-        /* first prepare unlink log record */
-        OBD_ALLOC(lur, sizeof(*lur));
-        if (!lur)
-                GOTO(out, rc = -ENOMEM);
-        lur->lur_hdr.lrh_len = lur->lur_tail.lrt_len = sizeof(*lur);
-        lur->lur_hdr.lrh_type = MDS_UNLINK_REC;
+        rc = mds_llog_add_unlink(obd, lsm, 0, logcookies,
+                                 cookies_size / sizeof(struct llog_cookie));
+        obd_free_memmd(mds->mds_osc_exp, &lsm);
+        RETURN(rc);
+}
 
-        ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT);
-        rc = llog_add(ctxt, &lur->lur_hdr, lsm, logcookies,
-                      cookies_size / sizeof(struct llog_cookie));
-        llog_ctxt_put(ctxt);
+int mds_log_op_orphan(struct obd_device *obd, struct lov_stripe_md *lsm,
+                      obd_count count)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        struct llog_cookie logcookie;
+        int rc;
+        ENTRY;
 
-        OBD_FREE(lur, sizeof(*lur));
-out:
-        obd_free_memmd(mds->mds_osc_exp, &lsm);
+        if (IS_ERR(mds->mds_osc_obd))
+                RETURN(PTR_ERR(mds->mds_osc_obd));
+
+        rc = obd_checkmd(mds->mds_osc_exp, obd->obd_self_export, lsm);
+        if (rc)
+                RETURN(rc);
+        rc = mds_llog_add_unlink(obd, lsm, count - 1, &logcookie, 1);
         RETURN(rc);
 }
 
diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c
index 7809783..45ff9f7 100644
--- a/lustre/mds/mds_lov.c
+++ b/lustre/mds/mds_lov.c
@@ -209,11 +209,11 @@ static int mds_lov_update_max_ost(struct mds_obd *mds, obd_id index)
                 stripes = min_t(__u32, LOV_MAX_STRIPE_COUNT,
                                 mds->mds_lov_objid_count);
 
-                mds->mds_max_mdsize = lov_mds_md_size(stripes);
+                mds->mds_max_mdsize = lov_mds_md_size(stripes, LOV_MAGIC_V3);
                 mds->mds_max_cookiesize = stripes * sizeof(struct llog_cookie);
-                CDEBUG(D_CONFIG, "updated max_mdsize/max_cookiesize for %d stripes: "
-                       "%d/%d\n", mds->mds_max_mdsize, mds->mds_max_cookiesize,
-                       stripes);
+                CDEBUG(D_CONFIG, "updated max_mdsize/max_cookiesize for %d "
+                       "stripes: %d/%d\n", mds->mds_max_mdsize,
+                       mds->mds_max_cookiesize, stripes);
         }
 
         EXIT;
@@ -224,14 +224,20 @@ int mds_lov_prepare_objids(struct obd_device *obd, struct lov_mds_md *lmm)
 {
         int rc = 0;
         __u32 j;
+        struct lov_ost_data_v1 *lmm_objects;
 
         /* if we create file without objects - lmm is NULL */
         if (lmm == NULL)
                 return 0;
 
         mutex_down(&obd->obd_dev_sem);
+        if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3)
+                lmm_objects = ((struct lov_mds_md_v3 *)lmm)->lmm_objects;
+        else
+                lmm_objects = lmm->lmm_objects;
+
         for (j = 0; j < le32_to_cpu(lmm->lmm_stripe_count); j++) {
-                __u32 i = le32_to_cpu(lmm->lmm_objects[j].l_ost_idx);
+                __u32 i = le32_to_cpu(lmm_objects[j].l_ost_idx);
                 if (mds_lov_update_max_ost(&obd->u.mds, i)) {
                         rc = -ENOMEM;
                         break;
@@ -243,19 +249,60 @@ int mds_lov_prepare_objids(struct obd_device *obd, struct lov_mds_md *lmm)
 }
 EXPORT_SYMBOL(mds_lov_prepare_objids);
 
+/*
+ * write llog orphan record about lost ost object,
+ * Special lsm is allocated with single stripe, caller should deallocated it
+ * after use
+ */
+static int mds_log_lost_precreated(struct obd_device *obd,
+                                   struct lov_stripe_md **lsmp, int *stripes,
+                                   obd_id id, obd_count count, int idx)
+{
+        struct lov_stripe_md *lsm = *lsmp;
+        int rc;
+        ENTRY;
+
+        if (*lsmp == NULL) {
+                rc = obd_alloc_memmd(obd->u.mds.mds_osc_exp, &lsm);
+                if (rc < 0)
+                        RETURN(rc);
+                /* need only one stripe, save old value */
+                *stripes = lsm->lsm_stripe_count;
+                lsm->lsm_stripe_count = 1;
+                *lsmp = lsm;
+        }
+
+        lsm->lsm_oinfo[0]->loi_id = id;
+        lsm->lsm_oinfo[0]->loi_gr = 0; /* needed in 2.0 */
+        lsm->lsm_oinfo[0]->loi_ost_idx = idx;
+
+        rc = mds_log_op_orphan(obd, lsm, count);
+        RETURN(rc);
+}
+
 void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm)
 {
         struct mds_obd *mds = &obd->u.mds;
         int j;
+        struct lov_ost_data_v1 *lmm_objects;
+#ifndef HAVE_DELAYED_RECOVERY
+        struct lov_stripe_md *lsm = NULL;
+        int stripes = 0;
+#endif
         ENTRY;
 
         /* if we create file without objects - lmm is NULL */
         if (lmm == NULL)
                 return;
 
+        if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3)
+                lmm_objects = ((struct lov_mds_md_v3 *)lmm)->lmm_objects;
+        else
+                lmm_objects = lmm->lmm_objects;
+
         for (j = 0; j < le32_to_cpu(lmm->lmm_stripe_count); j++) {
-                __u32 i = le32_to_cpu(lmm->lmm_objects[j].l_ost_idx);
-                obd_id id = le64_to_cpu(lmm->lmm_objects[j].l_object_id);
+                __u32 i = le32_to_cpu(lmm_objects[j].l_ost_idx);
+                obd_id id = le64_to_cpu(lmm_objects[j].l_object_id);
                 __u32 page = i / OBJID_PER_PAGE();
                 __u32 idx = i % OBJID_PER_PAGE();
                 obd_id *data;
@@ -265,10 +312,29 @@ void mds_lov_update_objids(struct obd_device *obd, struct lov_mds_md *lmm)
                 CDEBUG(D_INODE,"update last object for ost %u"
                        " - new "LPU64" old "LPU64"\n", i, id, data[idx]);
                 if (id > data[idx]) {
+#ifndef HAVE_DELAYED_RECOVERY
+                        int lost = id - data[idx] - 1;
+                        /* we might have lost precreated objects due to VBR */
+                        if (lost > 0 && obd->obd_recovering) {
+                                CDEBUG(D_HA, "GAP in objids is %u\n", lost);
+                                if (!obd->obd_version_recov)
+                                        CWARN("Unexpected gap in objids\n");
+                                /* lsm is allocated if NULL */
+                                mds_log_lost_precreated(obd, &lsm, &stripes,
+                                                        data[idx] + 1, lost, i);
+                        }
+#endif
                         data[idx] = id;
                         cfs_bitmap_set(mds->mds_lov_page_dirty, page);
                 }
         }
+#ifndef HAVE_DELAYED_RECOVERY
+        if (lsm) {
+                /* restore stripes number */
+                lsm->lsm_stripe_count = stripes;
+                obd_free_memmd(mds->mds_osc_exp, &lsm);
+        }
+#endif
         EXIT;
         return;
 }
@@ -288,7 +354,7 @@ static int mds_lov_update_from_read(struct mds_obd *mds, obd_id *data,
                 stripes = min_t(__u32, LOV_MAX_STRIPE_COUNT,
                                 mds->mds_lov_objid_count);
 
-                mds->mds_max_mdsize = lov_mds_md_size(stripes);
+                mds->mds_max_mdsize = lov_mds_md_size(stripes, LOV_MAGIC_V3);
                 mds->mds_max_cookiesize = stripes * sizeof(struct llog_cookie);
                 CDEBUG(D_CONFIG, "updated max_mdsize/max_cookiesize for %d stripes: "
                        "%d/%d\n", stripes, mds->mds_max_mdsize, mds->mds_max_cookiesize);
@@ -314,7 +380,7 @@ static int mds_lov_read_objids(struct obd_device *obd)
 
         page = (size/(OBJID_PER_PAGE()*sizeof(obd_id)))+1;
         CDEBUG(D_INFO, "file size %d pages %d\n", (int)size, page);
-        for(i=0; i < page; i++) {
+        for (i = 0; i < page; i++) {
                 obd_id *data;
                 loff_t off_old = off;
 
@@ -340,7 +406,7 @@ static int mds_lov_read_objids(struct obd_device *obd)
 
                 if (off == off_old)
                         break; /* eof */
-        }
+         }
          mds->mds_lov_objid_lastpage = i;
          mds->mds_lov_objid_lastidx = count;
 
@@ -374,7 +440,7 @@ int mds_lov_write_objids(struct obd_device *obd)
                 if (i == mds->mds_lov_objid_lastpage)
                         size = (mds->mds_lov_objid_lastidx + 1) * sizeof(obd_id);
 
-                CDEBUG(D_INFO, "write %lld - %u\n", off, size);
+                CDEBUG(D_INFO,"write %lld - %u\n", off, size);
                 rc = fsfilt_write_record(obd, mds->mds_lov_objid_filp, data,
                                          size, &off, 0);
                 if (rc < 0)
@@ -392,17 +458,21 @@ static int mds_lov_get_objid(struct obd_device * obd,
                              obd_id idx)
 {
         struct mds_obd *mds = &obd->u.mds;
+        struct obd_export *osc_exp = mds->mds_osc_exp;
         unsigned int page;
         unsigned int off;
         obd_id *data;
         int rc = 0;
         ENTRY;
 
+        LASSERT(osc_exp != NULL);
+
         page = idx / OBJID_PER_PAGE();
         off = idx % OBJID_PER_PAGE();
 
         data = mds->mds_lov_page_array[page];
-        if (data[off] < 2) {
+        if (data[off] < 2 || 
+            !(osc_exp->exp_connect_flags & OBD_CONNECT_SKIP_ORPHAN)) {
                 /* We never read this lastid; ask the osc */
                 struct obd_id_info lastid;
                 __u32 size = sizeof(lastid);
@@ -429,7 +499,7 @@ out:
 int mds_lov_clear_orphans(struct mds_obd *mds, struct obd_uuid *ost_uuid)
 {
         int rc;
-        struct obdo oa;
+        struct obdo oa = { 0 };
         struct obd_trans_info oti = {0};
         struct lov_stripe_md  *empty_ea = NULL;
         ENTRY;
@@ -615,7 +685,8 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name)
                 RETURN(-ENOMEM);
         data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_INDEX |
                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_QUOTA64 | OBD_CONNECT_AT |
-                OBD_CONNECT_CHANGE_QS | OBD_CONNECT_MDS;
+                OBD_CONNECT_CHANGE_QS | OBD_CONNECT_MDS |
+                OBD_CONNECT_SKIP_ORPHAN;
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #endif
@@ -852,7 +923,7 @@ int mds_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
         }
 
         case OBD_IOC_ABORT_RECOVERY:
-                CERROR("aborting recovery for device %s\n", obd->obd_name);
+                LCONSOLE_WARN("%s: Aborting recovery.\n", obd->obd_name);
                 target_abort_recovery(obd);
                 /* obd_recovering has been changed */
                 mds_allow_cli(obd, 0);
@@ -959,7 +1030,7 @@ out:
                 CERROR("%s sync failed %d, deactivating\n", obd_uuid2str(uuid),
                        rc);
                 if (!obd->obd_stopping && mds->mds_osc_obd &&
-                    !mds->mds_osc_obd->obd_stopping && !watched->obd_stopping) 
+                    !mds->mds_osc_obd->obd_stopping && !watched->obd_stopping)
                         obd_notify(mds->mds_osc_obd, watched,
                                    OBD_NOTIFY_INACTIVE, NULL);
         } else {
@@ -1055,7 +1126,9 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched,
                 break;
         case OBD_NOTIFY_CONFIG:
                 mds_allow_cli(obd, (unsigned long)data);
-
+                /* call this only when config is processed and stale_export_age
+                 * value is configured */
+                class_disconnect_expired_exports(obd);
                 /* quota_type has been processed, we can now handle
                  * incoming quota requests */
                 QUOTA_MASTER_READY(&obd->u.obt.obt_qctxt);
@@ -1087,7 +1160,8 @@ int mds_notify(struct obd_device *obd, struct obd_device *watched,
         rc = mds_lov_start_synchronize(obd, watched, data,
                                        !(ev == OBD_NOTIFY_SYNC));
 
-        lquota_recovery(mds_quota_interface_ref, obd);
+        if (likely(obd->obd_stopping == 0))
+                lquota_recovery(mds_quota_interface_ref, obd);
 
         RETURN(rc);
 }
@@ -1127,40 +1201,46 @@ int mds_get_default_md(struct obd_device *obd, struct lov_mds_md *lmm,
  * reason.  We will not delete the old lmm data until we have written the
  * new format lmm data in fsfilt_set_md(). */
 int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
-                       struct lov_mds_md *lmm, int lmm_size)
+                       struct lov_mds_md *lmm, int lmm_size,
+                       __u64 connect_flags)
 {
         struct lov_stripe_md *lsm = NULL;
         void *handle;
         int rc, err;
         ENTRY;
 
-        if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3) {
-                /* LOV_MAGIC_V3 ea, we have to convert it to V1
+        if (((connect_flags & OBD_CONNECT_LOV_V3) == 0) &&
+            (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3)) {
+                /* client does not support LOV_MAGIC_V3, so we have to convert
+                 * it to V1
                  * we convert the lmm from v3 to v1
                  * and return the new size (which is smaller)
-                 * the caller support this way to return the new size
-                 */
+                 * the caller supports this way to return the new size */
                 int new_lmm_size;
 
                 lmm->lmm_magic = cpu_to_le32(LOV_MAGIC_V1);
                 /* lmm_stripe_count for non reg files is not used or -1 */
                 if (!S_ISREG(inode->i_mode)) {
-                        new_lmm_size = lov_mds_md_size(0);
+                        new_lmm_size = lov_mds_md_size(0, LOV_MAGIC_V1);
                 } else {
-                        int count = le32_to_cpu(
-                               ((struct lov_mds_md_v3 *)lmm)->lmm_stripe_count);
-                        new_lmm_size = lov_mds_md_size(count);
+                        __u32 lmm_stripe_count;
+
+                        lmm_stripe_count = le32_to_cpu(lmm->lmm_stripe_count);
+                        new_lmm_size = lov_mds_md_size(lmm_stripe_count,
+                                                       LOV_MAGIC_V1);
+                        /* move the objects to the new place */
                         memmove(lmm->lmm_objects,
                                 ((struct lov_mds_md_v3 *)lmm)->lmm_objects,
-                                count * sizeof(struct lov_ost_data_v1));
+                                lmm_stripe_count * sizeof(struct lov_ost_data_v1));
                 }
                 /* even if new size is smaller than old one,
                  * this should not generate memory leak */
                 RETURN(new_lmm_size);
         }
 
-        if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC ||
-            le32_to_cpu(lmm->lmm_magic == LOV_MAGIC_JOIN))
+        if (le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V1 ||
+            le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_V3 ||
+            le32_to_cpu(lmm->lmm_magic) == LOV_MAGIC_JOIN)
                 RETURN(0);
 
         CDEBUG(D_INODE, "converting LOV EA on %lu/%u from %#08x to %#08x\n",
diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c
index 4457db0..41480df 100644
--- a/lustre/mds/mds_open.c
+++ b/lustre/mds/mds_open.c
@@ -138,9 +138,9 @@ void mds_mfd_unlink(struct mds_file_data *mfd, int decref)
 /* Caller must hold mds->mds_epoch_sem */
 static int mds_alloc_filterdata(struct inode *inode)
 {
-        LASSERT(inode->i_filterdata == NULL);
-        OBD_ALLOC(inode->i_filterdata, sizeof(struct mds_filter_data));
-        if (inode->i_filterdata == NULL)
+        LASSERT(INODE_PRIVATE_DATA(inode) == NULL);
+        OBD_ALLOC(INODE_PRIVATE_DATA(inode), sizeof(struct mds_filter_data));
+        if (INODE_PRIVATE_DATA(inode) == NULL)
                 return -ENOMEM;
         LASSERT(igrab(inode) == inode);
         return 0;
@@ -149,9 +149,9 @@ static int mds_alloc_filterdata(struct inode *inode)
 /* Caller must hold mds->mds_epoch_sem */
 static void mds_free_filterdata(struct inode *inode)
 {
-        LASSERT(inode->i_filterdata != NULL);
-        OBD_FREE(inode->i_filterdata, sizeof(struct mds_filter_data));
-        inode->i_filterdata = NULL;
+        LASSERT(INODE_PRIVATE_DATA(inode) != NULL);
+        OBD_FREE(INODE_PRIVATE_DATA(inode), sizeof(struct mds_filter_data));
+        INODE_PRIVATE_DATA(inode) = NULL;
         iput(inode);
 }
 
@@ -186,9 +186,9 @@ static int mds_get_write_access(struct mds_obd *mds, struct inode *inode,
                 goto out;
         }
 
-        if (inode->i_filterdata == NULL)
+        if (MDS_FILTERDATA(inode) == NULL)
                 mds_alloc_filterdata(inode);
-        if (inode->i_filterdata == NULL) {
+        if (MDS_FILTERDATA(inode) == NULL) {
                 rc = -ENOMEM;
                 goto out;
         }
@@ -297,13 +297,19 @@ static struct mds_file_data *mds_dentry_open(struct dentry *dentry,
         mfd->mfd_mode = flags;
         mfd->mfd_dentry = dentry;
         mfd->mfd_xid = req->rq_xid;
-
-        spin_lock(&med->med_open_lock);
-        list_add(&mfd->mfd_list, &med->med_open_head);
-        spin_unlock(&med->med_open_lock);
-
         body->handle.cookie = mfd->mfd_handle.h_cookie;
 
+        if (req->rq_export->exp_disconnected) {
+                mds_mfd_unlink(mfd, 0);
+                MDS_DOWN_WRITE_ORPHAN_SEM(dentry->d_inode);
+                mds_mfd_close(NULL, REQ_REC_OFF, req->rq_export->exp_obd,
+                              mfd, 0, NULL, 0, NULL, 0, NULL);
+        } else {
+                spin_lock(&med->med_open_lock);
+                list_add(&mfd->mfd_list, &med->med_open_head);
+                spin_unlock(&med->med_open_lock);
+        }
+
         RETURN(mfd);
 
 cleanup_mfd:
@@ -356,8 +362,11 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset,
                 lmm = rec->ur_eadata;
                 LASSERT(lmm);
 
-                if (*handle == NULL)
-                        *handle = fsfilt_start(obd,inode,FSFILT_OP_CREATE,NULL);
+                if (*handle == NULL) {
+                        int stripe_count = le32_to_cpu(lmm->lmm_stripe_count);
+                        *handle = fsfilt_start_log(obd, inode, FSFILT_OP_CREATE,
+                                                   NULL, stripe_count);
+                }
                 if (IS_ERR(*handle)) {
                         rc = PTR_ERR(*handle);
                         *handle = NULL;
@@ -385,8 +394,9 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset,
         oinfo.oi_oa->o_gid = 0;
         oinfo.oi_oa->o_mode = S_IFREG | 0600;
         oinfo.oi_oa->o_id = inode->i_ino;
+        oinfo.oi_oa->o_gr = 0;
         oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLFLAGS |
-                OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID;
+                OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID| OBD_MD_FLGROUP;
         oinfo.oi_oa->o_size = 0;
 
         obdo_from_inode(oinfo.oi_oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
@@ -407,7 +417,8 @@ static int mds_create_objects(struct ptlrpc_request *req, int offset,
 
                         lmm_size = lmm_sz;
                         rc = mds_get_md(obd, dchild->d_parent->d_inode,
-                                        lmm, &lmm_size, 1, 0);
+                                        lmm, &lmm_size, 1, 0,
+                                        req->rq_export->exp_connect_flags);
                         if (rc > 0)
                                 rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
                                                    mds->mds_osc_exp,
@@ -511,14 +522,14 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
         struct mds_export_data *med = &req->rq_export->exp_mds_data;
         struct lsd_client_data *lcd = med->med_lcd;
         struct mds_obd *mds = mds_req2mds(req);
-        struct mds_file_data *mfd;
+        struct mds_file_data *mfd = NULL;
         struct obd_export *exp = req->rq_export;
         struct obd_device *obd = exp->exp_obd;
         struct dentry *parent, *dchild;
         struct ldlm_reply *rep;
         struct mds_body *body;
-        int rc;
         struct list_head *t;
+        int rc;
         int put_child = 1;
         ENTRY;
 
@@ -536,31 +547,58 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
                 return; /* error looking up parent or child */
         }
 
-        parent = mds_fid2dentry(mds, rec->ur_fid1, NULL);
-        if (IS_ERR(parent)) {
-                rc = PTR_ERR(parent);
-                LCONSOLE_WARN("Parent "LPU64"/%u lookup error %d."
-                              " Evicting client %s with export %s.\n",
-                              rec->ur_fid1->id, rec->ur_fid1->generation, rc,
-                              obd_uuid2str(&exp->exp_client_uuid),
-                              obd_export_nid2str(exp));
-                mds_export_evict(exp);
+        /* If we failed, then we must have failed opening, so don't look for
+         * file descriptor or anything, just give the client the bad news.
+         */
+        if (req->rq_status) {
                 EXIT;
                 return;
         }
 
-        dchild = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1);
-        if (IS_ERR(dchild)) {
-                rc = PTR_ERR(dchild);
-                LCONSOLE_WARN("Child "LPU64"/%u lookup error %d."
-                              " Evicting client %s with export %s.\n",
-                              rec->ur_fid1->id, rec->ur_fid1->generation, rc,
-                              obd_uuid2str(&exp->exp_client_uuid),
-                              obd_export_nid2str(exp));
-                mds_export_evict(exp);
+        /* Now let's see if we have file descriptor present.
+         * No need to lookup child as it could be already deleted by another
+         * thread (bug 15010) */
+        spin_lock(&med->med_open_lock);
+        list_for_each(t, &med->med_open_head) {
+                mfd = list_entry(t, struct mds_file_data, mfd_list);
+                if (mfd->mfd_xid == req->rq_xid) {
+                       mds_mfd_addref(mfd);
+                       break;
+                }
+                mfd = NULL;
+        }
+        spin_unlock(&med->med_open_lock);
+
+        if (mfd && mfd->mfd_dentry && mfd->mfd_dentry->d_inode) {
+                dchild = mfd->mfd_dentry;
+                put_child = 0;
+        } else {
+                parent = mds_fid2dentry(mds, rec->ur_fid1, NULL);
+                if (IS_ERR(parent)) {
+                        rc = PTR_ERR(parent);
+                        LCONSOLE_WARN("Parent "LPU64"/%u lookup error %d."
+                                      " Evicting client %s with export %s.\n",
+                                      rec->ur_fid1->id,rec->ur_fid1->generation,
+                                      rc, obd_uuid2str(&exp->exp_client_uuid),
+                                      obd_export_nid2str(exp));
+                        mds_export_evict(exp);
+                        EXIT;
+                        return;
+                }
+
+                dchild = mds_lookup(obd, rec->ur_name, parent, rec->ur_namelen - 1);
                 l_dput(parent);
-                EXIT;
-                return;
+                if (IS_ERR(dchild)) {
+                        rc = PTR_ERR(dchild);
+                        LCONSOLE_WARN("Child "LPU64"/%u lookup error %d."
+                                      " Evicting client %s with export %s.\n",
+                                      rec->ur_fid1->id,rec->ur_fid1->generation,
+                                      rc, obd_uuid2str(&exp->exp_client_uuid),
+                                      obd_export_nid2str(exp));
+                        mds_export_evict(exp);
+                        EXIT;
+                        return;
+                }
         }
 
         if (!dchild->d_inode)
@@ -575,11 +613,11 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
                 GOTO(out_dput, 0);
         }
 
-        mds_pack_inode2fid(&body->fid1, dchild->d_inode);
         mds_pack_inode2body(body, dchild->d_inode);
         if (S_ISREG(dchild->d_inode->i_mode)) {
                 rc = mds_pack_md(obd, req->rq_repmsg, DLM_REPLY_REC_OFF + 1,
-                                 body, dchild->d_inode, 1, 0);
+                                 body, dchild->d_inode, 1, 0,
+                                 req->rq_export->exp_connect_flags);
 
                 if (rc)
                         LASSERT(rc == req->rq_status);
@@ -605,39 +643,6 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
                         req->rq_status = rc;
         }
 
-        /* If we have -EEXIST as the status, and we were asked to create
-         * exclusively, we can tell we failed because the file already existed.
-         */
-        if (req->rq_status == -EEXIST &&
-            ((rec->ur_flags & (MDS_OPEN_CREAT | MDS_OPEN_EXCL)) ==
-             (MDS_OPEN_CREAT | MDS_OPEN_EXCL))) {
-                GOTO(out_dput, 0);
-        }
-
-        /* If we didn't get as far as trying to open, then some locking thing
-         * probably went wrong, and we'll just bail here.
-         */
-        if (!ldlm_reply_disposition(rep, DISP_OPEN_OPEN))
-                GOTO(out_dput, 0);
-
-        /* If we failed, then we must have failed opening, so don't look for
-         * file descriptor or anything, just give the client the bad news.
-         */
-        if (req->rq_status)
-                GOTO(out_dput, 0);
-
-        mfd = NULL;
-        spin_lock(&med->med_open_lock);
-        list_for_each(t, &med->med_open_head) {
-                mfd = list_entry(t, struct mds_file_data, mfd_list);
-                if (mfd->mfd_xid == req->rq_xid) {
-                        mds_mfd_addref(mfd);
-                        break;
-                }
-                mfd = NULL;
-        }
-        spin_unlock(&med->med_open_lock);
-
         /* #warning "XXX fixme" bug 2991 */
         /* Here it used to LASSERT(mfd) if exp_outstanding_reply != NULL.
          * Now that exp_outstanding_reply is a list, it's just using mfd != NULL
@@ -674,8 +679,6 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
                        mfd->mfd_handle.h_cookie);
         }
 
-        mds_mfd_put(mfd);
-
         if (!ldlm_reply_disposition(rep, DISP_OPEN_LOCK))
                 GOTO(out_dput, 0);
 
@@ -687,12 +690,60 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
         }
 
  out_dput:
+        if (mfd)
+                mds_mfd_put(mfd);
+
         if (put_child)
                 l_dput(dchild);
-        l_dput(parent);
         EXIT;
 }
 
+/* if client disconnects during recovery it may resend opens which were replayed
+ * on server but their transno less then last_transno on server so they will not
+ * be detected as reconstructs */
+static int open_replay_reconstruct(struct ptlrpc_request *req)
+{
+        struct mds_export_data *med = &req->rq_export->exp_mds_data;
+        struct mds_file_data *mfd = NULL;
+        struct list_head *t;
+
+        if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT))
+                return 0;
+
+        if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY))
+                return 0;
+
+        /* if mfd exists then replay was done already */
+        spin_lock(&med->med_open_lock);
+        list_for_each(t, &med->med_open_head) {
+                mfd = list_entry(t, struct mds_file_data, mfd_list);
+                if (mfd->mfd_xid == req->rq_xid) {
+                        mds_mfd_addref(mfd);
+                        break;
+                }
+                mfd = NULL;
+        }
+        spin_unlock(&med->med_open_lock);
+
+        if (mfd) {
+                struct mds_body *body = lustre_msg_buf(req->rq_repmsg,
+                                                       DLM_REPLY_REC_OFF,
+                                                       sizeof(*body));
+                __u64 *pre_versions = lustre_msg_get_versions(req->rq_reqmsg);
+
+                body->handle.cookie = mfd->mfd_handle.h_cookie;
+                CDEBUG(D_INODE, "resend mfd %p, cookie "LPX64"\n", mfd,
+                       mfd->mfd_handle.h_cookie);
+                mds_mfd_put(mfd);
+                lustre_msg_set_versions(req->rq_repmsg, pre_versions);
+                lustre_msg_set_transno(req->rq_repmsg,
+                                       lustre_msg_get_transno(req->rq_reqmsg));
+                lustre_msg_set_status(req->rq_repmsg, 0);
+                return 1;
+        }
+        return 0;
+}
+
 /* do NOT or the MAY_*'s, you'll get the weakest */
 static int accmode(struct inode *inode, int flags)
 {
@@ -734,7 +785,8 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
         if (S_ISREG(dchild->d_inode->i_mode) &&
             !(body->valid & OBD_MD_FLEASIZE)) {
                 rc = mds_pack_md(obd, req->rq_repmsg, DLM_REPLY_REC_OFF + 1,
-                                 body, dchild->d_inode, 0, 0);
+                                 body, dchild->d_inode, 0, 0,
+                                 req->rq_export->exp_connect_flags);
                 if (rc) {
                         UNLOCK_INODE_MUTEX(dchild->d_inode);
                         RETURN(rc);
@@ -762,12 +814,16 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
                 }
                 if (!(body->valid & OBD_MD_FLEASIZE) &&
                     !(body->valid & OBD_MD_FLMODEASIZE)) {
+                        /* split open transactions here */
+                        OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_SPLIT_OPEN, 10);
                         /* no EA: create objects */
                         rc = mds_create_objects(req, DLM_REPLY_REC_OFF + 1, rec,
                                                 mds, obd, dchild, handle, &lmm);
                         if (rc) {
                                 CERROR("mds_create_objects: rc = %d\n", rc);
                                 UNLOCK_INODE_MUTEX(dchild->d_inode);
+                                lustre_shrink_reply(req, DLM_REPLY_REC_OFF + 1,
+                                                    0, 1);
                                 RETURN(rc);
                         }
                 }
@@ -820,15 +876,17 @@ static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid,
                            struct mds_body *body, int flags,
                            struct mds_update_record *rec,struct ldlm_reply *rep)
 {
+        struct obd_device *obd = req->rq_export->exp_obd;
         struct mds_obd *mds = mds_req2mds(req);
-        struct dentry *dchild;
+        struct dentry *dchild, *dparent = NULL;
         char fidname[LL_FID_NAMELEN];
         int fidlen = 0, rc;
         void *handle = NULL;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         ENTRY;
 
         fidlen = ll_fid2str(fidname, fid->id, fid->generation);
-        dchild = ll_lookup_one_len(fidname, mds->mds_pending_dir, fidlen);
+        dchild = mds_lookup(obd, fidname, mds->mds_pending_dir, fidlen);
         if (IS_ERR(dchild)) {
                 rc = PTR_ERR(dchild);
                 CERROR("error looking up %s in PENDING: rc = %d\n",fidname, rc);
@@ -840,6 +898,7 @@ static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid,
                 CWARN("Orphan %s found and opened in PENDING directory\n",
                        fidname);
         } else {
+                __u64 *pre_versions = lustre_msg_get_versions(req->rq_reqmsg);
                 l_dput(dchild);
 
                 /* We didn't find it in PENDING so it isn't an orphan.  See
@@ -847,18 +906,45 @@ static int mds_open_by_fid(struct ptlrpc_request *req, struct ll_fid *fid,
                 dchild = mds_fid2dentry(mds, fid, NULL);
                 if (IS_ERR(dchild))
                         RETURN(PTR_ERR(dchild));
+                /**
+                 * bug19224
+                 * this can be replay of partially committed open|create,
+                 * the create itself was committed while LOV EA weren't
+                 * We need to set versions again if conditions are:
+                 * - this is replay
+                 * - the transaction is greater than last_committed
+                 * - this was open|create
+                 * - there was real create so parent pre_version was saved
+                 */
+                if ((lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) &&
+                    (lustre_msg_get_transno(req->rq_reqmsg) >
+                     req->rq_export->exp_last_committed) &&
+                    (rec->ur_flags & MDS_OPEN_CREAT) &&
+                    (pre_versions && pre_versions[0] != 0)) {
+                        /* need parent to set version */
+                        dparent = mds_fid2dentry(mds, rec->ur_fid1, NULL);
+                        if (IS_ERR(dparent)) {
+                                CERROR("Can't find parent for open replay\n");
+                                l_dput(dchild);
+                                RETURN(PTR_ERR(dparent));
+                        }
+                        /* though file was created, the versions were not
+                         * changed yet, need to replay that too */
+                        inodes[0] = dparent->d_inode;
+                        inodes[1] = dchild->d_inode;
+                }
         }
 
-        mds_pack_inode2fid(&body->fid1, dchild->d_inode);
         mds_pack_inode2body(body, dchild->d_inode);
         ldlm_reply_set_disposition(rep, DISP_LOOKUP_EXECD);
         ldlm_reply_set_disposition(rep, DISP_LOOKUP_POS);
 
         rc = mds_finish_open(req, dchild, body, flags, &handle, rec, rep, NULL);
-        rc = mds_finish_transno(mds, dchild->d_inode, handle,
+        rc = mds_finish_transno(mds, inodes, handle,
                                 req, rc, rep ? rep->lock_policy_res1 : 0, 0);
         /* XXX what do we do here if mds_finish_transno itself failed? */
 
+        l_dput(dparent);
         l_dput(dchild);
         RETURN(rc);
 }
@@ -924,6 +1010,7 @@ int mds_open(struct mds_update_record *rec, int offset,
         struct ldlm_reply *rep = NULL;
         struct mds_body *body = NULL;
         struct dentry *dchild = NULL, *dparent = NULL;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct mds_export_data *med;
         struct lustre_handle parent_lockh;
         int rc = 0, cleanup_phase = 0, acc_mode, created = 0;
@@ -939,6 +1026,7 @@ int mds_open(struct mds_update_record *rec, int offset,
         int quota_pending[2] = {0, 0};
         int use_parent, need_open_lock;
         unsigned int gid = current->fsgid;
+        int finish = 0;
         ENTRY;
 
         mds_counter_incr(req->rq_export, LPROC_MDS_OPEN);
@@ -961,6 +1049,10 @@ int mds_open(struct mds_update_record *rec, int offset,
                 LBUG();
         }
 
+        /* check the open resent|replay case */
+        if (open_replay_reconstruct(req))
+                RETURN(0);
+
         MDS_CHECK_RESENT(req, reconstruct_open(rec, offset, req, child_lockh));
 
         /* Step 0: If we are passed a fid, then we assume the client already
@@ -980,6 +1072,13 @@ int mds_open(struct mds_update_record *rec, int offset,
                         RETURN(-EFAULT);
                 }
 
+                /** check there is no stale orphan with same inode number */
+                if (rec->ur_flags & MDS_OPEN_CREAT) {
+                        rc = mds_check_stale_orphan(obd, rec->ur_fid2);
+                        if (rc)
+                                RETURN(rc);
+                }
+
                 rc = mds_open_by_fid(req, rec->ur_fid2, body, rec->ur_flags,
                                      rec, rep);
                 if (rc != -ENOENT) {
@@ -1063,9 +1162,8 @@ int mds_open(struct mds_update_record *rec, int offset,
 
         cleanup_phase = 1; /* parent dentry and lock */
 
-        if (use_parent) {
+        if (use_parent)
                 dchild = dget(dparent);
-        }
 
         if (rec->ur_flags & MDS_OPEN_JOIN_FILE) {
                 acc_mode = accmode(dchild->d_inode, rec->ur_flags);
@@ -1094,6 +1192,16 @@ int mds_open(struct mds_update_record *rec, int offset,
                 if (req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY)
                         GOTO(cleanup, rc = -EROFS);
 
+                /** check there is no stale orphan with same inode number */
+                rc = mds_check_stale_orphan(obd, rec->ur_fid2);
+                if (rc)
+                        GOTO(cleanup, rc);
+
+                /* version recovery check */
+                rc = mds_version_get_check(req, dparent->d_inode, 0);
+                if (rc)
+                        GOTO(cleanup_no_trans, rc);
+
                 if (dparent->d_inode->i_mode & S_ISGID)
                         gid = dparent->d_inode->i_gid;
                 else
@@ -1132,8 +1240,16 @@ int mds_open(struct mds_update_record *rec, int offset,
                 inode = dchild->d_inode;
                 created = 1;
                 if (ino) {
-                        if (ino != inode->i_ino)
-                                GOTO(cleanup, rc = -EFAULT);
+                        if (ino != inode->i_ino) {
+                                /* FID support is needed to replay this
+                                 * correctly. Now fail gracefully like there is
+                                 * version mismatch */
+                                if (req->rq_export->exp_delayed)
+                                        rc = -EOVERFLOW;
+                                else
+                                        rc = -EFAULT;
+                                GOTO(cleanup, rc);
+                        }
                         /* Written as part of setattr */
                         inode->i_generation = rec->ur_fid2->generation;
                         CDEBUG(D_HA, "recreated ino %lu with gen %u\n",
@@ -1181,9 +1297,6 @@ int mds_open(struct mds_update_record *rec, int offset,
                  dchild->d_inode->i_ino, dchild->d_inode->i_generation);
 
 found_child:
-        mds_pack_inode2fid(&body->fid1, dchild->d_inode);
-        if (obd->obd_self_export->exp_bflag)
-                body->flags |= MDS_BFLAG_EXT_FLAGS;
         mds_pack_inode2body(body, dchild->d_inode);
 
         if (S_ISREG(dchild->d_inode->i_mode)) {
@@ -1266,15 +1379,17 @@ found_child:
                  * special device nodes */
                 GOTO(cleanup_no_trans, rc = 0);
         }
-
+        finish = 1;
         /* Step 5: mds_open it */
         rc = mds_finish_open(req, dchild, body, rec->ur_flags, &handle, rec,
                              rep, &parent_lockh);
         GOTO(cleanup, rc);
 
  cleanup:
-        rc = mds_finish_transno(mds, dchild ? dchild->d_inode : NULL, handle,
-                                req, rc, rep ? rep->lock_policy_res1 : 0, 0);
+        inodes[0] = (!created || IS_ERR(dparent)) ? NULL : dparent->d_inode;
+        inodes[1] = (created && dchild) ? dchild->d_inode : NULL;
+        rc = mds_finish_transno(mds, inodes, handle, req, rc,
+                                rep ? rep->lock_policy_res1 : 0, 0);
 
  cleanup_no_trans:
         if (quota_pending[0] || quota_pending[1])
@@ -1316,9 +1431,13 @@ found_child:
                 else
                         ptlrpc_save_lock(req, &parent_lockh, parent_mode);
         }
+        if (!finish)
+                mds_shrink_reply(obd, req, body, DLM_REPLY_REC_OFF + 1);
+
         /* trigger dqacq on the owner of child and parent */
         lquota_adjust(mds_quota_interface_ref, obd, qcids, qpids, rc,
                       FSFILT_OP_CREATE);
+
         RETURN(rc);
 }
 
@@ -1361,8 +1480,9 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,
         CDEBUG(D_INODE, "inode %p ino %s nlink %d orphan %d\n", inode, fidname,
                inode->i_nlink, mds_orphan_open_count(inode));
 
-        last_orphan = mds_orphan_open_dec_test(inode) &&
-                      mds_inode_is_orphan(inode);
+        last_orphan = (mds_orphan_open_dec_test(inode) &&
+                       mds_inode_is_orphan(inode) &&
+                       !obd->obd_recovering);
 
         /* this is half of the actual "close" */
         if (mfd->mfd_mode & FMODE_WRITE) {
@@ -1438,44 +1558,29 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,
         }
 
         if (request_body != NULL) {
-               if ((request_body->valid & OBD_MD_FLCTIME) &&
-                   (request_body->ctime > LTIME_S(inode->i_ctime))) {
-                       LTIME_S(iattr.ia_ctime) = request_body->ctime;
-                       iattr.ia_valid |= ATTR_CTIME;
-               }
-
-               if ((request_body->valid & OBD_MD_FLMTIME) &&
-                   (request_body->mtime > LTIME_S(inode->i_mtime)) &&
-                   (iattr.ia_valid & ATTR_CTIME)) {
-                       LTIME_S(iattr.ia_mtime) = request_body->mtime;
-                       iattr.ia_valid |= ATTR_MTIME;
-               }
-
-               /* Only start a transaction to write out only the atime
-                * if it is more out-of-date than the specified limit.
-                * If we are already going to write out the inode then
-                * update the atime anyway.
-                */
-               if ((request_body->valid & OBD_MD_FLATIME) &&
-                   ((request_body->atime >
-                     LTIME_S(inode->i_atime) + mds->mds_atime_diff) ||
-                    (iattr.ia_valid != 0 &&
-                     request_body->atime > LTIME_S(inode->i_atime)))) {
-                       LTIME_S(iattr.ia_atime) = request_body->atime;
-                       iattr.ia_valid |= ATTR_ATIME;
-               }
-
-               /* Store a rough estimate of the file size on the MDS for
-                * tools like e2scan and HSM that are just using this for
-                * rough decision making and will get the proper size later.
-                * This is NOT guaranteed to be correct with multiple
-                * writers, but is only needed until SOM is done. b=11063 */
-               if (S_ISREG(inode->i_mode) &&
-                   (request_body->valid & OBD_MD_FLSIZE) &&
-                   (iattr.ia_valid != 0)) {
-                       iattr.ia_size = request_body->size;
-                       iattr.ia_valid |= ATTR_SIZE;
-               }
+                /* Only start a transaction to write out only the atime if it
+                 * is more out-of-date than the specified limit.  If we are
+                 * already going to write out the atime then do it anyway. */
+                if ((request_body->valid & OBD_MD_FLATIME) &&
+                    ((LTIME_S(iattr.ia_atime) >
+                      LTIME_S(inode->i_atime) + mds->mds_atime_diff) ||
+                     (iattr.ia_valid != 0 &&
+                      LTIME_S(iattr.ia_atime) > LTIME_S(inode->i_atime)))) {
+                        LTIME_S(iattr.ia_atime) = request_body->atime;
+                        iattr.ia_valid |= ATTR_ATIME;
+                }
+
+                /* Store a rough estimate of the file size on the MDS for
+                 * tools like e2scan and HSM that are just using this for *
+                 * rough decision making and will get the proper size later.
+                 * * This is NOT guaranteed to be correct with multiple *
+                 * writers, but is only needed until SOM is done. b=11063 */
+                if (S_ISREG(inode->i_mode) &&
+                    (request_body->valid & OBD_MD_FLSIZE) &&
+                    (iattr.ia_valid != 0)) {
+                        iattr.ia_size = request_body->size;
+                        iattr.ia_valid |= ATTR_SIZE;
+                }
         }
 
         if (iattr.ia_valid != 0) {
@@ -1493,12 +1598,12 @@ out:
         /* If other clients have this file open for write, rc will be > 0 */
         if (rc > 0)
                 rc = 0;
-        l_dput(mfd->mfd_dentry);
-        mds_mfd_put(mfd);
 
  cleanup:
+        l_dput(mfd->mfd_dentry);
+        mds_mfd_put(mfd);
         if (req != NULL && reply_body != NULL) {
-                rc = mds_finish_transno(mds, pending_dir, handle, req, rc, 0, 0);
+                rc = mds_finish_transno(mds, NULL, handle, req, rc, 0, 0);
         } else if (handle) {
                 int err = fsfilt_commit(obd, pending_dir, handle, 0);
                 if (err) {
@@ -1576,15 +1681,16 @@ int mds_close(struct ptlrpc_request *req, int offset)
         inode = mfd->mfd_dentry->d_inode;
         /* child orphan sem protects orphan_dec_test && is_orphan race */
         MDS_DOWN_WRITE_ORPHAN_SEM(inode); /* mds_mfd_close drops this */
-        if (mds_inode_is_orphan(inode) && mds_orphan_open_count(inode) == 1) {
+        if (!obd->obd_recovering &&
+            mds_inode_is_orphan(inode) && mds_orphan_open_count(inode) == 1) {
                 body = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
                                       sizeof(*body));
                 LASSERT(body != NULL);
 
-                mds_pack_inode2fid(&body->fid1, inode);
                 mds_pack_inode2body(body, inode);
                 mds_pack_md(obd, req->rq_repmsg, REPLY_REC_OFF + 1, body, inode,
-                            MDS_PACK_MD_LOCK, 0);
+                            MDS_PACK_MD_LOCK, 0,
+                            req->rq_export->exp_connect_flags);
         }
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c
index 0ec2764..fbc77c0 100644
--- a/lustre/mds/mds_reint.c
+++ b/lustre/mds/mds_reint.c
@@ -57,13 +57,19 @@
 #include <lustre_dlm.h>
 #include <lustre_fsfilt.h>
 #include <lustre_ucache.h>
+#include <lustre_net.h>
 
 #include "mds_internal.h"
 
 void mds_commit_cb(struct obd_device *obd, __u64 transno, void *data,
                    int error)
 {
-        obd_transno_commit_cb(obd, transno, error);
+        struct obd_export *exp = data;
+        LASSERTF(exp->exp_obd == obd,
+                 "%s: bad export (%p), obd (%p) != exp->exp_obd (%p)\n",
+                 obd->obd_name, exp, obd, exp->exp_obd);
+        obd_transno_commit_cb(obd, transno, exp, error);
+        class_export_put(exp);
 }
 
 struct mds_logcancel_data {
@@ -74,6 +80,38 @@ struct mds_logcancel_data {
         struct llog_cookie      mlcd_cookies[0];
 };
 
+/** lookup child dentry in parent dentry according to the name.
+ *  if dentry is found, delete "lustre_mdt_attrs" EA (with name "lma")
+ *  if it exists by checking OBD_INCOMPAT_FID.
+ */
+struct dentry *mds_lookup(struct obd_device *obd, const char *fid_name,
+                          struct dentry *dparent, int fid_namelen)
+{
+        struct dentry *dchild;
+        struct lr_server_data *lsd = obd->u.mds.mds_server_data;
+        ENTRY;
+
+        dchild = ll_lookup_one_len(fid_name, dparent, fid_namelen);
+        if (!IS_ERR(dchild) &&
+            unlikely((lsd->lsd_feature_incompat & OBD_INCOMPAT_FID) ||
+                      OBD_FAIL_CHECK(OBD_FAIL_MDS_REMOVE_COMMON_EA))) {
+                struct inode *inode = dchild->d_inode; 
+                void         *handle;
+                if (inode != NULL) {
+                        handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR,
+                                              NULL);
+                        if (!IS_ERR(handle)) {
+                                LOCK_INODE_MUTEX(inode);
+                                fsfilt_set_md(obd, inode, handle, NULL, 0,
+                                              "lma");
+                                /* result is ignored. */
+                                UNLOCK_INODE_MUTEX(inode);
+                                fsfilt_commit(obd, inode, handle, 0);
+                        }
+                }
+        }
+        RETURN(dchild);
+}
 
 static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
                                   void *cb_data, int error)
@@ -83,7 +121,7 @@ static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
         struct llog_ctxt *ctxt;
         int rc;
 
-        obd_transno_commit_cb(obd, transno, error);
+        obd_transno_commit_cb(obd, transno, NULL, error);
 
         CDEBUG(D_RPCTRACE, "cancelling %d cookies\n",
                (int)(mlcd->mlcd_cookielen / sizeof(*mlcd->mlcd_cookies)));
@@ -95,13 +133,13 @@ static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
                        (int)(mlcd->mlcd_cookielen/sizeof(*mlcd->mlcd_cookies)),
                        rc);
         } else {
-                ///* XXX 0 normally, SENDNOW for debug */);
                 rc = obd_checkmd(obd->u.mds.mds_osc_exp, obd->obd_self_export,
                                  lsm);
                 if (rc)
                         CERROR("Can not revalidate lsm %p \n", lsm);
 
                 ctxt = llog_get_context(obd,mlcd->mlcd_cookies[0].lgc_subsys+1);
+                /* XXX 0 normally, SENDNOW for debug */
                 rc = llog_cancel(ctxt, lsm, mlcd->mlcd_cookielen /
                                                 sizeof(*mlcd->mlcd_cookies),
                                  mlcd->mlcd_cookies, OBD_LLOG_FL_SENDNOW);
@@ -116,9 +154,65 @@ static void mds_cancel_cookies_cb(struct obd_device *obd, __u64 transno,
         OBD_FREE(mlcd, mlcd->mlcd_size);
 }
 
+/* fsfilt_set_version return old version. use that here */
+static void mds_versions_set(struct obd_device *obd,
+                             struct inode **inodes, __u64 version)
+{
+        int i;
+
+        if (inodes == NULL)
+                return;
+
+        for (i = 0; i < PTLRPC_NUM_VERSIONS; i++)
+                if (inodes[i] != NULL)
+                        fsfilt_set_version(obd, inodes[i], version);
+}
+
+int mds_version_get_check(struct ptlrpc_request *req, struct inode *inode,
+                          int index)
+{
+        /* version recovery */
+        struct obd_device *obd = req->rq_export->exp_obd;
+        __u64 curr_version, *pre_versions;
+        ENTRY;
+
+        if (inode == NULL || !exp_connect_vbr(req->rq_export))
+                RETURN(0);
+
+        curr_version = fsfilt_get_version(obd, inode);
+        if ((__s64)curr_version == -EOPNOTSUPP)
+                RETURN(0);
+        /* VBR: version is checked always because costs nothing */
+        if (lustre_msg_get_transno(req->rq_reqmsg) != 0) {
+                pre_versions = lustre_msg_get_versions(req->rq_reqmsg);
+                LASSERT(index < PTLRPC_NUM_VERSIONS);
+                /* Sanity check for malformed buffers */
+                if (pre_versions == NULL) {
+                        CERROR("No versions in request buffer\n");
+                        spin_lock(&req->rq_export->exp_lock);
+                        req->rq_export->exp_vbr_failed = 1;
+                        spin_unlock(&req->rq_export->exp_lock);
+                        RETURN(-EOVERFLOW);
+                } else if (pre_versions[index] != curr_version) {
+                        CDEBUG(D_INODE, "Version mismatch "LPX64" != "LPX64"\n",
+                               pre_versions[index], curr_version);
+                        spin_lock(&req->rq_export->exp_lock);
+                        req->rq_export->exp_vbr_failed = 1;
+                        spin_unlock(&req->rq_export->exp_lock);
+                        RETURN(-EOVERFLOW);
+                }
+        }
+        /* save pre-versions in reply */
+        LASSERT(req->rq_repmsg != NULL);
+        pre_versions = lustre_msg_get_versions(req->rq_repmsg);
+        if (pre_versions)
+                pre_versions[index] = curr_version;
+        RETURN(0);
+}
+
 /* Assumes caller has already pushed us into the kernel context. */
-int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
-                       struct ptlrpc_request *req, int rc, __u32 op_data, 
+int mds_finish_transno(struct mds_obd *mds, struct inode **inodes, void *handle,
+                       struct ptlrpc_request *req, int rc, __u32 op_data,
                        int force_sync)
 {
         struct mds_export_data *med = &req->rq_export->exp_mds_data;
@@ -128,6 +222,8 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
         int err;
         loff_t off;
         int log_pri = D_RPCTRACE;
+        struct inode *inode = inodes ? inodes[0] : NULL;
+        int version_set = handle ? 1 : 0;
         ENTRY;
 
         if (IS_ERR(handle)) {
@@ -165,24 +261,33 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
                                obd->obd_name,
                                libcfs_nid2str(req->rq_export->exp_connection->c_peer.nid),
                                transno, rc);
-                        transno = 0;
                 }
         } else if (transno == 0) {
                 spin_lock(&mds->mds_transno_lock);
                 transno = ++mds->mds_last_transno;
                 spin_unlock(&mds->mds_transno_lock);
+                /* VBR: set versions */
+                if (inodes && version_set)
+                        mds_versions_set(obd, inodes, transno);
         } else {
                 spin_lock(&mds->mds_transno_lock);
                 if (transno > mds->mds_last_transno)
                         mds->mds_last_transno = transno;
                 spin_unlock(&mds->mds_transno_lock);
+
+                /* VBR: replay case. Copy version from replay req and
+                 * set new versions */
+                mds_versions_set(obd, inodes, transno);
         }
 
         req->rq_transno = transno;
         lustre_msg_set_transno(req->rq_repmsg, transno);
+
+        if (transno == 0)
+                LASSERT(rc != 0);
         if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE) {
-                prev_transno = le64_to_cpu(lcd->lcd_last_close_transno);
-                lcd->lcd_last_close_transno = cpu_to_le64(transno);
+                if (transno != 0)
+                        lcd->lcd_last_close_transno = cpu_to_le64(transno);
                 lcd->lcd_last_close_xid = cpu_to_le64(req->rq_xid);
                 lcd->lcd_last_close_result = cpu_to_le32(rc);
                 lcd->lcd_last_close_data = cpu_to_le32(op_data);
@@ -191,15 +296,23 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
                 if (((lustre_msg_get_flags(req->rq_reqmsg) &
                       (MSG_RESENT | MSG_REPLAY)) == 0) ||
                     (transno > prev_transno)) {
-                        lcd->lcd_last_transno = cpu_to_le64(transno);
+                        /* VBR: save versions in last_rcvd for reconstruct. */
+                        __u64 *pre_versions = lustre_msg_get_versions(req->rq_repmsg);
+                        if (pre_versions) {
+                                lcd->lcd_pre_versions[0] = cpu_to_le64(pre_versions[0]);
+                                lcd->lcd_pre_versions[1] = cpu_to_le64(pre_versions[1]);
+                                lcd->lcd_pre_versions[2] = cpu_to_le64(pre_versions[2]);
+                                lcd->lcd_pre_versions[3] = cpu_to_le64(pre_versions[3]);
+                        }
+                        if (transno != 0)
+                                lcd->lcd_last_transno = cpu_to_le64(transno);
                         lcd->lcd_last_xid     = cpu_to_le64(req->rq_xid);
                         lcd->lcd_last_result  = cpu_to_le32(rc);
                         lcd->lcd_last_data    = cpu_to_le32(op_data);
                 }
         }
-        /* update the server data to not lose the greatest transno. Bug 11125 */
-        if ((transno == 0) && (prev_transno == mds->mds_last_transno))
-                mds_update_server_data(obd, 0);
+        /** update trans table */
+        target_trans_table_update(req->rq_export, transno);
 
         if (off <= 0) {
                 CERROR("client idx %d has offset %lld\n", med->med_lr_idx, off);
@@ -207,16 +320,17 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
         } else {
                 struct obd_export *exp = req->rq_export;
 
+                class_export_get(exp); /* released once the cb is called */
                 if (!force_sync)
-                        force_sync = fsfilt_add_journal_cb(exp->exp_obd,transno, 
-                                                          handle, mds_commit_cb,
-                                                          NULL);
+                        force_sync = fsfilt_add_journal_cb(obd, transno,
+                                                           handle, mds_commit_cb,
+                                                           exp);
 
                 err = fsfilt_write_record(obd, mds->mds_rcvd_filp, lcd,
                                           sizeof(*lcd), &off,
                                           force_sync | exp->exp_need_sync);
                 if (force_sync)
-                        mds_commit_cb(obd, transno, NULL, err);
+                        mds_commit_cb(obd, transno, exp, err);
         }
 
         if (err) {
@@ -370,7 +484,7 @@ void mds_steal_ack_locks(struct ptlrpc_request *req)
 
                 if (lustre_msg_get_opc(oldrep->rs_msg) !=
                     lustre_msg_get_opc(req->rq_reqmsg))
-                        CERROR ("Resent req xid "LPX64" has mismatched opc: "
+                        CERROR ("Resent req xid "LPU64" has mismatched opc: "
                                 "new %d old %d\n", req->rq_xid,
                                 lustre_msg_get_opc(req->rq_reqmsg),
                                 lustre_msg_get_opc(oldrep->rs_msg));
@@ -402,19 +516,34 @@ void mds_steal_ack_locks(struct ptlrpc_request *req)
         spin_unlock(&exp->exp_lock);
 }
 
+/**
+ * VBR: restore versions
+ */
+void mds_vbr_reconstruct(struct ptlrpc_request *req,
+                         struct lsd_client_data *lcd)
+{
+        __u64 pre_versions[4] = {0};
+        pre_versions[0] = le64_to_cpu(lcd->lcd_pre_versions[0]);
+        pre_versions[1] = le64_to_cpu(lcd->lcd_pre_versions[1]);
+        pre_versions[2] = le64_to_cpu(lcd->lcd_pre_versions[2]);
+        pre_versions[3] = le64_to_cpu(lcd->lcd_pre_versions[3]);
+        lustre_msg_set_versions(req->rq_repmsg, pre_versions);
+}
+
 void mds_req_from_lcd(struct ptlrpc_request *req, struct lsd_client_data *lcd)
 {
         if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE) {
                 req->rq_transno = le64_to_cpu(lcd->lcd_last_close_transno);
-                lustre_msg_set_transno(req->rq_repmsg, req->rq_transno);
                 req->rq_status = le32_to_cpu(lcd->lcd_last_close_result);
-                lustre_msg_set_status(req->rq_repmsg, req->rq_status);
         } else {
                 req->rq_transno = le64_to_cpu(lcd->lcd_last_transno);
-                lustre_msg_set_transno(req->rq_repmsg, req->rq_transno);
                 req->rq_status = le32_to_cpu(lcd->lcd_last_result);
-                lustre_msg_set_status(req->rq_repmsg, req->rq_status);
+                mds_vbr_reconstruct(req, lcd);
         }
+        if (req->rq_status != 0)
+                req->rq_transno = 0;
+        lustre_msg_set_transno(req->rq_repmsg, req->rq_transno);
+        lustre_msg_set_status(req->rq_repmsg, req->rq_status);
         DEBUG_REQ(D_RPCTRACE, req, "restoring transno "LPD64"/status %d",
                   req->rq_transno, req->rq_status);
 
@@ -447,7 +576,6 @@ static void reconstruct_reint_setattr(struct mds_update_record *rec,
         }
 
         body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
-        mds_pack_inode2fid(&body->fid1, de->d_inode);
         mds_pack_inode2body(body, de->d_inode);
 
         /* Don't return OST-specific attributes if we didn't just set them */
@@ -495,8 +623,9 @@ int mds_osc_setattr_async(struct obd_device *obd, struct inode *inode,
 
         /* then fill oa */
         obdo_from_inode(oinfo.oi_oa, inode, OBD_MD_FLUID | OBD_MD_FLGID);
-        oinfo.oi_oa->o_valid |= OBD_MD_FLID;
+        oinfo.oi_oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
         oinfo.oi_oa->o_id = oinfo.oi_md->lsm_object_id;
+        oinfo.oi_oa->o_gr = 0;
         if (logcookies) {
                 oinfo.oi_oa->o_valid |= OBD_MD_FLCOOKIE;
                 oti.oti_logcookies = logcookies;
@@ -533,6 +662,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         struct obd_device *obd = req->rq_export->exp_obd;
         struct mds_body *body;
         struct dentry *de;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct inode *inode = NULL;
         struct lustre_handle lockh;
         void *handle = NULL;
@@ -540,7 +670,10 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         struct lov_mds_md *lmm = NULL;
         struct llog_cookie *logcookies = NULL;
         int lmm_size = 0, need_lock = 1, cookie_size = 0;
-        int rc = 0, cleanup_phase = 0, err, locked = 0, sync = 0;
+        int rc = 0, cleanup_phase = 0, err = 0, locked = 0, sync = 0;
+        int do_vbr = rec->ur_iattr.ia_valid &
+                     (ATTR_MODE|ATTR_UID|ATTR_GID|
+                      ATTR_FROM_OPEN|ATTR_RAW|ATTR_ATTR_FLAG);
         unsigned int qcids[MAXQUOTAS] = { 0, 0 };
         unsigned int qpids[MAXQUOTAS] = { rec->ur_iattr.ia_uid, 
                                           rec->ur_iattr.ia_gid };
@@ -600,6 +733,12 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
 
         OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_REINT_SETATTR_WRITE, inode->i_sb);
 
+        /* VBR: update version if attr changed are important for recovery */
+        if (do_vbr) {
+                rc = mds_version_get_check(req, inode, 0);
+                if (rc)
+                        GOTO(cleanup_no_trans, rc);
+        }
         /* start a log jounal handle if needed */
         if (S_ISREG(inode->i_mode) &&
             rec->ur_iattr.ia_valid & (ATTR_UID | ATTR_GID)) {
@@ -609,7 +748,8 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                         GOTO(cleanup, rc = -ENOMEM);
 
                 cleanup_phase = 2;
-                rc = mds_get_md(obd, inode, lmm, &lmm_size, need_lock, 0);
+                rc = mds_get_md(obd, inode, lmm, &lmm_size, need_lock, 0,
+                                req->rq_export->exp_connect_flags);
                 if (rc < 0)
                         GOTO(cleanup, rc);
                 rc = 0;
@@ -631,7 +771,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                 GOTO(cleanup, rc);
 
         if (rec->ur_iattr.ia_valid & ATTR_ATTR_FLAG) {  /* ioctl */
-                rc = fsfilt_iocontrol(obd, inode, NULL, EXT3_IOC_SETFLAGS,
+                rc = fsfilt_iocontrol(obd, de, FSFILT_IOC_SETFLAGS,
                                       (long)&rec->ur_flags);
         } else if (rec->ur_iattr.ia_valid) {            /* setattr */
                 rc = fsfilt_setattr(obd, de, handle, &rec->ur_iattr, 0);
@@ -660,16 +800,15 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                         GOTO(cleanup, rc);
 
                 lum = rec->ur_eadata;
-                /* if { size, offset, count } = { 0, -1, 0 } (i.e. all default
-                 * values specified) then delete default striping from dir. */
+                /* if { size, offset, count } = { 0, -1, 0 } and no pool
+                 * (i.e. all default values specified) then delete default
+                 * striping from dir. */
                 if (S_ISDIR(inode->i_mode) &&
-                    ((lum->lmm_stripe_size == 0 &&
+                    (lum->lmm_stripe_size == 0 &&
                       lum->lmm_stripe_offset ==
                       (typeof(lum->lmm_stripe_offset))(-1) &&
-                      lum->lmm_stripe_count == 0) ||
-                    /* lmm_stripe_size == -1 is deprecated in 1.4.6 */
-                    lum->lmm_stripe_size ==
-                    (typeof(lum->lmm_stripe_size))(-1))){
+                      lum->lmm_stripe_count == 0 &&
+                      le32_to_cpu(lum->lmm_magic) != LOV_USER_MAGIC_V3)){
                         rc = fsfilt_set_md(obd, inode, handle, NULL, 0, "lov");
                         if (rc)
                                 GOTO(cleanup, rc);
@@ -690,7 +829,6 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         }
 
         body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
-        mds_pack_inode2fid(&body->fid1, inode);
         mds_pack_inode2body(body, inode);
 
         /* don't return OST-specific attributes if we didn't just set them. */
@@ -710,7 +848,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                         mlcd->mlcd_eadatalen = rec->ur_eadatalen;
                         mlcd->mlcd_cookielen = rec->ur_cookielen;
                         mlcd->mlcd_lmm = (void *)&mlcd->mlcd_cookies +
-                                mlcd->mlcd_cookielen;
+                                         mlcd->mlcd_cookielen;
                         memcpy(&mlcd->mlcd_cookies, rec->ur_logcookies,
                                mlcd->mlcd_cookielen);
                         memcpy(mlcd->mlcd_lmm, rec->ur_eadata,
@@ -724,7 +862,15 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         if (mlcd != NULL)
                 sync = fsfilt_add_journal_cb(req->rq_export->exp_obd, 0, handle,
                                              mds_cancel_cookies_cb, mlcd);
-        err = mds_finish_transno(mds, inode, handle, req, rc, 0, sync);
+
+        /* permission changes may require sync operation */
+        if (rc == 0 && ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID))
+                sync |= mds->mds_sync_permission;
+        inodes[0] = inode;
+        err = mds_finish_transno(mds, do_vbr ? inodes : NULL, handle, req,
+                                 rc, 0, sync);
+
+ cleanup_no_trans:
         /* do mds to ost setattr if needed */
         if (!rc && !err && lmm_size)
                 mds_osc_setattr_async(obd, inode, lmm, lmm_size,
@@ -792,7 +938,8 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset,
                 EXIT;
                 return;
         }
-        child = ll_lookup_one_len(rec->ur_name, parent, rec->ur_namelen - 1);
+        child = mds_lookup(exp->exp_obd, rec->ur_name, parent,
+                           rec->ur_namelen - 1);
         if (IS_ERR(child)) {
                 rc = PTR_ERR(child);
                 LCONSOLE_WARN("Child "LPU64"/%u lookup error %d." 
@@ -807,7 +954,6 @@ static void reconstruct_reint_create(struct mds_update_record *rec, int offset,
         }
 
         body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
-        mds_pack_inode2fid(&body->fid1, child->d_inode);
         mds_pack_inode2body(body, child->d_inode);
 
         l_dput(parent);
@@ -822,10 +968,11 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         struct mds_obd *mds = mds_req2mds(req);
         struct obd_device *obd = req->rq_export->exp_obd;
         struct dentry *dchild = NULL;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct inode *dir = NULL;
         void *handle = NULL;
         struct lustre_handle lockh;
-        int rc = 0, err, type = rec->ur_mode & S_IFMT, cleanup_phase = 0;
+        int rc = 0, err = 0, type = rec->ur_mode & S_IFMT, cleanup_phase = 0;
         int created = 0;
         unsigned int qcids[MAXQUOTAS] = { current->fsuid, current->fsgid };
         unsigned int qpids[MAXQUOTAS] = { 0, 0 };
@@ -867,9 +1014,10 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
 
         ldlm_lock_dump_handle(D_OTHER, &lockh);
 
-        dchild = ll_lookup_one_len(rec->ur_name, dparent, rec->ur_namelen - 1);
+        dchild = mds_lookup(obd, rec->ur_name, dparent, rec->ur_namelen - 1);
         if (IS_ERR(dchild)) {
                 rc = PTR_ERR(dchild);
+                dchild = NULL;
                 CDEBUG(D_DENTRY, "child lookup error %d\n", rc);
                 GOTO(cleanup, rc);
         }
@@ -884,6 +1032,16 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                 GOTO(cleanup, rc = -EROFS);
         }
 
+        /** check there is no stale orphan with same inode number */
+        rc = mds_check_stale_orphan(obd, rec->ur_fid2);
+        if (rc)
+                GOTO(cleanup, rc);
+
+        /* version recovery check */
+        rc = mds_version_get_check(req, dir, 0);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+
         if (dir->i_mode & S_ISGID && S_ISDIR(rec->ur_mode))
                 rec->ur_mode |= S_ISGID;
 
@@ -985,7 +1143,13 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                         ATTR_MTIME | ATTR_CTIME;
 
                 if (rec->ur_fid2->id) {
-                        LASSERT(rec->ur_fid2->id == inode->i_ino);
+                        if (rec->ur_fid2->id != inode->i_ino) {
+                                if (req->rq_export->exp_delayed)
+                                        rc = -EOVERFLOW;
+                                else
+                                        rc = -EFAULT;
+                                GOTO(cleanup, rc);
+                        }
                         inode->i_generation = rec->ur_fid2->generation;
                         /* Dirtied and committed by the upcoming setattr. */
                         CDEBUG(D_INODE, "recreated ino %lu with gen %u\n",
@@ -1005,9 +1169,10 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                         CERROR("error on parent setattr: rc = %d\n", rc);
 
                 if (S_ISDIR(inode->i_mode)) {
-                        struct lov_mds_md lmm;
+                        struct lov_mds_md_v3 lmm;
                         int lmm_size = sizeof(lmm);
-                        rc = mds_get_md(obd, dir, &lmm, &lmm_size, 1, 0);
+                        rc = mds_get_md(obd, dir, &lmm, &lmm_size, 1, 0,
+                                        req->rq_export->exp_connect_flags);
                         if (rc > 0) {
                                 LOCK_INODE_MUTEX(inode);
                                 rc = fsfilt_set_md(obd, inode, handle,
@@ -1020,13 +1185,16 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                 }
 
                 body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
-                mds_pack_inode2fid(&body->fid1, inode);
                 mds_pack_inode2body(body, inode);
         }
         EXIT;
 
 cleanup:
-        err = mds_finish_transno(mds, dir, handle, req, rc, 0, 0);
+        inodes[0] = dir;
+        inodes[1] = dchild ? dchild->d_inode : NULL;
+        err = mds_finish_transno(mds, inodes, handle, req, rc, 0, 0);
+
+cleanup_no_trans:
         if (quota_pending[0] || quota_pending[1])
                 lquota_pending_commit(mds_quota_interface_ref, obd,
                                       current->fsuid, gid, quota_pending);
@@ -1452,7 +1620,7 @@ int mds_get_parent_child_locked(struct obd_device *obd, struct mds_obd *mds,
         if (name == NULL)
                 GOTO(retry_locks, rc);
         /* Step 2: Lookup child (without DLM lock, to get resource name) */
-        *dchildp = ll_lookup_one_len(name, *dparentp, namelen - 1);
+        *dchildp = mds_lookup(obd, name, *dparentp, namelen - 1);
         if (IS_ERR(*dchildp)) {
                 rc = PTR_ERR(*dchildp);
                 *dchildp = NULL;
@@ -1570,7 +1738,7 @@ static int mds_orphan_add_link(struct mds_update_record *rec,
                S_ISDIR(inode->i_mode) ? "dir" :
                 S_ISREG(inode->i_mode) ? "file" : "other",rec->ur_name,fidname);
 
-        if (mds_orphan_open_count(inode) == 0 || inode->i_nlink != 0)
+        if (!mds_orphan_needed(obd, inode) || inode->i_nlink != 0)
                 RETURN(0);
 
         pending_child = lookup_one_len(fidname, mds->mds_pending_dir, fidlen);
@@ -1625,21 +1793,27 @@ void mds_shrink_reply(struct obd_device *obd, struct ptlrpc_request *req,
 {
         int cookie_size = 0, md_size = 0;
 
-        if (body && body->valid & OBD_MD_FLEASIZE) {
-                md_size = body->eadatasize;
-        }
-        if (body && body->valid & OBD_MD_FLCOOKIE) {
-                LASSERT(body->valid & OBD_MD_FLEASIZE);
-                cookie_size = mds_get_cookie_size(obd, lustre_msg_buf(
-                                                  req->rq_repmsg, md_off, 0));
+       if (body) {
+                if (body->valid & (OBD_MD_FLEASIZE | OBD_MD_FLDIREA)) {
+                        md_size = body->eadatasize;
+                } else if (body->valid & OBD_MD_LINKNAME)
+                        md_size = body->eadatasize;
+
+                if (body->valid & OBD_MD_FLCOOKIE) {
+                        LASSERT(body->valid & OBD_MD_FLEASIZE);
+                        cookie_size = mds_get_cookie_size(obd, lustre_msg_buf(
+                                                          req->rq_repmsg,
+                                                          md_off, 0));
+                } else if (body->valid & OBD_MD_FLACL) {
+                        cookie_size = body->aclsize;
+                }
         }
-
         CDEBUG(D_INFO, "Shrink to md_size %d cookie_size %d \n", md_size,
                cookie_size);
- 
+
         lustre_shrink_reply(req, md_off, md_size, 1);
-        
-        lustre_shrink_reply(req, md_off + (md_size > 0), cookie_size, 0); 
+
+        lustre_shrink_reply(req, md_off + (md_size > 0), cookie_size, 1); 
 }
 
 static int mds_reint_unlink(struct mds_update_record *rec, int offset,
@@ -1650,6 +1824,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
         struct mds_obd *mds = mds_req2mds(req);
         struct obd_device *obd = req->rq_export->exp_obd;
         struct mds_body *body = NULL;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct inode *child_inode = NULL;
         struct lustre_handle parent_lockh, child_lockh, child_reuse_lockh;
         void *handle = NULL;
@@ -1699,6 +1874,16 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
 
         cleanup_phase = 2; /* dchild has a lock */
 
+        /* VBR: version recovery check for parent */
+        rc = mds_version_get_check(req, dparent->d_inode, 0);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+
+        /* version recovery check */
+        rc = mds_version_get_check(req, child_inode, 1);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+
         /* We have to do these checks ourselves, in case we are making an
          * orphan.  The client tells us whether rmdir() or unlink() was called,
          * so we need to return appropriate errors (bug 72). */
@@ -1740,15 +1925,15 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
          * only do the object removal later if no open files/links remain. */
         if ((S_ISDIR(child_inode->i_mode) && child_inode->i_nlink == 2) ||
             child_inode->i_nlink == 1) {
-                if (mds_orphan_open_count(child_inode) > 0) {
+                if (mds_orphan_needed(obd, child_inode)) {
                         /* need to lock pending_dir before transaction */
                         LOCK_INODE_MUTEX(mds->mds_pending_dir->d_inode);
                         cleanup_phase = 5; /* UNLOCK_INODE_MUTEX(mds->mds_pending_dir->d_inode); */
                 } else if (S_ISREG(child_inode->i_mode)) {
-                        mds_pack_inode2fid(&body->fid1, child_inode);
                         mds_pack_inode2body(body, child_inode);
                         mds_pack_md(obd, req->rq_repmsg, offset + 1, body,
-                                    child_inode, MDS_PACK_MD_LOCK, 0);
+                                    child_inode, MDS_PACK_MD_LOCK, 0,
+                                    req->rq_export->exp_connect_flags);
                 }
         }
 
@@ -1771,9 +1956,11 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
         case S_IFREG: {
                 struct lov_mds_md *lmm = lustre_msg_buf(req->rq_repmsg,
                                                         offset + 1, 0);
+                int sz = lustre_msg_buflen(req->rq_repmsg, offset + 1) > 0 ?
+                         le32_to_cpu(lmm->lmm_stripe_count) : 0;
+
                 handle = fsfilt_start_log(obd, dparent->d_inode,
-                                          FSFILT_OP_UNLINK, NULL,
-                                          le32_to_cpu(lmm->lmm_stripe_count));
+                                          FSFILT_OP_UNLINK, NULL, sz);
                 if (IS_ERR(handle))
                         GOTO(cleanup, rc = PTR_ERR(handle));
                 LOCK_INODE_MUTEX(dparent->d_inode);
@@ -1804,7 +1991,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
         }
 
         if (rc == 0 && child_inode->i_nlink == 0) {
-                if (mds_orphan_open_count(child_inode) > 0)
+                if (mds_orphan_needed(obd, child_inode))
                         rc = mds_orphan_add_link(rec, obd, dchild);
 
                 if (rc == 1)
@@ -1849,12 +2036,13 @@ cleanup:
                 if (err)
                         CERROR("error on parent setattr: rc = %d\n", err);
         }
-
-        rc = mds_finish_transno(mds, dparent ? dparent->d_inode : NULL,
-                                handle, req, rc, 0, 0);
+        inodes[0] = dparent ? dparent->d_inode : NULL;
+        inodes[1] = child_inode;
+        rc = mds_finish_transno(mds, inodes, handle, req, rc, 0, 0);
         if (!rc)
                 (void)obd_set_info_async(mds->mds_osc_exp, sizeof(KEY_UNLINKED),
                                          KEY_UNLINKED, 0, NULL, NULL);
+cleanup_no_trans:
         switch(cleanup_phase) {
         case 5: /* pending_dir semaphore */
                 UNLOCK_INODE_MUTEX(mds->mds_pending_dir->d_inode);
@@ -1903,6 +2091,7 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
         struct dentry *de_src = NULL;
         struct dentry *de_tgt_dir = NULL;
         struct dentry *dchild = NULL;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct mds_obd *mds = mds_req2mds(req);
         struct lustre_handle *handle = NULL, tgt_dir_lockh, src_lockh;
         struct ldlm_res_id src_res_id = { .name = {0} };
@@ -1928,7 +2117,7 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
 
         if (rec->ur_dlm)
                 ldlm_request_cancel(req, rec->ur_dlm, 0);
-        
+
         /* Step 1: Lookup the source inode and target directory by FID */
         de_src = mds_fid2dentry(mds, rec->ur_fid1, NULL);
         if (IS_ERR(de_src))
@@ -1964,6 +2153,16 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
 
         cleanup_phase = 3; /* locks */
 
+        /* version recovery check */
+        /* directory check */
+        rc = mds_version_get_check(req, de_tgt_dir->d_inode, 0);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+        /* inode version check */
+        rc = mds_version_get_check(req, de_src->d_inode, 1);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+
         if (mds_inode_is_orphan(de_src->d_inode)) {
                 CDEBUG(D_INODE, "an attempt to link an orphan inode %lu/%u\n",
                        de_src->d_inode->i_ino,
@@ -1972,9 +2171,10 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
         }
 
         /* Step 3: Lookup the child */
-        dchild = ll_lookup_one_len(rec->ur_name, de_tgt_dir, rec->ur_namelen-1);
+        dchild = mds_lookup(obd, rec->ur_name, de_tgt_dir, rec->ur_namelen-1);
         if (IS_ERR(dchild)) {
                 rc = PTR_ERR(dchild);
+                dchild = NULL;
                 if (rc != -EPERM && rc != -EACCES && rc != -ENAMETOOLONG)
                         CERROR("child lookup error %d\n", rc);
                 GOTO(cleanup, rc);
@@ -2027,10 +2227,12 @@ static int mds_reint_link(struct mds_update_record *rec, int offset,
                                "rc = %d\n", err);
         }
 cleanup:
-        rc = mds_finish_transno(mds, de_tgt_dir ? de_tgt_dir->d_inode : NULL,
-                                handle, req, rc, 0, 0);
+        inodes[0] = de_tgt_dir ? de_tgt_dir->d_inode : NULL;
+        inodes[1] = (dchild && !IS_ERR(dchild)) ? dchild->d_inode : NULL;
+        rc = mds_finish_transno(mds, inodes, handle, req, rc, 0, 0);
         EXIT;
 
+cleanup_no_trans:
         switch (cleanup_phase) {
         case 4: /* child dentry */
                 l_dput(dchild);
@@ -2100,7 +2302,8 @@ int mds_get_parents_children_locked(struct obd_device *obd,
         /* Only dentry should disappear, but the inode itself would be
            intact otherwise. */
         ldlm_policy_data_t c1_policy = {.l_inodebits = {MDS_INODELOCK_LOOKUP}};
-        /* If something is going to be replaced, both dentry and inode locks are           needed */
+        /* If something is going to be replaced, both dentry and inode locks are
+         * needed */
         ldlm_policy_data_t c2_policy = {.l_inodebits = {MDS_INODELOCK_FULL}};
         struct ldlm_res_id *maxres_src, *maxres_tgt;
         struct inode *inode;
@@ -2135,7 +2338,7 @@ int mds_get_parents_children_locked(struct obd_device *obd,
         p2_res_id.name[1] = (*de_tgtdirp)->d_inode->i_generation;
 
         /* Step 3: Lookup the source child entry */
-        *de_oldp = ll_lookup_one_len(old_name, *de_srcdirp, old_len - 1);
+        *de_oldp = mds_lookup(obd, old_name, *de_srcdirp, old_len - 1);
         if (IS_ERR(*de_oldp)) {
                 rc = PTR_ERR(*de_oldp);
                 CDEBUG(D_INODE, "old child lookup error (%.*s): rc %d\n",
@@ -2159,7 +2362,7 @@ int mds_get_parents_children_locked(struct obd_device *obd,
         /* Step 4: Lookup the target child entry */
         if (!new_name)
                 GOTO(retry_locks, rc);
-        *de_newp = ll_lookup_one_len(new_name, *de_tgtdirp, new_len - 1);
+        *de_newp = mds_lookup(obd, new_name, *de_tgtdirp, new_len - 1);
         if (IS_ERR(*de_newp)) {
                 rc = PTR_ERR(*de_newp);
                 CDEBUG(D_DENTRY, "new child lookup error (%.*s): rc %d\n",
@@ -2282,11 +2485,12 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
         struct dentry *de_old = NULL;
         struct dentry *de_new = NULL;
         struct inode *old_inode = NULL, *new_inode = NULL;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct mds_obd *mds = mds_req2mds(req);
         struct lustre_handle dlm_handles[4];
         struct mds_body *body = NULL;
         struct lov_mds_md *lmm = NULL;
-        int rc = 0, lock_count = 3, cleanup_phase = 0;
+        int rc = 0, lock_count = 3, cleanup_phase = 0, sz;
         void *handle = NULL;
         unsigned int qcids[MAXQUOTAS] = { 0, 0 };
         unsigned int qpids[4] = { 0, 0, 0, 0 };
@@ -2300,7 +2504,7 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
                   rec->ur_fid2->id, rec->ur_fid2->generation, rec->ur_tgt);
 
         mds_counter_incr(req->rq_export, LPROC_MDS_RENAME);
-        
+
         MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
 
         if (rec->ur_dlm)
@@ -2323,6 +2527,20 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
         if (new_inode != NULL)
                 lock_count = 4;
 
+        /* version recovery check */
+        rc = mds_version_get_check(req, de_srcdir->d_inode, 0);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+        rc = mds_version_get_check(req, old_inode, 1);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+        rc = mds_version_get_check(req, de_tgtdir->d_inode, 2);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+        rc = mds_version_get_check(req, new_inode, 3);
+        if (rc)
+                GOTO(cleanup_no_trans, rc);
+
         /* sanity check for src inode */
         if (old_inode->i_ino == de_srcdir->d_inode->i_ino ||
             old_inode->i_ino == de_tgtdir->d_inode->i_ino)
@@ -2364,15 +2582,15 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset,
 
         if ((S_ISDIR(new_inode->i_mode) && new_inode->i_nlink == 2) ||
             new_inode->i_nlink == 1) {
-                if (mds_orphan_open_count(new_inode) > 0) {
+                if (mds_orphan_needed(obd, new_inode)) {
                         /* need to lock pending_dir before transaction */
                         LOCK_INODE_MUTEX(mds->mds_pending_dir->d_inode);
                         cleanup_phase = 4; /* UNLOCK_INODE_MUTEX(mds->mds_pending_dir->d_inode); */
                 } else if (S_ISREG(new_inode->i_mode)) {
-                        mds_pack_inode2fid(&body->fid1, new_inode);
                         mds_pack_inode2body(body, new_inode);
                         mds_pack_md(obd, req->rq_repmsg, offset + 1, body,
-                                    new_inode, MDS_PACK_MD_LOCK, 0);
+                                    new_inode, MDS_PACK_MD_LOCK, 0,
+                                    req->rq_export->exp_connect_flags);
                 }
         }
 
@@ -2386,9 +2604,12 @@ no_unlink:
                 GOTO(cleanup, rc = -EINVAL);
 
         lmm = lustre_msg_buf(req->rq_repmsg, offset + 1, 0);
-        handle = fsfilt_start_log(obd, de_tgtdir->d_inode, FSFILT_OP_RENAME,
-                                  NULL, le32_to_cpu(lmm->lmm_stripe_count));
+        /* check that lmm size is not 0 */
+        sz = lustre_msg_buflen(req->rq_repmsg, offset + 1) > 0 ?
+             le32_to_cpu(lmm->lmm_stripe_count) : 0;
 
+        handle = fsfilt_start_log(obd, de_tgtdir->d_inode, FSFILT_OP_RENAME,
+                                  NULL, sz);
         if (IS_ERR(handle))
                 GOTO(cleanup, rc = PTR_ERR(handle));
 
@@ -2453,7 +2674,7 @@ no_unlink:
         }
 
         if (rc == 0 && new_inode != NULL && new_inode->i_nlink == 0) {
-                if (mds_orphan_open_count(new_inode) > 0)
+                if (mds_orphan_needed(obd, new_inode))
                         rc = mds_orphan_add_link(rec, obd, de_new);
 
                 if (rc == 1)
@@ -2481,9 +2702,13 @@ no_unlink:
 
         GOTO(cleanup, rc);
 cleanup:
-        rc = mds_finish_transno(mds, de_tgtdir ? de_tgtdir->d_inode : NULL,
-                                handle, req, rc, 0, 0);
+        inodes[0] = de_srcdir && !IS_ERR(de_srcdir) ? de_srcdir->d_inode : NULL;
+        inodes[1] = old_inode;
+        inodes[2] = de_tgtdir && !IS_ERR(de_tgtdir) ? de_tgtdir->d_inode : NULL;
+        inodes[3] = new_inode;
+        rc = mds_finish_transno(mds, inodes, handle, req, rc, 0, 0);
 
+cleanup_no_trans:
         switch (cleanup_phase) {
         case 4:
                 UNLOCK_INODE_MUTEX(mds->mds_pending_dir->d_inode);
diff --git a/lustre/mds/mds_unlink_open.c b/lustre/mds/mds_unlink_open.c
index f24a9dc..0e6d15a 100644
--- a/lustre/mds/mds_unlink_open.c
+++ b/lustre/mds/mds_unlink_open.c
@@ -92,8 +92,9 @@ int mds_osc_destroy_orphan(struct obd_device *obd,
         if (oa == NULL)
                 GOTO(out_free_memmd, rc = -ENOMEM);
         oa->o_id = lsm->lsm_object_id;
+        oa->o_gr = 0;
         oa->o_mode = mode & S_IFMT;
-        oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE;
+        oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP;
 
         if (log_unlink && logcookies) {
                 oa->o_valid |= OBD_MD_FLCOOKIE;
@@ -122,7 +123,7 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild,
         ENTRY;
 
         LASSERT(mds->mds_osc_obd != NULL);
-        
+
         /* We don't need to do any of these other things for orhpan dirs,
          * especially not mds_get_md (may get a default LOV EA, bug 4554) */
         mode = inode->i_mode;
@@ -139,7 +140,7 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild,
         if (lmm == NULL)
                 RETURN(-ENOMEM);
 
-        rc = mds_get_md(obd, inode, lmm, &lmm_size, 1, 0);
+        rc = mds_get_md(obd, inode, lmm, &lmm_size, 1, 0, 0);
         if (rc < 0)
                 GOTO(out_free_lmm, rc);
 
@@ -183,6 +184,19 @@ out_free_lmm:
         RETURN(rc);
 }
 
+static __u64 mds_orphans_max_version(struct obd_device *obd)
+{
+        struct obd_export *exp;
+        __u32 epoch = lr_epoch(obd->u.mds.mds_last_transno);
+        spin_lock(&obd->obd_dev_lock);
+        list_for_each_entry(exp, &obd->obd_delayed_exports, exp_obd_chain) {
+                struct lu_export_data *led = &exp->exp_target_data;
+                epoch = min(epoch, le32_to_cpu(led->led_lcd->lcd_first_epoch));
+        }
+        spin_unlock(&obd->obd_dev_lock);
+        return (__u64)epoch << LR_EPOCH_BITS;
+}
+
 /* Delete inodes which were previously open-unlinked but were not reopened
  * during MDS recovery for whatever reason (e.g. client also failed, recovery
  * aborted, etc). */
@@ -198,6 +212,7 @@ int mds_cleanup_pending(struct obd_device *obd)
         struct list_head dentry_list;
         char d_name[LL_FID_NAMELEN];
         unsigned long inum;
+        __u64 max_version;
         int i = 0, rc = 0, item = 0, namlen;
         ENTRY;
 
@@ -216,13 +231,19 @@ int mds_cleanup_pending(struct obd_device *obd)
         if (IS_ERR(file))
                 GOTO(err_pop, rc = PTR_ERR(file));
 
-        INIT_LIST_HEAD(&dentry_list);
+        CFS_INIT_LIST_HEAD(&dentry_list);
         rc = l_readdir(file, &dentry_list);
         filp_close(file, 0);
         if (rc < 0)
                 GOTO(err_out, rc);
 
+        /** Get maximum version for orphans to delete. All other orphans may be
+         *  needed for delayed clients */
+        max_version = mds_orphans_max_version(obd);
+
         list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
+                __u64 version;
+
                 i++;
                 list_del(&dirent->lld_list);
 
@@ -230,7 +251,7 @@ int mds_cleanup_pending(struct obd_device *obd)
                 LASSERT(sizeof(d_name) >= namlen + 1);
                 strcpy(d_name, dirent->lld_name);
                 inum = dirent->lld_ino;
-                OBD_FREE(dirent, sizeof(*dirent));
+                OBD_FREE_PTR(dirent);
 
                 CDEBUG(D_INODE, "entry %d of PENDING DIR: %s\n", i, d_name);
 
@@ -266,6 +287,17 @@ int mds_cleanup_pending(struct obd_device *obd)
                               obd->obd_name, d_name);
                         GOTO(next, rc = 0);
                 }
+                /** Keep orphans for possible use by delayed exports. Remove
+                 * orphans with version lower than minimal one of all exports */
+                version = fsfilt_get_version(obd, child_inode);
+                if ((__s64)version != -EOPNOTSUPP &&
+                    version >= max_version) {
+                        MDS_UP_READ_ORPHAN_SEM(child_inode);
+                        CDEBUG(D_INFO,
+                               "%s: orphan %s is needed for delayed exports\n",
+                               obd->obd_name, d_name);
+                        GOTO(next, rc = 0);
+                }
                 MDS_UP_READ_ORPHAN_SEM(child_inode);
 
                 rc = mds_unlink_orphan(obd, dchild, child_inode, pending_dir);
@@ -296,3 +328,79 @@ err_mntget:
         l_dput(mds->mds_pending_dir);
         goto err_pop;
 }
+
+/**
+ * Determine there is no orphan with the same inode number. That may happens
+ * since unlink replay don't delete inode but keep orphan for delayed clients.
+ * Therefore replays like 'create, unlink, create' will fail due to inode can't
+ * be reused.
+ */
+int mds_check_stale_orphan(struct obd_device *obd, struct ll_fid *fid)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        char fidname[32];
+        struct dentry *result;
+        struct inode *inode, *pending_dir = mds->mds_pending_dir->d_inode;
+        int fidlen = 0, rc = 0;
+
+        /* no need in checks*/
+        if (fid->id == 0 || obd->obd_recovering == 0)
+                RETURN(0);
+
+        /** open by fid like mds_fid2dentry does */
+        snprintf(fidname, sizeof(fidname), "0x%lx", (unsigned long)(fid->id));
+        fidlen = strlen(fidname);
+        result = mds_lookup(obd, fidname, mds->mds_fid_de, fidlen);
+        if (IS_ERR(result))
+                RETURN(0);
+        inode = result->d_inode;
+        if (!inode)
+                GOTO(out, rc = 0);
+
+        LOCK_INODE_MUTEX(pending_dir);
+        MDS_DOWN_READ_ORPHAN_SEM(inode);
+        if (mds_inode_is_orphan(inode)) {
+                struct dentry *orphan;
+
+                /* bz18927: The exactly same inode can be marked as orphan
+                 * if there was open|creat replay and this is second one */
+                if (inode->i_generation == fid->generation)
+                        GOTO(unlock_child, rc);
+
+                if (mds_orphan_open_count(inode) > 0) {
+                        CERROR("Orphan "LPU64"/%u is in use!\n",
+                               fid->id, fid->generation);
+                        GOTO(unlock_child, rc = -EFAULT);
+                }
+
+                /** Found orphan in pending dir and delete it */
+                fidlen = ll_fid2str(fidname, fid->id, inode->i_generation);
+                orphan = lookup_one_len(fidname, mds->mds_pending_dir, fidlen);
+                if (IS_ERR(orphan)) {
+                        rc = PTR_ERR(orphan);
+                        CERROR("error looking up %s in PENDING: rc = %d\n",
+                                fidname, rc);
+                        GOTO(unlock_child, rc);
+                }
+                if (orphan->d_inode != inode) {
+                        l_dput(orphan);
+                        CWARN("%s: Found wrong orphan %s %p/%p\n",
+                              obd->obd_name, fidname, orphan->d_inode, inode);
+                        GOTO(unlock_child, rc = -EFAULT);
+                }
+                MDS_UP_READ_ORPHAN_SEM(inode);
+
+                rc = mds_unlink_orphan(obd, orphan, inode, pending_dir);
+                CDEBUG(D_INODE, "%s: removed orphan %s: rc %d\n",
+                       obd->obd_name, fidname, rc);
+                l_dput(orphan);
+                GOTO(unlock, rc);
+        }
+unlock_child:
+        MDS_UP_READ_ORPHAN_SEM(inode);
+unlock:
+        UNLOCK_INODE_MUTEX(pending_dir);
+out:
+        l_dput(result);
+        RETURN(0);
+}
diff --git a/lustre/mds/mds_xattr.c b/lustre/mds/mds_xattr.c
index de43c1f..cd84bc5 100644
--- a/lustre/mds/mds_xattr.c
+++ b/lustre/mds/mds_xattr.c
@@ -226,12 +226,13 @@ int mds_setxattr_internal(struct ptlrpc_request *req, struct mds_body *body)
         struct obd_device *obd = req->rq_export->exp_obd;
         struct dentry *de;
         struct inode *inode = NULL;
+        struct inode *inodes[PTLRPC_NUM_VERSIONS] = { NULL };
         struct lustre_handle lockh;
         void *handle = NULL;
         char *xattr_name;
         char *xattr = NULL;
         int xattrlen;
-        int rc = -EOPNOTSUPP, err = 0;
+        int rc = -EOPNOTSUPP, err = 0, sync = 0;
         __u64 lockpart;
         ENTRY;
 
@@ -258,6 +259,9 @@ int mds_setxattr_internal(struct ptlrpc_request *req, struct mds_body *body)
         if (strncmp(xattr_name, "trusted.", 8) == 0) {
                 if (strcmp(xattr_name + 8, XATTR_LUSTRE_MDS_LOV_EA) == 0)
                         GOTO(out, rc = -EACCES);
+                if (strcmp(xattr_name + 8, "lma") == 0 &&
+                    !OBD_FAIL_CHECK(OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING))
+                        GOTO(out, rc = 0);
         }
 
         if (!(req->rq_export->exp_connect_flags & OBD_CONNECT_XATTR) &&
@@ -288,6 +292,11 @@ int mds_setxattr_internal(struct ptlrpc_request *req, struct mds_body *body)
 
         OBD_FAIL_WRITE(obd, OBD_FAIL_MDS_SETXATTR_WRITE, inode->i_sb);
 
+        /* version recovery check */
+        rc = mds_version_get_check(req, inode, 0);
+        if (rc)
+                GOTO(out_dput, rc);
+
         /* filter_op simply use setattr one */
         handle = fsfilt_start(obd, inode, FSFILT_OP_SETATTR, NULL);
         if (IS_ERR(handle))
@@ -324,8 +333,11 @@ int mds_setxattr_internal(struct ptlrpc_request *req, struct mds_body *body)
 
         LASSERT(rc <= 0);
 out_trans:
-        err = mds_finish_transno(mds, inode, handle, req, rc, 0, 0);
-
+        /* security-replated changes may require sync */
+        if (!strcmp(xattr_name, XATTR_NAME_ACL_ACCESS))
+                sync = mds->mds_sync_permission;
+        inodes[0] = inode;
+        err = mds_finish_transno(mds, inodes, handle, req, rc, 0, sync);
 out_dput:
         l_dput(de);
         if (rc)
diff --git a/lustre/mgc/Makefile.in b/lustre/mgc/Makefile.in
index 8adca32..7ce8a37 100644
--- a/lustre/mgc/Makefile.in
+++ b/lustre/mgc/Makefile.in
@@ -1,4 +1,6 @@
 MODULES := mgc
 mgc-objs := mgc_request.o lproc_mgc.o
 
+EXTRA_DIST := $(mgc-objs:%.o=%.c) libmgc.c mgc_internal.h
+
 @INCLUDE_RULES@
diff --git a/lustre/mgc/autoMakefile.am b/lustre/mgc/autoMakefile.am
index db9a433..e337ea9 100644
--- a/lustre/mgc/autoMakefile.am
+++ b/lustre/mgc/autoMakefile.am
@@ -46,4 +46,3 @@ modulefs_DATA = mgc$(KMODEXT)
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES := $(mgc-objs:%.o=%.c) libmgc.c mgc_internal.h
diff --git a/lustre/mgc/autoMakefile.in b/lustre/mgc/autoMakefile.in
index 530b0fc..1b58722 100644
--- a/lustre/mgc/autoMakefile.in
+++ b/lustre/mgc/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -335,7 +335,6 @@ target_vendor = @target_vendor@
 @LIBLUSTRE_TRUE at libmgc_a_CFLAGS = $(LLCFLAGS)
 
 @MODULES_TRUE at modulefs_DATA = mgc$(KMODEXT)
-DIST_SOURCES := $(mgc-objs:%.o=%.c) libmgc.c mgc_internal.h
 subdir = lustre/mgc
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -357,6 +356,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libmgc_a_SOURCES_DIST)
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/mgc/libmgc.c b/lustre/mgc/libmgc.c
index bb5f415..5abbd8d 100644
--- a/lustre/mgc/libmgc.c
+++ b/lustre/mgc/libmgc.c
@@ -41,7 +41,7 @@
 
 /* Minimal MGC for liblustre: only used to read the config log from the MGS
    at setup time, no updates. */
- 
+
 #ifndef EXPORT_SYMTAB
 # define EXPORT_SYMTAB
 #endif
@@ -87,8 +87,19 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         ENTRY;
 
         switch (stage) {
-        case OBD_CLEANUP_EARLY: 
+        case OBD_CLEANUP_EARLY:
         case OBD_CLEANUP_EXPORTS:
+                /* client import will not have been cleaned. */
+                down_write(&obd->u.cli.cl_sem);
+                if (obd->u.cli.cl_import) {
+                        struct obd_import *imp;
+                        imp = obd->u.cli.cl_import;
+                        CERROR("client import never connected\n");
+                        class_destroy_import(imp);
+                        obd->u.cli.cl_import = NULL;
+                }
+                up_write(&obd->u.cli.cl_sem);
+
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");
@@ -108,7 +119,7 @@ static int mgc_cleanup(struct obd_device *obd)
         ENTRY;
 
         LASSERT(cli->cl_mgc_vfsmnt == NULL);
-        
+
         ptlrpcd_decref();
 
         rc = client_obd_cleanup(obd);
@@ -116,7 +127,7 @@ static int mgc_cleanup(struct obd_device *obd)
 }
 
 static int mgc_llog_init(struct obd_device *obd, struct obd_device *tgt,
-                         int count, struct llog_catid *logid, 
+                         int count, struct llog_catid *logid,
                          struct obd_uuid *uuid)
 {
         struct llog_ctxt *ctxt;
diff --git a/lustre/mgc/lproc_mgc.c b/lustre/mgc/lproc_mgc.c
index ba98f1b..bf708ab 100644
--- a/lustre/mgc/lproc_mgc.c
+++ b/lustre/mgc/lproc_mgc.c
@@ -49,6 +49,7 @@ static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
         { "mgs_server_uuid", lprocfs_rd_server_uuid,   0, 0 },
         { "mgs_conn_uuid",   lprocfs_rd_conn_uuid,     0, 0 },
         { "import",          lprocfs_rd_import,    0, 0 },
+        { "state",           lprocfs_rd_state,         0, 0 },
         { 0 }
 };
 
diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c
index 5a7714b..4b989cd 100644
--- a/lustre/mgc/mgc_request.c
+++ b/lustre/mgc/mgc_request.c
@@ -415,7 +415,7 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb,
         obd->obd_lvfs_ctxt.fs = get_ds();
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        dentry = lookup_one_len(MOUNT_CONFIGS_DIR, current->fs->pwd,
+        dentry = lookup_one_len(MOUNT_CONFIGS_DIR, cfs_fs_pwd(current->fs),
                                 strlen(MOUNT_CONFIGS_DIR));
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         if (IS_ERR(dentry)) {
@@ -489,6 +489,17 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                         spin_unlock(&config_list_lock);
                         cfs_waitq_signal(&rq_waitq);
                 }
+                /* client import will not have been cleaned. */
+                down_write(&obd->u.cli.cl_sem);
+                if (obd->u.cli.cl_import) {
+                        struct obd_import *imp;
+                        imp = obd->u.cli.cl_import;
+                        CERROR("client import never connected\n");
+                        class_destroy_import(imp);
+                        obd->u.cli.cl_import = NULL;
+                }
+                up_write(&obd->u.cli.cl_sem);
+
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");
@@ -897,7 +908,6 @@ static int mgc_import_event(struct obd_device *obd,
 
         switch (event) {
         case IMP_EVENT_DISCON:
-                /* MGC imports should not wait for recovery */
                 break;
         case IMP_EVENT_INACTIVE:
                 break;
diff --git a/lustre/mgs/Makefile.in b/lustre/mgs/Makefile.in
index 8bb6a5f..413f381 100644
--- a/lustre/mgs/Makefile.in
+++ b/lustre/mgs/Makefile.in
@@ -1,4 +1,6 @@
 MODULES := mgs
 mgs-objs := mgs_handler.o mgs_fs.o mgs_llog.o lproc_mgs.o
 
+EXTRA_DIST := $(mgs-objs:%.o=%.c) mgs_internal.h
+
 @INCLUDE_RULES@
diff --git a/lustre/mgs/autoMakefile.am b/lustre/mgs/autoMakefile.am
index c538cb4..a57c433 100644
--- a/lustre/mgs/autoMakefile.am
+++ b/lustre/mgs/autoMakefile.am
@@ -39,4 +39,3 @@ modulefs_DATA = mgs$(KMODEXT)
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES := $(mgs-objs:%.o=%.c) mgs_internal.h
diff --git a/lustre/mgs/autoMakefile.in b/lustre/mgs/autoMakefile.in
index 6b15b52..149b4a8 100644
--- a/lustre/mgs/autoMakefile.in
+++ b/lustre/mgs/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @MODULES_TRUE at modulefs_DATA = mgs$(KMODEXT)
-DIST_SOURCES := $(mgs-objs:%.o=%.c) mgs_internal.h
 subdir = lustre/mgs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/mgs/mgs_fs.c b/lustre/mgs/mgs_fs.c
index 95a14b4..cc6b3f0 100644
--- a/lustre/mgs/mgs_fs.c
+++ b/lustre/mgs/mgs_fs.c
@@ -79,22 +79,25 @@ static int mgs_export_stats_init(struct obd_device *obd,
                 num_stats = (sizeof(*obd->obd_type->typ_ops) / sizeof(void *)) +
                              LPROC_MGS_LAST - 1;
                 exp->exp_ops_stats = lprocfs_alloc_stats(num_stats,
-                                                         LPROCFS_STATS_FLAG_NOPERCPU);
+                                                LPROCFS_STATS_FLAG_NOPERCPU);
                 if (exp->exp_ops_stats == NULL)
                         return -ENOMEM;
                 lprocfs_init_ops_stats(LPROC_MGS_LAST, exp->exp_ops_stats);
                 mgs_stats_counter_init(exp->exp_ops_stats);
-                lprocfs_register_stats(exp->exp_nid_stats->nid_proc, "stats", exp->exp_ops_stats);
+                lprocfs_register_stats(exp->exp_nid_stats->nid_proc, "stats",
+                                       exp->exp_ops_stats);
 
                 /* Always add in ldlm_stats */
-                exp->exp_nid_stats->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC -
-                                                                         LDLM_FIRST_OPC, 0);
+                exp->exp_nid_stats->nid_ldlm_stats =
+                        lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC,
+                                            LPROCFS_STATS_FLAG_NOPERCPU);
                 if (exp->exp_nid_stats->nid_ldlm_stats == NULL)
                         return -ENOMEM;
 
                 lprocfs_init_ldlm_stats(exp->exp_nid_stats->nid_ldlm_stats);
 
-                rc = lprocfs_register_stats(exp->exp_nid_stats->nid_proc, "ldlm_stats",
+                rc = lprocfs_register_stats(exp->exp_nid_stats->nid_proc,
+                                            "ldlm_stats",
                                             exp->exp_nid_stats->nid_ldlm_stats);
         }
 
@@ -215,7 +218,7 @@ int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
         /* Setup the configs dir */
-        dentry = simple_mkdir(current->fs->pwd, mnt, MOUNT_CONFIGS_DIR, 0777, 1);
+        dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, MOUNT_CONFIGS_DIR, 0777, 1);
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
                 CERROR("cannot create %s directory: rc = %d\n",
@@ -226,7 +229,7 @@ int mgs_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
 
         /* Need the iopen dir for fid2dentry, required by
            LLOG_ORIGIN_HANDLE_READ_HEADER */
-        dentry = lookup_one_len("__iopen__", current->fs->pwd,
+        dentry = lookup_one_len("__iopen__", cfs_fs_pwd(current->fs),
                                 strlen("__iopen__"));
         if (IS_ERR(dentry)) {
                 rc = PTR_ERR(dentry);
diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c
index 80179f8..2471b3e 100644
--- a/lustre/mgs/mgs_handler.c
+++ b/lustre/mgs/mgs_handler.c
@@ -91,6 +91,7 @@ static int mgs_connect(struct lustre_handle *conn, struct obd_device *obd,
 
         if (rc) {
                 class_disconnect(exp);
+                lprocfs_exp_cleanup(exp);
         } else {
                 class_export_put(exp);
         }
@@ -181,6 +182,12 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
         if (IS_ERR(obd->obd_fsops))
                 GOTO(err_put, rc = PTR_ERR(obd->obd_fsops));
 
+        if (lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb))) {
+                CERROR("%s: Underlying device is marked as read-only. "
+                       "Setup failed\n", obd->obd_name);
+                GOTO(err_ops, rc = -EROFS);
+        }
+
         /* namespace for mgs llog */
         obd->obd_namespace = ldlm_namespace_new(obd, "MGS", LDLM_NAMESPACE_SERVER,
                                                 LDLM_NAMESPACE_MODEST);
@@ -191,12 +198,6 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
         ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
                            "mgs_ldlm_client", &obd->obd_ldlm_client);
 
-        if (lvfs_check_rdonly(lvfs_sbdev(mnt->mnt_sb))) {
-                CERROR("%s: Underlying device is marked as read-only. "
-                       "Setup failed\n", obd->obd_name);
-                GOTO(err_ops, rc = -EROFS);
-        }
-
         rc = mgs_fs_setup(obd, mnt);
         if (rc) {
                 CERROR("%s: MGS filesystem method init failed: rc = %d\n",
@@ -220,7 +221,7 @@ static int mgs_setup(struct obd_device *obd, obd_count len, void *buf)
         mgs->mgs_service =
                 ptlrpc_init_svc(MGS_NBUFS, MGS_BUFSIZE, MGS_MAXREQSIZE,
                                 MGS_MAXREPSIZE, MGS_REQUEST_PORTAL,
-                                MGC_REPLY_PORTAL, 2000,
+                                MGC_REPLY_PORTAL, 2,
                                 mgs_handle, LUSTRE_MGS_NAME,
                                 obd->obd_proc_entry, NULL,
                                 MGS_THREADS_AUTO_MIN, MGS_THREADS_AUTO_MAX,
@@ -341,6 +342,21 @@ static int mgs_put_cfg_lock(struct lustre_handle *lockh)
         RETURN(0);
 }
 
+static void mgs_revoke_lock(struct obd_device *obd, char *fsname,
+                            struct lustre_handle *lockh)
+{
+        int lockrc;
+
+        if (fsname[0]) {
+                lockrc = mgs_get_cfg_lock(obd, fsname, lockh);
+                if (lockrc != ELDLM_OK)
+                        CERROR("lock error %d for fs %s\n", lockrc,
+                               fsname);
+                else
+                        mgs_put_cfg_lock(lockh);
+        }
+}
+
 /* rc=0 means ok
       1 means update
      <0 means error */
@@ -386,6 +402,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req)
 
         mti = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*mti),
                                  lustre_swab_mgs_target_info);
+        LASSERT(mti);
 
         if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 |
                                 LDD_F_UPDATE))) {
@@ -491,7 +508,7 @@ static int mgs_set_info_rpc(struct ptlrpc_request *req)
         struct mgs_send_param *msp, *rep_msp;
         struct lustre_handle lockh;
         int rep_size[] = { sizeof(struct ptlrpc_body), sizeof(*msp) };
-        int lockrc, rc;
+        int rc;
         struct lustre_cfg_bufs bufs;
         struct lustre_cfg *lcfg;
         char fsname[MTI_NAME_MAXLEN];
@@ -510,19 +527,9 @@ static int mgs_set_info_rpc(struct ptlrpc_request *req)
                 RETURN(rc);
         }
 
-        /* Revoke lock so everyone updates.  Should be alright if
-         * someone was already reading while we were updating the logs,
-         * so we don't really need to hold the lock while we're
-         * writing.
-         */
-        if (fsname[0]) {
-                lockrc = mgs_get_cfg_lock(obd, fsname, &lockh);
-                if (lockrc != ELDLM_OK)
-                        CERROR("lock error %d for fs %s\n", lockrc,
-                               fsname);
-                else
-                        mgs_put_cfg_lock(&lockh);
-        }
+        /* request for update */
+        mgs_revoke_lock(obd, fsname, &lockh);
+
         lustre_cfg_free(lcfg);
 
         lustre_pack_reply(req, 2, rep_size, NULL);
@@ -674,6 +681,134 @@ static inline int mgs_destroy_export(struct obd_export *exp)
         RETURN(0);
 }
 
+static int mgs_extract_fs_pool(char * arg, char *fsname, char *poolname)
+{
+        char *ptr;
+
+        ENTRY;
+        for (ptr = arg;  (*ptr != '\0') && (*ptr != '.'); ptr++ ) {
+                *fsname = *ptr;
+                fsname++;
+        }
+        if (*ptr == '\0')
+                return -EINVAL;
+        *fsname = '\0';
+        ptr++;
+        strcpy(poolname, ptr);
+
+        RETURN(0);
+}
+
+static int mgs_iocontrol_pool(struct obd_device *obd,
+                              struct obd_ioctl_data *data)
+{
+        int rc;
+        struct lustre_handle lockh;
+        struct lustre_cfg *lcfg = NULL;
+        struct llog_rec_hdr rec;
+        char *fsname = NULL;
+        char *poolname = NULL;
+        ENTRY;
+
+        OBD_ALLOC(fsname, MTI_NAME_MAXLEN);
+        if (fsname == NULL)
+                RETURN(-ENOMEM);
+
+        OBD_ALLOC(poolname, LOV_MAXPOOLNAME + 1);
+        if (poolname == NULL) {
+                rc = -ENOMEM;
+                GOTO(out_pool, rc);
+        }
+        rec.lrh_len = llog_data_len(data->ioc_plen1);
+
+        if (data->ioc_type == LUSTRE_CFG_TYPE) {
+                rec.lrh_type = OBD_CFG_REC;
+        } else {
+                CERROR("unknown cfg record type:%d \n", data->ioc_type);
+                rc = -EINVAL;
+                GOTO(out_pool, rc);
+        }
+
+        if (data->ioc_plen1 > CFS_PAGE_SIZE) {
+                rc = -E2BIG;
+                GOTO(out_pool, rc);
+        }
+
+        OBD_ALLOC(lcfg, data->ioc_plen1);
+        if (lcfg == NULL) {
+                rc = -ENOMEM;
+                GOTO(out_pool, rc);
+        }
+        rc = copy_from_user(lcfg, data->ioc_pbuf1, data->ioc_plen1);
+        if (rc)
+                GOTO(out_pool, rc);
+
+        if (lcfg->lcfg_bufcount < 2) {
+                rc = -EINVAL;
+                GOTO(out_pool, rc);
+        }
+
+        /* first arg is always <fsname>.<poolname> */
+        mgs_extract_fs_pool(lustre_cfg_string(lcfg, 1), fsname,
+                            poolname);
+
+        switch (lcfg->lcfg_command) {
+        case LCFG_POOL_NEW: {
+                if (lcfg->lcfg_bufcount != 2)
+                        RETURN(-EINVAL);
+                rc = mgs_pool_cmd(obd, LCFG_POOL_NEW, fsname,
+                                  poolname, NULL);
+                break;
+        }
+        case LCFG_POOL_ADD: {
+                if (lcfg->lcfg_bufcount != 3)
+                        RETURN(-EINVAL);
+                rc = mgs_pool_cmd(obd, LCFG_POOL_ADD, fsname, poolname,
+                                  lustre_cfg_string(lcfg, 2));
+                break;
+        }
+        case LCFG_POOL_REM: {
+                if (lcfg->lcfg_bufcount != 3)
+                        RETURN(-EINVAL);
+                rc = mgs_pool_cmd(obd, LCFG_POOL_REM, fsname, poolname,
+                                  lustre_cfg_string(lcfg, 2));
+                break;
+        }
+        case LCFG_POOL_DEL: {
+                if (lcfg->lcfg_bufcount != 2)
+                        RETURN(-EINVAL);
+                rc = mgs_pool_cmd(obd, LCFG_POOL_DEL, fsname,
+                                  poolname, NULL);
+                break;
+        }
+        default: {
+                 rc = -EINVAL;
+                 GOTO(out_pool, rc);
+        }
+        }
+
+        if (rc) {
+                CERROR("OBD_IOC_POOL err %d, cmd %X for pool %s.%s\n",
+                       rc, lcfg->lcfg_command, fsname, poolname);
+                GOTO(out_pool, rc);
+        }
+
+        /* request for update */
+        mgs_revoke_lock(obd, fsname, &lockh);
+
+out_pool:
+        if (lcfg != NULL)
+                OBD_FREE(lcfg, data->ioc_plen1);
+
+        if (fsname != NULL)
+                OBD_FREE(fsname, MTI_NAME_MAXLEN);
+
+        if (poolname != NULL)
+                OBD_FREE(poolname, LOV_MAXPOOLNAME + 1);
+
+        RETURN(rc);
+}
+
 /* from mdt_iocontrol */
 int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                   void *karg, void *uarg)
@@ -693,7 +828,6 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 struct lustre_cfg *lcfg;
                 struct llog_rec_hdr rec;
                 char fsname[MTI_NAME_MAXLEN];
-                int lockrc;
 
                 rec.lrh_len = llog_data_len(data->ioc_plen1);
 
@@ -724,20 +858,17 @@ int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                    someone was already reading while we were updating the logs,
                    so we don't really need to hold the lock while we're
                    writing (above). */
-                if (fsname[0]) {
-                        lockrc = mgs_get_cfg_lock(obd, fsname, &lockh);
-                        if (lockrc != ELDLM_OK)
-                                CERROR("lock error %d for fs %s\n", lockrc,
-                                       fsname);
-                        else
-                                mgs_put_cfg_lock(&lockh);
-                }
+                mgs_revoke_lock(obd, fsname, &lockh);
 
 out_free:
                 OBD_FREE(lcfg, data->ioc_plen1);
                 RETURN(rc);
         }
 
+        case OBD_IOC_POOL: {
+                RETURN(mgs_iocontrol_pool(obd, data));
+        }
+
         case OBD_IOC_DUMP_LOG: {
                 struct llog_ctxt *ctxt =
                         llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h
index cbf183b..7594bf9 100644
--- a/lustre/mgs/mgs_internal.h
+++ b/lustre/mgs/mgs_internal.h
@@ -82,6 +82,9 @@ int mgs_erase_log(struct obd_device *obd, char *name);
 int mgs_erase_logs(struct obd_device *obd, char *fsname);
 int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname);
 
+int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd,
+                 char *poolname, char *fsname, char *ostname);
+
 /* mgs_fs.c */
 int mgs_client_add(struct obd_device *obd,
                    struct obd_export *exp,
diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c
index ffc53eb..4cbac7e 100644
--- a/lustre/mgs/mgs_llog.c
+++ b/lustre/mgs/mgs_llog.c
@@ -68,8 +68,9 @@
 
 /* Caller must list_del and OBD_FREE each dentry from the list */
 int class_dentry_readdir(struct obd_device *obd, struct dentry *dir,
-                         struct vfsmount *inmnt, 
-                         struct list_head *dentry_list){
+                         struct vfsmount *inmnt,
+                         struct list_head *dentry_list)
+{
         /* see mds_cleanup_pending */
         struct lvfs_run_ctxt saved;
         struct file *file;
@@ -109,14 +110,14 @@ static inline int name_create(char **newname, char *prefix, char *suffix)
 {
         LASSERT(newname);
         OBD_ALLOC(*newname, strlen(prefix) + strlen(suffix) + 1);
-        if (!*newname) 
+        if (!*newname)
                 return -ENOMEM;
         sprintf(*newname, "%s%s", prefix, suffix);
         return 0;
 }
 
 static inline void name_destroy(char **name)
-{        
+{
         if (*name)
                 OBD_FREE(*name, strlen(*name) + 1);
         *name = NULL;
@@ -127,11 +128,11 @@ static inline void name_destroy(char **name)
         2. what the last config step is
         3. COMPAT_146 lov name
         4. COMPAT_146 mdt lov name
-        5. COMPAT_146 mdc name 
+        5. COMPAT_146 mdc name
 */
 /* It might be better to have a separate db file, instead of parsing the info
    out of the client log.  This is slow and potentially error-prone. */
-static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec, 
+static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
                             void *data)
 {
         struct fs_db *fsdb = (struct fs_db *)data;
@@ -155,21 +156,21 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
 
         lcfg = (struct lustre_cfg *)cfg_buf;
 
-        CDEBUG(D_INFO, "cmd %x %s %s\n", lcfg->lcfg_command, 
+        CDEBUG(D_INFO, "cmd %x %s %s\n", lcfg->lcfg_command,
                lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1));
 
-        /* Figure out ost indicies */ 
+        /* Figure out ost indicies */
         /* lov_modify_tgts add 0:lov1  1:ost1_UUID  2(index):0  3(gen):1 */
         if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD ||
             lcfg->lcfg_command == LCFG_LOV_DEL_OBD) {
                 index = simple_strtoul(lustre_cfg_string(lcfg, 2),
                                        NULL, 10);
                 CDEBUG(D_MGS, "OST index for %s is %u (%s)\n",
-                       lustre_cfg_string(lcfg, 1), index, 
+                       lustre_cfg_string(lcfg, 1), index,
                        lustre_cfg_string(lcfg, 2));
                 set_bit(index, fsdb->fsdb_ost_index_map);
         }
-        
+
         /* Figure out mdt indicies */
         /* attach   0:MDC_uml1_mdsA_MNT_client  1:mdc  2:1d834_MNT_client_03f */
         if ((lcfg->lcfg_command == LCFG_ATTACH) &&
@@ -193,9 +194,9 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
             (strcmp(lustre_cfg_string(lcfg, 1), LUSTRE_LOV_NAME) == 0)) {
                 fsdb->fsdb_flags |= FSDB_OLDLOG14;
                 name_destroy(&fsdb->fsdb_clilov);
-                rc = name_create(&fsdb->fsdb_clilov, 
+                rc = name_create(&fsdb->fsdb_clilov,
                                  lustre_cfg_string(lcfg, 0), "");
-                if (rc) 
+                if (rc)
                         RETURN(rc);
                 CDEBUG(D_MGS, "client lov name is %s\n", fsdb->fsdb_clilov);
         }
@@ -207,20 +208,20 @@ static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
                 fsdb->fsdb_flags |= FSDB_OLDLOG14;
                 ptr = strstr(lustre_cfg_string(lcfg, 1), "_UUID");
                 if (!ptr) {
-                        CERROR("Can't parse MDT uuid %s\n", 
+                        CERROR("Can't parse MDT uuid %s\n",
                                lustre_cfg_string(lcfg, 1));
                         RETURN(-EINVAL);
                 }
                 *ptr = '\0';
                 name_destroy(&fsdb->fsdb_mdtlov);
-                rc = name_create(&fsdb->fsdb_mdtlov, 
+                rc = name_create(&fsdb->fsdb_mdtlov,
                                  "lov_", lustre_cfg_string(lcfg, 1));
-                if (rc) 
+                if (rc)
                         RETURN(rc);
                 name_destroy(&fsdb->fsdb_mdc);
-                rc = name_create(&fsdb->fsdb_mdc, 
+                rc = name_create(&fsdb->fsdb_mdc,
                                  lustre_cfg_string(lcfg, 0), "");
-                if (rc) 
+                if (rc)
                         RETURN(rc);
                 CDEBUG(D_MGS, "MDT lov name is %s\n", fsdb->fsdb_mdtlov);
         }
@@ -297,9 +298,9 @@ static struct fs_db *mgs_new_fsdb(struct obd_device *obd, char *fsname)
         struct fs_db *fsdb;
         int rc;
         ENTRY;
-        
+
         OBD_ALLOC_PTR(fsdb);
-        if (!fsdb) 
+        if (!fsdb)
                 RETURN(NULL);
 
         OBD_ALLOC(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
@@ -308,14 +309,14 @@ static struct fs_db *mgs_new_fsdb(struct obd_device *obd, char *fsname)
                 CERROR("No memory for index maps\n");
                 GOTO(err, 0);
         }
-        
+
         strncpy(fsdb->fsdb_name, fsname, sizeof(fsdb->fsdb_name));
         fsdb->fsdb_name[sizeof(fsdb->fsdb_name) - 1] = 0;
         rc = name_create(&fsdb->fsdb_mdtlov, fsname, "-mdtlov");
-        if (rc) 
+        if (rc)
                 GOTO(err, rc);
         rc = name_create(&fsdb->fsdb_clilov, fsname, "-clilov");
-        if (rc) 
+        if (rc)
                 GOTO(err, rc);
 
         sema_init(&fsdb->fsdb_sem, 1);
@@ -324,12 +325,12 @@ static struct fs_db *mgs_new_fsdb(struct obd_device *obd, char *fsname)
 
         RETURN(fsdb);
 err:
-        if (fsdb->fsdb_ost_index_map) 
+        if (fsdb->fsdb_ost_index_map)
                 OBD_FREE(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
-        if (fsdb->fsdb_mdt_index_map) 
+        if (fsdb->fsdb_mdt_index_map)
                 OBD_FREE(fsdb->fsdb_mdt_index_map, INDEX_MAP_SIZE);
-        name_destroy(&fsdb->fsdb_clilov); 
-        name_destroy(&fsdb->fsdb_mdtlov); 
+        name_destroy(&fsdb->fsdb_clilov);
+        name_destroy(&fsdb->fsdb_mdtlov);
         OBD_FREE_PTR(fsdb);
         RETURN(NULL);
 }
@@ -342,9 +343,9 @@ static void mgs_free_fsdb(struct obd_device *obd, struct fs_db *fsdb)
         list_del(&fsdb->fsdb_list);
         OBD_FREE(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
         OBD_FREE(fsdb->fsdb_mdt_index_map, INDEX_MAP_SIZE);
-        name_destroy(&fsdb->fsdb_clilov); 
-        name_destroy(&fsdb->fsdb_mdtlov); 
-        name_destroy(&fsdb->fsdb_mdc); 
+        name_destroy(&fsdb->fsdb_clilov);
+        name_destroy(&fsdb->fsdb_mdtlov);
+        name_destroy(&fsdb->fsdb_mdc);
         OBD_FREE_PTR(fsdb);
 }
 
@@ -369,8 +370,8 @@ int mgs_cleanup_fsdb_list(struct obd_device *obd)
         return 0;
 }
 
-static int mgs_find_or_make_fsdb(struct obd_device *obd, char *name, 
-                               struct fs_db **dbh)
+static int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
+                                 struct fs_db **dbh)
 {
         struct mgs_obd *mgs = &obd->u.mgs;
         struct fs_db *fsdb;
@@ -387,7 +388,7 @@ static int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
         CDEBUG(D_MGS, "Creating new db\n");
         fsdb = mgs_new_fsdb(obd, name);
         up(&mgs->mgs_sem);
-        if (!fsdb) 
+        if (!fsdb)
                 return -ENOMEM;
 
         /* populate the db from the client llog */
@@ -399,12 +400,12 @@ static int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
         }
 
         *dbh = fsdb;
-        
+
         return 0;
 }
 
 /* 1 = index in use
-   0 = index unused 
+   0 = index unused
    -1= empty client log */
 int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti)
 {
@@ -415,23 +416,23 @@ int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti)
 
         LASSERT(!(mti->mti_flags & LDD_F_NEED_INDEX));
 
-        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb); 
+        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
         if (rc) {
                 CERROR("Can't get db for %s\n", mti->mti_fsname);
                 RETURN(rc);
         }
 
-        if (fsdb->fsdb_flags & FSDB_LOG_EMPTY) 
+        if (fsdb->fsdb_flags & FSDB_LOG_EMPTY)
                 RETURN(-1);
 
-        if (mti->mti_flags & LDD_F_SV_TYPE_OST) 
+        if (mti->mti_flags & LDD_F_SV_TYPE_OST)
                 imap = fsdb->fsdb_ost_index_map;
-        else if (mti->mti_flags & LDD_F_SV_TYPE_MDT) 
+        else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
                 imap = fsdb->fsdb_mdt_index_map;
         else
                 RETURN(-EINVAL);
 
-        if (test_bit(mti->mti_stripe_index, imap)) 
+        if (test_bit(mti->mti_stripe_index, imap))
                 RETURN(1);
         RETURN(0);
 }
@@ -458,15 +459,15 @@ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
         int rc = 0;
         ENTRY;
 
-        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb); 
+        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
         if (rc) {
                 CERROR("Can't get db for %s\n", mti->mti_fsname);
                 RETURN(rc);
         }
 
-        if (mti->mti_flags & LDD_F_SV_TYPE_OST) 
+        if (mti->mti_flags & LDD_F_SV_TYPE_OST)
                 imap = fsdb->fsdb_ost_index_map;
-        else if (mti->mti_flags & LDD_F_SV_TYPE_MDT) 
+        else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
                 imap = fsdb->fsdb_mdt_index_map;
         else
                 RETURN(-EINVAL);
@@ -479,7 +480,7 @@ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
         }
 
         /* Remove after CMD */
-        if ((mti->mti_flags & LDD_F_SV_TYPE_MDT) && 
+        if ((mti->mti_flags & LDD_F_SV_TYPE_MDT) &&
             (mti->mti_stripe_index > 0)) {
                 LCONSOLE_ERROR_MSG(0x13e, "MDT index must = 0 (until Clustered "
                                    "MetaData feature is ready.)\n");
@@ -488,7 +489,7 @@ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
 
         if (mti->mti_stripe_index >= INDEX_MAP_SIZE * 8) {
                 LCONSOLE_ERROR_MSG(0x13f, "Server %s requested index %d, but the"
-                                   "max index is %d.\n", 
+                                   "max index is %d.\n",
                                    mti->mti_svname, mti->mti_stripe_index,
                                    INDEX_MAP_SIZE * 8);
                 RETURN(-ERANGE);
@@ -515,7 +516,7 @@ int mgs_set_index(struct obd_device *obd, struct mgs_target_info *mti)
         server_make_name(mti->mti_flags, mti->mti_stripe_index,
                          mti->mti_fsname, mti->mti_svname);
 
-        CDEBUG(D_MGS, "Set index for %s to %d\n", mti->mti_svname, 
+        CDEBUG(D_MGS, "Set index for %s to %d\n", mti->mti_svname,
                mti->mti_stripe_index);
 
         RETURN(0);
@@ -526,13 +527,13 @@ struct mgs_modify_lookup {
         int               mml_modified;
 };
 
-static int mgs_modify_handler(struct llog_handle *llh, struct llog_rec_hdr *rec, 
+static int mgs_modify_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
                               void *data)
 {
         struct mgs_modify_lookup *mml = (struct mgs_modify_lookup *)data;
         struct cfg_marker *marker;
         struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1);
-        int cfg_len = rec->lrh_len - sizeof(struct llog_rec_hdr) - 
+        int cfg_len = rec->lrh_len - sizeof(struct llog_rec_hdr) -
                 sizeof(struct llog_rec_tail);
         int rc;
         ENTRY;
@@ -550,27 +551,27 @@ static int mgs_modify_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
 
         /* We only care about markers */
         if (lcfg->lcfg_command != LCFG_MARKER)
-                RETURN(0); 
-        
+                RETURN(0);
+
         marker = lustre_cfg_buf(lcfg, 1);
-        if ((strcmp(mml->mml_marker.cm_comment, marker->cm_comment) == 0) && 
+        if ((strcmp(mml->mml_marker.cm_comment, marker->cm_comment) == 0) &&
             (strcmp(mml->mml_marker.cm_tgtname, marker->cm_tgtname) == 0) &&
             !(marker->cm_flags & CM_SKIP)) {
                 /* Found a non-skipped marker match */
                 CDEBUG(D_MGS, "Changing rec %u marker %d %x->%x: %s %s\n",
-                       rec->lrh_index, marker->cm_step, 
+                       rec->lrh_index, marker->cm_step,
                        marker->cm_flags, mml->mml_marker.cm_flags,
                        marker->cm_tgtname, marker->cm_comment);
                 /* Overwrite the old marker llog entry */
                 marker->cm_flags &= ~CM_EXCLUDE; /* in case we're unexcluding */
                 marker->cm_flags |= mml->mml_marker.cm_flags;
                 marker->cm_canceltime = mml->mml_marker.cm_canceltime;
-                /* Header and tail are added back to lrh_len in 
+                /* Header and tail are added back to lrh_len in
                    llog_lvfs_write_rec */
-                rec->lrh_len = cfg_len; 
-                rc = llog_write_rec(llh, rec, NULL, 0, (void *)lcfg, 
+                rec->lrh_len = cfg_len;
+                rc = llog_write_rec(llh, rec, NULL, 0, (void *)lcfg,
                                     rec->lrh_index);
-                if (!rc) 
+                if (!rc)
                          mml->mml_modified++;
         }
 
@@ -579,7 +580,7 @@ static int mgs_modify_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
 
 /* Modify an existing config log record (for CM_SKIP or CM_EXCLUDE) */
 static int mgs_modify(struct obd_device *obd, struct fs_db *fsdb,
-                      struct mgs_target_info *mti, char *logname, 
+                      struct mgs_target_info *mti, char *logname,
                       char *devname, char *comment, int flags)
 {
         struct llog_handle *loghandle;
@@ -592,7 +593,7 @@ static int mgs_modify(struct obd_device *obd, struct fs_db *fsdb,
         CDEBUG(D_MGS, "modify %s/%s/%s\n", logname, devname, comment);
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-       
+
         ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
         LASSERT(ctxt != NULL);
         rc = llog_create(ctxt, &loghandle, NULL, logname);
@@ -607,7 +608,7 @@ static int mgs_modify(struct obd_device *obd, struct fs_db *fsdb,
                 GOTO(out_close, rc = 0);
 
         OBD_ALLOC_PTR(mml);
-        if (!mml) 
+        if (!mml)
                 GOTO(out_close, rc = -ENOMEM);
         strcpy(mml->mml_marker.cm_comment, comment);
         strcpy(mml->mml_marker.cm_tgtname, devname);
@@ -616,7 +617,7 @@ static int mgs_modify(struct obd_device *obd, struct fs_db *fsdb,
         mml->mml_marker.cm_canceltime = flags ? cfs_time_current_sec() : 0;
         mml->mml_modified = 0;
         rc = llog_process(loghandle, mgs_modify_handler, (void *)mml, NULL);
-        if (!rc && !mml->mml_modified) 
+        if (!rc && !mml->mml_modified)
                 rc = -ENODEV;
         OBD_FREE_PTR(mml);
 
@@ -627,14 +628,14 @@ out_close:
 out_pop:
         llog_ctxt_put(ctxt);
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        if (rc && rc != -ENODEV) 
+        if (rc && rc != -ENODEV)
                 CERROR("modify %s/%s failed %d\n",
                        mti->mti_svname, comment, rc);
 
         RETURN(rc);
 }
 
-                           
+
 /******************** config log recording functions *********************/
 
 static int record_lcfg(struct obd_device *obd, struct llog_handle *llh,
@@ -644,10 +645,10 @@ static int record_lcfg(struct obd_device *obd, struct llog_handle *llh,
         struct llog_rec_hdr    rec;
         int buflen, rc;
 
-        if (!lcfg || !llh) 
+        if (!lcfg || !llh)
                 return -ENOMEM;
 
-        LASSERT(llh->lgh_ctxt);        
+        LASSERT(llh->lgh_ctxt);
 
         buflen = lustre_cfg_len(lcfg->lcfg_bufcount,
                                 lcfg->lcfg_buflens);
@@ -657,7 +658,7 @@ static int record_lcfg(struct obd_device *obd, struct llog_handle *llh,
         /* idx = -1 means append */
         rc = llog_write_rec(llh, &rec, NULL, 0, (void *)lcfg, -1);
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        if (rc) 
+        if (rc)
                 CERROR("failed %d\n", rc);
         return rc;
 }
@@ -669,46 +670,46 @@ static int record_base(struct obd_device *obd, struct llog_handle *llh,
         struct lustre_cfg_bufs bufs;
         struct lustre_cfg     *lcfg;
         int rc;
-               
+
         CDEBUG(D_MGS, "lcfg %s %#x %s %s %s %s\n", cfgname,
-               cmd, s1, s2, s3, s4); 
+               cmd, s1, s2, s3, s4);
 
         lustre_cfg_bufs_reset(&bufs, cfgname);
-        if (s1) 
+        if (s1)
                 lustre_cfg_bufs_set_string(&bufs, 1, s1);
-        if (s2) 
+        if (s2)
                 lustre_cfg_bufs_set_string(&bufs, 2, s2);
-        if (s3) 
+        if (s3)
                 lustre_cfg_bufs_set_string(&bufs, 3, s3);
-        if (s4) 
+        if (s4)
                 lustre_cfg_bufs_set_string(&bufs, 4, s4);
 
         lcfg = lustre_cfg_new(cmd, &bufs);
-        if (!lcfg) 
+        if (!lcfg)
                 return -ENOMEM;
         lcfg->lcfg_nid = nid;
 
         rc = record_lcfg(obd, llh, lcfg);
-        
+
         lustre_cfg_free(lcfg);
-        
+
         if (rc) {
                 CERROR("error %d: lcfg %s %#x %s %s %s %s\n", rc, cfgname,
-                       cmd, s1, s2, s3, s4); 
+                       cmd, s1, s2, s3, s4);
         }
         return(rc);
 }
 
 
-static inline int record_add_uuid(struct obd_device *obd, 
-                                  struct llog_handle *llh, 
+static inline int record_add_uuid(struct obd_device *obd,
+                                  struct llog_handle *llh,
                                   __u64 nid, char *uuid)
 {
         return record_base(obd,llh,NULL,nid,LCFG_ADD_UUID,uuid,0,0,0);
 
 }
 
-static inline int record_add_conn(struct obd_device *obd, 
+static inline int record_add_conn(struct obd_device *obd,
                                   struct llog_handle *llh,
                                   char *devname,
                                   char *uuid)
@@ -723,7 +724,7 @@ static inline int record_attach(struct obd_device *obd, struct llog_handle *llh,
 }
 
 static inline int record_setup(struct obd_device *obd, struct llog_handle *llh,
-                               char *devname, 
+                               char *devname,
                                char *s1, char *s2, char *s3, char *s4)
 {
         return record_base(obd,llh,devname,0,LCFG_SETUP,s1,s2,s3,s4);
@@ -739,7 +740,7 @@ static int record_lov_setup(struct obd_device *obd, struct llog_handle *llh,
         lustre_cfg_bufs_reset(&bufs, devname);
         lustre_cfg_bufs_set(&bufs, 1, desc, sizeof(*desc));
         lcfg = lustre_cfg_new(LCFG_SETUP, &bufs);
-        if (!lcfg) 
+        if (!lcfg)
                 return -ENOMEM;
         rc = record_lcfg(obd, llh, lcfg);
 
@@ -754,16 +755,16 @@ static inline int record_lov_add(struct obd_device *obd,
 {
         return record_base(obd,llh,lov_name,0,LCFG_LOV_ADD_OBD,
                            ost_uuid,index,gen,0);
-}                                  
+}
 
-static inline int record_mount_opt(struct obd_device *obd, 
+static inline int record_mount_opt(struct obd_device *obd,
                                    struct llog_handle *llh,
                                    char *profile, char *lov_name,
                                    char *mdc_name)
 {
         return record_base(obd,llh,NULL,0,LCFG_MOUNTOPT,
                            profile,lov_name,mdc_name,0);
-}                
+}
 
 static int record_marker(struct obd_device *obd, struct llog_handle *llh,
                          struct fs_db *fsdb, __u32 flags,
@@ -774,19 +775,19 @@ static int record_marker(struct obd_device *obd, struct llog_handle *llh,
         struct lustre_cfg *lcfg;
         int rc;
 
-        if (flags & CM_START) 
+        if (flags & CM_START)
                 fsdb->fsdb_gen++;
         marker.cm_step = fsdb->fsdb_gen;
         marker.cm_flags = flags;
         marker.cm_vers = LUSTRE_VERSION_CODE;
-        strncpy(marker.cm_tgtname, tgtname, sizeof(marker.cm_tgtname)); 
-        strncpy(marker.cm_comment, comment, sizeof(marker.cm_comment)); 
+        strncpy(marker.cm_tgtname, tgtname, sizeof(marker.cm_tgtname));
+        strncpy(marker.cm_comment, comment, sizeof(marker.cm_comment));
         marker.cm_createtime = cfs_time_current_sec();
         marker.cm_canceltime = 0;
         lustre_cfg_bufs_reset(&bufs, NULL);
         lustre_cfg_bufs_set(&bufs, 1, &marker, sizeof(marker));
         lcfg = lustre_cfg_new(LCFG_MARKER, &bufs);
-        if (!lcfg) 
+        if (!lcfg)
                 return -ENOMEM;
         rc = record_lcfg(obd, llh, lcfg);
 
@@ -794,21 +795,21 @@ static int record_marker(struct obd_device *obd, struct llog_handle *llh,
         return rc;
 }
 
-static int record_start_log(struct obd_device *obd, 
+static int record_start_log(struct obd_device *obd,
                             struct llog_handle **llh, char *name)
 {
         static struct obd_uuid cfg_uuid = { .uuid = "config_uuid" };
         struct lvfs_run_ctxt saved;
         struct llog_ctxt *ctxt;
         int rc = 0;
-        
-        if (*llh) 
+
+        if (*llh)
                 GOTO(out, rc = -EBUSY);
 
         ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
         if (!ctxt)
                 GOTO(out, rc = -ENODEV);
-        
+
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         rc = llog_create(ctxt, llh, NULL, name);
         if (rc == 0)
@@ -832,10 +833,10 @@ static int record_end_log(struct obd_device *obd, struct llog_handle **llh)
         int rc = 0;
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        
+
         rc = llog_close(*llh);
         *llh = NULL;
-        
+
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         RETURN(rc);
 }
@@ -866,34 +867,34 @@ static int mgs_log_is_empty(struct obd_device *obd, char *name)
 
 /* write an lcfg directly into a log (with markers) */
 static int mgs_write_log_direct(struct obd_device *obd, struct fs_db *fsdb,
-                                char *logname, struct lustre_cfg *lcfg, 
+                                char *logname, struct lustre_cfg *lcfg,
                                 char *devname, char *comment)
 {
         struct llog_handle *llh = NULL;
         int rc;
         ENTRY;
 
-        if (!lcfg) 
+        if (!lcfg)
                 RETURN(-ENOMEM);
 
         rc = record_start_log(obd, &llh, logname);
-        if (rc) 
+        if (rc)
                 RETURN(rc);
-        
+
         /* FIXME These should be a single journal transaction */
-        rc = record_marker(obd, llh, fsdb, CM_START, devname, comment); 
-        
+        rc = record_marker(obd, llh, fsdb, CM_START, devname, comment);
+
         rc = record_lcfg(obd, llh, lcfg);
 
-        rc = record_marker(obd, llh, fsdb, CM_END, devname, comment); 
+        rc = record_marker(obd, llh, fsdb, CM_END, devname, comment);
         rc = record_end_log(obd, &llh);
-        
+
         RETURN(rc);
 }
 
 /* write the lcfg in all logs for the given fs */
 int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb,
-                             struct mgs_target_info *mti, 
+                             struct mgs_target_info *mti,
                              struct lustre_cfg *lcfg,
                              char *devname, char *comment)
 {
@@ -904,9 +905,9 @@ int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb,
         char *logname;
         int rc = 0, len = strlen(fsname);
         ENTRY;
-        
-        /* We need to set params for any future logs 
-           as well. FIXME Append this file to every new log. 
+
+        /* We need to set params for any future logs
+           as well. FIXME Append this file to every new log.
            Actually, we should store as params (text), not llogs.  Or
            in a database. */
         name_create(&logname, fsname, "-params");
@@ -916,7 +917,7 @@ int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb,
                 record_end_log(obd, &llh);
         }
         name_destroy(&logname);
-        if (rc) 
+        if (rc)
                 RETURN(rc);
 
         /* Find all the logs in the CONFIGS directory */
@@ -926,30 +927,30 @@ int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb,
                 CERROR("Can't read %s dir\n", MOUNT_CONFIGS_DIR);
                 RETURN(rc);
         }
-                                                                                
+
         /* Could use fsdb index maps instead of directory listing */
         list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
                 list_del(&dirent->lld_list);
                 if (strncmp(fsname, dirent->lld_name, len) == 0) {
                         CDEBUG(D_MGS, "Changing log %s\n", dirent->lld_name);
                         /* Erase any old settings of this same parameter */
-                        mgs_modify(obd, fsdb, mti, dirent->lld_name, devname, 
+                        mgs_modify(obd, fsdb, mti, dirent->lld_name, devname,
                                    comment, CM_SKIP);
                         /* Write the new one */
                         rc = mgs_write_log_direct(obd, fsdb, dirent->lld_name,
                                                   lcfg, devname, comment);
                         if (rc)
-                                CERROR("err %d writing log %s\n", rc, 
+                                CERROR("err %d writing log %s\n", rc,
                                        dirent->lld_name);
                 }
                 OBD_FREE(dirent, sizeof(*dirent));
         }
-        
+
         RETURN(rc);
 }
 
 /* lov is the first thing in the mdt and client logs */
-static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb, 
+static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb,
                              struct mgs_target_info *mti,
                              char *logname, char *lovname)
 {
@@ -973,7 +974,7 @@ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb,
                 RETURN(-ENOMEM);
         lovdesc->ld_magic = LOV_DESC_MAGIC;
         lovdesc->ld_tgt_count = 0;
-        /* Defaults.  Can be changed later by lcfg config_param */ 
+        /* Defaults.  Can be changed later by lcfg config_param */
         lovdesc->ld_default_stripe_count = 1;
         lovdesc->ld_pattern = LOV_PATTERN_RAID0;
         lovdesc->ld_default_stripe_size = 1024 * 1024;
@@ -986,15 +987,15 @@ static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb,
         /* This should always be the first entry in a log.
         rc = mgs_clear_log(obd, logname); */
         rc = record_start_log(obd, &llh, logname);
-        if (rc) 
+        if (rc)
                 GOTO(out, rc);
         /* FIXME these should be a single journal transaction */
-        rc = record_marker(obd, llh, fsdb, CM_START, lovname, "lov setup"); 
+        rc = record_marker(obd, llh, fsdb, CM_START, lovname, "lov setup");
         rc = record_attach(obd, llh, lovname, "lov", uuid);
         rc = record_lov_setup(obd, llh, lovname, lovdesc);
-        rc = record_marker(obd, llh, fsdb, CM_END, lovname, "lov setup"); 
+        rc = record_marker(obd, llh, fsdb, CM_END, lovname, "lov setup");
         rc = record_end_log(obd, &llh);
-out:        
+out:
         OBD_FREE(lovdesc, sizeof(*lovdesc));
         RETURN(rc);
 }
@@ -1023,11 +1024,11 @@ static int mgs_write_log_failnids(struct obd_device *obd,
         while (class_find_param(ptr, PARAM_FAILNODE, &ptr) == 0) {
                 while (class_parse_nid(ptr, &nid, &ptr) == 0) {
                         if (failnodeuuid == NULL) {
-                                /* We don't know the failover node name, 
+                                /* We don't know the failover node name,
                                    so just use the first nid as the uuid */
                                 rc = name_create(&failnodeuuid,
                                                  libcfs_nid2str(nid), "");
-                                if (rc) 
+                                if (rc)
                                         return rc;
                         }
                         CDEBUG(D_MGS, "add nid %s for failover uuid %s, "
@@ -1054,7 +1055,7 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb,
         ENTRY;
 
         CDEBUG(D_MGS, "writing new mdt %s\n", mti->mti_svname);
-        
+
         if (mti->mti_uuid[0] == '\0') {
                 /* Make up our own uuid */
                 snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
@@ -1063,43 +1064,43 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb,
 
         /* Append mdt info to mdt log */
         if (mgs_log_is_empty(obd, mti->mti_svname)) {
-                /* This is the first time for all logs for this fs, 
+                /* This is the first time for all logs for this fs,
                    since any ost should have already started the mdt log. */
                 first_log++;
                 rc = mgs_write_log_lov(obd, fsdb, mti, mti->mti_svname,
                                        fsdb->fsdb_mdtlov);
-        } 
+        }
         /* else there's already some ost entries in the mdt log. */
 
         /* We added the lov, maybe some osc's, now for the mdt.
            We might add more ost's after this. Note that during the parsing
-           of this log, this is when the mdt will start. (This was not 
+           of this log, this is when the mdt will start. (This was not
            formerly part of the old mds log, it was directly executed by
-           lconf.) */ 
+           lconf.) */
         /*
         mount_option 0:  1:mdsA  2:lov_mdsA
         attach mds mdsA mdsA_UUID
         setup /dev/loop2 ldiskfs mdsA errors=remount-ro,user_xattr
         */
         rc = record_start_log(obd, &llh, mti->mti_svname);
-        if (rc) 
+        if (rc)
                 RETURN(rc);
         /* FIXME this whole fn should be a single journal transaction */
-        rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add mdt"); 
+        rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add mdt");
         rc = record_mount_opt(obd, llh, mti->mti_svname, fsdb->fsdb_mdtlov, 0);
-        rc = record_attach(obd, llh, mti->mti_svname, LUSTRE_MDS_NAME, 
+        rc = record_attach(obd, llh, mti->mti_svname, LUSTRE_MDS_NAME,
                            mti->mti_uuid);
         rc = record_setup(obd, llh, mti->mti_svname,
                           mti->mti_uuid /* Ignored. Compatible with future. */,
                           "0" /* MDT Index, default to zero. */,
                           mti->mti_svname,
                           0 /* options */);
-        rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdt"); 
+        rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdt");
         rc = record_end_log(obd, &llh);
 
         /* Append the mdt info to the client log */
         name_create(&cliname, mti->mti_fsname, "-client");
-        if (first_log) { 
+        if (first_log) {
                 /* Start client log */
                 rc = mgs_write_log_lov(obd, fsdb, mti, cliname,
                                        fsdb->fsdb_clilov);
@@ -1108,7 +1109,7 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb,
         name_create(&nodeuuid, libcfs_nid2str(mti->mti_nids[0]),/*"_UUID"*/"");
         name_create(&mdcname, mti->mti_svname, "-mdc");
         name_create(&mdcuuid, mdcname, "_UUID");
-        /* 
+        /*
         #09 L add_uuid nid=uml1 at tcp(0x20000c0a80201) 0:  1:uml1_UUID
         #10 L attach   0:MDC_uml1_mdsA_MNT_client  1:mdc  2:1d834_MNT_client_03f
         #11 L setup    0:MDC_uml1_mdsA_MNT_client  1:mdsA_UUID  2:uml1_UUID
@@ -1117,19 +1118,19 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb,
         #14 L mount_option 0:  1:client  2:lov1  3:MDC_uml1_mdsA_MNT_client
         */
         rc = record_start_log(obd, &llh, cliname);
-        if (rc) 
+        if (rc)
                 GOTO(out, rc);
         rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add mdc");
         /* COMPAT_146 */
         if (fsdb->fsdb_flags & FSDB_OLDLOG14) {
-                /* Old client log already has MDC entry, but needs mount opt 
+                /* Old client log already has MDC entry, but needs mount opt
                    for new client name (lustre-client) */
-                /* FIXME Old MDT log already has an old mount opt 
+                /* FIXME Old MDT log already has an old mount opt
                    which we should remove (currently handled by
                    class_del_profiles()) */
                 rc = record_mount_opt(obd, llh, cliname, fsdb->fsdb_clilov,
                                       fsdb->fsdb_mdc);
-                /* Only add failnids with --writeconf 
+                /* Only add failnids with --writeconf
                 rc = mgs_write_log_failnids(obd, mti, llh, fsdb->fsdb_mdc);
                 */
                 /* end COMPAT_146 */
@@ -1147,7 +1148,7 @@ static int mgs_write_log_mdt(struct obd_device *obd, struct fs_db *fsdb,
                 rc = record_mount_opt(obd, llh, cliname, fsdb->fsdb_clilov,
                                       mdcname);
         }
-        rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdc"); 
+        rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add mdc");
         rc = record_end_log(obd, &llh);
 out:
         name_destroy(&mdcuuid);
@@ -1172,7 +1173,7 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *fsdb,
                    somewhere to add our osc. */
                 rc = mgs_write_log_lov(obd, fsdb, mti, logname, lovname);
         }
-  
+
         CDEBUG(D_MGS, "adding osc for %s to log %s\n",
                mti->mti_svname, logname);
 
@@ -1193,11 +1194,11 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *fsdb,
         #08 L lov_modify_tgts add 0:lov1  1:ost1_UUID  2(index):0  3(gen):1
         */
         rc = record_start_log(obd, &llh, logname);
-        if (rc) 
+        if (rc)
                 GOTO(out, rc);
         /* FIXME these should be a single journal transaction */
         rc = record_marker(obd, llh, fsdb, CM_START | flags, mti->mti_svname,
-                           "add osc"); 
+                           "add osc");
         for (i = 0; i < mti->mti_nid_count; i++) {
                 CDEBUG(D_MGS, "add nid %s\n", libcfs_nid2str(mti->mti_nids[i]));
                 rc = record_add_uuid(obd, llh, mti->mti_nids[i], nodeuuid);
@@ -1208,9 +1209,9 @@ static int mgs_write_log_osc(struct obd_device *obd, struct fs_db *fsdb,
         snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
         rc = record_lov_add(obd, llh, lovname, mti->mti_uuid, index, "1");
         rc = record_marker(obd, llh, fsdb, CM_END | flags, mti->mti_svname,
-                           "add osc"); 
+                           "add osc");
         rc = record_end_log(obd, &llh);
-out:        
+out:
         name_destroy(&lovuuid);
         name_destroy(&oscuuid);
         name_destroy(&oscname);
@@ -1226,7 +1227,7 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb,
         char *ptr = mti->mti_params;
         int rc, flags = 0, failout = 0;
         ENTRY;
-        
+
         CDEBUG(D_MGS, "writing new ost %s\n", mti->mti_svname);
 
         /* The ost startup log */
@@ -1245,14 +1246,14 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb,
         attach obdfilter ost1 ost1_UUID
         setup /dev/loop2 ldiskfs f|n errors=remount-ro,user_xattr
         */
-        if (class_find_param(ptr, PARAM_FAILMODE, &ptr) == 0) 
+        if (class_find_param(ptr, PARAM_FAILMODE, &ptr) == 0)
                 failout = (strncmp(ptr, "failout", 7) == 0);
         rc = record_start_log(obd, &llh, mti->mti_svname);
-        if (rc) 
+        if (rc)
                 RETURN(rc);
         /* FIXME these should be a single journal transaction */
-        rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add ost"); 
-        if (*mti->mti_uuid == '\0') 
+        rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,"add ost");
+        if (*mti->mti_uuid == '\0')
                 snprintf(mti->mti_uuid, sizeof(mti->mti_uuid),
                          "%s_UUID", mti->mti_svname);
         rc = record_attach(obd, llh, mti->mti_svname,
@@ -1260,10 +1261,10 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb,
         rc = record_setup(obd, llh, mti->mti_svname,
                           "dev"/*ignored*/, "type"/*ignored*/,
                           failout ? "n" : "f", 0/*options*/);
-        rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add ost"); 
+        rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname, "add ost");
         rc = record_end_log(obd, &llh);
 
-        /* We also have to update the other logs where this osc is part of 
+        /* We also have to update the other logs where this osc is part of
            the lov */
 
         if (fsdb->fsdb_flags & FSDB_OLDLOG14) {
@@ -1280,7 +1281,7 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb,
                               "the MDT first to regenerate it.\n",
                               mti->mti_svname);
         }
-        
+
         /* Append ost info to mdt log */
         /* FIXME add to all MDT logs for CMD */
         /* FIXME need real MDT name, but MDT may not have registered yet! */
@@ -1288,17 +1289,17 @@ static int mgs_write_log_ost(struct obd_device *obd, struct fs_db *fsdb,
         rc = mgs_write_log_osc(obd, fsdb, mti, logname, fsdb->fsdb_mdtlov,
                                flags);
         name_destroy(&logname);
-        
+
         /* Append ost info to the client log */
         name_create(&logname, mti->mti_fsname, "-client");
-        rc = mgs_write_log_osc(obd, fsdb, mti, logname, fsdb->fsdb_clilov, 
+        rc = mgs_write_log_osc(obd, fsdb, mti, logname, fsdb->fsdb_clilov,
                                flags);
         name_destroy(&logname);
-        
+
         RETURN(rc);
 }
 
-/* Add additional failnids to an existing log.  
+/* Add additional failnids to an existing log.
    The mdc/osc must have been added to logs first */
 /* tcp nids must be in dotted-quad ascii -
    we can't resolve hostnames from the kernel. */
@@ -1311,7 +1312,7 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb,
         ENTRY;
 
         /* FIXME how do we delete a failnid? Currently --writeconf is the
-           only way.  Maybe make --erase-params pass a flag to really 
+           only way.  Maybe make --erase-params pass a flag to really
            erase all params from logs - except it can't erase the failnids
            given when a target first registers, since they aren't processed
            as params... */
@@ -1326,10 +1327,10 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb,
 
         /* Create mdc/osc client name (e.g. lustre-OST0001-osc) */
         if (mti->mti_flags & LDD_F_SV_TYPE_MDT) {
-                /* COMPAT_146 */ 
+                /* COMPAT_146 */
                 if (fsdb->fsdb_mdc)
                         name_create(&cliname, fsdb->fsdb_mdc, "");
-                else 
+                else
                         name_create(&cliname, mti->mti_svname, "-mdc");
         } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) {
                 /* COMPAT_146 */
@@ -1337,7 +1338,7 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb,
                         LCONSOLE_ERROR_MSG(0x143, "Failover NIDs cannot be "
                                            "added to upgraded client logs for "
                                            "%s. Consider updating the "
-                                           "configuration with --writeconf.\n", 
+                                           "configuration with --writeconf.\n",
                                            mti->mti_svname);
                         RETURN(-EINVAL);
                 }
@@ -1345,17 +1346,17 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb,
         } else {
                 RETURN(-EINVAL);
         }
-        
+
         /* Add failover nids to client log */
         name_create(&logname, mti->mti_fsname, "-client");
         rc = record_start_log(obd, &llh, logname);
-        if (!rc) { 
+        if (!rc) {
                 /* FIXME this fn should be a single journal transaction */
                 rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,
                                    "add failnid");
                 rc = mgs_write_log_failnids(obd, mti, llh, cliname);
                 rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname,
-                                   "add failnid"); 
+                                   "add failnid");
                 rc = record_end_log(obd, &llh);
         }
         name_destroy(&logname);
@@ -1365,11 +1366,11 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb,
                 name_create(&logname, mti->mti_fsname, "-MDT0000");
                 rc = record_start_log(obd, &llh, logname);
                 if (!rc) {
-                        rc = record_marker(obd, llh, fsdb, CM_START, 
+                        rc = record_marker(obd, llh, fsdb, CM_START,
                                            mti->mti_svname, "add failnid");
                         rc = mgs_write_log_failnids(obd, mti, llh, cliname);
-                        rc = record_marker(obd, llh, fsdb, CM_END, 
-                                           mti->mti_svname, "add failnid"); 
+                        rc = record_marker(obd, llh, fsdb, CM_END,
+                                           mti->mti_svname, "add failnid");
                         rc = record_end_log(obd, &llh);
                 }
                 name_destroy(&logname);
@@ -1379,7 +1380,7 @@ static int mgs_write_log_add_failnid(struct obd_device *obd, struct fs_db *fsdb,
         RETURN(rc);
 }
 
-static int mgs_wlp_lcfg(struct obd_device *obd, struct fs_db *fsdb, 
+static int mgs_wlp_lcfg(struct obd_device *obd, struct fs_db *fsdb,
                         struct mgs_target_info *mti,
                         char *logname, struct lustre_cfg_bufs *bufs,
                         char *tgtname, char *ptr)
@@ -1388,7 +1389,7 @@ static int mgs_wlp_lcfg(struct obd_device *obd, struct fs_db *fsdb,
         char *tmp;
         struct lustre_cfg *lcfg;
         int rc;
-        
+
         /* Erase any old settings of this same parameter */
         memcpy(comment, ptr, MTI_NAME_MAXLEN);
         comment[MTI_NAME_MAXLEN - 1] = 0;
@@ -1403,44 +1404,81 @@ static int mgs_wlp_lcfg(struct obd_device *obd, struct fs_db *fsdb,
         lustre_cfg_bufs_reset(bufs, tgtname);
         lustre_cfg_bufs_set_string(bufs, 1, ptr);
         lcfg = lustre_cfg_new(LCFG_PARAM, bufs);
-        if (!lcfg) 
+        if (!lcfg)
                 return -ENOMEM;
         rc = mgs_write_log_direct(obd, fsdb, logname, lcfg, tgtname, comment);
         lustre_cfg_free(lcfg);
         return rc;
 }
 
+/* write global variable settings into log */
+static int mgs_write_log_sys(struct obd_device *obd, struct fs_db *fsdb,
+                             struct mgs_target_info *mti, char *sys, char *ptr)
+{
+        struct lustre_cfg_bufs bufs;
+        struct lustre_cfg *lcfg;
+        char *tmp;
+        int cmd, val;
+        int rc;
+
+        if (class_match_param(ptr, PARAM_TIMEOUT, &tmp) == 0)
+                cmd = LCFG_SET_TIMEOUT;
+        else if (class_match_param(ptr, PARAM_LDLM_TIMEOUT, &tmp) == 0)
+                cmd = LCFG_SET_LDLM_TIMEOUT;
+        /* Check for known params here so we can return error to lctl */
+        else if ((class_match_param(ptr, PARAM_AT_MIN, &tmp) == 0)
+                 || (class_match_param(ptr, PARAM_AT_MAX, &tmp) == 0)
+                 || (class_match_param(ptr, PARAM_AT_EXTRA, &tmp) == 0)
+                 || (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, &tmp) == 0)
+                 || (class_match_param(ptr, PARAM_AT_HISTORY, &tmp) == 0))
+                cmd = LCFG_PARAM;
+        else
+                return -EINVAL;
+
+        val = simple_strtoul(tmp, NULL, 0);
+        CDEBUG(D_MGS, "global %s = %d\n", ptr, val);
+
+        lustre_cfg_bufs_reset(&bufs, NULL);
+        lustre_cfg_bufs_set_string(&bufs, 1, sys);
+        lcfg = lustre_cfg_new(cmd, &bufs);
+        lcfg->lcfg_num = val;
+        /* modify all servers and clients */
+        rc = mgs_write_log_direct_all(obd, fsdb, mti, lcfg, mti->mti_fsname,
+                                      ptr);
+        lustre_cfg_free(lcfg);
+        return rc;
+}
+
 static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb,
                                 struct mgs_target_info *mti)
 {
         struct lustre_cfg_bufs bufs;
-        struct lustre_cfg *lcfg;
         char *logname;
         char *ptr = mti->mti_params;
         char *endptr, *tmp;
         int rc = 0;
         ENTRY;
 
-        if (!mti->mti_params) 
+        if (!mti->mti_params)
                 RETURN(0);
 
         /* For various parameter settings, we have to figure out which logs
            care about them (e.g. both mdt and client for lov settings) */
         while (ptr) {
-                while (*ptr == ' ') 
+                while (*ptr == ' ')
                         ptr++;
                 if (*ptr == '\0')
                         break;
                 endptr = strchr(ptr, ' ');
-                if (endptr) 
+                if (endptr)
                         *endptr = '\0';
                 CDEBUG(D_MGS, "next param '%s'\n", ptr);
 
-                /* The params are stored in MOUNT_DATA_FILE and modified 
+                /* The params are stored in MOUNT_DATA_FILE and modified
                    via tunefs.lustre */
 
                 /* Processed in lustre_start_mgc */
-                if (class_match_param(ptr, PARAM_MGSNODE, NULL) == 0) 
+                if (class_match_param(ptr, PARAM_MGSNODE, NULL) == 0)
                         goto end_while;
 
                 /* Processed in mgs_write_log_ost */
@@ -1466,30 +1504,17 @@ static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb,
                         goto end_while;
                 }
 
-                if (class_match_param(ptr, PARAM_SYS_TIMEOUT, &tmp) == 0) {
-                        /* Change obd timeout */
-                        int timeout;
-                        timeout = simple_strtoul(tmp, NULL, 0);
-
-                        CDEBUG(D_MGS, "obd timeout %d\n", timeout);
-                        
-                        lustre_cfg_bufs_reset(&bufs, NULL);
-                        lcfg = lustre_cfg_new(LCFG_SET_TIMEOUT, &bufs);
-                        lcfg->lcfg_num = timeout;
-                        /* modify all servers and clients */
-                        rc = mgs_write_log_direct_all(obd, fsdb, mti, lcfg,
-                                                      mti->mti_fsname,
-                                                      "timeout"); 
-                        lustre_cfg_free(lcfg);
+                if (class_match_param(ptr, PARAM_SYS, &tmp) == 0) {
+                        rc = mgs_write_log_sys(obd, fsdb, mti, ptr, tmp);
                         goto end_while;
                 }
 
-                if (class_match_param(ptr, PARAM_OSC""PARAM_ACTIVE, &tmp) == 0){ 
+                if (class_match_param(ptr, PARAM_OSC""PARAM_ACTIVE, &tmp) == 0){
                         /* active=0 means off, anything else means on */
                         int flag = (*tmp == '0') ? CM_EXCLUDE : 0;
                         if (!(mti->mti_flags & LDD_F_SV_TYPE_OST)) {
                                 LCONSOLE_ERROR_MSG(0x144, "%s: Only OSCs can be"
-                                                   " (de)activated.\n", 
+                                                   " (de)activated.\n",
                                                    mti->mti_svname);
                                 rc = -EINVAL;
                                 goto end_while;
@@ -1498,15 +1523,15 @@ static int mgs_write_log_params(struct obd_device *obd, struct fs_db *fsdb,
                                       flag ? "de": "re", mti->mti_svname);
                         /* Modify clilov */
                         name_create(&logname, mti->mti_fsname, "-client");
-                        rc = mgs_modify(obd, fsdb, mti, logname, 
+                        rc = mgs_modify(obd, fsdb, mti, logname,
                                         mti->mti_svname, "add osc", flag);
                         name_destroy(&logname);
-                        if (rc) 
+                        if (rc)
                                 goto active_err;
                         /* Modify mdtlov */
                         /* FIXME add to all MDT logs for CMD */
                         name_create(&logname, mti->mti_fsname, "-MDT0000");
-                        rc = mgs_modify(obd, fsdb, mti, logname, 
+                        rc = mgs_modify(obd, fsdb, mti, logname,
                                         mti->mti_svname, "add osc", flag);
                         name_destroy(&logname);
 active_err:
@@ -1514,16 +1539,16 @@ active_err:
                                 LCONSOLE_ERROR_MSG(0x145, "Couldn't find %s in "
                                                   "log (%d). No permanent "
                                                   "changes were made to the "
-                                                  "config log.\n", 
+                                                  "config log.\n",
                                                   mti->mti_svname, rc);
-                                if (fsdb->fsdb_flags & FSDB_OLDLOG14) 
+                                if (fsdb->fsdb_flags & FSDB_OLDLOG14)
                                         LCONSOLE_ERROR_MSG(0x146, "This may be "
                                         "because the log is in the old 1.4 "
                                         "style. Consider --writeconf to "
                                         "update the logs.\n");
                                 goto end_while;
                         }
-                        /* Fall through to osc proc for deactivating 
+                        /* Fall through to osc proc for deactivating
                            live OSC on running MDT / clients. */
                 }
 
@@ -1535,7 +1560,7 @@ active_err:
                         if (!(mti->mti_flags & LDD_F_SV_TYPE_MDT)) {
                                 LCONSOLE_ERROR_MSG(0x147, "LOV params must be "
                                                    "set on the MDT, not %s. "
-                                                   "Ignoring.\n", 
+                                                   "Ignoring.\n",
                                                    mti->mti_svname);
                                 rc = 0;
                                 goto end_while;
@@ -1546,9 +1571,9 @@ active_err:
                                 rc = -ENODEV;
                                 goto end_while;
                         }
-                        rc = mgs_wlp_lcfg(obd, fsdb, mti, mti->mti_svname, 
+                        rc = mgs_wlp_lcfg(obd, fsdb, mti, mti->mti_svname,
                                           &bufs, fsdb->fsdb_mdtlov, ptr);
-                        if (rc) 
+                        if (rc)
                                 goto end_while;
 
                         /* Modify clilov */
@@ -1560,20 +1585,20 @@ active_err:
                 }
 
                 /* All osc., mdc., llite. params in proc */
-                if ((class_match_param(ptr, PARAM_OSC, NULL) == 0) || 
-                    (class_match_param(ptr, PARAM_MDC, NULL) == 0) || 
+                if ((class_match_param(ptr, PARAM_OSC, NULL) == 0) ||
+                    (class_match_param(ptr, PARAM_MDC, NULL) == 0) ||
                     (class_match_param(ptr, PARAM_LLITE, NULL) == 0)) {
                         char *cname;
-                        if (memcmp(ptr, PARAM_LLITE, strlen(PARAM_LLITE)) == 0) {
+                        if (memcmp(ptr, PARAM_LLITE, strlen(PARAM_LLITE)) == 0){
                                 name_create(&cname, mti->mti_fsname, "-client");
-                        /* Add the client type to match the obdname 
+                        /* Add the client type to match the obdname
                            in class_config_llog_handler */
                         } else if (mti->mti_flags & LDD_F_SV_TYPE_MDT) {
                                 /* COMPAT_146 */
                                 if (fsdb->fsdb_mdc)
                                         name_create(&cname, fsdb->fsdb_mdc, "");
                                 else
-                                        name_create(&cname, mti->mti_svname, 
+                                        name_create(&cname, mti->mti_svname,
                                                     "-mdc");
                         } else if (mti->mti_flags & LDD_F_SV_TYPE_OST) {
                                 /* COMPAT_146 */
@@ -1589,19 +1614,19 @@ active_err:
                                         goto end_while;
                                 }
                                 name_create(&cname, mti->mti_svname, "-osc");
-                        } else {       
+                        } else {
                                 rc = -EINVAL;
                                 goto end_while;
                         }
 
                         CDEBUG(D_MGS, "%.3s param %s\n", ptr, ptr + 4);
-                        
+
                         /* Modify client */
                         name_create(&logname, mti->mti_fsname, "-client");
-                        rc = mgs_wlp_lcfg(obd, fsdb, mti, logname, &bufs, 
+                        rc = mgs_wlp_lcfg(obd, fsdb, mti, logname, &bufs,
                                           cname, ptr);
                         name_destroy(&logname);
-                        
+
                         /* osc params affect the MDT as well */
                         if (mti->mti_flags & LDD_F_SV_TYPE_OST) {
                                 /* FIXME add to all MDT logs for CMD */
@@ -1609,7 +1634,7 @@ active_err:
                                             "-MDT0000");
                                 if (!mgs_log_is_empty(obd, logname))
                                         rc = mgs_wlp_lcfg(obd, fsdb, mti,
-                                                          logname, &bufs, 
+                                                          logname, &bufs,
                                                           cname, ptr);
                                 name_destroy(&logname);
                         }
@@ -1618,7 +1643,7 @@ active_err:
                 }
 
                 /* All mdt., ost. params in proc */
-                if ((class_match_param(ptr, PARAM_MDT, NULL) == 0) || 
+                if ((class_match_param(ptr, PARAM_MDT, NULL) == 0) ||
                     (class_match_param(ptr, PARAM_OST, NULL) == 0)) {
                         CDEBUG(D_MGS, "%.3s param %s\n", ptr, ptr + 4);
                         if (mgs_log_is_empty(obd, mti->mti_svname)) {
@@ -1637,11 +1662,11 @@ end_while:
                         CERROR("err %d on param '%s\n", rc, ptr);
                         break;
                 }
-                
+
                 if (!endptr)
                         /* last param */
                         break;
-                 
+
                 *endptr = ' ';
                 ptr = endptr + 1;
         }
@@ -1658,20 +1683,20 @@ int mgs_check_failnid(struct obd_device *obd, struct mgs_target_info *mti)
         int rc;
         ENTRY;
 
-        rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb); 
-        if (rc) 
+        rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
+        if (rc)
                 RETURN(rc);
 
-        if (mgs_log_is_empty(obd, mti->mti_svname)) 
+        if (mgs_log_is_empty(obd, mti->mti_svname))
                 /* should never happen */
                 RETURN(-ENOENT);
 
         CDEBUG(D_MGS, "Checking for new failnids for %s\n", mti->mti_svname);
 
         /* FIXME We can just check mti->params to see if we're already in
-           the failover list.  Modify mti->params for rewriting back at 
+           the failover list.  Modify mti->params for rewriting back at
            server_register_target(). */
-        
+
         down(&fsdb->fsdb_sem);
         rc = mgs_write_log_add_failnid(obd, fsdb, mti);
         up(&fsdb->fsdb_sem);
@@ -1697,7 +1722,7 @@ int mgs_write_log_target(struct obd_device *obd,
         if (mti->mti_flags & LDD_F_UPGRADE14) {
                 if (rc == EALREADY) {
                         LCONSOLE_INFO("Found index %d for %s 1.4 log, "
-                                      "upgrading\n", mti->mti_stripe_index, 
+                                      "upgrading\n", mti->mti_stripe_index,
                                       mti->mti_svname);
                 } else {
                         LCONSOLE_ERROR_MSG(0x149, "Failed to find %s in the old"
@@ -1715,13 +1740,13 @@ int mgs_write_log_target(struct obd_device *obd,
                 /* end COMPAT_146 */
         } else {
                 if (rc == EALREADY) {
-                        /* This might be a params update, or a 
+                        /* This might be a params update, or a
                            local writeconf. (For "full" writeconf, the client
-                           log won't have an entry for this target, so we 
+                           log won't have an entry for this target, so we
                            won't get here.) */
-                        LCONSOLE_WARN("Found index %d for %s, updating log\n", 
+                        LCONSOLE_WARN("Found index %d for %s, updating log\n",
                                       mti->mti_stripe_index, mti->mti_svname);
-                        /* We would like to mark old log sections as invalid 
+                        /* We would like to mark old log sections as invalid
                            and add new log sections in the client and mdt logs.
                            But if we add new sections, then live clients will
                            get repeat setup instructions for already running
@@ -1730,7 +1755,7 @@ int mgs_write_log_target(struct obd_device *obd,
                 }
         }
 
-        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb); 
+        rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
         if (rc) {
                 CERROR("Can't get db for %s\n", mti->mti_fsname);
                 RETURN(rc);
@@ -1738,7 +1763,7 @@ int mgs_write_log_target(struct obd_device *obd,
 
         down(&fsdb->fsdb_sem);
 
-        if (mti->mti_flags & 
+        if (mti->mti_flags &
             (LDD_F_VIRGIN | LDD_F_UPGRADE14 | LDD_F_WRITECONF)) {
                 /* Generate a log from scratch */
                 if (mti->mti_flags & LDD_F_SV_TYPE_MDT) {
@@ -1759,7 +1784,7 @@ int mgs_write_log_target(struct obd_device *obd,
                 CDEBUG(D_MGS, "Update params for %s\n", mti->mti_svname);
                 mti->mti_flags |= LDD_F_PARAM;
         }
-        
+
         rc = mgs_write_log_params(obd, fsdb, mti);
 
 out_up:
@@ -1768,32 +1793,32 @@ out_up:
 }
 
 /* COMPAT_146 */
-/* verify that we can handle the old config logs */ 
+/* verify that we can handle the old config logs */
 int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti)
 {
         struct fs_db *fsdb;
         int rc = 0;
         ENTRY;
 
-        /* Create ost log normally, as servers register.  Servers 
+        /* Create ost log normally, as servers register.  Servers
            register with their old uuids (from last_rcvd), so old
            (MDT and client) logs should work.
-         - new MDT won't know about old OSTs, only the ones that have 
-           registered, so we need the old MDT log to get the LOV right 
-           in order for old clients to work. 
-         - Old clients connect to the MDT, not the MGS, for their logs, and 
-           will therefore receive the old client log from the MDT /LOGS dir. 
+         - new MDT won't know about old OSTs, only the ones that have
+           registered, so we need the old MDT log to get the LOV right
+           in order for old clients to work.
+         - Old clients connect to the MDT, not the MGS, for their logs, and
+           will therefore receive the old client log from the MDT /LOGS dir.
          - Old clients can continue to use and connect to old or new OSTs
-         - New clients will contact the MGS for their log 
+         - New clients will contact the MGS for their log
         */
 
-        LCONSOLE_INFO("upgrading server %s from pre-1.6\n", mti->mti_svname); 
+        LCONSOLE_INFO("upgrading server %s from pre-1.6\n", mti->mti_svname);
         server_mti_print("upgrade", mti);
-        
+
         rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
-        if (rc) 
+        if (rc)
                 RETURN(rc);
-        
+
         if (fsdb->fsdb_flags & FSDB_LOG_EMPTY) {
                 LCONSOLE_ERROR_MSG(0x14a, "The old client log %s-client is "
                                    "missing.  Was tunefs.lustre successful?\n",
@@ -1802,7 +1827,7 @@ int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti)
         }
 
         if (fsdb->fsdb_gen == 0) {
-                /* There were no markers in the client log, meaning we have 
+                /* There were no markers in the client log, meaning we have
                    not updated the logs for this fs */
                 CDEBUG(D_MGS, "found old, unupdated client log\n");
         }
@@ -1819,10 +1844,10 @@ int mgs_upgrade_sv_14(struct obd_device *obd, struct mgs_target_info *mti)
                 /* We're starting with an old uuid.  Assume old name for lov
                    as well since the lov entry already exists in the log. */
                 CDEBUG(D_MGS, "old mds uuid %s\n", mti->mti_uuid);
-                if (strncmp(mti->mti_uuid, fsdb->fsdb_mdtlov + 4, 
+                if (strncmp(mti->mti_uuid, fsdb->fsdb_mdtlov + 4,
                             strlen(fsdb->fsdb_mdtlov) - 4) != 0) {
                         CERROR("old mds uuid %s doesn't match log %s (%s)\n",
-                               mti->mti_uuid, fsdb->fsdb_mdtlov, 
+                               mti->mti_uuid, fsdb->fsdb_mdtlov,
                                fsdb->fsdb_mdtlov + 4);
                         RETURN(-EINVAL);
                 }
@@ -1874,7 +1899,7 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname)
         struct l_linux_dirent *dirent, *n;
         int rc, len = strlen(fsname);
         ENTRY;
-        
+
         /* Find all the logs in the CONFIGS directory */
         rc = class_dentry_readdir(obd, mgs->mgs_configs_dir,
                                   mgs->mgs_vfsmnt, &dentry_list);
@@ -1882,12 +1907,12 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname)
                 CERROR("Can't read %s dir\n", MOUNT_CONFIGS_DIR);
                 RETURN(rc);
         }
-                                                                                
+
         down(&mgs->mgs_sem);
-        
+
         /* Delete the fs db */
         fsdb = mgs_find_fsdb(obd, fsname);
-        if (fsdb) 
+        if (fsdb)
                 mgs_free_fsdb(obd, fsdb);
 
         list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
@@ -1898,7 +1923,7 @@ int mgs_erase_logs(struct obd_device *obd, char *fsname)
                 }
                 OBD_FREE(dirent, sizeof(*dirent));
         }
-        
+
         up(&mgs->mgs_sem);
 
         RETURN(rc);
@@ -1922,7 +1947,7 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg)
         if (lcfg->lcfg_bufcount < LUSTRE_CFG_MAX_BUFCOUNT)
                 for (i = 0; i < lcfg->lcfg_bufcount; i++) {
                         CDEBUG(D_MGS, "\tlcfg->lcfg_buflens[%d]: %d %s\n",
-                               i, lcfg->lcfg_buflens[i], 
+                               i, lcfg->lcfg_buflens[i],
                                lustre_cfg_string(lcfg, i));
                 }
         EXIT;
@@ -1940,7 +1965,7 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname)
         ENTRY;
 
         print_lustre_cfg(lcfg);
-        
+
         /* lustre, lustre-mdtlov, lustre-client, lustre-MDT0000 */
         devname = lustre_cfg_string(lcfg, 0);
         param = lustre_cfg_string(lcfg, 1);
@@ -1975,8 +2000,8 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname)
         fsname[MTI_NAME_MAXLEN - 1] = 0;
         CDEBUG(D_MGS, "setparam on fs %s device %s\n", fsname, devname);
 
-        rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb); 
-        if (rc) 
+        rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
+        if (rc)
                 RETURN(rc);
         if (fsdb->fsdb_flags & FSDB_LOG_EMPTY) {
                 CERROR("No filesystem targets for %s.  cfg_device from lctl "
@@ -1987,25 +2012,25 @@ int mgs_setparam(struct obd_device *obd, struct lustre_cfg *lcfg, char *fsname)
 
         /* Create a fake mti to hold everything */
         OBD_ALLOC_PTR(mti);
-        if (!mti) 
+        if (!mti)
                 GOTO(out, rc = -ENOMEM);
         strncpy(mti->mti_fsname, fsname, MTI_NAME_MAXLEN);
         strncpy(mti->mti_svname, devname, MTI_NAME_MAXLEN);
         strncpy(mti->mti_params, param, sizeof(mti->mti_params));
         rc = server_name2index(mti->mti_svname, &mti->mti_stripe_index, &tmp);
-        if (rc < 0) 
+        if (rc < 0)
                 /* Not a valid server; may be only fsname */
                 rc = 0;
         else
                 /* Strip -osc or -mdc suffix from svname */
-                if (server_make_name(rc, mti->mti_stripe_index, mti->mti_fsname, 
-                                     mti->mti_svname)) 
+                if (server_make_name(rc, mti->mti_stripe_index, mti->mti_fsname,
+                                     mti->mti_svname))
                         GOTO(out, rc = -EINVAL);
 
         mti->mti_flags = rc | LDD_F_PARAM;
 
         down(&fsdb->fsdb_sem);
-        rc = mgs_write_log_params(obd, fsdb, mti); 
+        rc = mgs_write_log_params(obd, fsdb, mti);
         up(&fsdb->fsdb_sem);
 
 out:
@@ -2014,6 +2039,145 @@ out:
 }
 
 
+static int mgs_write_log_pool(struct obd_device *obd, char *logname, struct fs_db *fsdb,
+                       char *lovname,
+                       enum lcfg_command_type cmd,
+                       char *poolname, char *fsname,
+                       char *ostname, char *comment)
+{
+        struct llog_handle *llh = NULL;
+        int rc;
+
+        rc = record_start_log(obd, &llh, logname);
+        if (rc)
+                RETURN(rc);
+        rc = record_marker(obd, llh, fsdb, CM_START, lovname, comment);
+        record_base(obd, llh, lovname, 0, cmd, poolname, fsname, ostname, 0);
+        rc = record_marker(obd, llh, fsdb, CM_END, lovname, comment);
+        rc = record_end_log(obd, &llh);
+
+        return(rc);
+}
+
+int mgs_pool_cmd(struct obd_device *obd, enum lcfg_command_type cmd,
+                 char *fsname, char *poolname, char *ostname)
+{
+        struct fs_db *fsdb;
+        char mdt_index[16];
+        char *lovname;
+        char *logname;
+        char *label, *canceled_label = NULL;
+        int label_sz;
+        struct mgs_target_info *mti;
+        int rc;
+        ENTRY;
+
+        rc = mgs_find_or_make_fsdb(obd, fsname, &fsdb);
+        if (rc) {
+                CERROR("Can't get db for %s\n", fsname);
+                RETURN(rc);
+        }
+        if (fsdb->fsdb_flags & FSDB_LOG_EMPTY) {
+                CERROR("%s is not defined\n", fsname);
+                mgs_free_fsdb(obd, fsdb);
+                RETURN(-EINVAL);
+        }
+
+        label_sz = 10 + strlen(fsname) + strlen(poolname);
+
+        /* check if ostname match fsname */
+        if (ostname != NULL) {
+                char *ptr;
+
+                ptr = strrchr(ostname, '-');
+                if ((ptr == NULL) ||
+                    (strncmp(fsname, ostname, ptr-ostname) != 0))
+                        RETURN(-EINVAL);
+                label_sz += strlen(ostname);
+        }
+
+        OBD_ALLOC(label, label_sz);
+        if (label == NULL)
+                RETURN(-ENOMEM);
+
+        switch(cmd) {
+        case LCFG_POOL_NEW: {
+                sprintf(label,
+                        "new %s.%s", fsname, poolname);
+                break;
+        }
+        case LCFG_POOL_ADD: {
+                sprintf(label,
+                        "add %s.%s.%s", fsname, poolname, ostname);
+                break;
+        }
+        case LCFG_POOL_REM: {
+                OBD_ALLOC(canceled_label, label_sz);
+                if (canceled_label == NULL)
+                         RETURN(-ENOMEM);
+                sprintf(label,
+                        "rem %s.%s.%s", fsname, poolname, ostname);
+                sprintf(canceled_label,
+                        "add %s.%s.%s", fsname, poolname, ostname);
+                break;
+        }
+        case LCFG_POOL_DEL: {
+                OBD_ALLOC(canceled_label, label_sz);
+                if (canceled_label == NULL)
+                         RETURN(-ENOMEM);
+                sprintf(label,
+                        "del %s.%s", fsname, poolname);
+                sprintf(canceled_label,
+                        "new %s.%s", fsname, poolname);
+                break;
+        }
+        default: {
+                break;
+        }
+        }
+
+        down(&fsdb->fsdb_sem);
+
+        sprintf(mdt_index, "-MDT%04x", 0);
+        name_create(&logname, fsname, mdt_index);
+        name_create(&lovname, fsdb->fsdb_mdtlov, "");
+
+        mti = NULL;
+        if (canceled_label != NULL) {
+                OBD_ALLOC(mti, sizeof(*mti));
+                if (mti != NULL) {
+                        strcpy(mti->mti_svname, "lov pool");
+                        mgs_modify(obd, fsdb, mti, logname, lovname,
+                                   canceled_label, CM_SKIP);
+                }
+        }
+
+        mgs_write_log_pool(obd, logname, fsdb, lovname,
+                           cmd, fsname, poolname, ostname, label);
+        name_destroy(&logname);
+
+        name_create(&logname, fsname, "-client");
+        if (canceled_label != NULL) {
+                mgs_modify(obd, fsdb, mti, logname, lovname,
+                           canceled_label, CM_SKIP);
+        }
+        mgs_write_log_pool(obd, logname, fsdb, fsdb->fsdb_clilov,
+                           cmd, fsname, poolname, ostname, label);
+        name_destroy(&logname);
+        name_destroy(&lovname);
+
+        up(&fsdb->fsdb_sem);
+
+        OBD_FREE(label, label_sz);
+        if (canceled_label != NULL)
+                OBD_FREE(canceled_label, label_sz);
+
+        if (mti != NULL)
+                OBD_FREE(mti, sizeof(*mti));
+
+        RETURN(rc);
+}
+
 #if 0
 /******************** unused *********************/
 static int mgs_backup_llog(struct obd_device *obd, char* fsname)
@@ -2038,10 +2202,10 @@ static int mgs_backup_llog(struct obd_device *obd, char* fsname)
 
         if (len >= PATH_MAX - 1) {
                 GOTO(out, -ENAMETOOLONG);
-        } 
+        }
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-                
+
         bak_filp = l_filp_open(logname, O_RDWR|O_CREAT|O_TRUNC, 0660);
         if (IS_ERR(bak_filp)) {
                 rc = PTR_ERR(bak_filp);
diff --git a/lustre/obdclass/Makefile.in b/lustre/obdclass/Makefile.in
index d81ee84..775d4ff 100644
--- a/lustre/obdclass/Makefile.in
+++ b/lustre/obdclass/Makefile.in
@@ -1,37 +1,25 @@
 MODULES := obdclass llog_test
 
 obdclass-linux-objs := linux-module.o linux-obdo.o linux-sysctl.o
-ifeq ($(PATCHLEVEL),6)
 obdclass-linux-objs := $(addprefix linux/,$(obdclass-linux-objs))
-endif
 
 default: all
 
-ifeq (@linux25@,no)
 sources:
-	@for i in $(obdclass-linux-objs:%.o=%.c) ; do \
-		echo "ln -s @srcdir@/linux/$$i ." ; \
-		ln -sf @srcdir@/linux/$$i . || exit 1 ; \
-	done
-
-else
-sources:
-
-endif
 
 obdclass-all-objs := llog.o llog_cat.o llog_lvfs.o llog_obd.o llog_swab.o
-obdclass-all-objs += class_obd.o class_hash.o
+obdclass-all-objs += class_obd.o class_hash.o target.o
 obdclass-all-objs += debug.o genops.o uuid.o llog_ioctl.o
 obdclass-all-objs += lprocfs_status.o lustre_handles.o lustre_peer.o
 obdclass-all-objs += statfs_pack.o obdo.o obd_config.o obd_mount.o
 
 obdclass-objs := $(obdclass-linux-objs) $(obdclass-all-objs)
 
-ifeq ($(PATCHLEVEL),6)
 llog_test-objs := llog-test.o
 
 $(obj)/llog-test.c: $(obj)/llog_test.c
 	ln -sf $< $@
-endif
+
+EXTRA_DIST = $(filter-out llog-test.c,$(obdclass-all-objs:.o=.c)) $(llog-test-objs:.o=.c) llog_test.c llog_internal.h
 
 @INCLUDE_RULES@
diff --git a/lustre/obdclass/autoMakefile.am b/lustre/obdclass/autoMakefile.am
index 40d964c..0553359 100644
--- a/lustre/obdclass/autoMakefile.am
+++ b/lustre/obdclass/autoMakefile.am
@@ -51,4 +51,3 @@ install-data-hook: $(install_data_hook)
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@  llog-test.c
 MOSTLYCLEANFILES += linux/*.o darwin/*.o
-DIST_SOURCES = $(filter-out llog-test.c,$(obdclass-all-objs:.o=.c)) $(llog-test-objs:.o=.c) llog_test.c llog_internal.h
diff --git a/lustre/obdclass/autoMakefile.in b/lustre/obdclass/autoMakefile.in
index 7c21a38..0dd58ea 100644
--- a/lustre/obdclass/autoMakefile.in
+++ b/lustre/obdclass/autoMakefile.in
@@ -176,9 +176,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@  llog-test.c linux/*.o darwin/*.o
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -321,7 +321,6 @@ DIST_SUBDIRS := $(SUBDIRS)
 @DARWIN_TRUE@@MODULES_TRUE at plist_DATA := Info.plist
 
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
-DIST_SOURCES = $(filter-out llog-test.c,$(obdclass-all-objs:.o=.c)) $(llog-test-objs:.o=.c) llog_test.c llog_internal.h
 subdir = lustre/obdclass
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -428,6 +427,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__liblustreclass_a_SOURCES_DIST) \
+	$(am__obdclass_SOURCES_DIST)
 DATA = $(modulefs_DATA) $(noinst_DATA) $(plist_DATA)
 
 
diff --git a/lustre/obdclass/class_hash.c b/lustre/obdclass/class_hash.c
index 0befb37..5370a4e 100644
--- a/lustre/obdclass/class_hash.c
+++ b/lustre/obdclass/class_hash.c
@@ -84,6 +84,7 @@ lustre_hash_init(char *name, unsigned int cur_bits, unsigned int max_bits,
                 RETURN(NULL);
 
         strncpy(lh->lh_name, name, sizeof(lh->lh_name));
+        lh->lh_name[sizeof(lh->lh_name) - 1] = '\0';
         atomic_set(&lh->lh_rehash_count, 0);
         atomic_set(&lh->lh_count, 0);
         rwlock_init(&lh->lh_rwlock);
@@ -146,10 +147,10 @@ lustre_hash_exit(lustre_hash_t *lh)
                 write_unlock(&lhb->lhb_rwlock);
         }
 
-        OBD_VFREE(lh->lh_buckets, sizeof(*lh->lh_buckets) << lh->lh_cur_bits);
         LASSERT(atomic_read(&lh->lh_count) == 0);
         write_unlock(&lh->lh_rwlock);
 
+        OBD_VFREE(lh->lh_buckets, sizeof(*lh->lh_buckets) << lh->lh_cur_bits);
         OBD_FREE_PTR(lh);
         EXIT;
 }
@@ -651,7 +652,7 @@ void lustre_hash_rehash_key(lustre_hash_t *lh, void *old_key, void *new_key,
         lustre_hash_bucket_t  *old_lhb;
         lustre_hash_bucket_t  *new_lhb;
         unsigned               i;
-        int                    j;
+        unsigned               j;
         ENTRY;
 
         __lustre_hash_key_validate(lh, new_key, hnode);
@@ -667,8 +668,17 @@ void lustre_hash_rehash_key(lustre_hash_t *lh, void *old_key, void *new_key,
         new_lhb = &lh->lh_buckets[j];
         LASSERT(j <= lh->lh_cur_mask);
 
-        write_lock(&old_lhb->lhb_rwlock);
-        write_lock(&new_lhb->lhb_rwlock);
+        if (i < j) { /* write_lock ordering */
+                write_lock(&old_lhb->lhb_rwlock);
+                write_lock(&new_lhb->lhb_rwlock);
+        } else if (i > j) {
+                write_lock(&new_lhb->lhb_rwlock);
+                write_lock(&old_lhb->lhb_rwlock);
+        } else { /* do nothing */
+                read_unlock(&lh->lh_rwlock);
+                EXIT;
+                return;
+        }
 
         /*
          * Migrate item between hash buckets without calling
@@ -691,7 +701,7 @@ EXPORT_SYMBOL(lustre_hash_rehash_key);
 int lustre_hash_debug_header(char *str, int size)
 {
         return snprintf(str, size,
-                 "%-36s%6s%6s%6s%6s%6s%6s%6s%7s%6s%s\n",
+                 "%-*s%6s%6s%6s%6s%6s%6s%6s%7s%6s%s\n", LUSTRE_MAX_HASH_NAME,
                  "name", "cur", "min", "max", "theta", "t-min", "t-max",
                  "flags", "rehash", "count", " distribution");
 }
@@ -711,7 +721,8 @@ int lustre_hash_debug_str(lustre_hash_t *lh, char *str, int size)
         read_lock(&lh->lh_rwlock);
         theta = __lustre_hash_theta(lh);
 
-        c += snprintf(str + c, size - c, "%-36s ", lh->lh_name);
+        c += snprintf(str + c, size - c, "%-*s ",
+                      LUSTRE_MAX_HASH_NAME, lh->lh_name);
         c += snprintf(str + c, size - c, "%5d ",  1 << lh->lh_cur_bits);
         c += snprintf(str + c, size - c, "%5d ",  1 << lh->lh_min_bits);
         c += snprintf(str + c, size - c, "%5d ",  1 << lh->lh_max_bits);
diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c
index 16533c4..9b1baf0 100644
--- a/lustre/obdclass/class_obd.c
+++ b/lustre/obdclass/class_obd.c
@@ -64,11 +64,21 @@ cfs_mem_cache_t *obd_lvfs_ctxt_cache;
 unsigned int obd_debug_peer_on_timeout;
 unsigned int obd_dump_on_timeout;
 unsigned int obd_dump_on_eviction;
+unsigned int obd_max_dirty_pages = 256;
 unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT;   /* seconds */
 unsigned int ldlm_timeout = LDLM_TIMEOUT_DEFAULT; /* seconds */
-unsigned int obd_max_dirty_pages = 256;
-atomic_t obd_dirty_pages;
+/* Adaptive timeout defs here instead of ptlrpc module for /proc/sys/ access */
+unsigned int at_min = 0;
+#ifdef HAVE_AT_SUPPORT
+unsigned int at_max = 600;
+#else
+unsigned int at_max = 0;
+#endif
+unsigned int at_history = 600;
+int at_early_margin = 5;
+int at_extra = 30;
 
+atomic_t obd_dirty_pages;
 cfs_waitq_t obd_race_waitq;
 int obd_race_state;
 
@@ -273,16 +283,16 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                 if (!data->ioc_inlbuf1) {
                         CERROR("No buffer passed in ioctl\n");
                         GOTO(out, err = -EINVAL);
-                } 
+                }
                 if (data->ioc_inllen1 < 128) {
                         CERROR("ioctl buffer too small to hold version\n");
                         GOTO(out, err = -EINVAL);
                 }
-                                
+
                 obd = class_num2obd(index);
                 if (!obd)
                         GOTO(out, err = -ENOENT);
-                
+
                 if (obd->obd_stopping)
                         status = "ST";
                 else if (obd->obd_set_up)
@@ -290,7 +300,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                 else if (obd->obd_attached)
                         status = "AT";
                 else
-                        status = "--"; 
+                        status = "--";
                 str = (char *)data->ioc_bulk;
                 snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d",
                          (int)index, status, obd->obd_type->typ_name,
@@ -303,14 +313,24 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
 
         }
 
-        if (data->ioc_dev >= class_devno_max()) {
+        if (data->ioc_dev == OBD_DEV_BY_DEVNAME) {
+                if (data->ioc_inllen4 <= 0 || data->ioc_inlbuf4 == NULL)
+                        GOTO(out, err = -EINVAL);
+                if (strnlen(data->ioc_inlbuf4, MAX_OBD_NAME) >= MAX_OBD_NAME)
+                        GOTO(out, err = -EINVAL);
+                obd = class_name2obd(data->ioc_inlbuf4);
+        } else if (data->ioc_dev < class_devno_max()) {
+                obd = class_num2obd(data->ioc_dev);
+        } else {
                 CERROR("OBD ioctl: No device\n");
                 GOTO(out, err = -EINVAL);
         }
 
-        obd = class_num2obd(data->ioc_dev);
         if (obd == NULL) {
-                CERROR("OBD ioctl : No Device %d\n", data->ioc_dev);
+                if (data->ioc_dev == OBD_DEV_BY_DEVNAME)
+                        CERROR("OBD ioctl: No Device %s\n", data->ioc_inlbuf4);
+                else
+                        CERROR("OBD ioctl: No Device %d\n", data->ioc_dev);
                 GOTO(out, err = -EINVAL);
         }
         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
@@ -328,7 +348,9 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                 }
                 CDEBUG(D_HA, "%s: disabling committed-transno notification\n",
                        obd->obd_name);
+                spin_lock_bh(&obd->obd_processing_task_lock);
                 obd->obd_no_transno = 1;
+                spin_unlock_bh(&obd->obd_processing_task_lock);
                 GOTO(out, err = 0);
         }
 
@@ -387,6 +409,11 @@ EXPORT_SYMBOL(obd_timeout);
 EXPORT_SYMBOL(ldlm_timeout);
 EXPORT_SYMBOL(obd_max_dirty_pages);
 EXPORT_SYMBOL(obd_dirty_pages);
+EXPORT_SYMBOL(at_min);
+EXPORT_SYMBOL(at_max);
+EXPORT_SYMBOL(at_extra);
+EXPORT_SYMBOL(at_early_margin);
+EXPORT_SYMBOL(at_history);
 EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
 
 EXPORT_SYMBOL(proc_lustre_root);
@@ -498,7 +525,7 @@ int obd_init_checks(void)
                 ret = -EINVAL;
         }
         if ((u64val & ~CFS_PAGE_MASK) >= CFS_PAGE_SIZE) {
-                CWARN("mask failed: u64val "LPU64" >= %lu\n", u64val, 
+                CWARN("mask failed: u64val "LPU64" >= %lu\n", u64val,
                       (unsigned long)CFS_PAGE_SIZE);
                 ret = -EINVAL;
         }
@@ -525,25 +552,25 @@ int init_obdclass(void)
 #endif
 
         LCONSOLE_INFO("OBD class driver, http://www.lustre.org/\n");
-        LCONSOLE_INFO("        Lustre Version: "LUSTRE_VERSION_STRING"\n");
-        LCONSOLE_INFO("        Build Version: "BUILD_VERSION"\n");
+        LCONSOLE_INFO("    Lustre Version: "LUSTRE_VERSION_STRING"\n");
+        LCONSOLE_INFO("    Build Version: "BUILD_VERSION"\n");
 
         spin_lock_init(&obd_types_lock);
         cfs_waitq_init(&obd_race_waitq);
         obd_zombie_impexp_init();
 #ifdef LPROCFS
-        obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM, 
-                                         LPROCFS_STATS_FLAG_PERCPU);
+        obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
+                                         LPROCFS_STATS_FLAG_NONE);
         if (obd_memory == NULL) {
                 CERROR("kmalloc of 'obd_memory' failed\n");
                 RETURN(-ENOMEM);
         }
 
         lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
-                             LPROCFS_CNTR_AVGMINMAX, 
+                             LPROCFS_CNTR_AVGMINMAX,
                              "memused", "bytes");
         lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
-                             LPROCFS_CNTR_AVGMINMAX, 
+                             LPROCFS_CNTR_AVGMINMAX,
                              "pagesused", "pages");
 #endif
         obd_lvfs_ctxt_cache = cfs_mem_cache_create("obd_lvfs_ctxt_cache",
diff --git a/lustre/obdclass/darwin/darwin-module.c b/lustre/obdclass/darwin/darwin-module.c
new file mode 100644
index 0000000..f67ae0e
--- /dev/null
+++ b/lustre/obdclass/darwin/darwin-module.c
@@ -0,0 +1,217 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ */
+
+#define DEBUG_SUBSYSTEM S_CLASS
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+
+#include <mach/mach_types.h>
+#include <string.h>
+#include <sys/file.h>
+#include <sys/conf.h>
+#include <miscfs/devfs/devfs.h>
+
+#include <libcfs/libcfs.h>
+#include <obd_support.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
+
+#ifndef OBD_MAX_IOCTL_BUFFER
+#define OBD_MAX_IOCTL_BUFFER 8192
+#endif
+
+/* buffer MUST be at least the size of obd_ioctl_hdr */
+int obd_ioctl_getdata(char **buf, int *len, void *arg)
+{
+        struct obd_ioctl_hdr *hdr;
+        struct obd_ioctl_data *data;
+        int err = 0;
+        int offset = 0;
+        ENTRY;
+
+	hdr = (struct obd_ioctl_hdr *)arg;
+        if (hdr->ioc_version != OBD_IOCTL_VERSION) {
+                CERROR("Version mismatch kernel vs application\n");
+                RETURN(-EINVAL);
+        }
+
+        if (hdr->ioc_len > OBD_MAX_IOCTL_BUFFER) {
+                CERROR("User buffer len %d exceeds %d max buffer\n",
+                       hdr->ioc_len, OBD_MAX_IOCTL_BUFFER);
+                RETURN(-EINVAL);
+        }
+
+        if (hdr->ioc_len < sizeof(struct obd_ioctl_data)) {
+                CERROR("OBD: user buffer too small for ioctl (%d)\n", hdr->ioc_len);
+                RETURN(-EINVAL);
+        }
+
+        /* XXX allocate this more intelligently, using kmalloc when
+         * appropriate */
+        OBD_VMALLOC(*buf, hdr->ioc_len);
+        if (*buf == NULL) {
+                CERROR("Cannot allocate control buffer of len %d\n",
+                       hdr->ioc_len);
+                RETURN(-EINVAL);
+        }
+        *len = hdr->ioc_len;
+        data = (struct obd_ioctl_data *)*buf;
+
+	bzero(data, hdr->ioc_len);
+	memcpy(data, (void *)arg, sizeof(struct obd_ioctl_data));
+	if (data->ioc_inlbuf1)
+		err = copy_from_user(&data->ioc_bulk[0], (void *)data->ioc_inlbuf1,
+				     hdr->ioc_len - ((void *)&data->ioc_bulk[0] - (void *)data));
+
+        if (obd_ioctl_is_invalid(data)) {
+                CERROR("ioctl not correctly formatted\n");
+                return -EINVAL;
+        }
+
+        if (data->ioc_inllen1) {
+                data->ioc_inlbuf1 = &data->ioc_bulk[0];
+                offset += size_round(data->ioc_inllen1);
+        }
+
+        if (data->ioc_inllen2) {
+                data->ioc_inlbuf2 = &data->ioc_bulk[0] + offset;
+                offset += size_round(data->ioc_inllen2);
+        }
+
+        if (data->ioc_inllen3) {
+                data->ioc_inlbuf3 = &data->ioc_bulk[0] + offset;
+                offset += size_round(data->ioc_inllen3);
+        }
+
+        if (data->ioc_inllen4) {
+                data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset;
+        }
+
+        EXIT;
+        return 0;
+}
+
+int obd_ioctl_popdata(void *arg, void *data, int len)
+{
+	/* 
+	 * Xnu ioctl copyout(uaddr, arg, sizeof(struct obd_ioctl_data)),
+	 * we have to copyout data exceed sizeof(struct obd_ioctl_data)
+	 * by ourself.
+	 */
+	if (len <= sizeof(struct obd_ioctl_data)) {
+		memcpy(arg, data, len);
+		return 0;
+	} else {
+		int err;
+		struct obd_ioctl_data *u = (struct obd_ioctl_data *)arg;
+		struct obd_ioctl_data *k = (struct obd_ioctl_data *)data;
+		err = copy_to_user((void *)u->ioc_inlbuf1, &k->ioc_bulk[0],
+				    len -((void *)&k->ioc_bulk[0] -(void *)k));
+		memcpy(arg, data, sizeof(struct obd_ioctl_data));
+		return err;
+	}
+}
+/*
+ * cfs pseudo device
+ */
+extern struct cfs_psdev_ops          obd_psdev_ops;
+
+static int
+obd_class_open(dev_t dev, int flags, int devtype, struct proc *p)
+{
+	if (obd_psdev_ops.p_open != NULL)
+		return -obd_psdev_ops.p_open(0, NULL);
+	return EPERM;
+}
+
+/*  closing /dev/obd */
+static int
+obd_class_release(dev_t dev, int flags, int mode, struct proc *p)
+{
+	if (obd_psdev_ops.p_close != NULL)
+		return -obd_psdev_ops.p_close(0, NULL);
+	return EPERM;
+}
+
+static int
+obd_class_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
+{
+	int err = 0;
+	ENTRY;
+
+	if (!is_suser())
+		RETURN (EPERM);
+	if (obd_psdev_ops.p_ioctl != NULL)
+		err = -obd_psdev_ops.p_ioctl(NULL, cmd, (void *)arg);
+	else
+		err = EPERM;
+
+	RETURN(err);
+}
+
+static struct cdevsw obd_psdevsw = {
+	obd_class_open,
+	obd_class_release,
+	NULL,
+	NULL,
+	obd_class_ioctl,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+};
+
+cfs_psdev_t obd_psdev = {
+	-1,
+	NULL,
+	"obd",
+	&obd_psdevsw
+};
+
+int class_procfs_init(void)
+{
+	return 0;
+}
+
+int class_procfs_clean(void)
+{
+	return 0;
+}
diff --git a/lustre/obdclass/darwin/darwin-sysctl.c b/lustre/obdclass/darwin/darwin-sysctl.c
new file mode 100644
index 0000000..3d0d5f6
--- /dev/null
+++ b/lustre/obdclass/darwin/darwin-sysctl.c
@@ -0,0 +1,189 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+#include <sys/sysctl.h>
+#include <sys/proc.h>
+#include <sys/unistd.h>
+#include <mach/mach_types.h>
+#include <lustre/lustre_build_version.h>
+
+#define DEBUG_SUBSYSTEM S_CLASS
+                                                                                                                                                                     
+#include <libcfs/libcfs.h>
+#ifndef BUILD_VERSION	
+#define BUILD_VERSION		"Unknown"
+#endif
+#ifndef LUSTRE_KERNEL_VERSION
+#define LUSTRE_KERNEL_VERSION	"Unknown Darwin version"
+#endif
+
+cfs_sysctl_table_header_t *obd_table_header = NULL;
+
+int proc_fail_loc SYSCTL_HANDLER_ARGS;
+int proc_obd_timeout SYSCTL_HANDLER_ARGS;
+extern unsigned int obd_fail_loc;
+extern unsigned int obd_dump_on_timeout;
+extern unsigned int obd_timeout;
+extern unsigned int ldlm_timeout;
+extern unsigned int obd_sync_filter;
+extern atomic_t obd_memory;
+
+int read_build_version SYSCTL_HANDLER_ARGS;
+int read_lustre_kernel_version SYSCTL_HANDLER_ARGS;
+
+SYSCTL_NODE (,                  OID_AUTO,       lustre,	    CTLFLAG_RW,
+	     0,                 "lustre sysctl top");
+SYSCTL_PROC(_lustre,		OID_AUTO,       fail_loc, 
+	    CTLTYPE_INT | CTLFLAG_RW ,		&obd_fail_loc,
+	    0,		&proc_fail_loc,		"I",	"obd_fail_loc");
+SYSCTL_PROC(_lustre,		OID_AUTO,       timeout, 
+	    CTLTYPE_INT | CTLFLAG_RW ,		&obd_timeout,
+	    0,		&proc_obd_timeout,	"I",	"obd_timeout");
+SYSCTL_PROC(_lustre,		OID_AUTO,       build_version, 
+	    CTLTYPE_STRING | CTLFLAG_RD ,	NULL,
+	    0,		&read_build_version,	"A",	"lustre_build_version");
+SYSCTL_PROC(_lustre,		OID_AUTO,       lustre_kernel_version,
+	    CTLTYPE_STRING | CTLFLAG_RD ,	NULL,
+	    0,		&read_lustre_kernel_version,	"A",	"lustre_build_version");
+SYSCTL_INT(_lustre,		OID_AUTO,	dump_on_timeout, 
+	   CTLTYPE_INT | CTLFLAG_RW,		&obd_dump_on_timeout,
+	   0,		"lustre_dump_on_timeout");
+SYSCTL_INT(_lustre,		OID_AUTO,	debug_peer_on_timeout, 
+	   CTLTYPE_INT | CTLFLAG_RW,		&obd_debug_peer_on_timeout,
+	   0,		"lustre_debug_peer_on_timeout");
+SYSCTL_INT(_lustre,		OID_AUTO,	memused, 
+	   CTLTYPE_INT | CTLFLAG_RW,		(int *)&obd_memory.counter,
+	   0,		"lustre_memory_used");
+SYSCTL_INT(_lustre,		OID_AUTO,	ldlm_timeout, 
+	   CTLTYPE_INT | CTLFLAG_RW,		&ldlm_timeout,
+	   0,		"ldlm_timeout");
+
+static cfs_sysctl_table_t      parent_table[] = {
+	&sysctl__lustre,
+	&sysctl__lustre_fail_loc,
+	&sysctl__lustre_timeout,
+	&sysctl__lustre_dump_on_timeout,
+	&sysctl__lustre_debug_peer_on_timeout,
+	&sysctl__lustre_upcall,
+	&sysctl__lustre_memused,
+	&sysctl__lustre_filter_sync_on_commit,
+	&sysctl__lustre_ldlm_timeout,
+};
+
+extern cfs_waitq_t obd_race_waitq;
+
+int proc_fail_loc SYSCTL_HANDLER_ARGS
+{ 
+	int error = 0; 
+	int old_fail_loc = obd_fail_loc;
+	
+	error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req); 
+	if (!error && req->newptr != USER_ADDR_NULL) {
+		if (old_fail_loc != obd_fail_loc) 
+			cfs_waitq_signal(&obd_race_waitq);
+	} else  if (req->newptr != USER_ADDR_NULL) { 
+		/* Something was wrong with the write request */ 
+		printf ("sysctl fail loc fault: %d.\n", error);
+	} else { 
+		/* Read request */ 
+		error = SYSCTL_OUT(req, &obd_fail_loc, sizeof obd_fail_loc);
+	}
+	return error;
+}
+
+int proc_obd_timeout SYSCTL_HANDLER_ARGS
+{ 
+	int error = 0;
+
+	error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req); 
+	if (!error && req->newptr != USER_ADDR_NULL) {
+		if (ldlm_timeout >= obd_timeout)
+			ldlm_timeout = max(obd_timeout / 3, 1U);
+	} else  if (req->newptr != USER_ADDR_NULL) { 
+		printf ("sysctl fail obd_timeout: %d.\n", error);
+	} else {
+		/* Read request */ 
+		error = SYSCTL_OUT(req, &obd_timeout, sizeof obd_timeout);
+	}
+	return error;
+}
+
+int read_build_version SYSCTL_HANDLER_ARGS
+{
+	int error = 0;
+
+	error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req); 
+	if ( req->newptr != USER_ADDR_NULL) {
+		printf("sysctl read_build_version is read-only!\n");
+	} else {
+		error = SYSCTL_OUT(req, BUILD_VERSION, strlen(BUILD_VERSION));
+	}
+	return error;
+}
+
+int read_lustre_kernel_version SYSCTL_HANDLER_ARGS
+{
+	int error = 0;
+
+	error = sysctl_handle_long(oidp, oidp->oid_arg1, oidp->oid_arg2, req); 
+	if ( req->newptr != NULL) {
+		printf("sysctl lustre_kernel_version is read-only!\n");
+	} else {
+		error = SYSCTL_OUT(req, LUSTRE_KERNEL_VERSION, strlen(LUSTRE_KERNEL_VERSION));
+	}
+	return error;
+}
+
+void obd_sysctl_init (void)
+{
+#if 1 
+	if ( !obd_table_header ) 
+		obd_table_header = cfs_register_sysctl_table(parent_table, 0);
+#endif
+}
+                                                                                                                                                                     
+void obd_sysctl_clean (void)
+{
+#if 1 
+	if ( obd_table_header ) 
+		cfs_unregister_sysctl_table(obd_table_header); 
+	obd_table_header = NULL;
+#endif
+}
diff --git a/lustre/obdclass/debug.c b/lustre/obdclass/debug.c
index 1f4d99b..a80cd2c 100644
--- a/lustre/obdclass/debug.c
+++ b/lustre/obdclass/debug.c
@@ -117,9 +117,10 @@ int dump_obdo(struct obdo *oa)
 void dump_lsm(int level, struct lov_stripe_md *lsm)
 {
         CDEBUG(level, "lsm %p, objid "LPX64", maxbytes "LPX64", magic 0x%08X, "
-               "stripe_size %u, stripe_count %u\n", lsm,
+               "stripe_size %u, stripe_count %u pool "LOV_POOLNAMEF"\n", lsm,
                lsm->lsm_object_id, lsm->lsm_maxbytes, lsm->lsm_magic,
-               lsm->lsm_stripe_size, lsm->lsm_stripe_count);
+               lsm->lsm_stripe_size, lsm->lsm_stripe_count,
+               lsm->lsm_pool_name);
 }
 
 /* XXX assumes only a single page in request */
diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c
index bc12c28..9f3ae9f 100644
--- a/lustre/obdclass/genops.c
+++ b/lustre/obdclass/genops.c
@@ -47,6 +47,7 @@
 #include <obd_class.h>
 #include <lprocfs_status.h>
 #include <class_hash.h>
+#include <lustre_export.h>
 
 extern struct list_head obd_types;
 spinlock_t obd_types_lock;
@@ -643,6 +644,8 @@ static void export_handle_addref(void *export)
         class_export_get(export);
 }
 
+/* called from mds_commit_cb() in context of journal commit callback
+ * and cannot call any blocking functions. */
 void __class_export_put(struct obd_export *exp)
 {
         if (atomic_dec_and_test(&exp->exp_refcount)) {
@@ -676,6 +679,7 @@ void class_export_destroy(struct obd_export *exp)
                 ptlrpc_put_connection_superhack(exp->exp_connection);
 
         LASSERT(list_empty(&exp->exp_outstanding_replies));
+        LASSERT(list_empty(&exp->exp_uncommitted_replies));
         LASSERT(list_empty(&exp->exp_req_replay_queue));
         LASSERT(list_empty(&exp->exp_queued_rpc));
         obd_destroy_export(exp);
@@ -703,8 +707,11 @@ struct obd_export *class_new_export(struct obd_device *obd,
         atomic_set(&export->exp_rpc_count, 0);
         export->exp_obd = obd;
         CFS_INIT_LIST_HEAD(&export->exp_outstanding_replies);
+        spin_lock_init(&export->exp_uncommitted_replies_lock);
+        CFS_INIT_LIST_HEAD(&export->exp_uncommitted_replies);
         CFS_INIT_LIST_HEAD(&export->exp_req_replay_queue);
         CFS_INIT_LIST_HEAD(&export->exp_queued_rpc);
+
         CFS_INIT_LIST_HEAD(&export->exp_handle.h_link);
         class_handle_hash(&export->exp_handle, export_handle_addref);
         export->exp_last_request_time = cfs_time_current_sec();
@@ -757,7 +764,9 @@ void class_unlink_export(struct obd_export *exp)
         spin_unlock(&exp->exp_obd->obd_dev_lock);
         /* Keep these counter valid always */
         spin_lock_bh(&exp->exp_obd->obd_processing_task_lock);
-        if (exp->exp_replay_needed)
+        if (exp->exp_delayed)
+                exp->exp_obd->obd_delayed_clients--;
+        else if (exp->exp_replay_needed)
                 exp->exp_obd->obd_recoverable_clients--;
         spin_unlock_bh(&exp->exp_obd->obd_processing_task_lock);
         class_export_put(exp);
@@ -872,6 +881,10 @@ struct obd_import *class_new_import(struct obd_device *obd)
         class_handle_hash(&imp->imp_handle, import_handle_addref);
         init_imp_at(&imp->imp_at);
 
+/* b1_8 supports both v1 & v2. but HEAD only supports v2.
+ * So let's use v2.
+ */
+#define HAVE_DEFAULT_V2_CONNECT 1
 #ifdef HAVE_DEFAULT_V2_CONNECT
         /* the default magic is V2, will be used in connect RPC, and
          * then adjusted according to the flags in request/reply. */
@@ -927,10 +940,12 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd,
 }
 EXPORT_SYMBOL(class_connect);
 
-/* This function removes two references from the export: one for the
- * hash entry and one for the export pointer passed in.  The export
- * pointer passed to this function is destroyed should not be used
- * again. */
+/* This function removes 1-3 references from the export:
+ * 1 - for export pointer passed
+ * and if disconnect really need
+ * 2 - removing from hash
+ * 3 - in client_unlink_export
+ * The export pointer passed to this function can destroyed */
 int class_disconnect(struct obd_export *export)
 {
         int already_disconnected;
@@ -945,24 +960,27 @@ int class_disconnect(struct obd_export *export)
         spin_lock(&export->exp_lock);
         already_disconnected = export->exp_disconnected;
         export->exp_disconnected = 1;
-
-        if (!hlist_unhashed(&export->exp_nid_hash))
-                lustre_hash_del(export->exp_obd->obd_nid_hash,
-                                &export->exp_connection->c_peer.nid,
-                                &export->exp_nid_hash);
-
         spin_unlock(&export->exp_lock);
 
+
         /* class_cleanup(), abort_recovery(), and class_fail_export()
          * all end up in here, and if any of them race we shouldn't
          * call extra class_export_puts(). */
         if (already_disconnected)
-                RETURN(0);
+                GOTO(no_disconn, already_disconnected);
 
         CDEBUG(D_IOCTL, "disconnect: cookie "LPX64"\n",
                export->exp_handle.h_cookie);
 
+
+        if (!hlist_unhashed(&export->exp_nid_hash))
+                lustre_hash_del(export->exp_obd->obd_nid_hash,
+                                &export->exp_connection->c_peer.nid,
+                                &export->exp_nid_hash);
+
         class_unlink_export(export);
+
+no_disconn:
         class_export_put(export);
         RETURN(0);
 }
@@ -971,14 +989,14 @@ static void class_disconnect_export_list(struct list_head *list,
                                          enum obd_option flags)
 {
         int rc;
-        struct lustre_handle fake_conn;
-        struct obd_export *fake_exp, *exp;
+        struct obd_export *exp;
         ENTRY;
 
         /* It's possible that an export may disconnect itself, but
          * nothing else will be added to this list. */
         while (!list_empty(list)) {
                 exp = list_entry(list->next, struct obd_export, exp_obd_chain);
+                /* need for safe call CDEBUG after obd_disconnect */
                 class_export_get(exp);
 
                 spin_lock(&exp->exp_lock);
@@ -997,22 +1015,16 @@ static void class_disconnect_export_list(struct list_head *list,
                         continue;
                 }
 
-                fake_conn.cookie = exp->exp_handle.h_cookie;
-                fake_exp = class_conn2export(&fake_conn);
-                if (!fake_exp) {
-                        class_export_put(exp);
-                        continue;
-                }
-
-                spin_lock(&fake_exp->exp_lock);
-                fake_exp->exp_flags = flags;
-                spin_unlock(&fake_exp->exp_lock);
-
+                class_export_get(exp);
                 CDEBUG(D_HA, "%s: disconnecting export at %s (%p), "
                        "last request at %ld\n",
                        exp->exp_obd->obd_name, obd_export_nid2str(exp),
                        exp, exp->exp_last_request_time);
-                rc = obd_disconnect(fake_exp);
+
+                /* release one export reference anyway */
+                rc = obd_disconnect(exp);
+                CDEBUG(D_HA, "disconnected export at %s (%p): rc %d\n",
+                       obd_export_nid2str(exp), exp, rc);
                 class_export_put(exp);
         }
         EXIT;
@@ -1024,9 +1036,10 @@ void class_disconnect_exports(struct obd_device *obd)
         ENTRY;
 
         /* Move all of the exports from obd_exports to a work list, en masse. */
+        CFS_INIT_LIST_HEAD(&work_list);
         spin_lock(&obd->obd_dev_lock);
-        list_add(&work_list, &obd->obd_exports);
-        list_del_init(&obd->obd_exports);
+        list_splice_init(&obd->obd_delayed_exports, &work_list);
+        list_splice_init(&obd->obd_exports, &work_list);
         spin_unlock(&obd->obd_dev_lock);
 
         CDEBUG(D_HA, "OBD device %d (%p) has exports, "
@@ -1036,15 +1049,13 @@ void class_disconnect_exports(struct obd_device *obd)
 }
 EXPORT_SYMBOL(class_disconnect_exports);
 
-/* Remove exports that have not completed recovery.
- */
+/* Remove exports that have not completed recovery. */
 void class_disconnect_stale_exports(struct obd_device *obd,
                                     enum obd_option flags)
 {
         struct list_head work_list;
         struct list_head *pos, *n;
         struct obd_export *exp;
-        int cnt = 0;
         ENTRY;
 
         CFS_INIT_LIST_HEAD(&work_list);
@@ -1052,20 +1063,125 @@ void class_disconnect_stale_exports(struct obd_device *obd,
         list_for_each_safe(pos, n, &obd->obd_exports) {
                 exp = list_entry(pos, struct obd_export, exp_obd_chain);
                 if (exp->exp_replay_needed) {
-                        list_del(&exp->exp_obd_chain);
-                        list_add(&exp->exp_obd_chain, &work_list);
-                        cnt++;
+                        list_move(&exp->exp_obd_chain, &work_list);
+                        obd->obd_stale_clients++;
                 }
         }
         spin_unlock(&obd->obd_dev_lock);
 
-        CDEBUG(D_ERROR, "%s: disconnecting %d stale clients\n",
-               obd->obd_name, cnt);
+        CDEBUG(D_HA, "%s: disconnecting %d stale clients\n",
+               obd->obd_name, obd->obd_stale_clients);
         class_disconnect_export_list(&work_list, flags);
         EXIT;
 }
 EXPORT_SYMBOL(class_disconnect_stale_exports);
 
+void class_disconnect_expired_exports(struct obd_device *obd)
+{
+        struct list_head expired_list;
+        struct obd_export *exp, *n;
+        int cnt = 0;
+        ENTRY;
+
+        CFS_INIT_LIST_HEAD(&expired_list);
+        spin_lock(&obd->obd_dev_lock);
+        list_for_each_entry_safe(exp, n, &obd->obd_delayed_exports,
+                                 exp_obd_chain) {
+                if (exp_expired(exp, obd->u.obt.obt_stale_export_age)) {
+                        list_move(&exp->exp_obd_chain, &expired_list);
+                        cnt++;
+                }
+        }
+        spin_unlock(&obd->obd_dev_lock);
+
+        if (cnt == 0)
+                return;
+
+        CDEBUG(D_INFO, "%s: disconnecting %d expired exports\n",
+               obd->obd_name, cnt);
+        class_disconnect_export_list(&expired_list, exp_flags_from_obd(obd));
+
+        EXIT;
+}
+EXPORT_SYMBOL(class_disconnect_expired_exports);
+
+void class_set_export_delayed(struct obd_export *exp)
+{
+        struct obd_device *obd = class_exp2obd(exp);
+
+        LASSERT(!exp->exp_delayed);
+        spin_lock(&exp->exp_lock);
+        exp->exp_delayed = 1;
+        spin_unlock(&exp->exp_lock);
+
+        /* no need to ping delayed exports */
+        spin_lock(&obd->obd_dev_lock);
+        list_del_init(&exp->exp_obd_chain_timed);
+        list_move_tail(&exp->exp_obd_chain, &obd->obd_delayed_exports);
+        spin_unlock(&obd->obd_dev_lock);
+
+        LASSERT(obd->obd_recoverable_clients > 0);
+
+        spin_lock_bh(&obd->obd_processing_task_lock);
+        obd->obd_delayed_clients++;
+        obd->obd_recoverable_clients--;
+        spin_unlock_bh(&obd->obd_processing_task_lock);
+
+        CDEBUG(D_HA, "%s: set client %s as delayed\n",
+               obd->obd_name, exp->exp_client_uuid.uuid);
+}
+EXPORT_SYMBOL(class_set_export_delayed);
+
+/*
+ * Manage exports that have not completed recovery.
+ */
+void class_handle_stale_exports(struct obd_device *obd)
+{
+        struct list_head delay_list, evict_list;
+        struct obd_export *exp, *n;
+        int delayed = 0;
+        ENTRY;
+
+        CFS_INIT_LIST_HEAD(&delay_list);
+        CFS_INIT_LIST_HEAD(&evict_list);
+        spin_lock(&obd->obd_dev_lock);
+        list_for_each_entry_safe(exp, n, &obd->obd_exports, exp_obd_chain) {
+                LASSERT(!exp->exp_delayed);
+                /* clients finished recovery */
+                if (!exp->exp_replay_needed)
+                        continue;
+                /* connected non-vbr clients are evicted */
+                if (exp->exp_in_recovery && !exp_connect_vbr(exp)) {
+                        obd->obd_stale_clients++;
+                        list_move_tail(&exp->exp_obd_chain, &evict_list);
+                        continue;
+                }
+                if (obd->obd_version_recov || !exp->exp_in_recovery) {
+                        list_move_tail(&exp->exp_obd_chain, &delay_list);
+                        delayed++;
+                }
+        }
+#ifndef HAVE_DELAYED_RECOVERY
+        /* delayed recovery is turned off, evict all delayed exports */
+        list_splice_init(&delay_list, &evict_list);
+        list_splice_init(&obd->obd_delayed_exports, &evict_list);
+        obd->obd_stale_clients += delayed;
+#endif
+        spin_unlock(&obd->obd_dev_lock);
+
+        list_for_each_entry_safe(exp, n, &delay_list, exp_obd_chain) {
+                class_set_export_delayed(exp);
+                exp->exp_last_request_time = cfs_time_current_sec();
+        }
+        LASSERT(list_empty(&delay_list));
+
+        /* evict clients without VBR support */
+        class_disconnect_export_list(&evict_list, exp_flags_from_obd(obd));
+
+        EXIT;
+}
+EXPORT_SYMBOL(class_handle_stale_exports);
+
 int oig_init(struct obd_io_group **oig_out)
 {
         struct obd_io_group *oig;
diff --git a/lustre/obdclass/linux/Makefile.in b/lustre/obdclass/linux/Makefile.in
index 74fb0d2..2ff15ce 100644
--- a/lustre/obdclass/linux/Makefile.in
+++ b/lustre/obdclass/linux/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c
index 40603d6..431f074 100644
--- a/lustre/obdclass/linux/linux-module.c
+++ b/lustre/obdclass/linux/linux-module.c
@@ -419,13 +419,14 @@ int class_procfs_init(void)
         ENTRY;
 
         obd_sysctl_init();
-        proc_lustre_root = proc_mkdir("lustre", proc_root_fs);
+        proc_lustre_root = lprocfs_register("fs/lustre", NULL,
+                                              lprocfs_base, NULL);
         if (!proc_lustre_root) {
                 printk(KERN_ERR
                        "LustreError: error registering /proc/fs/lustre\n");
                 RETURN(-ENOMEM);
         }
-        proc_version = lprocfs_add_vars(proc_lustre_root, lprocfs_base, NULL);
+
         entry = create_proc_entry("devices", 0444, proc_lustre_root);
         if (entry == NULL) {
                 CERROR("error registering /proc/fs/lustre/devices\n");
diff --git a/lustre/obdclass/linux/linux-obdo.c b/lustre/obdclass/linux/linux-obdo.c
index 04155cc..3c85ae4 100644
--- a/lustre/obdclass/linux/linux-obdo.c
+++ b/lustre/obdclass/linux/linux-obdo.c
@@ -220,16 +220,10 @@ void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid)
 
         if (valid & OBD_MD_FLATIME && src->o_atime > LTIME_S(dst->i_atime))
                 LTIME_S(dst->i_atime) = src->o_atime;
-
-        /* mtime is always updated with ctime, but can be set in past.
-           As write and utime(2) may happen within 1 second, and utime's
-           mtime has a priority over write's one, leave mtime from mds 
-           for the same ctimes. */
-        if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime)) {
+        if (valid & OBD_MD_FLMTIME && src->o_mtime > LTIME_S(dst->i_mtime))
+                LTIME_S(dst->i_mtime) = src->o_mtime;
+        if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime))
                 LTIME_S(dst->i_ctime) = src->o_ctime;
-                if (valid & OBD_MD_FLMTIME)
-                        LTIME_S(dst->i_mtime) = src->o_mtime;
-        }
         if (valid & OBD_MD_FLSIZE)
                 i_size_write(dst, src->o_size);
         /* optimum IO size */
diff --git a/lustre/obdclass/linux/linux-sysctl.c b/lustre/obdclass/linux/linux-sysctl.c
index b9eac5e..b6333ce 100644
--- a/lustre/obdclass/linux/linux-sysctl.c
+++ b/lustre/obdclass/linux/linux-sysctl.c
@@ -56,7 +56,9 @@
 
 cfs_sysctl_table_header_t *obd_table_header = NULL;
 
-#define OBD_SYSCTL 300
+#ifndef HAVE_SYSCTL_UNNUMBERED
+
+#define CTL_LUSTRE      300
 
 enum {
         OBD_FAIL_LOC = 1,       /* control test failures instrumentation */
@@ -73,7 +75,34 @@ enum {
         OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */
         OBD_ALLOC_FAIL_RATE,    /* memory allocation random failure rate */
         OBD_MAX_DIRTY_PAGES,    /* maximum dirty pages */
+        OBD_AT_MIN,             /* Adaptive timeouts params */
+        OBD_AT_MAX,
+        OBD_AT_EXTRA,
+        OBD_AT_EARLY_MARGIN,
+        OBD_AT_HISTORY,
 };
+#else
+#define CTL_LUSTRE              CTL_UNNUMBERED
+#define OBD_FAIL_LOC            CTL_UNNUMBERED
+#define OBD_FAIL_VAL            CTL_UNNUMBERED
+#define OBD_TIMEOUT             CTL_UNNUMBERED
+#define OBD_DUMP_ON_TIMEOUT     CTL_UNNUMBERED
+#define OBD_MEMUSED             CTL_UNNUMBERED
+#define OBD_PAGESUSED           CTL_UNNUMBERED
+#define OBD_MAXMEMUSED          CTL_UNNUMBERED
+#define OBD_MAXPAGESUSED        CTL_UNNUMBERED
+#define OBD_SYNCFILTER          CTL_UNNUMBERED
+#define OBD_LDLM_TIMEOUT        CTL_UNNUMBERED
+#define OBD_DUMP_ON_EVICTION    CTL_UNNUMBERED
+#define OBD_DEBUG_PEER_ON_TIMEOUT CTL_UNNUMBERED
+#define OBD_ALLOC_FAIL_RATE     CTL_UNNUMBERED
+#define OBD_MAX_DIRTY_PAGES     CTL_UNNUMBERED
+#define OBD_AT_MIN              CTL_UNNUMBERED
+#define OBD_AT_MAX              CTL_UNNUMBERED
+#define OBD_AT_EXTRA            CTL_UNNUMBERED
+#define OBD_AT_EARLY_MARGIN     CTL_UNNUMBERED
+#define OBD_AT_HISTORY          CTL_UNNUMBERED
+#endif
 
 int LL_PROC_PROTO(proc_fail_loc)
 {
@@ -120,7 +149,8 @@ int LL_PROC_PROTO(proc_max_dirty_pages_in_mb)
                         obd_max_dirty_pages = 4 << (20 - CFS_PAGE_SHIFT);
                 }
         } else {
-                char buf[21];
+                char buf[22];
+                struct ctl_table dummy;
                 int len;
 
                 len = lprocfs_read_frac_helper(buf, sizeof(buf),
@@ -129,7 +159,13 @@ int LL_PROC_PROTO(proc_max_dirty_pages_in_mb)
                 if (len > *lenp)
                         len = *lenp;
                 buf[len] = '\0';
-                if (copy_to_user(buffer, buf, len))
+
+                dummy = *table;
+                dummy.data = buf;
+                dummy.maxlen = sizeof(buf);
+
+                rc = ll_proc_dostring(&dummy,write,filp,buffer,lenp, ppos);
+                if (rc)
                         return -EFAULT;
                 *lenp = len;
         }
@@ -152,7 +188,8 @@ int LL_PROC_PROTO(proc_alloc_fail_rate)
                                                (unsigned int*)table->data,
                                                OBD_ALLOC_FAIL_MULT);
         } else {
-                char buf[21];
+                char buf[22];
+                struct ctl_table dummy;
                 int  len;
 
                 len = lprocfs_read_frac_helper(buf, sizeof(buf),
@@ -161,7 +198,12 @@ int LL_PROC_PROTO(proc_alloc_fail_rate)
                 if (len > *lenp)
                         len = *lenp;
                 buf[len] = '\0';
-                if (copy_to_user(buffer, buf, len))
+                dummy = *table;
+                dummy.data = buf;
+                dummy.maxlen = sizeof(buf);
+
+                rc = ll_proc_dostring(&dummy,write,filp,buffer,lenp, ppos);
+                if(rc)
                         return -EFAULT;
                 *lenp = len;
         }
@@ -172,6 +214,7 @@ int LL_PROC_PROTO(proc_alloc_fail_rate)
 
 int LL_PROC_PROTO(proc_memory_alloc)
 {
+        struct ctl_table dummy;
         char buf[22];
         int len;
         DECLARE_LL_PROC_PPOS_DECL;
@@ -187,15 +230,17 @@ int LL_PROC_PROTO(proc_memory_alloc)
         if (len > *lenp)
                 len = *lenp;
         buf[len] = '\0';
-        if (copy_to_user(buffer, buf, len))
-                return -EFAULT;
-        *lenp = len;
-        *ppos += *lenp;
-        return 0;
+
+        dummy = *table;
+        dummy.data = buf;
+        dummy.maxlen = sizeof(buf);
+
+        return ll_proc_dostring(&dummy,write,filp,buffer,lenp, ppos);
 }
 
 int LL_PROC_PROTO(proc_pages_alloc)
 {
+        struct ctl_table dummy;
         char buf[22];
         int len;
         DECLARE_LL_PROC_PPOS_DECL;
@@ -211,15 +256,17 @@ int LL_PROC_PROTO(proc_pages_alloc)
         if (len > *lenp)
                 len = *lenp;
         buf[len] = '\0';
-        if (copy_to_user(buffer, buf, len))
-                return -EFAULT;
-        *lenp = len;
-        *ppos += *lenp;
-        return 0;
+
+        dummy = *table;
+        dummy.data = buf;
+        dummy.maxlen = sizeof(buf);
+
+        return ll_proc_dostring(&dummy,write,filp,buffer,lenp, ppos);
 }
 
 int LL_PROC_PROTO(proc_mem_max)
 {
+        struct ctl_table dummy;
         char buf[22];
         int len;
         DECLARE_LL_PROC_PPOS_DECL;
@@ -235,17 +282,19 @@ int LL_PROC_PROTO(proc_mem_max)
         if (len > *lenp)
                 len = *lenp;
         buf[len] = '\0';
-        if (copy_to_user(buffer, buf, len))
-                return -EFAULT;
-        *lenp = len;
-        *ppos += *lenp;
-        return 0;
+
+        dummy = *table;
+        dummy.data = buf;
+        dummy.maxlen = sizeof(buf);
+
+        return ll_proc_dostring(&dummy,write,filp,buffer,lenp, ppos);
 }
 
 int LL_PROC_PROTO(proc_pages_max)
 {
         char buf[22];
         int len;
+        struct ctl_table dummy;
         DECLARE_LL_PROC_PPOS_DECL;
 
         if (!*lenp || (*ppos && !write)) {
@@ -254,16 +303,38 @@ int LL_PROC_PROTO(proc_pages_max)
         }
         if (write)
                 return -EINVAL;
+         dummy = *table;
+         dummy.data = buf;
+         dummy.maxlen = sizeof(buf);
+         len = snprintf(buf, sizeof(buf), LPU64,
+                        obd_pages_max());
 
-        len = snprintf(buf, sizeof(buf), LPU64"\n", obd_pages_max());
-        if (len > *lenp)
-                len = *lenp;
-        buf[len] = '\0';
-        if (copy_to_user(buffer, buf, len))
-                return -EFAULT;
-        *lenp = len;
-        *ppos += *lenp;
-        return 0;
+         if (len > *lenp)
+                 len = *lenp;
+         buf[len] = '\0';
+
+         return ll_proc_dostring(&dummy,write,filp,buffer,lenp, ppos);
+}
+
+int LL_PROC_PROTO(proc_at_min)
+{
+        return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
+}
+int LL_PROC_PROTO(proc_at_max)
+{
+        return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
+}
+int LL_PROC_PROTO(proc_at_extra)
+{
+        return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
+}
+int LL_PROC_PROTO(proc_at_early_margin)
+{
+        return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
+}
+int LL_PROC_PROTO(proc_at_history)
+{
+        return ll_proc_dointvec(table, write, filp, buffer, lenp, ppos);
 }
 
 static cfs_sysctl_table_t obd_table[] = {
@@ -281,7 +352,8 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = &obd_fail_val,
                 .maxlen   = sizeof(int),
                 .mode     = 0644,
-                .proc_handler = &proc_dointvec
+                .proc_handler = &proc_dointvec,
+                .strategy = &sysctl_intvec,
         },
         {
                 .ctl_name = OBD_TIMEOUT,
@@ -297,7 +369,7 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = &obd_debug_peer_on_timeout,
                 .maxlen   = sizeof(int),
                 .mode     = 0644,
-                .proc_handler = &proc_dointvec
+                .proc_handler = &proc_dointvec,
         },
         {
                 .ctl_name = OBD_DUMP_ON_TIMEOUT,
@@ -305,7 +377,7 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = &obd_dump_on_timeout,
                 .maxlen   = sizeof(int),
                 .mode     = 0644,
-                .proc_handler = &proc_dointvec
+                .proc_handler = &proc_dointvec,
         },
         {
                 .ctl_name = OBD_DUMP_ON_EVICTION,
@@ -313,7 +385,7 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = &obd_dump_on_eviction,
                 .maxlen   = sizeof(int),
                 .mode     = 0644,
-                .proc_handler = &proc_dointvec
+                .proc_handler = &proc_dointvec,
         },
         {
                 .ctl_name = OBD_MEMUSED,
@@ -321,7 +393,7 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = NULL,
                 .maxlen   = 0,
                 .mode     = 0444,
-                .proc_handler = &proc_memory_alloc
+                .proc_handler = &proc_memory_alloc,
         },
         {
                 .ctl_name = OBD_PAGESUSED,
@@ -329,7 +401,7 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = NULL,
                 .maxlen   = 0,
                 .mode     = 0444,
-                .proc_handler = &proc_pages_alloc
+                .proc_handler = &proc_pages_alloc,
         },
         {
                 .ctl_name = OBD_MAXMEMUSED,
@@ -337,7 +409,7 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = NULL,
                 .maxlen   = 0,
                 .mode     = 0444,
-                .proc_handler = &proc_mem_max
+                .proc_handler = &proc_mem_max,
         },
         {
                 .ctl_name = OBD_MAXPAGESUSED,
@@ -345,7 +417,7 @@ static cfs_sysctl_table_t obd_table[] = {
                 .data     = NULL,
                 .maxlen   = 0,
                 .mode     = 0444,
-                .proc_handler = &proc_pages_max
+                .proc_handler = &proc_pages_max,
         },
         {
                 .ctl_name = OBD_LDLM_TIMEOUT,
@@ -373,12 +445,52 @@ static cfs_sysctl_table_t obd_table[] = {
                 .mode     = 0644,
                 .proc_handler = &proc_max_dirty_pages_in_mb
         },
+        {
+                .ctl_name = OBD_AT_MIN,
+                .procname = "at_min",
+                .data     = &at_min,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_at_min
+        },
+        {
+                .ctl_name = OBD_AT_MAX,
+                .procname = "at_max",
+                .data     = &at_max,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_at_max
+        },
+        {
+                .ctl_name = OBD_AT_EXTRA,
+                .procname = "at_extra",
+                .data     = &at_extra,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_at_extra
+        },
+        {
+                .ctl_name = OBD_AT_EARLY_MARGIN,
+                .procname = "at_early_margin",
+                .data     = &at_early_margin,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_at_early_margin
+        },
+        {
+                .ctl_name = OBD_AT_HISTORY,
+                .procname = "at_history",
+                .data     = &at_history,
+                .maxlen   = sizeof(int),
+                .mode     = 0644,
+                .proc_handler = &proc_at_history
+        },
         { 0 }
 };
 
 static cfs_sysctl_table_t parent_table[] = {
        {
-               .ctl_name = OBD_SYSCTL,
+               .ctl_name = CTL_LUSTRE,
                .procname = "lustre",
                .data     = NULL,
                .maxlen   = 0,
diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c
index b03b3f6..469fd15 100644
--- a/lustre/obdclass/llog_obd.c
+++ b/lustre/obdclass/llog_obd.c
@@ -60,6 +60,7 @@ static struct llog_ctxt* llog_new_ctxt(struct obd_device *obd)
 
         ctxt->loc_obd = obd;
         atomic_set(&ctxt->loc_refcount, 1);
+        ctxt->loc_flags = LLOG_CTXT_FLAG_UNINITIALIZED;
 
         return ctxt;
 }
@@ -109,7 +110,7 @@ EXPORT_SYMBOL(__llog_ctxt_put);
 int llog_cleanup(struct llog_ctxt *ctxt)
 {
         struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
-        struct obd_device *obd = ctxt->loc_obd;
+        struct obd_device *obd;
         int rc, idx;
         ENTRY;
 
@@ -117,6 +118,7 @@ int llog_cleanup(struct llog_ctxt *ctxt)
                 CERROR("No ctxt\n");
                 RETURN(-ENODEV);
         }
+        obd = ctxt->loc_obd;
 
         /*banlance the ctxt get when calling llog_cleanup */
         llog_ctxt_put(ctxt);
@@ -193,6 +195,10 @@ int llog_setup(struct obd_device *obd, int index, struct obd_device *disk_obd,
                 CERROR("obd %s ctxt %d lop_setup=%p failed %d\n",
                        obd->obd_name, index, op->lop_setup, rc);
                 llog_ctxt_put(ctxt);
+        } else {
+                CDEBUG(D_CONFIG, "obd %s ctxt %d is initialized\n",
+                       obd->obd_name, index);
+                ctxt->loc_flags &= ~LLOG_CTXT_FLAG_UNINITIALIZED;
         }
 out:
         mutex_up(&obd->obd_llog_alloc);
diff --git a/lustre/obdclass/llog_swab.c b/lustre/obdclass/llog_swab.c
index 7bf539c..70a53d2 100644
--- a/lustre/obdclass/llog_swab.c
+++ b/lustre/obdclass/llog_swab.c
@@ -99,6 +99,14 @@ void lustre_swab_ll_fid(struct ll_fid *fid)
 }
 EXPORT_SYMBOL(lustre_swab_ll_fid);
 
+void lustre_swab_lu_fid(struct lu_fid *fid)
+{
+        __swab64s(&fid->f_seq);
+        __swab32s(&fid->f_oid);
+        __swab32s(&fid->f_ver);
+}
+EXPORT_SYMBOL(lustre_swab_lu_fid);
+
 void lustre_swab_llog_rec(struct llog_rec_hdr *rec, struct llog_rec_tail *tail)
 {
         __swab32s(&rec->lrh_len);
@@ -123,8 +131,8 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec, struct llog_rec_tail *tail)
                 struct llog_unlink_rec *lur = (struct llog_unlink_rec *)rec;
 
                 __swab64s(&lur->lur_oid);
-                __swab32s(&lur->lur_ogen);
-
+                __swab32s(&lur->lur_ogr);
+                __swab32s(&lur->lur_count);
                 break;
         }
 
@@ -132,7 +140,18 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec, struct llog_rec_tail *tail)
                 struct llog_setattr_rec *lsr = (struct llog_setattr_rec *)rec;
 
                 __swab64s(&lsr->lsr_oid);
-                __swab32s(&lsr->lsr_ogen);
+                __swab32s(&lsr->lsr_ogr);
+                __swab32s(&lsr->lsr_uid);
+                __swab32s(&lsr->lsr_gid);
+
+                break;
+        }
+
+        case MDS_SETATTR64_REC: {
+                struct llog_setattr64_rec *lsr = (struct llog_setattr64_rec *)rec;
+
+                __swab64s(&lsr->lsr_oid);
+                __swab32s(&lsr->lsr_ogr);
                 __swab32s(&lsr->lsr_uid);
                 __swab32s(&lsr->lsr_gid);
 
diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c
index c417d18..5dbccc8 100644
--- a/lustre/obdclass/llog_test.c
+++ b/lustre/obdclass/llog_test.c
@@ -254,19 +254,19 @@ static int llog_test_3(struct obd_device *obd, struct llog_handle *llh)
                         hdr.lrh_len = 32;
                         hdr.lrh_type = OBD_CFG_REC;
                         rc = llog_write_rec(llh, &hdr, NULL, 0, buf_odd, -1);
-		}
+                }
                 if (rc) {
                         if (rc == -ENOSPC) {
                                 break;
                         } else {
-                                CERROR("3d: write recs failed at #%d: %d\n",
+                       	        CERROR("3c: write recs failed at #%d: %d\n",
                                	        i + 1, rc);
-                                RETURN(rc);
+                       	        RETURN(rc);
                         }
                 }
                 num_recs++;
         }
-        if (rc != -ENOSPC) {
+	if (rc != -ENOSPC) {
                 CWARN("3d: write record more than BITMAP size!\n");
                 RETURN(-EINVAL);
         }
@@ -502,9 +502,6 @@ static int llog_test_6(struct obd_device *obd, char *name)
         struct obd_device *mdc_obd;
         struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
         struct obd_uuid *mds_uuid = &ctxt->loc_exp->exp_obd->obd_uuid;
-        struct lustre_handle exph = {0, };
-        struct obd_export *exp;
-        struct obd_uuid uuid = {"LLOG_TEST6_UUID"};
         struct llog_handle *llh = NULL;
         struct llog_ctxt *nctxt;
         int rc;
@@ -517,14 +514,6 @@ static int llog_test_6(struct obd_device *obd, char *name)
                 GOTO(ctxt_release, rc = -ENOENT);
         }
 
-        rc = obd_connect(&exph, mdc_obd, &uuid, NULL /* obd_connect_data */,
-                         NULL);
-        if (rc) {
-                CERROR("6: failed to connect to MDC: %s\n", mdc_obd->obd_name);
-                GOTO(ctxt_release, rc);
-        }
-        exp = class_conn2export(&exph);
-
         nctxt = llog_get_context(mdc_obd, LLOG_CONFIG_REPL_CTXT);
         rc = llog_create(nctxt, &llh, NULL, name);
         if (rc) {
@@ -553,7 +542,7 @@ parse_out:
         if (rc) {
                 CERROR("6: llog_close failed: rc = %d\n", rc);
         }
-        rc = obd_disconnect(exp);
+
 ctxt_release:
         llog_ctxt_put(ctxt);
         RETURN(rc);
diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c
index 007eaa3..6dea637 100644
--- a/lustre/obdclass/lprocfs_status.c
+++ b/lustre/obdclass/lprocfs_status.c
@@ -74,17 +74,17 @@ struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
         if (head == NULL)
                 return NULL;
 
-        LPROCFS_ENTRY();
+        LPROCFS_SRCH_ENTRY();
         temp = head->subdir;
         while (temp != NULL) {
                 if (strcmp(temp->name, name) == 0) {
-                        LPROCFS_EXIT();
+                        LPROCFS_SRCH_EXIT();
                         return temp;
                 }
 
                 temp = temp->next;
         }
-        LPROCFS_EXIT();
+        LPROCFS_SRCH_EXIT();
         return NULL;
 }
 
@@ -111,28 +111,35 @@ static int lprocfs_obd_snprintf(char **page, int end, int *len,
         return n;
 }
 
-int lprocfs_add_simple(struct proc_dir_entry *root, char *name,
-                       read_proc_t *read_proc, write_proc_t *write_proc,
-                       void *data)
+cfs_proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root,
+                                        char *name,
+                                        read_proc_t *read_proc,
+                                        write_proc_t *write_proc,
+                                        void *data,
+                                        struct file_operations *fops)
 {
-        struct proc_dir_entry *proc;
+        cfs_proc_dir_entry_t *proc;
         mode_t mode = 0;
 
         if (root == NULL || name == NULL)
-                return -EINVAL;
+                return ERR_PTR(-EINVAL);
         if (read_proc)
                 mode = 0444;
         if (write_proc)
                 mode |= 0200;
+        if (fops)
+                mode = 0644;
         proc = create_proc_entry(name, mode, root);
         if (!proc) {
                 CERROR("LprocFS: No memory to create /proc entry %s", name);
-                return -ENOMEM;
+                return ERR_PTR(-ENOMEM);
         }
         proc->read_proc = read_proc;
         proc->write_proc = write_proc;
         proc->data = data;
-        return 0;
+        if (fops)
+                proc->proc_fops = fops;
+        return proc;
 }
 
 static ssize_t lprocfs_fops_read(struct file *f, char __user *buf, size_t size,
@@ -151,7 +158,7 @@ static ssize_t lprocfs_fops_read(struct file *f, char __user *buf, size_t size,
 
         LPROCFS_ENTRY();
         OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
-        if (!dp->deleted && dp->read_proc)
+        if (!LPROCFS_CHECK_DELETED(dp) && dp->read_proc)
                 rc = dp->read_proc(page, &start, *ppos, PAGE_SIZE,
                         &eof, dp->data);
         LPROCFS_EXIT();
@@ -191,7 +198,7 @@ static ssize_t lprocfs_fops_write(struct file *f, const char __user *buf,
         int rc = -EIO;
 
         LPROCFS_ENTRY();
-        if (!dp->deleted && dp->write_proc)
+        if (!LPROCFS_CHECK_DELETED(dp) && dp->write_proc)
                 rc = dp->write_proc(f, buf, size, dp->data);
         LPROCFS_EXIT();
         return rc;
@@ -344,9 +351,23 @@ void lprocfs_remove(struct proc_dir_entry **rooth)
                          "0x%p  %s/%s len %d\n", rm_entry, temp->name,
                          rm_entry->name, (int)strlen(rm_entry->name));
 
+#ifdef HAVE_PROCFS_USERS
+                /* if procfs uses user count to synchronize deletion of
+                 * proc entry, there is no protection for rm_entry->data,
+                 * then lprocfs_fops_read and lprocfs_fops_write maybe
+                 * call proc_dir_entry->read_proc (or write_proc) with
+                 * proc_dir_entry->data == NULL, then cause kernel Oops.
+                 * see bug19706 for detailed information */
+
+                /* procfs won't free rm_entry->data if it isn't a LINK,
+                 * and Lustre won't use rm_entry->data if it is a LINK */
+                if (S_ISLNK(rm_entry->mode))
+                        rm_entry->data = NULL;
+#else
                 /* Now, the rm_entry->deleted flags is protected
                  * by _lprocfs_lock. */
                 rm_entry->data = NULL;
+#endif
                 remove_proc_entry(rm_entry->name, temp);
                 if (temp == parent)
                         break;
@@ -610,15 +631,61 @@ int lprocfs_rd_conn_uuid(char *page, char **start, off_t off, int count,
         return rc;
 }
 
-#define flag2str(flag) \
-        if (imp->imp_##flag && max - len > 0) \
-                len += snprintf(str + len, max - len, " " #flag);
+/** add up per-cpu counters */
+void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
+                           struct lprocfs_counter *cnt)
+{
+        unsigned int num_cpu;
+        struct lprocfs_counter t;
+        struct lprocfs_counter *percpu_cntr;
+        int centry, i;
+
+        memset(cnt, 0, sizeof(*cnt));
+
+        if (stats == NULL) {
+                /* set count to 1 to avoid divide-by-zero errs in callers */
+                cnt->lc_count = 1;
+                return;
+        }
+
+        cnt->lc_min = LC_MIN_INIT;
+
+        if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU)
+                num_cpu = 1;
+        else
+                num_cpu = num_possible_cpus();
+
+        for (i = 0; i < num_cpu; i++) {
+                percpu_cntr = &(stats->ls_percpu[i])->lp_cntr[idx];
+
+                do {
+                        centry = atomic_read(&percpu_cntr->lc_cntl.la_entry);
+                        t.lc_count = percpu_cntr->lc_count;
+                        t.lc_sum = percpu_cntr->lc_sum;
+                        t.lc_min = percpu_cntr->lc_min;
+                        t.lc_max = percpu_cntr->lc_max;
+                        t.lc_sumsquare = percpu_cntr->lc_sumsquare;
+                } while (centry != atomic_read(&percpu_cntr->lc_cntl.la_entry) &&
+                         centry != atomic_read(&percpu_cntr->lc_cntl.la_exit));
+                cnt->lc_count += t.lc_count;
+                cnt->lc_sum += t.lc_sum;
+                if (t.lc_min < cnt->lc_min)
+                        cnt->lc_min = t.lc_min;
+                if (t.lc_max > cnt->lc_max)
+                        cnt->lc_max = t.lc_max;
+                cnt->lc_sumsquare += t.lc_sumsquare;
+        }
+
+        cnt->lc_units = stats->ls_percpu[0]->lp_cntr[idx].lc_units;
+}
 
 /**
  * Append a space separated list of current set flags to str.
  */
-static int obd_import_flags2str(struct obd_import *imp, char *str,
-                                          int max)
+#define flag2str(flag) \
+        if (imp->imp_##flag && max - len > 0) \
+             len += snprintf(str + len, max - len, "%s" #flag, len ? ", " : "");
+static int obd_import_flags2str(struct obd_import *imp, char *str, int max)
 {
         int len = 0;
 
@@ -635,48 +702,202 @@ static int obd_import_flags2str(struct obd_import *imp, char *str,
 }
 #undef flags2str
 
+static const char *obd_connect_names[] = {
+        "read_only",
+        "lov_index",
+        "unused",
+        "write_grant",
+        "server_lock",
+        "version",
+        "request_portal",
+        "acl",
+        "xattr",
+        "create_on_write",
+        "truncate_lock",
+        "initial_transno",
+        "inode_bit_locks",
+        "join_file",
+        "getattr_by_fid",
+        "no_oh_for_devices",
+        "local_client",
+        "remote_client",
+        "max_byte_per_rpc",
+        "64bit_qdata",
+        "mds_capability",
+        "oss_capability",
+        "early_lock_cancel",
+        "size_on_mds",
+        "adaptive_timeouts",
+        "lru_resize",
+        "mds_mds_connection",
+        "real_conn",
+        "change_qunit_size",
+        "alt_checksum_algorithm",
+        "fid_is_enabled",
+        "version_recovery",
+        "pools",
+        "grant_shrink",
+        "skip_orphan",
+        NULL
+};
+
+static int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep)
+{
+        __u64 mask = 1;
+        int i, ret = 0;
+
+        for (i = 0; obd_connect_names[i] != NULL; i++, mask <<= 1) {
+                if (flags & mask)
+                        ret += snprintf(page + ret, count - ret, "%s%s",
+                                        ret ? sep : "", obd_connect_names[i]);
+        }
+        if (flags & ~(mask - 1))
+                ret += snprintf(page + ret, count - ret,
+                                "%sunknown flags "LPX64,
+                                ret ? sep : "", flags & ~(mask - 1));
+        return ret;
+}
+
 int lprocfs_rd_import(char *page, char **start, off_t off, int count,
                       int *eof, void *data)
 {
+        struct lprocfs_counter ret;
         struct obd_device *obd = (struct obd_device *)data;
         struct obd_import *imp;
-        char *imp_state_name = NULL;
-        int rc = 0;
+        int i, j, k, rw = 0;
 
         LASSERT(obd != NULL);
         LPROCFS_CLIMP_CHECK(obd);
         imp = obd->u.cli.cl_import;
-        imp_state_name = ptlrpc_import_state_name(imp->imp_state);
         *eof = 1;
 
-        rc = snprintf(page, count,
-                      "import: %s\n"
-                      "    target: %s@%s\n"
-                      "    state: %s\n"
-                      "    inflight: %u\n"
-                      "    unregistering: %u\n"
-                      "    conn_cnt: %u\n"
-                      "    generation: %u\n"
-                      "    inval_cnt: %u\n"
-                      "    last_replay_transno: "LPU64"\n"
-                      "    peer_committed_transno: "LPU64"\n"
-                      "    last_trasno_checked: "LPU64"\n"
-                      "    flags:",
-                      obd->obd_name,
-                      obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid,
-                      imp_state_name,
-                      atomic_read(&imp->imp_inflight),
-                      atomic_read(&imp->imp_unregistering),
+        i = snprintf(page, count,
+                     "import:\n"
+                     "    name: %s\n"
+                     "    target: %s\n"
+                     "    current_connection: %s\n"
+                     "    state: %s\n"
+                     "    connect_flags: [",
+                     obd->obd_name,
+                     obd2cli_tgt(obd),
+                     imp->imp_connection->c_remote_uuid.uuid,
+                     ptlrpc_import_state_name(imp->imp_state));
+        i += obd_connect_flags2str(page + i, count - i,
+                                   imp->imp_connect_data.ocd_connect_flags,
+                                   ", ");
+        i += snprintf(page + i, count - i,
+                      "]\n"
+                      "    import_flags: [");
+        i += obd_import_flags2str(imp, page + i, count - i);
+
+        i += snprintf(page + i, count - i,
+                      "]\n"
+                      "    connection:\n"
+                      "       connection_attempts: %u\n"
+                      "       generation: %u\n"
+                      "       in-progress_invalidations: %u\n",
                       imp->imp_conn_cnt,
                       imp->imp_generation,
-                      atomic_read(&imp->imp_inval_count),
+                      atomic_read(&imp->imp_inval_count));
+
+        lprocfs_stats_collect(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR, &ret);
+        do_div(ret.lc_sum, ret.lc_count);
+        i += snprintf(page + i, count - i,
+                      "    rpcs:\n"
+                      "       inflight: %u\n"
+                      "       unregistering: %u\n"
+                      "       timeouts: %u\n"
+                      "       avg_waittime: "LPU64" %s\n",
+                      atomic_read(&imp->imp_inflight),
+                      atomic_read(&imp->imp_unregistering),
+                      atomic_read(&imp->imp_timeouts),
+                      ret.lc_sum, ret.lc_units);
+
+        k = 0;
+        for(j = 0; j < IMP_AT_MAX_PORTALS; j++) {
+                if (imp->imp_at.iat_portal[j] == 0)
+                        break;
+                k = max_t(unsigned int, k,
+                          at_get(&imp->imp_at.iat_service_estimate[j]));
+        }
+        i += snprintf(page + i, count - i,
+                      "    service_estimates:\n"
+                      "       services: %u sec\n"
+                      "       network: %u sec\n",
+                      k,
+                      at_get(&imp->imp_at.iat_net_latency));
+
+        i += snprintf(page + i, count - i,
+                      "    transactions:\n"
+                      "       last_replay: "LPU64"\n"
+                      "       peer_committed: "LPU64"\n"
+                      "       last_checked: "LPU64"\n",
                       imp->imp_last_replay_transno,
                       imp->imp_peer_committed_transno,
                       imp->imp_last_transno_checked);
-        rc += obd_import_flags2str(imp, page + rc, count - rc);
-        rc += snprintf(page+rc, count - rc, "\n");
+
+        /* avg data rates */
+        for (rw = 0; rw <= 1; rw++) {
+                lprocfs_stats_collect(obd->obd_svc_stats,
+                                      PTLRPC_LAST_CNTR + BRW_READ_BYTES + rw,
+                                      &ret);
+                if (ret.lc_sum > 0) {
+                        do_div(ret.lc_sum, ret.lc_count);
+                        i += snprintf(page + i, count - i,
+                                      "    %s_data_averages:\n"
+                                      "       bytes_per_rpc: "LPU64"\n",
+                                      rw ? "write" : "read",
+                                      ret.lc_sum);
+                }
+                k = (int)ret.lc_sum;
+                j = opcode_offset(OST_READ + rw) + EXTRA_MAX_OPCODES;
+                lprocfs_stats_collect(obd->obd_svc_stats, j, &ret);
+                if (ret.lc_sum > 0) {
+                        do_div(ret.lc_sum, ret.lc_count);
+                        i += snprintf(page + i, count - i,
+                                      "       %s_per_rpc: "LPU64"\n",
+                                      ret.lc_units, ret.lc_sum);
+                        j = (int)ret.lc_sum;
+                        if (j > 0)
+                                i += snprintf(page + i, count - i,
+                                              "       MB_per_sec: %u.%.02u\n",
+                                              k / j, (100 * k / j) % 100);
+                }
+        }
+
         LPROCFS_CLIMP_EXIT(obd);
-        return rc;
+        return i;
+}
+
+int lprocfs_rd_state(char *page, char **start, off_t off, int count,
+                      int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        struct obd_import *imp;
+        int i, j, k;
+
+        LASSERT(obd != NULL);
+        LPROCFS_CLIMP_CHECK(obd);
+        imp = obd->u.cli.cl_import;
+        *eof = 1;
+
+        i = snprintf(page, count, "current_state: %s\n",
+                     ptlrpc_import_state_name(imp->imp_state));
+        i += snprintf(page + i, count - i,
+                      "state_history:\n");
+        k = imp->imp_state_hist_idx;
+        for (j = 0; j < IMP_STATE_HIST_LEN; j++) {
+                struct import_state_hist *ish =
+                        &imp->imp_state_hist[(k + j) % IMP_STATE_HIST_LEN];
+                if (ish->ish_state == 0)
+                        continue;
+                i += snprintf(page + i, count - i, " - ["CFS_TIME_T", %s]\n",
+                              ish->ish_time,
+                              ptlrpc_import_state_name(ish->ish_state));
+        }
+
+        LPROCFS_CLIMP_EXIT(obd);
+        return i;
 }
 
 int lprocfs_at_hist_helper(char *page, int count, int rc,
@@ -742,62 +963,18 @@ int lprocfs_rd_timeouts(char *page, char **start, off_t off, int count,
         return rc;
 }
 
-static const char *obd_connect_names[] = {
-        "read_only",
-        "lov_index",
-        "unused",
-        "write_grant",
-        "server_lock",
-        "version",
-        "request_portal",
-        "acl",
-        "xattr",
-        "create_on_write",
-        "truncate_lock",
-        "initial_transno",
-        "inode_bit_locks",
-        "join_file",
-        "getattr_by_fid",
-        "no_oh_for_devices",
-        "local_1.8_client",
-        "remote_1.8_client",
-        "max_byte_per_rpc",
-        "64bit_qdata",
-        "fid_capability",
-        "oss_capability",
-        "early_lock_cancel",
-        "size_on_mds",
-        "adaptive_timeout",
-        "lru_resize",
-        "mds_mds_connection",
-        "real_conn",
-        "change_qunit_size",
-        "alt_checksum_algorithm",
-        "fid_is_enabled",
-        "version_recovery",
-        "pools",
-        NULL
-};
-
 int lprocfs_rd_connect_flags(char *page, char **start, off_t off,
                              int count, int *eof, void *data)
 {
         struct obd_device *obd = data;
-        __u64 mask = 1, flags;
-        int i, ret = 0;
+        __u64 flags;
+        int ret = 0;
 
         LPROCFS_CLIMP_CHECK(obd);
         flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags;
         ret = snprintf(page, count, "flags="LPX64"\n", flags);
-        for (i = 0; obd_connect_names[i] != NULL; i++, mask <<= 1) {
-                if (flags & mask)
-                        ret += snprintf(page + ret, count - ret, "%s\n",
-                                        obd_connect_names[i]);
-        }
-        if (flags & ~(mask - 1))
-                ret += snprintf(page + ret, count - ret,
-                                "unknown flags "LPX64"\n", flags & ~(mask - 1));
-
+        ret += obd_connect_flags2str(page + ret, count - ret, flags, "\n");
+        ret += snprintf(page + ret, count - ret, "\n");
         LPROCFS_CLIMP_EXIT(obd);
         return ret;
 }
@@ -861,8 +1038,8 @@ static void lprocfs_free_client_stats(struct nid_stat *client_stat)
                client_stat->nid_proc, client_stat->nid_stats,
                client_stat->nid_brw_stats);
 
-        LASSERTF(client_stat->nid_exp_ref_count == 0, "count %d\n",
-                 client_stat->nid_exp_ref_count);
+        LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
+                 "count %d\n", atomic_read(&client_stat->nid_exp_ref_count));
 
         hlist_del_init(&client_stat->nid_hash);
 
@@ -1035,9 +1212,8 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
 {
        struct lprocfs_stats *stats = p->private;
        struct lprocfs_counter  *cntr = v;
-       struct lprocfs_counter  t, ret = { .lc_min = LC_MIN_INIT };
-       int i, idx, rc = 0;
-       unsigned int num_cpu;
+       struct lprocfs_counter ret;
+       int idx, rc = 0;
 
        if (cntr == &(stats->ls_percpu[0])->lp_cntr[0]) {
                struct timeval now;
@@ -1049,39 +1225,14 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
        }
        idx = cntr - &(stats->ls_percpu[0])->lp_cntr[0];
 
-       if (stats->ls_flags & LPROCFS_STATS_FLAG_NOPERCPU)
-               num_cpu = 1;
-       else
-               num_cpu = num_possible_cpus();
-
-       for (i = 0; i < num_cpu; i++) {
-               struct lprocfs_counter *percpu_cntr =
-                       &(stats->ls_percpu[i])->lp_cntr[idx];
-               int centry;
-
-               do {
-                       centry = atomic_read(&percpu_cntr->lc_cntl.la_entry);
-                       t.lc_count = percpu_cntr->lc_count;
-                       t.lc_sum = percpu_cntr->lc_sum;
-                       t.lc_min = percpu_cntr->lc_min;
-                       t.lc_max = percpu_cntr->lc_max;
-                       t.lc_sumsquare = percpu_cntr->lc_sumsquare;
-               } while (centry != atomic_read(&percpu_cntr->lc_cntl.la_entry) &&
-                        centry != atomic_read(&percpu_cntr->lc_cntl.la_exit));
-               ret.lc_count += t.lc_count;
-               ret.lc_sum += t.lc_sum;
-               if (t.lc_min < ret.lc_min)
-                       ret.lc_min = t.lc_min;
-               if (t.lc_max > ret.lc_max)
-                       ret.lc_max = t.lc_max;
-               ret.lc_sumsquare += t.lc_sumsquare;
-       }
+       lprocfs_stats_collect(stats, idx, &ret);
 
        if (ret.lc_count == 0)
                goto out;
 
        rc = seq_printf(p, "%-25s "LPD64" samples [%s]", cntr->lc_name,
                        ret.lc_count, cntr->lc_units);
+
        if (rc < 0)
                goto out;
 
@@ -1198,6 +1349,8 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, connect);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, reconnect);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, disconnect);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_init);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, fid_fini);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, statfs_async);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, packmd);
@@ -1222,6 +1375,7 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, set_async_flags);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, teardown_async_page);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, merge_lvb);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, update_lvb);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, adjust_kms);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, punch);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, sync);
@@ -1254,6 +1408,12 @@ void lprocfs_init_ops_stats(int num_private_stats, struct lprocfs_stats *stats)
         LPROCFS_OBD_OP_INIT(num_private_stats,stats,unregister_page_removal_cb);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats, register_lock_cancel_cb);
         LPROCFS_OBD_OP_INIT(num_private_stats, stats,unregister_lock_cancel_cb);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_new);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_rem);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_add);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, pool_del);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, getref);
+        LPROCFS_OBD_OP_INIT(num_private_stats, stats, putref);
 }
 
 void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
@@ -1423,17 +1583,16 @@ void lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
 {
         struct nid_stat *stat = obj;
         int i;
-
+        ENTRY;
         /* object has only hash + iterate_all references.
          * add/delete blocked by hash bucket lock */
-        CDEBUG(D_INFO,"refcnt %d\n", stat->nid_exp_ref_count);
-        if (stat->nid_exp_ref_count == 2) {
+        CDEBUG(D_INFO,"refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
+        if (atomic_read(&stat->nid_exp_ref_count) == 2) {
                 hlist_del_init(&stat->nid_hash);
-                stat->nid_exp_ref_count--;
+                nidstat_putref(stat);
                 spin_lock(&stat->nid_obd->obd_nid_lock);
-                list_del_init(&stat->nid_list);
+                list_move(&stat->nid_list, data);
                 spin_unlock(&stat->nid_obd->obd_nid_lock);
-                list_add(&stat->nid_list, data);
                 EXIT;
                 return;
         }
@@ -1472,10 +1631,10 @@ EXPORT_SYMBOL(lprocfs_nid_stats_clear_write);
 
 int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
 {
+        int rc = 0;
         struct nid_stat *new_stat, *old_stat;
-        struct nid_stat_uuid *new_ns_uuid;
         struct obd_device *obd;
-        int rc = 0;
+        cfs_proc_dir_entry_t *entry;
         ENTRY;
 
         *newnid = 0;
@@ -1498,84 +1657,62 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
         if (new_stat == NULL)
                 RETURN(-ENOMEM);
 
-        OBD_ALLOC_PTR(new_ns_uuid);
-        if (new_ns_uuid == NULL) {
-                OBD_FREE_PTR(new_stat);
-                RETURN(-ENOMEM);
-        }
-        CFS_INIT_LIST_HEAD(&new_ns_uuid->ns_uuid_list);
-        strncpy(new_ns_uuid->ns_uuid.uuid, exp->exp_client_uuid.uuid,
-                sizeof(struct obd_uuid));
-
-        CFS_INIT_LIST_HEAD(&new_stat->nid_uuid_list);
         new_stat->nid = *nid;
         new_stat->nid_obd = exp->exp_obd;
-        /* need live in hash after destroy export */
-        new_stat->nid_exp_ref_count = 1;
+        atomic_set(&new_stat->nid_exp_ref_count, 0);
 
         old_stat = lustre_hash_findadd_unique(obd->obd_nid_stats_hash,
                                               nid, &new_stat->nid_hash);
         CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
-               old_stat, libcfs_nid2str(*nid), new_stat->nid_exp_ref_count);
+               old_stat, libcfs_nid2str(*nid),
+               atomic_read(&new_stat->nid_exp_ref_count));
 
         /* Return -EALREADY here so that we know that the /proc
          * entry already has been created */
         if (old_stat != new_stat) {
-                struct nid_stat_uuid *tmp_uuid;
-                int found = 0;
-
-                exp->exp_nid_stats = old_stat;
-
-                /* We need to decrement the refcount if the uuid was
-                 * already in our list */
                 spin_lock(&obd->obd_nid_lock);
-                list_for_each_entry(tmp_uuid, &old_stat->nid_uuid_list,
-                                    ns_uuid_list) {
-                        if (tmp_uuid && obd_uuid_equals(&tmp_uuid->ns_uuid,
-                                                        &exp->exp_client_uuid)){
-                                found = 1;
-                                --old_stat->nid_exp_ref_count;
-                                break;
-                        }
+                if (exp->exp_nid_stats != old_stat) {
+                        if (exp->exp_nid_stats)
+                                nidstat_putref(exp->exp_nid_stats);
+                        exp->exp_nid_stats = old_stat;
+                } else {
+                        /* lustre_hash_findadd_unique() has added
+                         * old_stat's refcount */
+                        nidstat_putref(old_stat);
                 }
 
-                if (!found)
-                        list_add(&new_ns_uuid->ns_uuid_list,
-                                 &old_stat->nid_uuid_list);
-                else
-                        OBD_FREE_PTR(new_ns_uuid);
                 spin_unlock(&obd->obd_nid_lock);
 
                 GOTO(destroy_new, rc = -EALREADY);
         }
         /* not found - create */
         new_stat->nid_proc = proc_mkdir(libcfs_nid2str(*nid),
-                                        obd->obd_proc_exports_entry);
+                                   obd->obd_proc_exports_entry);
         if (!new_stat->nid_proc) {
                 CERROR("Error making export directory for"
                        " nid %s\n", libcfs_nid2str(*nid));
                 GOTO(destroy_new_ns, rc = -ENOMEM);
         }
 
-        /* Add in uuid to our nid_stats list */
-        spin_lock(&obd->obd_nid_lock);
-        list_add(&new_ns_uuid->ns_uuid_list, &new_stat->nid_uuid_list);
-        spin_unlock(&obd->obd_nid_lock);
-
-        rc = lprocfs_add_simple(new_stat->nid_proc, "uuid",
-                                lprocfs_exp_rd_uuid, NULL, new_stat);
-        if (rc) {
+        entry = lprocfs_add_simple(new_stat->nid_proc, "uuid",
+                                   lprocfs_exp_rd_uuid, NULL, new_stat, NULL);
+        if (IS_ERR(entry)) {
                 CWARN("Error adding the uuid file\n");
+                rc = PTR_ERR(entry);
                 GOTO(destroy_new_ns, rc);
         }
 
-        rc = lprocfs_add_simple(new_stat->nid_proc, "hash",
-                                lprocfs_exp_rd_hash, NULL, new_stat);
-        if (rc) {
+        entry = lprocfs_add_simple(new_stat->nid_proc, "hash",
+                                lprocfs_exp_rd_hash, NULL, new_stat, NULL);
+        if (IS_ERR(entry)) {
                 CWARN("Error adding the hash file\n");
+                rc = PTR_ERR(entry);
                 GOTO(destroy_new_ns, rc);
         }
 
+        if (exp->exp_nid_stats)
+                nidstat_putref(exp->exp_nid_stats);
+        nidstat_getref(new_stat);
         exp->exp_nid_stats = new_stat;
         *newnid = 1;
         /* protect competitive add to list, not need locking on destroy */
@@ -1589,7 +1726,6 @@ destroy_new_ns:
         if (new_stat->nid_proc != NULL)
                 lprocfs_remove(&new_stat->nid_proc);
         lustre_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
-        OBD_FREE_PTR(new_ns_uuid);
 
 destroy_new:
         OBD_FREE_PTR(new_stat);
@@ -1599,32 +1735,11 @@ destroy_new:
 int lprocfs_exp_cleanup(struct obd_export *exp)
 {
         struct nid_stat *stat = exp->exp_nid_stats;
-        struct nid_stat_uuid *cursor, *tmp;
-        int found = 0;
 
         if(!stat || !exp->exp_obd)
                 RETURN(0);
 
-        spin_lock(&exp->exp_obd->obd_nid_lock);
-        list_for_each_entry_safe(cursor, tmp,
-                                 &stat->nid_uuid_list,
-                                 ns_uuid_list) {
-                if (cursor && obd_uuid_equals(&cursor->ns_uuid,
-                                              &exp->exp_client_uuid)) {
-                        found = 1;
-                        list_del(&cursor->ns_uuid_list);
-                        OBD_FREE_PTR(cursor);
-                        --stat->nid_exp_ref_count;
-                        CDEBUG(D_INFO, "Put stat %p - %d\n", stat,
-                               stat->nid_exp_ref_count);
-                        break;
-                }
-        }
-        spin_unlock(&exp->exp_obd->obd_nid_lock);
-        if (!found)
-                CERROR("obd_export's client uuid %s are not found in its "
-                       "nid_stats list\n", exp->exp_client_uuid.uuid);
-
+        nidstat_putref(exp->exp_nid_stats);
         exp->exp_nid_stats = NULL;
         lprocfs_free_stats(&exp->exp_ops_stats);
 
@@ -1716,8 +1831,7 @@ int lprocfs_read_frac_helper(char *buffer, unsigned long count, long val,
                         temp_mult *= 10;
 
                 frac_bits = min((int)count - prtn, 3 - frac_bits);
-                prtn += snprintf(buffer + prtn, frac_bits, "%ld",
-                                 frac_val * temp_mult / mult);
+                prtn += snprintf(buffer + prtn, frac_bits, "%ld", frac_val * temp_mult / mult);
 
                 prtn--;
                 while(buffer[prtn] < '1' || buffer[prtn] > '9') {
@@ -1913,11 +2027,18 @@ int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
                                          obd->obd_recovery_end -
                                          obd->obd_recovery_start) <= 0)
                         goto out;
+                if (lprocfs_obd_snprintf(&page, size, &len,
+                                         "delayed_clients: %d/%d\n",
+                                         obd->obd_delayed_clients,
+                                         obd->obd_max_recoverable_clients) <= 0)
+                        goto out;
                 /* Number of clients that have completed recovery */
                 if (lprocfs_obd_snprintf(&page, size, &len,
                                          "completed_clients: %d/%d\n",
                                          obd->obd_max_recoverable_clients -
-                                         obd->obd_recoverable_clients,
+                                         obd->obd_recoverable_clients -
+                                         obd->obd_delayed_clients -
+                                         obd->obd_stale_clients,
                                          obd->obd_max_recoverable_clients) <= 0)
                         goto out;
                 if (lprocfs_obd_snprintf(&page, size, &len,
@@ -1944,10 +2065,15 @@ int lprocfs_obd_rd_recovery_status(char *page, char **start, off_t off,
                                  obd->obd_connected_clients,
                                  obd->obd_max_recoverable_clients) <= 0)
                 goto out;
+        if (lprocfs_obd_snprintf(&page, size, &len,"delayed_clients: %d/%d\n",
+                                 obd->obd_delayed_clients,
+                                 obd->obd_max_recoverable_clients) <= 0)
+                goto out;
         /* Number of clients that have completed recovery */
         if (lprocfs_obd_snprintf(&page, size, &len,"completed_clients: %d/%d\n",
                                  obd->obd_max_recoverable_clients -
-                                 obd->obd_recoverable_clients,
+                                 obd->obd_recoverable_clients -
+                                 obd->obd_delayed_clients,
                                  obd->obd_max_recoverable_clients) <= 0)
                 goto out;
         if (lprocfs_obd_snprintf(&page, size, &len,"replayed_requests: %d/??\n",
@@ -2014,6 +2140,79 @@ int lprocfs_obd_wr_recovery_maxtime(struct file *file, const char *buffer,
 EXPORT_SYMBOL(lprocfs_obd_wr_recovery_maxtime);
 #endif /* CRAY_XT3 */
 
+#ifdef HAVE_DELAYED_RECOVERY
+int lprocfs_obd_rd_stale_export_age(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%u\n",
+                        obd->u.obt.obt_stale_export_age);
+}
+EXPORT_SYMBOL(lprocfs_obd_rd_stale_export_age);
+
+int lprocfs_obd_wr_stale_export_age(struct file *file, const char *buffer,
+                                    unsigned long count, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        int val, rc;
+        LASSERT(obd != NULL);
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        target_trans_table_recalc(obd, val);
+        obd->u.obt.obt_stale_export_age = val;
+        return count;
+}
+EXPORT_SYMBOL(lprocfs_obd_wr_stale_export_age);
+
+static int obd_stale_exports_seq_show(struct seq_file *seq, void *v)
+{
+        struct obd_device *obd = seq->private;
+        struct obd_export *exp;
+
+        spin_lock(&obd->obd_dev_lock);
+        list_for_each_entry(exp, &obd->obd_delayed_exports,
+                            exp_obd_chain) {
+                seq_printf(seq, "%s: %ld seconds ago%s\n",
+                           obd_uuid2str(&exp->exp_client_uuid),
+                           cfs_time_current_sec() - exp->exp_last_request_time,
+                           exp_expired(exp, obd->u.obt.obt_stale_export_age) ?
+                                       " [EXPIRED]" : "");
+        }
+        spin_unlock(&obd->obd_dev_lock);
+        return 0;
+}
+
+LPROC_SEQ_FOPS_RO(obd_stale_exports);
+
+int lprocfs_obd_attach_stale_exports(struct obd_device *dev)
+{
+        return lprocfs_obd_seq_create(dev, "stale_exports", 0444,
+                                      &obd_stale_exports_fops, dev);
+}
+EXPORT_SYMBOL(lprocfs_obd_attach_stale_exports);
+
+int lprocfs_obd_wr_flush_stale_exports(struct file *file, const char *buffer,
+                                       unsigned long count, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        int val, rc;
+        LASSERT(obd != NULL);
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        class_disconnect_expired_exports(obd);
+        return count;
+}
+EXPORT_SYMBOL(lprocfs_obd_wr_flush_stale_exports);
+#endif
+
 EXPORT_SYMBOL(lprocfs_register);
 EXPORT_SYMBOL(lprocfs_srch);
 EXPORT_SYMBOL(lprocfs_remove);
@@ -2047,6 +2246,7 @@ EXPORT_SYMBOL(lprocfs_rd_num_exports);
 EXPORT_SYMBOL(lprocfs_rd_numrefs);
 EXPORT_SYMBOL(lprocfs_at_hist_helper);
 EXPORT_SYMBOL(lprocfs_rd_import);
+EXPORT_SYMBOL(lprocfs_rd_state);
 EXPORT_SYMBOL(lprocfs_rd_timeouts);
 EXPORT_SYMBOL(lprocfs_rd_blksize);
 EXPORT_SYMBOL(lprocfs_rd_kbytestotal);
@@ -2060,4 +2260,5 @@ EXPORT_SYMBOL(lprocfs_write_frac_helper);
 EXPORT_SYMBOL(lprocfs_read_frac_helper);
 EXPORT_SYMBOL(lprocfs_write_u64_helper);
 EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);
+EXPORT_SYMBOL(lprocfs_stats_collect);
 #endif /* LPROCFS*/
diff --git a/lustre/obdclass/lustre_handles.c b/lustre/obdclass/lustre_handles.c
index e830330..43b0125 100644
--- a/lustre/obdclass/lustre_handles.c
+++ b/lustre/obdclass/lustre_handles.c
@@ -232,11 +232,12 @@ static void cleanup_all_handles(void)
         int i;
 
         for (i = 0; i < HANDLE_HASH_SIZE; i++) {
-                struct list_head *tmp, *pos;
+                struct list_head *pos, *n;
+                n = NULL;
                 spin_lock(&handle_hash[i].lock);
-                list_for_each_safe_rcu(tmp, pos, &(handle_hash[i].head)) {
+                list_for_each_safe_rcu(pos, n, &(handle_hash[i].head)) {
                         struct portals_handle *h;
-                        h = list_entry(tmp, struct portals_handle, h_link);
+                        h = list_entry(pos, struct portals_handle, h_link);
 
                         CERROR("force clean handle "LPX64" addr %p addref %p\n",
                                h->h_cookie, h, h->h_addref);
diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c
index 7eaeb96..7860bd9 100644
--- a/lustre/obdclass/obd_config.c
+++ b/lustre/obdclass/obd_config.c
@@ -47,6 +47,7 @@
 #include <obd_class.h>
 #include <obd.h>
 #endif
+#include <lustre_disk.h>
 #include <lustre_log.h>
 #include <lprocfs_status.h>
 #include <libcfs/list.h>
@@ -64,15 +65,15 @@ int class_find_param(char *buf, char *key, char **valp)
 {
         char *ptr;
 
-        if (!buf) 
+        if (!buf)
                 return 1;
 
-        if ((ptr = strstr(buf, key)) == NULL) 
+        if ((ptr = strstr(buf, key)) == NULL)
                 return 1;
 
-        if (valp) 
+        if (valp)
                 *valp = ptr + strlen(key);
-        
+
         return 0;
 }
 
@@ -80,19 +81,19 @@ int class_find_param(char *buf, char *key, char **valp)
    valp points to first char after key. */
 int class_match_param(char *buf, char *key, char **valp)
 {
-        if (!buf) 
+        if (!buf)
                 return 1;
 
-        if (memcmp(buf, key, strlen(key)) != 0) 
+        if (memcmp(buf, key, strlen(key)) != 0)
                 return 1;
 
-        if (valp) 
+        if (valp)
                 *valp = buf + strlen(key);
-        
+
         return 0;
 }
 
-/* 0 is good nid, 
+/* 0 is good nid,
    1 not found
    < 0 error
    endh is set to next separator */
@@ -100,16 +101,16 @@ int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh)
 {
         char tmp, *endp;
 
-        if (!buf) 
+        if (!buf)
                 return 1;
-        while (*buf == ',' || *buf == ':') 
+        while (*buf == ',' || *buf == ':')
                 buf++;
-        if (*buf == ' ' || *buf == '/' || *buf == '\0') 
+        if (*buf == ' ' || *buf == '/' || *buf == '\0')
                 return 1;
 
         /* nid separators or end of nids */
         endp = strpbrk(buf, ",: /");
-        if (endp == NULL) 
+        if (endp == NULL)
                 endp = buf + strlen(buf);
 
         tmp = *endp;
@@ -122,7 +123,7 @@ int class_parse_nid(char *buf, lnet_nid_t *nid, char **endh)
         }
         *endp = tmp;
 
-        if (endh) 
+        if (endh)
                 *endh = endp;
         CDEBUG(D_INFO, "Nid %s\n", libcfs_nid2str(*nid));
         return 0;
@@ -196,17 +197,18 @@ int class_attach(struct lustre_cfg *lcfg)
         }
         LASSERTF(obd != NULL, "Cannot get obd device %s of type %s\n",
                  name, typename);
-        LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC, 
+        LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC,
                  "obd %p obd_magic %08X != %08X\n",
                  obd, obd->obd_magic, OBD_DEVICE_MAGIC);
-        LASSERTF(strncmp(obd->obd_name, name, strlen(name)) == 0, "%p obd_name %s != %s\n",
-                 obd, obd->obd_name, name);
+        LASSERTF(strncmp(obd->obd_name, name, strlen(name)) == 0,
+                 "%p obd_name %s != %s\n", obd, obd->obd_name, name);
 
         rwlock_init(&obd->obd_pool_lock);
         obd->obd_pool_limit = 0;
         obd->obd_pool_slv = 0;
 
         CFS_INIT_LIST_HEAD(&obd->obd_exports);
+        CFS_INIT_LIST_HEAD(&obd->obd_delayed_exports);
         CFS_INIT_LIST_HEAD(&obd->obd_exports_timed);
         CFS_INIT_LIST_HEAD(&obd->obd_nid_stats);
         spin_lock_init(&obd->obd_nid_lock);
@@ -229,9 +231,6 @@ int class_attach(struct lustre_cfg *lcfg)
         CFS_INIT_LIST_HEAD(&obd->obd_recovery_queue);
         CFS_INIT_LIST_HEAD(&obd->obd_delayed_reply_queue);
 
-        spin_lock_init(&obd->obd_uncommitted_replies_lock);
-        CFS_INIT_LIST_HEAD(&obd->obd_uncommitted_replies);
-
         len = strlen(uuid);
         if (len >= sizeof(obd->obd_uuid)) {
                 CERROR("uuid must be < %d bytes long\n",
@@ -270,9 +269,11 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         ENTRY;
 
         LASSERT(obd != NULL);
-        LASSERTF(obd == class_num2obd(obd->obd_minor), "obd %p != obd_devs[%d] %p\n", 
+        LASSERTF(obd == class_num2obd(obd->obd_minor),
+                 "obd %p != obd_devs[%d] %p\n",
                  obd, obd->obd_minor, class_num2obd(obd->obd_minor));
-        LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC, "obd %p obd_magic %08x != %08x\n", 
+        LASSERTF(obd->obd_magic == OBD_DEVICE_MAGIC,
+                 "obd %p obd_magic %08x != %08x\n",
                  obd, obd->obd_magic, OBD_DEVICE_MAGIC);
 
         /* have we attached a type to this device? */
@@ -304,19 +305,25 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         spin_unlock(&obd->obd_dev_lock);
 
         /* create an uuid-export lustre hash */
-        obd->obd_uuid_hash = lustre_hash_init("UUID_HASH", 7, 7,
+        obd->obd_uuid_hash = lustre_hash_init("UUID_HASH",
+                                              HASH_UUID_CUR_BITS,
+                                              HASH_UUID_MAX_BITS,
                                               &uuid_hash_ops, 0);
         if (!obd->obd_uuid_hash)
                 GOTO(err_hash, err = -ENOMEM);
 
         /* create a nid-export lustre hash */
-        obd->obd_nid_hash = lustre_hash_init("NID_HASH", 7, 7,
+        obd->obd_nid_hash = lustre_hash_init("NID_HASH",
+                                             HASH_NID_CUR_BITS,
+                                             HASH_NID_MAX_BITS,
                                              &nid_hash_ops, 0);
         if (!obd->obd_nid_hash)
                 GOTO(err_hash, err = -ENOMEM);
 
         /* create a nid-stats lustre hash */
-        obd->obd_nid_stats_hash = lustre_hash_init("NID_STATS", 7, 7,
+        obd->obd_nid_stats_hash = lustre_hash_init("NID_STATS",
+                                                   HASH_NID_STATS_CUR_BITS,
+                                                   HASH_NID_STATS_MAX_BITS,
                                                    &nid_stat_hash_ops, 0);
         if (!obd->obd_nid_stats_hash)
                 GOTO(err_hash, err = -ENOMEM);
@@ -395,19 +402,22 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg)
 
 static void dump_exports(struct obd_device *obd)
 {
-        struct obd_export *exp, *n;
+        struct obd_export *exp;
 
-        list_for_each_entry_safe(exp, n, &obd->obd_exports, exp_obd_chain) {
+        spin_lock(&obd->obd_dev_lock);
+        list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) {
                 struct ptlrpc_reply_state *rs;
                 struct ptlrpc_reply_state *first_reply = NULL;
                 int                        nreplies = 0;
 
+                spin_lock(&exp->exp_lock);
                 list_for_each_entry (rs, &exp->exp_outstanding_replies,
                                      rs_exp_list) {
                         if (nreplies == 0)
                                 first_reply = rs;
                         nreplies++;
                 }
+                spin_unlock(&exp->exp_lock);
 
                 CDEBUG(D_IOCTL, "%s: %p %s %s %d %d %d: %p %s\n",
                        obd->obd_name, exp, exp->exp_client_uuid.uuid,
@@ -416,6 +426,7 @@ static void dump_exports(struct obd_device *obd)
                        exp->exp_failed, nreplies, first_reply,
                        nreplies > 3 ? "..." : "");
         }
+        spin_unlock(&obd->obd_dev_lock);
 }
 
 int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
@@ -448,7 +459,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
                                 obd->obd_force = 1;
                                 break;
                         case 'A':
-                                LCONSOLE_WARN("Failing over %s\n", 
+                                LCONSOLE_WARN("Failing over %s\n",
                                               obd->obd_name);
                                 obd->obd_fail = 1;
                                 obd->obd_no_transno = 1;
@@ -468,7 +479,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
         /* The three references that should be remaining are the
          * obd_self_export and the attach and setup references. */
         if (atomic_read(&obd->obd_refcount) > 3) {
-#if 0           /* We should never fail to cleanup with mountconf */ 
+#if 0           /* We should never fail to cleanup with mountconf */
                 if (!(obd->obd_fail || obd->obd_force)) {
                         CERROR("OBD %s is still busy with %d references\n"
                                "You should stop active file system users,"
@@ -480,7 +491,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
                         RETURN(-EBUSY);
                 }
 #endif
-                /* refcounf - 3 might be the number of real exports 
+                /* refcounf - 3 might be the number of real exports
                    (excluding self export). But class_incref is called
                    by other things as well, so don't count on it. */
                 CDEBUG(D_IOCTL, "%s: forcing exports to disconnect: %d\n",
@@ -587,7 +598,7 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg)
                 RETURN(-EINVAL);
         }
         if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) &&
-            strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) && 
+            strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) &&
             strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME)) {
                 CERROR("can't add connection on non-client dev\n");
                 RETURN(-EINVAL);
@@ -694,7 +705,7 @@ out:
                 OBD_FREE(lprof->lp_osc, osclen);
         if (lprof->lp_profile)
                 OBD_FREE(lprof->lp_profile, proflen);
-        OBD_FREE(lprof, sizeof(*lprof));        
+        OBD_FREE(lprof, sizeof(*lprof));
         RETURN(err);
 }
 
@@ -734,6 +745,28 @@ void class_del_profiles(void)
         EXIT;
 }
 
+static int class_set_global(char *ptr, int val) {
+        ENTRY;
+
+        if (class_match_param(ptr, PARAM_AT_MIN, NULL) == 0)
+            at_min = val;
+        else if (class_match_param(ptr, PARAM_AT_MAX, NULL) == 0)
+                at_max = val;
+        else if (class_match_param(ptr, PARAM_AT_EXTRA, NULL) == 0)
+                at_extra = val;
+        else if (class_match_param(ptr, PARAM_AT_EARLY_MARGIN, NULL) == 0)
+                at_early_margin = val;
+        else if (class_match_param(ptr, PARAM_AT_HISTORY, NULL) == 0)
+                at_history = val;
+        else
+                RETURN(-EINVAL);
+
+        CDEBUG(D_IOCTL, "global %s = %d\n", ptr, val);
+
+        RETURN(0);
+}
+
+
 /* We can't call ll_process_config directly because it lives in a module that
    must be loaded after this one. */
 static int (*client_process_config)(struct lustre_cfg *lcfg) = NULL;
@@ -801,6 +834,15 @@ int class_process_config(struct lustre_cfg *lcfg)
                 obd_timeout = max(lcfg->lcfg_num, 1U);
                 GOTO(out, err = 0);
         }
+        case LCFG_SET_LDLM_TIMEOUT: {
+                CDEBUG(D_IOCTL, "changing lustre ldlm_timeout from %d to %d\n",
+                       ldlm_timeout, lcfg->lcfg_num);
+                ldlm_timeout = max(lcfg->lcfg_num, 1U);
+                if (ldlm_timeout >= obd_timeout)
+                        ldlm_timeout = max(obd_timeout / 3, 1U);
+
+                GOTO(out, err = 0);
+        }
         case LCFG_SET_UPCALL: {
                 LCONSOLE_ERROR_MSG(0x15a, "recovery upcall is deprecated\n");
                 /* COMPAT_146 Don't fail on old configs */
@@ -814,13 +856,24 @@ int class_process_config(struct lustre_cfg *lcfg)
                 GOTO(out, err = 0);
         }
         case LCFG_PARAM: {
+                char *tmp;
                 /* llite has no obd */
-                if ((class_match_param(lustre_cfg_string(lcfg, 1), 
+                if ((class_match_param(lustre_cfg_string(lcfg, 1),
                                        PARAM_LLITE, 0) == 0) &&
                     client_process_config) {
                         err = (*client_process_config)(lcfg);
                         GOTO(out, err);
+                } else if ((class_match_param(lustre_cfg_string(lcfg, 1),
+                                              PARAM_SYS, &tmp) == 0)) {
+                        /* Global param settings */
+                        err = class_set_global(tmp, lcfg->lcfg_num);
+                        /* Note that since LCFG_PARAM is LCFG_REQUIRED, new
+                           unknown globals would cause config to fail */
+                        if (err)
+                                CWARN("Ignoring unknown param %s\n", tmp);
+                        GOTO(out, 0);
                 }
+
                 /* Fall through */
                 break;
         }
@@ -859,6 +912,28 @@ int class_process_config(struct lustre_cfg *lcfg)
                 err = class_del_conn(obd, lcfg);
                 GOTO(out, err = 0);
         }
+        case LCFG_POOL_NEW: {
+                err = obd_pool_new(obd, lustre_cfg_string(lcfg, 2));
+                GOTO(out, err = 0);
+                break;
+        }
+        case LCFG_POOL_ADD: {
+                err = obd_pool_add(obd, lustre_cfg_string(lcfg, 2),
+                                   lustre_cfg_string(lcfg, 3));
+                GOTO(out, err = 0);
+                break;
+        }
+        case LCFG_POOL_REM: {
+                err = obd_pool_rem(obd, lustre_cfg_string(lcfg, 2),
+                                   lustre_cfg_string(lcfg, 3));
+                GOTO(out, err = 0);
+                break;
+        }
+        case LCFG_POOL_DEL: {
+                err = obd_pool_del(obd, lustre_cfg_string(lcfg, 2));
+                GOTO(out, err = 0);
+                break;
+        }
         default: {
                 err = obd_process_config(obd, sizeof(*lcfg), lcfg);
                 GOTO(out, err);
@@ -867,14 +942,14 @@ int class_process_config(struct lustre_cfg *lcfg)
         }
 out:
         if ((err < 0) && !(lcfg->lcfg_command & LCFG_REQUIRED)) {
-                CWARN("Ignoring error %d on optional command %#x\n", err, 
+                CWARN("Ignoring error %d on optional command %#x\n", err,
                       lcfg->lcfg_command);
                 err = 0;
         }
         return err;
 }
 
-int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, 
+int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
                              struct lustre_cfg *lcfg, void *data)
 {
 #ifdef __KERNEL__
@@ -886,7 +961,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
         ENTRY;
 
         if (lcfg->lcfg_command != LCFG_PARAM) {
-                CERROR("Unknown command: %d\n", lcfg->lcfg_command);
+                CERROR("Unknown command: %x\n", lcfg->lcfg_command);
                 RETURN(-EINVAL);
         }
 
@@ -922,26 +997,26 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
                                                                vallen, data);
                                         set_fs(oldfs);
                                 }
-                                if (rc < 0) 
-                                        CERROR("writing proc entry %s err %d\n", 
+                                if (rc < 0)
+                                        CERROR("writing proc entry %s err %d\n",
                                                var->name, rc);
                                 break;
                         }
                         j++;
-                }    
+                }
                 if (!matched) {
                         CERROR("%s: unknown param %s\n",
                                (char *)lustre_cfg_string(lcfg, 0), key);
-                        /* rc = -EINVAL;	continue parsing other params */
+                        /* rc = -EINVAL;        continue parsing other params */
                 } else {
-                        LCONSOLE_INFO("%s.%.*s: set parameter %.*s=%s\n", 
-                                      (char *)lustre_cfg_string(lcfg, 0),
+                        LCONSOLE_INFO("%s.%.*s: set parameter %.*s=%s\n",
+                                      lustre_cfg_string(lcfg, 0),
                                       (int)strlen(prefix) - 1, prefix,
                                       (int)(sval - key - 1), key, sval);
                 }
         }
-        
-        if (rc > 0) 
+
+        if (rc > 0)
                 rc = 0;
         RETURN(rc);
 #else
@@ -968,7 +1043,7 @@ static int class_config_llog_handler(struct llog_handle * handle,
         char *cfg_buf = (char*) (rec + 1);
         int rc = 0;
         ENTRY;
-        
+
         //class_config_dump_handler(handle, rec, data);
 
         switch (rec->lrh_type) {
@@ -999,12 +1074,12 @@ static int class_config_llog_handler(struct llog_handle * handle,
                         if (marker->cm_flags & CM_START) {
                                 /* all previous flags off */
                                 clli->cfg_flags = CFG_F_MARKER;
-                                if (marker->cm_flags & CM_SKIP) { 
+                                if (marker->cm_flags & CM_SKIP) {
                                         clli->cfg_flags |= CFG_F_SKIP;
                                         CDEBUG(D_CONFIG, "SKIP #%d\n",
                                                marker->cm_step);
                                 } else if ((marker->cm_flags & CM_EXCLUDE) ||
-                                           lustre_check_exclusion(clli->cfg_sb, 
+                                           lustre_check_exclusion(clli->cfg_sb,
                                                           marker->cm_tgtname)) {
                                         clli->cfg_flags |= CFG_F_EXCLUDE;
                                         CDEBUG(D_CONFIG, "EXCLUDE %d\n",
@@ -1014,12 +1089,12 @@ static int class_config_llog_handler(struct llog_handle * handle,
                                 clli->cfg_flags = 0;
                         }
                 }
-                /* A config command without a start marker before it is 
+                /* A config command without a start marker before it is
                    illegal (post 146) */
                 if (!(clli->cfg_flags & CFG_F_COMPAT146) &&
-                    !(clli->cfg_flags & CFG_F_MARKER) && 
+                    !(clli->cfg_flags & CFG_F_MARKER) &&
                     (lcfg->lcfg_command != LCFG_MARKER)) {
-                        CWARN("Config not inside markers, ignoring! (%#x)\n", 
+                        CWARN("Config not inside markers, ignoring! (%#x)\n",
                               clli->cfg_flags);
                         clli->cfg_flags |= CFG_F_SKIP;
                 }
@@ -1032,14 +1107,34 @@ static int class_config_llog_handler(struct llog_handle * handle,
                         break;
                 }
 
-                if ((clli->cfg_flags & CFG_F_EXCLUDE) && 
+                /**
+                 * For interop mode between 1.8 and 2.0:
+                 * skip "lmv" configuration which exists since 2.0.
+                 */
+                {
+                        char *devname = lustre_cfg_string(lcfg, 0);
+                        char *typename = lustre_cfg_string(lcfg, 1);
+
+                        if (devname)
+                                devname += strlen(devname) - strlen("clilmv");
+
+                        if ((lcfg->lcfg_command == LCFG_ATTACH && typename &&
+                             strcmp(typename, "lmv") == 0) ||
+                            (devname && strcmp(devname, "clilmv") == 0)) {
+                                CWARN("skipping 'lmv' config: cmd=%x,%s:%s\n",
+                                       lcfg->lcfg_command, devname, typename);
+                                GOTO(out, rc = 0);
+                        }
+                }
+
+                if ((clli->cfg_flags & CFG_F_EXCLUDE) &&
                     (lcfg->lcfg_command == LCFG_LOV_ADD_OBD))
                         /* Add inactive instead */
                         lcfg->lcfg_command = LCFG_LOV_ADD_INA;
 
                 lustre_cfg_bufs_init(&bufs, lcfg);
 
-                if (clli && clli->cfg_instance && 
+                if (clli && clli->cfg_instance &&
                     LUSTRE_CFG_BUFLEN(lcfg, 0) > 0){
                         inst = 1;
                         inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
@@ -1051,13 +1146,13 @@ static int class_config_llog_handler(struct llog_handle * handle,
                                 lustre_cfg_string(lcfg, 0),
                                 clli->cfg_instance);
                         lustre_cfg_bufs_set_string(&bufs, 0, inst_name);
-                        CDEBUG(D_CONFIG, "cmd %x, instance name: %s\n", 
+                        CDEBUG(D_CONFIG, "cmd %x, instance name: %s\n",
                                lcfg->lcfg_command, inst_name);
                 }
 
                 /* we override the llog's uuid for clients, to insure they
                 are unique */
-                if (clli && clli->cfg_instance && 
+                if (clli && clli->cfg_instance &&
                     lcfg->lcfg_command == LCFG_ATTACH) {
                         lustre_cfg_bufs_set_string(&bufs, 2,
                                                    clli->cfg_uuid.uuid);
@@ -1129,7 +1224,7 @@ int class_config_parse_llog(struct llog_ctxt *ctxt, char *name,
 
         rc = llog_process(llh, class_config_llog_handler, cfg, &cd);
 
-        CDEBUG(D_CONFIG, "Processed log %s gen %d-%d (rc=%d)\n", name, 
+        CDEBUG(D_CONFIG, "Processed log %s gen %d-%d (rc=%d)\n", name,
                cd.lpcd_first_idx + 1, cd.lpcd_last_idx, rc);
         if (cfg)
                 cfg->cfg_last_idx = cd.lpcd_last_idx;
@@ -1184,7 +1279,7 @@ int class_config_dump_handler(struct llog_handle * handle,
                 if (lcfg->lcfg_command == LCFG_MARKER) {
                         struct cfg_marker *marker = lustre_cfg_buf(lcfg, 1);
                         ptr += snprintf(ptr, end-ptr, "marker=%d(%#x)%s '%s'",
-                                        marker->cm_step, marker->cm_flags, 
+                                        marker->cm_step, marker->cm_flags,
                                         marker->cm_tgtname, marker->cm_comment);
                 } else {
                         for (i = 0; i <  lcfg->lcfg_bufcount; i++) {
@@ -1433,7 +1528,7 @@ nidstats_get(struct hlist_node *hnode)
         struct nid_stat *ns;
 
         ns = hlist_entry(hnode, struct nid_stat, nid_hash);
-        ns->nid_exp_ref_count++;
+        nidstat_getref(ns);
 
         RETURN(ns);
 }
@@ -1444,7 +1539,7 @@ nidstats_put(struct hlist_node *hnode)
         struct nid_stat *ns;
 
         ns = hlist_entry(hnode, struct nid_stat, nid_hash);
-        ns->nid_exp_ref_count--;
+        nidstat_putref(ns);
 
         RETURN(ns);
 }
diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c
index f21492b..4d8f3c0 100644
--- a/lustre/obdclass/obd_mount.c
+++ b/lustre/obdclass/obd_mount.c
@@ -167,7 +167,7 @@ struct lustre_mount_info *server_get_mount(char *name)
         lsi = s2lsi(lmi->lmi_sb);
         mntget(lmi->lmi_mnt);
         atomic_inc(&lsi->lsi_mounts);
-        
+
         CDEBUG(D_MOUNT, "get_mnt %p from %s, refs=%d, vfscount=%d\n",
                lmi->lmi_mnt, name, atomic_read(&lsi->lsi_mounts),
                atomic_read(&lmi->lmi_mnt->mnt_count));
@@ -510,7 +510,6 @@ static int server_start_mgs(struct super_block *sb)
                 LCONSOLE_ERROR_MSG(0x15e, "Failed to start MGS '%s' (%d).  Is "
                                    "the 'mgs' module loaded?\n",
                                    LUSTRE_MGS_OBDNAME, rc);
-
         RETURN(rc);
 }
 
@@ -729,7 +728,8 @@ static int lustre_start_mgc(struct super_block *sb)
         OBD_ALLOC_PTR(data);
         if (data == NULL)
                 GOTO(out, rc = -ENOMEM);
-        data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT;
+        data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT |
+                                  OBD_CONNECT_FID;
         data->ocd_version = LUSTRE_VERSION_CODE;
         /* We connect to the MGS at setup, and don't disconnect until cleanup */
         rc = obd_connect(&mgc_conn, obd, &(obd->obd_uuid), data, &exp);
@@ -1350,10 +1350,9 @@ static void server_wait_finished(struct vfsmount *mnt)
                 LCONSOLE_WARN("Mount still busy with %d refs, waiting for "
                               "%d secs...\n",
                               atomic_read(&mnt->mnt_count), retries);
-
                 /* Wait for a bit */
                 retries -= 5;
-                lwi = LWI_TIMEOUT(5 * HZ, NULL, NULL);
+                lwi = LWI_TIMEOUT(cfs_time_seconds(5), NULL, NULL);
                 l_wait_event(waitq, 0, &lwi);
         }
         if (atomic_read(&mnt->mnt_count) > 1) {
@@ -1380,6 +1379,8 @@ static void server_put_super(struct super_block *sb)
         OBD_ALLOC(tmpname, tmpname_sz);
         memcpy(tmpname, lsi->lsi_ldd->ldd_svname, tmpname_sz);
         CDEBUG(D_MOUNT, "server put_super %s\n", tmpname);
+        if (IS_MDT(lsi->lsi_ldd) && (lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC))
+                snprintf(tmpname, tmpname_sz, "MGS");
 
         /* Stop the target */
         if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC) &&
@@ -1644,7 +1645,9 @@ static int server_fill_super(struct super_block *sb)
                 GOTO(out_mnt, rc);
 
         LCONSOLE_WARN("Server %s on device %s has started\n",
-                      lsi->lsi_ldd->ldd_svname, lsi->lsi_lmd->lmd_dev);
+                      ((lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC) &&
+                       (IS_MDT(lsi->lsi_ldd))) ? "MGS" : lsi->lsi_ldd->ldd_svname,
+                      lsi->lsi_lmd->lmd_dev);
 
         RETURN(0);
 out_mnt:
@@ -1867,8 +1870,11 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
                            must be the last one. */
                         *s1 = '\0';
                         break;
+                } else if (strncmp(s1, "loop=", 5) == 0) {
+                        clear++;
                 }
 
+
                 /* Find next opt */
                 s2 = strchr(s1, ',');
                 if (s2 == NULL) {
@@ -1990,7 +1996,7 @@ out:
                 CERROR("Unable to mount %s (%d)\n",
                        s2lsi(sb) ? lmd->lmd_dev : "", rc);
         } else {
-                CDEBUG(D_SUPER, "Mount %s complete\n", 
+                CDEBUG(D_SUPER, "Mount %s complete\n",
                        lmd->lmd_dev);
         }
         return rc;
diff --git a/lustre/obdclass/target.c b/lustre/obdclass/target.c
new file mode 100644
index 0000000..c723a99
--- /dev/null
+++ b/lustre/obdclass/target.c
@@ -0,0 +1,186 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/obdclass/class_target.c
+ *
+ * Common methods for target devices
+ *
+ * Author: Mikhail Pershin
+ */
+#define DEBUG_SUBSYSTEM S_CLASS
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+
+#include <obd_class.h>
+#include <lustre_fsfilt.h>
+#include <libcfs/list.h>
+#include <lustre_disk.h>
+#include <lustre_lib.h>
+#include <linux/slab.h>
+#include <lustre_param.h>
+#include <obd.h>
+
+/**
+ * Initialize trans_table if it is not initialized yet
+ */
+void target_trans_table_init(struct obd_device *obd)
+{
+        struct lr_server_data *lsd = obd->u.obt.obt_lsd;
+        /** new export or from 1.6 fs */
+        if (le32_to_cpu(lsd->lsd_trans_table_time) == 0)
+                lsd->lsd_trans_table_time = cpu_to_le32(cfs_time_current_sec());
+        /** number of interval changed, write new value */
+        if (le32_to_cpu(lsd->lsd_expire_intervals) == 0)
+                lsd->lsd_expire_intervals = cpu_to_le32(LR_EXPIRE_INTERVALS);
+}
+EXPORT_SYMBOL(target_trans_table_init);
+
+/**
+ * Calculate time by index. All expiration time is divided by LR_EXPIRE_INTERVALS,
+ * so time of each index is calculated from time of first index
+ */
+static inline
+__u32 target_trans_table_slot2time(struct obd_device_target *obt, int idx)
+{
+        __u32 time = le32_to_cpu(obt->obt_lsd->lsd_trans_table_time);
+        __u32 age;
+
+        age = obt->obt_stale_export_age /
+              le32_to_cpu(obt->obt_lsd->lsd_expire_intervals) * idx;
+        return cfs_time_sub(time, age);
+}
+
+/**
+ * Check trans table in server_data to get last time this export was seen
+ */
+__u32 target_trans_table_last_time(struct obd_export *exp)
+{
+        struct obd_device_target *obt = &exp->exp_obd->u.obt;
+        const __u32 slots = le32_to_cpu(obt->obt_lsd->lsd_expire_intervals);
+        __u32 time = cfs_time_current_sec();
+        int i, idx = slots;
+
+        /** return current time */
+        if (obt->obt_stale_export_age == 0)
+                return time;
+
+        spin_lock(&obt->obt_trans_table_lock);
+        for (i = 0; i < slots; i++)
+                if (exp->exp_last_committed <=
+                    le64_to_cpu(obt->obt_lsd->lsd_trans_table[i]))
+                        idx = i;
+        if (idx < slots)
+                time = target_trans_table_slot2time(obt, idx);
+        spin_unlock(&obt->obt_trans_table_lock);
+        return time;
+}
+EXPORT_SYMBOL(target_trans_table_last_time);
+
+/**
+ * Recalculate trans_table slots data if stale_export_age is changed
+ */
+void target_trans_table_recalc(struct obd_device *obd, __u32 new_age)
+{
+        struct obd_device_target *obt = &obd->u.obt;
+        __u32 old_age = obt->obt_stale_export_age;
+        const __u32 slots = le32_to_cpu(obt->obt_lsd->lsd_expire_intervals);
+        __u64 *table = obt->obt_lsd->lsd_trans_table;
+        int i, j;
+
+        /** there is no old info to recalc */
+        if (obt->obt_stale_export_age == 0)
+                return;
+
+        /** Expand table */
+        spin_lock(&obt->obt_trans_table_lock);
+        if (old_age < new_age) {
+                for (j = 0; j < slots; j++) {
+                        i = j * new_age / old_age;
+                        /** no more data for new age */
+                        if (i >= slots)
+                                table[j] = 0;
+                        else
+                                table[j] = table[i];
+                }
+        } else {
+                for (j = slots; j > 0; j--) {
+                        i = (j - 1) * new_age / old_age;
+                        table[j] = table[i];
+                }
+        }
+        spin_unlock(&obt->obt_trans_table_lock);
+}
+EXPORT_SYMBOL(target_trans_table_recalc);
+
+/**
+ * New transno is arrived and it is time for new slot
+ */
+void target_trans_table_update(struct obd_export *exp, __u64 transno)
+{
+        struct obd_device_target *obt = &exp->exp_obd->u.obt;
+        __u32 shift = cfs_time_sub(cfs_time_current_sec(),
+                              le32_to_cpu(obt->obt_lsd->lsd_trans_table_time));
+        __u64 *table = obt->obt_lsd->lsd_trans_table;
+        const __u32 slots = le32_to_cpu(obt->obt_lsd->lsd_expire_intervals);
+        int n = 0, i, j;
+
+        /** how many slots are in shift */
+        if (obt->obt_stale_export_age > 0)
+                n = shift * slots / obt->obt_stale_export_age;
+        /** it is not time to update */
+        if (n == 0)
+                return;
+        spin_lock(&obt->obt_trans_table_lock);
+        /** shift table if there is overlapping or fill with latest transno */
+        for (i = slots - 1; i >= 1; i--) {
+                j = i > n ? i - n : 0;
+                table[i] = table[j];
+        }
+        /** now update first slot with new data */
+        obt->obt_lsd->lsd_trans_table_time = cpu_to_le32(cfs_time_current_sec());
+        obt->obt_lsd->lsd_trans_table[0] = cpu_to_le64(transno);
+        spin_unlock(&obt->obt_trans_table_lock);
+}
+EXPORT_SYMBOL(target_trans_table_update);
+
+int target_fs_version_capable(struct obd_device *obd)
+{
+        struct inode * inode = obd->u.obt.obt_rcvd_filp->f_dentry->d_inode;
+        /** check inode has version */
+        return (fsfilt_get_version(obd, inode) != -EOPNOTSUPP);
+}
+EXPORT_SYMBOL(target_fs_version_capable);
+
diff --git a/lustre/obdecho/Makefile.in b/lustre/obdecho/Makefile.in
index 66e61ed..73595ad 100644
--- a/lustre/obdecho/Makefile.in
+++ b/lustre/obdecho/Makefile.in
@@ -1,4 +1,6 @@
 MODULES := obdecho
 obdecho-objs := echo.o echo_client.o lproc_echo.o
 
+EXTRA_DIST = $(obdecho-objs:%.o=%.c)
+
 @INCLUDE_RULES@
diff --git a/lustre/obdecho/autoMakefile.am b/lustre/obdecho/autoMakefile.am
index bd83a99..313b0f8 100644
--- a/lustre/obdecho/autoMakefile.am
+++ b/lustre/obdecho/autoMakefile.am
@@ -68,4 +68,3 @@ endif # MODULES
 install-data-hook: $(install_data_hook)
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES = $(obdecho-objs:%.o=%.c)
diff --git a/lustre/obdecho/autoMakefile.in b/lustre/obdecho/autoMakefile.in
index 9deb544..e102563 100644
--- a/lustre/obdecho/autoMakefile.in
+++ b/lustre/obdecho/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -350,7 +350,6 @@ target_vendor = @target_vendor@
 @DARWIN_TRUE@@MODULES_TRUE at plist_DATA := Info.plist
 
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
-DIST_SOURCES = $(obdecho-objs:%.o=%.c)
 subdir = lustre/obdecho
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -392,6 +391,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libobdecho_a_SOURCES_DIST) \
+	$(am__obdecho_SOURCES_DIST)
 DATA = $(modulefs_DATA) $(plist_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c
index bbd234e..dab376b 100644
--- a/lustre/obdecho/echo.c
+++ b/lustre/obdecho/echo.c
@@ -288,16 +288,79 @@ echo_page_debug_check(cfs_page_t *page, obd_id id,
 /* This allows us to verify that desc_private is passed unmolested */
 #define DESC_PRIV 0x10293847
 
+static int echo_map_nb_to_lb(struct obdo *oa, struct obd_ioobj *obj,
+                             struct niobuf_remote *nb, int *pages,
+                             struct niobuf_local *lb, int cmd, int *left)
+{
+        int gfp_mask = (obj->ioo_id & 1) ? CFS_ALLOC_HIGHUSER : CFS_ALLOC_STD;
+        int ispersistent = obj->ioo_id == ECHO_PERSISTENT_OBJID;
+        int debug_setup = (!ispersistent &&
+                           (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
+                           (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
+        struct niobuf_local *res = lb;
+        obd_off offset = nb->offset;
+        int len = nb->len;
+
+        while (len > 0) {
+                int plen = CFS_PAGE_SIZE - (offset & (CFS_PAGE_SIZE-1));
+                if (len < plen)
+                        plen = len;
+
+                /* check for local buf overflow */
+                if (*left == 0)
+                        return -EINVAL;
+
+                res->offset = offset;
+                res->len = plen;
+                LASSERT((res->offset & ~CFS_PAGE_MASK) + res->len <= CFS_PAGE_SIZE);
+
+
+                if (ispersistent &&
+                    (res->offset >> CFS_PAGE_SHIFT) < ECHO_PERSISTENT_PAGES) {
+                        res->page = echo_persistent_pages[res->offset >>
+                                CFS_PAGE_SHIFT];
+                        /* Take extra ref so __free_pages() can be called OK */
+                        cfs_get_page (res->page);
+                } else {
+                        OBD_PAGE_ALLOC(res->page, gfp_mask);
+                        if (res->page == NULL) {
+                                CERROR("can't get page for id " LPU64"\n",
+                                       obj->ioo_id);
+                                return -ENOMEM;
+                        }
+                }
+
+                CDEBUG(D_PAGE, "$$$$ get page %p @ "LPU64" for %d\n",
+                       res->page, res->offset, res->len);
+
+                if (cmd & OBD_BRW_READ)
+                        res->rc = res->len;
+
+                if (debug_setup)
+                        echo_page_debug_setup(res->page, cmd, obj->ioo_id,
+                                              res->offset, res->len);
+
+                offset += plen;
+                len -= plen;
+                res++;
+
+                (*left)--;
+                (*pages)++;
+        }
+        
+        return 0;
+}
+
 int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
-                int objcount, struct obd_ioobj *obj, int niocount,
-                struct niobuf_remote *nb, struct niobuf_local *res,
+                int objcount, struct obd_ioobj *obj, struct niobuf_remote *nb,
+                int *pages, struct niobuf_local *res,
                 struct obd_trans_info *oti)
 {
         struct obd_device *obd;
         struct niobuf_local *r = res;
         int tot_bytes = 0;
         int rc = 0;
-        int i;
+        int i, left;
         ENTRY;
 
         obd = export->exp_obd;
@@ -307,59 +370,33 @@ int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
         /* Temp fix to stop falling foul of osc_announce_cached() */
         oa->o_valid &= ~(OBD_MD_FLBLOCKS | OBD_MD_FLGRANT);
 
-        memset(res, 0, sizeof(*res) * niocount);
+        memset(res, 0, sizeof(*res) * *pages);
 
         CDEBUG(D_PAGE, "%s %d obdos with %d IOs\n",
-               cmd == OBD_BRW_READ ? "reading" : "writing", objcount, niocount);
+               cmd == OBD_BRW_READ ? "reading" : "writing", objcount, *pages);
 
         if (oti)
                 oti->oti_handle = (void *)DESC_PRIV;
 
+        left = *pages;
+        *pages = 0;
+
         for (i = 0; i < objcount; i++, obj++) {
-                int gfp_mask = (obj->ioo_id & 1) ? CFS_ALLOC_HIGHUSER : CFS_ALLOC_STD;
-                int ispersistent = obj->ioo_id == ECHO_PERSISTENT_OBJID;
-                int debug_setup = (!ispersistent &&
-                                   (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
-                                   (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0);
                 int j;
 
                 for (j = 0 ; j < obj->ioo_bufcnt ; j++, nb++, r++) {
 
-                        if (ispersistent &&
-                            (nb->offset >> CFS_PAGE_SHIFT) < ECHO_PERSISTENT_PAGES) {
-                                r->page = echo_persistent_pages[nb->offset >>
-                                                                CFS_PAGE_SHIFT];
-                                /* Take extra ref so __free_pages() can be called OK */
-                                cfs_get_page (r->page);
-                        } else {
-                                OBD_PAGE_ALLOC(r->page, gfp_mask);
-                                if (r->page == NULL) {
-                                        CERROR("can't get page %u/%u for id "
-                                               LPU64"\n",
-                                               j, obj->ioo_bufcnt, obj->ioo_id);
-                                        GOTO(preprw_cleanup, rc = -ENOMEM);
-                                }
-                        }
+                        rc = echo_map_nb_to_lb(oa, obj, nb, pages,
+                                               res + *pages, cmd, &left);
+                        if (rc)
+                                GOTO(preprw_cleanup, rc);
 
                         tot_bytes += nb->len;
-
-                        atomic_inc(&obd->u.echo.eo_prep);
-
-                        r->offset = nb->offset;
-                        r->len = nb->len;
-                        LASSERT((r->offset & ~CFS_PAGE_MASK) + r->len <= CFS_PAGE_SIZE);
-
-                        CDEBUG(D_PAGE, "$$$$ get page %p @ "LPU64" for %d\n",
-                               r->page, r->offset, r->len);
-
-                        if (cmd & OBD_BRW_READ)
-                                r->rc = r->len;
-
-                        if (debug_setup)
-                                echo_page_debug_setup(r->page, cmd, obj->ioo_id,
-                                                      r->offset, r->len);
                 }
         }
+
+        atomic_add(*pages, &obd->u.echo.eo_prep);
+
         if (cmd & OBD_BRW_READ)
                 lprocfs_counter_add(obd->obd_stats, LPROC_ECHO_READ_BYTES,
                                     tot_bytes);
@@ -378,21 +415,22 @@ preprw_cleanup:
          * all down again.  I believe that this is what the in-kernel
          * prep/commit operations do.
          */
-        CERROR("cleaning up %ld pages (%d obdos)\n", (long)(r - res), objcount);
-        while (r-- > res) {
-                cfs_kunmap(r->page);
+        CERROR("cleaning up %u pages (%d obdos)\n", *pages, objcount);
+        for (i = 0; i < *pages; i++) {
+                cfs_kunmap(res[i].page);
                 /* NB if this is a persistent page, __free_pages will just
                  * lose the extra ref gained above */
-                OBD_PAGE_FREE(r->page);
+                OBD_PAGE_FREE(res[i].page);
+                res[i].page = NULL;
                 atomic_dec(&obd->u.echo.eo_prep);
         }
-        memset(res, 0, sizeof(*res) * niocount);
 
         return rc;
 }
 
 int echo_commitrw(int cmd, struct obd_export *export, struct obdo *oa,
-                  int objcount, struct obd_ioobj *obj, int niocount,
+                  int objcount, struct obd_ioobj *obj,
+                  struct niobuf_remote *rb, int niocount,
                   struct niobuf_local *res, struct obd_trans_info *oti, int rc)
 {
         struct obd_device *obd;
diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c
index ab75bc0..3d6536b 100644
--- a/lustre/obdecho/echo_client.c
+++ b/lustre/obdecho/echo_client.c
@@ -169,9 +169,9 @@ echo_free_object (struct ec_object *eco)
         struct echo_client_obd *ec = &obd->u.echo_client;
 
         LASSERT (eco->eco_refcount == 0);
-        if (!eco->eco_lsm) 
+        if (!eco->eco_lsm)
                 CERROR("No object %s\n", obd->obd_name);
-        else 
+        else
                 obd_free_memmd(ec->ec_exp, &eco->eco_lsm);
         OBD_FREE (eco, sizeof (*eco));
 }
@@ -196,7 +196,7 @@ static int echo_create_object(struct obd_device *obd, int on_target,
 
         if (ulsm != NULL) {
                 eco = echo_allocate_object (obd);
-                if (eco == NULL) 
+                if (eco == NULL)
                         return (-ENOMEM);
 
                 lsm = eco->eco_lsm;
@@ -227,7 +227,7 @@ static int echo_create_object(struct obd_device *obd, int on_target,
                 }
         } else {
                 OBD_ALLOC(eco, sizeof(*eco));
-                if (!eco) 
+                if (!eco)
                         return (-ENOMEM);
                 eco->eco_device = obd;
                 lsm = NULL;
@@ -281,7 +281,7 @@ static int echo_create_object(struct obd_device *obd, int on_target,
 
  failed:
         echo_free_object (eco);
-        if (rc) 
+        if (rc)
                 CERROR("%s: err %d on create\n", obd->obd_name, rc);
         return (rc);
 }
@@ -447,9 +447,9 @@ echo_get_stripe_off_id (struct lov_stripe_md *lsm, obd_off *offp, obd_id *idp)
         *offp = offset * stripe_size + woffset % stripe_size;
 }
 
-static void 
-echo_client_page_debug_setup(struct lov_stripe_md *lsm, 
-                             cfs_page_t *page, int rw, obd_id id, 
+static void
+echo_client_page_debug_setup(struct lov_stripe_md *lsm,
+                             cfs_page_t *page, int rw, obd_id id,
                              obd_off offset, obd_off count)
 {
         char    *addr;
@@ -471,7 +471,7 @@ echo_client_page_debug_setup(struct lov_stripe_md *lsm,
                         stripe_off = 0xdeadbeef00c0ffeeULL;
                         stripe_id = 0xdeadbeef00c0ffeeULL;
                 }
-                block_debug_setup(addr + delta, OBD_ECHO_BLOCK_SIZE, 
+                block_debug_setup(addr + delta, OBD_ECHO_BLOCK_SIZE,
                                   stripe_off, stripe_id);
         }
 
@@ -479,8 +479,8 @@ echo_client_page_debug_setup(struct lov_stripe_md *lsm,
 }
 
 static int
-echo_client_page_debug_check(struct lov_stripe_md *lsm, 
-                             cfs_page_t *page, obd_id id, 
+echo_client_page_debug_check(struct lov_stripe_md *lsm,
+                             cfs_page_t *page, obd_id id,
                              obd_off offset, obd_off count)
 {
         obd_off stripe_off;
@@ -500,8 +500,8 @@ echo_client_page_debug_check(struct lov_stripe_md *lsm,
                 stripe_id = id;
                 echo_get_stripe_off_id (lsm, &stripe_off, &stripe_id);
 
-                rc2 = block_debug_check("test_brw", 
-                                        addr + delta, OBD_ECHO_BLOCK_SIZE, 
+                rc2 = block_debug_check("test_brw",
+                                        addr + delta, OBD_ECHO_BLOCK_SIZE,
                                         stripe_off, stripe_id);
                 if (rc2 != 0) {
                         CERROR ("Error in echo object "LPX64"\n", id);
@@ -520,6 +520,7 @@ static int echo_client_kbrw(struct obd_device *obd, int rw, struct obdo *oa,
         struct echo_client_obd *ec = &obd->u.echo_client;
         struct obd_info         oinfo = { { { 0 } } };
         obd_count               npages;
+        struct ptlrpc_request_set *set = NULL;
         struct brw_page        *pga;
         struct brw_page        *pgp;
         obd_off                 off;
@@ -542,6 +543,10 @@ static int echo_client_kbrw(struct obd_device *obd, int rw, struct obdo *oa,
             (count & (~CFS_PAGE_MASK)) != 0)
                 return (-EINVAL);
 
+        set =  ptlrpc_prep_set();
+        if (set == NULL)
+                RETURN(-ENOMEM);
+
         /* XXX think again with misaligned I/O */
         npages = count >> CFS_PAGE_SHIFT;
 
@@ -571,8 +576,24 @@ static int echo_client_kbrw(struct obd_device *obd, int rw, struct obdo *oa,
 
         oinfo.oi_oa = oa;
         oinfo.oi_md = lsm;
-        rc = obd_brw(rw, ec->ec_exp, &oinfo, npages, pga, oti);
 
+        /* OST/filter device don't support o_brw_async ops, turn to o_brw ops */
+        if (ec->ec_exp && ec->ec_exp->exp_obd &&
+            OBT(ec->ec_exp->exp_obd) && OBP(ec->ec_exp->exp_obd, brw_async)) {
+                rc = obd_brw_async(rw, ec->ec_exp, &oinfo, npages, pga, oti,
+                                   set);
+                if (rc == 0) {
+                        rc = ptlrpc_set_wait(set);
+                        if (rc)
+                                CERROR("error from callback: rc = %d\n", rc);
+                }
+        } else {
+                rc = obd_brw(rw, ec->ec_exp, &oinfo, npages, pga, oti);
+        }
+        if (rc)
+                CDEBUG_LIMIT(rc == -ENOSPC ? D_INODE : D_ERROR,
+                             "error from obd_brw_async: rc = %d\n", rc);
+        ptlrpc_set_destroy(set);
  out:
         if (rc != 0 || rw != OBD_BRW_READ)
                 verify = 0;
@@ -649,7 +670,7 @@ static void ec_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
 {
         struct echo_async_page *eap = EAP_FROM_COOKIE(data);
 
-        memcpy(oa, &eap->eap_eas->eas_oa, sizeof(*oa));
+        lustre_set_wire_obdo(oa, &eap->eap_eas->eas_oa);
 }
 
 static int ec_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
@@ -663,7 +684,7 @@ static int ec_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
             eas->eas_oa.o_id != ECHO_PERSISTENT_OBJID &&
             (eas->eas_oa.o_valid & OBD_MD_FLFLAGS) != 0 &&
             (eas->eas_oa.o_flags & OBD_FL_DEBUG_CHECK) != 0)
-                echo_client_page_debug_check(eas->eas_lsm, eap->eap_page, 
+                echo_client_page_debug_check(eas->eas_lsm, eap->eap_page,
                                              eas->eas_oa.o_id, eap->eap_off,
                                              CFS_PAGE_SIZE);
 
@@ -760,7 +781,7 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
 
                 /* sleep until we have a page to send */
                 spin_unlock(&eas.eas_lock);
-                rc = wait_event_interruptible(eas.eas_waitq, 
+                rc = wait_event_interruptible(eas.eas_waitq,
                                               eas_should_wake(&eas));
                 spin_lock(&eas.eas_lock);
                 if (rc && !eas.eas_rc)
@@ -776,7 +797,7 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
 
                 /* unbind the eap from its old page offset */
                 if (eap->eap_cookie != NULL) {
-                        obd_teardown_async_page(exp, lsm, NULL, 
+                        obd_teardown_async_page(exp, lsm, NULL,
                                                 eap->eap_cookie);
                         eap->eap_cookie = NULL;
                 }
@@ -796,8 +817,8 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
                 if (oa->o_id != ECHO_PERSISTENT_OBJID &&
                     (oa->o_valid & OBD_MD_FLFLAGS) != 0 &&
                     (oa->o_flags & OBD_FL_DEBUG_CHECK) != 0)
-                        echo_client_page_debug_setup(lsm, eap->eap_page, rw, 
-                                                     oa->o_id, 
+                        echo_client_page_debug_setup(lsm, eap->eap_page, rw,
+                                                     oa->o_id,
                                                      eap->eap_off, CFS_PAGE_SIZE);
 
                 /* always asserts urgent, which isn't quite right */
@@ -813,14 +834,14 @@ static int echo_client_async_page(struct obd_export *exp, int rw,
                 eas.eas_in_flight++;
                 if (eas.eas_next_offset == eas.eas_end_offset)
                         break;
-        } 
+        }
 
         /* still hold the eas_lock here.. */
 
         /* now we just spin waiting for all the rpcs to complete */
         while(eas.eas_in_flight) {
                 spin_unlock(&eas.eas_lock);
-                wait_event_interruptible(eas.eas_waitq, 
+                wait_event_interruptible(eas.eas_waitq,
                                          eas.eas_in_flight == 0);
                 spin_lock(&eas.eas_lock);
         }
@@ -847,7 +868,7 @@ out:
 
 static int echo_client_prep_commit(struct obd_export *exp, int rw,
                                    struct obdo *oa, struct lov_stripe_md *lsm,
-                                   obd_off offset, obd_size count,  
+                                   obd_off offset, obd_size count,
                                    obd_size batch, struct obd_trans_info *oti)
 {
         struct obd_ioobj ioo;
@@ -876,6 +897,8 @@ static int echo_client_prep_commit(struct obd_export *exp, int rw,
         off = offset;
 
         for(; tot_pages; tot_pages -= npages) {
+                int lpages;
+
                 if (tot_pages < npages)
                         npages = tot_pages;
 
@@ -887,11 +910,13 @@ static int echo_client_prep_commit(struct obd_export *exp, int rw,
                 ioo.ioo_bufcnt = npages;
                 oti->oti_transno = 0;
 
-                ret = obd_preprw(rw, exp, oa, 1, &ioo, npages, rnb, lnb, oti);
+                lpages = npages;
+                ret = obd_preprw(rw, exp, oa, 1, &ioo, rnb, &lpages, lnb, oti);
                 if (ret != 0)
                         GOTO(out, ret);
+                LASSERT(lpages == npages);
 
-                for (i = 0; i < npages; i++) {
+                for (i = 0; i < lpages; i++) {
                         cfs_page_t *page = lnb[i].page;
 
                         /* read past eof? */
@@ -915,7 +940,7 @@ static int echo_client_prep_commit(struct obd_export *exp, int rw,
                                                              rnb[i].len);
                 }
 
-                ret = obd_commitrw(rw, exp, oa, 1, &ioo, npages, lnb, oti, ret);
+                ret = obd_commitrw(rw, exp, oa, 1,&ioo,rnb,npages,lnb,oti,ret);
                 if (ret != 0)
                         GOTO(out, ret);
         }
@@ -1256,7 +1281,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp,
  out:
 
         /* XXX this should be in a helper also called by target_send_reply */
-        for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i < 4; 
+        for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i < 4;
              i++, ack_lock++) {
                 if (!ack_lock->mode)
                         break;
@@ -1296,25 +1321,48 @@ echo_client_setup(struct obd_device *obddev, obd_count len, void *buf)
         CFS_INIT_LIST_HEAD (&ec->ec_objects);
         ec->ec_unique = 0;
 
+        ec->ec_exp = lustre_hash_lookup(tgt->obd_uuid_hash, &echo_uuid);
+        if (ec->ec_exp)
+                RETURN(0);
+
         OBD_ALLOC(ocd, sizeof(*ocd));
         if (ocd == NULL) {
                 CERROR("Can't alloc ocd connecting to %s\n",
                        lustre_cfg_string(lcfg, 1));
                 return -ENOMEM;
         }
-
         ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_REQPORTAL;
         ocd->ocd_version = LUSTRE_VERSION_CODE;
 
-        rc = obd_connect(&conn, tgt, &echo_uuid, ocd, &ec->ec_exp);
+        if ((strncmp(tgt->obd_type->typ_name, LUSTRE_OSC_NAME,
+                     strlen(LUSTRE_OSC_NAME)) == 0) ||
+            (strncmp(tgt->obd_type->typ_name, LUSTRE_LOV_NAME,
+                     strlen(LUSTRE_LOV_NAME)) == 0)) {
+                rc = obd_connect(&conn, tgt, &echo_uuid, ocd, &ec->ec_exp);
+        } else {
+                rc = obd_connect(&conn, tgt, &echo_uuid, ocd, NULL);
+                if (rc == 0)
+                        ec->ec_exp = class_conn2export(&conn);
+        }
 
         OBD_FREE(ocd, sizeof(*ocd));
 
-        if (rc != 0) {
+        if (rc == -EALREADY && (strncmp(tgt->obd_type->typ_name,LUSTRE_OSC_NAME,
+                                        strlen(LUSTRE_OSC_NAME)) == 0)) {
+                /* OSC obd forbid reconnect already connected import,
+                 * so we hack creating another export here */
+                down_write(&tgt->u.cli.cl_sem);
+                rc = class_connect(&conn, tgt, &echo_uuid);
+                if (rc == 0) {
+                        ++tgt->u.cli.cl_conn_count;
+                        ec->ec_exp = class_conn2export(&conn);
+                }
+                up_write(&tgt->u.cli.cl_sem);
+        }
+
+        if (rc != 0)
                 CERROR("fail to connect to device %s\n",
                        lustre_cfg_string(lcfg, 1));
-                return (rc);
-        }
 
         RETURN(rc);
 }
diff --git a/lustre/obdfilter/Makefile.in b/lustre/obdfilter/Makefile.in
index 8305eb5..0db3c99 100644
--- a/lustre/obdfilter/Makefile.in
+++ b/lustre/obdfilter/Makefile.in
@@ -2,11 +2,8 @@ MODULES := obdfilter
 
 obdfilter-objs := filter.o filter_io.o filter_log.o
 obdfilter-objs += lproc_obdfilter.o filter_lvb.o
-
-ifeq ($(PATCHLEVEL),4)
-obdfilter-objs += filter_io_24.o
-else
 obdfilter-objs += filter_io_26.o
-endif # PATCHLEVEL 
+
+EXTRA_DIST = $(obdfilter-objs:%.o=%.c) filter_io_26.c filter_internal.h
 
 @INCLUDE_RULES@
diff --git a/lustre/obdfilter/autoMakefile.am b/lustre/obdfilter/autoMakefile.am
index 9eb4a37..cfef4e9 100644
--- a/lustre/obdfilter/autoMakefile.am
+++ b/lustre/obdfilter/autoMakefile.am
@@ -39,4 +39,3 @@ modulefs_DATA = obdfilter$(KMODEXT)
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES = $(obdfilter-objs:%.o=%.c) filter_io_24.c filter_io_26.c filter_internal.h
diff --git a/lustre/obdfilter/autoMakefile.in b/lustre/obdfilter/autoMakefile.in
index ffec6d2..cfeccbb 100644
--- a/lustre/obdfilter/autoMakefile.in
+++ b/lustre/obdfilter/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @MODULES_TRUE at modulefs_DATA = obdfilter$(KMODEXT)
-DIST_SOURCES = $(obdfilter-objs:%.o=%.c) filter_io_24.c filter_io_26.c filter_internal.h
 subdir = lustre/obdfilter
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c
index f3c8c88..936adef 100644
--- a/lustre/obdfilter/filter.c
+++ b/lustre/obdfilter/filter.c
@@ -83,11 +83,42 @@ cfs_mem_cache_t *ll_fmd_cachep;
 static void filter_commit_cb(struct obd_device *obd, __u64 transno,
                              void *cb_data, int error)
 {
-        obd_transno_commit_cb(obd, transno, error);
+        struct obd_export *exp = cb_data;
+        LASSERTF(exp->exp_obd == obd,
+                 "%s: bad export (%p), obd (%p) != exp->exp_obd (%p)\n",
+                 obd->obd_name, exp, obd, exp->exp_obd);
+        obd_transno_commit_cb(obd, transno, exp, error);
+        class_export_put(exp);
+}
+
+int filter_version_get_check(struct obd_export *exp,
+                             struct obd_trans_info *oti, struct inode *inode)
+{
+        __u64 curr_version;
+
+        if (inode == NULL || oti == NULL)
+                RETURN(0);
+
+        curr_version = fsfilt_get_version(exp->exp_obd, inode);
+        if ((__s64)curr_version == -EOPNOTSUPP)
+                RETURN(0);
+        /* VBR: version is checked always because costs nothing */
+        if (oti->oti_pre_version != 0 &&
+            oti->oti_pre_version != curr_version) {
+                CDEBUG(D_INODE, "Version mismatch "LPX64" != "LPX64"\n",
+                       oti->oti_pre_version, curr_version);
+                spin_lock(&exp->exp_lock);
+                exp->exp_vbr_failed = 1;
+                spin_unlock(&exp->exp_lock);
+                RETURN (-EOVERFLOW);
+        }
+        oti->oti_pre_version = curr_version;
+        RETURN(0);
 }
 
 /* Assumes caller has already pushed us into the kernel context. */
-int filter_finish_transno(struct obd_export *exp, struct obd_trans_info *oti,
+int filter_finish_transno(struct obd_export *exp, struct inode *inode,
+                          struct obd_trans_info *oti,
                           int rc, int force_sync)
 {
         struct filter_obd *filter = &exp->exp_obd->u.filter;
@@ -105,24 +136,29 @@ int filter_finish_transno(struct obd_export *exp, struct obd_trans_info *oti,
                 RETURN(rc);
 
         /* we don't allocate new transnos for replayed requests */
+        spin_lock(&filter->fo_translock);
         if (oti->oti_transno == 0) {
-                spin_lock(&filter->fo_translock);
                 last_rcvd = le64_to_cpu(filter->fo_fsd->lsd_last_transno) + 1;
                 filter->fo_fsd->lsd_last_transno = cpu_to_le64(last_rcvd);
-                spin_unlock(&filter->fo_translock);
-                oti->oti_transno = last_rcvd;
         } else {
-                spin_lock(&filter->fo_translock);
                 last_rcvd = oti->oti_transno;
                 if (last_rcvd > le64_to_cpu(filter->fo_fsd->lsd_last_transno))
-                        filter->fo_fsd->lsd_last_transno =
-                                cpu_to_le64(last_rcvd);
+                        filter->fo_fsd->lsd_last_transno = cpu_to_le64(last_rcvd);
+        }
+        oti->oti_transno = last_rcvd;
+        if (last_rcvd <= le64_to_cpu(lcd->lcd_last_transno)) {
                 spin_unlock(&filter->fo_translock);
+                LBUG();
         }
         lcd->lcd_last_transno = cpu_to_le64(last_rcvd);
+        lcd->lcd_pre_versions[0] = cpu_to_le64(oti->oti_pre_version);
+        lcd->lcd_last_xid = cpu_to_le64(oti->oti_xid);
+        target_trans_table_update(exp, last_rcvd);
+
+        spin_unlock(&filter->fo_translock);
 
-        /* could get xid from oti, if it's ever needed */
-        lcd->lcd_last_xid = 0;
+        if (inode)
+                fsfilt_set_version(exp->exp_obd, inode, last_rcvd);
 
         off = fed->fed_lr_off;
         if (off <= 0) {
@@ -130,18 +166,19 @@ int filter_finish_transno(struct obd_export *exp, struct obd_trans_info *oti,
                        fed->fed_lr_idx, fed->fed_lr_off);
                 err = -EINVAL;
         } else {
+                class_export_get(exp); /* released when the cb is called */
                 if (!force_sync)
                         force_sync = fsfilt_add_journal_cb(exp->exp_obd,
                                                            last_rcvd,
                                                            oti->oti_handle,
                                                            filter_commit_cb,
-                                                           NULL);
+                                                           exp);
 
                 err = fsfilt_write_record(exp->exp_obd, filter->fo_rcvd_filp,
                                           lcd, sizeof(*lcd), &off,
                                           force_sync | exp->exp_need_sync);
                 if (force_sync)
-                        filter_commit_cb(exp->exp_obd, last_rcvd, NULL, err);
+                        filter_commit_cb(exp->exp_obd, last_rcvd, exp, err);
         }
         if (err) {
                 log_pri = D_ERROR;
@@ -179,7 +216,7 @@ static int lprocfs_init_rw_stats(struct obd_device *obd,
 
         num_stats = (sizeof(*obd->obd_type->typ_ops) / sizeof(void *)) +
                                                         LPROC_FILTER_LAST - 1;
-        *stats = lprocfs_alloc_stats(num_stats, 0);
+        *stats = lprocfs_alloc_stats(num_stats, LPROCFS_STATS_FLAG_NOPERCPU);
         if (*stats == NULL)
                 return -ENOMEM;
 
@@ -198,13 +235,10 @@ static int filter_export_stats_init(struct obd_device *obd,
                                     struct obd_export *exp,
                                     void *client_nid)
 {
-        struct filter_export_data *fed = &exp->exp_filter_data;
         struct proc_dir_entry *brw_entry;
         int rc, newnid = 0;
         ENTRY;
 
-        init_brw_stats(&fed->fed_brw_stats);
-
         if (obd_uuid_equals(&exp->exp_client_uuid, &obd->obd_uuid))
                 /* Self-export gets no proc entry */
                 RETURN(0);
@@ -246,8 +280,9 @@ static int filter_export_stats_init(struct obd_device *obd,
                         RETURN(rc);
 
                 /* Always add in ldlm_stats */
-                tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC -
-                                                          LDLM_FIRST_OPC, 0);
+                tmp->nid_ldlm_stats =
+                        lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC,
+                                            LPROCFS_STATS_FLAG_NOPERCPU);
                 if (tmp->nid_ldlm_stats == NULL)
                         return -ENOMEM;
 
@@ -260,6 +295,73 @@ static int filter_export_stats_init(struct obd_device *obd,
         RETURN(0);
 }
 
+/* VBR: to determine the delayed client the lcd should be updated for each new
+ * epoch */
+static int filter_update_client_epoch(struct obd_export *exp)
+{
+        struct filter_export_data *fed = &exp->exp_filter_data;
+        struct filter_obd *filter = &exp->exp_obd->u.filter;
+        struct lvfs_run_ctxt saved;
+        loff_t off = fed->fed_lr_off;
+        int rc = 0;
+
+        /* VBR: set client last_epoch to current epoch */
+        if (le32_to_cpu(fed->fed_lcd->lcd_last_epoch) >=
+                        le32_to_cpu(filter->fo_fsd->lsd_start_epoch))
+                return rc;
+        fed->fed_lcd->lcd_last_epoch = filter->fo_fsd->lsd_start_epoch;
+        push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
+        rc = fsfilt_write_record(exp->exp_obd, filter->fo_rcvd_filp,
+                                 fed->fed_lcd, sizeof(*fed->fed_lcd), &off,
+                                 exp->exp_delayed);
+        pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
+
+        CDEBUG(D_INFO, "update client idx %u last_epoch %#x (%#x)\n",
+               fed->fed_lr_idx, le32_to_cpu(fed->fed_lcd->lcd_last_epoch),
+               le32_to_cpu(filter->fo_fsd->lsd_start_epoch));
+
+        return rc;
+}
+
+/* Called after recovery is done on server */
+static void filter_update_last_epoch(struct obd_device *obd)
+{
+        struct ptlrpc_request *req;
+        struct filter_obd *filter = &obd->u.filter;
+        struct lr_server_data *fsd = filter->fo_fsd;
+        __u32 start_epoch;
+
+        /* Increase server epoch after recovery */
+        spin_lock(&filter->fo_translock);
+        /* VBR: increase the epoch and store it in lsd */
+        start_epoch = lr_epoch(le64_to_cpu(fsd->lsd_last_transno)) + 1;
+        fsd->lsd_last_transno = cpu_to_le64((__u64)start_epoch << LR_EPOCH_BITS);
+        fsd->lsd_start_epoch = cpu_to_le32(start_epoch);
+        spin_unlock(&filter->fo_translock);
+
+        /* go through delayed reply queue to find all exports participate in
+         * recovery and set new epoch for them */
+        list_for_each_entry(req, &obd->obd_delayed_reply_queue, rq_list) {
+                LASSERT(!req->rq_export->exp_delayed);
+                filter_update_client_epoch(req->rq_export);
+        }
+        filter_update_server_data(obd, filter->fo_rcvd_filp, fsd, 1);
+}
+
+static int filter_postrecov(struct obd_device *obd)
+{
+        ENTRY;
+
+        if (obd->obd_fail)
+                RETURN(0);
+
+        LASSERT(!obd->obd_recovering);
+        /* VBR: update start_epoch on server */
+        filter_update_last_epoch(obd);
+
+        RETURN(0);
+}
+
 /* Add client data to the FILTER.  We use a bitmap to locate a free space
  * in the last_rcvd file if cl_idx is -1 (i.e. a new client).
  * Otherwise, we have just read the data from the last_rcvd file and
@@ -281,6 +383,10 @@ static int filter_client_add(struct obd_device *obd, struct obd_export *exp,
         if (strcmp(fed->fed_lcd->lcd_uuid, obd->obd_uuid.uuid) == 0)
                 RETURN(0);
 
+        /* VBR: remove expired exports before searching for free slot */
+        if (new_client)
+                class_disconnect_expired_exports(obd);
+
         /* the bitmap operations can handle cl_idx > sizeof(long) * 8, so
          * there's no need for extra complication here
          */
@@ -331,6 +437,9 @@ static int filter_client_add(struct obd_device *obd, struct obd_export *exp,
                         rc = PTR_ERR(handle);
                         CERROR("unable to start transaction: rc %d\n", rc);
                 } else {
+                        fed->fed_lcd->lcd_last_epoch =
+                                              filter->fo_fsd->lsd_start_epoch;
+                        exp->exp_last_request_time = cfs_time_current_sec();
                         rc = fsfilt_add_journal_cb(obd, 0, handle,
                                                    target_client_add_cb, exp);
                         if (rc == 0) {
@@ -376,13 +485,13 @@ static int filter_client_free(struct obd_export *exp)
         if (strcmp(fed->fed_lcd->lcd_uuid, obd->obd_uuid.uuid ) == 0)
                 GOTO(free, 0);
 
-        CDEBUG(D_INFO, "freeing client at idx %u, offset %lld with UUID '%s'\n",
-               fed->fed_lr_idx, fed->fed_lr_off, fed->fed_lcd->lcd_uuid);
-
         LASSERT(filter->fo_last_rcvd_slots != NULL);
 
         off = fed->fed_lr_off;
 
+        CDEBUG(D_INFO, "freeing client at idx %u, offset %lld with UUID '%s'\n",
+               fed->fed_lr_idx, fed->fed_lr_off, fed->fed_lcd->lcd_uuid);
+
         /* Don't clear fed_lr_idx here as it is likely also unset.  At worst
          * we leak a client slot that will be cleaned on the next recovery. */
         if (off <= 0) {
@@ -402,7 +511,7 @@ static int filter_client_free(struct obd_export *exp)
         if (!(exp->exp_flags & OBD_OPT_FAILOVER)) {
                 /* Don't force sync on disconnect if aborting recovery,
                  * or it does num_clients * num_osts.  b=17194 */
-                int need_sync = (!exp->exp_libclient || exp->exp_need_sync) &&
+                int need_sync = exp->exp_need_sync &&
                                 !(exp->exp_flags&OBD_OPT_ABORT_RECOV);
 
                 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
@@ -687,6 +796,7 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp)
         struct inode *inode = filp->f_dentry->d_inode;
         unsigned long last_rcvd_size = i_size_read(inode);
         __u64 mount_count;
+        __u32 start_epoch;
         int cl_idx;
         loff_t off = 0;
         int rc;
@@ -758,7 +868,12 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp)
                 GOTO(err_fsd, rc = -EINVAL);
         }
 
-        CDEBUG(D_INODE, "%s: server last_transno : "LPU64"\n",
+        target_trans_table_init(obd);
+        start_epoch = le32_to_cpu(fsd->lsd_start_epoch);
+
+        CDEBUG(D_INODE, "%s: server start_epoch : %#x\n",
+               obd->obd_name, start_epoch);
+        CDEBUG(D_INODE, "%s: server last_transno : "LPX64"\n",
                obd->obd_name, le64_to_cpu(fsd->lsd_last_transno));
         CDEBUG(D_INODE, "%s: server mount_count: "LPU64"\n",
                obd->obd_name, mount_count + 1);
@@ -836,20 +951,34 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp)
                         /* can't fail for existing client */
                         LASSERTF(rc == 0, "rc = %d\n", rc);
 
-                        lcd = NULL;
+                        /* VBR: set export last committed */
+                        exp->exp_last_committed = last_rcvd;
+                        /* read last time from disk */
+                        exp->exp_last_request_time = target_trans_table_last_time(exp);
 
                         spin_lock(&exp->exp_lock);
                         exp->exp_replay_needed = 1;
                         exp->exp_connecting = 0;
+                        exp->exp_in_recovery = 0;
                         spin_unlock(&exp->exp_lock);
 
+                        spin_lock_bh(&obd->obd_processing_task_lock);
                         obd->obd_recoverable_clients++;
                         obd->obd_max_recoverable_clients++;
+                        spin_unlock_bh(&obd->obd_processing_task_lock);
+
+                        /* VBR: if epoch too old mark export as delayed,
+                         * if epoch is zero then client is pre-vbr one */
+                        if (start_epoch > le32_to_cpu(lcd->lcd_last_epoch) &&
+                            le32_to_cpu(lcd->lcd_last_epoch) != 0)
+                                class_set_export_delayed(exp);
+
+                        lcd = NULL;
                         class_export_put(exp);
                 }
 
                 /* Need to check last_rcvd even for duplicated exports. */
-                CDEBUG(D_OTHER, "client at idx %d has last_rcvd = "LPU64"\n",
+                CDEBUG(D_OTHER, "client at idx %d has last_rcvd = "LPX64"\n",
                        cl_idx, last_rcvd);
 
                 if (last_rcvd > le64_to_cpu(fsd->lsd_last_transno))
@@ -863,8 +992,9 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp)
 
         if (obd->obd_recoverable_clients) {
                 CWARN("RECOVERY: service %s, %d recoverable clients, "
-                      "last_rcvd "LPU64"\n", obd->obd_name,
-                      obd->obd_recoverable_clients,
+                      "%d delayed clients, last_rcvd "LPU64"\n",
+                      obd->obd_name, obd->obd_recoverable_clients,
+                      obd->obd_delayed_clients,
                       le64_to_cpu(fsd->lsd_last_transno));
                 obd->obd_next_recovery_transno = obd->obd_last_committed + 1;
                 obd->obd_recovering = 1;
@@ -875,8 +1005,11 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp)
                 /* b13079: this should be set to desired value for ost */
                 obd->obd_recovery_max_time = OBD_RECOVERY_MAX_TIME;
 #endif
+        } else {
+                LASSERT(!obd->obd_recovering);
+                /* VBR: update boot epoch after recovery */
+                filter_update_last_epoch(obd);
         }
-
 out:
         filter->fo_mount_count = mount_count + 1;
         fsd->lsd_mount_count = cpu_to_le64(filter->fo_mount_count);
@@ -955,7 +1088,7 @@ static int filter_prep_groups(struct obd_device *obd)
         int i, rc = 0, cleanup_phase = 0;
         ENTRY;
 
-        O_dentry = simple_mkdir(current->fs->pwd, filter->fo_vfsmnt,
+        O_dentry = simple_mkdir(cfs_fs_pwd(current->fs), filter->fo_vfsmnt,
                                 "O", 0700, 1);
         CDEBUG(D_INODE, "got/created O: %p\n", O_dentry);
         if (IS_ERR(O_dentry)) {
@@ -1100,7 +1233,7 @@ static int filter_prep(struct obd_device *obd)
                        HEALTH_CHECK, rc);
                 GOTO(err_filp, rc);
         }
-        filter->fo_health_check_filp = file;
+        filter->fo_obt.obt_health_check_filp = file;
         if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
                 CERROR("%s is not a regular file!: mode = %o\n", HEALTH_CHECK,
                        file->f_dentry->d_inode->i_mode);
@@ -1122,9 +1255,9 @@ static int filter_prep(struct obd_device *obd)
         //class_disconnect_exports(obd, 0);
         filter_free_server_data(filter);
  err_health_check:
-        if (filp_close(filter->fo_health_check_filp, 0))
+        if (filp_close(filter->fo_obt.obt_health_check_filp, 0))
                 CERROR("can't close %s after error\n", HEALTH_CHECK);
-        filter->fo_health_check_filp = NULL;
+        filter->fo_obt.obt_health_check_filp = NULL;
  err_filp:
         if (filp_close(filter->fo_rcvd_filp, 0))
                 CERROR("can't close %s after error\n", LAST_RCVD);
@@ -1161,8 +1294,8 @@ static void filter_post(struct obd_device *obd)
         if (rc)
                 CERROR("error closing %s: rc = %d\n", LAST_RCVD, rc);
 
-        rc = filp_close(filter->fo_health_check_filp, 0);
-        filter->fo_health_check_filp = NULL;
+        rc = filp_close(filter->fo_obt.obt_health_check_filp, 0);
+        filter->fo_obt.obt_health_check_filp = NULL;
         if (rc)
                 CERROR("error closing %s: rc = %d\n", HEALTH_CHECK, rc);
 
@@ -1486,14 +1619,11 @@ static int filter_intent_policy(struct ldlm_namespace *ns,
 
         //fixup_handle_for_resent_req(req, lock, &lockh);
 
-        /* If we grant any lock at all, it will be a whole-file read lock.
-         * Call the extent policy function to see if our request can be
+        /* Call the extent policy function to see if our request can be
          * granted, or is blocked.
-         * If the OST lock has LDLM_FL_HAS_INTENT set, it means a glimpse lock
+         * If the OST lock has LDLM_FL_HAS_INTENT set, it means a glimpse
+         * lock, and should not be granted if the lock will be blocked.
          */
-        lock->l_policy_data.l_extent.start = 0;
-        lock->l_policy_data.l_extent.end = OBD_OBJECT_EOF;
-        lock->l_req_mode = LCK_PR;
 
         LASSERT(ns == res->lr_namespace);
         lock_res(res);
@@ -1724,7 +1854,7 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
         char *str, *label;
         char ns_name[48];
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,9)
-        request_queue_t *q;
+        struct request_queue *q;
 #endif
         int rc;
         ENTRY;
@@ -1782,6 +1912,9 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
 
         filter->fo_vfsmnt = mnt;
         obd->u.obt.obt_sb = mnt->mnt_sb;
+        obd->u.obt.obt_stale_export_age = STALE_EXPORT_MAXTIME_DEFAULT;
+        spin_lock_init(&obd->u.obt.obt_trans_table_lock);
+
         filter->fo_fstype = mnt->mnt_sb->s_type->name;
         CDEBUG(D_SUPER, "%s: mnt = %p\n", filter->fo_fstype, mnt);
 
@@ -1795,10 +1928,6 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
         obd->obd_lvfs_ctxt.fs = get_ds();
         obd->obd_lvfs_ctxt.cb_ops = filter_lvfs_ops;
 
-        rc = filter_prep(obd);
-        if (rc)
-                GOTO(err_ops, rc);
-
         filter->fo_destroy_in_progress = 0;
         sema_init(&filter->fo_create_lock, 1);
         spin_lock_init(&filter->fo_translock);
@@ -1806,9 +1935,16 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
         INIT_LIST_HEAD(&filter->fo_export_list);
         sema_init(&filter->fo_alloc_lock, 1);
         init_brw_stats(&filter->fo_filter_stats);
+        filter->fo_read_cache = 1; /* enable read-only cache by default */
+        filter->fo_writethrough_cache = 1; /* enable writethrough cache */
         filter->fo_readcache_max_filesize = FILTER_MAX_CACHE_SIZE;
         filter->fo_fmd_max_num = FILTER_FMD_MAX_NUM_DEFAULT;
         filter->fo_fmd_max_age = FILTER_FMD_MAX_AGE_DEFAULT;
+        filter->fo_syncjournal = 1; /* Sync journals on i/o by default b=19128 */
+
+        rc = filter_prep(obd);
+        if (rc)
+                GOTO(err_ops, rc);
 
         sprintf(ns_name, "filter-%s", obd->obd_uuid.uuid);
         obd->obd_namespace = ldlm_namespace_new(obd, ns_name, LDLM_NAMESPACE_SERVER,
@@ -1856,17 +1992,14 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
         if (obd->obd_recovering) {
                 LCONSOLE_WARN("OST %s now serving %s (%s%s%s), but will be in "
                               "recovery for at least %d:%.02d, or until %d "
-                              "client%s reconnect. During this time new clients"
-                              " will not be allowed to connect. "
-                              "Recovery progress can be monitored by watching "
-                              "/proc/fs/lustre/obdfilter/%s/recovery_status.\n",
+                              "client%s reconnect%s.\n",
                               obd->obd_name, lustre_cfg_string(lcfg, 1),
                               label ?: "", label ? "/" : "", str,
                               obd->obd_recovery_timeout / 60,
                               obd->obd_recovery_timeout % 60,
-                              obd->obd_max_recoverable_clients,
-                              (obd->obd_max_recoverable_clients == 1) ? "":"s",
-                              obd->obd_name);
+                              obd->obd_recoverable_clients,
+                              obd->obd_recoverable_clients == 1 ? "":"s",
+                              obd->obd_recoverable_clients == 1 ? "s":"");
         } else {
                 LCONSOLE_INFO("OST %s now serving %s (%s%s%s) with recovery "
                               "%s\n", obd->obd_name, lustre_cfg_string(lcfg, 1),
@@ -1920,14 +2053,32 @@ static int filter_setup(struct obd_device *obd, obd_count len, void *buf)
                 lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_WRITE_BYTES,
                                      LPROCFS_CNTR_AVGMINMAX,
                                      "write_bytes", "bytes");
+                lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_GET_PAGE,
+                                     LPROCFS_CNTR_AVGMINMAX|LPROCFS_CNTR_STDDEV,
+                                     "get_page", "usec");
+                lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_NO_PAGE,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "get_page failures", "num");
+                lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_CACHE_ACCESS,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "cache_access", "pages");
+                lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_CACHE_HIT,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "cache_hit", "pages");
+                lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_CACHE_MISS,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "cache_miss", "pages");
                 lproc_filter_attach_seqstat(obd);
+#ifdef HAVE_DELAYED_RECOVERY
+                lprocfs_obd_attach_stale_exports(obd);
+#endif
                 obd->obd_proc_exports_entry = proc_mkdir("exports",
                                                          obd->obd_proc_entry);
         }
         if (obd->obd_proc_exports_entry)
                 lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
                                    lprocfs_nid_stats_clear_read,
-                                   lprocfs_nid_stats_clear_write, obd);
+                                   lprocfs_nid_stats_clear_write, obd, NULL);
 
         memcpy((void *)addr, lustre_cfg_buf(lcfg, 4),
                LUSTRE_CFG_BUFLEN(lcfg, 4));
@@ -2095,7 +2246,7 @@ static int filter_cleanup(struct obd_device *obd)
 
         filter_post(obd);
 
-        LL_DQUOT_OFF(obd->u.obt.obt_sb);
+        LL_DQUOT_OFF(obd->u.obt.obt_sb, 0);
         shrink_dcache_sb(obd->u.obt.obt_sb);
 
         server_put_mount(obd->obd_name, filter->fo_vfsmnt);
@@ -2126,7 +2277,13 @@ static int filter_connect_internal(struct obd_export *exp,
         exp->exp_connect_flags = data->ocd_connect_flags;
         data->ocd_version = LUSTRE_VERSION_CODE;
 
+        /* Kindly make sure the SKIP_ORPHAN flag is from MDS. */
+        if (!ergo(data->ocd_connect_flags & OBD_CONNECT_SKIP_ORPHAN,
+                  data->ocd_connect_flags & OBD_CONNECT_MDS))
+                RETURN(-EPROTO);
+
         if (exp->exp_connect_flags & OBD_CONNECT_GRANT) {
+                struct filter_obd *filter = &exp->exp_obd->u.filter;
                 struct filter_export_data *fed = &exp->exp_filter_data;
                 obd_size left, want;
 
@@ -2141,6 +2298,8 @@ static int filter_connect_internal(struct obd_export *exp,
                        LPU64" left: "LPU64"\n", exp->exp_obd->obd_name,
                        exp->exp_client_uuid.uuid, exp,
                        data->ocd_grant, want, left);
+                
+                filter->fo_tot_granted_clients ++;
         }
 
         if (data->ocd_connect_flags & OBD_CONNECT_INDEX) {
@@ -2277,6 +2436,7 @@ cleanup:
                         fed->fed_lcd = NULL;
                 }
                 class_disconnect(exp);
+                lprocfs_exp_cleanup(exp);
         } else {
                 class_export_put(exp);
         }
@@ -2448,10 +2608,18 @@ static int filter_disconnect(struct obd_export *exp)
                 llog_ctxt_put(ctxt);
         }
 
+        if (exp->exp_connect_flags & OBD_CONNECT_GRANT_SHRINK) {
+                struct filter_obd *filter = &exp->exp_obd->u.filter;
+                if (filter->fo_tot_granted_clients > 0)
+                        filter->fo_tot_granted_clients --;
+        }
+
         if (!(exp->exp_flags & OBD_OPT_FORCE))
                 filter_grant_sanity_check(obd, __FUNCTION__);
         filter_grant_discard(exp);
 
+        lquota_clearinfo(filter_quota_interface_ref, exp, exp->exp_obd);
+
         /* Disconnect early so that clients can't keep using export */
         rc = class_disconnect(exp);
         if (exp->exp_obd->obd_namespace != NULL)
@@ -2466,6 +2634,9 @@ static int filter_ping(struct obd_export *exp)
 {
         filter_fmd_expire(exp);
 
+        if (exp->exp_delayed)
+                filter_update_client_epoch(exp);
+
         return 0;
 }
 
@@ -2566,7 +2737,8 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
         unsigned int orig_ids[MAXQUOTAS] = {0, 0};
         struct llog_cookie *fcc = NULL;
         struct filter_obd *filter;
-        int rc, err, locked = 0, sync = 0;
+        int rc, err, sync = 0;
+        loff_t old_size = 0;
         unsigned int ia_valid;
         struct inode *inode;
         struct iattr iattr;
@@ -2588,13 +2760,22 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
                 if (fcc != NULL)
                         *fcc = oa->o_lcookie;
         }
-
-        if (ia_valid & ATTR_SIZE || ia_valid & (ATTR_UID | ATTR_GID)) {
+        if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID)) {
                 DQUOT_INIT(inode);
+                /* Filter truncates and writes are serialized by
+                 * i_alloc_sem, see the comment in
+                 * filter_preprw_write.*/
+                if (ia_valid & ATTR_SIZE)
+                        down_write(&inode->i_alloc_sem);
                 LOCK_INODE_MUTEX(inode);
-                locked = 1;
+                old_size = i_size_read(inode);
         }
 
+        /* VBR: version recovery check */
+        rc = filter_version_get_check(exp, oti, inode);
+        if (rc)
+                GOTO(out_unlock, rc);
+
         /* If the inode still has SUID+SGID bits set (see filter_precreate())
          * then we will accept the UID+GID sent by the client during write for
          * initializing the ownership of this inode.  We only allow this to
@@ -2642,8 +2823,8 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
         }
 
         if (oa->o_valid & OBD_MD_FLFLAGS) {
-                rc = fsfilt_iocontrol(exp->exp_obd, inode, NULL,
-                                      EXT3_IOC_SETFLAGS, (long)&oa->o_flags);
+                rc = fsfilt_iocontrol(exp->exp_obd, dentry,
+                                      FSFILT_IOC_SETFLAGS, (long)&oa->o_flags);
         } else {
                 rc = fsfilt_setattr(exp->exp_obd, dentry, handle, &iattr, 1);
                 if (fcc != NULL)
@@ -2659,7 +2840,7 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
         /* The truncate might have used up our transaction credits.  Make
          * sure we have one left for the last_rcvd update. */
         err = fsfilt_extend(exp->exp_obd, inode, 1, handle);
-        rc = filter_finish_transno(exp, oti, rc, sync);
+        rc = filter_finish_transno(exp, inode, oti, rc, sync);
         if (sync) {
                 filter_cancel_cookies_cb(exp->exp_obd, 0, fcc, rc);
                 fcc = NULL;
@@ -2674,23 +2855,22 @@ int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry,
                 fcc = NULL;
         }
 
-        if (locked) {
-                /* Let's flush truncated page on disk immediately, then we can
-                 * avoid need to search for page aliases before directio writes
-                 * and this sort of stuff at expense of somewhat slower
-                 * truncates not on a page boundary. I believe this is the only
-                 * place in filter code that can lead to pages getting to
-                 * pagecache so far. */
-                filter_clear_truncated_page(inode);
-                UNLOCK_INODE_MUTEX(inode);
-                locked = 0;
+        /* For a partial-page truncate flush the page to disk immediately
+         * to avoid data corruption during direct disk write. b=17397 */
+        if (!sync && (iattr.ia_valid & ATTR_SIZE) &&
+            old_size != iattr.ia_size && (iattr.ia_size & ~CFS_PAGE_MASK)) {
+                err = filemap_fdatawrite_range(inode->i_mapping, iattr.ia_size,
+                                               iattr.ia_size + 1);
+                if (!rc)
+                        rc = err;
         }
 
         EXIT;
 out_unlock:
-        if (locked)
+        if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID))
                 UNLOCK_INODE_MUTEX(inode);
-
+        if (ia_valid & ATTR_SIZE)
+                up_write(&inode->i_alloc_sem);
         if (fcc)
                 OBD_FREE(fcc, sizeof(*fcc));
 
@@ -2715,7 +2895,7 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
         struct filter_obd *filter;
         struct ldlm_resource *res;
         struct dentry *dentry;
-        int rc;
+        int rc = 0;
         ENTRY;
 
         dentry = __filter_oa2dentry(exp->exp_obd, oinfo->oi_oa,
@@ -2819,11 +2999,12 @@ static int filter_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
 
 /* caller must hold fo_create_lock */
 static int filter_destroy_precreated(struct obd_export *exp, struct obdo *oa,
-                                      struct filter_obd *filter)
+                                     struct filter_obd *filter)
 {
-        struct obdo doa; /* XXX obdo on stack */
+        struct obdo doa = { 0 }; /* XXX obdo on stack */
         obd_id last, id;
-        int rc;
+        int rc = 0;
+        int skip_orphan;
         ENTRY;
 
         LASSERT(oa);
@@ -2845,25 +3026,37 @@ static int filter_destroy_precreated(struct obd_export *exp, struct obdo *oa,
         }
 
         last = filter_last_id(filter, doa.o_gr);
-        CWARN("%s: deleting orphan objects from "LPU64" to "LPU64"\n",
-               exp->exp_obd->obd_name, oa->o_id + 1, last);
+        skip_orphan = !!(exp->exp_connect_flags & OBD_CONNECT_SKIP_ORPHAN);
+
+        CWARN("%s: deleting orphan objects from "LPU64" to "LPU64"%s\n",
+               exp->exp_obd->obd_name, oa->o_id + 1, last,
+               skip_orphan ? ", orphan objids won't be reused any more." : ".");
+
         for (id = last; id > oa->o_id; id--) {
                 doa.o_id = id;
                 rc = filter_destroy(exp, &doa, NULL, NULL, NULL);
                 if (rc && rc != -ENOENT) /* this is pretty fatal... */
                         CEMERG("error destroying precreate objid "LPU64": %d\n",
                                id, rc);
-                filter_set_last_id(filter, id - 1, doa.o_gr);
                 /* update last_id on disk periodically so that if we restart
                  * we don't need to re-scan all of the just-deleted objects. */
-                if ((id & 511) == 0)
+                if ((id & 511) == 0 && !skip_orphan) {
+                        filter_set_last_id(filter, id - 1, doa.o_gr);
                         filter_update_last_objid(exp->exp_obd, doa.o_gr, 0);
+                }
         }
 
         CDEBUG(D_HA, "%s: after destroy: set last_objids["LPU64"] = "LPU64"\n",
                exp->exp_obd->obd_name, doa.o_gr, oa->o_id);
 
-        rc = filter_update_last_objid(exp->exp_obd, doa.o_gr, 1);
+        if (!skip_orphan) {
+                filter_set_last_id(filter, id, doa.o_gr);
+                rc = filter_update_last_objid(exp->exp_obd, doa.o_gr, 1);
+        } else {
+                /* don't reuse orphan object, return last used objid */
+                oa->o_id = last;
+                rc = 0;
+        }
         filter->fo_destroy_in_progress = 0;
 
         RETURN(rc);
@@ -2977,7 +3170,7 @@ static int filter_statfs(struct obd_device *obd, struct obd_statfs *osfs,
          * stop creating files on MDS if OST is not good shape to create
          * objects.*/
         osfs->os_state = (filter->fo_obt.obt_sb->s_flags & MS_RDONLY) ?
-                EROFS : 0;
+                OS_STATE_READONLY : 0;
         RETURN(rc);
 }
 
@@ -3126,7 +3319,7 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa,
                 cleanup_phase = 3;
 
                 CDEBUG(D_INODE, "%s: filter_precreate(od->o_gr="LPU64
-                       ",od->o_id="LPU64")\n", obd->obd_name, group, 
+                       ",od->o_id="LPU64")\n", obd->obd_name, group,
                        next_id);
 
                 /* We mark object SUID+SGID to flag it for accepting UID+GID
@@ -3138,6 +3331,9 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa,
                         CERROR("create failed rc = %d\n", rc);
                         GOTO(cleanup, rc);
                 }
+                if (dchild->d_inode)
+                        CDEBUG(D_INFO, "objid "LPU64" got inum %lu\n", next_id,
+                                       dchild->d_inode->i_ino);
 
 set_last_id:
                 if (!recreate_obj) {
@@ -3194,16 +3390,22 @@ int filter_recreate(struct obd_device *obd, struct obdo *oa)
         ENTRY;
 
         if (oa->o_id > filter_last_id(&obd->u.filter, oa->o_gr)) {
-                CERROR("recreate objid "LPU64" > last id "LPU64"\n",
-                       oa->o_id, filter_last_id(&obd->u.filter, oa->o_gr));
-                RETURN(-EINVAL);
-        }
-
-        if ((oa->o_valid & OBD_MD_FLFLAGS) == 0) {
-                oa->o_valid |= OBD_MD_FLFLAGS;
-                oa->o_flags = OBD_FL_RECREATE_OBJS;
+                if (!obd->obd_recovering ||
+                    oa->o_id > filter_last_id(&obd->u.filter, oa->o_gr) +
+                    OST_MAX_PRECREATE) {
+                        CERROR("recreate objid "LPU64" > last id "LPU64"\n",
+                               oa->o_id, filter_last_id(&obd->u.filter,
+                               oa->o_gr));
+                        RETURN(-EINVAL);
+                }
+                diff = oa->o_id - filter_last_id(&obd->u.filter, oa->o_gr);
         } else {
-                oa->o_flags |= OBD_FL_RECREATE_OBJS;
+                if ((oa->o_valid & OBD_MD_FLFLAGS) == 0) {
+                        oa->o_valid |= OBD_MD_FLFLAGS;
+                        oa->o_flags = OBD_FL_RECREATE_OBJS;
+                } else {
+                        oa->o_flags |= OBD_FL_RECREATE_OBJS;
+                }
         }
 
         down(&obd->u.filter.fo_create_lock);
@@ -3359,6 +3561,12 @@ int filter_destroy(struct obd_export *exp, struct obdo *oa,
          * (see BUG 4180) -bzzz
          */
         LOCK_INODE_MUTEX(dchild->d_inode);
+
+        /* VBR: version recovery check */
+        rc = filter_version_get_check(exp, oti, dchild->d_inode);
+        if (rc)
+                GOTO(cleanup, rc);
+
         handle = fsfilt_start_log(obd, dchild->d_inode, FSFILT_OP_SETATTR,
                                   NULL, 1);
         if (IS_ERR(handle)) {
@@ -3415,7 +3623,7 @@ cleanup:
                  * on commit. then we call callback directly to free
                  * the fcc.
                  */
-                rc = filter_finish_transno(exp, oti, rc, sync);
+                rc = filter_finish_transno(exp, NULL, oti, rc, sync);
                 if (sync) {
                         filter_cancel_cookies_cb(obd, 0, fcc, rc);
                         fcc = NULL;
@@ -3465,7 +3673,7 @@ static int filter_truncate(struct obd_export *exp, struct obd_info *oinfo,
                        oinfo->oi_policy.l_extent.end);
                 RETURN(-EFAULT);
         }
-
+        
         CDEBUG(D_INODE, "calling truncate for object "LPU64", valid = "LPX64
                ", o_size = "LPD64"\n", oinfo->oi_oa->o_id,
                oinfo->oi_oa->o_valid, oinfo->oi_policy.l_extent.start);
@@ -3476,8 +3684,9 @@ static int filter_truncate(struct obd_export *exp, struct obd_info *oinfo,
         RETURN(rc);
 }
 
-static int filter_sync(struct obd_export *exp, struct obdo *oa,
-                       struct lov_stripe_md *lsm, obd_off start, obd_off end)
+static int filter_sync(struct obd_export *exp, struct obd_info *oinfo,
+                       obd_off start, obd_off end,
+                       struct ptlrpc_request_set *set)
 {
         struct lvfs_run_ctxt saved;
         struct filter_obd *filter;
@@ -3489,7 +3698,7 @@ static int filter_sync(struct obd_export *exp, struct obdo *oa,
         filter = &exp->exp_obd->u.filter;
 
         /* An objid of zero is taken to mean "sync whole filesystem" */
-        if (!oa || !(oa->o_valid & OBD_MD_FLID)) {
+        if (!oinfo->oi_oa || !(oinfo->oi_oa->o_valid & OBD_MD_FLID)) {
                 rc = fsfilt_sync(exp->exp_obd, filter->fo_obt.obt_sb);
 
                 /* Flush any remaining cancel messages out to the target */
@@ -3504,7 +3713,7 @@ static int filter_sync(struct obd_export *exp, struct obdo *oa,
                 RETURN(rc);
         }
 
-        dentry = filter_oa2dentry(exp->exp_obd, oa);
+        dentry = filter_oa2dentry(exp->exp_obd, oinfo->oi_oa);
         if (IS_ERR(dentry))
                 RETURN(PTR_ERR(dentry));
 
@@ -3526,8 +3735,8 @@ static int filter_sync(struct obd_export *exp, struct obdo *oa,
         }
         UNLOCK_INODE_MUTEX(dentry->d_inode);
 
-        oa->o_valid = OBD_MD_FLID;
-        obdo_from_inode(oa, dentry->d_inode, FILTER_VALID_FLAGS);
+        oinfo->oi_oa->o_valid = OBD_MD_FLID;
+        obdo_from_inode(oinfo->oi_oa, dentry->d_inode, FILTER_VALID_FLAGS);
 
         pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
 
@@ -3602,16 +3811,13 @@ static int filter_get_info(struct obd_export *exp, __u32 keylen,
 
                 memcpy(fiemap, &fm_key->fiemap, sizeof(*fiemap));
                 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-                rc = fsfilt_iocontrol(obd, dentry->d_inode, NULL,
-                                      EXT3_IOC_FIEMAP, (long)fiemap);
-                if (rc) {
-                        f_dput(dentry);
-                        RETURN(rc);
-                }
+
+                rc = fsfilt_iocontrol(obd, dentry, FSFILT_IOC_FIEMAP,
+                                      (long)fiemap);
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
                 f_dput(dentry);
-                RETURN(0);
+                RETURN(rc);
         }
 
         CDEBUG(D_IOCTL, "invalid key\n");
@@ -3633,6 +3839,19 @@ static int filter_set_info_async(struct obd_export *exp, __u32 keylen,
                 RETURN(-EINVAL);
         }
 
+	if (KEY_IS(KEY_GRANT_SHRINK)) {
+                struct ost_body *body = (struct ost_body *)val;
+                /* handle shrink grant */
+                spin_lock(&exp->exp_obd->obd_osfs_lock);
+                filter_grant_incoming(exp, &body->oa);
+                spin_unlock(&exp->exp_obd->obd_osfs_lock);
+                RETURN(rc);
+        }
+
+        if (KEY_IS(KEY_CAPA_KEY)) {
+                RETURN(0);
+        }
+
         if (!KEY_IS(KEY_MDS_CONN))
                 RETURN(-EINVAL);
 
@@ -3709,8 +3928,6 @@ int filter_iocontrol(unsigned int cmd, struct obd_export *exp,
                 RETURN(rc);
 */
         }
-
-
         default:
                 RETURN(-EINVAL);
         }
@@ -3732,8 +3949,8 @@ static int filter_health_check(struct obd_device *obd)
                 rc = 1;
 
 #ifdef USE_HEALTH_CHECK_WRITE
-        LASSERT(filter->fo_health_check_filp != NULL);
-        rc |= !!lvfs_check_io_health(obd, filter->fo_health_check_filp);
+        LASSERT(filter->fo_obt.obt_health_check_filp != NULL);
+        rc |= !!lvfs_check_io_health(obd, filter->fo_obt.obt_health_check_filp);
 #endif
 
         return rc;
@@ -3762,6 +3979,23 @@ static struct lvfs_callback_ops filter_lvfs_ops = {
         l_fid2dentry:     filter_lvfs_fid2dentry,
 };
 
+static int filter_notify(struct obd_device *obd, struct obd_device *watched,
+                         enum obd_notify_event ev, void *data)
+{
+        ENTRY;
+
+        CDEBUG(D_CONFIG, "notify %s ev=%d\n", watched->obd_name, ev);
+
+        switch (ev) {
+        case OBD_NOTIFY_CONFIG:
+                /* call this only when config is processed and stale_export_age
+                 * value is configured */
+                class_disconnect_expired_exports(obd);
+        default:
+                RETURN(0);
+        }
+}
+
 static struct obd_ops filter_obd_ops = {
         .o_owner          = THIS_MODULE,
         .o_get_info       = filter_get_info,
@@ -3791,6 +4025,8 @@ static struct obd_ops filter_obd_ops = {
         .o_iocontrol      = filter_iocontrol,
         .o_health_check   = filter_health_check,
         .o_process_config = filter_process_config,
+        .o_postrecov      = filter_postrecov,
+        .o_notify         = filter_notify,
 };
 
 quota_interface_t *filter_quota_interface_ref;
diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h
index b0547a9..1990c7a 100644
--- a/lustre/obdfilter/filter_internal.h
+++ b/lustre/obdfilter/filter_internal.h
@@ -59,6 +59,7 @@
                               OBD_INCOMPAT_COMMON_LR)
 
 #define FILTER_GRANT_CHUNK (2ULL * PTLRPC_MAX_BRW_SIZE)
+#define FILTER_GRANT_SHRINK_LIMIT (16ULL * FILTER_GRANT_CHUNK)
 #define GRANT_FOR_LLOG(obd) 16
 
 extern struct file_operations filter_per_export_stats_fops;
@@ -87,6 +88,12 @@ struct filter_mod_data {
 /* Client cache seconds */
 #define FILTER_FMD_MAX_AGE_DEFAULT ((obd_timeout + 10) * HZ)
 
+#ifndef HAVE_PAGE_CONSTANT
+#define mapping_cap_page_constant_write(mapping) 0
+#define SetPageConstant(page) do {} while (0)
+#define ClearPageConstant(page) do {} while (0)
+#endif
+
 struct filter_mod_data *filter_fmd_find(struct obd_export *exp,
                                         obd_id objid, obd_gr group);
 struct filter_mod_data *filter_fmd_get(struct obd_export *exp,
@@ -97,6 +104,11 @@ void filter_fmd_expire(struct obd_export *exp);
 enum {
         LPROC_FILTER_READ_BYTES = 0,
         LPROC_FILTER_WRITE_BYTES = 1,
+        LPROC_FILTER_GET_PAGE = 2,
+        LPROC_FILTER_NO_PAGE = 3,
+        LPROC_FILTER_CACHE_ACCESS = 4,
+        LPROC_FILTER_CACHE_HIT = 5,
+        LPROC_FILTER_CACHE_MISS = 6,
         LPROC_FILTER_LAST,
 };
 
@@ -116,8 +128,8 @@ struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa,
                                   const char *what, int quiet);
 #define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__, 0)
 
-int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc,
-                          int force_sync);
+int filter_finish_transno(struct obd_export *, struct inode *,
+                          struct obd_trans_info *, int rc, int force_sync);
 __u64 filter_next_id(struct filter_obd *, struct obdo *);
 __u64 filter_last_id(struct filter_obd *, obd_gr group);
 int filter_update_fidea(struct obd_export *exp, struct inode *inode,
@@ -144,19 +156,20 @@ extern struct ldlm_valblock_ops filter_lvbo;
 
 /* filter_io.c */
 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
-                  struct obd_ioobj *, int niocount, struct niobuf_remote *,
-                  struct niobuf_local *, struct obd_trans_info *);
+                  struct obd_ioobj *, struct niobuf_remote *,
+                  int *, struct niobuf_local *, struct obd_trans_info *);
 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
-                    struct obd_ioobj *, int niocount, struct niobuf_local *,
-                    struct obd_trans_info *, int rc);
+                    struct obd_ioobj *, struct niobuf_remote *,  int,
+                    struct niobuf_local *, struct obd_trans_info *, int rc);
 int filter_brw(int cmd, struct obd_export *, struct obd_info *oinfo,
                obd_count oa_bufs, struct brw_page *pga, struct obd_trans_info *);
-void flip_into_page_cache(struct inode *inode, struct page *new_page);
+void filter_release_cache(struct obd_device *, struct obd_ioobj *,
+                          struct niobuf_remote *, struct inode *);
 
 /* filter_io_*.c */
 struct filter_iobuf;
 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
-                          struct obd_ioobj *obj, int niocount,
+                          struct obd_ioobj *obj, struct niobuf_remote *, int,
                           struct niobuf_local *res, struct obd_trans_info *oti,
                           int rc);
 obd_size filter_grant_space_left(struct obd_export *exp);
@@ -164,6 +177,7 @@ long filter_grant(struct obd_export *exp, obd_size current_grant,
                   obd_size want, obd_size fs_space_left);
 void filter_grant_commit(struct obd_export *exp, int niocount,
                          struct niobuf_local *res);
+void filter_grant_incoming(struct obd_export *exp, struct obdo *oa);
 struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *, int rw,
                                         int num_pages);
 void filter_free_iobuf(struct filter_iobuf *iobuf);
diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c
index d8f5707..56ecb74 100644
--- a/lustre/obdfilter/filter_io.c
+++ b/lustre/obdfilter/filter_io.c
@@ -55,41 +55,10 @@
 
 int *obdfilter_created_scratchpad;
 
-static int filter_alloc_dio_page(struct obd_device *obd, struct inode *inode,
-                                 struct niobuf_local *lnb)
-{
-        struct page *page;
-
-        LASSERT(lnb->page != NULL);
-
-        page = lnb->page;
-#if 0
-        POISON_PAGE(page, 0xf1);
-        if (lnb->len != CFS_PAGE_SIZE) {
-                memset(kmap(page) + lnb->len, 0, CFS_PAGE_SIZE - lnb->len);
-                kunmap(page);
-        }
-#endif
-        page->index = lnb->offset >> CFS_PAGE_SHIFT;
-
-        RETURN(0);
-}
-
-static void filter_free_dio_pages(int objcount, struct obd_ioobj *obj,
-                           int niocount, struct niobuf_local *res)
-{
-        int i, j;
-
-        for (i = 0; i < objcount; i++, obj++) {
-                for (j = 0 ; j < obj->ioo_bufcnt ; j++, res++)
-                                res->page = NULL;
-        }
-}
-
 /* Grab the dirty and seen grant announcements from the incoming obdo.
  * We will later calculate the clients new grant and return it.
  * Caller must hold osfs lock */
-static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
+void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
 {
         struct filter_export_data *fed;
         struct obd_device *obd = exp->exp_obd;
@@ -138,6 +107,26 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
         obd->u.filter.fo_tot_granted -= oa->o_dropped;
         fed->fed_grant -= oa->o_dropped;
         fed->fed_dirty = oa->o_dirty;
+
+        if (oa->o_flags & OBD_FL_SHRINK_GRANT) {
+                obd_size left_space = filter_grant_space_left(exp);
+                struct filter_obd *filter = &exp->exp_obd->u.filter;
+
+                /*Only if left_space < fo_tot_clients * 32M, 
+                 *then the grant space could be shrinked */
+                if (left_space < filter->fo_tot_granted_clients * 
+                                 FILTER_GRANT_SHRINK_LIMIT) { 
+                        fed->fed_grant -= oa->o_grant;
+                        filter->fo_tot_granted -= oa->o_grant;
+                        CDEBUG(D_CACHE, "%s: cli %s/%p shrink "LPU64
+                               "fed_grant %ld total "LPU64"\n",
+                               obd->obd_name, exp->exp_client_uuid.uuid,
+                               exp, oa->o_grant, fed->fed_grant,
+                               filter->fo_tot_granted);
+                        oa->o_grant = 0;
+                }
+        }
+
         if (fed->fed_dirty < 0 || fed->fed_grant < 0 || fed->fed_pending < 0) {
                 CERROR("%s: cli %s/%p dirty %ld pend %ld grant %ld\n",
                        obd->obd_name, exp->exp_client_uuid.uuid, exp,
@@ -271,21 +260,130 @@ long filter_grant(struct obd_export *exp, obd_size current_grant,
         return grant;
 }
 
+/*
+ * the routine is used to request pages from pagecache
+ *
+ * use GFP_NOFS not allowing to enter FS as the client can run on this node
+ * and we might end waiting on a page he sent in the request we're serving.
+ *
+ * use __GFP_HIGHMEM so that the pages can use all of the available memory
+ * on 32-bit machines
+ *
+ */
+static struct page * filter_get_page(struct obd_device *obd,
+                                     struct inode *inode,
+                                     obd_off offset)
+{
+        struct page *page;
+
+        /* __GFP_NOMEMALLOC = don't use emergency reserves because it
+         * can cause atomic allocations to fail. See bug 19917.
+         * For local (same node) client, we should really be using
+         * GFP_NOFS | __GFP_HIGHMEM instead. This will be addressed
+         * by bug 19529 */
+        page = find_or_create_page(inode->i_mapping, offset >> CFS_PAGE_SHIFT,
+                                   GFP_HIGHUSER  | __GFP_NOMEMALLOC);
+        if (unlikely(page == NULL))
+                lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_NO_PAGE, 1);
+
+        return page;
+}
+
+/*
+ * the routine initializes array of local_niobuf from remote_niobuf
+ */
+static int filter_map_remote_to_local(int objcount, struct obd_ioobj *obj,
+                                      struct niobuf_remote *nb,
+                                      int *nrpages, struct niobuf_local *res)
+{
+        struct niobuf_remote *rnb;
+        struct niobuf_local *lnb;
+        int i, max;
+        ENTRY;
+
+        /* we don't support multiobject RPC yet
+         * ost_brw_read() and ost_brw_write() check this */
+        LASSERT(objcount == 1);
+
+        max = *nrpages;
+        *nrpages = 0;
+        for (i = 0, rnb = nb, lnb = res; i < obj->ioo_bufcnt; i++, rnb++) {
+                obd_off offset = rnb->offset;
+                unsigned int len = rnb->len;
+
+                while (len > 0) {
+                        int poff = offset & (CFS_PAGE_SIZE - 1);
+                        int plen = CFS_PAGE_SIZE - poff;
+
+                        if (*nrpages >= max) {
+                                CERROR("small array of local bufs: %d\n", max);
+                                RETURN(-EINVAL);
+                        }
+
+                        if (plen > len)
+                                plen = len;
+                        lnb->offset = offset;
+                        lnb->len = plen;
+                        lnb->flags = rnb->flags;
+                        lnb->page = NULL;
+                        lnb->rc = 0;
+                        lnb->lnb_grant_used = 0;
+
+                        LASSERTF(plen <= len, "plen %u, len %u\n", plen, len);
+                        offset += plen;
+                        len -= plen;
+                        lnb++;
+                        (*nrpages)++;
+                }
+        }
+        RETURN(0);
+}
+
+/*
+ * Invalidating the pages to get them out of cache doesn't work because
+ * LNET pins the pages.  Instead (on newer kernels) the pages are truncated
+ * from the cache, while older kernels (RHEL4 and SLES9) just leave them in
+ * the cache.  b=18718/
+ */
+void filter_release_cache(struct obd_device *obd, struct obd_ioobj *obj,
+                          struct niobuf_remote *rnb, struct inode *inode)
+{
+        int i;
+
+        LASSERT(inode != NULL);
+        for (i = 0; i < obj->ioo_bufcnt; i++, rnb++) {
+#ifdef HAVE_TRUNCATE_RANGE
+                /* remove pages in which range is fit */
+                truncate_inode_pages_range(inode->i_mapping,
+                                           rnb->offset & CFS_PAGE_MASK,
+                                           (rnb->offset + rnb->len - 1) |
+                                           ~CFS_PAGE_MASK);
+#else
+                /* use invalidate for old kernels */
+                invalidate_mapping_pages(inode->i_mapping,
+                                         rnb->offset >> CFS_PAGE_SHIFT,
+                                         (rnb->offset + rnb->len) >>
+                                         CFS_PAGE_SHIFT);
+#endif
+        }
+}
+
 static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
                               int objcount, struct obd_ioobj *obj,
-                              int niocount, struct niobuf_remote *nb,
-                              struct niobuf_local *res,
+                              struct niobuf_remote *nb,
+                              int *pages, struct niobuf_local *res,
                               struct obd_trans_info *oti)
 {
         struct obd_device *obd = exp->exp_obd;
+        struct timeval start, end;
         struct lvfs_run_ctxt saved;
-        struct niobuf_remote *rnb;
         struct niobuf_local *lnb;
         struct dentry *dentry = NULL;
-        struct inode *inode;
+        struct inode *inode = NULL;
         void *iobuf = NULL;
         int rc = 0, i, tot_bytes = 0;
         unsigned long now = jiffies;
+        long timediff;
         ENTRY;
 
         /* We are currently not supporting multi-obj BRW_READ RPCS at all.
@@ -298,7 +396,8 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
                 spin_lock(&obd->obd_osfs_lock);
                 filter_grant_incoming(exp, oa);
 
-                oa->o_grant = 0;
+                if (!(oa->o_flags & OBD_FL_SHRINK_GRANT))
+                        oa->o_grant = 0;
                 spin_unlock(&obd->obd_osfs_lock);
         }
 
@@ -317,28 +416,29 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
         inode = dentry->d_inode;
 
         obdo_to_inode(inode, oa, OBD_MD_FLATIME);
+
+        rc = filter_map_remote_to_local(objcount, obj, nb, pages, res);
+        if (rc)
+                GOTO(cleanup, rc);
+
         fsfilt_check_slow(obd, now, "preprw_read setup");
 
-        for (i = 0, lnb = res, rnb = nb; i < obj->ioo_bufcnt;
-             i++, rnb++, lnb++) {
+        /* find pages for all segments, fill array with them */
+        do_gettimeofday(&start);
+        for (i = 0, lnb = res; i < *pages; i++, lnb++) {
+
                 lnb->dentry = dentry;
-                lnb->offset = rnb->offset;
-                lnb->len    = rnb->len;
-                lnb->flags  = rnb->flags;
-
-                /*
-                 * ost_brw_write()->ost_nio_pages_get() already initialized
-                 * lnb->page to point to the page from the per-thread page
-                 * pool (bug 5137), initialize page.
-                 */
-                LASSERT(lnb->page != NULL);
-
-                if (i_size_read(inode) <= rnb->offset)
+
+                if (i_size_read(inode) <= lnb->offset)
                         /* If there's no more data, abort early.  lnb->rc == 0,
                          * so it's easy to detect later. */
                         break;
-                else
-                        filter_alloc_dio_page(obd, inode, lnb);
+
+                lnb->page = filter_get_page(obd, inode, lnb->offset);
+                if (lnb->page == NULL)
+                        GOTO(cleanup, rc = -ENOMEM);
+
+                lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_CACHE_ACCESS, 1);
 
                 if (i_size_read(inode) < lnb->offset + lnb->len - 1)
                         lnb->rc = i_size_read(inode) - lnb->offset;
@@ -347,8 +447,21 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
 
                 tot_bytes += lnb->rc;
 
+                if (PageUptodate(lnb->page)) {
+                        lprocfs_counter_add(obd->obd_stats,
+                                            LPROC_FILTER_CACHE_HIT, 1);
+                        continue;
+                }
+
+                lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_CACHE_MISS, 1);
                 filter_iobuf_add_page(obd, iobuf, inode, lnb->page);
         }
+        do_gettimeofday(&end);
+        timediff = cfs_timeval_sub(&end, &start, NULL);
+        lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_GET_PAGE, timediff);
+
+        if (OBD_FAIL_CHECK(OBD_FAIL_OST_NOMEM))
+                GOTO(cleanup, rc = -ENOMEM);
 
         fsfilt_check_slow(obd, now, "start_page_read");
 
@@ -365,9 +478,20 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
         EXIT;
 
  cleanup:
-        if (rc != 0) {
-                filter_free_dio_pages(objcount, obj, niocount, res);
+        /* unlock pages to allow access from concurrent OST_READ */
+        for (i = 0, lnb = res; i < *pages; i++, lnb++) {
+                if (lnb->page) {
+                        LASSERT(PageLocked(lnb->page));
+                        unlock_page(lnb->page);
+
+                        if (rc) {
+                                page_cache_release(lnb->page);
+                                lnb->page = NULL;
+                        }
+                }
+        }
 
+        if (rc != 0) {
                 if (dentry != NULL)
                         f_dput(dentry);
         }
@@ -391,9 +515,8 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
  * Caller must hold obd_osfs_lock. */
 static int filter_grant_check(struct obd_export *exp, struct obdo *oa, 
                               int objcount, struct fsfilt_objinfo *fso, 
-                              int niocount, struct niobuf_remote *rnb,
-                              struct niobuf_local *lnb, obd_size *left,
-                              struct inode *inode)
+                              int niocount, struct niobuf_local *lnb,
+                              obd_size *left, struct inode *inode)
 {
         struct filter_export_data *fed = &exp->exp_filter_data;
         int blocksize = exp->exp_obd->u.obt.obt_sb->s_blocksize;
@@ -407,13 +530,13 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
                         int tmp, bytes;
 
                         /* should match the code in osc_exit_cache */
-                        bytes = rnb[n].len;
-                        bytes += rnb[n].offset & (blocksize - 1);
-                        tmp = (rnb[n].offset + rnb[n].len) & (blocksize - 1);
+                        bytes = lnb[n].len;
+                        bytes += lnb[n].offset & (blocksize - 1);
+                        tmp = (lnb[n].offset + lnb[n].len) & (blocksize - 1);
                         if (tmp)
                                 bytes += blocksize - tmp;
 
-                        if ((rnb[n].flags & OBD_BRW_FROM_GRANT) &&
+                        if ((lnb[n].flags & OBD_BRW_FROM_GRANT) &&
                             (oa->o_valid & OBD_MD_FLGRANT)) {
                                 if (fed->fed_grant < used + bytes) {
                                         CDEBUG(D_CACHE,
@@ -424,7 +547,7 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
                                                used, bytes, fed->fed_grant, n);
                                 } else {
                                         used += bytes;
-                                        rnb[n].flags |= OBD_BRW_GRANTED;
+                                        lnb[n].flags |= OBD_BRW_GRANTED;
                                         lnb[n].lnb_grant_used = bytes;
                                         CDEBUG(0, "idx %d used=%lu\n", n, used);
                                         rc = 0;
@@ -434,7 +557,7 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
                         if (*left > ungranted + bytes) {
                                 /* if enough space, pretend it was granted */
                                 ungranted += bytes;
-                                rnb[n].flags |= OBD_BRW_GRANTED;
+                                lnb[n].flags |= OBD_BRW_GRANTED;
                                 lnb[n].lnb_grant_used = bytes;
                                 CDEBUG(0, "idx %d ungranted=%lu\n",n,ungranted);
                                 rc = 0;
@@ -448,7 +571,7 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
                          * marked BRW_GRANTED are already mapped and we can
                          * ignore this error. */
                         lnb[n].rc = -ENOSPC;
-                        rnb[n].flags &= ~OBD_BRW_GRANTED;
+                        lnb[n].flags &= ~OBD_BRW_GRANTED;
                         CDEBUG(D_CACHE,"%s: cli %s/%p idx %d no space for %d\n",
                                exp->exp_obd->obd_name,
                                exp->exp_client_uuid.uuid, exp, n, bytes);
@@ -509,46 +632,74 @@ static int filter_grant_check(struct obd_export *exp, struct obdo *oa,
  * bug) or ensure we get the page locks in an appropriate order. */
 static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
                                int objcount, struct obd_ioobj *obj,
-                               int niocount, struct niobuf_remote *nb,
+                               struct niobuf_remote *nb, int *pages,
                                struct niobuf_local *res,
                                struct obd_trans_info *oti)
 {
+        struct obd_device *obd = exp->exp_obd;
+        struct timeval start, end;
         struct lvfs_run_ctxt saved;
-        struct niobuf_remote *rnb;
         struct niobuf_local *lnb = res;
         struct fsfilt_objinfo fso;
         struct filter_mod_data *fmd;
         struct dentry *dentry = NULL;
         void *iobuf;
         obd_size left;
-        unsigned long now = jiffies;
+        unsigned long now = jiffies, timediff;
         int rc = 0, i, tot_bytes = 0, cleanup_phase = 0;
         ENTRY;
         LASSERT(objcount == 1);
         LASSERT(obj->ioo_bufcnt > 0);
 
-        push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
-        iobuf = filter_iobuf_get(&exp->exp_obd->u.filter, oti);
+        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+        iobuf = filter_iobuf_get(&obd->u.filter, oti);
         if (IS_ERR(iobuf))
                 GOTO(cleanup, rc = PTR_ERR(iobuf));
         cleanup_phase = 1;
 
-        dentry = filter_fid2dentry(exp->exp_obd, NULL, obj->ioo_gr,
-                                   obj->ioo_id);
+        dentry = filter_fid2dentry(obd, NULL, obj->ioo_gr, obj->ioo_id);
         if (IS_ERR(dentry))
                 GOTO(cleanup, rc = PTR_ERR(dentry));
         cleanup_phase = 2;
 
         if (dentry->d_inode == NULL) {
-                CERROR("%s: trying to BRW to non-existent file "LPU64"\n",
-                       exp->exp_obd->obd_name, obj->ioo_id);
-                GOTO(cleanup, rc = -ENOENT);
+                if (exp->exp_obd->obd_recovering) {
+                        struct obdo *noa = oa;
+
+                        if (oa == NULL) {
+                                OBDO_ALLOC(noa);
+                                if (noa == NULL)
+                                        GOTO(recreate_out, rc = -ENOMEM);
+                                noa->o_id = obj->ioo_id;
+                                noa->o_valid = OBD_MD_FLID;
+                        }
+
+                        if (filter_recreate(exp->exp_obd, noa) == 0) {
+                                f_dput(dentry);
+                                dentry = filter_fid2dentry(exp->exp_obd, NULL,
+                                                           obj->ioo_gr,
+                                                           obj->ioo_id);
+                        }
+                        if (oa == NULL)
+                                OBDO_FREE(noa);
+                }
+    recreate_out:
+                if (IS_ERR(dentry) || dentry->d_inode == NULL) {
+                        CERROR("%s: BRW to missing obj "LPU64"/"LPU64":rc %d\n",
+                               exp->exp_obd->obd_name,
+                               obj->ioo_id, obj->ioo_gr,
+                               IS_ERR(dentry) ? (int)PTR_ERR(dentry) : -ENOENT);
+                        if (IS_ERR(dentry))
+                                cleanup_phase = 1;
+                        GOTO(cleanup, rc = -ENOENT);
+                }
         }
 
-        fso.fso_dentry = dentry;
-        fso.fso_bufcnt = obj->ioo_bufcnt;
+        rc = filter_map_remote_to_local(objcount, obj, nb, pages, res);
+        if (rc)
+                GOTO(cleanup, rc);
 
-        fsfilt_check_slow(exp->exp_obd, now, "preprw_write setup");
+        fsfilt_check_slow(obd, now, "preprw_write setup");
 
         /* Don't update inode timestamps if this write is older than a
          * setattr which modifies the timestamps. b=10150 */
@@ -558,8 +709,8 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         fmd = filter_fmd_find(exp, obj->ioo_id, obj->ioo_gr);
 
         LASSERT(oa != NULL);
-        spin_lock(&exp->exp_obd->obd_osfs_lock);
- 
+        spin_lock(&obd->obd_osfs_lock);
+
         filter_grant_incoming(exp, oa);
         if (fmd && fmd->fmd_mactime_xid > oti->oti_xid)
                 oa->o_valid &= ~(OBD_MD_FLMTIME | OBD_MD_FLCTIME |
@@ -571,7 +722,10 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
 
         left = filter_grant_space_left(exp);
 
-        rc = filter_grant_check(exp, oa, objcount, &fso, niocount, nb, res,
+        fso.fso_dentry = dentry;
+        fso.fso_bufcnt = *pages;
+
+        rc = filter_grant_check(exp, oa, objcount, &fso, *pages, res,
                                 &left, dentry->d_inode);
 
         /* do not zero out oa->o_valid as it is used in filter_commitrw_write()
@@ -579,36 +733,44 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
         if (oa->o_valid & OBD_MD_FLGRANT)
                 oa->o_grant = filter_grant(exp,oa->o_grant,oa->o_undirty,left);
 
-        spin_unlock(&exp->exp_obd->obd_osfs_lock);
+        spin_unlock(&obd->obd_osfs_lock);
         filter_fmd_put(exp, fmd);
 
         if (rc)
                 GOTO(cleanup, rc);
+        cleanup_phase = 4;
+
+        /* Filter truncate first locks i_mutex then partally truncated
+         * page, filter write code first locks pages then take
+         * i_mutex.  To avoid a deadlock in case of concurrent
+         * punch/write requests from one client, filter writes and
+         * filter truncates are serialized by i_alloc_sem, allowing
+         * multiple writes or single truncate. */
+        down_read(&dentry->d_inode->i_alloc_sem);
+
+        do_gettimeofday(&start);
+        for (i = 0, lnb = res; i < *pages; i++, lnb++) {
 
-        for (i = 0, rnb = nb, lnb = res; i < obj->ioo_bufcnt;
-             i++, lnb++, rnb++) {
                 /* We still set up for ungranted pages so that granted pages
                  * can be written to disk as they were promised, and portals
                  * needs to keep the pages all aligned properly. */
                 lnb->dentry = dentry;
-                lnb->offset = rnb->offset;
-                lnb->len    = rnb->len;
-                lnb->flags  = rnb->flags;
-
-                /*
-                 * ost_brw_write()->ost_nio_pages_get() already initialized
-                 * lnb->page to point to the page from the per-thread page
-                 * pool (bug 5137), initialize page.
-                 */
-                LASSERT(lnb->page != NULL);
-                if (lnb->len != CFS_PAGE_SIZE) {
-                        memset(kmap(lnb->page) + lnb->len,
-                               0, CFS_PAGE_SIZE - lnb->len);
-                        kunmap(lnb->page);
-                }
-                lnb->page->index = lnb->offset >> CFS_PAGE_SHIFT;
 
-                cleanup_phase = 4;
+                lnb->page = filter_get_page(obd, dentry->d_inode, lnb->offset);
+                if (lnb->page == NULL)
+                        GOTO(cleanup, rc = -ENOMEM);
+
+                /* DLM locking protects us from write and truncate competing
+                 * for same region, but truncate can leave dirty page in the
+                 * cache. it's possible the writeout on a such a page is in
+                 * progress when we access it. it's also possible that during
+                 * this writeout we put new (partial) data, but then won't
+                 * be able to proceed in filter_commitrw_write(). thus let's
+                 * just wait for writeout completion, should be rare enough.
+                 * -bzzz */
+                if (obd->u.filter.fo_writethrough_cache)
+                        wait_on_page_writeback(lnb->page);
+                BUG_ON(PageWriteback(lnb->page));
 
                 /* If the filter writes a partial page, then has the file
                  * extended, the client will read in the whole page.  the
@@ -626,7 +788,7 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
                                                LPU64" flg %x before EOF %llu\n",
                                                lnb->len, lnb->offset,lnb->flags,
                                                i_size_read(dentry->d_inode));
-                                filter_iobuf_add_page(exp->exp_obd, iobuf,
+                                filter_iobuf_add_page(obd, iobuf,
                                                       dentry->d_inode,
                                                       lnb->page);
                         } else {
@@ -645,13 +807,20 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
                 if (lnb->rc == 0)
                         tot_bytes += lnb->len;
         }
+        do_gettimeofday(&end);
+        timediff = cfs_timeval_sub(&end, &start, NULL);
+        lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_GET_PAGE, timediff);
+
+        if (OBD_FAIL_CHECK(OBD_FAIL_OST_NOMEM))
+                GOTO(cleanup, rc = -ENOMEM);
 
+        /* don't unlock pages to prevent any access */
         rc = filter_direct_io(OBD_BRW_READ, dentry, iobuf, exp,
                               NULL, NULL, NULL);
 
-        fsfilt_check_slow(exp->exp_obd, now, "start_page_write");
+        fsfilt_check_slow(obd, now, "start_page_write");
 
-        lprocfs_counter_add(exp->exp_obd->obd_stats, LPROC_FILTER_WRITE_BYTES,
+        lprocfs_counter_add(obd->obd_stats, LPROC_FILTER_WRITE_BYTES,
                             tot_bytes);
         if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats)
                 lprocfs_counter_add(exp->exp_nid_stats->nid_stats,
@@ -660,21 +829,32 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
 cleanup:
         switch(cleanup_phase) {
         case 4:
+                if (rc) {
+                        for (i = 0, lnb = res; i < *pages; i++, lnb++) {
+                                if (lnb->page != NULL) {
+                                        unlock_page(lnb->page);
+                                        page_cache_release(lnb->page);
+                                        lnb->page = NULL;
+                                }
+                        }
+                        filter_grant_commit(exp, *pages, res);
+                        up_read(&dentry->d_inode->i_alloc_sem);
+                }
         case 3:
-                filter_iobuf_put(&exp->exp_obd->u.filter, iobuf, oti);
+                filter_iobuf_put(&obd->u.filter, iobuf, oti);
         case 2:
-                pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
+                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                 if (rc)
                         f_dput(dentry);
                 break;
         case 1:
-                filter_iobuf_put(&exp->exp_obd->u.filter, iobuf, oti);
+                filter_iobuf_put(&obd->u.filter, iobuf, oti);
         case 0:
-                spin_lock(&exp->exp_obd->obd_osfs_lock);
+                spin_lock(&obd->obd_osfs_lock);
                 if (oa)
                         filter_grant_incoming(exp, oa);
-                spin_unlock(&exp->exp_obd->obd_osfs_lock);
-                pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
+                spin_unlock(&obd->obd_osfs_lock);
+                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                 break;
         default:;
         }
@@ -682,47 +862,33 @@ cleanup:
 }
 
 int filter_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
-                  int objcount, struct obd_ioobj *obj, int niocount,
-                  struct niobuf_remote *nb, struct niobuf_local *res,
-                  struct obd_trans_info *oti)
+                  int objcount, struct obd_ioobj *obj,
+                  struct niobuf_remote *nb, int *pages,
+                  struct niobuf_local *res, struct obd_trans_info *oti)
 {
         if (cmd == OBD_BRW_WRITE)
                 return filter_preprw_write(cmd, exp, oa, objcount, obj,
-                                           niocount, nb, res, oti);
+                                           nb, pages, res, oti);
         if (cmd == OBD_BRW_READ)
                 return filter_preprw_read(cmd, exp, oa, objcount, obj,
-                                          niocount, nb, res, oti);
+                                          nb, pages, res, oti);
         LBUG();
         return -EPROTO;
 }
 
-void filter_release_read_page(struct filter_obd *filter, struct inode *inode,
-                              struct page *page)
-{
-        int drop = 0;
-
-        if (inode != NULL &&
-            (i_size_read(inode) > filter->fo_readcache_max_filesize))
-                drop = 1;
-
-        /* drop from cache like truncate_list_pages() */
-        if (drop && !TryLockPage(page)) {
-                if (page->mapping)
-                        ll_truncate_complete_page(page);
-                unlock_page(page);
-        }
-        page_cache_release(page);
-}
-
 static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa,
                                 int objcount, struct obd_ioobj *obj,
-                                int niocount, struct niobuf_local *res,
+                                struct niobuf_remote *rnb,
+                                int pages, struct niobuf_local *res,
                                 struct obd_trans_info *oti, int rc)
 {
+        struct filter_obd *fo = &exp->exp_obd->u.filter;
         struct inode *inode = NULL;
         struct ldlm_res_id res_id = { .name = { obj->ioo_id } };
         struct ldlm_resource *resource = NULL;
         struct ldlm_namespace *ns = exp->exp_obd->obd_namespace;
+        struct niobuf_local *lnb;
+        int i;
         ENTRY;
 
         /* If oa != NULL then filter_preprw_read updated the inode atime
@@ -740,52 +906,22 @@ static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa,
         if (res->dentry != NULL)
                 inode = res->dentry->d_inode;
 
-        filter_free_dio_pages(objcount, obj, niocount, res);
+        for (i = 0, lnb = res; i < pages; i++, lnb++) {
+                if (lnb->page != NULL) {
+                        page_cache_release(lnb->page);
+                        lnb->page = NULL;
+                }
+        }
+
+        if (inode && (fo->fo_read_cache == 0 ||
+                      i_size_read(inode) > fo->fo_readcache_max_filesize))
+                filter_release_cache(exp->exp_obd, obj, rnb, inode);
 
         if (res->dentry != NULL)
                 f_dput(res->dentry);
         RETURN(rc);
 }
 
-void flip_into_page_cache(struct inode *inode, struct page *new_page)
-{
-        struct page *old_page;
-        int rc;
-
-        do {
-                /* the dlm is protecting us from read/write concurrency, so we
-                 * expect this find_lock_page to return quickly.  even if we
-                 * race with another writer it won't be doing much work with
-                 * the page locked.  we do this 'cause t_c_p expects a
-                 * locked page, and it wants to grab the pagecache lock
-                 * as well. */
-                old_page = find_lock_page(inode->i_mapping, new_page->index);
-                if (old_page) {
-                        ll_truncate_complete_page(old_page);
-                        unlock_page(old_page);
-                        page_cache_release(old_page);
-                }
-
-#if 0 /* this should be a /proc tunable someday */
-                /* racing o_directs (no locking ioctl) could race adding
-                 * their pages, so we repeat the page invalidation unless
-                 * we successfully added our new page */
-                rc = add_to_page_cache_unique(new_page, inode->i_mapping,
-                                              new_page->index,
-                                              page_hash(inode->i_mapping,
-                                                        new_page->index));
-                if (rc == 0) {
-                        /* add_to_page_cache clears uptodate|dirty and locks
-                         * the page */
-                        SetPageUptodate(new_page);
-                        unlock_page(new_page);
-                }
-#else
-                rc = 0;
-#endif
-        } while (rc != 0);
-}
-
 void filter_grant_commit(struct obd_export *exp, int niocount,
                          struct niobuf_local *res)
 {
@@ -818,16 +954,17 @@ void filter_grant_commit(struct obd_export *exp, int niocount,
 }
 
 int filter_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
-                    int objcount, struct obd_ioobj *obj, int niocount,
+                    int objcount, struct obd_ioobj *obj,
+                    struct niobuf_remote *nb, int pages,
                     struct niobuf_local *res, struct obd_trans_info *oti,
                     int rc)
 {
         if (cmd == OBD_BRW_WRITE)
-                return filter_commitrw_write(exp, oa, objcount, obj, niocount,
-                                             res, oti, rc);
+                return filter_commitrw_write(exp, oa, objcount, obj,
+                                             nb, pages, res, oti, rc);
         if (cmd == OBD_BRW_READ)
-                return filter_commitrw_read(exp, oa, objcount, obj, niocount,
-                                            res, oti, rc);
+                return filter_commitrw_read(exp, oa, objcount, obj,
+                                            nb, pages, res, oti, rc);
         LBUG();
         return -EPROTO;
 }
@@ -840,7 +977,7 @@ int filter_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo,
         struct niobuf_local *lnb;
         struct niobuf_remote *rnb;
         obd_count i;
-        int ret = 0;
+        int ret = 0, npages;
         ENTRY;
 
         OBD_ALLOC(lnb, oa_bufs * sizeof(struct niobuf_local));
@@ -858,13 +995,15 @@ int filter_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo,
         obdo_to_ioobj(oinfo->oi_oa, &ioo);
         ioo.ioo_bufcnt = oa_bufs;
 
+        npages = oa_bufs;
         ret = filter_preprw(cmd, exp, oinfo->oi_oa, 1, &ioo,
-                            oa_bufs, rnb, lnb, oti);
+                            rnb, &npages, lnb, oti);
         if (ret != 0)
                 GOTO(out, ret);
+        LASSERTF(oa_bufs == npages, "%u != %u\n", oa_bufs, npages);
 
-        ret = filter_commitrw(cmd, exp, oinfo->oi_oa, 1, &ioo,
-                              oa_bufs, lnb, oti, ret);
+        ret = filter_commitrw(cmd, exp, oinfo->oi_oa, 1, &ioo, rnb,
+                              npages, lnb, oti, ret);
 
 out:
         if (lnb)
diff --git a/lustre/obdfilter/filter_io_24.c b/lustre/obdfilter/filter_io_24.c
deleted file mode 100644
index 6031c1f..0000000
--- a/lustre/obdfilter/filter_io_24.c
+++ /dev/null
@@ -1,558 +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  2008 Sun Microsystems, Inc. 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.
- *
- * lustre/obdfilter/filter_io_24.c
- *
- * Author: Peter Braam <braam at clusterfs.com>
- * Author: Andreas Dilger <adilger at clusterfs.com>
- * Author: Phil Schwan <phil at clusterfs.com>
- */
-
-#ifndef AUTOCONF_INCLUDED
-#include <linux/config.h>
-#endif
-#include <linux/module.h>
-#include <linux/pagemap.h> // XXX kill me soon
-#include <linux/version.h>
-
-#define DEBUG_SUBSYSTEM S_FILTER
-
-#include <linux/iobuf.h>
-#include <linux/locks.h>
-
-#include <obd_class.h>
-#include <lustre_fsfilt.h>
-#include "filter_internal.h"
-
-/* Bug 2254 -- this is better done in ext3_map_inode_page, but this
- * workaround will suffice until everyone has upgraded their kernels */
-static void check_pending_bhs(unsigned long *blocks, int nr_pages, dev_t dev,
-                              int size)
-{
-#if (LUSTRE_KERNEL_VERSION < 32)
-        struct buffer_head *bh;
-        int i;
-
-        for (i = 0; i < nr_pages; i++) {
-                bh = get_hash_table(dev, blocks[i], size);
-                if (bh == NULL)
-                        continue;
-                if (!buffer_dirty(bh)) {
-                        put_bh(bh);
-                        continue;
-                }
-                mark_buffer_clean(bh);
-                wait_on_buffer(bh);
-                clear_bit(BH_Req, &bh->b_state);
-                __brelse(bh);
-        }
-#endif
-}
-
-/* when brw_kiovec() is asked to read from block -1UL it just zeros
- * the page.  this gives us a chance to verify the write mappings
- * as well */
-static int filter_cleanup_mappings(int rw, struct kiobuf *iobuf,
-                                   struct inode *inode)
-{
-        int i, blocks_per_page_bits = CFS_PAGE_SHIFT - inode->i_blkbits;
-        ENTRY;
-
-        for (i = 0 ; i < iobuf->nr_pages << blocks_per_page_bits; i++) {
-                if (KIOBUF_GET_BLOCKS(iobuf)[i] > 0)
-                        continue;
-
-                if (rw == OBD_BRW_WRITE)
-                        RETURN(-EINVAL);
-
-                KIOBUF_GET_BLOCKS(iobuf)[i] = -1UL;
-        }
-        RETURN(0);
-}
-
-#if 0
-static void dump_page(int rw, unsigned long block, struct page *page)
-{
-        char *blah = kmap(page);
-        CDEBUG(D_PAGE, "rw %d block %lu: %02x %02x %02x %02x\n", rw, block,
-                       blah[0], blah[1], blah[2], blah[3]);
-        kunmap(page);
-}
-#endif
-
-/* These are our hacks to keep our directio/bh IO coherent with ext3's
- * page cache use.  Most notably ext3 reads file data into the page
- * cache when it is zeroing the tail of partial-block truncates and
- * leaves it there, sometimes generating io from it at later truncates.
- * This removes the partial page and its buffers from the page cache,
- * so it should only ever cause a wait in rare cases, as otherwise we
- * always do full-page IO to the OST.
- *
- * The call to truncate_complete_page() will call journal_flushpage() to
- * free the buffers and drop the page from cache.  The buffers should not
- * be dirty, because we already called fdatasync/fdatawait on them.
- */
-static int filter_sync_inode_data(struct inode *inode)
-{
-        int rc, rc2;
-
-        /* This is nearly generic_osync_inode, without the waiting on the inode
-        rc = generic_osync_inode(inode, inode->i_mapping,
-                                 OSYNC_DATA|OSYNC_METADATA);
-         */
-        rc = filemap_fdatasync(inode->i_mapping);
-        rc2 = fsync_inode_data_buffers(inode);
-        if (rc == 0)
-                rc = rc2;
-        rc2 = filemap_fdatawait(inode->i_mapping);
-        if (rc == 0)
-                rc = rc2;
-
-        return rc;
-}
-
-static int filter_clear_page_cache(struct inode *inode, struct kiobuf *iobuf)
-{
-        struct page *page;
-        int i, rc;
-
-        check_pending_bhs(KIOBUF_GET_BLOCKS(iobuf), iobuf->nr_pages,
-                          inode->i_dev, 1 << inode->i_blkbits);
-
-        rc = filter_sync_inode_data(inode);
-        if (rc != 0)
-                RETURN(rc);
-
-        /* be careful to call this after fsync_inode_data_buffers has waited
-         * for IO to complete before we evict it from the cache */
-        for (i = 0; i < iobuf->nr_pages ; i++) {
-                page = find_lock_page(inode->i_mapping,
-                                      iobuf->maplist[i]->index);
-                if (page == NULL)
-                        continue;
-                if (page->mapping != NULL) {
-                        /* Now that the only source of such pages in truncate
-                         * path flushes these pages to disk and and then
-                         * discards, this is error condition */
-                        CERROR("Data page in page cache during write!\n");
-                        ll_truncate_complete_page(page);
-                }
-
-                unlock_page(page);
-                page_cache_release(page);
-        }
-
-        return 0;
-}
-
-int filter_clear_truncated_page(struct inode *inode)
-{
-        struct page *page;
-        int rc;
-
-        /* Truncate on page boundary, so nothing to flush? */
-        if (!(i_size_read(inode) & ~CFS_PAGE_MASK))
-                return 0;
-
-        rc = filter_sync_inode_data(inode);
-        if (rc != 0)
-                RETURN(rc);
-
-        /* be careful to call this after fsync_inode_data_buffers has waited
-         * for IO to complete before we evict it from the cache */
-        page = find_lock_page(inode->i_mapping,
-                              i_size_read(inode) >> CFS_PAGE_SHIFT);
-        if (page) {
-                if (page->mapping != NULL)
-                        ll_truncate_complete_page(page);
-
-                unlock_page(page);
-                page_cache_release(page);
-        }
-
-        return 0;
-}
-
-/* Must be called with i_sem taken for writes; this will drop it */
-int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *buf,
-                     struct obd_export *exp, struct iattr *attr,
-                     struct obd_trans_info *oti, void **wait_handle)
-{
-        struct obd_device *obd = exp->exp_obd;
-        struct inode *inode = dchild->d_inode;
-        struct kiobuf *iobuf = (void *)buf;
-        int rc, create = (rw == OBD_BRW_WRITE), committed = 0;
-        int blocks_per_page = CFS_PAGE_SIZE >> inode->i_blkbits, cleanup_phase = 0;
-        struct semaphore *sem = NULL;
-        ENTRY;
-
-        LASSERTF(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ, "%x\n", rw);
-
-        if (iobuf->nr_pages == 0)
-                GOTO(cleanup, rc = 0);
-
-        if (iobuf->nr_pages * blocks_per_page > KIO_MAX_SECTORS)
-                GOTO(cleanup, rc = -EINVAL);
-
-        if (iobuf->nr_pages * blocks_per_page >
-            OBDFILTER_CREATED_SCRATCHPAD_ENTRIES)
-                GOTO(cleanup, rc = -EINVAL);
-
-        cleanup_phase = 1;
-
-        rc = lock_kiovec(1, &iobuf, 1);
-        if (rc < 0)
-                GOTO(cleanup, rc);
-        cleanup_phase = 2;
-
-        if (rw == OBD_BRW_WRITE) {
-                create = 1;
-                sem = &obd->u.filter.fo_alloc_lock;
-        }
-        rc = fsfilt_map_inode_pages(obd, inode, iobuf->maplist,
-                                    iobuf->nr_pages, KIOBUF_GET_BLOCKS(iobuf),
-                                    obdfilter_created_scratchpad, create, sem);
-        if (rc)
-                GOTO(cleanup, rc);
-
-        rc = filter_cleanup_mappings(rw, iobuf, inode);
-        if (rc)
-                GOTO(cleanup, rc);
-
-        if (rw == OBD_BRW_WRITE) {
-                if (rc == 0) {
-                        filter_tally(exp, iobuf->maplist, iobuf->nr_pages,
-                                     KIOBUF_GET_BLOCKS(iobuf), blocks_per_page,
-                                     1);
-
-                        if (attr->ia_size > i_size_read(inode))
-                                attr->ia_valid |= ATTR_SIZE;
-                        rc = fsfilt_setattr(obd, dchild,
-                                            oti->oti_handle, attr, 0);
-                        if (rc)
-                                GOTO(cleanup, rc);
-                }
-
-                up(&inode->i_sem);
-                cleanup_phase = 3;
-
-                rc = filter_finish_transno(exp, oti, 0, 0);
-                if (rc)
-                        GOTO(cleanup, rc);
-
-                rc = fsfilt_commit_async(obd,inode,oti->oti_handle,wait_handle);
-                committed = 1;
-                if (rc)
-                        GOTO(cleanup, rc);
-        } else {
-                filter_tally(exp, iobuf->maplist, iobuf->nr_pages,
-                             KIOBUF_GET_BLOCKS(iobuf), blocks_per_page, 0);
-        }
-
-        rc = filter_clear_page_cache(inode, iobuf);
-        if (rc < 0)
-                GOTO(cleanup, rc);
-
-        rc = fsfilt_send_bio(rw, obd, inode, iobuf);
-
-        CDEBUG(D_INFO, "tried to %s %d pages, rc = %d\n",
-               rw & OBD_BRW_WRITE ? "write" : "read", iobuf->nr_pages, rc);
-
-        if (rc > 0)
-                rc = 0;
-
-        EXIT;
-cleanup:
-        if (!committed && (rw == OBD_BRW_WRITE)) {
-                int err = fsfilt_commit_async(obd, inode,
-                                              oti->oti_handle, wait_handle);
-                if (err)
-                        CERROR("can't close transaction: %d\n", err);
-                /*
-                 * this is error path, so we prefer to return
-                 * original error, not this one
-                 */
-        }
-
-        switch(cleanup_phase) {
-        case 3:
-        case 2:
-                unlock_kiovec(1, &iobuf);
-        case 1:
-        case 0:
-                if (cleanup_phase != 3 && rw == OBD_BRW_WRITE)
-                        up(&inode->i_sem);
-                break;
-        default:
-                CERROR("corrupt cleanup_phase (%d)?\n", cleanup_phase);
-                LBUG();
-                break;
-        }
-        return rc;
-}
-
-/* See if there are unallocated parts in given file region */
-int filter_range_is_mapped(struct inode *inode, obd_size offset, int len)
-{
-        int (*fs_bmap)(struct address_space *, long) =
-                inode->i_mapping->a_ops->bmap;
-        int j;
-
-        /* We can't know if the range is mapped already or not */
-        if (fs_bmap == NULL)
-                return 0;
-
-        offset >>= inode->i_blkbits;
-        len >>= inode->i_blkbits;
-
-        for (j = 0; j < len; j++)
-                if (fs_bmap(inode->i_mapping, offset + j) == 0)
-                        return 0;
-
-        return 1;
-}
-
-/* some kernels require alloc_kiovec callers to zero members through the use of
- * map_user_kiobuf and unmap_.. we don't use those, so we have a little helper
- * that makes sure we don't break the rules. */
-static void clear_kiobuf(struct kiobuf *iobuf)
-{
-        int i;
-
-        for (i = 0; i < iobuf->array_len; i++)
-                iobuf->maplist[i] = NULL;
-
-        iobuf->nr_pages = 0;
-        iobuf->offset = 0;
-        iobuf->length = 0;
-}
-
-struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *filter,
-                                        int rw, int num_pages)
-{
-        struct kiobuf *iobuf;
-        int rc;
-        ENTRY;
-
-        LASSERTF(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ, "%x\n", rw);
-
-        rc = alloc_kiovec(1, &iobuf);
-        if (rc)
-                RETURN(ERR_PTR(rc));
-
-        rc = expand_kiobuf(iobuf, num_pages);
-        if (rc) {
-                free_kiovec(1, &iobuf);
-                RETURN(ERR_PTR(rc));
-        }
-
-#ifdef HAVE_KIOBUF_DOVARY
-        iobuf->dovary = 0; /* this prevents corruption, not present in 2.4.20 */
-#endif
-        clear_kiobuf(iobuf);
-        RETURN((void *)iobuf);
-}
-
-void filter_free_iobuf(struct filter_iobuf *buf)
-{
-        struct kiobuf *iobuf = (void *)buf;
-
-        clear_kiobuf(iobuf);
-        free_kiovec(1, &iobuf);
-}
-
-void filter_iobuf_put(struct filter_obd *filter, struct filter_iobuf *iobuf,
-                      struct obd_trans_info *oti)
-{
-        int thread_id = (oti && oti->oti_thread) ?
-                        oti->oti_thread->t_id : -1;
-
-        if (unlikely(thread_id < 0)) {
-                filter_free_iobuf(iobuf);
-                return;
-        }
-
-        LASSERTF(filter->fo_iobuf_pool[thread_id] == iobuf,
-                 "iobuf mismatch for thread %d: pool %p iobuf %p\n",
-                 thread_id, filter->fo_iobuf_pool[thread_id], iobuf);
-        clear_kiobuf((void *)iobuf);
-}
-
-int filter_iobuf_add_page(struct obd_device *obd, struct filter_iobuf *buf,
-                           struct inode *inode, struct page *page)
-{
-        struct kiobuf *iobuf = (void *)buf;
-
-        iobuf->maplist[iobuf->nr_pages++] = page;
-        iobuf->length += CFS_PAGE_SIZE;
-
-        return 0;
-}
-
-int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
-                          struct obd_ioobj *obj, int niocount,
-                          struct niobuf_local *res, struct obd_trans_info *oti,
-                          int rc)
-{
-        struct obd_device *obd = exp->exp_obd;
-        struct lvfs_run_ctxt saved;
-        struct niobuf_local *lnb;
-        struct fsfilt_objinfo fso;
-        struct iattr iattr = { 0 };
-        void *iobuf = NULL;
-        struct inode *inode = NULL;
-        int i, n, cleanup_phase = 0, err;
-        unsigned long now = jiffies; /* DEBUGGING OST TIMEOUTS */
-        void *wait_handle;
-        ENTRY;
-        LASSERT(oti != NULL);
-        LASSERT(objcount == 1);
-        LASSERT(current->journal_info == NULL);
-
-        if (rc != 0)
-                GOTO(cleanup, rc);
-
-        iobuf = filter_iobuf_get(&obd->u.filter, oti);
-        if (IS_ERR(iobuf))
-                GOTO(cleanup, rc = PTR_ERR(iobuf));
-        cleanup_phase = 1;
-
-        fso.fso_dentry = res->dentry;
-        fso.fso_bufcnt = obj->ioo_bufcnt;
-        inode = res->dentry->d_inode;
-
-        for (i = 0, lnb = res, n = 0; i < obj->ioo_bufcnt; i++, lnb++) {
-                loff_t this_size;
-
-                /* If overwriting an existing block, we don't need a grant */
-                if (!(lnb->flags & OBD_BRW_GRANTED) && lnb->rc == -ENOSPC &&
-                    filter_range_is_mapped(inode, lnb->offset, lnb->len))
-                        lnb->rc = 0;
-
-                if (lnb->rc) /* ENOSPC, network RPC error */
-                        continue;
-
-                filter_iobuf_add_page(obd, iobuf, inode, lnb->page);
-
-                /* We expect these pages to be in offset order, but we'll
-                 * be forgiving */
-                this_size = lnb->offset + lnb->len;
-                if (this_size > iattr.ia_size)
-                        iattr.ia_size = this_size;
-        }
-
-        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-        cleanup_phase = 2;
-
-        down(&inode->i_sem);
-        oti->oti_handle = fsfilt_brw_start(obd, objcount, &fso, niocount, res,
-                                           oti);
-        if (IS_ERR(oti->oti_handle)) {
-                up(&inode->i_sem);
-                rc = PTR_ERR(oti->oti_handle);
-                CDEBUG(rc == -ENOSPC ? D_INODE : D_ERROR,
-                       "error starting transaction: rc = %d\n", rc);
-                oti->oti_handle = NULL;
-                GOTO(cleanup, rc);
-        }
-
-        fsfilt_check_slow(obd, now, "brw_start");
-
-        i = OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME;
-
-        /* If the inode still has SUID+SGID bits set (see filter_precreate())
-         * then we will accept the UID+GID if sent by the client for
-         * initializing the ownership of this inode.  We only allow this to
-         * happen once (so clear these bits) and later only allow setattr. */
-        if (inode->i_mode & S_ISUID)
-                i |= OBD_MD_FLUID;
-        if (inode->i_mode & S_ISGID)
-                i |= OBD_MD_FLGID;
-
-        iattr_from_obdo(&iattr, oa, i);
-        if (iattr.ia_valid & (ATTR_UID | ATTR_GID)) {
-                CDEBUG(D_INODE, "update UID/GID to %lu/%lu\n",
-                       (unsigned long)oa->o_uid, (unsigned long)oa->o_gid);
-
-                cfs_cap_raise(CFS_CAP_SYS_RESOURCE);
-
-                iattr.ia_valid |= ATTR_MODE;
-                iattr.ia_mode = inode->i_mode;
-                if (iattr.ia_valid & ATTR_UID)
-                        iattr.ia_mode &= ~S_ISUID;
-                if (iattr.ia_valid & ATTR_GID)
-                        iattr.ia_mode &= ~S_ISGID;
-
-                rc = filter_update_fidea(exp, inode, oti->oti_handle, oa);
-        }
-
-        /* filter_direct_io drops i_sem */
-        rc = filter_direct_io(OBD_BRW_WRITE, res->dentry, iobuf, exp, &iattr,
-                              oti, &wait_handle);
-        if (rc == 0)
-                obdo_from_inode(oa, inode, FILTER_VALID_FLAGS);
-
-        fsfilt_check_slow(obd, now, "direct_io");
-
-        err = fsfilt_commit_wait(obd, inode, wait_handle);
-        if (err) {
-                CERROR("Failure to commit OST transaction (%d)?\n", err);
-                rc = err;
-        }
-        if (obd->obd_replayable && !rc)
-                LASSERTF(oti->oti_transno <= obd->obd_last_committed,
-                         "oti_transno "LPU64" last_committed "LPU64"\n",
-                         oti->oti_transno, obd->obd_last_committed);
-        fsfilt_check_slow(obd, now, "commitrw commit");
-
-cleanup:
-        filter_grant_commit(exp, niocount, res);
-
-        switch (cleanup_phase) {
-        case 2:
-                pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-                LASSERT(current->journal_info == NULL);
-        case 1:
-                filter_iobuf_put(&obd->u.filter, iobuf, oti);
-        case 0:
-                /*
-                 * lnb->page automatically returns back into per-thread page
-                 * pool (bug 5137)
-                 */
-                f_dput(res->dentry);
-        }
-
-        RETURN(rc);
-}
diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c
index 8afe460..22c841d 100644
--- a/lustre/obdfilter/filter_io_26.c
+++ b/lustre/obdfilter/filter_io_26.c
@@ -65,7 +65,6 @@ struct filter_iobuf {
         int               dr_error;
         struct page     **dr_pages;
         unsigned long    *dr_blocks;
-        spinlock_t        dr_lock;              /* IRQ lock */
         unsigned int      dr_ignore_quota:1;
         struct filter_obd *dr_filter;
 };
@@ -81,18 +80,32 @@ static void record_start_io(struct filter_iobuf *iobuf, int rw, int size,
                 atomic_inc(&filter->fo_r_in_flight);
                 lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_RPC_HIST],
                                  atomic_read(&filter->fo_r_in_flight));
-                lprocfs_oh_tally_log2(&filter->fo_filter_stats.hist[BRW_R_DISK_IOSIZE], size);
-                lprocfs_oh_tally(&exp->exp_filter_data.fed_brw_stats.hist[BRW_R_RPC_HIST],
-                                 atomic_read(&filter->fo_r_in_flight));
-                lprocfs_oh_tally_log2(&exp->exp_filter_data.fed_brw_stats.hist[BRW_R_DISK_IOSIZE], size);
+                lprocfs_oh_tally_log2(&filter->
+                                       fo_filter_stats.hist[BRW_R_DISK_IOSIZE],
+                                      size);
+                if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) {
+                        lprocfs_oh_tally(&exp->exp_nid_stats->nid_brw_stats->
+                                          hist[BRW_R_RPC_HIST],
+                                         atomic_read(&filter->fo_r_in_flight));
+                        lprocfs_oh_tally_log2(&exp->exp_nid_stats->
+                                         nid_brw_stats->hist[BRW_R_DISK_IOSIZE],
+                                              size);
+                }
         } else {
                 atomic_inc(&filter->fo_w_in_flight);
                 lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_W_RPC_HIST],
                                  atomic_read(&filter->fo_w_in_flight));
-                lprocfs_oh_tally_log2(&filter->fo_filter_stats.hist[BRW_W_DISK_IOSIZE], size);
-                lprocfs_oh_tally(&exp->exp_filter_data.fed_brw_stats.hist[BRW_W_RPC_HIST],
-                                 atomic_read(&filter->fo_w_in_flight));
-                lprocfs_oh_tally_log2(&exp->exp_filter_data.fed_brw_stats.hist[BRW_W_DISK_IOSIZE], size);
+                lprocfs_oh_tally_log2(&filter->
+                                       fo_filter_stats.hist[BRW_W_DISK_IOSIZE],
+                                      size);
+                if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) {
+                        lprocfs_oh_tally(&exp->exp_nid_stats->nid_brw_stats->
+                                          hist[BRW_W_RPC_HIST],
+                                         atomic_read(&filter->fo_r_in_flight));
+                        lprocfs_oh_tally_log2(&exp->exp_nid_stats->
+                                        nid_brw_stats->hist[BRW_W_DISK_IOSIZE],
+                                              size);
+                }
         }
 }
 
@@ -100,7 +113,7 @@ static void record_finish_io(struct filter_iobuf *iobuf, int rw, int rc)
 {
         struct filter_obd *filter = iobuf->dr_filter;
 
-        /* CAVEAT EMPTOR: possibly in IRQ context 
+        /* CAVEAT EMPTOR: possibly in IRQ context
          * DO NOT record procfs stats here!!! */
 
         if (rw == OBD_BRW_READ)
@@ -112,23 +125,33 @@ static void record_finish_io(struct filter_iobuf *iobuf, int rw, int rc)
                 wake_up(&iobuf->dr_wait);
 }
 
+#ifdef HAVE_BIO_ENDIO_2ARG
+#define DIO_RETURN(a)
+static void dio_complete_routine(struct bio *bio, int error)
+#else
+#define DIO_RETURN(a)   (a)
 static int dio_complete_routine(struct bio *bio, unsigned int done, int error)
+#endif
 {
         struct filter_iobuf *iobuf = bio->bi_private;
-        unsigned long        flags;
-
-#ifdef HAVE_PAGE_CONSTANT
         struct bio_vec *bvl;
         int i;
-#endif
 
-        /* CAVEAT EMPTOR: possibly in IRQ context 
+        /* CAVEAT EMPTOR: possibly in IRQ context
          * DO NOT record procfs stats here!!! */
 
-        if (bio->bi_size)                       /* Not complete */
-                return 1;
+#ifndef HAVE_BIO_ENDIO_2ARG
+	/* The "bi_size" check was needed for kernels < 2.6.24 in order to
+	 * handle the case where a SCSI request error caused this callback
+	 * to be called before all of the biovecs had been processed.
+	 * Without this check the server thread will hang.  In newer kernels
+	 * the bio_end_io routine is never called for partial completions,
+	 * so this check is no longer needed. */
+	if (bio->bi_size)		       /* Not complete */
+		return DIO_RETURN(1);
+#endif
 
-        if (iobuf == NULL) {
+        if (unlikely(iobuf == NULL)) {
                 CERROR("***** bio->bi_private is NULL!  This should never "
                        "happen.  Normally, I would crash here, but instead I "
                        "will dump the bio contents to the console.  Please "
@@ -136,28 +159,37 @@ static int dio_complete_routine(struct bio *bio, unsigned int done, int error)
                        "with any interesting messages leading up to this point "
                        "(like SCSI errors, perhaps).  Because bi_private is "
                        "NULL, I can't wake up the thread that initiated this "
-                       "I/O -- so you will probably have to reboot this node.\n");
+                       "IO - you will probably have to reboot this node.\n");
                 CERROR("bi_next: %p, bi_flags: %lx, bi_rw: %lu, bi_vcnt: %d, "
                        "bi_idx: %d, bi->size: %d, bi_end_io: %p, bi_cnt: %d, "
                        "bi_private: %p\n", bio->bi_next, bio->bi_flags,
                        bio->bi_rw, bio->bi_vcnt, bio->bi_idx, bio->bi_size,
                        bio->bi_end_io, atomic_read(&bio->bi_cnt),
                        bio->bi_private);
-                return 0;
+                return DIO_RETURN(0);
         }
 
-#ifdef HAVE_PAGE_CONSTANT
-        bio_for_each_segment(bvl, bio, i)
-                ClearPageConstant(bvl->bv_page);
-#endif
+        /* the check is outside of the cycle for performance reason -bzzz */
+        if (!test_bit(BIO_RW, &bio->bi_rw)) {
+                bio_for_each_segment(bvl, bio, i) {
+                        if (likely(error == 0))
+                                SetPageUptodate(bvl->bv_page);
+                        LASSERT(PageLocked(bvl->bv_page));
+                        ClearPageConstant(bvl->bv_page);
+                }
+                record_finish_io(iobuf, OBD_BRW_READ, error);
+        } else {
+                if (mapping_cap_page_constant_write(iobuf->dr_pages[0]->mapping)){
+                        bio_for_each_segment(bvl, bio, i) {
+                                ClearPageConstant(bvl->bv_page);
+                        }
+                }
+                record_finish_io(iobuf, OBD_BRW_WRITE, error);
+        }
 
-        spin_lock_irqsave(&iobuf->dr_lock, flags);
-        if (iobuf->dr_error == 0)
+        /* any real error is good enough -bzzz */
+        if (error != 0 && iobuf->dr_error == 0)
                 iobuf->dr_error = error;
-        spin_unlock_irqrestore(&iobuf->dr_lock, flags);
-
-        record_finish_io(iobuf, test_bit(BIO_RW, &bio->bi_rw) ?
-                         OBD_BRW_WRITE : OBD_BRW_READ, error);
 
         /* Completed bios used to be chained off iobuf->dr_bios and freed in
          * filter_clear_dreq().  It was then possible to exhaust the biovec-256
@@ -165,7 +197,7 @@ static int dio_complete_routine(struct bio *bio, unsigned int done, int error)
          * deadlocking the OST.  The bios are now released as soon as complete
          * so the pool cannot be exhausted while IOs are competing. bug 10076 */
         bio_put(bio);
-        return 0;
+        return DIO_RETURN(0);
 }
 
 static int can_be_merged(struct bio *bio, sector_t sector)
@@ -202,7 +234,6 @@ struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *filter,
         iobuf->dr_filter = filter;
         init_waitqueue_head(&iobuf->dr_wait);
         atomic_set(&iobuf->dr_numreqs, 0);
-        spin_lock_init(&iobuf->dr_lock);
         iobuf->dr_max_pages = num_pages;
         iobuf->dr_npages = 0;
         iobuf->dr_error = 0;
@@ -320,17 +351,15 @@ int filter_do_bio(struct obd_export *exp, struct inode *inode,
                                 sector_bits))
                                 nblocks++;
 
-#ifdef HAVE_PAGE_CONSTANT
-                        /* I only set the page to be constant only if it 
-                         * is mapped to a contiguous underlying disk block(s). 
-                         * It will then make sure the corresponding device 
-                         * cache of raid5 will be overwritten by this page. 
+                        /* I only set the page to be constant only if it
+                         * is mapped to a contiguous underlying disk block(s).
+                         * It will then make sure the corresponding device
+                         * cache of raid5 will be overwritten by this page.
                          * - jay */
-                        if ((rw == OBD_BRW_WRITE) && 
-                            (nblocks == blocks_per_page) && 
+                        if ((rw == OBD_BRW_WRITE) &&
+                            (nblocks == blocks_per_page) &&
                             mapping_cap_page_constant_write(inode->i_mapping))
-                                SetPageConstant(page);
-#endif
+                               SetPageConstant(page);
 
                         if (bio != NULL &&
                             can_be_merged(bio, sector) &&
@@ -339,8 +368,8 @@ int filter_do_bio(struct obd_export *exp, struct inode *inode,
                                 continue;       /* added this frag OK */
 
                         if (bio != NULL) {
-                                request_queue_t *q =
-                                        bdev_get_queue(bio->bi_bdev);
+                                struct request_queue *q =
+                                       bdev_get_queue(bio->bi_bdev);
 
                                 /* Dang! I have to fragment this I/O */
                                 CDEBUG(D_INODE, "bio++ sz %d vcnt %d(%d) "
@@ -363,9 +392,10 @@ int filter_do_bio(struct obd_export *exp, struct inode *inode,
                                 frags++;
                         }
 
-                        /* allocate new bio */
-                        bio = bio_alloc(GFP_NOIO,
-                                        (npages - page_idx) * blocks_per_page);
+                        /* allocate new bio, limited by max BIO size, b=9945 */
+                        bio = bio_alloc(GFP_NOIO, max(BIO_MAX_PAGES,
+						      (npages - page_idx) *
+						      blocks_per_page));
                         if (bio == NULL) {
                                 CERROR("Can't allocate bio %u*%u = %u pages\n",
                                        (npages - page_idx), blocks_per_page,
@@ -401,31 +431,32 @@ int filter_do_bio(struct obd_export *exp, struct inode *inode,
         wait_event(iobuf->dr_wait, atomic_read(&iobuf->dr_numreqs) == 0);
 
         if (rw == OBD_BRW_READ) {
-                lprocfs_oh_tally(&obd->u.filter.fo_filter_stats.hist[BRW_R_DIO_FRAGS], frags);
-                lprocfs_oh_tally(&exp->exp_filter_data.fed_brw_stats.hist[BRW_R_DIO_FRAGS],
+                lprocfs_oh_tally(&obd->u.filter.fo_filter_stats.
+                                  hist[BRW_R_DIO_FRAGS],
                                  frags);
-                lprocfs_oh_tally_log2(&obd->u.filter.fo_filter_stats.hist[BRW_R_IO_TIME],
+                lprocfs_oh_tally_log2(&obd->u.filter.
+                                       fo_filter_stats.hist[BRW_R_IO_TIME],
                                       jiffies - start_time);
-                lprocfs_oh_tally_log2(&exp->exp_filter_data.fed_brw_stats.hist[BRW_R_IO_TIME],
-                                 jiffies - start_time);
                 if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) {
-                        lprocfs_oh_tally(&exp->exp_nid_stats->nid_brw_stats->hist[BRW_R_DIO_FRAGS],
+                        lprocfs_oh_tally(&exp->exp_nid_stats->nid_brw_stats->
+                                          hist[BRW_R_DIO_FRAGS],
                                          frags);
-                        lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->hist[BRW_R_IO_TIME],
+                        lprocfs_oh_tally_log2(&exp->exp_nid_stats->
+                                             nid_brw_stats->hist[BRW_R_IO_TIME],
                                               jiffies - start_time);
                 }
         } else {
-                lprocfs_oh_tally(&obd->u.filter.fo_filter_stats.hist[BRW_W_DIO_FRAGS], frags);
-                lprocfs_oh_tally(&exp->exp_filter_data.fed_brw_stats.hist[BRW_W_DIO_FRAGS],
-                                 frags);
-                lprocfs_oh_tally_log2(&obd->u.filter.fo_filter_stats.hist[BRW_W_IO_TIME],
+                lprocfs_oh_tally(&obd->u.filter.fo_filter_stats.
+                                  hist[BRW_W_DIO_FRAGS], frags);
+                lprocfs_oh_tally_log2(&obd->u.filter.fo_filter_stats.
+                                       hist[BRW_W_IO_TIME],
                                       jiffies - start_time);
-                lprocfs_oh_tally_log2(&exp->exp_filter_data.fed_brw_stats.hist[BRW_W_IO_TIME],
-                                 jiffies - start_time);
                 if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) {
-                        lprocfs_oh_tally(&exp->exp_nid_stats->nid_brw_stats->hist[BRW_W_DIO_FRAGS],
+                        lprocfs_oh_tally(&exp->exp_nid_stats->nid_brw_stats->
+                                          hist[BRW_W_DIO_FRAGS],
                                          frags);
-                        lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->hist[BRW_W_IO_TIME],
+                        lprocfs_oh_tally_log2(&exp->exp_nid_stats->
+                                             nid_brw_stats->hist[BRW_W_IO_TIME],
                                               jiffies - start_time);
                 }
         }
@@ -435,110 +466,6 @@ int filter_do_bio(struct obd_export *exp, struct inode *inode,
         RETURN(rc);
 }
 
-/* These are our hacks to keep our directio/bh IO coherent with ext3's
- * page cache use.  Most notably ext3 reads file data into the page
- * cache when it is zeroing the tail of partial-block truncates and
- * leaves it there, sometimes generating io from it at later truncates.
- * This removes the partial page and its buffers from the page cache,
- * so it should only ever cause a wait in rare cases, as otherwise we
- * always do full-page IO to the OST.
- *
- * The call to truncate_complete_page() will call journal_invalidatepage()
- * to free the buffers and drop the page from cache.  The buffers should
- * not be dirty, because we already called fdatasync/fdatawait on them.
- */
-static int filter_sync_inode_data(struct inode *inode, int locked)
-{
-        int rc = 0;
-
-        /* This is nearly do_fsync(), without the waiting on the inode */
-        /* XXX: in 2.6.16 (at least) we don't need to hold i_mutex over
-         * filemap_fdatawrite() and filemap_fdatawait(), so we may no longer
-         * need this lock here at all. */
-        if (!locked)
-                LOCK_INODE_MUTEX(inode);
-        if (inode->i_mapping->nrpages) {
-#ifdef PF_SYNCWRITE
-                current->flags |= PF_SYNCWRITE;
-#endif
-                rc = filemap_fdatawrite(inode->i_mapping);
-                if (rc == 0)
-                        rc = filemap_fdatawait(inode->i_mapping);
-#ifdef PF_SYNCWRITE
-                current->flags &= ~PF_SYNCWRITE;
-#endif
-        }
-        if (!locked)
-                UNLOCK_INODE_MUTEX(inode);
-
-        return rc;
-}
-
-/* Clear pages from the mapping before we do direct IO to that offset.
- * Now that the only source of such pages in the truncate path flushes
- * these pages to disk and then discards them, this is error condition.
- * If add back read cache this will happen again.  This could be disabled
- * until that time if we never see the below error. */
-static int filter_clear_page_cache(struct inode *inode,
-                                   struct filter_iobuf *iobuf)
-{
-        struct page *page;
-        int i, rc;
-
-        rc = filter_sync_inode_data(inode, 0);
-        if (rc != 0)
-                RETURN(rc);
-
-        /* be careful to call this after fsync_inode_data_buffers has waited
-         * for IO to complete before we evict it from the cache */
-        for (i = 0; i < iobuf->dr_npages; i++) {
-                page = find_lock_page(inode->i_mapping,
-                                      iobuf->dr_pages[i]->index);
-                if (page == NULL)
-                        continue;
-                if (page->mapping != NULL) {
-                        CERROR("page %lu (%d/%d) in page cache during write!\n",
-                               page->index, i, iobuf->dr_npages);
-                        wait_on_page_writeback(page);
-                        ll_truncate_complete_page(page);
-                }
-
-                unlock_page(page);
-                page_cache_release(page);
-        }
-
-        return 0;
-}
-
-int filter_clear_truncated_page(struct inode *inode)
-{
-        struct page *page;
-        int rc;
-
-        /* Truncate on page boundary, so nothing to flush? */
-        if (!(i_size_read(inode) & ~CFS_PAGE_MASK))
-                return 0;
-
-        rc = filter_sync_inode_data(inode, 1);
-        if (rc != 0)
-                RETURN(rc);
-
-        /* be careful to call this after fsync_inode_data_buffers has waited
-         * for IO to complete before we evict it from the cache */
-        page = find_lock_page(inode->i_mapping,
-                              i_size_read(inode) >> CFS_PAGE_SHIFT);
-        if (page) {
-                if (page->mapping != NULL) {
-                        wait_on_page_writeback(page);
-                        ll_truncate_complete_page(page);
-                }
-                unlock_page(page);
-                page_cache_release(page);
-        }
-
-        return 0;
-}
-
 /* Must be called with i_mutex taken for writes; this will drop it */
 int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *iobuf,
                      struct obd_export *exp, struct iattr *attr,
@@ -587,14 +514,18 @@ int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *iobuf,
 
                 UNLOCK_INODE_MUTEX(inode);
 
-                rc2 = filter_finish_transno(exp, oti, 0, 0);
+                rc2 = filter_finish_transno(exp, inode, oti, 0, 0);
                 if (rc2 != 0) {
                         CERROR("can't close transaction: %d\n", rc2);
                         if (rc == 0)
                                 rc = rc2;
                 }
 
-                rc2 =fsfilt_commit_async(obd,inode,oti->oti_handle,wait_handle);
+                if (wait_handle)
+                        rc2 = fsfilt_commit_async(obd, inode, oti->oti_handle,
+                                                  wait_handle);
+                else
+                        rc2 = fsfilt_commit(obd, inode, oti->oti_handle, 0);
                 if (rc == 0)
                         rc = rc2;
                 if (rc != 0)
@@ -604,10 +535,6 @@ int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *iobuf,
                              iobuf->dr_blocks, blocks_per_page, 0);
         }
 
-        rc = filter_clear_page_cache(inode, iobuf);
-        if (rc != 0)
-                RETURN(rc);
-
         RETURN(filter_do_bio(exp, inode, iobuf, rw));
 }
 
@@ -632,8 +559,20 @@ static int filter_range_is_mapped(struct inode *inode, obd_size offset, int len)
         return 1;
 }
 
+/*
+ * interesting use cases on how it interacts with VM:
+ *
+ * - vm writeout -- shouldn't see our pages as we don't mark them dirty
+ *   though vm can find partial page left dirty by truncate. in this
+ *   usual writeout is used unless our write rewrite that page - then we
+ *   drop PG_dirty with PG_lock held.
+ *
+ * - else?
+ *
+ */
 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
-                          int objcount, struct obd_ioobj *obj, int niocount,
+                          int objcount, struct obd_ioobj *obj,
+                          struct niobuf_remote *nb, int niocount,
                           struct niobuf_local *res, struct obd_trans_info *oti,
                           int rc)
 {
@@ -646,10 +585,12 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         unsigned long now = jiffies;
         int i, err, cleanup_phase = 0;
         struct obd_device *obd = exp->exp_obd;
-        void *wait_handle;
+        struct filter_obd *fo = &obd->u.filter;
+        void *wait_handle = NULL;
         int total_size = 0;
-        int quota_pending[2] = {0, 0};
+        int quota_pending[2] = {0, 0}, quota_pages = 0;
         unsigned int qcids[MAXQUOTAS] = {0, 0};
+        int sync_journal_commit = obd->u.filter.fo_syncjournal;
         ENTRY;
 
         LASSERT(oti != NULL);
@@ -659,11 +600,6 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         if (rc != 0)
                 GOTO(cleanup, rc);
 
-        /* we try to get enough quota to write here, and let ldiskfs
-         * decide if it is out of quota or not b=14783 */
-        lquota_chkquota(filter_quota_interface_ref, obd, oa->o_uid, oa->o_gid,
-                        niocount, quota_pending, oti, inode, obj->ioo_bufcnt);
-
         iobuf = filter_iobuf_get(&obd->u.filter, oti);
         if (IS_ERR(iobuf))
                 GOTO(cleanup, rc = PTR_ERR(iobuf));
@@ -673,19 +609,35 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         fso.fso_bufcnt = obj->ioo_bufcnt;
 
         iobuf->dr_ignore_quota = 0;
-        for (i = 0, lnb = res; i < obj->ioo_bufcnt; i++, lnb++) {
+        for (i = 0, lnb = res; i < niocount; i++, lnb++) {
                 loff_t this_size;
 
-                /* If overwriting an existing block, we don't need a grant */
-                if (!(lnb->flags & OBD_BRW_GRANTED) && lnb->rc == -ENOSPC &&
-                    filter_range_is_mapped(inode, lnb->offset, lnb->len))
-                        lnb->rc = 0;
+
+                if (filter_range_is_mapped(inode, lnb->offset, lnb->len)) {
+                        /* If overwriting an existing block,
+                         * we don't need a grant */
+                        if (!(lnb->flags & OBD_BRW_GRANTED) &&
+                            lnb->rc == -ENOSPC)
+                                lnb->rc = 0;
+                } else {
+                        quota_pages++;
+                }
 
                 if (lnb->rc) { /* ENOSPC, network RPC error, etc. */
                         CDEBUG(D_INODE, "Skipping [%d] == %d\n", i, lnb->rc);
                         continue;
                 }
 
+                LASSERT(PageLocked(lnb->page));
+                LASSERT(!PageWriteback(lnb->page));
+
+                /* preceding filemap_write_and_wait() should have clean pages */
+                if (fo->fo_writethrough_cache)
+                        clear_page_dirty_for_io(lnb->page);
+                LASSERT(!PageDirty(lnb->page));
+
+                SetPageUptodate(lnb->page);
+
                 err = filter_iobuf_add_page(obd, iobuf, inode, lnb->page);
                 LASSERT (err == 0);
 
@@ -701,10 +653,21 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
                  * not from direct_io, or it's written by root, then mark
                  * the whole io request as ignore quota request */
                 if (lnb->flags & OBD_BRW_NOQUOTA ||
-                    (lnb->flags & (OBD_BRW_FROM_GRANT | OBD_BRW_SYNC)) == OBD_BRW_FROM_GRANT)
+                    (lnb->flags & (OBD_BRW_FROM_GRANT | OBD_BRW_SYNC)) ==
+                    OBD_BRW_FROM_GRANT)
                         iobuf->dr_ignore_quota = 1;
+
+                if (!(lnb->flags & OBD_BRW_ASYNC)) {
+                        sync_journal_commit = 1;
+                }
         }
 
+        /* we try to get enough quota to write here, and let ldiskfs
+         * decide if it is out of quota or not b=14783 */
+        lquota_chkquota(filter_quota_interface_ref, obd, oa->o_uid, oa->o_gid,
+                        quota_pages, quota_pending, oti, inode,
+                        obj->ioo_bufcnt);
+
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         cleanup_phase = 2;
 
@@ -759,15 +722,15 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
                  * in the inode before filter_direct_io() - see bug 10357. */
                 save = iattr.ia_valid;
                 iattr.ia_valid &= (ATTR_UID | ATTR_GID);
-                rc = fsfilt_setattr(obd, res->dentry, oti->oti_handle, &iattr, 0);
-                CDEBUG(D_QUOTA, "set uid(%u)/gid(%u) to ino(%lu). rc(%d)\n", 
+                rc = fsfilt_setattr(obd, res->dentry, oti->oti_handle,&iattr,0);
+                CDEBUG(D_QUOTA, "set uid(%u)/gid(%u) to ino(%lu). rc(%d)\n",
                                 iattr.ia_uid, iattr.ia_gid, inode->i_ino, rc);
                 iattr.ia_valid = save & ~(ATTR_UID | ATTR_GID);
         }
 
         /* filter_direct_io drops i_mutex */
         rc = filter_direct_io(OBD_BRW_WRITE, res->dentry, iobuf, exp, &iattr,
-                              oti, &wait_handle);
+                              oti, sync_journal_commit ? &wait_handle : NULL);
         if (rc == 0)
                 obdo_from_inode(oa, inode,
                                 FILTER_VALID_FLAGS |OBD_MD_FLUID |OBD_MD_FLGID);
@@ -778,13 +741,18 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
 
         fsfilt_check_slow(obd, now, "direct_io");
 
-        err = fsfilt_commit_wait(obd, inode, wait_handle);
+        if (wait_handle)
+                err = fsfilt_commit_wait(obd, inode, wait_handle);
+        else
+                err = 0;
+
         if (err) {
                 CERROR("Failure to commit OST transaction (%d)?\n", err);
-                rc = err;
+                if (rc == 0)
+                        rc = err;
         }
 
-        if (obd->obd_replayable && !rc)
+        if (obd->obd_replayable && !rc && wait_handle)
                 LASSERTF(oti->oti_transno <= obd->obd_last_committed,
                          "oti_transno "LPU64" last_committed "LPU64"\n",
                          oti->oti_transno, obd->obd_last_committed);
@@ -793,8 +761,8 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
 
 cleanup:
         if (quota_pending[0] || quota_pending[1])
-                lquota_pending_commit(filter_quota_interface_ref, obd, oa->o_uid,
-                                      oa->o_gid, quota_pending);
+                lquota_pending_commit(filter_quota_interface_ref, obd,
+                                      oa->o_uid, oa->o_gid, quota_pending);
 
         filter_grant_commit(exp, niocount, res);
 
@@ -820,5 +788,23 @@ cleanup:
         CDEBUG(err ? D_ERROR : D_QUOTA,
                "filter adjust qunit! (rc:%d)\n", err);
 
+        for (i = 0, lnb = res; i < niocount; i++, lnb++) {
+                if (lnb->page == NULL)
+                        continue;
+
+                LASSERT(PageLocked(lnb->page));
+                unlock_page(lnb->page);
+
+                page_cache_release(lnb->page);
+                lnb->page = NULL;
+        }
+
+        if (inode) {
+                if (fo->fo_writethrough_cache == 0 ||
+                    i_size_read(inode) > fo->fo_readcache_max_filesize)
+                        filter_release_cache(obd, obj, nb, inode);
+                up_read(&inode->i_alloc_sem);
+        }
+
         RETURN(rc);
 }
diff --git a/lustre/obdfilter/filter_log.c b/lustre/obdfilter/filter_log.c
index 5a977b7..29c2a54 100644
--- a/lustre/obdfilter/filter_log.c
+++ b/lustre/obdfilter/filter_log.c
@@ -66,7 +66,7 @@ int filter_log_sz_change(struct llog_handle *cathandle,
         ENTRY;
 
         LOCK_INODE_MUTEX(inode);
-        ofd = inode->i_filterdata;
+        ofd = INODE_PRIVATE_DATA(inode);
 
         if (ofd && ofd->ofd_epoch >= io_epoch) {
                 if (ofd->ofd_epoch > io_epoch)
@@ -83,7 +83,7 @@ int filter_log_sz_change(struct llog_handle *cathandle,
                 if (!ofd)
                         GOTO(out, rc = -ENOMEM);
                 igrab(inode);
-                inode->i_filterdata = ofd;
+                INODE_PRIVATE_DATA(inode) = ofd;
                 ofd->ofd_epoch = io_epoch;
         }
         /* the decision to write a record is now made, unlock */
@@ -144,11 +144,11 @@ static int filter_recov_log_unlink_cb(struct llog_ctxt *ctxt,
                                       struct llog_rec_hdr *rec,
                                       struct llog_cookie *cookie)
 {
-        struct obd_device *obd = ctxt->loc_obd;
-        struct obd_export *exp = obd->obd_self_export;
+        struct obd_export *exp = ctxt->loc_obd->obd_self_export;
         struct llog_unlink_rec *lur;
         struct obdo *oa;
         obd_id oid;
+        obd_count count;
         int rc = 0;
         ENTRY;
 
@@ -158,20 +158,26 @@ static int filter_recov_log_unlink_cb(struct llog_ctxt *ctxt,
                 RETURN(-ENOMEM);
         oa->o_valid |= OBD_MD_FLCOOKIE;
         oa->o_id = lur->lur_oid;
-        oa->o_gr = lur->lur_ogen;
+        oa->o_gr = lur->lur_ogr;
         oa->o_lcookie = *cookie;
         oid = oa->o_id;
-
-        rc = filter_destroy(exp, oa, NULL, NULL, NULL);
-        OBDO_FREE(oa);
-        if (rc == -ENOENT) {
-                CDEBUG(D_RPCTRACE, "object already removed, send cookie\n");
-                llog_cancel(ctxt, NULL, 1, cookie, 0);
-                RETURN(0);
+        /* objid gap may require to destroy several objects in row */
+        count = lur->lur_count + 1;
+
+        while (count > 0) {
+                rc = filter_destroy(exp, oa, NULL, NULL, NULL);
+                if (rc == 0)
+                        CDEBUG(D_RPCTRACE, "object "LPU64" is destroyed\n",
+                               oid);
+                else if (rc != -ENOENT)
+                        CEMERG("error destroying object "LPU64": %d\n",
+                               oid, rc);
+                else
+                        rc = 0;
+                count--;
+                oid++;
         }
-
-        if (rc == 0)
-                CDEBUG(D_RPCTRACE, "object "LPU64" is destroyed\n", oid);
+        OBDO_FREE(oa);
 
         RETURN(rc);
 }
@@ -184,21 +190,31 @@ static int filter_recov_log_setattr_cb(struct llog_ctxt *ctxt,
 {
         struct obd_device *obd = ctxt->loc_obd;
         struct obd_export *exp = obd->obd_self_export;
-        struct llog_setattr_rec *lsr;
         struct obd_info oinfo = { { { 0 } } };
         obd_id oid;
         int rc = 0;
         ENTRY;
 
-        lsr = (struct llog_setattr_rec *)rec;
         OBDO_ALLOC(oinfo.oi_oa);
 
+        if (rec->lrh_type == MDS_SETATTR_REC) {
+                struct llog_setattr_rec *lsr = (struct llog_setattr_rec *)rec;
+
+                oinfo.oi_oa->o_id = lsr->lsr_oid;
+                oinfo.oi_oa->o_gr = lsr->lsr_ogr;
+                oinfo.oi_oa->o_uid = lsr->lsr_uid;
+                oinfo.oi_oa->o_gid = lsr->lsr_gid;
+        } else {
+                struct llog_setattr64_rec *lsr = (struct llog_setattr64_rec *)rec;
+
+                oinfo.oi_oa->o_id = lsr->lsr_oid;
+                oinfo.oi_oa->o_gr = lsr->lsr_ogr;
+                oinfo.oi_oa->o_uid = lsr->lsr_uid;
+                oinfo.oi_oa->o_gid = lsr->lsr_gid;
+        }
+
         oinfo.oi_oa->o_valid |= (OBD_MD_FLID | OBD_MD_FLUID | OBD_MD_FLGID |
                                  OBD_MD_FLCOOKIE);
-        oinfo.oi_oa->o_id = lsr->lsr_oid;
-        oinfo.oi_oa->o_gr = lsr->lsr_ogen;
-        oinfo.oi_oa->o_uid = lsr->lsr_uid;
-        oinfo.oi_oa->o_gid = lsr->lsr_gid;
         oinfo.oi_oa->o_lcookie = *cookie;
         oid = oinfo.oi_oa->o_id;
 
@@ -243,6 +259,7 @@ int filter_recov_log_mds_ost_cb(struct llog_handle *llh,
                 rc = filter_recov_log_unlink_cb(ctxt, rec, &cookie);
                 break;
         case MDS_SETATTR_REC:
+        case MDS_SETATTR64_REC:
                 rc = filter_recov_log_setattr_cb(ctxt, rec, &cookie);
                 break;
         case LLOG_GEN_REC: {
diff --git a/lustre/obdfilter/filter_lvb.c b/lustre/obdfilter/filter_lvb.c
index 3e77239..8a18a7e 100644
--- a/lustre/obdfilter/filter_lvb.c
+++ b/lustre/obdfilter/filter_lvb.c
@@ -66,11 +66,6 @@ static int filter_lvbo_init(struct ldlm_resource *res)
         LASSERT(res);
         LASSERT_SEM_LOCKED(&res->lr_lvb_sem);
 
-        /* we only want lvb's for object resources */
-        /* check for internal locks: these have name[1] != 0 */
-        if (res->lr_name.name[1])
-                RETURN(0);
-
         if (res->lr_lvb_data)
                 RETURN(0);
 
@@ -135,11 +130,6 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct ptlrpc_request *
 
         LASSERT(res);
 
-        /* we only want lvb's for object resources */
-        /* check for internal locks: these have name[1] != 0 */
-        if (res->lr_name.name[1])
-                RETURN(0);
-
         down(&res->lr_lvb_sem);
         lvb = res->lr_lvb_data;
         if (lvb == NULL) {
@@ -223,8 +213,8 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct ptlrpc_request *
         }
         if (lvb->lvb_blocks != dentry->d_inode->i_blocks) {
                 CDEBUG(D_DLMTRACE,"res: "LPU64" updating lvb blocks from disk: "
-                       LPU64" -> %lu\n", res->lr_name.name[0],
-                       lvb->lvb_blocks, dentry->d_inode->i_blocks);
+                       LPU64" -> "LPU64"\n", res->lr_name.name[0],
+                       lvb->lvb_blocks, (__u64)dentry->d_inode->i_blocks);
                 lvb->lvb_blocks = dentry->d_inode->i_blocks;
         }
 
diff --git a/lustre/obdfilter/lproc_obdfilter.c b/lustre/obdfilter/lproc_obdfilter.c
index f09354f..dc2a396 100644
--- a/lustre/obdfilter/lproc_obdfilter.c
+++ b/lustre/obdfilter/lproc_obdfilter.c
@@ -187,6 +187,84 @@ int lprocfs_filter_wr_fmd_max_age(struct file *file, const char *buffer,
         return count;
 }
 
+static int lprocfs_filter_rd_cache(char *page, char **start, off_t off,
+                                   int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%u\n", obd->u.filter.fo_read_cache);
+}
+
+static int lprocfs_filter_wr_cache(struct file *file, const char *buffer,
+                     unsigned long count, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        int val, rc;
+        LASSERT(obd != NULL);
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+
+        if (rc)
+                return rc;
+
+        obd->u.filter.fo_read_cache = val;
+        return count;
+}
+
+static int lprocfs_filter_rd_wcache(char *page, char **start, off_t off,
+                                   int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%u\n", obd->u.filter.fo_writethrough_cache);
+}
+
+static int lprocfs_filter_wr_wcache(struct file *file, const char *buffer,
+                     unsigned long count, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        int val, rc;
+        LASSERT(obd != NULL);
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+
+        if (rc)
+                return rc;
+
+        obd->u.filter.fo_writethrough_cache = val;
+        return count;
+}
+
+int lprocfs_filter_rd_syncjournal(char *page, char **start, off_t off,
+                                  int count, int *eof, void *data)
+{
+        struct obd_device *obd = data;
+        int rc;
+
+        rc = snprintf(page, count, "%u\n", obd->u.filter.fo_syncjournal);
+        return rc;
+}
+
+int lprocfs_filter_wr_syncjournal(struct file *file, const char *buffer,
+                                  unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val;
+        int rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        if (val < 0)
+                return -EINVAL;
+
+        obd->u.filter.fo_syncjournal = !!val;
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_filter_obd_vars[] = {
         { "uuid",         lprocfs_rd_uuid,          0, 0 },
         { "blocksize",    lprocfs_rd_blksize,       0, 0 },
@@ -232,6 +310,16 @@ static struct lprocfs_vars lprocfs_filter_obd_vars[] = {
                           lprocfs_filter_wr_fmd_max_num, 0 },
         { "client_cache_seconds", lprocfs_filter_rd_fmd_max_age,
                           lprocfs_filter_wr_fmd_max_age, 0 },
+        { "read_cache_enable", lprocfs_filter_rd_cache, lprocfs_filter_wr_cache, 0},
+        { "writethrough_cache_enable", lprocfs_filter_rd_wcache,
+                          lprocfs_filter_wr_wcache, 0},
+#ifdef HAVE_DELAYED_RECOVERY
+        { "stale_export_age", lprocfs_obd_rd_stale_export_age,
+                              lprocfs_obd_wr_stale_export_age, 0},
+        { "flush_stale_exports", 0, lprocfs_obd_wr_flush_stale_exports, 0 },
+#endif
+        { "sync_journal", lprocfs_filter_rd_syncjournal,
+                          lprocfs_filter_wr_syncjournal, 0 },
         { 0 }
 };
 
@@ -244,7 +332,6 @@ void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages,
                   unsigned long *blocks, int blocks_per_page, int wr)
 {
         struct filter_obd *filter = &exp->exp_obd->u.filter;
-        struct filter_export_data *fed = &exp->exp_filter_data;
         struct page *last_page = NULL;
         unsigned long *last_block = NULL;
         unsigned long discont_pages = 0;
@@ -256,8 +343,6 @@ void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages,
 
         lprocfs_oh_tally_log2(&filter->fo_filter_stats.hist[BRW_R_PAGES + wr],
                               nr_pages);
-        lprocfs_oh_tally_log2(&fed->fed_brw_stats.hist[BRW_R_PAGES + wr],
-                              nr_pages);
         if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats)
                 lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->
                                         hist[BRW_R_PAGES + wr], nr_pages);
@@ -276,12 +361,8 @@ void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages,
 
         lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_DISCONT_PAGES +wr],
                          discont_pages);
-        lprocfs_oh_tally(&fed->fed_brw_stats.hist[BRW_R_DISCONT_PAGES + wr],
-                         discont_pages);
         lprocfs_oh_tally(&filter->fo_filter_stats.hist[BRW_R_DISCONT_BLOCKS+wr],
                          discont_blocks);
-        lprocfs_oh_tally(&fed->fed_brw_stats.hist[BRW_R_DISCONT_BLOCKS + wr],
-                         discont_blocks);
 
         if (exp->exp_nid_stats && exp->exp_nid_stats->nid_brw_stats) {
                 lprocfs_oh_tally_log2(&exp->exp_nid_stats->nid_brw_stats->
@@ -409,30 +490,6 @@ int lproc_filter_attach_seqstat(struct obd_device *dev)
                                       &filter_brw_stats_fops, dev);
 }
 
-static int filter_per_export_stats_seq_show(struct seq_file *seq, void *v)
-{
-        struct filter_export_data *fed = seq->private;
-
-        brw_stats_show(seq, &fed->fed_brw_stats);
-
-        return 0;
-}
-
-static ssize_t filter_per_export_stats_seq_write(struct file *file,
-                                       const char *buf, size_t len, loff_t *off)
-{
-        struct seq_file *seq = file->private_data;
-        struct filter_export_data *fed = seq->private;
-        int i;
-
-        for (i = 0; i < BRW_LAST; i++)
-                lprocfs_oh_clear(&fed->fed_brw_stats.hist[i]);
-
-        return len;
-}
-
-LPROC_SEQ_FOPS(filter_per_export_stats);
-
 void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars)
 {
     lvars->module_vars  = lprocfs_filter_module_vars;
@@ -441,10 +498,10 @@ void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars)
 
 static int filter_per_nid_stats_seq_show(struct seq_file *seq, void *v)
 {
-        nid_stat_t *tmp = seq->private;
+        nid_stat_t * stat = seq->private;
 
-        if (tmp->nid_brw_stats)
-                brw_stats_show(seq, tmp->nid_brw_stats);
+        if (stat->nid_brw_stats)
+                brw_stats_show(seq, stat->nid_brw_stats);
 
         return 0;
 }
@@ -453,13 +510,13 @@ static ssize_t filter_per_nid_stats_seq_write(struct file *file,
                                               const char *buf, size_t len,
                                               loff_t *off)
 {
-        struct seq_file *seq = file->private_data;
-        nid_stat_t *tmp = seq->private;
+        struct seq_file *seq  = file->private_data;
+        nid_stat_t      *stat = seq->private;
         int i;
 
-        if (tmp->nid_brw_stats)
+        if (stat->nid_brw_stats)
                 for (i = 0; i < BRW_LAST; i++)
-                        lprocfs_oh_clear(&tmp->nid_brw_stats->hist[i]);
+                        lprocfs_oh_clear(&stat->nid_brw_stats->hist[i]);
 
         return len;
 }
diff --git a/lustre/osc/Makefile.in b/lustre/osc/Makefile.in
index 2eb2eea..4618145 100644
--- a/lustre/osc/Makefile.in
+++ b/lustre/osc/Makefile.in
@@ -1,4 +1,6 @@
 MODULES := osc
 osc-objs := osc_request.o lproc_osc.o osc_create.o cache.o
 
+EXTRA_DIST = $(osc-objs:%.o=%.c) osc_internal.h
+
 @INCLUDE_RULES@
diff --git a/lustre/osc/autoMakefile.am b/lustre/osc/autoMakefile.am
index 65c588b..b99a9bf 100644
--- a/lustre/osc/autoMakefile.am
+++ b/lustre/osc/autoMakefile.am
@@ -69,4 +69,3 @@ endif
 install-data-hook: $(install_data_hook)
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES = $(osc-objs:%.o=%.c) osc_internal.h
diff --git a/lustre/osc/autoMakefile.in b/lustre/osc/autoMakefile.in
index eb72a1c..fcf10e8 100644
--- a/lustre/osc/autoMakefile.in
+++ b/lustre/osc/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -350,7 +350,6 @@ target_vendor = @target_vendor@
 @DARWIN_TRUE@@MODULES_TRUE at plist_DATA := Info.plist
 
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
-DIST_SOURCES = $(osc-objs:%.o=%.c) osc_internal.h
 subdir = lustre/osc
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -393,6 +392,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libosc_a_SOURCES_DIST) $(am__osc_SOURCES_DIST)
 DATA = $(modulefs_DATA) $(plist_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c
index 15c6860..37d2ec8 100644
--- a/lustre/osc/lproc_osc.c
+++ b/lustre/osc/lproc_osc.c
@@ -223,6 +223,70 @@ static int osc_rd_cur_grant_bytes(char *page, char **start, off_t off,
         return rc;
 }
 
+static int osc_wr_cur_grant_bytes(struct file *file, const char *buffer,
+                                  unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        struct client_obd *cli = &obd->u.cli;
+        int                rc;
+        __u64              val;
+
+        if (obd == NULL)
+                return 0;
+
+        rc = lprocfs_write_u64_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        /* this is only for shrinking grant */
+        client_obd_list_lock(&cli->cl_loi_list_lock);
+        if (val >= cli->cl_avail_grant) {
+                client_obd_list_unlock(&cli->cl_loi_list_lock);
+                return 0;
+        }
+        client_obd_list_unlock(&cli->cl_loi_list_lock);
+
+        LPROCFS_CLIMP_CHECK(obd);
+        if (cli->cl_import->imp_state == LUSTRE_IMP_FULL)
+                rc = osc_shrink_grant_to_target(cli, val);
+        LPROCFS_CLIMP_EXIT(obd);
+        if (rc)
+                return rc;
+        return count;
+}
+
+static int osc_rd_grant_shrink_interval(char *page, char **start, off_t off,
+                                        int count, int *eof, void *data)
+{
+        struct obd_device *obd = data;
+
+        if (obd == NULL)
+                return 0;
+        return snprintf(page, count, "%d\n",
+                        obd->u.cli.cl_grant_shrink_interval);
+}
+
+static int osc_wr_grant_shrink_interval(struct file *file, const char *buffer,
+                                        unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val, rc;
+
+        if (obd == NULL)
+                return 0;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        if (val <= 0)
+                return -ERANGE;
+
+        obd->u.cli.cl_grant_shrink_interval = val;
+
+        return count;
+}
+
 static int osc_rd_create_count(char *page, char **start, off_t off, int count,
                                int *eof, void *data)
 {
@@ -465,7 +529,10 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
                                 osc_wr_max_rpcs_in_flight, 0 },
         { "max_dirty_mb",    osc_rd_max_dirty_mb, osc_wr_max_dirty_mb, 0 },
         { "cur_dirty_bytes", osc_rd_cur_dirty_bytes, 0, 0 },
-        { "cur_grant_bytes", osc_rd_cur_grant_bytes, 0, 0 },
+        { "cur_grant_bytes", osc_rd_cur_grant_bytes,
+                             osc_wr_cur_grant_bytes, 0 },
+        { "grant_shrink_interval", osc_rd_grant_shrink_interval,
+                                   osc_wr_grant_shrink_interval, 0 },
         { "create_count",    osc_rd_create_count, osc_wr_create_count, 0 },
         { "max_create_count", osc_rd_max_create_count,
                               osc_wr_max_create_count, 0},
@@ -476,6 +543,7 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
         { "resend_count",  osc_rd_resend_count, osc_wr_resend_count, 0},
         { "timeouts",        lprocfs_rd_timeouts,      0, 0 },
         { "import",          lprocfs_rd_import,    0, 0 },
+        { "state",           lprocfs_rd_state,         0, 0 },
         { 0 }
 };
 
diff --git a/lustre/osc/osc_create.c b/lustre/osc/osc_create.c
index 47667d5..af45e6c 100644
--- a/lustre/osc/osc_create.c
+++ b/lustre/osc/osc_create.c
@@ -76,7 +76,7 @@ static int osc_interpret_create(struct ptlrpc_request *req, void *data, int rc)
 
         oscc = req->rq_async_args.pointer_arg[0];
         LASSERT(oscc && (oscc->oscc_obd != LP_POISON));
-        
+
         spin_lock(&oscc->oscc_lock);
         oscc->oscc_flags &= ~OSCC_FLAG_CREATING;
         switch (rc) {
@@ -84,11 +84,26 @@ static int osc_interpret_create(struct ptlrpc_request *req, void *data, int rc)
                 if (body) {
                         int diff = body->oa.o_id - oscc->oscc_last_id;
 
-                        if (diff < oscc->oscc_grow_count)
-                                oscc->oscc_grow_count =
-                                        max(diff/3, OST_MIN_PRECREATE);
-                        else
+                        /* oscc_internal_create() stores the original value of
+                         * grow_count in rq_async_args.space[0].
+                         * We can't compare against oscc_grow_count directly,
+                         * because it may have been increased while the RPC
+                         * is in flight, so we would always find ourselves
+                         * having created fewer objects and decreasing the
+                         * precreate request size.  b=18577 */
+                        if (diff < (int) req->rq_async_args.space[0]) {
+                                /* the OST has not managed to create all the
+                                 * objects we asked for */
+                                oscc->oscc_grow_count = max(diff,
+                                                            OST_MIN_PRECREATE);
+                                /* don't bump grow_count next time */
+                                oscc->oscc_flags |= OSCC_FLAG_LOW;
+                        } else {
+                                /* the OST is able to keep up with the work,
+                                 * we could consider increasing grow_count
+                                 * next time if needed */
                                 oscc->oscc_flags &= ~OSCC_FLAG_LOW;
+                        }
                         oscc->oscc_last_id = body->oa.o_id;
                 }
                 spin_unlock(&oscc->oscc_lock);
@@ -182,7 +197,9 @@ static int oscc_internal_create(struct osc_creator *oscc)
 
         spin_lock(&oscc->oscc_lock);
         body->oa.o_id = oscc->oscc_last_id + oscc->oscc_grow_count;
-        body->oa.o_valid |= OBD_MD_FLID;
+        body->oa.o_gr = 0;
+        body->oa.o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
+        request->rq_async_args.space[0] = oscc->oscc_grow_count;
         spin_unlock(&oscc->oscc_lock);
         CDEBUG(D_RPCTRACE, "prealloc through id "LPU64" (last seen "LPU64")\n",
                body->oa.o_id, oscc->oscc_last_id);
@@ -307,6 +324,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
 {
         struct lov_stripe_md *lsm;
         struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
+        struct obd_import  *imp  = exp->exp_obd->u.cli.cl_import;
         int try_again = 1, rc = 0;
         ENTRY;
         LASSERT(oa);
@@ -341,18 +359,28 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                        oscc->oscc_obd->obd_name, oscc->oscc_next_id - 1);
 
                 /* delete from next_id on up */
-                oa->o_valid |= OBD_MD_FLID;
+                oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
                 oa->o_id = oscc->oscc_next_id - 1;
+                oa->o_gr = 0;
 
                 rc = osc_real_create(exp, oa, ea, NULL);
 
                 spin_lock(&oscc->oscc_lock);
                 oscc->oscc_flags &= ~OSCC_FLAG_SYNC_IN_PROGRESS;
                 if (rc == 0 || rc == -ENOSPC) {
+                        struct obd_connect_data *ocd;
+
                         if (rc == -ENOSPC)
                                 oscc->oscc_flags |= OSCC_FLAG_NOSPC;
                         oscc->oscc_flags &= ~OSCC_FLAG_RECOVERING;
                         oscc->oscc_last_id = oa->o_id;
+                        ocd = &imp->imp_connect_data;
+                        if (ocd->ocd_connect_flags & OBD_CONNECT_SKIP_ORPHAN) {
+                                CDEBUG(D_HA, "%s: Skip orphan set, reset last "
+                                       "objid\n", oscc->oscc_obd->obd_name);
+                                oscc->oscc_next_id = oa->o_id + 1;
+                        }
+
                         CDEBUG(D_HA, "%s: oscc recovery finished, last_id: "
                                LPU64", rc: %d\n", oscc->oscc_obd->obd_name,
                                oscc->oscc_last_id, rc);
diff --git a/lustre/osc/osc_internal.h b/lustre/osc/osc_internal.h
index eee9700..3a31967 100644
--- a/lustre/osc/osc_internal.h
+++ b/lustre/osc/osc_internal.h
@@ -91,11 +91,12 @@ struct osc_cache_waiter {
 
 int osc_precreate(struct obd_export *exp);
 int osc_create(struct obd_export *exp, struct obdo *oa,
-	       struct lov_stripe_md **ea, struct obd_trans_info *oti);
+               struct lov_stripe_md **ea, struct obd_trans_info *oti);
 int osc_real_create(struct obd_export *exp, struct obdo *oa,
-	       struct lov_stripe_md **ea, struct obd_trans_info *oti);
+                    struct lov_stripe_md **ea, struct obd_trans_info *oti);
 void oscc_init(struct obd_device *obd);
 void osc_wake_cache_waiters(struct client_obd *cli);
+int osc_shrink_grant_to_target(struct client_obd *cli, long target);
 
 #ifdef LPROCFS
 int lproc_osc_attach_seqstat(struct obd_device *dev);
@@ -121,8 +122,13 @@ static inline int osc_recoverable_error(int rc)
 /* return 1 if osc should be resend request */
 static inline int osc_should_resend(int resend, struct client_obd *cli)
 {
-        return atomic_read(&cli->cl_resends) ? 
-                atomic_read(&cli->cl_resends) > resend : 1; 
+        return atomic_read(&cli->cl_resends) ?
+                atomic_read(&cli->cl_resends) > resend : 1;
+}
+
+static inline int osc_exp_is_2_0_server(struct obd_export *exp) {
+       LASSERT(exp);
+       return !!(exp->exp_connect_flags & OBD_CONNECT_FID);
 }
 
 
diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
index 9c869aa..12b4be0 100644
--- a/lustre/osc/osc_request.c
+++ b/lustre/osc/osc_request.c
@@ -176,7 +176,7 @@ static int osc_getattr_interpret(struct ptlrpc_request *req,
                                   lustre_swab_ost_body);
         if (body) {
                 CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
-                memcpy(aa->aa_oi->oi_oa, &body->oa, sizeof(*aa->aa_oi->oi_oa));
+                lustre_get_wire_obdo(aa->aa_oi->oi_oa, &body->oa);
 
                 /* This should really be sent by the OST */
                 aa->aa_oi->oi_oa->o_blksize = PTLRPC_MAX_BRW_SIZE;
@@ -206,7 +206,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        memcpy(&body->oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
+        lustre_set_wire_obdo(&body->oa, oinfo->oi_oa);
 
         ptlrpc_req_set_repsize(req, 2, size);
         req->rq_interpret_reply = osc_getattr_interpret;
@@ -233,7 +233,7 @@ static int osc_getattr(struct obd_export *exp, struct obd_info *oinfo)
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        memcpy(&body->oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
+        lustre_set_wire_obdo(&body->oa, oinfo->oi_oa);
 
         ptlrpc_req_set_repsize(req, 2, size);
 
@@ -251,7 +251,7 @@ static int osc_getattr(struct obd_export *exp, struct obd_info *oinfo)
         }
 
         CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
-        memcpy(oinfo->oi_oa, &body->oa, sizeof(*oinfo->oi_oa));
+        lustre_get_wire_obdo(oinfo->oi_oa, &body->oa);
 
         /* This should really be sent by the OST */
         oinfo->oi_oa->o_blksize = PTLRPC_MAX_BRW_SIZE;
@@ -278,7 +278,7 @@ static int osc_setattr(struct obd_export *exp, struct obd_info *oinfo,
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        memcpy(&body->oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
+        lustre_set_wire_obdo(&body->oa, oinfo->oi_oa);
 
         ptlrpc_req_set_repsize(req, 2, size);
 
@@ -291,7 +291,7 @@ static int osc_setattr(struct obd_export *exp, struct obd_info *oinfo,
         if (body == NULL)
                 GOTO(out, rc = -EPROTO);
 
-        memcpy(oinfo->oi_oa, &body->oa, sizeof(*oinfo->oi_oa));
+        lustre_get_wire_obdo(oinfo->oi_oa, &body->oa);
 
         EXIT;
 out:
@@ -315,7 +315,7 @@ static int osc_setattr_interpret(struct ptlrpc_request *req,
                 GOTO(out, rc = -EPROTO);
         }
 
-        memcpy(aa->aa_oi->oi_oa, &body->oa, sizeof(*aa->aa_oi->oi_oa));
+        lustre_get_wire_obdo(aa->aa_oi->oi_oa, &body->oa);
 out:
         rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc);
         RETURN(rc);
@@ -327,12 +327,17 @@ static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 {
         struct ptlrpc_request *req;
         struct ost_body *body;
-        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
+        __u32 size[3] = { sizeof(struct ptlrpc_body), sizeof(*body), 0 };
+        int bufcount = 2;
         struct osc_async_args *aa;
         ENTRY;
 
+        if (osc_exp_is_2_0_server(exp)) {
+                bufcount = 3;
+        }
+
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OST_VERSION,
-                              OST_SETATTR, 2, size, NULL);
+                              OST_SETATTR, bufcount, size, NULL);
         if (!req)
                 RETURN(-ENOMEM);
 
@@ -343,7 +348,7 @@ static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
                 oinfo->oi_oa->o_lcookie = *oti->oti_logcookies;
         }
 
-        memcpy(&body->oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
+        lustre_set_wire_obdo(&body->oa, oinfo->oi_oa);
         ptlrpc_req_set_repsize(req, 2, size);
         /* do mds to ost setattr asynchronouly */
         if (!rqset) {
@@ -388,7 +393,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa,
                 GOTO(out, rc = -ENOMEM);
 
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        memcpy(&body->oa, oa, sizeof(body->oa));
+        lustre_set_wire_obdo(&body->oa, oa);
 
         ptlrpc_req_set_repsize(req, 2, size);
         if ((oa->o_valid & OBD_MD_FLFLAGS) &&
@@ -410,7 +415,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa,
                 GOTO (out_req, rc = -EPROTO);
         }
 
-        memcpy(oa, &body->oa, sizeof(*oa));
+        lustre_get_wire_obdo(oa, &body->oa);
 
         /* This should really be sent by the OST */
         oa->o_blksize = PTLRPC_MAX_BRW_SIZE;
@@ -459,7 +464,7 @@ static int osc_punch_interpret(struct ptlrpc_request *req,
                 GOTO(out, rc = -EPROTO);
         }
 
-        memcpy(aa->aa_oi->oi_oa, &body->oa, sizeof(*aa->aa_oi->oi_oa));
+        lustre_get_wire_obdo(aa->aa_oi->oi_oa, &body->oa);
 out:
         rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc);
         RETURN(rc);
@@ -489,7 +494,7 @@ static int osc_punch(struct obd_export *exp, struct obd_info *oinfo,
         ptlrpc_at_set_req_timeout(req);
 
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        memcpy(&body->oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa));
+        lustre_set_wire_obdo(&body->oa, oinfo->oi_oa);
 
         /* overload the size and blocks fields in the oa with start/end */
         body->oa.o_size = oinfo->oi_policy.l_extent.start;
@@ -507,16 +512,39 @@ static int osc_punch(struct obd_export *exp, struct obd_info *oinfo,
         RETURN(0);
 }
 
-static int osc_sync(struct obd_export *exp, struct obdo *oa,
-                    struct lov_stripe_md *md, obd_size start, obd_size end)
+static int osc_sync_interpret(struct ptlrpc_request *req,
+                              struct osc_async_args *aa, int rc)
+{
+        struct ost_body *body;
+        ENTRY;
+
+        if (rc)
+                GOTO(out, rc);
+
+        body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
+                                  lustre_swab_ost_body);
+        if (body == NULL) {
+                CERROR ("can't unpack ost_body\n");
+                GOTO(out, rc = -EPROTO);
+        }
+
+        *aa->aa_oi->oi_oa = body->oa;
+out:
+        rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc);
+        RETURN(rc);
+}
+
+static int osc_sync(struct obd_export *exp, struct obd_info *oinfo,
+                    obd_size start, obd_size end,
+                    struct ptlrpc_request_set *set)
 {
         struct ptlrpc_request *req;
         struct ost_body *body;
         __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
-        int rc;
+        struct osc_async_args *aa;
         ENTRY;
 
-        if (!oa) {
+        if (!oinfo->oi_oa) {
                 CERROR("oa NULL\n");
                 RETURN(-EINVAL);
         }
@@ -527,7 +555,7 @@ static int osc_sync(struct obd_export *exp, struct obdo *oa,
                 RETURN(-ENOMEM);
 
         body = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*body));
-        memcpy(&body->oa, oa, sizeof(*oa));
+        lustre_set_wire_obdo(&body->oa, oinfo->oi_oa);
 
         /* overload the size and blocks fields in the oa with start/end */
         body->oa.o_size = start;
@@ -535,39 +563,31 @@ static int osc_sync(struct obd_export *exp, struct obdo *oa,
         body->oa.o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
 
         ptlrpc_req_set_repsize(req, 2, size);
+        req->rq_interpret_reply = osc_sync_interpret;
 
-        rc = ptlrpc_queue_wait(req);
-        if (rc)
-                GOTO(out, rc);
-
-        body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*body),
-                                  lustre_swab_ost_body);
-        if (body == NULL) {
-                CERROR ("can't unpack ost_body\n");
-                GOTO (out, rc = -EPROTO);
-        }
-
-        memcpy(oa, &body->oa, sizeof(*oa));
+        CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
+        aa = ptlrpc_req_async_args(req);
+        aa->aa_oi = oinfo;
 
-        EXIT;
- out:
-        ptlrpc_req_finished(req);
-        return rc;
+        ptlrpc_set_add_req(set, req);
+        RETURN (0);
 }
 
 /* Find and cancel locally locks matched by @mode in the resource found by
  * @objid. Found locks are added into @cancel list. Returns the amount of
  * locks added to @cancels list. */
-static int osc_resource_get_unused(struct obd_export *exp, __u64 objid,
+static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa,
                                    struct list_head *cancels, ldlm_mode_t mode,
                                    int lock_flags)
 {
         struct ldlm_namespace *ns = exp->exp_obd->obd_namespace;
-        struct ldlm_res_id res_id = { .name = { objid } };
-        struct ldlm_resource *res = ldlm_resource_get(ns, NULL, res_id, 0, 0);
+        struct ldlm_res_id res_id;
+        struct ldlm_resource *res;
         int count;
         ENTRY;
 
+        osc_build_res_name(oa->o_id, oa->o_gr, &res_id);
+        res = ldlm_resource_get(ns, NULL, res_id, 0, 0);
         if (res == NULL)
                 RETURN(0);
 
@@ -635,7 +655,7 @@ static int osc_destroy(struct obd_export *exp, struct obdo *oa,
 
         LASSERT(oa->o_id != 0);
 
-        count = osc_resource_get_unused(exp, oa->o_id, &cancels, LCK_PW,
+        count = osc_resource_get_unused(exp, oa, &cancels, LCK_PW,
                                         LDLM_FL_DISCARD_DATA);
         if (exp_connect_cancelset(exp))
                 bufcount = 3;
@@ -653,14 +673,15 @@ static int osc_destroy(struct obd_export *exp, struct obdo *oa,
                 oa->o_lcookie = *oti->oti_logcookies;
         }
 
-        memcpy(&body->oa, oa, sizeof(*oa));
+        lustre_set_wire_obdo(&body->oa, oa);
         ptlrpc_req_set_repsize(req, 2, size);
 
         /* don't throttle destroy RPCs for the MDT */
         if (!(cli->cl_import->imp_connect_flags_orig & OBD_CONNECT_MDS)) {
                 req->rq_interpret_reply = osc_destroy_interpret;
                 if (!osc_can_send_destroy(cli)) {
-                        struct l_wait_info lwi = { 0 };
+                        struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP,
+                                                          NULL);
 
                         /*
                          * Wait until the number of on-going destroy RPCs drops
@@ -709,6 +730,15 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
         client_obd_list_unlock(&cli->cl_loi_list_lock);
         CDEBUG(D_CACHE,"dirty: "LPU64" undirty: %u dropped %u grant: "LPU64"\n",
                oa->o_dirty, oa->o_undirty, oa->o_dropped, oa->o_grant);
+
+}
+
+static void osc_update_next_shrink(struct client_obd *cli)
+{
+        cli->cl_next_shrink_grant =
+                cfs_time_shift(cli->cl_grant_shrink_interval);
+        CDEBUG(D_CACHE, "next time %ld to shrink grant \n",
+               cli->cl_next_shrink_grant);
 }
 
 /* caller must hold loi_list_lock */
@@ -722,6 +752,7 @@ static void osc_consume_write_grant(struct client_obd *cli,struct brw_page *pga)
                CFS_PAGE_SIZE, pga, pga->pg);
         LASSERTF(cli->cl_avail_grant >= 0, "invalid avail grant is %ld \n",
                  cli->cl_avail_grant);
+        osc_update_next_shrink(cli);
 }
 
 /* the companion to osc_consume_write_grant, called when a brw has completed.
@@ -810,25 +841,176 @@ void osc_wake_cache_waiters(struct client_obd *cli)
         EXIT;
 }
 
-static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)
+static void osc_update_grant(struct client_obd *cli, struct ost_body *body)
 {
         client_obd_list_lock(&cli->cl_loi_list_lock);
-        cli->cl_avail_grant = ocd->ocd_grant;
+        CDEBUG(D_CACHE, "got "LPU64" extra grant\n", body->oa.o_grant);
+        if (body->oa.o_valid & OBD_MD_FLGRANT)
+                cli->cl_avail_grant += body->oa.o_grant;
+        /* waiters are woken in brw_interpret */
         client_obd_list_unlock(&cli->cl_loi_list_lock);
+}
 
-        CDEBUG(D_CACHE, "setting cl_avail_grant: %ld cl_lost_grant: %ld\n",
-               cli->cl_avail_grant, cli->cl_lost_grant);
-        LASSERT(cli->cl_avail_grant >= 0);
+static int osc_set_info_async(struct obd_export *exp, obd_count keylen,
+                              void *key, obd_count vallen, void *val,
+                              struct ptlrpc_request_set *set);
+
+static int osc_shrink_grant_interpret(struct ptlrpc_request *req,
+                                      struct osc_grant_args *aa, int rc)
+{
+        struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
+        struct obdo *oa = aa->aa_oa;
+        struct ost_body *body;
+
+        if (rc != 0) {
+                client_obd_list_lock(&cli->cl_loi_list_lock);
+                cli->cl_avail_grant += oa->o_grant;
+                client_obd_list_unlock(&cli->cl_loi_list_lock);
+                GOTO(out, rc);
+        }
+        body = lustre_swab_repbuf(req, REPLY_REC_OFF, sizeof(*oa),
+                                lustre_swab_ost_body);
+        osc_update_grant(cli, body);
+out:
+        OBD_FREE_PTR(oa);
+        return rc;
 }
 
-static void osc_update_grant(struct client_obd *cli, struct ost_body *body)
+static void osc_shrink_grant_local(struct client_obd *cli, struct obdo *oa)
 {
         client_obd_list_lock(&cli->cl_loi_list_lock);
-        CDEBUG(D_CACHE, "got "LPU64" extra grant\n", body->oa.o_grant);
-        if (body->oa.o_valid & OBD_MD_FLGRANT)
+        oa->o_grant = cli->cl_avail_grant / 4;
+        cli->cl_avail_grant -= oa->o_grant;
+        client_obd_list_unlock(&cli->cl_loi_list_lock);
+        oa->o_flags |= OBD_FL_SHRINK_GRANT;
+        osc_update_next_shrink(cli);
+}
+
+/* Shrink the current grant, either from some large amount to enough for a
+ * full set of in-flight RPCs, or if we have already shrunk to that limit
+ * then to enough for a single RPC.  This avoids keeping more grant than
+ * needed, and avoids shrinking the grant piecemeal. */
+static int osc_shrink_grant(struct client_obd *cli)
+{
+        long target = (cli->cl_max_rpcs_in_flight + 1) *
+                      cli->cl_max_pages_per_rpc;
+
+        client_obd_list_lock(&cli->cl_loi_list_lock);
+        if (cli->cl_avail_grant <= target)
+                target = cli->cl_max_pages_per_rpc;
+        client_obd_list_unlock(&cli->cl_loi_list_lock);
+
+        return osc_shrink_grant_to_target(cli, target);
+}
+
+int osc_shrink_grant_to_target(struct client_obd *cli, long target)
+{
+        int    rc = 0;
+        struct ost_body     *body;
+        ENTRY;
+
+        client_obd_list_lock(&cli->cl_loi_list_lock);
+        /* Don't shrink if we are already above or below the desired limit
+         * We don't want to shrink below a single RPC, as that will negatively
+         * impact block allocation and long-term performance. */
+        if (target < cli->cl_max_pages_per_rpc)
+                target = cli->cl_max_pages_per_rpc;
+
+        if (target >= cli->cl_avail_grant) {
+                client_obd_list_unlock(&cli->cl_loi_list_lock);
+                RETURN(0);
+        }
+        client_obd_list_unlock(&cli->cl_loi_list_lock);
+
+        OBD_ALLOC_PTR(body);
+        if (!body)
+                RETURN(-ENOMEM);
+
+        osc_announce_cached(cli, &body->oa, 0);
+
+        client_obd_list_lock(&cli->cl_loi_list_lock);
+        body->oa.o_grant = cli->cl_avail_grant - target;
+        cli->cl_avail_grant = target;
+        client_obd_list_unlock(&cli->cl_loi_list_lock);
+        body->oa.o_flags |= OBD_FL_SHRINK_GRANT;
+        osc_update_next_shrink(cli);
+
+        rc = osc_set_info_async(cli->cl_import->imp_obd->obd_self_export,
+                                sizeof(KEY_GRANT_SHRINK), KEY_GRANT_SHRINK,
+                                sizeof(*body), body, NULL);
+        if (rc) {
+                client_obd_list_lock(&cli->cl_loi_list_lock);
                 cli->cl_avail_grant += body->oa.o_grant;
-        /* waiters are woken in brw_interpret */
+                client_obd_list_unlock(&cli->cl_loi_list_lock);
+        }
+        OBD_FREE_PTR(body);
+        RETURN(rc);
+}
+
+#define GRANT_SHRINK_LIMIT PTLRPC_MAX_BRW_SIZE
+static int osc_should_shrink_grant(struct client_obd *client)
+{
+        cfs_time_t time = cfs_time_current();
+        cfs_time_t next_shrink = client->cl_next_shrink_grant;
+        if (cfs_time_aftereq(time, next_shrink - 5 * CFS_TICK)) {
+                if (client->cl_import->imp_state == LUSTRE_IMP_FULL &&
+                    client->cl_avail_grant > GRANT_SHRINK_LIMIT)
+                        return 1;
+                else
+                        osc_update_next_shrink(client);
+        }
+        return 0;
+}
+
+static int osc_grant_shrink_grant_cb(struct timeout_item *item, void *data)
+{
+        struct client_obd *client;
+
+        list_for_each_entry(client, &item->ti_obd_list, cl_grant_shrink_list) {
+                if (osc_should_shrink_grant(client))
+                        osc_shrink_grant(client);
+        }
+        return 0;
+}
+
+static int osc_add_shrink_grant(struct client_obd *client)
+{
+        int rc;
+
+        rc = ptlrpc_add_timeout_client(client->cl_grant_shrink_interval,
+                                       TIMEOUT_GRANT,
+                                       osc_grant_shrink_grant_cb, NULL,
+                                       &client->cl_grant_shrink_list);
+        if (rc) {
+                CERROR("add grant client %s error %d\n",
+                        client->cl_import->imp_obd->obd_name, rc);
+                return rc;
+        }
+        CDEBUG(D_CACHE, "add grant client %s \n",
+               client->cl_import->imp_obd->obd_name);
+        osc_update_next_shrink(client);
+        return 0;
+}
+
+static int osc_del_shrink_grant(struct client_obd *client)
+{
+        return ptlrpc_del_timeout_client(&client->cl_grant_shrink_list,
+                                         TIMEOUT_GRANT);
+}
+
+static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)
+{
+        client_obd_list_lock(&cli->cl_loi_list_lock);
+        cli->cl_avail_grant = ocd->ocd_grant;
         client_obd_list_unlock(&cli->cl_loi_list_lock);
+
+        if (ocd->ocd_connect_flags & OBD_CONNECT_GRANT_SHRINK &&
+            list_empty(&cli->cl_grant_shrink_list))
+                osc_add_shrink_grant(cli);
+
+        CDEBUG(D_CACHE, "setting cl_avail_grant: %ld cl_lost_grant: %ld \n",
+               cli->cl_avail_grant, cli->cl_lost_grant);
+        LASSERT(cli->cl_avail_grant >= 0);
 }
 
 /* We assume that the reason this OSC got a short read is because it read
@@ -910,7 +1092,7 @@ static int check_write_rcs(struct ptlrpc_request *req,
 static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2)
 {
         if (p1->flag != p2->flag) {
-                unsigned mask = ~OBD_BRW_FROM_GRANT;
+                unsigned mask = ~(OBD_BRW_FROM_GRANT | OBD_BRW_ASYNC);
 
                 /* warn if we try to combine flags that we don't know to be
                  * safe to combine */
@@ -1013,8 +1195,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa,
         niobuf = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 2,
                                 niocount * sizeof(*niobuf));
 
-        memcpy(&body->oa, oa, sizeof(*oa));
-
+        lustre_set_wire_obdo(&body->oa, oa);
         obdo_to_ioobj(oa, ioobj);
         ioobj->ioo_bufcnt = niocount;
 
@@ -1065,6 +1246,8 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa,
                 (void *)(niobuf - niocount));
 
         osc_announce_cached(cli, &body->oa, opc == OST_WRITE ? requested_nob:0);
+        if (osc_should_shrink_grant(cli))
+                osc_shrink_grant_local(cli, &body->oa);
 
         /* size[REQ_REC_OFF] still sizeof (*body) */
         if (opc == OST_WRITE) {
@@ -1073,8 +1256,10 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa,
                          * it can be changed via lprocfs */
                         cksum_type_t cksum_type = cli->cl_cksum_type;
 
-                        if ((body->oa.o_valid & OBD_MD_FLFLAGS) == 0)
-                                oa->o_flags = body->oa.o_flags = 0;
+                        if ((body->oa.o_valid & OBD_MD_FLFLAGS) == 0) {
+                                oa->o_flags &= OBD_FL_LOCAL_MASK;
+                                body->oa.o_flags = 0;
+                        }
                         body->oa.o_flags |= cksum_type_pack(cksum_type);
                         body->oa.o_valid |= OBD_MD_FLCKSUM | OBD_MD_FLFLAGS;
                         body->oa.o_cksum = osc_checksum_bulk(requested_nob,
@@ -1180,7 +1365,7 @@ static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer,
 /* Note rc enters this function as number of bytes transferred */
 static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
 {
-        struct osc_brw_async_args *aa = (void *)&req->rq_async_args;
+        struct osc_brw_async_args *aa = ptlrpc_req_async_args(req);
         const lnet_process_id_t *peer =
                         &req->rq_import->imp_connection->c_peer;
         struct client_obd *cli = aa->aa_cli;
@@ -1317,7 +1502,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
         }
 out:
         if (rc >= 0)
-                memcpy(aa->aa_oa, &body->oa, sizeof(*aa->aa_oa));
+                lustre_get_wire_obdo(aa->aa_oa, &body->oa);
 
         RETURN(rc);
 }
@@ -1462,6 +1647,7 @@ static int async_internal(int cmd, struct obd_export *exp, struct obdo *oa,
         rc = osc_brw_prep_request(cmd, &exp->exp_obd->u.cli, oa, lsm,
                                   page_count, pga, &request);
 
+        CLASSERT(sizeof(*aa) <= sizeof(request->rq_async_args));
         aa = ptlrpc_req_async_args(request);
         if (cmd == OBD_BRW_READ) {
                 lprocfs_oh_tally_log2(&cli->cl_read_page_hist, page_count);
@@ -1580,15 +1766,18 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo,
         struct obdo *saved_oa = NULL;
         struct brw_page **ppga, **orig;
         struct obd_import *imp = class_exp2cliimp(exp);
-        struct client_obd *cli = &imp->imp_obd->u.cli;
+        struct client_obd *cli;
         int rc, page_count_orig;
         ENTRY;
 
+        LASSERT((imp != NULL) && (imp->imp_obd != NULL));
+        cli = &imp->imp_obd->u.cli;
+
         if (cmd & OBD_BRW_CHECK) {
                 /* The caller just wants to know if there's a chance that this
                  * I/O can succeed */
 
-                if (imp == NULL || imp->imp_invalid)
+                if (imp->imp_invalid)
                         RETURN(-EIO);
                 RETURN(0);
         }
@@ -1672,6 +1861,7 @@ static int osc_brw_async(int cmd, struct obd_export *exp,
         sort_brw_pages(ppga, page_count);
         while (page_count) {
                 struct brw_page **copy;
+                struct obdo *oa;
                 obd_count pages_per_brw;
 
                 pages_per_brw = min_t(obd_count, page_count,
@@ -1685,15 +1875,29 @@ static int osc_brw_async(int cmd, struct obd_export *exp,
                         if (copy == NULL)
                                 GOTO(out, rc = -ENOMEM);
                         memcpy(copy, ppga, pages_per_brw * sizeof(*copy));
-                } else
+
+                        OBDO_ALLOC(oa);
+                        if (oa == NULL) {
+                                OBD_FREE(copy, pages_per_brw * sizeof(*copy));
+                                GOTO(out, rc = -ENOMEM);
+                        }
+                        memcpy(oa, oinfo->oi_oa, sizeof(*oa));
+                        oa->o_flags |= OBD_FL_TEMPORARY;
+                } else {
                         copy = ppga;
+                        oa = oinfo->oi_oa;
+                        LASSERT(!(oa->o_flags & OBD_FL_TEMPORARY));
+                }
 
-                rc = async_internal(cmd, exp, oinfo->oi_oa, oinfo->oi_md,
-                                    pages_per_brw, copy, set);
+                rc = async_internal(cmd, exp, oa, oinfo->oi_md, pages_per_brw,
+                                    copy, set);
 
                 if (rc != 0) {
                         if (copy != ppga)
                                 OBD_FREE(copy, pages_per_brw * sizeof(*copy));
+
+                        if (oa->o_flags & OBD_FL_TEMPORARY)
+                                OBDO_FREE(oa);
                         break;
                 }
 
@@ -1934,7 +2138,9 @@ static void osc_ap_completion(struct client_obd *cli, struct obdo *oa,
                 oap->oap_request = NULL;
         }
 
+        spin_lock(&oap->oap_lock);
         oap->oap_async_flags = 0;
+        spin_unlock(&oap->oap_lock);
         oap->oap_interrupted = 0;
 
         if (oap->oap_cmd & OBD_BRW_WRITE) {
@@ -2010,15 +2216,19 @@ static int brw_interpret(struct ptlrpc_request *request, void *data, int rc)
                 }
                 OBDO_FREE(aa->aa_oa);
         } else { /* from async_internal() */
-                int i;
+                obd_count i;
                 for (i = 0; i < aa->aa_page_count; i++)
                         osc_release_write_grant(aa->aa_cli, aa->aa_ppga[i], 1);
+
+                if (aa->aa_oa->o_flags & OBD_FL_TEMPORARY)
+                        OBDO_FREE(aa->aa_oa);
         }
         osc_wake_cache_waiters(cli);
         osc_check_rpcs(cli);
         client_obd_list_unlock(&cli->cl_loi_list_lock);
 
         osc_release_ppga(aa->aa_ppga, aa->aa_page_count);
+
         RETURN(rc);
 }
 
@@ -2034,6 +2244,7 @@ static struct ptlrpc_request *osc_build_req(struct client_obd *cli,
         void *caller_data = NULL;
         struct osc_async_page *oap;
         struct ldlm_lock *lock = NULL;
+        obd_valid valid;
         int i, rc;
 
         ENTRY;
@@ -2075,14 +2286,32 @@ static struct ptlrpc_request *osc_build_req(struct client_obd *cli,
                 CERROR("prep_req failed: %d\n", rc);
                 GOTO(out, req = ERR_PTR(rc));
         }
+        oa = &((struct ost_body *)lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
+                                                 sizeof(struct ost_body)))->oa;
 
         /* Need to update the timestamps after the request is built in case
          * we race with setattr (locally or in queue at OST).  If OST gets
          * later setattr before earlier BRW (as determined by the request xid),
          * the OST will not use BRW timestamps.  Sadly, there is no obvious
          * way to do this in a single call.  bug 10150 */
-        ops->ap_update_obdo(caller_data, cmd, oa,
-                            OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLATIME);
+        if (pga[0]->flag & OBD_BRW_SRVLOCK) {
+                /* in case of lockless read/write do not use inode's
+                 * timestamps because concurrent stat might fill the
+                 * inode with out-of-date times, send current
+                 * instead */
+                if (cmd & OBD_BRW_WRITE) {
+                        oa->o_mtime = oa->o_ctime = LTIME_S(CURRENT_TIME);
+                        oa->o_valid |= OBD_MD_FLMTIME | OBD_MD_FLCTIME;
+                        valid = OBD_MD_FLATIME;
+                } else {
+                        oa->o_atime = LTIME_S(CURRENT_TIME);
+                        oa->o_valid |= OBD_MD_FLATIME;
+                        valid = OBD_MD_FLMTIME | OBD_MD_FLCTIME;
+                }
+        } else {
+                valid = OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLATIME;
+        }
+        ops->ap_update_obdo(caller_data, cmd, oa, valid);
 
         CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
@@ -2178,11 +2407,15 @@ static int osc_send_oap_rpc(struct client_obd *cli, struct lov_oinfo *loi,
                         case -EINTR:
                                 /* the io isn't needed.. tell the checks
                                  * below to complete the rpc with EINTR */
+                                spin_lock(&oap->oap_lock);
                                 oap->oap_async_flags |= ASYNC_COUNT_STABLE;
+                                spin_unlock(&oap->oap_lock);
                                 oap->oap_count = -EINTR;
                                 break;
                         case 0:
+                                spin_lock(&oap->oap_lock);
                                 oap->oap_async_flags |= ASYNC_READY;
+                                spin_unlock(&oap->oap_lock);
                                 break;
                         default:
                                 LASSERTF(0, "oap %p page %p returned %d "
@@ -2602,7 +2835,7 @@ int osc_prep_async_page(struct obd_export *exp, struct lov_stripe_md *lsm,
 
         /* If the page was marked as notcacheable - don't add to any locks */
         if (!nocache) {
-                oid.name[0] = loi->loi_id;
+                osc_build_res_name(loi->loi_id, loi->loi_gr, &oid);
                 /* This is the only place where we can call cache_add_extent
                    without oap_lock, because this page is locked now, and
                    the lock we are adding it to is referenced, so cannot lose
@@ -2675,7 +2908,9 @@ static int osc_queue_async_io(struct obd_export *exp, struct lov_stripe_md *lsm,
         oap->oap_page_off = off;
         oap->oap_count = count;
         oap->oap_brw_flags = brw_flags;
+        spin_lock(&oap->oap_lock);
         oap->oap_async_flags = async_flags;
+        spin_unlock(&oap->oap_lock);
 
         if (cmd & OBD_BRW_WRITE) {
                 rc = osc_enter_cache(cli, loi, oap);
@@ -2738,7 +2973,8 @@ static int osc_set_async_flags(struct obd_export *exp,
         }
 
         client_obd_list_lock(&cli->cl_loi_list_lock);
-
+        /* oap_lock provides atomic semantics of oap_async_flags access */
+        spin_lock(&oap->oap_lock);
         if (list_empty(&oap->oap_pending_item))
                 GOTO(out, rc = -EINVAL);
 
@@ -2761,6 +2997,7 @@ static int osc_set_async_flags(struct obd_export *exp,
         LOI_DEBUG(loi, "oap %p page %p has flags %x\n", oap, oap->oap_page,
                         oap->oap_async_flags);
 out:
+        spin_unlock(&oap->oap_lock);
         osc_check_rpcs(cli);
         client_obd_list_unlock(&cli->cl_loi_list_lock);
         RETURN(rc);
@@ -2800,7 +3037,9 @@ static int osc_queue_group_io(struct obd_export *exp, struct lov_stripe_md *lsm,
         oap->oap_page_off = off;
         oap->oap_count = count;
         oap->oap_brw_flags = brw_flags;
+        spin_lock(&oap->oap_lock);
         oap->oap_async_flags = async_flags;
+        spin_unlock(&oap->oap_lock);
 
         if (cmd & OBD_BRW_WRITE)
                 lop = &loi->loi_write_lop;
@@ -2890,7 +3129,9 @@ static int osc_teardown_async_page(struct obd_export *exp,
 
         if (!list_empty(&oap->oap_urgent_item)) {
                 list_del_init(&oap->oap_urgent_item);
+                spin_lock(&oap->oap_lock);
                 oap->oap_async_flags &= ~(ASYNC_URGENT | ASYNC_HP);
+                spin_unlock(&oap->oap_lock);
         }
 
         if (!list_empty(&oap->oap_pending_item)) {
@@ -2983,9 +3224,10 @@ static void osc_set_data_with_check(struct lustre_handle *lockh, void *data,
 static int osc_change_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm,
                              ldlm_iterator_t replace, void *data)
 {
-        struct ldlm_res_id res_id = { .name = {lsm->lsm_object_id} };
+        struct ldlm_res_id res_id;
         struct obd_device *obd = class_exp2obd(exp);
 
+        osc_build_res_name(lsm->lsm_object_id, lsm->lsm_object_gr, &res_id);
         ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data);
         return 0;
 }
@@ -3069,7 +3311,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo,
                        struct ldlm_enqueue_info *einfo,
                        struct ptlrpc_request_set *rqset)
 {
-        struct ldlm_res_id res_id = { .name = {oinfo->oi_md->lsm_object_id} };
+        struct ldlm_res_id res_id;
         struct obd_device *obd = exp->exp_obd;
         struct ldlm_reply *rep;
         struct ptlrpc_request *req = NULL;
@@ -3078,6 +3320,8 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo,
         int rc;
         ENTRY;
 
+        osc_build_res_name(oinfo->oi_md->lsm_object_id,
+                           oinfo->oi_md->lsm_object_gr, &res_id);
         /* Filesystem lock extents are extended to page boundaries so that
          * dealing with the page cache is a little smoother.  */
         oinfo->oi_policy.l_extent.start -=
@@ -3183,14 +3427,17 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo,
 
 static int osc_match(struct obd_export *exp, struct lov_stripe_md *lsm,
                      __u32 type, ldlm_policy_data_t *policy, __u32 mode,
-                     int *flags, void *data, struct lustre_handle *lockh)
+                     int *flags, void *data, struct lustre_handle *lockh,
+                     int *n_matches)
 {
-        struct ldlm_res_id res_id = { .name = {lsm->lsm_object_id} };
+        struct ldlm_res_id res_id;
         struct obd_device *obd = exp->exp_obd;
         int lflags = *flags;
         ldlm_mode_t rc;
         ENTRY;
 
+        osc_build_res_name(lsm->lsm_object_id, lsm->lsm_object_gr, &res_id);
+
         OBD_FAIL_RETURN(OBD_FAIL_OSC_MATCH, -EIO);
 
         /* Filesystem lock extents are extended to page boundaries so that
@@ -3213,7 +3460,8 @@ static int osc_match(struct obd_export *exp, struct lov_stripe_md *lsm,
                         ldlm_lock_addref(lockh, LCK_PR);
                         ldlm_lock_decref(lockh, LCK_PW);
                 }
-                RETURN(rc);
+                if (n_matches != NULL)
+                        (*n_matches)++;
         }
 
         RETURN(rc);
@@ -3236,19 +3484,30 @@ static int osc_cancel_unused(struct obd_export *exp,
                              struct lov_stripe_md *lsm, int flags, void *opaque)
 {
         struct obd_device *obd = class_exp2obd(exp);
-        struct ldlm_res_id res_id = { .name = {lsm->lsm_object_id} };
+        struct ldlm_res_id res_id, *resp = NULL;
+
+        if (lsm != NULL) {
+                resp = osc_build_res_name(lsm->lsm_object_id,
+                                          lsm->lsm_object_gr, &res_id);
+        }
+
+        return ldlm_cli_cancel_unused(obd->obd_namespace, resp, flags, opaque);
 
-        return ldlm_cli_cancel_unused(obd->obd_namespace, &res_id, flags,
-                                      opaque);
 }
 
 static int osc_join_lru(struct obd_export *exp,
                         struct lov_stripe_md *lsm, int join)
 {
         struct obd_device *obd = class_exp2obd(exp);
-        struct ldlm_res_id res_id = { .name = {lsm->lsm_object_id} };
+        struct ldlm_res_id res_id, *resp = NULL;
+
+        if (lsm != NULL) {
+                resp = osc_build_res_name(lsm->lsm_object_id,
+                                          lsm->lsm_object_gr, &res_id);
+        }
+
+        return ldlm_cli_join_lru(obd->obd_namespace, resp, join);
 
-        return ldlm_cli_join_lru(obd->obd_namespace, &res_id, join);
 }
 
 static int osc_statfs_interpret(struct ptlrpc_request *req,
@@ -3257,6 +3516,10 @@ static int osc_statfs_interpret(struct ptlrpc_request *req,
         struct obd_statfs *msfs;
         ENTRY;
 
+        if ((rc == -ENOTCONN || rc == -EAGAIN) &&
+            (aa->aa_oi->oi_flags & OBD_STATFS_NODELAY))
+                GOTO(out, rc = 0);
+
         if (rc != 0)
                 GOTO(out, rc);
 
@@ -3375,37 +3638,66 @@ static int osc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
  *
  * @lmmu is a pointer to an in-core struct with lmm_ost_count indicating
  * the maximum number of OST indices which will fit in the user buffer.
- * lmm_magic must be LOV_MAGIC (we only use 1 slot here).
+ * lmm_magic must be LOV_MAGIC_V1 or LOV_MAGIC_V3 (we only use 1 slot here).
  */
 static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
 {
-        struct lov_user_md lum, *lumk;
+        /* we use lov_user_md_v3 because it is larger than lov_user_md_v1 */
+        struct lov_user_md_v3 lum, *lumk;
         int rc = 0, lum_size;
+        struct lov_user_ost_data_v1 *lmm_objects;
         ENTRY;
 
         if (!lsm)
                 RETURN(-ENODATA);
 
-        if (copy_from_user(&lum, lump, sizeof(lum)))
+        /* we only need the header part from user space to get lmm_magic and
+         * lmm_stripe_count, (the header part is common to v1 and v3) */
+        lum_size = sizeof(struct lov_user_md_v1);
+        memset(&lum, 0x00, sizeof(lum));
+        if (copy_from_user(&lum, lump, lum_size))
                 RETURN(-EFAULT);
 
-        if (lum.lmm_magic != LOV_USER_MAGIC)
+        if ((lum.lmm_magic != LOV_USER_MAGIC_V1) &&
+            (lum.lmm_magic != LOV_USER_MAGIC_V3))
                 RETURN(-EINVAL);
 
+        /* lov_user_md_vX and lov_mds_md_vX must have the same size */
+        LASSERT(sizeof(struct lov_user_md_v1) == sizeof(struct lov_mds_md_v1));
+        LASSERT(sizeof(struct lov_user_md_v3) == sizeof(struct lov_mds_md_v3));
+        LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lumk->lmm_objects[0]));
+
+        /* we can use lov_mds_md_size() to compute lum_size
+         * because lov_user_md_vX and lov_mds_md_vX have the same size */
         if (lum.lmm_stripe_count > 0) {
-                lum_size = sizeof(lum) + sizeof(lum.lmm_objects[0]);
+                lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic);
                 OBD_ALLOC(lumk, lum_size);
                 if (!lumk)
                         RETURN(-ENOMEM);
-
-                lumk->lmm_objects[0].l_object_id = lsm->lsm_object_id;
+                if (lum.lmm_magic == LOV_USER_MAGIC_V1)
+                        lmm_objects = &(((struct lov_user_md_v1 *)lumk)->lmm_objects[0]);
+                else
+                        lmm_objects = &(lumk->lmm_objects[0]);
+                lmm_objects->l_object_id = lsm->lsm_object_id;
         } else {
-                lum_size = sizeof(lum);
+                lum_size = lov_mds_md_size(0, lum.lmm_magic);
                 lumk = &lum;
         }
 
-        lumk->lmm_object_id = lsm->lsm_object_id;
+        lumk->lmm_magic = lum.lmm_magic;
         lumk->lmm_stripe_count = 1;
+        lumk->lmm_object_id = lsm->lsm_object_id;
+
+        if ((lsm->lsm_magic == LOV_USER_MAGIC_V1_SWABBED) ||
+            (lsm->lsm_magic == LOV_USER_MAGIC_V3_SWABBED)) {
+               /* lsm not in host order, so count also need be in same order */
+                __swab32s(&lumk->lmm_magic);
+                __swab16s(&lumk->lmm_stripe_count);
+                lustre_swab_lov_user_md((struct lov_user_md_v1*)lumk);
+                if (lum.lmm_stripe_count > 0)
+                        lustre_swab_lov_user_md_objects(
+                                (struct lov_user_md_v1*)lumk);
+        }
 
         if (copy_to_user(lump, lumk, lum_size))
                 rc = -EFAULT;
@@ -3416,6 +3708,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
         RETURN(rc);
 }
 
+
 static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                          void *karg, void *uarg)
 {
@@ -3505,6 +3798,9 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 err = osc_destroy(exp, oa, NULL, NULL, NULL);
                 GOTO(out, err);
         }
+        case OBD_IOC_PING_TARGET:
+                err = ptlrpc_obd_ping(obd);
+                GOTO(out, err);
         default:
                 CDEBUG(D_INODE, "unrecognised ioctl %#x by %s\n",
                        cmd, cfs_curproc_comm());
@@ -3515,8 +3811,8 @@ out:
         return err;
 }
 
-static int osc_get_info(struct obd_export *exp, obd_count keylen, void *key,
-                        __u32 *vallen, void *val, struct lov_stripe_md *lsm)
+static int osc_get_info(struct obd_export *exp, obd_count keylen,
+                        void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm)
 {
         ENTRY;
         if (!vallen || !val)
@@ -3527,6 +3823,12 @@ static int osc_get_info(struct obd_export *exp, obd_count keylen, void *key,
                 *vallen = sizeof(*stripe);
                 *stripe = 0;
                 RETURN(0);
+        } else if (KEY_IS(KEY_OFF_RPCSIZE)) {
+                struct client_obd *cli = &exp->exp_obd->u.cli;
+                __u64 *rpcsize = val;
+                LASSERT(*vallen == sizeof(__u64));
+                *rpcsize = (__u64)cli->cl_max_pages_per_rpc;
+                RETURN(0);
         } else if (KEY_IS(KEY_LAST_ID)) {
                 struct ptlrpc_request *req;
                 obd_id *reply;
@@ -3671,7 +3973,7 @@ static int osc_set_info_async(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
 
-        if (!set)
+        if (!set && !KEY_IS(KEY_GRANT_SHRINK))
                 RETURN(-EINVAL);
 
         /* We pass all other commands directly to OST. Since nobody calls osc
@@ -3688,14 +3990,36 @@ static int osc_set_info_async(struct obd_export *exp, obd_count keylen,
 
         if (KEY_IS(KEY_MDS_CONN))
                 req->rq_interpret_reply = osc_setinfo_mds_conn_interpret;
+        else if (KEY_IS(KEY_GRANT_SHRINK))
+                req->rq_interpret_reply = osc_shrink_grant_interpret;
 
-        ptlrpc_req_set_repsize(req, 1, NULL);
-        ptlrpc_set_add_req(set, req);
-        ptlrpc_check_set(set);
+        if (KEY_IS(KEY_GRANT_SHRINK)) {
+                struct osc_grant_args *aa;
+                struct obdo *oa;
+
+                CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
+                aa = ptlrpc_req_async_args(req);
+                OBD_ALLOC_PTR(oa);
+                if (!oa) {
+                        ptlrpc_req_finished(req);
+                        RETURN(-ENOMEM);
+                }
+                *oa = ((struct ost_body *)val)->oa;
+                aa->aa_oa = oa;
+
+                size[1] = vallen;
+                ptlrpc_req_set_repsize(req, 2, size);
+                ptlrpcd_add_req(req);
+        } else {
+                ptlrpc_req_set_repsize(req, 1, NULL);
+                ptlrpc_set_add_req(set, req);
+                ptlrpc_check_set(set);
+        }
 
         RETURN(0);
 }
 
+
 static struct llog_operations osc_size_repl_logops = {
         lop_cancel: llog_obd_repl_cancel
 };
@@ -3811,6 +4135,25 @@ static int osc_disconnect(struct obd_export *exp)
         }
 
         rc = client_disconnect_export(exp);
+        /**
+         * Initially we put del_shrink_grant before disconnect_export, but it
+         * causes the following problem if setup (connect) and cleanup
+         * (disconnect) are tangled together.
+         *      connect p1                     disconnect p2
+         *   ptlrpc_connect_import
+         *     ...............               class_manual_cleanup
+         *                                     osc_disconnect
+         *                                     del_shrink_grant
+         *   ptlrpc_connect_interrupt
+         *     init_grant_shrink
+         *   add this client to shrink list
+         *                                      cleanup_osc
+         * Bang! pinger trigger the shrink.
+         * So the osc should be disconnected from the shrink list, after we
+         * are sure the import has been destroyed. BUG18662
+         */
+        if (obd->u.cli.cl_import == NULL)
+                osc_del_shrink_grant(&obd->u.cli);
         return rc;
 }
 
@@ -3912,6 +4255,7 @@ int osc_setup(struct obd_device *obd, obd_count len, void *buf)
                 struct lprocfs_static_vars lvars = { 0 };
                 struct client_obd *cli = &obd->u.cli;
 
+                cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL;
                 lprocfs_osc_init_vars(&lvars);
                 if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
                         lproc_osc_attach_seqstat(obd);
@@ -3933,6 +4277,8 @@ int osc_setup(struct obd_device *obd, obd_count len, void *buf)
                         osc_cleanup(obd);
                         rc = -ENOMEM;
                 }
+                CFS_INIT_LIST_HEAD(&cli->cl_grant_shrink_list);
+                sema_init(&cli->cl_grant_sem, 1);
         }
 
         RETURN(rc);
@@ -3955,9 +4301,9 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
         case OBD_CLEANUP_EXPORTS: {
                 /* If we set up but never connected, the
                    client import will not have been cleaned. */
+                down_write(&obd->u.cli.cl_sem);
                 if (obd->u.cli.cl_import) {
                         struct obd_import *imp;
-                        down_write(&obd->u.cli.cl_sem);
                         imp = obd->u.cli.cl_import;
                         CDEBUG(D_CONFIG, "%s: client import never connected\n",
                                obd->obd_name);
@@ -3967,9 +4313,10 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                                 imp->imp_rq_pool = NULL;
                         }
                         class_destroy_import(imp);
-                        up_write(&obd->u.cli.cl_sem);
                         obd->u.cli.cl_import = NULL;
                 }
+                up_write(&obd->u.cli.cl_sem);
+
                 rc = obd_llog_finish(obd, 0);
                 if (rc != 0)
                         CERROR("failed to cleanup llogging subsystems\n");
diff --git a/lustre/ost/Makefile.in b/lustre/ost/Makefile.in
index 99002e4..6bd8be3 100644
--- a/lustre/ost/Makefile.in
+++ b/lustre/ost/Makefile.in
@@ -1,4 +1,6 @@
 MODULES := ost
 ost-objs := ost_handler.o lproc_ost.o
 
+EXTRA_DIST = $(ost-objs:%.o=%.c) ost_internal.h
+
 @INCLUDE_RULES@
diff --git a/lustre/ost/autoMakefile.am b/lustre/ost/autoMakefile.am
index 8db3fe4..907a0e0 100644
--- a/lustre/ost/autoMakefile.am
+++ b/lustre/ost/autoMakefile.am
@@ -39,4 +39,3 @@ modulefs_DATA = ost$(KMODEXT)
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES = $(ost-objs:%.o=%.c) ost_internal.h
diff --git a/lustre/ost/autoMakefile.in b/lustre/ost/autoMakefile.in
index 7d1f408..6a42071 100644
--- a/lustre/ost/autoMakefile.in
+++ b/lustre/ost/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -330,12 +330,12 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 
 @MODULES_TRUE at modulefs_DATA = ost$(KMODEXT)
-DIST_SOURCES = $(ost-objs:%.o=%.c) ost_internal.h
 subdir = lustre/ost
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = Makefile
+DIST_SOURCES =
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/ost/lproc_ost.c b/lustre/ost/lproc_ost.c
index 9cb8912..9bb91ba 100644
--- a/lustre/ost/lproc_ost.c
+++ b/lustre/ost/lproc_ost.c
@@ -41,8 +41,54 @@
 #include "ost_internal.h"
 
 #ifdef LPROCFS
+static char *sync_on_cancel_states[] = {"never",
+                                        "blocking",
+                                        "always" };
+
+int lprocfs_ost_rd_ost_sync_on_lock_cancel(char *page, char **start, off_t off,
+                                           int count, int *eof, void *data)
+{
+        struct obd_device *obd = data;
+        int rc;
+
+        rc = snprintf(page, count, "%s\n",
+                     sync_on_cancel_states[obd->u.ost.ost_sync_on_lock_cancel]);
+        return rc;
+}
+
+int lprocfs_ost_wr_ost_sync_on_lock_cancel(struct file *file,
+                                           const char *buffer,
+                                           unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val = -1;
+        int i;
+
+        for (i = 0 ; i < NUM_SYNC_ON_CANCEL_STATES; i++) {
+                if (memcmp(buffer, sync_on_cancel_states[i],
+                    strlen(sync_on_cancel_states[i])) == 0) {
+                        val = i;
+                        break;
+                }
+        }
+        if (val == -1) {
+                int rc;
+                rc = lprocfs_write_helper(buffer, count, &val);
+                if (rc)
+                        return rc;
+        }
+
+        if (val < 0 || val > 2)
+                return -EINVAL;
+
+        obd->u.ost.ost_sync_on_lock_cancel = val;
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_ost_obd_vars[] = {
         { "uuid",            lprocfs_rd_uuid,   0, 0 },
+        { "sync_on_lock_cancel", lprocfs_ost_rd_ost_sync_on_lock_cancel,
+                                 lprocfs_ost_wr_ost_sync_on_lock_cancel, 0 },
         { 0 }
 };
 
diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c
index 17ad02e..1b21669 100644
--- a/lustre/ost/ost_handler.c
+++ b/lustre/ost/ost_handler.c
@@ -77,8 +77,12 @@ void oti_to_request(struct obd_trans_info *oti, struct ptlrpc_request *req)
         if (oti == NULL)
                 return;
 
-        if (req->rq_repmsg)
+        if (req->rq_repmsg) {
+                __u64 versions[PTLRPC_NUM_VERSIONS] = { 0 };
                 lustre_msg_set_transno(req->rq_repmsg, oti->oti_transno);
+                versions[0] = oti->oti_pre_version;
+                lustre_msg_set_versions(req->rq_repmsg, versions);
+        }
         req->rq_transno = oti->oti_transno;
 
         /* XXX 4 == entries in oti_ack_locks??? */
@@ -316,6 +320,7 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
 
 static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
 {
+        struct obd_info oinfo = { { { 0 } } };
         struct ost_body *body, *repbody;
         __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*repbody) };
         int rc;
@@ -332,9 +337,11 @@ static int ost_sync(struct obd_export *exp, struct ptlrpc_request *req)
 
         repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
                                  sizeof(*repbody));
-        memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
-        req->rq_status = obd_sync(exp, &repbody->oa, NULL, repbody->oa.o_size,
-                                  repbody->oa.o_blocks);
+
+        oinfo.oi_oa = &body->oa;
+        req->rq_status = obd_sync(exp, &oinfo, repbody->oa.o_size,
+                                  repbody->oa.o_blocks, NULL);
+        repbody->oa = *oinfo.oi_oa;
         RETURN(0);
 }
 
@@ -374,100 +381,6 @@ static int ost_bulk_timeout(void *data)
         RETURN(1);
 }
 
-static int get_per_page_niobufs(struct obd_ioobj *ioo, int nioo,
-                                struct niobuf_remote *rnb, int nrnb,
-                                struct niobuf_remote **pp_rnbp)
-{
-        /* Copy a remote niobuf, splitting it into page-sized chunks
-         * and setting ioo[i].ioo_bufcnt accordingly */
-        struct niobuf_remote *pp_rnb;
-        int   i;
-        int   j;
-        int   page;
-        int   rnbidx = 0;
-        int   npages = 0;
-
-        /*
-         * array of sufficient size already preallocated by caller
-         */
-        LASSERT(pp_rnbp != NULL);
-        LASSERT(*pp_rnbp != NULL);
-
-        /* first count and check the number of pages required */
-        for (i = 0; i < nioo; i++)
-                for (j = 0; j < ioo->ioo_bufcnt; j++, rnbidx++) {
-                        obd_off offset = rnb[rnbidx].offset;
-                        obd_off p0 = offset >> CFS_PAGE_SHIFT;
-                        obd_off pn = (offset + rnb[rnbidx].len - 1)>>CFS_PAGE_SHIFT;
-
-                        LASSERT(rnbidx < nrnb);
-
-                        npages += (pn + 1 - p0);
-
-                        if (rnb[rnbidx].len == 0) {
-                                CERROR("zero len BRW: obj %d objid "LPX64
-                                       " buf %u\n", i, ioo[i].ioo_id, j);
-                                return -EINVAL;
-                        }
-                        if (j > 0 &&
-                            rnb[rnbidx].offset <= rnb[rnbidx-1].offset) {
-                                CERROR("unordered BRW: obj %d objid "LPX64
-                                       " buf %u offset "LPX64" <= "LPX64"\n",
-                                       i, ioo[i].ioo_id, j, rnb[rnbidx].offset,
-                                       rnb[rnbidx].offset);
-                                return -EINVAL;
-                        }
-                }
-
-        LASSERT(rnbidx == nrnb);
-
-        if (npages == nrnb) {       /* all niobufs are for single pages */
-                *pp_rnbp = rnb;
-                return npages;
-        }
-
-        pp_rnb = *pp_rnbp;
-
-        /* now do the actual split */
-        page = rnbidx = 0;
-        for (i = 0; i < nioo; i++) {
-                int  obj_pages = 0;
-
-                for (j = 0; j < ioo[i].ioo_bufcnt; j++, rnbidx++) {
-                        obd_off off = rnb[rnbidx].offset;
-                        int     nob = rnb[rnbidx].len;
-
-                        LASSERT(rnbidx < nrnb);
-                        do {
-                                obd_off  poff = off & ~CFS_PAGE_MASK;
-                                int      pnob = (poff + nob > CFS_PAGE_SIZE) ?
-                                                CFS_PAGE_SIZE - poff : nob;
-
-                                LASSERT(page < npages);
-                                pp_rnb[page].len = pnob;
-                                pp_rnb[page].offset = off;
-                                pp_rnb[page].flags = rnb[rnbidx].flags;
-
-                                CDEBUG(0, "   obj %d id "LPX64
-                                       "page %d(%d) "LPX64" for %d, flg %x\n",
-                                       i, ioo[i].ioo_id, obj_pages, page,
-                                       pp_rnb[page].offset, pp_rnb[page].len,
-                                       pp_rnb[page].flags);
-                                page++;
-                                obj_pages++;
-
-                                off += pnob;
-                                nob -= pnob;
-                        } while (nob > 0);
-                        LASSERT(nob == 0);
-                }
-                ioo[i].ioo_bufcnt = obj_pages;
-        }
-        LASSERT(page == npages);
-
-        return npages;
-}
-
 static __u32 ost_checksum_bulk(struct ptlrpc_bulk_desc *desc, int opc,
                                cksum_type_t cksum_type)
 {
@@ -490,62 +403,17 @@ static __u32 ost_checksum_bulk(struct ptlrpc_bulk_desc *desc, int opc,
                 /* corrupt the data after we compute the checksum, to
                  * simulate an OST->client data error */
                 if (i == 0 && opc == OST_READ &&
-                    OBD_FAIL_CHECK_ONCE(OBD_FAIL_OST_CHECKSUM_SEND))
+                    OBD_FAIL_CHECK_ONCE(OBD_FAIL_OST_CHECKSUM_SEND)) {
                         memcpy(ptr, "bad4", min(4, len));
+                        /* nobody should use corrupted page again */
+                        ClearPageUptodate(page);
+                }
                 kunmap(page);
         }
 
         return cksum;
 }
 
-/*
- * populate @nio by @nrpages pages from per-thread page pool
- */
-static void ost_nio_pages_get(struct ptlrpc_request *req,
-                              struct niobuf_local *nio, int nrpages)
-{
-        int i;
-        struct ost_thread_local_cache *tls;
-
-        ENTRY;
-
-        LASSERT(nrpages <= OST_THREAD_POOL_SIZE);
-        LASSERT(req != NULL);
-        LASSERT(req->rq_svc_thread != NULL);
-
-        tls = ost_tls(req);
-        LASSERT(tls != NULL);
-
-        memset(nio, 0, nrpages * sizeof *nio);
-        for (i = 0; i < nrpages; ++ i) {
-                struct page *page;
-
-                page = tls->page[i];
-                LASSERT(page != NULL);
-                POISON_PAGE(page, 0xf1);
-                nio[i].page = page;
-                LL_CDEBUG_PAGE(D_INFO, page, "%d\n", i);
-        }
-        EXIT;
-}
-
-/*
- * Dual for ost_nio_pages_get(). Poison pages in pool for debugging
- */
-static void ost_nio_pages_put(struct ptlrpc_request *req,
-                              struct niobuf_local *nio, int nrpages)
-{
-        int i;
-
-        ENTRY;
-
-        LASSERT(nrpages <= OST_THREAD_POOL_SIZE);
-
-        for (i = 0; i < nrpages; ++ i)
-                POISON_PAGE(nio[i].page, 0xf2);
-        EXIT;
-}
-
 static int ost_brw_lock_get(int mode, struct obd_export *exp,
                             struct obd_ioobj *obj, struct niobuf_remote *nb,
                             struct lustre_handle *lh)
@@ -641,6 +509,10 @@ static int ost_prolong_locks_iter(struct ldlm_lock *lock, void *data)
                 return LDLM_ITER_CONTINUE;
         }
 
+        CDEBUG(D_DLMTRACE,"refresh lock: "LPU64"/"LPU64" ("LPU64"->"LPU64")\n",
+               lock->l_resource->lr_name.name[0],
+               lock->l_resource->lr_name.name[1],
+               opd->opd_policy.l_extent.start, opd->opd_policy.l_extent.end);
         /* OK. this is a possible lock the user holds doing I/O
          * let's refresh eviction timer for it */
         ldlm_refresh_waiting_lock(lock, opd->opd_timeout);
@@ -652,10 +524,12 @@ static int ost_prolong_locks_iter(struct ldlm_lock *lock, void *data)
 static int ost_rw_prolong_locks(struct ptlrpc_request *req, struct obd_ioobj *obj,
                                 struct niobuf_remote *nb, struct obdo *oa,
                                 ldlm_mode_t mode)
+
+
 {
         struct ldlm_res_id res_id = { .name = { obj->ioo_id } };
-        int nrbufs = obj->ioo_bufcnt;
         struct ost_prolong_data opd = { 0 };
+        int nrbufs = obj->ioo_bufcnt;
 
         ENTRY;
 
@@ -671,7 +545,7 @@ static int ost_rw_prolong_locks(struct ptlrpc_request *req, struct obd_ioobj *ob
                           max(at_est2timeout(at_get(&req->rq_rqbd->
                               rqbd_service->srv_at_estimate)), ldlm_timeout);
 
-        CDEBUG(D_DLMTRACE,"refresh locks: "LPU64"/"LPU64" ("LPU64"->"LPU64")\n",
+        CDEBUG(D_INFO,"refresh locks: "LPU64"/"LPU64" ("LPU64"->"LPU64")\n",
                res_id.name[0], res_id.name[1], opd.opd_policy.l_extent.start,
                opd.opd_policy.l_extent.end);
 
@@ -705,12 +579,48 @@ static int ost_rw_prolong_locks(struct ptlrpc_request *req, struct obd_ioobj *ob
         RETURN(opd.opd_lock_match);
 }
 
+/* Allocate thread local buffers if needed */
+static struct ost_thread_local_cache *ost_tls_get(struct ptlrpc_request *r)
+{
+        struct ost_thread_local_cache *tls =
+                (struct ost_thread_local_cache *)(r->rq_svc_thread->t_data);
+
+        /* In normal mode of operation an I/O request is serviced only
+         * by ll_ost_io threads each of them has own tls buffers allocated by
+         * ost_thread_init().
+         * During recovery, an I/O request may be queued until any of the ost
+         * service threads process it. Not necessary it should be one of
+         * ll_ost_io threads. In that case we dynamically allocating tls
+         * buffers for the request service time. */
+        if (unlikely(tls == NULL)) {
+                LASSERT(r->rq_export->exp_in_recovery);
+                OBD_ALLOC_PTR(tls);
+                if (tls != NULL) {
+                        tls->temporary = 1;
+                        r->rq_svc_thread->t_data = tls;
+                }
+        }
+        return  tls;
+}
+
+/* Free thread local buffers if they were allocated only for servicing
+ * this one request */
+static void ost_tls_put(struct ptlrpc_request *r)
+{
+        struct ost_thread_local_cache *tls =
+                (struct ost_thread_local_cache *)(r->rq_svc_thread->t_data);
+
+        if (unlikely(tls->temporary)) {
+                OBD_FREE_PTR(tls);
+                r->rq_svc_thread->t_data = NULL;
+        }
+}
+
 static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
 {
-        struct ptlrpc_bulk_desc *desc;
+        struct ptlrpc_bulk_desc *desc = NULL;
         struct obd_export       *exp = req->rq_export;
         struct niobuf_remote *remote_nb;
-        struct niobuf_remote *pp_rnb = NULL;
         struct niobuf_local *local_nb;
         struct obd_ioobj *ioo;
         struct ost_body *body, *repbody;
@@ -719,6 +629,7 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         __u32  size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
         int niocount, npages, nob = 0, rc, i;
         int no_reply = 0;
+        struct ost_thread_local_cache *tls;
         ENTRY;
 
         if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_READ_BULK))
@@ -754,36 +665,14 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         if (rc)
                 GOTO(out, rc);
 
-        /*
-         * Per-thread array of struct niobuf_{local,remote}'s was allocated by
-         * ost_thread_init().
-         */
-        local_nb = ost_tls(req)->local;
-        pp_rnb   = ost_tls(req)->remote;
-
-        /* FIXME all niobuf splitting should be done in obdfilter if needed */
-        /* CAVEAT EMPTOR this sets ioo->ioo_bufcnt to # pages */
-        npages = get_per_page_niobufs(ioo, 1, remote_nb, niocount, &pp_rnb);
-        if (npages < 0)
-                GOTO(out, rc = npages);
-
-        if (npages > OST_THREAD_POOL_SIZE) {
-                DEBUG_REQ(D_ERROR, req, "number of pages (%d) required are more"
-                          " than the thread pool size (%d)",
-                          npages, OST_THREAD_POOL_SIZE);
-                GOTO(out, rc = -EPROTO);
-        }
-
-        ost_nio_pages_get(req, local_nb, npages);
-
-        desc = ptlrpc_prep_bulk_exp(req, npages,
-                                     BULK_PUT_SOURCE, OST_BULK_PORTAL);
-        if (desc == NULL)
-                GOTO(out, rc = -ENOMEM);
+        tls = ost_tls_get(req);
+        if (tls == NULL)
+                GOTO(out_bulk, rc = -ENOMEM);
+        local_nb = tls->local;
 
-        rc = ost_brw_lock_get(LCK_PR, exp, ioo, pp_rnb, &lockh);
+        rc = ost_brw_lock_get(LCK_PR, exp, ioo, remote_nb, &lockh);
         if (rc != 0)
-                GOTO(out_bulk, rc);
+                GOTO(out_tls, rc);
 
         /*
          * If getting the lock took more time than
@@ -800,12 +689,18 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 GOTO(out_lock, rc = -ETIMEDOUT);
         }
 
-        rc = obd_preprw(OBD_BRW_READ, exp, &body->oa, 1,
-                        ioo, npages, pp_rnb, local_nb, oti);
+        npages = OST_THREAD_POOL_SIZE;
+        rc = obd_preprw(OBD_BRW_READ, exp, &body->oa, 1, ioo,
+                        remote_nb, &npages, local_nb, oti);
         if (rc != 0)
                 GOTO(out_lock, rc);
 
-        ost_rw_prolong_locks(req, ioo, pp_rnb, &body->oa, LCK_PW | LCK_PR);
+        desc = ptlrpc_prep_bulk_exp(req, npages,
+                                     BULK_PUT_SOURCE, OST_BULK_PORTAL);
+        if (desc == NULL) /* XXX: check all cleanup stuff */
+                GOTO(out, rc = -ENOMEM);
+
+        ost_rw_prolong_locks(req, ioo, remote_nb, &body->oa, LCK_PW | LCK_PR);
 
         nob = 0;
         for (i = 0; i < npages; i++) {
@@ -816,26 +711,18 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
                         break;
                 }
 
-                LASSERTF(page_rc <= pp_rnb[i].len, "page_rc (%d) > "
-                         "pp_rnb[%d].len (%d)\n", page_rc, i, pp_rnb[i].len);
                 nob += page_rc;
                 if (page_rc != 0) {             /* some data! */
                         LASSERT (local_nb[i].page != NULL);
                         ptlrpc_prep_bulk_page(desc, local_nb[i].page,
-                                              pp_rnb[i].offset & ~CFS_PAGE_MASK,
+                                              local_nb[i].offset & ~CFS_PAGE_MASK,
                                               page_rc);
                 }
 
-                if (page_rc != pp_rnb[i].len) { /* short read */
-                        int j = i;
-
+                if (page_rc != local_nb[i].len) { /* short read */
                         /* All subsequent pages should be 0 */
                         while(++i < npages)
-                                LASSERTF(local_nb[i].rc == 0,
-                                         "page_rc %d, pp_rnb[%u].len=%d, "
-                                         "local_nb[%u/%u].rc=%d\n",
-                                         page_rc, j, pp_rnb[j].len,
-                                         i, npages, local_nb[i].rc);
+                                LASSERT(local_nb[i].rc == 0);
                         break;
                 }
         }
@@ -919,10 +806,8 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         }
 
         /* Must commit after prep above in all cases */
-        rc = obd_commitrw(OBD_BRW_READ, exp, &body->oa, 1,
-                          ioo, npages, local_nb, oti, rc);
-
-        ost_nio_pages_put(req, local_nb, npages);
+        rc = obd_commitrw(OBD_BRW_READ, exp, &body->oa, 1, ioo,
+                          remote_nb, npages, local_nb, oti, rc);
 
         if (rc == 0) {
                 repbody = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
@@ -931,9 +816,12 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
         }
 
  out_lock:
-        ost_brw_lock_put(LCK_PR, ioo, pp_rnb, &lockh);
+        ost_brw_lock_put(LCK_PR, ioo, remote_nb, &lockh);
+ out_tls:
+        ost_tls_put(req);
  out_bulk:
-        ptlrpc_free_bulk(desc);
+        if (desc)
+                ptlrpc_free_bulk(desc);
  out:
         LASSERT(rc <= 0);
         if (rc == 0) {
@@ -962,10 +850,9 @@ static int ost_brw_read(struct ptlrpc_request *req, struct obd_trans_info *oti)
 
 static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
 {
-        struct ptlrpc_bulk_desc *desc;
+        struct ptlrpc_bulk_desc *desc = NULL;
         struct obd_export       *exp = req->rq_export;
         struct niobuf_remote    *remote_nb;
-        struct niobuf_remote    *pp_rnb;
         struct niobuf_local     *local_nb;
         struct obd_ioobj        *ioo;
         struct ost_body         *body, *repbody;
@@ -978,6 +865,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         obd_count                client_cksum = 0, server_cksum = 0;
         cksum_type_t             cksum_type = OBD_CKSUM_CRC32;
         int                      no_reply = 0;
+        struct ost_thread_local_cache *tls;
         ENTRY;
 
         if (OBD_FAIL_CHECK(OBD_FAIL_OST_BRW_WRITE_BULK))
@@ -1025,36 +913,14 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         rcs = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF + 1,
                              niocount * sizeof(*rcs));
 
-        /*
-         * Per-thread array of struct niobuf_{local,remote}'s was allocated by
-         * ost_thread_init().
-         */
-        local_nb = ost_tls(req)->local;
-        pp_rnb   = ost_tls(req)->remote;
-
-        /* FIXME all niobuf splitting should be done in obdfilter if needed */
-        /* CAVEAT EMPTOR this sets ioo->ioo_bufcnt to # pages */
-        npages = get_per_page_niobufs(ioo, objcount,remote_nb,niocount,&pp_rnb);
-        if (npages < 0)
-                GOTO(out, rc = npages);
-
-        if (npages > OST_THREAD_POOL_SIZE) {
-                DEBUG_REQ(D_ERROR, req, "number of pages (%d) required are more"
-                          " than the thread pool size (%d)",
-                          npages, OST_THREAD_POOL_SIZE);
-                GOTO(out, rc = -EPROTO);
-        }
+        tls = ost_tls_get(req);
+        if (tls == NULL)
+                GOTO(out_bulk, rc = -ENOMEM);
+        local_nb = tls->local;
 
-        ost_nio_pages_get(req, local_nb, npages);
-
-        desc = ptlrpc_prep_bulk_exp(req, npages,
-                                     BULK_GET_SINK, OST_BULK_PORTAL);
-        if (desc == NULL)
-                GOTO(out, rc = -ENOMEM);
-
-        rc = ost_brw_lock_get(LCK_PW, exp, ioo, pp_rnb, &lockh);
+        rc = ost_brw_lock_get(LCK_PW, exp, ioo, remote_nb, &lockh);
         if (rc != 0)
-                GOTO(out_bulk, rc);
+                GOTO(out_tls, rc);
 
         /*
          * If getting the lock took more time than
@@ -1071,7 +937,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 GOTO(out_lock, rc = -ETIMEDOUT);
         }
 
-        ost_rw_prolong_locks(req, ioo, pp_rnb, &body->oa,  LCK_PW);
+        ost_rw_prolong_locks(req, ioo, remote_nb,&body->oa,  LCK_PW);
 
         /* obd_preprw clobbers oa->valid, so save what we need */
         if (body->oa.o_valid & OBD_MD_FLCKSUM) {
@@ -1088,17 +954,23 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 body->oa.o_valid &= ~OBD_MD_FLGRANT;
         }
 
+        npages = OST_THREAD_POOL_SIZE;
         rc = obd_preprw(OBD_BRW_WRITE, exp, &body->oa, objcount,
-                        ioo, npages, pp_rnb, local_nb, oti);
+                        ioo, remote_nb, &npages, local_nb, oti);
         if (rc != 0)
                 GOTO(out_lock, rc);
 
+        desc = ptlrpc_prep_bulk_exp(req, npages,
+                                     BULK_GET_SINK, OST_BULK_PORTAL);
+        if (desc == NULL)
+                GOTO(out, rc = -ENOMEM);
+
         /* NB Having prepped, we must commit... */
 
         for (i = 0; i < npages; i++)
                 ptlrpc_prep_bulk_page(desc, local_nb[i].page,
-                                      pp_rnb[i].offset & ~CFS_PAGE_MASK,
-                                      pp_rnb[i].len);
+                                      local_nb[i].offset & ~CFS_PAGE_MASK,
+                                      local_nb[i].len);
 
         /* Check if client was evicted while we were doing i/o before touching
            network */
@@ -1184,8 +1056,8 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 rc = -ENOTCONN;
 
         /* Must commit after prep above in all cases */
-        rc = obd_commitrw(OBD_BRW_WRITE, exp, &repbody->oa,
-                           objcount, ioo, npages, local_nb, oti, rc);
+        rc = obd_commitrw(OBD_BRW_WRITE, exp, &repbody->oa, objcount, ioo,
+                          remote_nb, npages, local_nb, oti, rc);
 
         if (unlikely(client_cksum != server_cksum && rc == 0)) {
                 int  new_cksum = ost_checksum_bulk(desc, OST_WRITE, cksum_type);
@@ -1220,16 +1092,14 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                                    body->oa.o_id,
                                    body->oa.o_valid & OBD_MD_FLGROUP ?
                                                 body->oa.o_gr : (__u64)0,
-                                   pp_rnb[0].offset,
-                                   pp_rnb[npages-1].offset+pp_rnb[npages-1].len
-                                   - 1 );
+                                   local_nb[0].offset,
+                                   local_nb[npages-1].offset +
+                                   local_nb[npages-1].len - 1 );
                 CERROR("client csum %x, original server csum %x, "
                        "server csum now %x\n",
                        client_cksum, server_cksum, new_cksum);
         }
 
-        ost_nio_pages_put(req, local_nb, npages);
-
         if (rc == 0) {
                 int nob = 0;
 
@@ -1243,7 +1113,7 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                                 LASSERT(j < npages);
                                 if (local_nb[j].rc < 0)
                                         rcs[i] = local_nb[j].rc;
-                                len -= pp_rnb[j].len;
+                                len -= local_nb[j].len;
                                 j++;
                         } while (len > 0);
                         LASSERT(len == 0);
@@ -1253,9 +1123,12 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         }
 
  out_lock:
-        ost_brw_lock_put(LCK_PW, ioo, pp_rnb, &lockh);
+        ost_brw_lock_put(LCK_PW, ioo, remote_nb, &lockh);
+ out_tls:
+        ost_tls_put(req);
  out_bulk:
-        ptlrpc_free_bulk(desc);
+        if (desc)
+                ptlrpc_free_bulk(desc);
  out:
         if (rc == 0) {
                 oti_to_request(oti, req);
@@ -1281,6 +1154,8 @@ static int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
 
 static int ost_set_info(struct obd_export *exp, struct ptlrpc_request *req)
 {
+        struct ost_body *body = NULL, *repbody;
+        __u32 size[2] = { sizeof(struct ptlrpc_body), sizeof(*body) };
         char *key, *val = NULL;
         int keylen, vallen, rc = 0;
         ENTRY;
@@ -1292,13 +1167,33 @@ static int ost_set_info(struct obd_export *exp, struct ptlrpc_request *req)
         }
         keylen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF);
 
-        rc = lustre_pack_reply(req, 1, NULL, NULL);
-        if (rc)
-                RETURN(rc);
+        if (KEY_IS(KEY_GRANT_SHRINK)) {
+                rc = lustre_pack_reply(req, 2, size, NULL);
+                if (rc)
+                        RETURN(rc);
+        } else {
+                rc = lustre_pack_reply(req, 1, NULL, NULL);
+                if (rc)
+                        RETURN(rc);
+        }
 
         vallen = lustre_msg_buflen(req->rq_reqmsg, REQ_REC_OFF + 1);
-        if (vallen)
-                val = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, 0);
+        if (vallen) {
+                if (KEY_IS(KEY_GRANT_SHRINK)) {
+                        body = lustre_swab_reqbuf(req, REQ_REC_OFF + 1,
+                                                  sizeof(*body),
+                                                  lustre_swab_ost_body);
+                        if (!body)
+                                RETURN(-EFAULT);
+
+                        repbody = lustre_msg_buf(req->rq_repmsg,
+                                                 REPLY_REC_OFF,
+                                                 sizeof(*repbody));
+                        memcpy(repbody, body, sizeof(*body));
+                        val = (char*)repbody;
+                } else
+                        val = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1,0);
+        }
 
         if (KEY_IS(KEY_EVICT_BY_NID)) {
                 if (val && vallen)
@@ -1413,6 +1308,47 @@ static int ost_handle_quota_adjust_qunit(struct ptlrpc_request *req)
 }
 #endif
 
+/* Ensure that data and metadata are synced to the disk when lock is cancelled
+ * (if requested) */
+int ost_blocking_ast(struct ldlm_lock *lock,
+                             struct ldlm_lock_desc *desc,
+                             void *data, int flag)
+{
+        struct obd_device *obd = lock->l_export->exp_obd;
+        if (flag == LDLM_CB_CANCELING &&
+            (lock->l_granted_mode & (LCK_PW|LCK_GROUP)) &&
+            (obd->u.ost.ost_sync_on_lock_cancel == ALWAYS_SYNC_ON_CANCEL ||
+             (obd->u.ost.ost_sync_on_lock_cancel == BLOCKING_SYNC_ON_CANCEL &&
+              lock->l_flags & LDLM_FL_CBPENDING))) {
+                struct obd_info *oinfo;
+                int rc;
+
+                OBD_ALLOC_PTR(oinfo);
+                if (!oinfo)
+                        RETURN(-ENOMEM);
+
+                OBDO_ALLOC(oinfo->oi_oa);
+                if (!oinfo->oi_oa) {
+                        OBD_FREE_PTR(oinfo);
+                        RETURN(-ENOMEM);
+                }
+
+                oinfo->oi_oa->o_id = lock->l_resource->lr_name.name[0];
+                oinfo->oi_oa->o_valid = OBD_MD_FLID;
+
+                rc = obd_sync_rqset(lock->l_export, oinfo,
+                                    lock->l_policy_data.l_extent.start,
+                                    lock->l_policy_data.l_extent.end);
+                if (rc)
+                        CERROR("Error %d syncing data on lock cancel\n", rc);
+
+                OBDO_FREE(oinfo->oi_oa);
+                OBD_FREE_PTR(oinfo);
+        }
+
+        return ldlm_server_blocking_ast(lock, desc, data, flag);
+}
+
 static int ost_filter_recovery_request(struct ptlrpc_request *req,
                                        struct obd_device *obd, int *process)
 {
@@ -1629,6 +1565,7 @@ static int ost_punch_prolong_locks(struct ptlrpc_request *req, struct obdo *oa)
                opd.opd_policy.l_extent.end);
 
         opd.opd_oa = oa;
+
         ldlm_resource_iterate(req->rq_export->exp_obd->obd_namespace, &res_id,
                               ost_prolong_locks_iter, &opd);
         RETURN(opd.opd_lock_match);
@@ -1774,7 +1711,7 @@ static int ost_handle(struct ptlrpc_request *req)
         LASSERT(current->journal_info == NULL);
         /* XXX identical to MDS */
         if (lustre_msg_get_opc(req->rq_reqmsg) != OST_CONNECT) {
-                int abort_recovery, recovering;
+                int recovering;
 
                 if (req->rq_export == NULL) {
                         CDEBUG(D_HA,"operation %d on unconnected OST from %s\n",
@@ -1788,12 +1725,10 @@ static int ost_handle(struct ptlrpc_request *req)
 
                 /* Check for aborted recovery. */
                 spin_lock_bh(&obd->obd_processing_task_lock);
-                abort_recovery = obd->obd_abort_recovery;
                 recovering = obd->obd_recovering;
                 spin_unlock_bh(&obd->obd_processing_task_lock);
-                if (abort_recovery) {
-                        target_abort_recovery(obd);
-                } else if (recovering) {
+                if (recovering &&
+                    target_recovery_check_and_stop(obd) == 0) {
                         rc = ost_filter_recovery_request(req, obd,
                                                          &should_process);
                         if (rc || !should_process)
@@ -1806,10 +1741,6 @@ static int ost_handle(struct ptlrpc_request *req)
         if (rc)
                 RETURN(rc);
 
-        rc = ost_msg_check_version(req->rq_reqmsg);
-        if (rc)
-                RETURN(rc);
-
         switch (lustre_msg_get_opc(req->rq_reqmsg)) {
         case OST_CONNECT: {
                 CDEBUG(D_INODE, "connect\n");
@@ -1954,7 +1885,7 @@ static int ost_handle(struct ptlrpc_request *req)
                 CDEBUG(D_INODE, "enqueue\n");
                 OBD_FAIL_RETURN(OBD_FAIL_LDLM_ENQUEUE, 0);
                 rc = ldlm_handle_enqueue(req, ldlm_server_completion_ast,
-                                         ldlm_server_blocking_ast,
+                                         ost_blocking_ast,
                                          ldlm_server_glimpse_ast);
                 fail = OBD_FAIL_OST_LDLM_REPLY_NET;
                 break;
@@ -1989,20 +1920,9 @@ static int ost_handle(struct ptlrpc_request *req)
                 target_committed_to_req(req);
 
 out:
-        if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LAST_REPLAY) {
-                if (obd && obd->obd_recovering) {
-                        DEBUG_REQ(D_HA, req, "LAST_REPLAY, queuing reply");
-                        return target_queue_last_replay_reply(req, rc);
-                }
-                /* Lost a race with recovery; let the error path DTRT. */
-                rc = req->rq_status = -ENOTCONN;
-        }
-
         if (!rc)
                 oti_to_request(oti, req);
-
-        target_send_reply(req, rc, fail);
-        return 0;
+        return target_handle_reply(req, rc, fail);
 }
 
 /*
@@ -2010,7 +1930,6 @@ out:
  */
 static void ost_thread_done(struct ptlrpc_thread *thread)
 {
-        int i;
         struct ost_thread_local_cache *tls; /* TLS stands for Thread-Local
                                              * Storage */
 
@@ -2024,10 +1943,6 @@ static void ost_thread_done(struct ptlrpc_thread *thread)
          */
         tls = thread->t_data;
         if (tls != NULL) {
-                for (i = 0; i < OST_THREAD_POOL_SIZE; ++ i) {
-                        if (tls->page[i] != NULL)
-                                OBD_PAGE_FREE(tls->page[i]);
-                }
                 OBD_FREE_PTR(tls);
                 thread->t_data = NULL;
         }
@@ -2039,8 +1954,6 @@ static void ost_thread_done(struct ptlrpc_thread *thread)
  */
 static int ost_thread_init(struct ptlrpc_thread *thread)
 {
-        int result;
-        int i;
         struct ost_thread_local_cache *tls;
 
         ENTRY;
@@ -2050,23 +1963,10 @@ static int ost_thread_init(struct ptlrpc_thread *thread)
         LASSERTF(thread->t_id <= OSS_THREADS_MAX, "%u\n", thread->t_id);
 
         OBD_ALLOC_PTR(tls);
-        if (tls != NULL) {
-                result = 0;
-                thread->t_data = tls;
-                /*
-                 * populate pool
-                 */
-                for (i = 0; i < OST_THREAD_POOL_SIZE; ++ i) {
-                        OBD_PAGE_ALLOC(tls->page[i], OST_THREAD_POOL_GFP);
-                        if (tls->page[i] == NULL) {
-                                ost_thread_done(thread);
-                                result = -ENOMEM;
-                                break;
-                        }
-                }
-        } else
-                result = -ENOMEM;
-        RETURN(result);
+        if (tls == NULL)
+                RETURN(-ENOMEM);
+        thread->t_data = tls;
+        RETURN(0);
 }
 
 /* Sigh - really, this is an OSS, the _server_, not the _target_ */
@@ -2089,6 +1989,9 @@ static int ost_setup(struct obd_device *obd, obd_count len, void *buf)
 
         sema_init(&ost->ost_health_sem, 1);
 
+        /* Always sync on lock cancel */
+        ost->ost_sync_on_lock_cancel = ALWAYS_SYNC_ON_CANCEL;
+
         if (oss_num_threads) {
                 /* If oss_num_threads is set, it is the min and the max. */
                 if (oss_num_threads > OSS_THREADS_MAX)
@@ -2242,11 +2145,6 @@ static int ost_health_check(struct obd_device *obd)
         return rc;
 }
 
-struct ost_thread_local_cache *ost_tls(struct ptlrpc_request *r)
-{
-        return (struct ost_thread_local_cache *)(r->rq_svc_thread->t_data);
-}
-
 /* use obd ops to offer management infrastructure */
 static struct obd_ops ost_obd_ops = {
         .o_owner        = THIS_MODULE,
@@ -2255,6 +2153,7 @@ static struct obd_ops ost_obd_ops = {
         .o_health_check = ost_health_check,
 };
 
+
 static int __init ost_init(void)
 {
         struct lprocfs_static_vars lvars;
diff --git a/lustre/ost/ost_internal.h b/lustre/ost/ost_internal.h
index 058db78..8203885 100644
--- a/lustre/ost/ost_internal.h
+++ b/lustre/ost/ost_internal.h
@@ -37,7 +37,7 @@
 #ifndef OST_INTERNAL_H
 #define OST_INTERNAL_H
 
-#define OSS_SERVICE_WATCHDOG_FACTOR 2000
+#define OSS_SERVICE_WATCHDOG_FACTOR 2
 
 /*
  * tunables for per-thread page pool (bug 5137)
@@ -56,15 +56,12 @@ struct ptlrpc_request;
  */
 struct ost_thread_local_cache {
         /*
-         * pool of pages and nio buffers used by write-path
+         * pool of nio buffers used by write-path
          */
-        struct page          *page  [OST_THREAD_POOL_SIZE];
         struct niobuf_local   local [OST_THREAD_POOL_SIZE];
-        struct niobuf_remote  remote[OST_THREAD_POOL_SIZE];
+        unsigned int          temporary:1;
 };
 
-struct ost_thread_local_cache *ost_tls(struct ptlrpc_request *r);
-
 #define OSS_DEF_CREATE_THREADS  2UL
 #define OSS_MAX_CREATE_THREADS 16UL
 
@@ -80,4 +77,11 @@ static void lprocfs_ost_init_vars(struct lprocfs_static_vars *lvars)
 }
 #endif
 
+enum {
+        NEVER_SYNC_ON_CANCEL = 0,
+        BLOCKING_SYNC_ON_CANCEL = 1,
+        ALWAYS_SYNC_ON_CANCEL = 2,
+        NUM_SYNC_ON_CANCEL_STATES
+};
+
 #endif /* OST_INTERNAL_H */
diff --git a/lustre/ptlrpc/Makefile.in b/lustre/ptlrpc/Makefile.in
index 535acac..c951d7b 100644
--- a/lustre/ptlrpc/Makefile.in
+++ b/lustre/ptlrpc/Makefile.in
@@ -1,9 +1,5 @@
 MODULES := ptlrpc
-ifeq ($(PATCHLEVEL),6)
 LDLM := @top_srcdir@/lustre/ldlm/
-else
-LDLM :=
-endif
 ldlm_objs := $(LDLM)l_lock.o $(LDLM)ldlm_lock.o 
 ldlm_objs += $(LDLM)ldlm_resource.o $(LDLM)ldlm_lib.o
 ldlm_objs += $(LDLM)ldlm_plain.o $(LDLM)ldlm_extent.o
@@ -29,6 +25,7 @@ l_lock.c: @LUSTRE@/ldlm/l_lock.c
 interval_tree.c: @LUSTRE@/ldlm/interval_tree.c
 	ln -sf $< $@
 
+EXTRA_DIST = $(ptlrpc_objs:.o=.c) ptlrpc_internal.h
 EXTRA_PRE_CFLAGS := -I at LUSTRE@/ldlm
 
 @INCLUDE_RULES@
diff --git a/lustre/ptlrpc/autoMakefile.am b/lustre/ptlrpc/autoMakefile.am
index d345492..ccb79c3 100644
--- a/lustre/ptlrpc/autoMakefile.am
+++ b/lustre/ptlrpc/autoMakefile.am
@@ -105,5 +105,4 @@ endif # DARWIN
 endif # MODULES
 
 install-data-hook: $(install_data_hook)
-DIST_SOURCES = $(ptlrpc_objs:.o=.c) ptlrpc_internal.h
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@  ldlm_*.c l_lock.c interval_tree.c
diff --git a/lustre/ptlrpc/autoMakefile.in b/lustre/ptlrpc/autoMakefile.in
index 77d1764..f62f92a 100644
--- a/lustre/ptlrpc/autoMakefile.in
+++ b/lustre/ptlrpc/autoMakefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@  ldlm_*.c l_lock.c interval_tree.c
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -387,7 +387,6 @@ COMMON_SOURCES = client.c recover.c connection.c niobuf.c pack_generic.c   \
 @DARWIN_TRUE@@MODULES_TRUE at plist_DATA := Info.plist
 
 @DARWIN_TRUE@@MODULES_TRUE at install_data_hook := fix-kext-ownership
-DIST_SOURCES = $(ptlrpc_objs:.o=.c) ptlrpc_internal.h
 subdir = lustre/ptlrpc
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -562,6 +561,8 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libptlrpc_a_SOURCES_DIST) \
+	$(am__ptlrpc_SOURCES_DIST)
 DATA = $(modulefs_DATA) $(plist_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c
index affe53f..f110862 100644
--- a/lustre/ptlrpc/client.c
+++ b/lustre/ptlrpc/client.c
@@ -161,11 +161,13 @@ void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
 
         desc->bd_nob += len;
 
+        cfs_page_pin(page);
         ptlrpc_add_bulk_page(desc, page, pageoffset, len);
 }
 
 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
 {
+        int i;
         ENTRY;
 
         LASSERT(desc != NULL);
@@ -177,6 +179,9 @@ void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
         else
                 class_import_put(desc->bd_import);
 
+        for (i = 0; i < desc->bd_iov_count ; i++)
+                cfs_page_unpin(desc->bd_iov[i].kiov_page);
+
         OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc,
                                 bd_iov[desc->bd_max_iov]));
         EXIT;
@@ -212,7 +217,7 @@ void ptlrpc_at_set_req_timeout(struct ptlrpc_request *req)
         lustre_msg_set_timeout(req->rq_reqmsg, req->rq_timeout);
 }
 
-/* Adjust max service estimate based on server value. */
+/* Adjust max service estimate based on server value */
 static void ptlrpc_at_adj_service(struct ptlrpc_request *req,
                                   unsigned int serv_est)
 {
@@ -221,7 +226,8 @@ static void ptlrpc_at_adj_service(struct ptlrpc_request *req,
         struct imp_at *at;
 
         /* do estimate only if is not in recovery */
-        if (!(req->rq_send_state & (LUSTRE_IMP_FULL | LUSTRE_IMP_CONNECTING)))
+        if ((req->rq_send_state != LUSTRE_IMP_FULL) &&
+             (req->rq_send_state != LUSTRE_IMP_CONNECTING))
                 return;
 
         LASSERT(req->rq_import);
@@ -806,31 +812,42 @@ static int ptlrpc_import_delay_req(struct obd_import *imp,
 static int ptlrpc_check_reply(struct ptlrpc_request *req)
 {
         int rc = 0;
+        const char *what = "";
         ENTRY;
 
         /* serialise with network callback */
         spin_lock(&req->rq_lock);
 
-        if (ptlrpc_client_replied(req))
+        if (ptlrpc_client_replied(req)) {
+                what = "REPLIED: ";
                 GOTO(out, rc = 1);
+        }
 
         if (req->rq_net_err && !req->rq_timedout) {
+                what = "NETERR: ";
                 spin_unlock(&req->rq_lock);
                 rc = ptlrpc_expire_one_request(req, 0);
                 spin_lock(&req->rq_lock);
                 GOTO(out, rc);
         }
 
-        if (req->rq_err)
+        if (req->rq_err) {
+                what = "ABORTED: ";
                 GOTO(out, rc = 1);
+        }
 
-        if (req->rq_resend)
+        if (req->rq_resend) {
+                what = "RESEND: ";
                 GOTO(out, rc = 1);
+        }
 
-        if (req->rq_restart)
+        if (req->rq_restart) {
+                what = "RESTART: ";
                 GOTO(out, rc = 1);
+        }
 
         if (ptlrpc_client_early(req)) {
+                what = "EARLYREP: ";
                 ptlrpc_at_recv_early_reply(req);
                 GOTO(out, rc = 0); /* keep waiting */
         }
@@ -838,27 +855,40 @@ static int ptlrpc_check_reply(struct ptlrpc_request *req)
         EXIT;
  out:
         spin_unlock(&req->rq_lock);
-        DEBUG_REQ(D_NET, req, "rc = %d for", rc);
+        DEBUG_REQ(D_NET, req, "%src = %d for", what, rc);
         return rc;
 }
 
-static int ptlrpc_check_status(struct ptlrpc_request *req)
+/* Conditionally suppress specific console messages */
+static int ptlrpc_console_allow(struct ptlrpc_request *req)
 {
+        __u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
         int err;
-        ENTRY;
 
-        err = lustre_msg_get_status(req->rq_repmsg);
-        if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
-                struct obd_import *imp = req->rq_import;
-                __u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
+        /* Suppress particular reconnect errors which are to be expected.  No
+         * errors are suppressed for the initial connection on an import */
+        if ((lustre_handle_is_used(&req->rq_import->imp_remote_handle)) &&
+            (opc == OST_CONNECT || opc == MDS_CONNECT || opc == MGS_CONNECT)) {
 
-                LCONSOLE_ERROR_MSG(0x011,"an error occurred while communicating"
-                               " with %s. The %s operation failed with %d\n",
-                               libcfs_nid2str(imp->imp_connection->c_peer.nid),
-                               ll_opcode2str(opc), err);
-                RETURN(err < 0 ? err : -EINVAL);
+                /* Suppress timed out reconnect requests */
+                if (req->rq_timedout)
+                        return 0;
+
+                /* Suppress unavailable/again reconnect requests */
+                err = lustre_msg_get_status(req->rq_repmsg);
+                if (err == -ENODEV || err == -EAGAIN)
+                        return 0;
         }
 
+        return 1;
+}
+
+static int ptlrpc_check_status(struct ptlrpc_request *req)
+{
+        int err;
+        ENTRY;
+
+        err = lustre_msg_get_status(req->rq_repmsg);
         if (err < 0) {
                 DEBUG_REQ(D_INFO, req, "status is %d", err);
         } else if (err > 0) {
@@ -866,9 +896,45 @@ static int ptlrpc_check_status(struct ptlrpc_request *req)
                 DEBUG_REQ(D_INFO, req, "status is %d", err);
         }
 
+        if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
+                struct obd_import *imp = req->rq_import;
+                __u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
+
+                if (ptlrpc_console_allow(req))
+                        LCONSOLE_ERROR_MSG(0x011,"an error occurred while "
+                                           "communicating with %s. The %s "
+                                           "operation failed with %d\n",
+                                           libcfs_nid2str(
+                                           imp->imp_connection->c_peer.nid),
+                                           ll_opcode2str(opc), err);
+
+                RETURN(err < 0 ? err : -EINVAL);
+        }
+
         RETURN(err);
 }
 
+/* VBR: we should save pre-versions for replay*/
+static void ptlrpc_save_versions(struct ptlrpc_request *req)
+{
+        struct lustre_msg *repmsg = req->rq_repmsg;
+        struct lustre_msg *reqmsg = req->rq_reqmsg;
+        __u64 *versions = lustre_msg_get_versions(repmsg);
+        ENTRY;
+        /* Interoperability with 1.6. This should be changed to LASSERT in HEAD */
+        if (versions == NULL)
+                return;
+
+        if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)
+                return;
+
+        lustre_msg_set_versions(reqmsg, versions);
+        CDEBUG(D_INFO, "Client save versions ["LPX64"/"LPX64"]\n",
+               versions[0], versions[1]);
+
+        EXIT;
+}
+
 static int after_reply(struct ptlrpc_request *req)
 {
         struct obd_import *imp = req->rq_import;
@@ -891,9 +957,11 @@ static int after_reply(struct ptlrpc_request *req)
 
         do_gettimeofday(&work_start);
         timediff = cfs_timeval_sub(&work_start, &req->rq_arrival_time, NULL);
-        if (obd->obd_svc_stats != NULL)
+        if (obd->obd_svc_stats != NULL) {
                 lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR,
                                     timediff);
+                ptlrpc_lprocfs_rpc_sent(req, timediff);
+        }
 
         OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_PAUSE_REP, obd_fail_val);
         ptlrpc_at_adj_service(req, lustre_msg_get_timeout(req->rq_repmsg));
@@ -926,19 +994,23 @@ static int after_reply(struct ptlrpc_request *req)
         }
 
         /* Store transno in reqmsg for replay. */
-        req->rq_transno = lustre_msg_get_transno(req->rq_repmsg);
-        lustre_msg_set_transno(req->rq_reqmsg, req->rq_transno);
+        if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)) {
+                req->rq_transno = lustre_msg_get_transno(req->rq_repmsg);
+                lustre_msg_set_transno(req->rq_reqmsg, req->rq_transno);
+        }
 
-        if (req->rq_import->imp_replayable) {
+        if (imp->imp_replayable) {
                 spin_lock(&imp->imp_lock);
                 /* no point in adding already-committed requests to the replay
                  * list, we will just remove them immediately. b=9829 */
                 if (req->rq_transno != 0 &&
                     (req->rq_transno >
                      lustre_msg_get_last_committed(req->rq_repmsg) ||
-                     req->rq_replay))
+                     req->rq_replay)) {
+                        /* version recovery */
+                        ptlrpc_save_versions(req);
                         ptlrpc_retain_replayable_request(req, imp);
-                else if (req->rq_commit_cb != NULL) {
+                } else if (req->rq_commit_cb != NULL) {
                         spin_unlock(&imp->imp_lock);
                         req->rq_commit_cb(req);
                         spin_lock(&imp->imp_lock);
@@ -949,6 +1021,9 @@ static int after_reply(struct ptlrpc_request *req)
                         imp->imp_peer_committed_transno =
                                 lustre_msg_get_last_committed(req->rq_repmsg);
                 ptlrpc_free_committed(imp);
+
+                if (req->rq_transno > imp->imp_peer_committed_transno)
+                        ptlrpc_pinger_sending_on_import(imp);
                 spin_unlock(&imp->imp_lock);
         }
 
@@ -1285,7 +1360,7 @@ int ptlrpc_check_set(struct ptlrpc_request_set *set)
                 spin_unlock(&imp->imp_lock);
 
                 set->set_remaining--;
-                cfs_waitq_signal(&imp->imp_recovery_waitq);
+                cfs_waitq_broadcast(&imp->imp_recovery_waitq);
         }
 
         /* If we hit an error, we want to recover promptly. */
@@ -1299,18 +1374,13 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
         int rc = 0;
         ENTRY;
 
-        DEBUG_REQ(D_NETERROR, req, "%s (sent at %lu, %lus ago)",
-                  req->rq_net_err ? "network error" : "timeout",
-                  (long)req->rq_sent, cfs_time_current_sec() - req->rq_sent);
-
-        if (imp) {
-                LCONSOLE_WARN("Request x"LPU64" sent from %s to NID %s %lus ago"
-                              " has timed out (limit %lus).\n", req->rq_xid,
-                              req->rq_import->imp_obd->obd_name,
-                              libcfs_nid2str(imp->imp_connection->c_peer.nid),
-                              cfs_time_current_sec() - req->rq_sent,
-                              req->rq_deadline - req->rq_sent);
-        }
+        DEBUG_REQ(D_WARNING, req, "Request x"LPU64" sent from %s to NID %s"
+                  " %lus ago has %s (limit %lus).\n", req->rq_xid,
+                  imp ? imp->imp_obd->obd_name : "<?>",
+                  imp ? libcfs_nid2str(imp->imp_connection->c_peer.nid) : "<?>",
+                  cfs_time_current_sec() - req->rq_sent,
+                  req->rq_net_err ? "failed due to network error" : "timed out",
+                  req->rq_deadline - req->rq_sent);
 
         if (imp != NULL && obd_debug_peer_on_timeout)
                 LNetCtl(IOC_LIBCFS_DEBUG_PEER, &imp->imp_connection->c_peer);
@@ -1330,6 +1400,8 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink)
                 RETURN(1);
         }
 
+        atomic_inc(&imp->imp_timeouts);
+
         /* The DLM server doesn't want recovery run on its imports. */
         if (imp->imp_dlm_fake)
                 RETURN(1);
@@ -1370,13 +1442,14 @@ int ptlrpc_expired_set(void *data)
         LASSERT(set != NULL);
 
         /* A timeout expired; see which reqs it applies to... */
-        list_for_each (tmp, &set->set_requests) {
+        list_for_each(tmp, &set->set_requests) {
                 struct ptlrpc_request *req =
                         list_entry(tmp, struct ptlrpc_request, rq_set_chain);
 
                 /* Request in-flight? */
-                if (!((req->rq_phase == RQ_PHASE_RPC && !req->rq_waiting && 
-                       !req->rq_resend) || (req->rq_phase == RQ_PHASE_BULK)))
+                if (!((req->rq_phase == RQ_PHASE_RPC &&
+                       !req->rq_waiting && !req->rq_resend) ||
+                      (req->rq_phase == RQ_PHASE_BULK)))
                         continue;
 
                 if (req->rq_timedout ||     /* already dealt with */
@@ -1436,7 +1509,7 @@ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set)
         list_for_each(tmp, &set->set_requests) {
                 req = list_entry(tmp, struct ptlrpc_request, rq_set_chain);
 
-                /* Request in-flight? */
+                /* request in-flight? */
                 if (!(((req->rq_phase == RQ_PHASE_RPC) && !req->rq_waiting) ||
                       (req->rq_phase == RQ_PHASE_BULK) ||
                       (req->rq_phase == RQ_PHASE_NEW)))
@@ -2090,7 +2163,7 @@ restart:
 
         LASSERT(!req->rq_receiving_reply);
         ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET);
-        cfs_waitq_signal(&imp->imp_recovery_waitq);
+        cfs_waitq_broadcast(&imp->imp_recovery_waitq);
         RETURN(rc);
 }
 
@@ -2118,9 +2191,24 @@ static int ptlrpc_replay_interpret(struct ptlrpc_request *req,
              lustre_msg_get_status(req->rq_repmsg) == -ENODEV))
                 GOTO(out, rc = lustre_msg_get_status(req->rq_repmsg));
 
-        /* The transno had better not change over replay. */
-        LASSERT(lustre_msg_get_transno(req->rq_reqmsg) ==
-                lustre_msg_get_transno(req->rq_repmsg));
+        /* VBR: check version failure */
+        if (lustre_msg_get_status(req->rq_repmsg) == -EOVERFLOW) {
+                /* replay was failed due to version mismatch */
+                DEBUG_REQ(D_WARNING, req, "Version mismatch during replay\n");
+                spin_lock(&imp->imp_lock);
+                imp->imp_vbr_failed = 1;
+                spin_unlock(&imp->imp_lock);
+        } else {
+                /* The transno had better not change over replay. */
+                LASSERT(lustre_msg_get_transno(req->rq_reqmsg) ==
+                        lustre_msg_get_transno(req->rq_repmsg) ||
+                        lustre_msg_get_transno(req->rq_repmsg) == 0);
+        }
+
+        spin_lock(&imp->imp_lock);
+        imp->imp_last_replay_transno = lustre_msg_get_transno(req->rq_reqmsg);
+        spin_unlock(&imp->imp_lock);
+        LASSERT(imp->imp_last_replay_transno);
 
         DEBUG_REQ(D_HA, req, "got rep");
 
@@ -2138,10 +2226,6 @@ static int ptlrpc_replay_interpret(struct ptlrpc_request *req,
                 lustre_msg_set_status(req->rq_repmsg, aa->praa_old_status);
         }
 
-        spin_lock(&imp->imp_lock);
-        imp->imp_last_replay_transno = req->rq_transno;
-        spin_unlock(&imp->imp_lock);
-
         /* continue with recovery */
         rc = ptlrpc_import_recovery_state_machine(imp);
  out:
@@ -2161,10 +2245,8 @@ int ptlrpc_replay_req(struct ptlrpc_request *req)
         ENTRY;
 
         LASSERT(req->rq_import->imp_state == LUSTRE_IMP_REPLAY);
-        /* Not handling automatic bulk replay yet (or ever?) */
-        LASSERT(req->rq_bulk == NULL);
 
-        CLASSERT(sizeof (*aa) <= sizeof (req->rq_async_args));
+        CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
         memset(aa, 0, sizeof *aa);
 
@@ -2267,8 +2349,37 @@ void ptlrpc_abort_set(struct ptlrpc_request_set *set)
         }
 }
 
-static __u64 ptlrpc_last_xid = 0;
-spinlock_t ptlrpc_last_xid_lock;
+static __u64 ptlrpc_last_xid;
+static spinlock_t ptlrpc_last_xid_lock;
+
+/* Initialize the XID for the node.  This is common among all requests on
+ * this node, and only requires the property that it is monotonically
+ * increasing.  It does not need to be sequential.  Since this is also used
+ * as the RDMA match bits, it is important that a single client NOT have
+ * the same match bits for two different in-flight requests, hence we do
+ * NOT want to have an XID per target or similar.
+ *
+ * To avoid an unlikely collision between match bits after a client reboot
+ * (which would deliver old data into the wrong RDMA buffer) we initialize
+ * the XID based on the current time, assuming a maximum RPC rate of 1M RPC/s.
+ * If the time is clearly incorrect, we instead use a 62-bit random number.
+ * In the worst case the random number will overflow 1M RPCs per second in
+ * 9133 years, or permutations thereof.
+ */
+#define YEAR_2004 (1ULL << 30)
+void ptlrpc_init_xid(void)
+{
+        time_t now = cfs_time_current_sec();
+
+        spin_lock_init(&ptlrpc_last_xid_lock);
+        if (now < YEAR_2004) {
+                ll_get_random_bytes(&ptlrpc_last_xid, sizeof(ptlrpc_last_xid));
+                ptlrpc_last_xid >>= 2;
+                ptlrpc_last_xid |= (1ULL << 61);
+        } else {
+                ptlrpc_last_xid = (__u64)now << 20;
+        }
+}
 
 __u64 ptlrpc_next_xid(void)
 {
@@ -2281,10 +2392,15 @@ __u64 ptlrpc_next_xid(void)
 
 __u64 ptlrpc_sample_next_xid(void)
 {
-        __u64 tmp;
-        spin_lock(&ptlrpc_last_xid_lock);
-        tmp = ptlrpc_last_xid + 1;
-        spin_unlock(&ptlrpc_last_xid_lock);
-        return tmp;
+        if (sizeof(long) < 8) {
+                /* need to avoid possible word tearing on 32-bit systems */
+                __u64 tmp;
+                spin_lock(&ptlrpc_last_xid_lock);
+                tmp = ptlrpc_last_xid + 1;
+                spin_unlock(&ptlrpc_last_xid_lock);
+                return tmp;
+        }
+        /* No need to lock, since returned value is racy anyways */
+        return ptlrpc_last_xid + 1;
 }
 EXPORT_SYMBOL(ptlrpc_sample_next_xid);
diff --git a/lustre/ptlrpc/connection.c b/lustre/ptlrpc/connection.c
index fb86c6c..1a38b4b 100644
--- a/lustre/ptlrpc/connection.c
+++ b/lustre/ptlrpc/connection.c
@@ -71,11 +71,11 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
         if (uuid)
                 obd_str2uuid(&conn->c_remote_uuid, uuid->uuid);
 
-        /* 
+        /*
          * Add the newly created conn to the hash, on key collision we
          * lost a racing addition and must destroy our newly allocated
          * connection.  The object which exists in the has will be
-         * returned and may be compared against out object. 
+         * returned and may be compared against out object.
          */
         conn2 = lustre_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
         if (conn != conn2) {
@@ -85,31 +85,31 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
         EXIT;
 out:
         CDEBUG(D_INFO, "conn=%p refcount %d to %s\n",
-               conn, atomic_read(&conn->c_refcount), 
+               conn, atomic_read(&conn->c_refcount),
                libcfs_nid2str(conn->c_peer.nid));
         return conn;
 }
-  
+
 int ptlrpc_connection_put(struct ptlrpc_connection *conn)
 {
         int rc = 0;
         ENTRY;
-  
+
         if (!conn)
                 RETURN(rc);
-  
+
         LASSERT(!hlist_unhashed(&conn->c_hash));
-  
+
         /*
-         * We do not remove connection from hashtable and 
+         * We do not remove connection from hashtable and
          * do not free it even if last caller released ref,
          * as we want to have it cached for the case it is
          * needed again.
          *
          * Deallocating it and later creating new connection
          * again would be wastful. This way we also avoid
-         * expensive locking to protect things from get/put 
-         * race when found cached connection is freed by 
+         * expensive locking to protect things from get/put
+         * race when found cached connection is freed by
          * ptlrpc_connection_put().
          *
          * It will be freed later in module unload time,
@@ -125,7 +125,7 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn)
 
         RETURN(rc);
 }
-  
+
 struct ptlrpc_connection *
 ptlrpc_connection_addref(struct ptlrpc_connection *conn)
 {
@@ -138,19 +138,21 @@ ptlrpc_connection_addref(struct ptlrpc_connection *conn)
 
         RETURN(conn);
 }
-  
+
 int ptlrpc_connection_init(void)
 {
         ENTRY;
 
-        conn_hash = lustre_hash_init("CONN_HASH", 5, 15,
+        conn_hash = lustre_hash_init("CONN_HASH",
+                                     HASH_CONN_CUR_BITS,
+                                     HASH_CONN_MAX_BITS,
                                      &conn_hash_ops, LH_REHASH);
         if (!conn_hash)
                 RETURN(-ENOMEM);
-  
+
         RETURN(0);
 }
-  
+
 void ptlrpc_connection_fini(void) {
         ENTRY;
         lustre_hash_exit(conn_hash);
@@ -216,13 +218,13 @@ conn_exit(struct hlist_node *hnode)
         struct ptlrpc_connection *conn;
 
         conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
-        /* 
+        /*
          * Nothing should be left. Connection user put it and
          * connection also was deleted from table by this time
          * so we should have 0 refs.
          */
-        LASSERTF(atomic_read(&conn->c_refcount) == 0, 
-                 "Busy connection with %d refs\n", 
+        LASSERTF(atomic_read(&conn->c_refcount) == 0,
+                 "Busy connection with %d refs\n",
                  atomic_read(&conn->c_refcount));
         OBD_FREE_PTR(conn);
 }
diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c
index 6eb4c86..18d5eff 100644
--- a/lustre/ptlrpc/events.c
+++ b/lustre/ptlrpc/events.c
@@ -93,7 +93,7 @@ void reply_in_callback(lnet_event_t *ev)
 
         DEBUG_REQ((ev->status == 0) ? D_NET : D_ERROR, req,
                   "type %d, status %d", ev->type, ev->status);
-        
+
         LASSERT(ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK);
         LASSERT(ev->md.start == req->rq_repbuf);
         LASSERT(ev->mlength <= req->rq_replen);
@@ -107,7 +107,7 @@ void reply_in_callback(lnet_event_t *ev)
         req->rq_early = 0;
         if (ev->unlinked)
                 req->rq_must_unlink = 0;
-        
+
         if (ev->status)
                 goto out_wake;
         if (ev->type == LNET_EVENT_UNLINK) {
@@ -116,7 +116,7 @@ void reply_in_callback(lnet_event_t *ev)
                 goto out_wake;
         }
 
-        if ((ev->offset == 0) && 
+        if ((ev->offset == 0) &&
             (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT)) {
                 /* Early reply */
                 DEBUG_REQ(D_ADAPTTO, req,
@@ -124,9 +124,9 @@ void reply_in_callback(lnet_event_t *ev)
                           "replied=%d unlinked=%d", ev->mlength, ev->offset,
                           req->rq_replen, req->rq_replied, ev->unlinked);
 
-                if (unlikely(ev->mlength != lustre_msg_early_size()))
+                if (unlikely(ev->mlength != lustre_msg_early_size(req)))
                         CERROR("early reply sized %u, expect %u\n",
-                               ev->mlength, lustre_msg_early_size());
+                               ev->mlength, lustre_msg_early_size(req));
 
                 req->rq_early_count++; /* number received, client side */
 
diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c
index d9d754e..f7cc6df 100644
--- a/lustre/ptlrpc/import.c
+++ b/lustre/ptlrpc/import.c
@@ -58,6 +58,17 @@ struct ptlrpc_connect_async_args {
         int pcaa_initial_connect;
 };
 
+static void __import_set_state(struct obd_import *imp,
+                               enum lustre_imp_state state)
+{
+        imp->imp_state = state;
+        imp->imp_state_hist[imp->imp_state_hist_idx].ish_state = state;
+        imp->imp_state_hist[imp->imp_state_hist_idx].ish_time =
+                cfs_time_current_sec();
+        imp->imp_state_hist_idx = (imp->imp_state_hist_idx + 1) %
+                IMP_STATE_HIST_LEN;
+}
+
 /* A CLOSED import should remain so. */
 #define IMPORT_SET_STATE_NOLOCK(imp, state)                                    \
 do {                                                                           \
@@ -66,7 +77,7 @@ do {                                                                           \
                       imp, obd2cli_tgt(imp->imp_obd),                          \
                       ptlrpc_import_state_name(imp->imp_state),                \
                       ptlrpc_import_state_name(state));                        \
-               imp->imp_state = state;                                         \
+               __import_set_state(imp, state);                                 \
         }                                                                      \
 } while(0)
 
@@ -259,7 +270,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp)
          * If this is an invalid MGC connection, then don't bother
          * waiting for imp_inflight to drop to 0.
          */
-        if (imp->imp_invalid && imp->imp_recon_bk && !imp->imp_obd->obd_no_recov)
+        if (imp->imp_invalid && imp->imp_recon_bk &&!imp->imp_obd->obd_no_recov)
                 goto out;
 
         if (!imp->imp_invalid || imp->imp_obd->obd_no_recov)
@@ -281,7 +292,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp)
                 if (timeout == 0)
                         timeout = obd_timeout;
 
-                CDEBUG(D_RPCTRACE, "Sleeping %d sec for inflight to error out\n",
+                CDEBUG(D_RPCTRACE,"Sleeping %d sec for inflight to error out\n",
                        timeout);
 
                 /* Wait for all requests to error out and call completion
@@ -302,25 +313,15 @@ void ptlrpc_invalidate_import(struct obd_import *imp)
                         list_for_each_safe(tmp, n, &imp->imp_sending_list) {
                                 req = list_entry(tmp, struct ptlrpc_request,
                                         rq_list);
-                                DEBUG_REQ(D_ERROR, req, "still on sending list");
+                                DEBUG_REQ(D_ERROR, req,"still on sending list");
                         }
                         list_for_each_safe(tmp, n, &imp->imp_delayed_list) {
                                 req = list_entry(tmp, struct ptlrpc_request,
                                         rq_list);
-                                DEBUG_REQ(D_ERROR, req, "still on delayed list");
+                                DEBUG_REQ(D_ERROR, req,"still on delayed list");
                         }
 
                         if (atomic_read(&imp->imp_unregistering) == 0) {
-                                /* XXX: This is temporary workaround for long
-                                 * connect interpret due to locking in lov in
-                                 * in import activation path, which causes
-                                 * connect rpc stay on sending list longer
-                                 * time. Let's wait longer insread of asserting
-                                 * here.
-                                 *
-                                 * Activation should not be blocking. Kill
-                                 * this #if 0 when activation code is fixed. */
-#if 0
                                 /* We know that only "unregistering" rpcs may
                                  * still survive in sending or delaying lists
                                  * (They are waiting for long reply unlink in
@@ -333,7 +334,6 @@ void ptlrpc_invalidate_import(struct obd_import *imp)
                                  * dropped to zero. No new inflights possible at
                                  * this point. */
                                 rc = 0;
-#endif
                         } else {
                                 CERROR("%s: RPCs in \"%s\" phase found (%d). "
                                        "Network is sluggish? Waiting them "
@@ -349,11 +349,11 @@ void ptlrpc_invalidate_import(struct obd_import *imp)
          * "invalidate" state. */
         LASSERT(atomic_read(&imp->imp_inflight) == 0);
 
-  out:
+out:
         obd_import_event(imp->imp_obd, imp, IMP_EVENT_INVALIDATE);
 
         atomic_dec(&imp->imp_inval_count);
-        cfs_waitq_signal(&imp->imp_recovery_waitq);
+        cfs_waitq_broadcast(&imp->imp_recovery_waitq);
 }
 
 /* unset imp_invalid */
@@ -398,6 +398,7 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt)
 
 int ptlrpc_reconnect_import(struct obd_import *imp)
 {
+
         ptlrpc_set_import_discon(imp, 0);
         /* Force a new connect attempt */
         ptlrpc_invalidate_import(imp);
@@ -523,10 +524,9 @@ static int import_select_connection(struct obd_import *imp)
 
         if (imp->imp_conn_current != imp_conn) {
                 if (imp->imp_conn_current)
-                        LCONSOLE_INFO("Changing connection for %s to %s/%s\n",
-                                      imp->imp_obd->obd_name,
-                                      imp_conn->oic_uuid.uuid,
-                                      libcfs_nid2str(imp_conn->oic_conn->c_peer.nid));
+                        CDEBUG(D_HA, "Changing connection for %s to %s/%s\n",
+                               imp->imp_obd->obd_name, imp_conn->oic_uuid.uuid,
+                               libcfs_nid2str(imp_conn->oic_conn->c_peer.nid));
                 imp->imp_conn_current = imp_conn;
         }
 
@@ -539,9 +539,31 @@ static int import_select_connection(struct obd_import *imp)
         RETURN(0);
 }
 
+/**
+ * must be called under imp lock
+ */
+static int ptlrpc_first_transno(struct obd_import *imp, __u64 *transno)
+{
+        struct ptlrpc_request *req;
+        struct list_head *tmp;
+
+        if (list_empty(&imp->imp_replay_list))
+                return 0;
+        tmp = imp->imp_replay_list.next;
+        req = list_entry(tmp, struct ptlrpc_request, rq_replay_list);
+        *transno = req->rq_transno;
+        if (req->rq_transno == 0) {
+                DEBUG_REQ(D_ERROR, req, "zero transno in replay");
+                LBUG();
+        }
+
+        return 1;
+}
+
 int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid)
 {
         struct obd_device *obd = imp->imp_obd;
+        int set_transno = 0;
         int initial_connect = 0;
         int rc;
         __u64 committed_before_reconnect = 0;
@@ -584,6 +606,9 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid)
         else
                 committed_before_reconnect = imp->imp_peer_committed_transno;
 
+        set_transno = ptlrpc_first_transno(imp,
+                                           &imp->imp_connect_data.ocd_transno);
+
         spin_unlock(&imp->imp_lock);
 
         if (new_uuid) {
@@ -663,7 +688,7 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid)
         ptlrpc_req_set_repsize(request, 2, size);
         request->rq_interpret_reply = ptlrpc_connect_interpret;
 
-        CLASSERT(sizeof (*aa) <= sizeof (request->rq_async_args));
+        CLASSERT(sizeof(*aa) <= sizeof(request->rq_async_args));
         aa = ptlrpc_req_async_args(request);
         memset(aa, 0, sizeof *aa);
 
@@ -673,8 +698,14 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid)
                 spin_lock(&imp->imp_lock);
                 imp->imp_replayable = 1;
                 spin_unlock(&imp->imp_lock);
+                lustre_msg_add_op_flags(request->rq_reqmsg,
+                                        MSG_CONNECT_INITIAL);
         }
 
+        if (set_transno)
+                lustre_msg_add_op_flags(request->rq_reqmsg,
+                                        MSG_CONNECT_TRANSNO);
+
         DEBUG_REQ(D_RPCTRACE, request, "%sconnect request %d",
                   aa->pcaa_initial_connect ? "initial " : "re",
                   imp->imp_conn_cnt);
@@ -795,7 +826,6 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
                         IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
                         ptlrpc_activate_import(imp);
                 }
-
                 GOTO(finish, rc = 0);
         } else {
                 spin_unlock(&imp->imp_lock);
@@ -816,8 +846,8 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
                 if (memcmp(&imp->imp_remote_handle,
                            lustre_msg_get_handle(request->rq_repmsg),
                            sizeof(imp->imp_remote_handle))) {
-                        int level = msg_flags & MSG_CONNECT_RECOVERING ? D_HA :
-                                                                         D_WARNING;
+                        int level = msg_flags & MSG_CONNECT_RECOVERING ?
+                                D_HA : D_WARNING;
 
                         /* Bug 16611/14775: if server handle have changed,
                          * that means some sort of disconnection happened.
@@ -827,14 +857,14 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
                          * participate since we can reestablish all of our state
                          * with server again */
                         CDEBUG(level,"%s@%s changed server handle from "
-                                     LPX64" to "LPX64"%s \n" "but is still in recovery \n",
+                                     LPX64" to "LPX64"%s\n",
                                      obd2cli_tgt(imp->imp_obd),
                                      imp->imp_connection->c_remote_uuid.uuid,
                                      imp->imp_remote_handle.cookie,
                                      lustre_msg_get_handle(request->rq_repmsg)->
                                                                         cookie,
                                      (MSG_CONNECT_RECOVERING & msg_flags) ?
-                                         "but is still in recovery" : "");
+                                         " but is still in recovery" : "");
 
                         imp->imp_remote_handle =
                                      *lustre_msg_get_handle(request->rq_repmsg);
@@ -861,6 +891,11 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
 
                         spin_lock(&imp->imp_lock);
                         imp->imp_resend_replay = 1;
+                        /* VBR: delayed connection */
+                        if (MSG_CONNECT_DELAYED & msg_flags) {
+                                imp->imp_delayed_recovery = 1;
+                                imp->imp_no_lock_replay = 1;
+                        }
                         spin_unlock(&imp->imp_lock);
 
                         IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
@@ -872,6 +907,13 @@ static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
                 imp->imp_remote_handle =
                                 *lustre_msg_get_handle(request->rq_repmsg);
                 imp->imp_last_replay_transno = 0;
+                /* VBR: delayed connection */
+                if (MSG_CONNECT_DELAYED & msg_flags) {
+                        spin_lock(&imp->imp_lock);
+                        imp->imp_delayed_recovery = 1;
+                        imp->imp_no_lock_replay = 1;
+                        spin_unlock(&imp->imp_lock);
+                }
                 IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
         } else {
                 DEBUG_REQ(D_HA, request, "evicting (not initial connect and "
@@ -947,7 +989,8 @@ finish:
                 }
                 old_connect_flags = exp->exp_connect_flags;
                 exp->exp_connect_flags = ocd->ocd_connect_flags;
-                imp->imp_obd->obd_self_export->exp_connect_flags = ocd->ocd_connect_flags;
+                imp->imp_obd->obd_self_export->exp_connect_flags =
+                        ocd->ocd_connect_flags;
                 class_export_put(exp);
 
                 obd_import_event(imp->imp_obd, imp, IMP_EVENT_OCD);
@@ -1027,8 +1070,9 @@ finish:
                  * disable lru_resize, etc. */
                 if (old_connect_flags != exp->exp_connect_flags ||
                     aa->pcaa_initial_connect) {
-                        CDEBUG(D_HA, "Resetting ns_connect_flags to server "
-                               "flags: "LPU64"\n", ocd->ocd_connect_flags);
+                        CDEBUG(D_HA, "%s: Resetting ns_connect_flags to server "
+                               "flags: "LPX64"\n", imp->imp_obd->obd_name,
+                               ocd->ocd_connect_flags);
                         imp->imp_obd->obd_namespace->ns_connect_flags =
                                 ocd->ocd_connect_flags;
                         imp->imp_obd->obd_namespace->ns_orig_connect_flags =
@@ -1108,24 +1152,34 @@ finish:
         imp->imp_last_recon = 0;
         spin_unlock(&imp->imp_lock);
 
-        cfs_waitq_signal(&imp->imp_recovery_waitq);
+        cfs_waitq_broadcast(&imp->imp_recovery_waitq);
         RETURN(rc);
 }
 
 static int completed_replay_interpret(struct ptlrpc_request *req,
-                                    void * data, int rc)
+                                      void * data, int rc)
 {
         ENTRY;
         atomic_dec(&req->rq_import->imp_replay_inflight);
-        if (req->rq_status == 0) {
+        if (req->rq_status == 0 &&
+            !req->rq_import->imp_vbr_failed) {
                 ptlrpc_import_recovery_state_machine(req->rq_import);
         } else {
-                CDEBUG(D_HA, "%s: LAST_REPLAY message error: %d, "
-                       "reconnecting\n",
-                       req->rq_import->imp_obd->obd_name, req->rq_status);
+                if (req->rq_import->imp_vbr_failed) {
+                        CDEBUG(D_WARNING,
+                               "%s: version recovery fails, reconnecting\n",
+                               req->rq_import->imp_obd->obd_name);
+                        spin_lock(&req->rq_import->imp_lock);
+                        req->rq_import->imp_vbr_failed = 0;
+                        spin_unlock(&req->rq_import->imp_lock);
+                } else {
+                        CDEBUG(D_HA, "%s: LAST_REPLAY message error: %d, "
+                                     "reconnecting\n",
+                               req->rq_import->imp_obd->obd_name,
+                               req->rq_status);
+                }
                 ptlrpc_connect_import(req->rq_import, NULL);
         }
-
         RETURN(0);
 }
 
@@ -1145,7 +1199,13 @@ static int signal_completed_replay(struct obd_import *imp)
 
         ptlrpc_req_set_repsize(req, 1, NULL);
         req->rq_send_state = LUSTRE_IMP_REPLAY_WAIT;
-        lustre_msg_add_flags(req->rq_reqmsg, MSG_LAST_REPLAY);
+        lustre_msg_add_flags(req->rq_reqmsg,
+                             MSG_LOCK_REPLAY_DONE |
+                             MSG_REQ_REPLAY_DONE |
+                             MSG_LAST_REPLAY);
+
+        if (imp->imp_delayed_recovery)
+                lustre_msg_add_flags(req->rq_reqmsg, MSG_DELAY_REPLAY);
         req->rq_timeout *= 3;
         req->rq_interpret_reply = completed_replay_interpret;
 
@@ -1206,9 +1266,9 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
 
 #ifdef __KERNEL__
                 /* bug 17802:  XXX client_disconnect_export vs connect request
-                 * race. if client will evicted at this time, we start invalidate
-                 * thread without referece to import and import can be freed
-                 * at same time. */
+                 * race. if client will evicted at this time, we start
+                 * invalidate thread without referece to import and import can
+                 * be freed at same time. */
                 class_import_get(imp);
                 rc = cfs_kernel_thread(ptlrpc_invalidate_import_thread, imp,
                                    CLONE_VM | CLONE_FILES);
@@ -1276,7 +1336,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
         }
 
         if (imp->imp_state == LUSTRE_IMP_FULL) {
-                cfs_waitq_signal(&imp->imp_recovery_waitq);
+                cfs_waitq_broadcast(&imp->imp_recovery_waitq);
                 ptlrpc_wake_delayed(imp);
         }
 
@@ -1382,6 +1442,18 @@ void ptlrpc_import_setasync(struct obd_import *imp, int count)
         LNetSetAsync(imp->imp_connection->c_peer, count);
 }
 
+void ptlrpc_cleanup_imp(struct obd_import *imp)
+{
+        ENTRY;
+
+        spin_lock(&imp->imp_lock);
+        IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED);
+        imp->imp_generation++;
+        spin_unlock(&imp->imp_lock);
+        ptlrpc_abort_inflight(imp);
+
+        EXIT;
+}
 
 /* Adaptive Timeout utils */
 extern unsigned int at_min, at_max, at_history;
@@ -1397,11 +1469,10 @@ int at_add(struct adaptive_timeout *at, unsigned int val)
         time_t binlimit = max_t(time_t, at_history / AT_BINS, 1);
 
         LASSERT(at);
-#if 0
-        CDEBUG(D_INFO, "add %u to %p time=%lu v=%u (%u %u %u %u)\n",
+        CDEBUG(D_OTHER, "add %u to %p time=%lu v=%u (%u %u %u %u)\n",
                val, at, now - at->at_binstart, at->at_current,
                at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]);
-#endif
+
         if (val == 0)
                 /* 0's don't count, because we never want our timeout to
                    drop to 0, and because 0 could mean an error */
@@ -1453,14 +1524,12 @@ int at_add(struct adaptive_timeout *at, unsigned int val)
                 at->at_current =  min(at->at_current, at_max);
         at->at_current =  max(at->at_current, at_min);
 
-#if 0
         if (at->at_current != old)
-                CDEBUG(D_ADAPTTO, "AT %p change: old=%u new=%u delta=%d "
+                CDEBUG(D_OTHER, "AT %p change: old=%u new=%u delta=%d "
                        "(val=%u) hist %u %u %u %u\n", at,
                        old, at->at_current, at->at_current - old, val,
                        at->at_hist[0], at->at_hist[1], at->at_hist[2],
                        at->at_hist[3]);
-#endif
 
         /* if we changed, report the old value */
         old = (at->at_current != old) ? old : 0;
diff --git a/lustre/ptlrpc/llog_client.c b/lustre/ptlrpc/llog_client.c
index d463183..d26d8df 100644
--- a/lustre/ptlrpc/llog_client.c
+++ b/lustre/ptlrpc/llog_client.c
@@ -57,7 +57,7 @@
 #include <lustre_net.h>
 #include <libcfs/list.h>
 
-#define  LLOG_CLIENT_ENTRY(ctxt, imp) do {                            \
+#define LLOG_CLIENT_ENTRY(ctxt, imp) do {                             \
         mutex_down(&ctxt->loc_sem);                                   \
         if (ctxt->loc_imp) {                                          \
                 imp = class_import_get(ctxt->loc_imp);                \
@@ -73,13 +73,13 @@
         mutex_up(&ctxt->loc_sem);                                     \
 } while(0)
 
-#define  LLOG_CLIENT_EXIT(ctxt, imp) do {                  \
-        mutex_down(&ctxt->loc_sem);                        \
-        if (ctxt->loc_imp != imp)                          \
-                CWARN("loc_imp has changed from %p to %p", \
-                       ctxt->loc_imp, imp);                \
-        class_import_put(imp);                             \
-        mutex_up(&ctxt->loc_sem);                          \
+#define LLOG_CLIENT_EXIT(ctxt, imp) do {                              \
+        mutex_down(&ctxt->loc_sem);                                   \
+        if (ctxt->loc_imp != imp)                                     \
+                CWARN("loc_imp has changed from %p to %p\n",          \
+                       ctxt->loc_imp, imp);                           \
+        class_import_put(imp);                                        \
+        mutex_up(&ctxt->loc_sem);                                     \
 } while(0)
 
 /* This is a callback from the llog_* functions.
diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c
index 558c83e..476d9b7 100644
--- a/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/lustre/ptlrpc/lproc_ptlrpc.c
@@ -91,6 +91,8 @@ struct ll_rpc_opcode {
         { MDS_QUOTACTL,     "mds_quotactl" },
         { MDS_GETXATTR,     "mds_getxattr" },
         { MDS_SETXATTR,     "mds_setxattr" },
+        { MDS_WRITEPAGE,    "mds_writepage" },
+        { MDS_IS_SUBDIR,    "mds_is_subdir" },
         { LDLM_ENQUEUE,     "ldlm_enqueue" },
         { LDLM_CONVERT,     "ldlm_convert" },
         { LDLM_CANCEL,      "ldlm_cancel" },
@@ -117,6 +119,7 @@ struct ll_rpc_opcode {
         { LLOG_ORIGIN_HANDLE_DESTROY,    "llog_origin_handle_destroy" },
         { QUOTA_DQACQ,      "quota_acquire" },
         { QUOTA_DQREL,      "quota_release" },
+        { SEQ_QUERY,        "seq_query" },
 };
 
 struct ll_eopcode {
@@ -285,6 +288,81 @@ ptlrpc_lprocfs_write_req_history_max(struct file *file, const char *buffer,
         return count;
 }
 
+static int
+ptlrpc_lprocfs_rd_threads_min(char *page, char **start, off_t off,
+                              int count, int *eof, void *data)
+{
+        struct ptlrpc_service *svc = data;
+
+        return snprintf(page, count, "%d\n", svc->srv_threads_min);
+}
+
+static int
+ptlrpc_lprocfs_wr_threads_min(struct file *file, const char *buffer,
+                              unsigned long count, void *data)
+{
+        struct ptlrpc_service *svc = data;
+        int                    val;
+        int                    rc = lprocfs_write_helper(buffer, count, &val);
+
+        if (rc < 0)
+                return rc;
+
+        if (val < 2)
+                return -ERANGE;
+
+        if (val > svc->srv_threads_max)
+                return -ERANGE;
+
+        spin_lock(&svc->srv_lock);
+        svc->srv_threads_min = val;
+        spin_unlock(&svc->srv_lock);
+
+        return count;
+}
+
+static int
+ptlrpc_lprocfs_rd_threads_started(char *page, char **start, off_t off,
+                                  int count, int *eof, void *data)
+{
+        struct ptlrpc_service *svc = data;
+
+        return snprintf(page, count, "%d\n", svc->srv_threads_started);
+}
+
+static int
+ptlrpc_lprocfs_rd_threads_max(char *page, char **start, off_t off,
+                              int count, int *eof, void *data)
+{
+        struct ptlrpc_service *svc = data;
+
+        return snprintf(page, count, "%d\n", svc->srv_threads_max);
+}
+
+static int
+ptlrpc_lprocfs_wr_threads_max(struct file *file, const char *buffer,
+                              unsigned long count, void *data)
+{
+        struct ptlrpc_service *svc = data;
+        int                    val;
+        int                    rc = lprocfs_write_helper(buffer, count, &val);
+
+        if (rc < 0)
+                return rc;
+
+        if (val < 2)
+                return -ERANGE;
+
+        if (val < svc->srv_threads_min)
+                return -ERANGE;
+
+        spin_lock(&svc->srv_lock);
+        svc->srv_threads_max = val;
+        spin_unlock(&svc->srv_lock);
+
+        return count;
+}
+
 struct ptlrpc_srh_iterator {
         __u64                  srhi_seq;
         struct ptlrpc_request *srhi_req;
@@ -436,7 +514,7 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
                  * must be just as careful as the service's request
                  * parser. Currently I only print stuff here I know is OK
                  * to look at coz it was set up in request_in_callback()!!! */
-                seq_printf(s, LPD64":%s:%s:x"LPD64":%d:%s:%ld:%lds(%+lds) ",
+                seq_printf(s, LPD64":%s:%s:x"LPU64":%d:%s:%ld:%lds(%+lds) ",
                            req->rq_history_seq, libcfs_nid2str(req->rq_self),
                            libcfs_id2str(req->rq_peer), req->rq_xid,
                            req->rq_reqlen, ptlrpc_rqphase2str(req),
@@ -520,7 +598,7 @@ static int ptlrpc_lprocfs_wr_hp_ratio(struct file *file, const char *buffer,
 {
         struct ptlrpc_service *svc = data;
         int rc, val;
-        
+
         rc = lprocfs_write_helper(buffer, count, &val);
         if (rc < 0)
                 return rc;
@@ -537,21 +615,31 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
                                      struct ptlrpc_service *svc)
 {
         struct lprocfs_vars lproc_vars[] = {
+                {.name       = "high_priority_ratio",
+                 .read_fptr  = ptlrpc_lprocfs_rd_hp_ratio,
+                 .write_fptr = ptlrpc_lprocfs_wr_hp_ratio,
+                 .data       = svc},
                 {.name       = "req_buffer_history_len",
-                 .write_fptr = NULL,
                  .read_fptr  = ptlrpc_lprocfs_read_req_history_len,
                  .data       = svc},
                 {.name       = "req_buffer_history_max",
                  .write_fptr = ptlrpc_lprocfs_write_req_history_max,
                  .read_fptr  = ptlrpc_lprocfs_read_req_history_max,
                  .data       = svc},
+                {.name       = "threads_min",
+                 .read_fptr  = ptlrpc_lprocfs_rd_threads_min,
+                 .write_fptr = ptlrpc_lprocfs_wr_threads_min,
+                 .data       = svc},
+                {.name       = "threads_max",
+                 .read_fptr  = ptlrpc_lprocfs_rd_threads_max,
+                 .write_fptr = ptlrpc_lprocfs_wr_threads_max,
+                 .data       = svc},
+                {.name       = "threads_started",
+                 .read_fptr  = ptlrpc_lprocfs_rd_threads_started,
+                 .data       = svc},
                 {.name       = "timeouts",
                  .read_fptr  = ptlrpc_lprocfs_rd_timeouts,
                  .data       = svc},
-                {.name       = "high_priority_ratio",
-                 .read_fptr  = ptlrpc_lprocfs_rd_hp_ratio,
-                 .write_fptr = ptlrpc_lprocfs_wr_hp_ratio,
-                 .data       = svc},
                 {NULL}
         };
         static struct file_operations req_history_fops = {
@@ -588,7 +676,7 @@ void ptlrpc_lprocfs_register_obd(struct obd_device *obddev)
 }
 EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd);
 
-void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req)
+void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount)
 {
         struct lprocfs_stats *svc_stats;
         __u32 op = lustre_msg_get_opc(req->rq_reqmsg);
@@ -599,7 +687,7 @@ void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req)
                 return;
         LASSERT(opc < LUSTRE_MAX_OPCODES);
         if (!(op == LDLM_ENQUEUE || op == MDS_REINT))
-                lprocfs_counter_add(svc_stats, opc + EXTRA_MAX_OPCODES, 0);
+                lprocfs_counter_add(svc_stats, opc + EXTRA_MAX_OPCODES, amount);
 }
 
 void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes)
@@ -688,16 +776,12 @@ int lprocfs_wr_ping(struct file *file, const char *buffer,
         ENTRY;
 
         LPROCFS_CLIMP_CHECK(obd);
-        req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_OBD_VERSION,
-                              OBD_PING, 1, NULL, NULL);
+        req = ptlrpc_prep_ping(obd->u.cli.cl_import);
         LPROCFS_CLIMP_EXIT(obd);
         if (req == NULL)
                 RETURN(-ENOMEM);
 
-        ptlrpc_req_set_repsize(req, 1, NULL);
         req->rq_send_state = LUSTRE_IMP_FULL;
-        req->rq_no_resend = 1;
-        req->rq_no_delay = 1;
 
         rc = ptlrpc_queue_wait(req);
 
diff --git a/lustre/ptlrpc/niobuf.c b/lustre/ptlrpc/niobuf.c
index 7bb6103..e48cf86 100644
--- a/lustre/ptlrpc/niobuf.c
+++ b/lustre/ptlrpc/niobuf.c
@@ -241,10 +241,14 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req)
 
         /* XXX Registering the same xid on retried bulk makes my head
          * explode trying to understand how the original request's bulk
-         * might interfere with the retried request -eeb */
-        LASSERTF (!desc->bd_registered || req->rq_xid != desc->bd_last_xid,
-                  "registered: %d  rq_xid: "LPU64" bd_last_xid: "LPU64"\n",
-                  desc->bd_registered, req->rq_xid, desc->bd_last_xid);
+         * might interfere with the retried request -eeb
+         * On the other hand replaying with the same xid is fine, since
+         * we are guaranteed old request have completed. -green */
+        LASSERTF(!(desc->bd_registered &&
+                 req->rq_send_state != LUSTRE_IMP_REPLAY) ||
+                 req->rq_xid != desc->bd_last_xid,
+                 "registered: %d  rq_xid: "LPU64" bd_last_xid: "LPU64"\n",
+                 desc->bd_registered, req->rq_xid, desc->bd_last_xid);
         desc->bd_registered = 1;
         desc->bd_last_xid = req->rq_xid;
 
@@ -268,7 +272,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req)
                 RETURN (-ENOMEM);
         }
 
-        CDEBUG(D_NET, "Setup bulk %s buffers: %u pages %u bytes, xid "LPX64", "
+        CDEBUG(D_NET, "Setup bulk %s buffers: %u pages %u bytes, xid "LPU64", "
                "portal %u\n",
                desc->bd_type == BULK_GET_SOURCE ? "get-source" : "put-sink",
                desc->bd_iov_count, desc->bd_nob,
@@ -415,7 +419,7 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags)
                         lustre_msg_set_cksum(req->rq_repmsg, 
                                          lustre_msg_calc_cksum(req->rq_repmsg));
                 } else {
-                        offset = lustre_msg_early_size();
+                        offset = lustre_msg_early_size(req);
                 }
         } else {
                 CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x "
@@ -619,10 +623,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
                           connection,
                           request->rq_request_portal,
                           request->rq_xid, 0);
-        if (rc == 0) {
-                ptlrpc_lprocfs_rpc_sent(request);
+        if (rc == 0)
                 RETURN(rc);
-        }
 
         ptlrpc_req_finished(request);
         if (noreply)
diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c
index 4eb5861..26d8104 100644
--- a/lustre/ptlrpc/pack_generic.c
+++ b/lustre/ptlrpc/pack_generic.c
@@ -54,10 +54,8 @@
 #include <lustre_net.h>
 #include <lustre/ll_fiemap.h>
 
-#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(1,8,0,0)
+#if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(1,8,99,0)
 #error "lustre_msg_v1 has been deprecated since 1.6.0, please remove it"
-#elif LUSTRE_VERSION_CODE > OBD_OCD_VERSION(1,6,50,0)
-#warning "lustre_msg_v1 has been deprecated since 1.6.0, consider removing it"
 #endif
 
 static inline int lustre_msg_hdr_size_v1(int count)
@@ -117,8 +115,16 @@ static int ptlrpc_repbuf_need_swab(struct ptlrpc_request *req, int index)
 
 
 /* early reply size */
-int lustre_msg_early_size() {
+int lustre_msg_early_size(struct ptlrpc_request *req) {
         static int size = 0;
+        /* For b1_6 interoperability */
+        if (req->rq_reqmsg &&
+            req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2) {
+                __u32 pb_len = lustre_msg_buflen(req->rq_reqmsg,
+                                               MSG_PTLRPC_BODY_OFF);
+                return lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pb_len);
+        }
+
         if (!size)
                 size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, NULL);
         return size;
@@ -166,8 +172,12 @@ int lustre_msg_size(__u32 magic, int count, __u32 *lens)
         }
 
         LASSERT(count > 0);
+#ifdef PTLRPC_INTEROP_1_6
+        LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body) ||
+                lens[MSG_PTLRPC_BODY_OFF] == PTLRPC_BODY_MIN_SIZE);
+#else
         LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
-
+#endif
         switch (magic) {
         case LUSTRE_MSG_MAGIC_V1:
                 return lustre_msg_size_v1(count - 1, lens + 1);
@@ -448,6 +458,12 @@ static int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
         if ((flags & LPRFL_EARLY_REPLY) == 0)
                 req->rq_packed_final = 1;
 
+        /* use the same size of ptlrpc_body as client requested for
+         * interoperability cases */
+        LASSERT(req->rq_reqmsg);
+        lens[MSG_PTLRPC_BODY_OFF] = lustre_msg_buflen(req->rq_reqmsg,
+                                                      MSG_PTLRPC_BODY_OFF);
+
         msg_len = lustre_msg_size_v2(count, lens);
         size = sizeof(struct ptlrpc_reply_state) + msg_len;
         OBD_ALLOC(rs, size);
@@ -468,7 +484,6 @@ static int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
         req->rq_replen = msg_len;
         req->rq_reply_state = rs;
         req->rq_repmsg = rs->rs_msg;
-
         /* server side, no rq_repbuf */
         lustre_init_msg_v2(rs->rs_msg, count, lens, bufs);
         lustre_msg_add_version(rs->rs_msg, PTLRPC_MSG_VERSION);
@@ -562,8 +577,9 @@ void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size)
 
         buflen = m->lm_buflens[n];
         if (buflen < min_size) {
-                CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
-                       m, n, buflen, min_size);
+                CERROR("msg %p buffer[%d] size %d too small "
+                       "(required %d, opc=%d)\n",
+                       m, n, buflen, min_size, lustre_msg_get_opc(m));
                 return NULL;
         }
 
@@ -654,7 +670,7 @@ void lustre_shrink_reply_v2(struct ptlrpc_request *req, int segment,
                 newpos = lustre_msg_buf_v2(msg, segment + 1, 0);
                 LASSERT(newpos <= tail);
                 if (newpos != tail)
-                        memcpy(newpos, tail, tail_len);
+                        memmove(newpos, tail, tail_len);
         }
 
         if (newlen == 0 && msg->lm_bufcount > segment + 1) {
@@ -883,13 +899,13 @@ static inline int lustre_unpack_ptlrpc_body_v2(struct lustre_msg_v2 *m,
 {
         struct ptlrpc_body *pb;
 
-        pb = lustre_msg_buf_v2(m, offset, sizeof(*pb));
+        pb = lustre_msg_buf_v2(m, offset, PTLRPC_BODY_MIN_SIZE);
         if (!pb) {
                 CERROR("error unpacking ptlrpc body\n");
                 return -EFAULT;
         }
         if (swab_needed)
-                lustre_swab_ptlrpc_body(pb);
+                lustre_swab_ptlrpc_body(pb, lustre_msg_buflen(m, offset));
 
         if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
                  CERROR("wrong lustre_msg version %08x\n", pb->pb_version);
@@ -1144,6 +1160,12 @@ void *lustre_swab_repbuf(struct ptlrpc_request *req, int index, int min_size,
         return lustre_swab_buf(req->rq_repmsg, index, min_size, swabber);
 }
 
+static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg)
+{
+        return lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
+                                 PTLRPC_BODY_MIN_SIZE);
+}
+
 __u32 lustre_msghdr_get_flags(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
@@ -1178,9 +1200,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
                 return ((struct lustre_msg_v1 *)msg)->lm_flags &
                        MSG_GEN_FLAG_MASK;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1203,9 +1223,7 @@ void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
                                         MSG_GEN_FLAG_MASK & flags;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_flags |= flags;
                 return;
@@ -1224,9 +1242,7 @@ void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
                                         MSG_GEN_FLAG_MASK & flags;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_flags = flags;
                 return;
@@ -1244,9 +1260,7 @@ void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
                                         ~(MSG_GEN_FLAG_MASK & flags);
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_flags &= ~(MSG_GEN_FLAG_MASK & flags);
                 return;
@@ -1263,9 +1277,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
                 return ((struct lustre_msg_v1 *)msg)->lm_flags >>
                        MSG_OP_FLAG_SHIFT;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1286,9 +1298,7 @@ void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
                         (flags & MSG_GEN_FLAG_MASK) << MSG_OP_FLAG_SHIFT;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_op_flags |= flags;
                 return;
@@ -1307,9 +1317,7 @@ void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
                         ((flags & MSG_GEN_FLAG_MASK) <<MSG_OP_FLAG_SHIFT);
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_op_flags |= flags;
                 return;
@@ -1325,9 +1333,7 @@ struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return &((struct lustre_msg_v1 *)msg)->lm_handle;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return NULL;
@@ -1346,9 +1352,7 @@ __u32 lustre_msg_get_type(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_type;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return PTL_RPC_MSG_ERR;
@@ -1367,9 +1371,7 @@ __u32 lustre_msg_get_version(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_version;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1388,9 +1390,7 @@ void lustre_msg_add_version(struct lustre_msg *msg, int version)
         case LUSTRE_MSG_MAGIC_V1:
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_version |= version;
                 return;
@@ -1406,9 +1406,7 @@ __u32 lustre_msg_get_opc(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_opc;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1427,9 +1425,7 @@ __u64 lustre_msg_get_last_xid(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_last_xid;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1448,9 +1444,7 @@ __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_last_committed;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1463,15 +1457,36 @@ __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
         }
 }
 
+__u64 *lustre_msg_get_versions(struct lustre_msg *msg)
+{
+        switch (msg->lm_magic) {
+        case LUSTRE_MSG_MAGIC_V1:
+                return NULL;
+        case LUSTRE_MSG_MAGIC_V2: {
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+                if (!pb) {
+                        CERROR("invalid msg %p: no ptlrpc body!\n", msg);
+                        return 0;
+                }
+#ifdef PTLRPC_INTEROP_1_6
+                if (lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF) < sizeof (*pb))
+                        return NULL;
+#endif
+                return pb->pb_pre_versions;
+        }
+        default:
+                CERROR("incorrect message magic: %08x\n", msg->lm_magic);
+                return NULL;
+        }
+}
+
 __u64 lustre_msg_get_transno(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_transno;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1490,9 +1505,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_status;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return -EINVAL;
@@ -1513,9 +1526,7 @@ __u64 lustre_msg_get_slv(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return 1;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return -EINVAL;
@@ -1535,9 +1546,7 @@ void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
         case LUSTRE_MSG_MAGIC_V1:
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return;
@@ -1557,9 +1566,7 @@ __u32 lustre_msg_get_limit(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return 1;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return -EINVAL;
@@ -1579,9 +1586,7 @@ void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
         case LUSTRE_MSG_MAGIC_V1:
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return;
@@ -1601,9 +1606,7 @@ __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return ((struct lustre_msg_v1 *)msg)->lm_conn_cnt;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1647,9 +1650,7 @@ __u32 lustre_msg_get_timeout(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return 0;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1668,9 +1669,7 @@ __u32 lustre_msg_get_service_time(struct lustre_msg *msg)
         case LUSTRE_MSG_MAGIC_V1:
                 return 0;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 if (!pb) {
                         CERROR("invalid msg %p: no ptlrpc body!\n", msg);
                         return 0;
@@ -1696,16 +1695,23 @@ __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
         }
 }
 
+/*
+ * the sizeof ptlrpc_body in 1.6 is 88 bytes (64 bytes shorter than current
+ * size), to be able to interoperate with 1.6 we only calculate checksum
+ * aginst first 88 bytes of ptlrpc_body.
+ */
+static const int ptlrpc_body_size_16 = 88;
+
 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V1:
                 return 0;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
-                return crc32_le(~(__u32)0, (unsigned char *)pb, sizeof(*pb));
+                return crc32_le(~(__u32)0, (unsigned char *)pb,
+                                ptlrpc_body_size_16);
         }
         default:
                 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
@@ -1720,9 +1726,7 @@ void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle)
                 ((struct lustre_msg_v1 *)msg)->lm_handle = *handle;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_handle = *handle;
                 return;
@@ -1739,9 +1743,7 @@ void lustre_msg_set_type(struct lustre_msg *msg, __u32 type)
                 ((struct lustre_msg_v1 *)msg)->lm_type = type;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_type = type;
                 return;
@@ -1758,9 +1760,7 @@ void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc)
                 ((struct lustre_msg_v1 *)msg)->lm_opc = opc;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_opc = opc;
                 return;
@@ -1777,9 +1777,7 @@ void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid)
                 ((struct lustre_msg_v1 *)msg)->lm_last_xid = last_xid;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_last_xid = last_xid;
                 return;
@@ -1796,9 +1794,7 @@ void lustre_msg_set_last_committed(struct lustre_msg *msg, __u64 last_committed)
                 ((struct lustre_msg_v1 *)msg)->lm_last_committed=last_committed;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_last_committed = last_committed;
                 return;
@@ -1808,6 +1804,31 @@ void lustre_msg_set_last_committed(struct lustre_msg *msg, __u64 last_committed)
         }
 }
 
+void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions)
+{
+        switch (msg->lm_magic) {
+        case LUSTRE_MSG_MAGIC_V1:
+                return;
+        case LUSTRE_MSG_MAGIC_V2: {
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
+                LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
+#ifdef PTLRPC_INTEROP_1_6
+                /* do nothing for old clients */
+                if (lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF) < sizeof (*pb))
+                        return;
+#endif
+                pb->pb_pre_versions[0] = versions[0];
+                pb->pb_pre_versions[1] = versions[1];
+                pb->pb_pre_versions[2] = versions[2];
+                pb->pb_pre_versions[3] = versions[3];
+                return;
+        }
+        default:
+                LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
+        }
+}
+
+
 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno)
 {
         switch (msg->lm_magic) {
@@ -1815,9 +1836,7 @@ void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno)
                 ((struct lustre_msg_v1 *)msg)->lm_transno = transno;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_transno = transno;
                 return;
@@ -1834,9 +1853,7 @@ void lustre_msg_set_status(struct lustre_msg *msg, __u32 status)
                 ((struct lustre_msg_v1 *)msg)->lm_status = status;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_status = status;
                 return;
@@ -1853,9 +1870,7 @@ void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt)
                 ((struct lustre_msg_v1 *)msg)->lm_conn_cnt = conn_cnt;
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_conn_cnt = conn_cnt;
                 return;
@@ -1871,9 +1886,7 @@ void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
         case LUSTRE_MSG_MAGIC_V1:
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_timeout = timeout;
                 return;
@@ -1889,9 +1902,7 @@ void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time)
         case LUSTRE_MSG_MAGIC_V1:
                 return;
         case LUSTRE_MSG_MAGIC_V2: {
-                struct ptlrpc_body *pb;
-
-                pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF, sizeof(*pb));
+                struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
                 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
                 pb->pb_service_time = service_time;
                 return;
@@ -1918,7 +1929,7 @@ void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
 /* byte flipping routines for all wire types declared in
  * lustre_idl.h implemented here.
  */
-void lustre_swab_ptlrpc_body(struct ptlrpc_body *b)
+void lustre_swab_ptlrpc_body(struct ptlrpc_body *b, int msgsize)
 {
         __swab32s (&b->pb_type);
         __swab32s (&b->pb_version);
@@ -1935,6 +1946,13 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *b)
         __swab32s (&b->pb_service_time);
         __swab64s (&b->pb_slv);
         __swab32s (&b->pb_limit);
+        if (msgsize < offsetof(struct ptlrpc_body, pb_pre_versions[4]))
+                return;
+        __swab64s (&b->pb_pre_versions[0]);
+        __swab64s (&b->pb_pre_versions[1]);
+        __swab64s (&b->pb_pre_versions[2]);
+        __swab64s (&b->pb_pre_versions[3]);
+        CLASSERT(offsetof(typeof(*b), pb_padding) != 0);
 }
 
 void lustre_swab_connect(struct obd_connect_data *ocd)
@@ -2255,10 +2273,9 @@ void lustre_swab_lov_desc (struct lov_desc *ld)
 }
 
 
-void lustre_swab_lov_user_md(struct lov_user_md *lum)
+static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
 {
         ENTRY;
-        CDEBUG(D_IOCTL, "swabbing lov_user_md\n");
         __swab32s(&lum->lmm_magic);
         __swab32s(&lum->lmm_pattern);
         __swab64s(&lum->lmm_object_id);
@@ -2269,6 +2286,58 @@ void lustre_swab_lov_user_md(struct lov_user_md *lum)
         EXIT;
 }
 
+static void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum)
+{
+        ENTRY;
+        CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n");
+        lustre_swab_lov_user_md_common(lum);
+        EXIT;
+}
+
+static void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum)
+{
+        ENTRY;
+        CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n");
+        lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum);
+        /* lmm_pool_name nothing to do with char */
+        EXIT;
+}
+
+int lustre_swab_lov_user_md(struct lov_user_md_v1 *lum)
+{
+        ENTRY;
+        switch (lum->lmm_magic) {
+        case LOV_USER_MAGIC_V1:
+        case LOV_USER_MAGIC_V1_SWABBED:
+                lustre_swab_lov_user_md_v1(lum);
+                break;
+        case LOV_USER_MAGIC_V3:
+        case LOV_USER_MAGIC_V3_SWABBED:
+                lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lum);
+                break;
+        default:
+                CDEBUG(D_IOCTL, "bad userland LOV MAGIC:"
+                                " %#08x != %#08x nor %#08x\n",
+                                lum->lmm_magic, LOV_USER_MAGIC_V1,
+                                LOV_USER_MAGIC_V3);
+                RETURN(-EINVAL);
+        }
+        RETURN(0);
+}
+
+void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
+{
+        ENTRY;
+        CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
+        __swab32s(&lmm->lmm_magic);
+        __swab32s(&lmm->lmm_pattern);
+        __swab64s(&lmm->lmm_object_id);
+        __swab64s(&lmm->lmm_object_gr);
+        __swab32s(&lmm->lmm_stripe_size);
+        __swab32s(&lmm->lmm_stripe_count);
+        EXIT;
+}
+
 void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj)
 {
         ENTRY;
@@ -2283,19 +2352,37 @@ void lustre_swab_lov_user_md_join(struct lov_user_md_join *lumj)
         EXIT;
 }
 
-void lustre_swab_lov_user_md_objects(struct lov_user_md *lum)
+int lustre_swab_lov_user_md_objects(struct lov_user_md *lum)
 {
-        struct lov_user_ost_data *lod;
         int i;
+        __u16 stripe_count = lum->lmm_stripe_count;
+        struct lov_user_ost_data *lod;
         ENTRY;
-        for (i = 0; i < lum->lmm_stripe_count; i++) {
-                lod = &lum->lmm_objects[i];
-                __swab64s(&lod->l_object_id);
-                __swab64s(&lod->l_object_gr);
-                __swab32s(&lod->l_ost_gen);
-                __swab32s(&lod->l_ost_idx);
+        switch (lum->lmm_magic) {
+        case LOV_USER_MAGIC_V1_SWABBED:
+                __swab16s(&stripe_count);
+        case LOV_USER_MAGIC_V1:
+                lod = lum->lmm_objects;
+                break;
+        case LOV_USER_MAGIC_V3_SWABBED:
+                __swab16s(&stripe_count);
+        case LOV_USER_MAGIC_V3:
+                lod = ((struct lov_user_md_v3 *)lum)->lmm_objects;
+                break;
+        default:
+                CDEBUG(D_IOCTL, "bad userland LOV MAGIC:"
+                                " %#08x != %#08x nor %#08x\n",
+                                lum->lmm_magic, LOV_USER_MAGIC_V1,
+                                LOV_USER_MAGIC_V3);
+                RETURN(-EINVAL);
         }
-        EXIT;
+        for (i = 0; i < stripe_count; i++) {
+                __swab64s(&(lod[i].l_object_id));
+                __swab64s(&(lod[i].l_object_gr));
+                __swab32s(&(lod[i].l_ost_gen));
+                __swab32s(&(lod[i].l_ost_idx));
+        }
+        RETURN(0);
 }
 
 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
@@ -2373,18 +2460,6 @@ void lustre_swab_qdata(struct qunit_data *d)
         __swab64s (&d->qd_qunit);
 }
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-void lustre_swab_qdata_old(struct qunit_data_old *d)
-{
-        __swab32s (&d->qd_id);
-        __swab32s (&d->qd_type);
-        __swab32s (&d->qd_count);
-        __swab32s (&d->qd_isblk);
-}
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
-
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
 void lustre_swab_qdata_old2(struct qunit_data_old2 *d)
 {
@@ -2398,42 +2473,6 @@ void lustre_swab_qdata_old2(struct qunit_data_old2 *d)
 
 #ifdef __KERNEL__
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-void qdata_v1_v3(struct qunit_data_old *d,
-                             struct qunit_data *qdata)
-{
-        LASSERT(d);
-        LASSERT(qdata);
-
-        qdata->qd_id = d->qd_id;
-        if (d->qd_type)
-                QDATA_SET_GRP(qdata);
-        if (d->qd_isblk)
-                QDATA_SET_BLK(qdata);
-        qdata->qd_count = d->qd_count;
-}
-
-struct qunit_data_old *qdata_v3_to_v1(struct qunit_data *d)
-{
-        struct qunit_data tmp;
-        struct qunit_data_old *ret;
-        ENTRY;
-
-        if (!d)
-                return NULL;
-
-        tmp = *d;
-        ret = (struct qunit_data_old *)d;
-        ret->qd_id = tmp.qd_id;
-        ret->qd_type = (QDATA_IS_GRP(&tmp) ? GRPQUOTA : USRQUOTA);
-        ret->qd_count = (__u32)tmp.qd_count;
-        ret->qd_isblk = (QDATA_IS_BLK(&tmp) ? 1 : 0);
-        RETURN(ret);
-}
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
-
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
 void qdata_v2_to_v3(struct qunit_data_old2 *d,
                               struct qunit_data *qdata)
@@ -2472,9 +2511,7 @@ int quota_get_qdata(void *request, struct qunit_data *qdata,
 {
         struct ptlrpc_request *req = (struct ptlrpc_request *)request;
         struct qunit_data *new;
-        struct qunit_data_old *old;
         struct qunit_data_old2 *old2;
-        int size  = sizeof(struct qunit_data_old);
         int size2 = sizeof(struct qunit_data_old2);
         __u64  flags = is_exp ? req->rq_export->exp_connect_flags :
                        req->rq_import->imp_connect_data.ocd_connect_flags;
@@ -2483,13 +2520,6 @@ int quota_get_qdata(void *request, struct qunit_data *qdata,
         LASSERT(req);
         LASSERT(qdata);
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-        if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_QD_COUNT_32BIT))
-                goto quota32;
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
-
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
         if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS))
                 goto without_change_qs;
@@ -2540,22 +2570,6 @@ without_change_qs:
 #else
 #warning "remove quota code above for format absolete in new release"
 #endif
-
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-quota32:
-        /* not support for quota64 and change_qs */
-        if (is_req == QUOTA_REQUEST)
-                old = lustre_swab_reqbuf(req, REQ_REC_OFF, size,
-                                         lustre_swab_qdata_old);
-        else
-                old = lustre_swab_repbuf(req, REPLY_REC_OFF, size,
-                                         lustre_swab_qdata_old);
-        if (old == NULL)
-                GOTO(out, rc = -EPROTO);
-        qdata_v1_v3(old, qdata);
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
 out:
         return rc;
 }
@@ -2567,7 +2581,6 @@ int quota_copy_qdata(void *request, struct qunit_data *qdata,
 {
         struct ptlrpc_request *req = (struct ptlrpc_request *)request;
         void *target;
-        struct qunit_data_old *old;
         struct qunit_data_old2 *old2;
         __u64  flags = is_exp ? req->rq_export->exp_connect_flags :
                 req->rq_import->imp_connect_data.ocd_connect_flags;
@@ -2576,13 +2589,6 @@ int quota_copy_qdata(void *request, struct qunit_data *qdata,
         LASSERT(req);
         LASSERT(qdata);
 
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-        if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_QD_COUNT_32BIT))
-                goto quota32;
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
-
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
         if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS))
                 goto without_change_qs;
@@ -2627,23 +2633,6 @@ without_change_qs:
 #else
 #warning "remove quota code above for format absolete in new release"
 #endif
-
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-quota32:
-        /* not support for quota64 and change_qs */
-        if (is_req == QUOTA_REQUEST)
-                target = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF,
-                                        sizeof(struct qunit_data_old));
-        else
-                target = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
-                                        sizeof(struct qunit_data_old));
-        if (!target)
-                GOTO(out, rc = -EPROTO);
-        old = qdata_v3_to_v1(qdata);
-        memcpy(target, old, sizeof(*old));
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
 out:
         return rc;
 }
@@ -2653,15 +2642,10 @@ int quota_get_qunit_data_size(__u64 flag)
 {
         int size;
 
-        if (flag & OBD_CONNECT_CHANGE_QS) {
+        if (flag & OBD_CONNECT_CHANGE_QS)
                 size = sizeof(struct qunit_data);
-        } else {
-                /* write in this way because sizes of qunit_data_old and
-                 * qunit_data_old2 are same */
-                LASSERT(sizeof(struct qunit_data_old) ==
-                        sizeof(struct qunit_data_old2));
-                size = sizeof(struct qunit_data_old);
-        }
+        else
+                size = sizeof(struct qunit_data_old2);
 
         return(size);
 }
@@ -2732,7 +2716,7 @@ void _debug_req(struct ptlrpc_request *req, __u32 mask,
         va_start(args, fmt);
         libcfs_debug_vmsg2(data->msg_cdls, data->msg_subsys, mask,
                 data->msg_file, data->msg_fn, data->msg_line, fmt, args,
-                " req@%p x"LPD64"/t"LPD64" o%d->%s@%s:%d/%d lens %d/%d e %d "
+                " req@%p x"LPU64"/t"LPD64" o%d->%s@%s:%d/%d lens %d/%d e %d "
                 "to %d dl %ld ref %d fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n",
                 req, req->rq_xid, req->rq_transno, opc,
                 req->rq_import ? obd2cli_tgt(req->rq_import->imp_obd) :
diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c
index 95feaf0..8d51078 100644
--- a/lustre/ptlrpc/pinger.c
+++ b/lustre/ptlrpc/pinger.c
@@ -50,6 +50,41 @@
 
 struct semaphore pinger_sem;
 static struct list_head pinger_imports = CFS_LIST_HEAD_INIT(pinger_imports);
+static struct list_head timeout_list = CFS_LIST_HEAD_INIT(timeout_list); 
+
+struct ptlrpc_request *
+ptlrpc_prep_ping(struct obd_import *imp)
+{
+        struct ptlrpc_request *req;
+
+        req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION,
+                              OBD_PING, 1, NULL, NULL);
+        if (req) {
+                ptlrpc_req_set_repsize(req, 1, NULL);
+                req->rq_no_resend = req->rq_no_delay = 1;
+        }
+        return req;
+}
+
+int ptlrpc_obd_ping(struct obd_device *obd)
+{
+        int rc;
+        struct ptlrpc_request *req;
+        ENTRY;
+
+        req = ptlrpc_prep_ping(obd->u.cli.cl_import);
+        if (req == NULL)
+                RETURN(-ENOMEM);
+
+        req->rq_send_state = LUSTRE_IMP_FULL;
+
+        rc = ptlrpc_queue_wait(req);
+
+        ptlrpc_req_finished(req);
+
+        RETURN(rc);
+}
+EXPORT_SYMBOL(ptlrpc_obd_ping);
 
 int ptlrpc_ping(struct obd_import *imp)
 {
@@ -57,14 +92,11 @@ int ptlrpc_ping(struct obd_import *imp)
         int rc = 0;
         ENTRY;
 
-        req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, OBD_PING, 
-                              1, NULL, NULL);
+        req = ptlrpc_prep_ping(imp);
         if (req) {
                 DEBUG_REQ(D_INFO, req, "pinging %s->%s",
                           imp->imp_obd->obd_uuid.uuid,
                           obd2cli_tgt(imp->imp_obd));
-                req->rq_no_resend = req->rq_no_delay = 1;
-                ptlrpc_req_set_repsize(req, 1, NULL);
                 ptlrpcd_add_req(req);
         } else {
                 CERROR("OOM trying to ping %s->%s\n",
@@ -75,11 +107,12 @@ int ptlrpc_ping(struct obd_import *imp)
 
         RETURN(rc);
 }
+EXPORT_SYMBOL(ptlrpc_ping);
 
-void ptlrpc_update_next_ping(struct obd_import *imp)
+void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
 {
 #ifdef ENABLE_PINGER
-        int time = PING_INTERVAL;
+        int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL;
         if (imp->imp_state == LUSTRE_IMP_DISCON) {
                 int dtime = max_t(int, CONNECTION_SWITCH_MIN,
                                   AT_OFF ? 0 :
@@ -95,6 +128,31 @@ void ptlrpc_ping_import_soon(struct obd_import *imp)
         imp->imp_next_ping = cfs_time_current();
 }
 
+static inline int imp_is_deactive(struct obd_import *imp)
+{
+        return (imp->imp_deactive ||
+                OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_IMP_DEACTIVE));
+}
+
+cfs_duration_t pinger_check_timeout(cfs_time_t time)
+{
+        struct timeout_item *item;
+        cfs_time_t timeout = PING_INTERVAL;
+
+	/* The timeout list is a increase order sorted list */
+        mutex_down(&pinger_sem);
+        list_for_each_entry(item, &timeout_list, ti_chain) {
+		int ti_timeout = item->ti_timeout;
+		if (timeout > ti_timeout)
+			 timeout = ti_timeout;
+        	break;
+	}
+        mutex_up(&pinger_sem);
+        
+	return cfs_time_sub(cfs_time_add(time, cfs_time_seconds(timeout)),
+                                         cfs_time_current());
+}
+
 #ifdef __KERNEL__
 static int ptlrpc_pinger_main(void *arg)
 {
@@ -112,10 +170,14 @@ static int ptlrpc_pinger_main(void *arg)
         while (1) {
                 cfs_time_t this_ping = cfs_time_current();
                 struct l_wait_info lwi;
-                cfs_duration_t time_to_next_ping;
+                cfs_duration_t time_to_next_wake;
+                struct timeout_item *item;
                 struct list_head *iter;
 
                 mutex_down(&pinger_sem);
+                list_for_each_entry(item, &timeout_list, ti_chain) {
+                        item->ti_cb(item, item->ti_cb_data);
+                }
                 list_for_each(iter, &pinger_imports) {
                         struct obd_import *imp =
                                 list_entry(iter, struct obd_import,
@@ -139,14 +201,14 @@ static int ptlrpc_pinger_main(void *arg)
                             cfs_time_aftereq(this_ping, 
                                              imp->imp_next_ping - 5 * CFS_TICK)) {
                                 if (level == LUSTRE_IMP_DISCON &&
-                                    !imp->imp_deactive) {
+                                    !imp_is_deactive(imp)) {
                                         /* wait at least a timeout before
                                            trying recovery again. */
                                         imp->imp_next_ping = cfs_time_shift(obd_timeout);
                                         ptlrpc_initiate_recovery(imp);
                                 } else if (level != LUSTRE_IMP_FULL ||
                                          imp->imp_obd->obd_no_recov ||
-                                         imp->imp_deactive) {
+                                         imp_is_deactive(imp)) {
                                         CDEBUG(D_HA, "not pinging %s "
                                                "(in recovery: %s or recovery "
                                                "disabled: %u/%u)\n",
@@ -155,7 +217,7 @@ static int ptlrpc_pinger_main(void *arg)
                                                imp->imp_deactive,
                                                imp->imp_obd->obd_no_recov);
                                 } else if (imp->imp_pingable || force) {
-                                        ptlrpc_ping(imp);
+                                                ptlrpc_ping(imp);
                                 }
                         } else {
                                 if (!imp->imp_pingable)
@@ -171,28 +233,25 @@ static int ptlrpc_pinger_main(void *arg)
                         if (cfs_time_after(imp->imp_next_ping,
                                            cfs_time_add(this_ping, 
                                                         cfs_time_seconds(PING_INTERVAL))))
-                                ptlrpc_update_next_ping(imp);
+                                ptlrpc_update_next_ping(imp, 0);
                 }
                 mutex_up(&pinger_sem);
                 /* update memory usage info */
                 obd_update_maxusage();
 
                 /* Wait until the next ping time, or until we're stopped. */
-                time_to_next_ping = cfs_time_sub(cfs_time_add(this_ping, 
-                                                              cfs_time_seconds(PING_INTERVAL)), 
-                                                 cfs_time_current());
-
+                time_to_next_wake = pinger_check_timeout(this_ping);
                 /* The ping sent by ptlrpc_send_rpc may get sent out
                    say .01 second after this.
                    ptlrpc_pinger_eending_on_import will then set the
                    next ping time to next_ping + .01 sec, which means
                    we will SKIP the next ping at next_ping, and the
                    ping will get sent 2 timeouts from now!  Beware. */
-                CDEBUG(D_INFO, "next ping in "CFS_DURATION_T" ("CFS_TIME_T")\n", 
-                               time_to_next_ping, 
+                CDEBUG(D_INFO, "next wakeup in "CFS_DURATION_T" ("CFS_TIME_T")\n",
+                               time_to_next_wake,
                                cfs_time_add(this_ping, cfs_time_seconds(PING_INTERVAL)));
-                if (time_to_next_ping > 0) {
-                        lwi = LWI_TIMEOUT(max_t(cfs_duration_t, time_to_next_ping, cfs_time_seconds(1)),
+                if (time_to_next_wake > 0) {
+                        lwi = LWI_TIMEOUT(max_t(cfs_duration_t, time_to_next_wake, cfs_time_seconds(1)),
                                           NULL, NULL);
                         l_wait_event(thread->t_ctl_waitq,
                                      thread->t_flags & (SVC_STOPPING|SVC_EVENT),
@@ -253,6 +312,8 @@ int ptlrpc_start_pinger(void)
         RETURN(0);
 }
 
+int ptlrpc_pinger_remove_timeouts(void);
+
 int ptlrpc_stop_pinger(void)
 {
         struct l_wait_info lwi = { 0 };
@@ -264,6 +325,8 @@ int ptlrpc_stop_pinger(void)
 
         if (pinger_thread == NULL)
                 RETURN(-EALREADY);
+
+        ptlrpc_pinger_remove_timeouts();
         mutex_down(&pinger_sem);
         pinger_thread->t_flags = SVC_STOPPING;
         cfs_waitq_signal(&pinger_thread->t_ctl_waitq);
@@ -279,7 +342,12 @@ int ptlrpc_stop_pinger(void)
 
 void ptlrpc_pinger_sending_on_import(struct obd_import *imp)
 {
-        ptlrpc_update_next_ping(imp);
+        ptlrpc_update_next_ping(imp, 0);
+}
+
+void ptlrpc_pinger_commit_expected(struct obd_import *imp)
+{
+        ptlrpc_update_next_ping(imp, 1);
 }
 
 int ptlrpc_pinger_add_import(struct obd_import *imp)
@@ -294,7 +362,7 @@ int ptlrpc_pinger_add_import(struct obd_import *imp)
         /* if we add to pinger we want recovery on this import */
         imp->imp_obd->obd_no_recov = 0;
 
-        ptlrpc_update_next_ping(imp);
+        ptlrpc_update_next_ping(imp, 0);
         /* XXX sort, blah blah */
         list_add_tail(&imp->imp_pinger_chain, &pinger_imports);
         class_import_get(imp);
@@ -322,6 +390,121 @@ int ptlrpc_pinger_del_import(struct obd_import *imp)
         RETURN(0);
 }
 
+/**
+ * Register a timeout callback to the pinger list, and the callback will
+ * be called when timeout happens.
+ */
+struct timeout_item* ptlrpc_new_timeout(int time, enum timeout_event event,
+                                        timeout_cb_t cb, void *data)
+{
+        struct timeout_item *ti;
+        
+        OBD_ALLOC_PTR(ti);
+        if (!ti)
+                return(NULL);
+
+        CFS_INIT_LIST_HEAD(&ti->ti_obd_list);
+        CFS_INIT_LIST_HEAD(&ti->ti_chain);
+        ti->ti_timeout = time;
+        ti->ti_event = event;
+        ti->ti_cb = cb;
+        ti->ti_cb_data = data;
+        
+        return ti;
+}
+
+/**
+ * Register timeout event on the the pinger thread.
+ * Note: the timeout list is an sorted list with increased timeout value.
+ */
+static struct timeout_item*
+ptlrpc_pinger_register_timeout(int time, enum timeout_event event,
+                               timeout_cb_t cb, void *data)
+{
+        struct timeout_item *item, *tmp;
+
+        LASSERT_SEM_LOCKED(&pinger_sem);
+
+        list_for_each_entry(item, &timeout_list, ti_chain)
+                if (item->ti_event == event)
+                        goto out;
+
+        item = ptlrpc_new_timeout(time, event, cb, data);
+        if (item) {
+                list_for_each_entry_reverse(tmp, &timeout_list, ti_chain) {
+                        if (tmp->ti_timeout < time) {
+                                list_add(&item->ti_chain, &tmp->ti_chain);
+                                goto out;
+                        }
+                }
+                list_add(&item->ti_chain, &timeout_list);
+        }
+out:
+        return item;
+}
+
+/* Add a client_obd to the timeout event list, when timeout(@time) 
+ * happens, the callback(@cb) will be called.
+ */
+int ptlrpc_add_timeout_client(int time, enum timeout_event event,
+                              timeout_cb_t cb, void *data,
+                              struct list_head *obd_list)
+{
+        struct timeout_item *ti;
+
+        mutex_down(&pinger_sem);
+        ti = ptlrpc_pinger_register_timeout(time, event, cb, data);
+        if (!ti) {
+                mutex_up(&pinger_sem);
+                return (-EINVAL);
+        }
+        list_add(obd_list, &ti->ti_obd_list);
+        mutex_up(&pinger_sem);
+        return 0;
+}           
+
+int ptlrpc_del_timeout_client(struct list_head *obd_list, 
+                              enum timeout_event event)
+{
+        struct timeout_item *ti = NULL, *item;
+
+        if (list_empty(obd_list))
+                return 0;  
+        mutex_down(&pinger_sem);
+        list_del_init(obd_list);
+        /**
+         * If there are no obd attached to the timeout event
+         * list, remove this timeout event from the pinger
+         */
+        list_for_each_entry(item, &timeout_list, ti_chain) {
+                if (item->ti_event == event) {
+                        ti = item;
+                        break;
+                }
+        }
+        LASSERTF(ti != NULL, "ti is NULL ! \n");
+        if (list_empty(&ti->ti_obd_list)) {
+                list_del(&ti->ti_chain);
+                OBD_FREE_PTR(ti);
+        }
+        mutex_up(&pinger_sem);
+        return 0;
+}  
+
+int ptlrpc_pinger_remove_timeouts(void)
+{
+        struct timeout_item *item, *tmp;
+
+        mutex_down(&pinger_sem);
+        list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) {
+                LASSERT(list_empty(&item->ti_obd_list));
+                list_del(&item->ti_chain);
+                OBD_FREE_PTR(item);
+        }
+        mutex_up(&pinger_sem);
+        return 0;
+}
+
 void ptlrpc_pinger_wake_up()
 {
 #ifdef ENABLE_PINGER
@@ -647,7 +830,7 @@ void ptlrpc_pinger_sending_on_import(struct obd_import *imp)
 {
 #ifdef ENABLE_PINGER
         mutex_down(&pinger_sem);
-        ptlrpc_update_next_ping(imp);
+        ptlrpc_update_next_ping(imp, 0);
         if (pinger_args.pd_set == NULL &&
             time_before(imp->imp_next_ping, pinger_args.pd_next_ping)) {
                 CDEBUG(D_HA, "set next ping to "CFS_TIME_T"(cur "CFS_TIME_T")\n",
@@ -658,6 +841,19 @@ void ptlrpc_pinger_sending_on_import(struct obd_import *imp)
 #endif
 }
 
+int ptlrpc_add_timeout_client(int time, enum timeout_event event,
+                              timeout_cb_t cb, void *data,
+                              struct list_head *obd_list)
+{
+        return 0;
+}           
+
+int ptlrpc_del_timeout_client(struct list_head *obd_list,
+                              enum timeout_event event)
+{
+        return 0;
+}  
+
 int ptlrpc_pinger_add_import(struct obd_import *imp)
 {
         ENTRY;
@@ -701,11 +897,13 @@ void ptlrpc_pinger_wake_up()
                 CDEBUG(D_RPCTRACE, "checking import %s->%s\n",
                        imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd));
 #ifdef ENABLE_LIBLUSTRE_RECOVERY
-                if (imp->imp_state == LUSTRE_IMP_DISCON && !imp->imp_deactive)
+                if (imp->imp_state == LUSTRE_IMP_DISCON &&
+                    !imp_is_deactive(imp))
 #else
                 /*XXX only recover for the initial connection */
                 if (!lustre_handle_is_used(&imp->imp_remote_handle) &&
-                    imp->imp_state == LUSTRE_IMP_DISCON && !imp->imp_deactive)
+                    imp->imp_state == LUSTRE_IMP_DISCON &&
+                    !imp_is_deactive(imp))
 #endif
                         ptlrpc_initiate_recovery(imp);
                 else if (imp->imp_state != LUSTRE_IMP_FULL)
@@ -713,7 +911,7 @@ void ptlrpc_pinger_wake_up()
                                      "state %d, deactive %d\n",
                                      imp->imp_obd->obd_uuid.uuid,
                                      obd2cli_tgt(imp->imp_obd), imp->imp_state,
-                                     imp->imp_deactive);
+                                     imp_is_deactive(imp));
         }
 #endif
         EXIT;
diff --git a/lustre/ptlrpc/ptlrpc_internal.h b/lustre/ptlrpc/ptlrpc_internal.h
index c491094..98ba674 100644
--- a/lustre/ptlrpc/ptlrpc_internal.h
+++ b/lustre/ptlrpc/ptlrpc_internal.h
@@ -48,6 +48,13 @@ struct ptlrpc_request_set;
 extern int test_req_buffer_pressure;
 extern cfs_mem_cache_t *ptlrpc_cbdata_slab;
 
+/* client.c */
+void ptlrpc_init_xid(void);
+
+/* events.c */
+int ptlrpc_init_portals(void);
+void ptlrpc_exit_portals(void);
+
 void ptlrpc_request_handle_notconn(struct ptlrpc_request *);
 void lustre_assert_wire_constants(void);
 int ptlrpc_import_in_recovery(struct obd_import *imp);
@@ -65,7 +72,7 @@ int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset);
 void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
                                      struct ptlrpc_service *svc);
 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
-void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req);
+void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount);
 void ptlrpc_lprocfs_do_request_stat (struct ptlrpc_request *req,
                                      long q_usec, long work_usec);
 #else
@@ -88,6 +95,7 @@ void ptl_rpc_wipe_bulk_pages(struct ptlrpc_bulk_desc *desc);
 int ptlrpc_start_pinger(void);
 int ptlrpc_stop_pinger(void);
 void ptlrpc_pinger_sending_on_import(struct obd_import *imp);
+void ptlrpc_pinger_commit_expected(struct obd_import *imp);
 void ptlrpc_pinger_wake_up(void);
 void ptlrpc_ping_import_soon(struct obd_import *imp);
 #ifdef __KERNEL__
diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c
index 0989c6c..0efa98d 100644
--- a/lustre/ptlrpc/ptlrpc_module.c
+++ b/lustre/ptlrpc/ptlrpc_module.c
@@ -48,14 +48,13 @@
 #include <lustre_net.h>
 
 #include "ptlrpc_internal.h"
+
 cfs_mem_cache_t *ptlrpc_cbdata_slab;
 extern spinlock_t ptlrpc_last_xid_lock;
 extern spinlock_t ptlrpc_rs_debug_lock;
 extern spinlock_t ptlrpc_all_services_lock;
 extern struct semaphore pinger_sem;
 extern struct semaphore ptlrpcd_sem;
-extern int ptlrpc_init_portals(void);
-extern void ptlrpc_exit_portals(void);
 
 __init int ptlrpc_init(void)
 {
@@ -63,11 +62,11 @@ __init int ptlrpc_init(void)
         ENTRY;
 
         lustre_assert_wire_constants();
-        spin_lock_init(&ptlrpc_last_xid_lock);
         spin_lock_init(&ptlrpc_rs_debug_lock);
         spin_lock_init(&ptlrpc_all_services_lock);
         init_mutex(&pinger_sem);
         init_mutex(&ptlrpcd_sem);
+        ptlrpc_init_xid();
 
         rc = ptlrpc_init_portals();
         if (rc)
@@ -174,6 +173,7 @@ EXPORT_SYMBOL(ptlrpc_prep_bulk_exp);
 EXPORT_SYMBOL(ptlrpc_free_bulk);
 EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
 EXPORT_SYMBOL(ptlrpc_abort_inflight);
+EXPORT_SYMBOL(ptlrpc_cleanup_imp);
 EXPORT_SYMBOL(ptlrpc_retain_replayable_request);
 EXPORT_SYMBOL(ptlrpc_next_xid);
 
@@ -236,6 +236,7 @@ EXPORT_SYMBOL(lustre_swab_lov_desc);
 EXPORT_SYMBOL(lustre_swab_lov_user_md);
 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
 EXPORT_SYMBOL(lustre_swab_lov_user_md_join);
+EXPORT_SYMBOL(lustre_swab_lov_mds_md);
 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
@@ -244,11 +245,6 @@ EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
 EXPORT_SYMBOL(lustre_swab_ldlm_request);
 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
 EXPORT_SYMBOL(lustre_swab_qdata);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-EXPORT_SYMBOL(lustre_swab_qdata_old);
-#else
-#warning "remove quota code above for format absolete in new release"
-#endif
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 9, 0, 0)
 EXPORT_SYMBOL(lustre_swab_qdata_old2);
 #else
@@ -269,6 +265,7 @@ EXPORT_SYMBOL(lustre_msg_add_version);
 EXPORT_SYMBOL(lustre_msg_get_opc);
 EXPORT_SYMBOL(lustre_msg_get_last_xid);
 EXPORT_SYMBOL(lustre_msg_get_last_committed);
+EXPORT_SYMBOL(lustre_msg_get_versions);
 EXPORT_SYMBOL(lustre_msg_get_transno);
 EXPORT_SYMBOL(lustre_msg_get_status);
 EXPORT_SYMBOL(lustre_msg_get_slv);
@@ -283,6 +280,7 @@ EXPORT_SYMBOL(lustre_msg_set_type);
 EXPORT_SYMBOL(lustre_msg_set_opc);
 EXPORT_SYMBOL(lustre_msg_set_last_xid);
 EXPORT_SYMBOL(lustre_msg_set_last_committed);
+EXPORT_SYMBOL(lustre_msg_set_versions);
 EXPORT_SYMBOL(lustre_msg_set_transno);
 EXPORT_SYMBOL(lustre_msg_set_status);
 EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
@@ -304,6 +302,8 @@ EXPORT_SYMBOL(ptlrpc_import_setasync);
 /* pinger.c */
 EXPORT_SYMBOL(ptlrpc_pinger_add_import);
 EXPORT_SYMBOL(ptlrpc_pinger_del_import);
+EXPORT_SYMBOL(ptlrpc_add_timeout_client);
+EXPORT_SYMBOL(ptlrpc_del_timeout_client);
 EXPORT_SYMBOL(ptlrpc_pinger_sending_on_import);
 
 /* ptlrpcd.c */
diff --git a/lustre/ptlrpc/ptlrpcd.c b/lustre/ptlrpc/ptlrpcd.c
index ff316c5..c5bb52e 100644
--- a/lustre/ptlrpc/ptlrpcd.c
+++ b/lustre/ptlrpc/ptlrpcd.c
@@ -69,7 +69,29 @@ void ptlrpcd_wake(struct ptlrpc_request *req)
         cfs_waitq_signal(&rq_set->set_waitq);
 }
 
-/* 
+/*
+ * Move all request from an existing request set to the ptlrpcd queue.
+ * All requests from the set must be in phase RQ_PHASE_NEW.
+ */
+void ptlrpcd_add_rqset(struct ptlrpc_request_set *set)
+{
+        struct list_head *tmp, *pos;
+
+        list_for_each_safe(pos, tmp, &set->set_requests) {
+                struct ptlrpc_request *req =
+                        list_entry(pos, struct ptlrpc_request, rq_set_chain);
+
+                LASSERT(req->rq_phase == RQ_PHASE_NEW);
+                list_del_init(&req->rq_set_chain);
+                req->rq_set = NULL;
+                ptlrpcd_add_req(req);
+                set->set_remaining--;
+        }
+        LASSERT(set->set_remaining == 0);
+}
+EXPORT_SYMBOL(ptlrpcd_add_rqset);
+
+/*
  * Requests that are added to the ptlrpcd queue are sent via
  * ptlrpcd_check->ptlrpc_check_set().
  */
@@ -82,12 +104,11 @@ void ptlrpcd_add_req(struct ptlrpc_request *req)
                 pc = &ptlrpcd_pc;
         else
                 pc = &ptlrpcd_recovery_pc;
-
         rc = ptlrpc_set_add_new_req(pc, req);
         if (rc) {
                 int (*interpreter)(struct ptlrpc_request *,
                                    void *, int);
-                                   
+
                 interpreter = req->rq_interpret_reply;
 
                 /*
@@ -96,7 +117,7 @@ void ptlrpcd_add_req(struct ptlrpc_request *req)
                  * interpret for it to let know we're killing it
                  * so that higher levels might free assosiated
                  * resources.
-                 */
+                */
                 req->rq_status = -EBADR;
                 interpreter(req, &req->rq_async_args,
                             req->rq_status);
@@ -117,8 +138,8 @@ static int ptlrpcd_check(struct ptlrpcd_ctl *pc)
                 req = list_entry(pos, struct ptlrpc_request, rq_set_chain);
                 list_del_init(&req->rq_set_chain);
                 ptlrpc_set_add_req(pc->pc_set, req);
-                /* 
-                 * Need to calculate its timeout. 
+                /*
+                 * Need to calculate its timeout.
                  */
                 rc = 1;
         }
@@ -127,9 +148,9 @@ static int ptlrpcd_check(struct ptlrpcd_ctl *pc)
         if (pc->pc_set->set_remaining) {
                 rc = rc | ptlrpc_check_set(pc->pc_set);
 
-                /* 
+                /*
                  * XXX: our set never completes, so we prune the completed
-                 * reqs after each iteration. boy could this be smarter. 
+                 * reqs after each iteration. boy could this be smarter.
                  */
                 list_for_each_safe(pos, tmp, &pc->pc_set->set_requests) {
                         req = list_entry(pos, struct ptlrpc_request,
@@ -144,8 +165,8 @@ static int ptlrpcd_check(struct ptlrpcd_ctl *pc)
         }
 
         if (rc == 0) {
-                /* 
-                 * If new requests have been added, make sure to wake up. 
+                /*
+                 * If new requests have been added, make sure to wake up.
                  */
                 spin_lock(&pc->pc_set->set_new_req_lock);
                 rc = !list_empty(&pc->pc_set->set_new_requests);
@@ -156,7 +177,7 @@ static int ptlrpcd_check(struct ptlrpcd_ctl *pc)
 }
 
 #ifdef __KERNEL__
-/* 
+/*
  * ptlrpc's code paths like to execute in process context, so we have this
  * thread which spins on a set which contains the io rpcs. llite specifies
  * ptlrpcd's set when it pushes pages down into the oscs.
@@ -174,18 +195,18 @@ static int ptlrpcd(void *arg)
 
         complete(&pc->pc_starting);
 
-        /* 
+        /*
          * This mainloop strongly resembles ptlrpc_set_wait() except that our
          * set never completes.  ptlrpcd_check() calls ptlrpc_check_set() when
-         * there are requests in the set. New requests come in on the set's 
-         * new_req_list and ptlrpcd_check() moves them into the set. 
+         * there are requests in the set. New requests come in on the set's
+         * new_req_list and ptlrpcd_check() moves them into the set.
          */
         do {
                 struct l_wait_info lwi;
                 int timeout;
 
                 timeout = ptlrpc_set_next_timeout(pc->pc_set);
-                lwi = LWI_TIMEOUT(cfs_time_seconds(timeout ? timeout : 1), 
+                lwi = LWI_TIMEOUT(cfs_time_seconds(timeout ? timeout : 1),
                                   ptlrpc_expired_set, pc->pc_set);
 
                 l_wait_event(pc->pc_set->set_waitq, ptlrpcd_check(pc), &lwi);
@@ -199,14 +220,14 @@ static int ptlrpcd(void *arg)
                         exit++;
                 }
 
-                /* 
+                /*
                  * Let's make one more loop to make sure that ptlrpcd_check()
                  * copied all raced new rpcs into the set so we can kill them.
                  */
         } while (exit < 2);
 
-        /* 
-         * Wait for inflight requests to drain. 
+        /*
+         * Wait for inflight requests to drain.
          */
         if (!list_empty(&pc->pc_set->set_requests))
                 ptlrpc_set_wait(pc->pc_set);
@@ -226,8 +247,8 @@ int ptlrpcd_check_async_rpcs(void *arg)
         struct ptlrpcd_ctl *pc = arg;
         int                  rc = 0;
 
-        /* 
-         * Single threaded!! 
+        /*
+         * Single threaded!!
          */
         pc->pc_recurred++;
 
@@ -235,8 +256,8 @@ int ptlrpcd_check_async_rpcs(void *arg)
                 rc = ptlrpcd_check(pc);
                 if (!rc)
                         ptlrpc_expired_set(pc->pc_set);
-                /* 
-                 * XXX: send replay requests. 
+                /*
+                 * XXX: send replay requests.
                  */
                 if (pc == &ptlrpcd_recovery_pc)
                         rc = ptlrpcd_check(pc);
@@ -260,9 +281,9 @@ int ptlrpcd_start(char *name, struct ptlrpcd_ctl *pc)
 {
         int rc = 0;
         ENTRY;
- 
-        /* 
-         * Do not allow start second thread for one pc. 
+
+        /*
+         * Do not allow start second thread for one pc.
          */
         if (test_bit(LIOD_START, &pc->pc_flags)) {
                 CERROR("Starting second thread (%s) for same pc %p\n",
diff --git a/lustre/ptlrpc/recov_thread.c b/lustre/ptlrpc/recov_thread.c
index 5c12b63..96ee8e9 100644
--- a/lustre/ptlrpc/recov_thread.c
+++ b/lustre/ptlrpc/recov_thread.c
@@ -76,8 +76,8 @@ enum {
         LLOG_LCM_FL_EXIT        = 1 << 1
 };
 
-static void llcd_print(struct llog_canceld_ctxt *llcd, 
-                       const char *func, int line) 
+static void llcd_print(struct llog_canceld_ctxt *llcd,
+                       const char *func, int line)
 {
         CDEBUG(D_RPCTRACE, "Llcd (%p) at %s:%d:\n", llcd, func, line);
         CDEBUG(D_RPCTRACE, "  size: %d\n", llcd->llcd_size);
@@ -86,7 +86,7 @@ static void llcd_print(struct llog_canceld_ctxt *llcd,
         CDEBUG(D_RPCTRACE, "  cookiebytes : %d\n", llcd->llcd_cookiebytes);
 }
 
-/** 
+/**
  * Allocate new llcd from cache, init it and return to caller.
  * Bumps number of objects allocated.
  */
@@ -97,7 +97,7 @@ static struct llog_canceld_ctxt *llcd_alloc(struct llog_commit_master *lcm)
 
         LASSERT(lcm != NULL);
 
-        /* 
+        /*
          * We want to send one page of cookies with rpc header. This buffer
          * will be assigned later to the rpc, this is why we preserve the
          * space for rpc header.
@@ -145,14 +145,14 @@ static void llcd_free(struct llog_canceld_ctxt *llcd)
                 atomic_dec(&lcm->lcm_count);
                 spin_unlock(&lcm->lcm_lock);
 
-                CDEBUG(D_RPCTRACE, "Free llcd %p on lcm %p (%d)\n", 
+                CDEBUG(D_RPCTRACE, "Free llcd %p on lcm %p (%d)\n",
                        llcd, lcm, atomic_read(&lcm->lcm_count));
         }
 
         LASSERT(atomic_read(&llcd_count) > 0);
         atomic_dec(&llcd_count);
 
-        size = offsetof(struct llog_canceld_ctxt, llcd_cookies) + 
+        size = offsetof(struct llog_canceld_ctxt, llcd_cookies) +
             llcd->llcd_size;
         OBD_SLAB_FREE(llcd, llcd_cache, size);
 }
@@ -161,7 +161,7 @@ static void llcd_free(struct llog_canceld_ctxt *llcd)
  * Checks if passed cookie fits into llcd free space buffer. Returns
  * 1 if yes and 0 otherwise.
  */
-static inline int 
+static inline int
 llcd_fit(struct llog_canceld_ctxt *llcd, struct llog_cookie *cookies)
 {
         return (llcd->llcd_size - llcd->llcd_cookiebytes >= sizeof(*cookies));
@@ -170,11 +170,11 @@ llcd_fit(struct llog_canceld_ctxt *llcd, struct llog_cookie *cookies)
 /**
  * Copy passed @cookies to @llcd.
  */
-static inline void 
+static inline void
 llcd_copy(struct llog_canceld_ctxt *llcd, struct llog_cookie *cookies)
 {
         LASSERT(llcd_fit(llcd, cookies));
-        memcpy((char *)llcd->llcd_cookies + llcd->llcd_cookiebytes, 
+        memcpy((char *)llcd->llcd_cookies + llcd->llcd_cookiebytes,
               cookies, sizeof(*cookies));
         llcd->llcd_cookiebytes += sizeof(*cookies);
 }
@@ -184,7 +184,7 @@ llcd_copy(struct llog_canceld_ctxt *llcd, struct llog_cookie *cookies)
  * sending result. Error is passed in @rc. Note, that this will be called
  * in cleanup time when all inflight rpcs aborted.
  */
-static int 
+static int
 llcd_interpret(struct ptlrpc_request *req, void *noused, int rc)
 {
         struct llog_canceld_ctxt *llcd = req->rq_async_args.pointer_arg[0];
@@ -192,10 +192,10 @@ llcd_interpret(struct ptlrpc_request *req, void *noused, int rc)
         llcd_free(llcd);
         return 0;
 }
- 
+
 /**
  * Send @llcd to remote node. Free llcd uppon completion or error. Sending
- * is performed in async style so this function will return asap without 
+ * is performed in async style so this function will return asap without
  * blocking.
  */
 static int llcd_send(struct llog_canceld_ctxt *llcd)
@@ -212,7 +212,7 @@ static int llcd_send(struct llog_canceld_ctxt *llcd)
 
         ctxt = llcd->llcd_ctxt;
         if (!ctxt) {
-                CERROR("Invalid llcd with NULL ctxt found (%p)\n", 
+                CERROR("Invalid llcd with NULL ctxt found (%p)\n",
                        llcd);
                 llcd_print(llcd, __FUNCTION__, __LINE__);
                 LBUG();
@@ -224,9 +224,9 @@ static int llcd_send(struct llog_canceld_ctxt *llcd)
 
         lcm = llcd->llcd_lcm;
 
-        /* 
+        /*
          * Check if we're in exit stage. Do not send llcd in
-         * this case. 
+         * this case.
          */
         if (test_bit(LLOG_LCM_FL_EXIT, &lcm->lcm_flags))
                 GOTO(exit, rc = -ENODEV);
@@ -234,9 +234,9 @@ static int llcd_send(struct llog_canceld_ctxt *llcd)
         CDEBUG(D_RPCTRACE, "Sending llcd %p\n", llcd);
 
         import = llcd->llcd_ctxt->loc_imp;
-        if (!import || (import == LP_POISON) || 
+        if (!import || (import == LP_POISON) ||
             (import->imp_client == LP_POISON)) {
-                CERROR("Invalid import %p for llcd %p\n", 
+                CERROR("Invalid import %p for llcd %p\n",
                        import, llcd);
                 GOTO(exit, rc = -ENODEV);
         }
@@ -244,20 +244,20 @@ static int llcd_send(struct llog_canceld_ctxt *llcd)
         OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_RECOV, 10);
 
         /*
-         * No need to get import here as it is already done in 
+         * No need to get import here as it is already done in
          * llog_receptor_accept().
          */
         req = ptlrpc_prep_req(import, LUSTRE_LOG_VERSION,
                               OBD_LOG_CANCEL, 2, size, bufs);
         if (req == NULL) {
-                CERROR("Can't allocate request for sending llcd %p\n", 
+                CERROR("Can't allocate request for sending llcd %p\n",
                        llcd);
                 GOTO(exit, rc = -ENOMEM);
         }
 
-        /* 
+        /*
          * Check if we're in exit stage again. Do not send llcd in
-         * this case. 
+         * this case.
          */
         if (test_bit(LLOG_LCM_FL_EXIT, &lcm->lcm_flags)) {
                 ptlrpc_req_finished(req);
@@ -322,7 +322,7 @@ static struct llog_canceld_ctxt *llcd_detach(struct llog_ctxt *ctxt)
         if (!llcd)
                 return NULL;
 
-        CDEBUG(D_RPCTRACE, "Detach llcd %p from ctxt %p\n", 
+        CDEBUG(D_RPCTRACE, "Detach llcd %p from ctxt %p\n",
                llcd, ctxt);
 
         ctxt->loc_llcd = NULL;
@@ -369,7 +369,7 @@ static int llcd_push(struct llog_ctxt *ctxt)
         int rc;
 
         /*
-         * Make sure that this llcd will not be sent again as we detach 
+         * Make sure that this llcd will not be sent again as we detach
          * it from ctxt.
          */
         llcd = llcd_detach(ctxt);
@@ -378,7 +378,7 @@ static int llcd_push(struct llog_ctxt *ctxt)
                 llcd_print(llcd, __FUNCTION__, __LINE__);
                 LBUG();
         }
-        
+
         rc = llcd_send(llcd);
         if (rc)
                 CERROR("Couldn't send llcd %p (%d)\n", llcd, rc);
@@ -397,7 +397,7 @@ int llog_recov_thread_start(struct llog_commit_master *lcm)
 
         rc = ptlrpcd_start(lcm->lcm_name, &lcm->lcm_pc);
         if (rc) {
-                CERROR("Error %d while starting recovery thread %s\n", 
+                CERROR("Error %d while starting recovery thread %s\n",
                        rc, lcm->lcm_name);
                 RETURN(rc);
         }
@@ -413,7 +413,7 @@ void llog_recov_thread_stop(struct llog_commit_master *lcm, int force)
         ENTRY;
 
         /*
-         * Let all know that we're stopping. This will also make 
+         * Let all know that we're stopping. This will also make
          * llcd_send() refuse any new llcds.
          */
         set_bit(LLOG_LCM_FL_EXIT, &lcm->lcm_flags);
@@ -423,7 +423,7 @@ void llog_recov_thread_stop(struct llog_commit_master *lcm, int force)
          * for processing now.
          */
         ptlrpcd_stop(&lcm->lcm_pc, force);
-        
+
         /*
          * By this point no alive inflight llcds should be left. Only
          * those forgotten in sync may still be attached to ctxt. Let's
@@ -433,7 +433,7 @@ void llog_recov_thread_stop(struct llog_commit_master *lcm, int force)
                 struct llog_canceld_ctxt *llcd;
                 struct list_head         *tmp;
 
-                CERROR("Busy llcds found (%d) on lcm %p\n", 
+                CERROR("Busy llcds found (%d) on lcm %p\n",
                        atomic_read(&lcm->lcm_count) == 0, lcm);
 
                 spin_lock(&lcm->lcm_lock);
@@ -443,7 +443,7 @@ void llog_recov_thread_stop(struct llog_commit_master *lcm, int force)
                         llcd_print(llcd, __FUNCTION__, __LINE__);
                 }
                 spin_unlock(&lcm->lcm_lock);
-                
+
                 /*
                  * No point to go further with busy llcds at this point
                  * as this is clear bug. It might mean we got hanging
@@ -476,8 +476,8 @@ struct llog_commit_master *llog_recov_thread_init(char *name)
         /*
          * Try to create threads with unique names.
          */
-        snprintf(lcm->lcm_name, sizeof(lcm->lcm_name), 
-                 "ll_log_commit_%s", name);
+        snprintf(lcm->lcm_name, sizeof(lcm->lcm_name),
+                 "lcm_%s", name);
 
         atomic_set(&lcm->lcm_count, 0);
         spin_lock_init(&lcm->lcm_lock);
@@ -506,7 +506,7 @@ void llog_recov_thread_fini(struct llog_commit_master *lcm, int force)
 }
 EXPORT_SYMBOL(llog_recov_thread_fini);
 
-static int llog_recov_thread_replay(struct llog_ctxt *ctxt, 
+static int llog_recov_thread_replay(struct llog_ctxt *ctxt,
                                     void *cb, void *arg)
 {
         struct obd_device *obd = ctxt->loc_obd;
@@ -535,7 +535,7 @@ static int llog_recov_thread_replay(struct llog_ctxt *ctxt,
                 OBD_FREE_PTR(lpca);
                 RETURN(-ENODEV);
         }
-        rc = cfs_kernel_thread(llog_cat_process_thread, lpca, 
+        rc = cfs_kernel_thread(llog_cat_process_thread, lpca,
                                CLONE_VM | CLONE_FILES);
         if (rc < 0) {
                 CERROR("Error starting llog_cat_process_thread(): %d\n", rc);
@@ -556,14 +556,14 @@ int llog_obd_repl_connect(struct llog_ctxt *ctxt,
         int rc;
         ENTRY;
 
-        /* 
+        /*
          * Send back cached llcd from llog before recovery if we have any.
          * This is void is nothing cached is found there.
          */
         llog_sync(ctxt, NULL);
 
-        /* 
-         * Start recovery in separate thread. 
+        /*
+         * Start recovery in separate thread.
          */
         mutex_down(&ctxt->loc_sem);
         ctxt->loc_gen = *gen;
@@ -574,7 +574,7 @@ int llog_obd_repl_connect(struct llog_ctxt *ctxt,
 }
 EXPORT_SYMBOL(llog_obd_repl_connect);
 
-/** 
+/**
  * Deleted objects have a commit callback that cancels the MDS
  * log record for the deletion. The commit callback calls this
  * function.
@@ -592,7 +592,8 @@ int llog_obd_repl_cancel(struct llog_ctxt *ctxt,
 
         mutex_down(&ctxt->loc_sem);
         lcm = ctxt->loc_lcm;
-        
+        CDEBUG(D_INFO, "cancel on lsm %p\n", lcm);
+
         /*
          * Let's check if we have all structures alive. We also check for
          * possible shutdown. Do nothing if we're stopping.
@@ -603,7 +604,7 @@ int llog_obd_repl_cancel(struct llog_ctxt *ctxt,
         }
 
         if (test_bit(LLOG_LCM_FL_EXIT, &lcm->lcm_flags)) {
-                CDEBUG(D_RPCTRACE, "Commit thread is stopping for ctxt %p\n", 
+                CDEBUG(D_RPCTRACE, "Commit thread is stopping for ctxt %p\n",
                        ctxt);
                 GOTO(out, rc = -ENODEV);
         }
@@ -612,7 +613,7 @@ int llog_obd_repl_cancel(struct llog_ctxt *ctxt,
 
         if (count > 0 && cookies != NULL) {
                 /*
-                 * Get new llcd from ctxt if required. 
+                 * Get new llcd from ctxt if required.
                  */
                 if (!llcd) {
                         llcd = llcd_get(ctxt);
@@ -627,8 +628,8 @@ int llog_obd_repl_cancel(struct llog_ctxt *ctxt,
                 }
 
                 /*
-                 * Llcd does not have enough room for @cookies. Let's push 
-                 * it out and allocate new one. 
+                 * Llcd does not have enough room for @cookies. Let's push
+                 * it out and allocate new one.
                  */
                 if (!llcd_fit(llcd, cookies)) {
                         rc = llcd_push(ctxt);
@@ -676,8 +677,8 @@ int llog_obd_repl_sync(struct llog_ctxt *ctxt, struct obd_export *exp)
         int rc = 0;
         ENTRY;
 
-        /* 
-         * Flush any remaining llcd. 
+        /*
+         * Flush any remaining llcd.
          */
         mutex_down(&ctxt->loc_sem);
         if (exp && (ctxt->loc_imp == exp->exp_imp_reverse)) {
@@ -689,10 +690,10 @@ int llog_obd_repl_sync(struct llog_ctxt *ctxt, struct obd_export *exp)
                 llcd_put(ctxt);
                 mutex_up(&ctxt->loc_sem);
         } else {
-                /* 
+                /*
                  * This is either llog_sync() from generic llog code or sync
                  * on client disconnect. In either way let's do it and send
-                 * llcds to the target with waiting for completion. 
+                 * llcds to the target with waiting for completion.
                  */
                 CDEBUG(D_RPCTRACE, "Sync cached llcd\n");
                 mutex_up(&ctxt->loc_sem);
@@ -719,7 +720,7 @@ int llog_recov_init(void)
 {
         int llcd_size;
 
-        llcd_size = CFS_PAGE_SIZE - 
+        llcd_size = CFS_PAGE_SIZE -
                 lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, NULL);
         llcd_size += offsetof(struct llog_canceld_ctxt, llcd_cookies);
         llcd_cache = cfs_mem_cache_create("llcd_cache", llcd_size, 0, 0);
@@ -736,7 +737,7 @@ int llog_recov_init(void)
 void llog_recov_fini(void)
 {
         /*
-         * Kill llcd cache when thread is stopped and we're sure no 
+         * Kill llcd cache when thread is stopped and we're sure no
          * llcd in use left.
          */
         if (llcd_cache) {
@@ -744,7 +745,7 @@ void llog_recov_fini(void)
                  * In 2.6.22 cfs_mem_cache_destroy() will not return error
                  * for busy resources. Let's check it another way.
                  */
-                LASSERTF(atomic_read(&llcd_count) == 0, 
+                LASSERTF(atomic_read(&llcd_count) == 0,
                          "Can't destroy llcd cache! Number of "
                          "busy llcds: %d\n", atomic_read(&llcd_count));
                 cfs_mem_cache_destroy(llcd_cache);
diff --git a/lustre/ptlrpc/recover.c b/lustre/ptlrpc/recover.c
index 4adf785..ec962a0 100644
--- a/lustre/ptlrpc/recover.c
+++ b/lustre/ptlrpc/recover.c
@@ -110,20 +110,15 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight)
          */
         list_for_each_safe(tmp, pos, &imp->imp_replay_list) {
                 req = list_entry(tmp, struct ptlrpc_request, rq_replay_list);
-
                 /* If need to resend the last sent transno (because a
                    reconnect has occurred), then stop on the matching
                    req and send it again. If, however, the last sent
                    transno has been committed then we continue replay
                    from the next request. */
-                if (imp->imp_resend_replay && 
-                    req->rq_transno == last_transno) {
-                        lustre_msg_add_flags(req->rq_reqmsg, MSG_RESENT);
-                        break;
-                }
-
                 if (req->rq_transno > last_transno) {
-                        imp->imp_last_replay_transno = req->rq_transno;
+                        if (imp->imp_resend_replay)
+                                lustre_msg_add_flags(req->rq_reqmsg,
+                                                     MSG_RESENT);
                         break;
                 }
 
@@ -138,7 +133,7 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight)
                 rc = ptlrpc_replay_req(req);
                 if (rc) {
                         CERROR("recovery replay error %d for req "
-                               LPD64"\n", rc, req->rq_xid);
+                               LPU64"\n", rc, req->rq_xid);
                         RETURN(rc);
                 }
                 *inflight = 1;
diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c
index 0b7a5db..293ab95 100644
--- a/lustre/ptlrpc/service.c
+++ b/lustre/ptlrpc/service.c
@@ -49,31 +49,19 @@
 int test_req_buffer_pressure = 0;
 CFS_MODULE_PARM(test_req_buffer_pressure, "i", int, 0444,
                 "set non-zero to put pressure on request buffer pools");
-unsigned int at_min = 0;
+
 CFS_MODULE_PARM(at_min, "i", int, 0644,
                 "Adaptive timeout minimum (sec)");
-
-#ifdef HAVE_AT_SUPPORT
-unsigned int at_max = 600;
-#else
-unsigned int at_max = 0;
-#endif
-
-EXPORT_SYMBOL(at_max);
 CFS_MODULE_PARM(at_max, "i", int, 0644,
                 "Adaptive timeout maximum (sec)");
-unsigned int at_history = 600;
 CFS_MODULE_PARM(at_history, "i", int, 0644,
                 "Adaptive timeouts remember the slowest event that took place "
                 "within this period (sec)");
-static int at_early_margin = 5;
 CFS_MODULE_PARM(at_early_margin, "i", int, 0644,
                 "How soon before an RPC deadline to send an early reply");
-static int at_extra = 30;
 CFS_MODULE_PARM(at_extra, "i", int, 0644,
                 "How much extra time to give with each early reply");
 
-
 /* forward ref */
 static int ptlrpc_server_post_idle_rqbds (struct ptlrpc_service *svc);
 
@@ -174,8 +162,8 @@ ptlrpc_grow_req_bufs(struct ptlrpc_service *svc)
 }
 
 void
-ptlrpc_save_lock (struct ptlrpc_request *req,
-                  struct lustre_handle *lock, int mode)
+ptlrpc_save_lock(struct ptlrpc_request *req,
+                 struct lustre_handle *lock, int mode)
 {
         struct ptlrpc_reply_state *rs = req->rq_reply_state;
         int                        idx;
@@ -183,10 +171,14 @@ ptlrpc_save_lock (struct ptlrpc_request *req,
         LASSERT(rs != NULL);
         LASSERT(rs->rs_nlocks < RS_MAX_LOCKS);
 
-        idx = rs->rs_nlocks++;
-        rs->rs_locks[idx] = *lock;
-        rs->rs_modes[idx] = mode;
-        rs->rs_difficult = 1;
+        if (req->rq_export->exp_disconnected) {
+                ldlm_lock_decref(lock, mode);
+        } else {
+                idx = rs->rs_nlocks++;
+                rs->rs_locks[idx] = *lock;
+                rs->rs_modes[idx] = mode;
+                rs->rs_difficult = 1;
+        }
 }
 
 void
@@ -210,7 +202,7 @@ ptlrpc_schedule_difficult_reply (struct ptlrpc_reply_state *rs)
 }
 
 void
-ptlrpc_commit_replies (struct obd_device *obd)
+ptlrpc_commit_replies (struct obd_export *exp)
 {
         struct list_head   *tmp;
         struct list_head   *nxt;
@@ -219,15 +211,16 @@ ptlrpc_commit_replies (struct obd_device *obd)
          * to attend to complete them. */
 
         /* CAVEAT EMPTOR: spinlock ordering!!! */
-        spin_lock(&obd->obd_uncommitted_replies_lock);
+        spin_lock(&exp->exp_uncommitted_replies_lock);
 
-        list_for_each_safe (tmp, nxt, &obd->obd_uncommitted_replies) {
+        list_for_each_safe(tmp, nxt, &exp->exp_uncommitted_replies) {
                 struct ptlrpc_reply_state *rs =
                         list_entry(tmp, struct ptlrpc_reply_state, rs_obd_list);
 
-                LASSERT (rs->rs_difficult);
-
-                if (rs->rs_transno <= obd->obd_last_committed) {
+                LASSERT(rs->rs_difficult);
+                /* VBR: per-export last_committed */
+                LASSERT(rs->rs_export);
+                if (rs->rs_transno <= rs->rs_export->exp_last_committed) {
                         struct ptlrpc_service *svc = rs->rs_service;
 
                         spin_lock (&svc->srv_lock);
@@ -237,7 +230,7 @@ ptlrpc_commit_replies (struct obd_device *obd)
                 }
         }
 
-        spin_unlock(&obd->obd_uncommitted_replies_lock);
+        spin_unlock(&exp->exp_uncommitted_replies_lock);
 }
 
 static int
@@ -305,8 +298,10 @@ ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size, int max_reply_size,
                 int min_threads, int max_threads, char *threadname,
                 svc_hpreq_handler_t hp_handler)
 {
-        int                    rc;
-        struct ptlrpc_service *service;
+        int                     rc;
+        struct ptlrpc_at_array *array;
+        struct ptlrpc_service  *service;
+        unsigned int            size, index;
         ENTRY;
 
         LASSERT (nbufs > 0);
@@ -357,7 +352,25 @@ ptlrpc_init_svc(int nbufs, int bufsize, int max_req_size, int max_reply_size,
 
         spin_lock_init(&service->srv_at_lock);
         CFS_INIT_LIST_HEAD(&service->srv_req_in_queue);
-        CFS_INIT_LIST_HEAD(&service->srv_at_list);
+
+        array = &service->srv_at_array;
+        size = at_est2timeout(at_max);
+        array->paa_size = size;
+        array->paa_count = 0;
+        array->paa_deadline = -1;
+
+        /* allocate memory for srv_at_array (ptlrpc_at_array) */
+        OBD_ALLOC(array->paa_reqs_array, sizeof(struct list_head) * size);
+        if (array->paa_reqs_array == NULL)
+                GOTO(failed, NULL);
+
+        for (index = 0; index < size; index++)
+                CFS_INIT_LIST_HEAD(&array->paa_reqs_array[index]);
+
+        OBD_ALLOC(array->paa_reqs_count, sizeof(__u32) * size);
+        if (array->paa_reqs_count == NULL)
+                GOTO(failed, NULL);
+
         cfs_timer_init(&service->srv_at_timer, ptlrpc_at_timer, service);
         /* At SOW, service time should be quick; 10s seems generous. If client
            timeout is less than this, we'll be sending an early reply. */
@@ -514,6 +527,14 @@ static void ptlrpc_server_finish_request(struct ptlrpc_request *req)
         spin_lock(&svc->srv_at_lock);
         req->rq_sent_final = 1;
         list_del_init(&req->rq_timed_list);
+        if (req->rq_at_linked) {
+                struct ptlrpc_at_array *array = &svc->srv_at_array;
+                __u32 index = req->rq_at_index;
+
+                req->rq_at_linked = 0;
+                array->paa_reqs_count[index]--;
+                array->paa_count--;
+        }
         spin_unlock(&svc->srv_at_lock);
 
         ptlrpc_server_drop_request(req);
@@ -625,20 +646,18 @@ static int ptlrpc_check_req(struct ptlrpc_request *req)
 
 static void ptlrpc_at_set_timer(struct ptlrpc_service *svc)
 {
-        struct ptlrpc_request *rq;
+        struct ptlrpc_at_array *array = &svc->srv_at_array;
         __s32 next;
 
         spin_lock(&svc->srv_at_lock);
-        if (list_empty(&svc->srv_at_list)) {
+        if (array->paa_count == 0) {
                 cfs_timer_disarm(&svc->srv_at_timer);
                 spin_unlock(&svc->srv_at_lock);
                 return;
         }
 
         /* Set timer for closest deadline */
-        rq = list_entry(svc->srv_at_list.next, struct ptlrpc_request,
-                        rq_timed_list);
-        next = (__s32)(rq->rq_deadline - cfs_time_current_sec() -
+        next = (__s32)(array->paa_deadline - cfs_time_current_sec() -
                        at_early_margin);
         if (next <= 0)
                 ptlrpc_at_timer((unsigned long)svc);
@@ -652,7 +671,9 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service *svc)
 static int ptlrpc_at_add_timed(struct ptlrpc_request *req)
 {
         struct ptlrpc_service *svc = req->rq_rqbd->rqbd_service;
-        struct ptlrpc_request *rq;
+        struct ptlrpc_request *rq = NULL;
+        struct ptlrpc_at_array *array = &svc->srv_at_array;
+        __u32 index;
         int found = 0;
 
         if (AT_OFF)
@@ -669,22 +690,33 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req)
         }
 
         LASSERT(list_empty(&req->rq_timed_list));
-        /* Add to sorted list.  Presumably latest rpcs will have the latest
-           deadlines, so search backward. */
-        list_for_each_entry_reverse(rq, &svc->srv_at_list, rq_timed_list) {
-                if (req->rq_deadline >= rq->rq_deadline) {
-                        list_add(&req->rq_timed_list, &rq->rq_timed_list);
-                        found++;
-                        break;
+
+        index = req->rq_deadline % array->paa_size;
+        if (array->paa_reqs_count[index] > 0) {
+                /* latest rpcs will have the latest deadlines in the list,
+                 * so search backward. */
+                list_for_each_entry_reverse(rq, &array->paa_reqs_array[index],
+                                            rq_timed_list) {
+                        if (req->rq_deadline >= rq->rq_deadline) {
+                                list_add(&req->rq_timed_list,
+                                         &rq->rq_timed_list);
+                                break;
+                        }
                 }
         }
-        if (!found)
-                /* Add to front if shortest deadline or list empty */
-                list_add(&req->rq_timed_list, &svc->srv_at_list);
-
-        /* Check if we're the head of the list */
-        found = (svc->srv_at_list.next == &req->rq_timed_list);
+        
+        /* Add the request at the head of the list */
+        if (list_empty(&req->rq_timed_list))
+                list_add(&req->rq_timed_list, &array->paa_reqs_array[index]);
 
+        req->rq_at_linked = 1;
+        req->rq_at_index = index;
+        array->paa_reqs_count[index]++;
+        array->paa_count++;
+        if (array->paa_count == 1 || array->paa_deadline > req->rq_deadline) {
+                array->paa_deadline = req->rq_deadline;
+                found = 1;
+        }
         spin_unlock(&svc->srv_at_lock);
 
         if (found)
@@ -730,13 +762,15 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req,
                 RETURN(-ENOSYS);
         }
 
-        if (req->rq_export && req->rq_export->exp_obd->obd_recovering) {
+        if (req->rq_export && req->rq_export->exp_in_recovery) {
+                /* don't increase server estimates during recovery, and give
+                   clients the full recovery time. */
                 newdl = cfs_time_current_sec() +
                         req->rq_export->exp_obd->obd_recovery_timeout;
         } else {
                 if (extra_time) {
                         /* Fake our processing time into the future to ask the
-                         * clients for some extra amount of time */
+                           clients for some extra amount of time */
                         extra_time += cfs_time_current_sec() -
                                       req->rq_arrival_time.tv_sec;
                         at_add(&svc->srv_at_estimate, extra_time);
@@ -744,7 +778,6 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req,
                 newdl = req->rq_arrival_time.tv_sec +
                         at_get(&svc->srv_at_estimate);
         }
-
         if (req->rq_deadline >= newdl) {
                 /* We're not adding any time, no need to send an early reply
                    (e.g. maybe at adaptive_max) */
@@ -821,6 +854,9 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
 {
         struct ptlrpc_request *rq, *n;
         struct list_head work_list;
+        struct ptlrpc_at_array *array = &svc->srv_at_array;
+        __u32  index, count;
+        time_t deadline;
         time_t now = cfs_time_current_sec();
         cfs_duration_t delay;
         int first, counter = 0;
@@ -834,15 +870,13 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
         delay = cfs_time_sub(cfs_time_current(), svc->srv_at_checktime);
         svc->srv_at_check = 0;
 
-        if (list_empty(&svc->srv_at_list)) {
+        if (array->paa_count == 0) {
                 spin_unlock(&svc->srv_at_lock);
                 RETURN(0);
         }
 
         /* The timer went off, but maybe the nearest rpc already completed. */
-        rq = list_entry(svc->srv_at_list.next, struct ptlrpc_request,
-                        rq_timed_list);
-        first = (int)(rq->rq_deadline - now);
+        first = array->paa_deadline - now;
         if (first > at_early_margin) {
                 /* We've still got plenty of time.  Reset the timer. */
                 spin_unlock(&svc->srv_at_lock);
@@ -853,15 +887,33 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service *svc)
         /* We're close to a timeout, and we don't know how much longer the
            server will take. Send early replies to everyone expiring soon. */
         CFS_INIT_LIST_HEAD(&work_list);
-        list_for_each_entry_safe(rq, n, &svc->srv_at_list, rq_timed_list) {
-                if (rq->rq_deadline <= now + at_early_margin) {
-                        list_move(&rq->rq_timed_list, &work_list);
-                        counter++;
-                } else {
+        deadline = -1;
+        index = array->paa_deadline % array->paa_size;
+        count = array->paa_count;
+        while (count > 0) {
+                count -= array->paa_reqs_count[index];
+                list_for_each_entry_safe(rq, n, &array->paa_reqs_array[index],
+                                         rq_timed_list) {
+                        if (rq->rq_deadline <= now + at_early_margin) {
+                                list_move(&rq->rq_timed_list, &work_list);
+                                counter++;
+                                array->paa_reqs_count[index]--;
+                                array->paa_count--;
+                                rq->rq_at_linked = 0;
+                                continue;
+                        }
+
+                        /* update the earliest deadline */
+                        if (deadline == -1 || rq->rq_deadline < deadline)
+                                deadline = rq->rq_deadline;
+
                         break;
                 }
-        }
 
+                if (++index >= array->paa_size)
+                        index = 0;
+        }
+        array->paa_deadline = deadline;
         spin_unlock(&svc->srv_at_lock);
 
         /* we have a new earliest deadline, restart the timer */
@@ -1120,7 +1172,7 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service *svc)
                 goto err_req;
         }
 
-        CDEBUG(D_NET, "got req "LPD64"\n", req->rq_xid);
+        CDEBUG(D_NET, "got req "LPU64"\n", req->rq_xid);
 
         req->rq_export = class_conn2export(
                 lustre_msg_get_handle(req->rq_reqmsg));
@@ -1192,7 +1244,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service *svc,
              svc->srv_n_difficult_replies != 0 &&
 #endif
              svc->srv_n_active_reqs >= (svc->srv_threads_running - 1))) {
-                /* Don't handle regular requests in the last thread, in order               * remain free to handle any 'difficult' replies (that might
+                /* Don't handle regular requests in the last thread, in order
                  * to handle difficult replies (which might block other threads)
                  * as well as handle any incoming reqs, early replies, etc.
                  * That means we always need at least 2 service threads. */
@@ -1256,7 +1308,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service *svc,
                                     at_get(&svc->srv_at_estimate));
         }
 
-        CDEBUG(D_NET, "got req "LPD64"\n", request->rq_xid);
+        CDEBUG(D_NET, "got req "LPU64"\n", request->rq_xid);
 
         request->rq_svc_thread = thread;
         if (request->rq_export) {
@@ -1384,10 +1436,10 @@ ptlrpc_server_handle_reply (struct ptlrpc_service *svc)
         /* Disengage from notifiers carefully (lock order - irqrestore below!)*/
         spin_unlock(&svc->srv_lock);
 
-        spin_lock (&obd->obd_uncommitted_replies_lock);
+        spin_lock (&exp->exp_uncommitted_replies_lock);
         /* Noop if removed already */
         list_del_init (&rs->rs_obd_list);
-        spin_unlock (&obd->obd_uncommitted_replies_lock);
+        spin_unlock (&exp->exp_uncommitted_replies_lock);
 
         spin_lock (&exp->exp_lock);
         /* Noop if removed already */
@@ -1406,9 +1458,7 @@ 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 %s\n",
-                      rs,
-                      rs->rs_xid, rs->rs_transno,
+                      " o%d NID %s\n", rs, rs->rs_xid, rs->rs_transno,
                       lustre_msg_get_opc(rs->rs_msg),
                       libcfs_nid2str(exp->exp_connection->c_peer.nid));
         }
@@ -1501,7 +1551,7 @@ void ptlrpc_daemonize(char *name)
         cfs_daemonize(name);
         exit_fs(cfs_current());
         current->fs = fs;
-        ll_set_fs_pwd(current->fs, init_task.fs->pwdmnt, init_task.fs->pwd);
+        ll_set_fs_pwd(current->fs, cfs_fs_mnt(init_task.fs), cfs_fs_pwd(init_task.fs));
 }
 
 static void
@@ -1599,10 +1649,7 @@ static int ptlrpc_main(void *arg)
          */
         cfs_waitq_signal(&thread->t_ctl_waitq);
 
-        thread->t_watchdog = lc_watchdog_add(max_t(int, obd_timeout, AT_OFF ? 0 :
-                                                   at_get(&svc->srv_at_estimate))
-                                             *  svc->srv_watchdog_factor,
-                                             NULL, NULL);
+        thread->t_watchdog = lc_watchdog_add(GET_TIMEOUT(svc), NULL, NULL);
 
         spin_lock(&svc->srv_lock);
         svc->srv_threads_running++;
@@ -1638,10 +1685,7 @@ static int ptlrpc_main(void *arg)
                               svc->srv_at_check,
                               &lwi);
 
-                lc_watchdog_touch_ms(thread->t_watchdog, max_t(int, obd_timeout,
-                                     AT_OFF ? 0 :
-                                     at_get(&svc->srv_at_estimate)) *
-                                     svc->srv_watchdog_factor);
+                lc_watchdog_touch(thread->t_watchdog, GET_TIMEOUT(svc));
 
                 ptlrpc_check_rqbd_pool(svc);
 
@@ -1750,6 +1794,7 @@ int ptlrpc_start_threads(struct obd_device *dev, struct ptlrpc_service *svc)
 
         /* We require 2 threads min - see note in
          * ptlrpc_server_handle_request() */
+
         LASSERT(svc->srv_threads_min >= 2);
         for (i = 0; i < svc->srv_threads_min; i++) {
                 rc = ptlrpc_start_thread(dev, svc);
@@ -1797,6 +1842,7 @@ int ptlrpc_start_thread(struct obd_device *dev, struct ptlrpc_service *svc)
         id = svc->srv_threads_started++;
         spin_unlock(&svc->srv_lock);
 
+        thread->t_svc = svc;
         thread->t_id = id;
         sprintf(name, "%s_%02d", svc->srv_thread_name, id);
         d.dev = dev;
@@ -1835,6 +1881,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service)
         struct l_wait_info    lwi;
         struct list_head     *tmp;
         struct ptlrpc_reply_state *rs, *t;
+        struct ptlrpc_at_array *array = &service->srv_at_array;
 
         cfs_timer_disarm(&service->srv_at_timer);
 
@@ -1963,6 +2010,18 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service)
         /* In case somebody rearmed this in the meantime */
         cfs_timer_disarm(&service->srv_at_timer);
 
+        if (array->paa_reqs_array != NULL) {
+                OBD_FREE(array->paa_reqs_array,
+                         sizeof(struct list_head) * array->paa_size);
+                array->paa_reqs_array = NULL;
+        }
+
+        if (array->paa_reqs_count != NULL) {
+                OBD_FREE(array->paa_reqs_count,
+                         sizeof(__u32) * array->paa_size);
+                array->paa_reqs_count= NULL;
+        }
+
         OBD_FREE(service, sizeof(*service));
         return 0;
 }
diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c
index 7e2b085..20acff7 100644
--- a/lustre/ptlrpc/wiretest.c
+++ b/lustre/ptlrpc/wiretest.c
@@ -61,13 +61,12 @@
 #include <obd_class.h>
 #include <lustre_net.h>
 #include <lustre_disk.h>
-
 void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
          * (make -C lustre/utils newwiretest)
-         * running on Linux xlab.hostel 2.6.23.12-52.fc7 #1 SMP Tue Dec 18 21:18:02 EST 2007 i686 i68
-         * with gcc version 3.4.6 20060404 (Red Hat 3.4.6-7) */
+         * running on Linux localhost.localdomain 2.6.18-prep #3 SMP Sun Nov 23 08:04:44 EST 2008 i68
+         * with gcc version 4.1.1 20061011 (Red Hat 4.1.1-30) */
 
 
         /* Constants... */
@@ -169,7 +168,15 @@ void lustre_assert_wire_constants(void)
                  (long long)MDS_QUOTACHECK);
         LASSERTF(MDS_QUOTACTL == 48, " found %lld\n",
                  (long long)MDS_QUOTACTL);
-        LASSERTF(MDS_LAST_OPC == 51, " found %lld\n",
+        LASSERTF(MDS_GETXATTR == 49, " found %lld\n",
+                 (long long)MDS_GETXATTR);
+        LASSERTF(MDS_SETXATTR == 50, " found %lld\n",
+                 (long long)MDS_SETXATTR);
+        LASSERTF(MDS_WRITEPAGE == 51, " found %lld\n",
+                 (long long)MDS_WRITEPAGE);
+        LASSERTF(MDS_IS_SUBDIR == 52, " found %lld\n",
+                 (long long)MDS_IS_SUBDIR);
+        LASSERTF(MDS_LAST_OPC == 53, " found %lld\n",
                  (long long)MDS_LAST_OPC);
         LASSERTF(REINT_SETATTR == 1, " found %lld\n",
                  (long long)REINT_SETATTR);
@@ -183,7 +190,9 @@ void lustre_assert_wire_constants(void)
                  (long long)REINT_RENAME);
         LASSERTF(REINT_OPEN == 6, " found %lld\n",
                  (long long)REINT_OPEN);
-        LASSERTF(REINT_MAX == 7, " found %lld\n",
+        LASSERTF(REINT_SETXATTR == 7, " found %lld\n",
+                 (long long)REINT_SETXATTR);
+        LASSERTF(REINT_MAX == 8, " found %lld\n",
                  (long long)REINT_MAX);
         LASSERTF(MGS_CONNECT == 250, " found %lld\n",
                  (long long)MGS_CONNECT);
@@ -385,7 +394,7 @@ void lustre_assert_wire_constants(void)
         LASSERT(offsetof(struct lustre_msg_v1, lm_magic) == offsetof(struct lustre_msg_v2, lm_magic));
 
         /* Checks for struct ptlrpc_body */
-        LASSERTF((int)sizeof(struct ptlrpc_body) == 88, " found %lld\n",
+        LASSERTF((int)sizeof(struct ptlrpc_body) == 152, " found %lld\n",
                  (long long)(int)sizeof(struct ptlrpc_body));
         LASSERTF((int)offsetof(struct ptlrpc_body, pb_handle) == 0, " found %lld\n",
                  (long long)(int)offsetof(struct ptlrpc_body, pb_handle));
@@ -451,6 +460,14 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct ptlrpc_body, pb_limit));
         LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_limit) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_limit));
+        LASSERTF((int)offsetof(struct ptlrpc_body, pb_pre_versions) == 88, " found %lld\n",
+                 (long long)(int)offsetof(struct ptlrpc_body, pb_pre_versions));
+        LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_pre_versions) == 32, " found %lld\n",
+                 (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_pre_versions));
+        LASSERTF((int)offsetof(struct ptlrpc_body, pb_padding) == 120, " found %lld\n",
+                 (long long)(int)offsetof(struct ptlrpc_body, pb_padding));
+        LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_padding) == 32, " found %lld\n",
+                 (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_padding));
 
         /* Checks for struct obd_connect_data */
         LASSERTF((int)sizeof(struct obd_connect_data) == 72, " found %lld\n",
@@ -522,8 +539,8 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_CONNECT_JOIN == 0x2000ULL);
         CLASSERT(OBD_CONNECT_ATTRFID == 0x4000ULL);
         CLASSERT(OBD_CONNECT_NODEVOH == 0x8000ULL);
-        CLASSERT(OBD_CONNECT_LCL_CLIENT == 0x10000ULL);
-        CLASSERT(OBD_CONNECT_RMT_CLIENT == 0x20000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT == 0x10000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT_FORCE == 0x20000ULL);
         CLASSERT(OBD_CONNECT_BRW_SIZE == 0x40000ULL);
         CLASSERT(OBD_CONNECT_QUOTA64 == 0x80000ULL);
         CLASSERT(OBD_CONNECT_MDS_CAPA == 0x100000ULL);
@@ -534,7 +551,9 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_CONNECT_LRU_RESIZE == 0x02000000ULL);
         CLASSERT(OBD_CONNECT_MDS_MDS == 0x04000000ULL);
         CLASSERT(OBD_CONNECT_REAL == 0x08000000ULL);
+        CLASSERT(OBD_CONNECT_FID == 0x40000000ULL);
         CLASSERT(OBD_CONNECT_CKSUM == 0x20000000ULL);
+        CLASSERT(OBD_CONNECT_VBR == 0x80000000ULL);
 
         /* Checks for struct obdo */
         LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",
@@ -703,6 +722,7 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_FL_TRUNCLOCK == (0x00000800));
         CLASSERT(OBD_FL_CKSUM_CRC32 == (0x00001000));
         CLASSERT(OBD_FL_CKSUM_ADLER == (0x00002000));
+        CLASSERT(OBD_FL_SHRINK_GRANT == (0x00020000));
         CLASSERT(OBD_CKSUM_CRC32 == 1);
         CLASSERT(OBD_CKSUM_ADLER == 2);
 
@@ -764,6 +784,67 @@ void lustre_assert_wire_constants(void)
         LASSERTF(LOV_PATTERN_RAID1 == 2, " found %lld\n",
                  (long long)LOV_PATTERN_RAID1);
 
+        /* Checks for struct lov_mds_md_v3 */
+        LASSERTF((int)sizeof(struct lov_mds_md_v3) == 48, " found %lld\n",
+                 (long long)(int)sizeof(struct lov_mds_md_v3));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_magic) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_magic));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_magic) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_magic));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pattern) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pattern));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pattern) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pattern));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_object_id) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_object_id));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_id) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_id));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_object_gr) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_object_gr));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_gr) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_gr));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_stripe_size) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_stripe_size));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_size) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_size));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_stripe_count) == 28, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_stripe_count));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_count) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_count));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pool_name) == 32, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pool_name));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_objects) == 48, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_objects));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects) == 0, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects));
+
+        /* Checks for struct lov_ost_data_v1 */
+        LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, " found %lld\n",
+                 (long long)(int)sizeof(struct lov_ost_data_v1));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_id) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_object_id));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_gr) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_object_gr));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_gen) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_gen));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_idx) == 20, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_idx));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx));
+        CLASSERT(LOV_MAGIC_V3 == 0x0BD30BD0);
+        LASSERTF(LOV_PATTERN_RAID0 == 1, " found %lld\n",
+                 (long long)LOV_PATTERN_RAID0);
+        LASSERTF(LOV_PATTERN_RAID1 == 2, " found %lld\n",
+                 (long long)LOV_PATTERN_RAID1);
+
         /* Checks for struct lov_mds_md_join */
         LASSERTF((int)sizeof(struct lov_mds_md_join) == 56, " found %lld\n",
                  (long long)(int)sizeof(struct lov_mds_md_join));
@@ -1647,6 +1728,38 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_blocks) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_blocks));
 
+        /* Checks for struct cfg_marker */
+        LASSERTF((int)sizeof(struct cfg_marker) == 160, " found %lld\n",
+                 (long long)(int)sizeof(struct cfg_marker));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_step) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_step));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_step) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_step));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_flags) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_flags));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_flags) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_flags));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_vers) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_vers));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_vers) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_vers));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_createtime) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_createtime));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_createtime) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_createtime));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_canceltime) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_canceltime));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_canceltime) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_canceltime));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_tgtname) == 32, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_tgtname));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_tgtname) == 64, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_tgtname));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_comment) == 96, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_comment));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_comment) == 64, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_comment));
+
         /* Checks for struct llog_logid */
         LASSERTF((int)sizeof(struct llog_logid) == 20, " found %lld\n",
                  (long long)(int)sizeof(struct llog_logid));
@@ -1776,10 +1889,10 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct llog_create_rec, lcr_oid));
         LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_oid) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_oid));
-        LASSERTF((int)offsetof(struct llog_create_rec, lcr_ogen) == 40, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_create_rec, lcr_ogen));
-        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_ogen) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_ogen));
+        LASSERTF((int)offsetof(struct llog_create_rec, lcr_ogr) == 40, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_create_rec, lcr_ogr));
+        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_ogr));
         LASSERTF((int)offsetof(struct llog_create_rec, padding) == 44, " found %lld\n",
                  (long long)(int)offsetof(struct llog_create_rec, padding));
         LASSERTF((int)sizeof(((struct llog_create_rec *)0)->padding) == 4, " found %lld\n",
@@ -1820,14 +1933,14 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct llog_unlink_rec, lur_oid));
         LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_oid) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_oid));
-        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_ogen) == 24, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_unlink_rec, lur_ogen));
-        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen));
-        LASSERTF((int)offsetof(struct llog_unlink_rec, padding) == 28, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_unlink_rec, padding));
-        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->padding) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->padding));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_ogr) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_unlink_rec, lur_ogr));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_ogr));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_count) == 28, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_unlink_rec, lur_count));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_count) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_count));
         LASSERTF((int)offsetof(struct llog_unlink_rec, lur_tail) == 32, " found %lld\n",
                  (long long)(int)offsetof(struct llog_unlink_rec, lur_tail));
         LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_tail) == 8, " found %lld\n",
@@ -1844,10 +1957,10 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct llog_setattr_rec, lsr_oid));
         LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_oid) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_oid));
-        LASSERTF((int)offsetof(struct llog_setattr_rec, lsr_ogen) == 24, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_setattr_rec, lsr_ogen));
-        LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogen) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogen));
+        LASSERTF((int)offsetof(struct llog_setattr_rec, lsr_ogr) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr_rec, lsr_ogr));
+        LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogr));
         LASSERTF((int)offsetof(struct llog_setattr_rec, lsr_uid) == 28, " found %lld\n",
                  (long long)(int)offsetof(struct llog_setattr_rec, lsr_uid));
         LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_uid) == 4, " found %lld\n",
@@ -1865,6 +1978,46 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_tail) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_tail));
 
+        /* Checks for struct llog_setattr64_rec */
+        LASSERTF((int)sizeof(struct llog_setattr64_rec) == 56, " found %lld\n",
+                 (long long)(int)sizeof(struct llog_setattr64_rec));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_hdr) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_hdr));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_hdr) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_hdr));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_oid) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_oid));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_oid) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_oid));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_ogr) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_ogr));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_ogr));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, padding) == 28, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, padding));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->padding) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->padding));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_uid) == 32, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_uid));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_uid_h) == 36, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_uid_h));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid_h) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid_h));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_gid) == 40, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_gid));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_gid_h) == 44, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_gid_h));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid_h) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid_h));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_tail) == 48, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_tail));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_tail) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_tail));
+
         /* Checks for struct llog_size_change_rec */
         LASSERTF((int)sizeof(struct llog_size_change_rec) == 48, " found %lld\n",
                  (long long)(int)sizeof(struct llog_size_change_rec));
@@ -2114,26 +2267,6 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct qunit_data_old2 *)0)->qd_count) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct qunit_data_old2 *)0)->qd_count));
 
-        /* Checks for struct qunit_data_old */
-        LASSERTF((int)sizeof(struct qunit_data_old) == 16, " found %lld\n",
-                 (long long)(int)sizeof(struct qunit_data_old));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_id) == 0, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_id));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_id) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_id));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_type) == 4, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_type));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_type) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_type));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_count) == 8, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_count));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_count) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_count));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_isblk) == 12, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_isblk));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_isblk) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_isblk));
-
         /* Checks for struct quota_adjust_qunit */
         LASSERTF((int)sizeof(struct quota_adjust_qunit) == 32, " found %lld\n",
                  (long long)(int)sizeof(struct quota_adjust_qunit));
@@ -2294,7 +2427,7 @@ void lustre_assert_wire_constants(void)
         CLASSERT(FIEMAP_FLAG_DEVICE_ORDER == 0x40000000);
 
         /* Checks for struct ll_fiemap_extent */
-        LASSERTF((int)sizeof(struct ll_fiemap_extent) == 32, " found %lld\n",
+        LASSERTF((int)sizeof(struct ll_fiemap_extent) == 56, " found %lld\n",
                  (long long)(int)sizeof(struct ll_fiemap_extent));
         LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_logical) == 0, " found %lld\n",
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_logical));
@@ -2308,28 +2441,27 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_length));
         LASSERTF((int)sizeof(((struct ll_fiemap_extent *)0)->fe_length) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct ll_fiemap_extent *)0)->fe_length));
-        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_flags) == 24, " found %lld\n",
+        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_flags) == 40, " found %lld\n",
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_flags));
         LASSERTF((int)sizeof(((struct ll_fiemap_extent *)0)->fe_flags) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct ll_fiemap_extent *)0)->fe_flags));
-        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_device) == 28, " found %lld\n",
+        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_device) == 44, " found %lld\n",
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_device));
         LASSERTF((int)sizeof(((struct ll_fiemap_extent *)0)->fe_device) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct ll_fiemap_extent *)0)->fe_device));
         CLASSERT(FIEMAP_EXTENT_LAST == 0x00000001);
         CLASSERT(FIEMAP_EXTENT_UNKNOWN == 0x00000002);
         CLASSERT(FIEMAP_EXTENT_DELALLOC == 0x00000004);
-        CLASSERT(FIEMAP_EXTENT_NO_DIRECT == 0x00000008);
-        CLASSERT(FIEMAP_EXTENT_SECONDARY == 0x00000010);
-        CLASSERT(FIEMAP_EXTENT_NET == 0x00000020);
-        CLASSERT(FIEMAP_EXTENT_DATA_COMPRESSED == 0x00000040);
+        CLASSERT(FIEMAP_EXTENT_ENCODED == 0x00000008);
         CLASSERT(FIEMAP_EXTENT_DATA_ENCRYPTED == 0x00000080);
         CLASSERT(FIEMAP_EXTENT_NOT_ALIGNED == 0x00000100);
         CLASSERT(FIEMAP_EXTENT_DATA_INLINE == 0x00000200);
         CLASSERT(FIEMAP_EXTENT_DATA_TAIL == 0x00000400);
         CLASSERT(FIEMAP_EXTENT_UNWRITTEN == 0x00000800);
         CLASSERT(FIEMAP_EXTENT_MERGED == 0x00001000);
-#ifdef LIBLUSTRE_POSIX_ACL
+        CLASSERT(FIEMAP_EXTENT_NO_DIRECT == 0x40000000);
+        CLASSERT(FIEMAP_EXTENT_NET == 0x80000000);
+#if defined(LIBLUSTRE_POSIX_ACL) && defined(CONFIG_FS_POSIX_ACL)
 
         /* Checks for type posix_acl_xattr_entry */
         LASSERTF((int)sizeof(xattr_acl_entry) == 8, " found %lld\n",
diff --git a/lustre/quota/Makefile.in b/lustre/quota/Makefile.in
index f052b42..50efef3 100644
--- a/lustre/quota/Makefile.in
+++ b/lustre/quota/Makefile.in
@@ -3,5 +3,7 @@ MODULES := lquota
 lquota-objs := quota_check.o quota_context.o quota_ctl.o quota_interface.o
 lquota-objs += quota_master.o quota_adjust_qunit.o lproc_quota.o
 
+EXTRA_DIST := $(lquota-objs:%.o=%.c) $(quotactl-objs:%.o=%.c) $(quotacheck-objs:%.o=%.c) quota_internal.h
+
 @INCLUDE_RULES@
 
diff --git a/lustre/quota/autoMakefile.am b/lustre/quota/autoMakefile.am
index 9a20d28..0c9bd1f 100644
--- a/lustre/quota/autoMakefile.am
+++ b/lustre/quota/autoMakefile.am
@@ -46,4 +46,3 @@ modulefs_DATA = lquota$(KMODEXT)
 endif
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
-DIST_SOURCES := $(lquota-objs:%.o=%.c) quota_internal.h
diff --git a/lustre/quota/autoMakefile.in b/lustre/quota/autoMakefile.in
index 8d22c35..51227b9 100644
--- a/lustre/quota/autoMakefile.in
+++ b/lustre/quota/autoMakefile.in
@@ -211,9 +211,9 @@ MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 
 MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -335,7 +335,6 @@ target_vendor = @target_vendor@
 @LIBLUSTRE_TRUE at libquota_a_CFLAGS = $(LLCFLAGS)
 
 @QUOTA_TRUE at modulefs_DATA = lquota$(KMODEXT)
-DIST_SOURCES := $(lquota-objs:%.o=%.c) quota_internal.h
 subdir = lustre/quota
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -364,6 +363,7 @@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(am__libquota_a_SOURCES_DIST)
 DATA = $(modulefs_DATA)
 
 DIST_COMMON = $(srcdir)/autoMakefile.in Makefile.in autoMakefile.am
diff --git a/lustre/quota/lproc_quota.c b/lustre/quota/lproc_quota.c
index bfc86f9..ee20213 100644
--- a/lustre/quota/lproc_quota.c
+++ b/lustre/quota/lproc_quota.c
@@ -411,8 +411,20 @@ int lprocfs_quota_wr_type(struct file *file, const char *buffer,
                 }
         }
 
-        if (type != 0)
-                auto_quota_on(obd, type - 1, obt->obt_sb, is_mds);
+        if (type != 0) {
+                int rc = auto_quota_on(obd, type - 1, obt->obt_sb, is_mds);
+
+                if (rc == 0)
+                        build_lqs(obd);
+                else if (rc == -ENOENT)
+                        CWARN("%s: quotaon failed because quota files don't "
+                              "exist, please run quotacheck firstly\n",
+                              obd->obd_name);
+                else if (rc == -EALREADY)
+                        CWARN("%s: quota is on already!\n", obd->obd_name);
+                else
+                        return rc;
+        }
 
         return count;
 }
@@ -762,7 +774,7 @@ int lquota_proc_cleanup(struct lustre_quota_ctxt *qctxt)
                 return -EINVAL;
 
         if (qctxt->lqc_stats != NULL)
-                 lprocfs_free_stats(&qctxt->lqc_stats);
+                lprocfs_free_stats(&qctxt->lqc_stats);
 
         lprocfs_remove(&qctxt->lqc_proc_dir);
         return 0;
diff --git a/lustre/quota/quota_adjust_qunit.c b/lustre/quota/quota_adjust_qunit.c
index 952eee5..49d487b 100644
--- a/lustre/quota/quota_adjust_qunit.c
+++ b/lustre/quota/quota_adjust_qunit.c
@@ -43,7 +43,6 @@
 # include <linux/module.h>
 # include <linux/init.h>
 # include <linux/fs.h>
-# include <linux/jbd.h>
 # include <linux/quota.h>
 #  include <linux/smp_lock.h>
 #  include <linux/buffer_head.h>
@@ -74,110 +73,41 @@
  * is_acq: whether it is acquiring; otherwise, it is releasing
  */
 void quota_compute_lqs(struct qunit_data *qdata, struct lustre_qunit_size *lqs,
-                      int is_chk, int is_acq)
+                       int is_chk, int is_acq)
 {
-        int is_blk;
+        long long *rec;
 
         LASSERT(qdata && lqs);
         LASSERT_SPIN_LOCKED(&lqs->lqs_lock);
-        is_blk = QDATA_IS_BLK(qdata);
-
-        if (is_chk) {
-                if (is_acq) {
-                        if (is_blk)
-                                lqs->lqs_blk_rec += qdata->qd_count;
-                        else
-                                lqs->lqs_ino_rec += qdata->qd_count;
-                } else {
-                        if (is_blk)
-                                lqs->lqs_blk_rec -= qdata->qd_count;
-                        else
-                                lqs->lqs_ino_rec -= qdata->qd_count;
-                }
-        } else {
-                if (is_acq) {
-                        if (is_blk)
-                                lqs->lqs_blk_rec -= qdata->qd_count;
-                        else
-                                lqs->lqs_ino_rec -= qdata->qd_count;
-                } else {
-                        if (is_blk)
-                                lqs->lqs_blk_rec += qdata->qd_count;
-                        else
-                                lqs->lqs_ino_rec += qdata->qd_count;
-                }
-        }
-}
-
-void qdata_to_oqaq(struct qunit_data *qdata, struct quota_adjust_qunit *oqaq)
-{
-        LASSERT(qdata);
-        LASSERT(oqaq);
 
-        oqaq->qaq_flags = qdata->qd_flags;
-        oqaq->qaq_id    = qdata->qd_id;
-        if (QDATA_IS_ADJBLK(qdata))
-                oqaq->qaq_bunit_sz = qdata->qd_qunit;
-        if (QDATA_IS_ADJINO(qdata))
-                oqaq->qaq_iunit_sz = qdata->qd_qunit;
-}
-
-int quota_search_lqs(struct qunit_data *qdata, struct quota_adjust_qunit *oqaq,
-                     struct lustre_quota_ctxt *qctxt,
-                     struct lustre_qunit_size **lqs_return)
-{
-        struct quota_adjust_qunit *oqaq_tmp = NULL;
-        ENTRY;
-
-        LASSERT(*lqs_return == NULL);
-        LASSERT(oqaq || qdata);
-
-        if (!oqaq) {
-                OBD_ALLOC_PTR(oqaq_tmp);
-                if (!oqaq_tmp)
-                        RETURN(-ENOMEM);
-                qdata_to_oqaq(qdata, oqaq_tmp);
-        } else {
-                oqaq_tmp = oqaq;
-        }
+        rec = QDATA_IS_BLK(qdata) ? &lqs->lqs_blk_rec : &lqs->lqs_ino_rec;
 
-        *lqs_return = lustre_hash_lookup(qctxt->lqc_lqs_hash, oqaq_tmp);
-        if (*lqs_return)
-                LQS_DEBUG((*lqs_return), "show lqs\n");
+        if (!!is_chk + !!is_acq == 1)
+                *rec -= qdata->qd_count;
+        else
+                *rec += qdata->qd_count;
 
-        if (!oqaq)
-                OBD_FREE_PTR(oqaq_tmp);
-        RETURN(0);
 }
 
-int quota_create_lqs(struct qunit_data *qdata, struct quota_adjust_qunit *oqaq,
-                     struct lustre_quota_ctxt *qctxt,
-                     struct lustre_qunit_size **lqs_return)
+static struct lustre_qunit_size *
+quota_create_lqs(unsigned long long lqs_key, struct lustre_quota_ctxt *qctxt)
 {
         struct lustre_qunit_size *lqs = NULL;
         int rc = 0;
-        ENTRY;
-
-        LASSERT(*lqs_return == NULL);
-        LASSERT(oqaq || qdata);
 
         OBD_ALLOC_PTR(lqs);
         if (!lqs)
                 GOTO(out, rc = -ENOMEM);
 
-        if (!oqaq) {
-                qdata_to_oqaq(qdata, &lqs->lqs_key);
-        } else {
-                lqs->lqs_key = *oqaq;
-        }
+        lqs->lqs_key = lqs_key;
 
         spin_lock_init(&lqs->lqs_lock);
         lqs->lqs_bwrite_pending = 0;
         lqs->lqs_iwrite_pending = 0;
         lqs->lqs_ino_rec = 0;
         lqs->lqs_blk_rec = 0;
-        lqs->lqs_id = lqs->lqs_key.qaq_id;
-        lqs->lqs_flags = QAQ_IS_GRP(&lqs->lqs_key);
+        lqs->lqs_id = LQS_KEY_ID(lqs->lqs_key);
+        lqs->lqs_flags = LQS_KEY_GRP(lqs->lqs_key) ? LQUOTA_FLAGS_GRP : 0;
         lqs->lqs_bunit_sz = qctxt->lqc_bunit_sz;
         lqs->lqs_iunit_sz = qctxt->lqc_iunit_sz;
         lqs->lqs_btune_sz = qctxt->lqc_btune_sz;
@@ -188,126 +118,150 @@ int quota_create_lqs(struct qunit_data *qdata, struct quota_adjust_qunit *oqaq,
                 lqs->lqs_last_ishrink  = 0;
         }
         lqs_initref(lqs);
-        rc = lustre_hash_add_unique(qctxt->lqc_lqs_hash,
+
+        spin_lock(&qctxt->lqc_lock);
+        if (!qctxt->lqc_valid)
+                rc = -EBUSY;
+        else
+                rc = lustre_hash_add_unique(qctxt->lqc_lqs_hash,
                                     &lqs->lqs_key, &lqs->lqs_hash);
-        LQS_DEBUG(lqs, "create lqs\n");
-        if (!rc) {
+        spin_unlock(&qctxt->lqc_lock);
+
+        if (!rc)
                 lqs_getref(lqs);
-                *lqs_return = lqs;
-        }
+
  out:
         if (rc && lqs)
                 OBD_FREE_PTR(lqs);
-        RETURN(rc);
+
+        if (rc)
+                return ERR_PTR(rc);
+        else
+                return lqs;
+}
+
+struct lustre_qunit_size *quota_search_lqs(unsigned long long lqs_key,
+                                           struct lustre_quota_ctxt *qctxt,
+                                           int create)
+{
+        struct lustre_qunit_size *lqs;
+        int rc = 0;
+
+ search_lqs:
+        lqs = lustre_hash_lookup(qctxt->lqc_lqs_hash, &lqs_key);
+        if (IS_ERR(lqs))
+                GOTO(out, rc = PTR_ERR(lqs));
+
+        if (create && lqs == NULL) {
+                /* if quota_create_lqs is successful, it will get a
+                 * ref to the lqs. The ref will be released when
+                 * qctxt_cleanup() or quota is nullified */
+                lqs = quota_create_lqs(lqs_key, qctxt);
+                if (IS_ERR(lqs))
+                        rc = PTR_ERR(lqs);
+                if (rc == -EALREADY)
+                        GOTO(search_lqs, rc = 0);
+                /* get a reference for the caller when creating lqs
+                 * successfully */
+                if (rc == 0)
+                        lqs_getref(lqs);
+        }
+
+        if (lqs && rc == 0)
+                LQS_DEBUG(lqs, "%s\n",
+                          (create == 1 ? "create lqs" : "search lqs"));
+
+ out:
+        if (rc == 0) {
+                return lqs;
+        } else {
+                CDEBUG(D_ERROR, "get lqs error(rc: %d)\n", rc);
+                return ERR_PTR(rc);
+        }
 }
 
 int quota_adjust_slave_lqs(struct quota_adjust_qunit *oqaq,
                            struct lustre_quota_ctxt *qctxt)
 {
         struct lustre_qunit_size *lqs = NULL;
-        unsigned long *lbunit, *liunit, *lbtune, *litune;
-        signed long b_tmp = 0, i_tmp = 0;
-        cfs_time_t time_limit = 0;
-        int rc = 0;
+        unsigned long *unit, *tune;
+        signed long tmp = 0;
+        cfs_time_t time_limit = 0, *shrink;
+        int i, rc = 0;
         ENTRY;
 
-        if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS))
-                RETURN(0);
-
         LASSERT(qctxt);
-search_lqs:
-        rc = quota_search_lqs(NULL, oqaq, qctxt, &lqs);
-
-        /* deleting the lqs, because a user sets lfs quota 0 0 0 0  */
-        if (!oqaq->qaq_bunit_sz && !oqaq->qaq_iunit_sz && QAQ_IS_ADJBLK(oqaq) &&
-            QAQ_IS_ADJINO(oqaq)) {
-                if (lqs) {
-                        LQS_DEBUG(lqs, "release lqs\n");
-                        /* this is for quota_search_lqs */
-                        lqs_putref(lqs);
-                        /* kill lqs */
-                        lqs_putref(lqs);
-                }
-                RETURN(rc);
+        lqs = quota_search_lqs(LQS_KEY(QAQ_IS_GRP(oqaq), oqaq->qaq_id),
+                               qctxt, QAQ_IS_CREATE_LQS(oqaq) ? 1 : 0);
+        if (lqs == NULL || IS_ERR(lqs)){
+                CDEBUG(D_ERROR, "fail to find a lqs(%s id: %u)!\n",
+                       QAQ_IS_GRP(oqaq) ? "group" : "user", oqaq->qaq_id);
+                RETURN(PTR_ERR(lqs));
         }
 
-        if (!lqs) {
-                rc = quota_create_lqs(NULL, oqaq, qctxt, &lqs);
-                if (rc == -EALREADY)
-                        goto search_lqs;
-                if (rc < 0)
-                        RETURN(rc);
+        if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS)) {
+                lqs->lqs_bunit_sz = qctxt->lqc_bunit_sz;
+                lqs->lqs_btune_sz = qctxt->lqc_btune_sz;
+                lqs->lqs_iunit_sz = qctxt->lqc_iunit_sz;
+                lqs->lqs_itune_sz = qctxt->lqc_itune_sz;
+                lqs_putref(lqs);
+                RETURN(0);
         }
 
-        lbunit = &lqs->lqs_bunit_sz;
-        liunit = &lqs->lqs_iunit_sz;
-        lbtune = &lqs->lqs_btune_sz;
-        litune = &lqs->lqs_itune_sz;
-
+        CDEBUG(D_QUOTA, "before: bunit: %lu, iunit: %lu.\n",
+               lqs->lqs_bunit_sz, lqs->lqs_iunit_sz);
         spin_lock(&lqs->lqs_lock);
-        CDEBUG(D_QUOTA, "before: bunit: %lu, iunit: %lu.\n", *lbunit, *liunit);
-        /* adjust the slave's block qunit size */
-        if (QAQ_IS_ADJBLK(oqaq)) {
-                cfs_duration_t sec = cfs_time_seconds(qctxt->lqc_switch_seconds);
-
-                b_tmp = *lbunit - oqaq->qaq_bunit_sz;
-
-                if (qctxt->lqc_handler && b_tmp > 0)
-                        lqs->lqs_last_bshrink = cfs_time_current();
-
-                if (qctxt->lqc_handler && b_tmp < 0) {
-                        time_limit = cfs_time_add(lqs->lqs_last_bshrink, sec);
-                        if (!lqs->lqs_last_bshrink ||
-                            cfs_time_after(cfs_time_current(), time_limit)) {
-                                *lbunit = oqaq->qaq_bunit_sz;
-                                *lbtune = (*lbunit) / 2;
-                        } else {
-                                b_tmp = 0;
-                        }
-                } else {
-                        *lbunit = oqaq->qaq_bunit_sz;
-                        *lbtune = (*lbunit) / 2;
+        for (i = 0; i < 2; i++) {
+                if (i == 0 && !QAQ_IS_ADJBLK(oqaq))
+                        continue;
+
+                if (i == 1 && !QAQ_IS_ADJINO(oqaq))
+                        continue;
+
+                tmp = i ? (lqs->lqs_iunit_sz - oqaq->qaq_iunit_sz) :
+                          (lqs->lqs_bunit_sz - oqaq->qaq_bunit_sz);
+                shrink = i ? &lqs->lqs_last_ishrink :
+                             &lqs->lqs_last_bshrink;
+                time_limit = cfs_time_add(i ? lqs->lqs_last_ishrink :
+                                              lqs->lqs_last_bshrink,
+                                   cfs_time_seconds(qctxt->lqc_switch_seconds));
+                unit = i ? &lqs->lqs_iunit_sz : &lqs->lqs_bunit_sz;
+                tune = i ? &lqs->lqs_itune_sz : &lqs->lqs_btune_sz;
+
+                /* quota master shrinks */
+                if (qctxt->lqc_handler && tmp > 0)
+                        *shrink = cfs_time_current();
+
+                /* quota master enlarges */
+                if (qctxt->lqc_handler && tmp < 0) {
+                        /* in case of ping-pong effect, don't enlarge lqs
+                         * in a short time */
+                        if (*shrink &&
+                            cfs_time_before(cfs_time_current(), time_limit))
+                                tmp = 0;
                 }
-        }
 
-        /* adjust the slave's file qunit size */
-        if (QAQ_IS_ADJINO(oqaq)) {
-                i_tmp = *liunit - oqaq->qaq_iunit_sz;
-
-                if (qctxt->lqc_handler && i_tmp > 0)
-                        lqs->lqs_last_ishrink  = cfs_time_current();
-
-                if (qctxt->lqc_handler && i_tmp < 0) {
-                        time_limit = cfs_time_add(lqs->lqs_last_ishrink,
-                                                  cfs_time_seconds(qctxt->
-                                                  lqc_switch_seconds));
-                        if (!lqs->lqs_last_ishrink ||
-                            cfs_time_after(cfs_time_current(), time_limit)) {
-                                *liunit = oqaq->qaq_iunit_sz;
-                                *litune = (*liunit) / 2;
-                        } else {
-                                i_tmp = 0;
-                        }
-                } else {
-                        *liunit = oqaq->qaq_iunit_sz;
-                        *litune = (*liunit) / 2;
+                /* when setquota, don't enlarge lqs b=18616 */
+                if (QAQ_IS_CREATE_LQS(oqaq) && tmp < 0)
+                        tmp = 0;
+
+                if (tmp != 0) {
+                        *unit = i ? oqaq->qaq_iunit_sz : oqaq->qaq_bunit_sz;
+                        *tune = (*unit) / 2;
                 }
+
+
+                if (tmp > 0)
+                        rc |= i ? LQS_INO_DECREASE : LQS_BLK_DECREASE;
+                if (tmp < 0)
+                        rc |= i ? LQS_INO_INCREASE : LQS_BLK_INCREASE;
         }
-        CDEBUG(D_QUOTA, "after: bunit: %lu, iunit: %lu.\n", *lbunit, *liunit);
         spin_unlock(&lqs->lqs_lock);
+        CDEBUG(D_QUOTA, "after: bunit: %lu, iunit: %lu.\n",
+               lqs->lqs_bunit_sz, lqs->lqs_iunit_sz);
 
         lqs_putref(lqs);
 
-        if (b_tmp > 0)
-                rc |= LQS_BLK_DECREASE;
-        else if (b_tmp < 0)
-                rc |= LQS_BLK_INCREASE;
-
-        if (i_tmp > 0)
-                rc |= LQS_INO_DECREASE;
-        else if (i_tmp < 0)
-                rc |= LQS_INO_INCREASE;
-
         RETURN(rc);
 }
 
@@ -334,7 +288,8 @@ int filter_quota_adjust_qunit(struct obd_export *exp,
 
         if (rc > 0) {
                 rc = qctxt_adjust_qunit(obd, qctxt, uid, gid, 1, 0, NULL);
-                if (rc == -EDQUOT || rc == -EBUSY || rc == -EAGAIN) {
+                if (rc == -EDQUOT || rc == -EBUSY ||
+                    rc == QUOTA_REQ_RETURNED || rc == -EAGAIN) {
                         CDEBUG(D_QUOTA, "rc: %d.\n", rc);
                         rc = 0;
                 }
diff --git a/lustre/quota/quota_check.c b/lustre/quota/quota_check.c
index ded26a1..74669ff 100644
--- a/lustre/quota/quota_check.c
+++ b/lustre/quota/quota_check.c
@@ -111,6 +111,7 @@ static int target_quotacheck_thread(void *data)
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
         rc = target_quotacheck_callback(exp, oqctl);
+        class_export_put(exp);
 
         atomic_inc(qta->qta_sem);
 
@@ -151,6 +152,9 @@ int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl)
                 }
         }
 
+        /* we get ref for exp because target_quotacheck_callback() will use this
+         * export later b=18126 */
+        class_export_get(exp);
         rc = kernel_thread(target_quotacheck_thread, qta, CLONE_VM|CLONE_FILES);
         if (rc >= 0) {
                 CDEBUG(D_INFO, "%s: target_quotacheck_thread: %d\n",
@@ -158,6 +162,7 @@ int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl)
                 RETURN(0);
         }
 
+        class_export_put(exp);
         CERROR("%s: error starting quotacheck_thread: %d\n",
                obd->obd_name, rc);
         OBD_FREE_PTR(qta);
diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c
index daff303..423629b 100644
--- a/lustre/quota/quota_context.c
+++ b/lustre/quota/quota_context.c
@@ -128,18 +128,12 @@ do {                                                                    \
         spin_unlock(&qunit->lq_lock);                                   \
 } while(0)
 
-
 int should_translate_quota (struct obd_import *imp)
 {
         ENTRY;
 
         LASSERT(imp);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(1, 7, 0, 0)
-        if (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_QUOTA64 &&
-            !OBD_FAIL_CHECK(OBD_FAIL_QUOTA_QD_COUNT_32BIT))
-#else
         if (imp->imp_connect_data.ocd_connect_flags & OBD_CONNECT_QUOTA64)
-#endif
                 RETURN(0);
         else
                 RETURN(1);
@@ -240,7 +234,7 @@ check_cur_qunit(struct obd_device *obd,
         int ret = 0;
         ENTRY;
 
-        if (!sb_any_quota_enabled(sb))
+        if (!ll_sb_any_quota_active(sb))
                 RETURN(0);
 
         spin_lock(&qctxt->lqc_lock);
@@ -280,17 +274,12 @@ check_cur_qunit(struct obd_device *obd,
         if (!limit)
                 GOTO(out, ret = 0);
 
- search_lqs:
-        quota_search_lqs(qdata, NULL, qctxt, &lqs);
-        if (!lqs) {
-                CDEBUG(D_QUOTA, "Can't find the lustre qunit size!\n");
-                ret = quota_create_lqs(qdata, NULL, qctxt, &lqs);
-                if (ret == -EALREADY) {
-                        ret = 0;
-                        goto search_lqs;
-                }
-                if (ret < 0)
-                        GOTO (out, ret);
+        lqs = quota_search_lqs(LQS_KEY(QDATA_IS_GRP(qdata), qdata->qd_id),
+                               qctxt, 0);
+        if (IS_ERR(lqs) || lqs == NULL) {
+                CDEBUG(D_ERROR, "fail to find a lqs(%s id: %u)!\n",
+                       QDATA_IS_GRP(qdata) ? "group" : "user", qdata->qd_id);
+                GOTO (out, ret = 0);
         }
         spin_lock(&lqs->lqs_lock);
 
@@ -342,14 +331,15 @@ check_cur_qunit(struct obd_device *obd,
                 }
         }
         CDEBUG(D_QUOTA, "type: %c, limit: "LPU64", usage: "LPU64
-               ", pending_write: "LPU64", record: "LPD64
+               ", pending_write: "LPU64", record: %llu"
                ", qunit_sz: %lu, tune_sz: %lu, ret: %d.\n",
                QDATA_IS_BLK(qdata) ? 'b' : 'i', limit, usage, pending_write,
-               record, qunit_sz, tune_sz, ret);
+               (__s64)record, qunit_sz, tune_sz, ret);
         LASSERT(ret == 0 || qdata->qd_count);
 
         spin_unlock(&lqs->lqs_lock);
         lqs_putref(lqs);
+
         EXIT;
  out:
         OBD_FREE_PTR(qctl);
@@ -366,7 +356,7 @@ int compute_remquota(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
         int ret = QUOTA_RET_OK;
         ENTRY;
 
-        if (!sb_any_quota_enabled(sb))
+        if (!ll_sb_any_quota_active(sb))
                 RETURN(QUOTA_RET_NOQUOTA);
 
         /* ignore root user */
@@ -477,10 +467,12 @@ insert_qunit_nolock(struct lustre_quota_ctxt *qctxt, struct lustre_qunit *qunit)
 
 static void compute_lqs_after_removing_qunit(struct lustre_qunit *qunit)
 {
-        struct lustre_qunit_size *lqs = NULL;
+        struct lustre_qunit_size *lqs;
 
-        quota_search_lqs(&qunit->lq_data, NULL, qunit->lq_ctxt, &lqs);
-        if (lqs) {
+        lqs = quota_search_lqs(LQS_KEY(QDATA_IS_GRP(&qunit->lq_data),
+                                       qunit->lq_data.qd_id),
+                               qunit->lq_ctxt, 0);
+        if (lqs && !IS_ERR(lqs)) {
                 spin_lock(&lqs->lqs_lock);
                 if (qunit->lq_opc == QUOTA_DQACQ)
                         quota_compute_lqs(&qunit->lq_data, lqs, 0, 1);
@@ -492,7 +484,6 @@ static void compute_lqs_after_removing_qunit(struct lustre_qunit *qunit)
                 /* this is for schedule_dqacq */
                 lqs_putref(lqs);
         }
-
 }
 
 static void remove_qunit_nolock(struct lustre_qunit *qunit)
@@ -505,6 +496,70 @@ static void remove_qunit_nolock(struct lustre_qunit *qunit)
         qunit_put(qunit);
 }
 
+void* quota_barrier(struct lustre_quota_ctxt *qctxt,
+                    struct obd_quotactl *oqctl, int isblk)
+{
+        struct lustre_qunit *qunit, *find_qunit;
+        int cycle = 1;
+
+        OBD_SLAB_ALLOC(qunit, qunit_cachep, CFS_ALLOC_IO, sizeof(*qunit));
+        if (qunit == NULL) {
+                CERROR("locating qunit failed.(id=%u isblk=%d %s)\n",
+                       oqctl->qc_id, isblk, oqctl->qc_type ? "grp" : "usr");
+                qctxt_wait_pending_dqacq(qctxt, oqctl->qc_id,
+                                         oqctl->qc_type, isblk);
+                return NULL;
+        }
+
+        INIT_LIST_HEAD(&qunit->lq_hash);
+        qunit->lq_lock = SPIN_LOCK_UNLOCKED;
+        init_waitqueue_head(&qunit->lq_waitq);
+        atomic_set(&qunit->lq_refcnt, 1);
+        qunit->lq_ctxt = qctxt;
+        qunit->lq_data.qd_id = oqctl->qc_id;
+        qunit->lq_data.qd_flags =  oqctl->qc_type;
+        if (isblk)
+                QDATA_SET_BLK(&qunit->lq_data);
+        QUNIT_SET_STATE_AND_RC(qunit, QUNIT_CREATED, 0);
+        /* it means it is only an invalid qunit for barrier */
+        qunit->lq_opc = QUOTA_LAST_OPC;
+
+        while (1) {
+                spin_lock(&qunit_hash_lock);
+                find_qunit = dqacq_in_flight(qctxt, &qunit->lq_data);
+                if (find_qunit) {
+                        spin_unlock(&qunit_hash_lock);
+                        qunit_put(find_qunit);
+                        qctxt_wait_pending_dqacq(qctxt, oqctl->qc_id,
+                                                 oqctl->qc_type, isblk);
+                        CDEBUG(D_QUOTA, "cycle=%d\n", cycle++);
+                        continue;
+                }
+                break;
+        }
+        insert_qunit_nolock(qctxt, qunit);
+        spin_unlock(&qunit_hash_lock);
+        return qunit;
+}
+
+void quota_unbarrier(void *handle)
+{
+        struct lustre_qunit *qunit = (struct lustre_qunit *)handle;
+
+        if (qunit == NULL) {
+                CERROR("handle is NULL\n");
+                return;
+        }
+
+        LASSERT(qunit->lq_opc == QUOTA_LAST_OPC);
+        spin_lock(&qunit_hash_lock);
+        remove_qunit_nolock(qunit);
+        spin_unlock(&qunit_hash_lock);
+        QUNIT_SET_STATE_AND_RC(qunit, QUNIT_FINISHED, QUOTA_REQ_RETURNED);
+        wake_up(&qunit->lq_waitq);
+        qunit_put(qunit);
+}
+
 #define INC_QLIMIT(limit, count) (limit == MIN_QLIMIT) ? \
                                  (limit = count) : (limit += count)
 
@@ -522,54 +577,18 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
                struct qunit_data *qdata, int opc, int wait,
                struct obd_trans_info *oti);
 
-static int split_before_schedule_dqacq(struct obd_device *obd,
-                                       struct lustre_quota_ctxt *qctxt,
-                                       struct qunit_data *qdata, int opc,
-                                       int wait, struct obd_trans_info *oti)
+static inline void qdata_to_oqaq(struct qunit_data *qdata,
+                                 struct quota_adjust_qunit *oqaq)
 {
-        int rc = 0;
-        unsigned long factor;
-        struct qunit_data tmp_qdata;
-        struct timeval    work_start;
-        struct timeval    work_end;
-        long              timediff;
-        ENTRY;
-
-        LASSERT(qdata && qdata->qd_count);
-        LASSERT(opc == QUOTA_DQACQ || opc == QUOTA_DQREL);
-        do_gettimeofday(&work_start);
-        QDATA_DEBUG(qdata, "%s quota split.\n",
-                    QDATA_IS_BLK(qdata) ? "block" : "inode");
-        if (QDATA_IS_BLK(qdata))
-                factor = MAX_QUOTA_COUNT32 / qctxt->lqc_bunit_sz *
-                        qctxt->lqc_bunit_sz;
-        else
-                factor = MAX_QUOTA_COUNT32 / qctxt->lqc_iunit_sz *
-                        qctxt->lqc_iunit_sz;
-
-        if (qctxt->lqc_import && should_translate_quota(qctxt->lqc_import) &&
-            qdata->qd_count > factor) {
-                tmp_qdata = *qdata;
-                tmp_qdata.qd_count = factor;
-                qdata->qd_count -= tmp_qdata.qd_count;
-                QDATA_DEBUG((&tmp_qdata), "be split.\n");
-                rc = schedule_dqacq(obd, qctxt, &tmp_qdata, opc, wait, oti);
-        } else{
-                QDATA_DEBUG(qdata, "don't be split.\n");
-                rc = schedule_dqacq(obd, qctxt, qdata, opc, wait, oti);
-        }
-        do_gettimeofday(&work_end);
-        timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
-        if (opc == QUOTA_DQACQ)
-                lprocfs_counter_add(qctxt->lqc_stats,
-                                    wait ? LQUOTA_SYNC_ACQ : LQUOTA_ASYNC_ACQ,
-                                    timediff);
-        else
-                lprocfs_counter_add(qctxt->lqc_stats,
-                                    wait ? LQUOTA_SYNC_REL : LQUOTA_ASYNC_REL,
-                                    timediff);
-
-        RETURN(rc);
+        LASSERT(qdata);
+        LASSERT(oqaq);
+
+        oqaq->qaq_flags = qdata->qd_flags;
+        oqaq->qaq_id    = qdata->qd_id;
+        if (QDATA_IS_ADJBLK(qdata))
+                oqaq->qaq_bunit_sz = qdata->qd_qunit;
+        if (QDATA_IS_ADJINO(qdata))
+                oqaq->qaq_iunit_sz = qdata->qd_qunit;
 }
 
 static int
@@ -587,6 +606,10 @@ dqacq_completion(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
         QDATA_DEBUG(qdata, "obd(%s): complete %s quota req\n",
                     obd->obd_name, (opc == QUOTA_DQACQ) ? "acq" : "rel");
 
+        /* do it only when a releasing quota req more than 5MB b=18491 */
+        if (opc == QUOTA_DQREL && qdata->qd_count >= 5242880)
+                OBD_FAIL_TIMEOUT(OBD_FAIL_QUOTA_DELAY_REL, 5);
+
         /* update local operational quota file */
         if (rc == 0) {
                 __u64 count = QUSG(qdata->qd_count, QDATA_IS_BLK(qdata));
@@ -682,8 +705,11 @@ out:
 
         compute_lqs_after_removing_qunit(qunit);
 
-        /* wake up all waiters */
+
+        if (rc == 0)
+                rc = QUOTA_REQ_RETURNED;
         QUNIT_SET_STATE_AND_RC(qunit, QUNIT_FINISHED, rc);
+        /* wake up all waiters */
         wake_up(&qunit->lq_waitq);
 
         /* this is for dqacq_in_flight() */
@@ -710,10 +736,13 @@ out:
                  CERROR("adjust slave's qunit size failed!(rc:%d)\n", rc1);
                  RETURN(rc1);
          }
-         if (err || (rc && rc != -EBUSY && rc1 == 0) ||
+         if (err || (rc < 0 && rc != -EBUSY && rc1 == 0) ||
              is_master(obd, qctxt, qdata->qd_id, QDATA_IS_GRP(qdata)))
                 RETURN(err);
 
+         if (opc == QUOTA_DQREL && qdata->qd_count >= 5242880)
+                 OBD_FAIL_RETURN(OBD_FAIL_QUOTA_DELAY_REL, err);
+
         /* reschedule another dqacq/dqrel if needed */
         qdata->qd_count = 0;
         qdata->qd_flags &= LQUOTA_QUNIT_FLAGS;
@@ -721,8 +750,7 @@ out:
         if (rc1 > 0) {
                 int opc;
                 opc = rc1 == 1 ? QUOTA_DQACQ : QUOTA_DQREL;
-                rc1 = split_before_schedule_dqacq(obd, qctxt, qdata, opc,
-                                                  0, NULL);
+                rc1 = schedule_dqacq(obd, qctxt, qdata, opc, 0, NULL);
                 QDATA_DEBUG(qdata, "reschedudle opc(%d) rc(%d)\n", opc, rc1);
         }
         RETURN(err);
@@ -816,25 +844,58 @@ int check_qm(struct lustre_quota_ctxt *qctxt)
         RETURN(rc);
 }
 
-static int got_qunit(struct lustre_qunit *qunit)
+/* wake up all waiting threads when lqc_import is NULL */
+void dqacq_interrupt(struct lustre_quota_ctxt *qctxt)
 {
-        int rc;
+        struct lustre_qunit *qunit, *tmp;
+        int i;
+        ENTRY;
+
+        spin_lock(&qunit_hash_lock);
+        for (i = 0; i < NR_DQHASH; i++) {
+                list_for_each_entry_safe(qunit, tmp, &qunit_hash[i], lq_hash) {
+                        if (qunit->lq_ctxt != qctxt)
+                                continue;
+
+                        /* Wake up all waiters. Do not change lq_state.
+                         * The waiters will check lq_rc which is kept as 0
+                         * if no others change it, then the waiters will return
+                         * -EAGAIN to caller who can perform related quota
+                         * acq/rel if necessary. */
+                        wake_up_all(&qunit->lq_waitq);
+                }
+        }
+        spin_unlock(&qunit_hash_lock);
+        EXIT;
+}
+
+static int got_qunit(struct lustre_qunit *qunit, int is_master)
+{
+        struct lustre_quota_ctxt *qctxt = qunit->lq_ctxt;
+        int rc = 0;
         ENTRY;
 
         spin_lock(&qunit->lq_lock);
         switch (qunit->lq_state) {
         case QUNIT_IN_HASH:
         case QUNIT_RM_FROM_HASH:
-                rc = 0;
                 break;
         case QUNIT_FINISHED:
                 rc = 1;
                 break;
         default:
-                rc = 0;
                 CERROR("invalid qunit state %d\n", qunit->lq_state);
         }
         spin_unlock(&qunit->lq_lock);
+
+        if (!rc) {
+                spin_lock(&qctxt->lqc_lock);
+                rc = !qctxt->lqc_valid;
+                if (!is_master)
+                        rc |= !qctxt->lqc_import;
+                spin_unlock(&qctxt->lqc_lock);
+        }
+
         RETURN(rc);
 }
 
@@ -849,11 +910,16 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
         struct dqacq_async_args *aa;
         int size[2] = { sizeof(struct ptlrpc_body), 0 };
         struct obd_import *imp = NULL;
-        unsigned long factor;
         struct lustre_qunit_size *lqs = NULL;
+        struct timeval work_start;
+        struct timeval work_end;
+        long timediff;
+        int ismaster = is_master(obd, qctxt, qdata->qd_id, QDATA_IS_GRP(qdata));
         int rc = 0;
         ENTRY;
 
+        LASSERT(opc == QUOTA_DQACQ || opc == QUOTA_DQREL);
+        do_gettimeofday(&work_start);
         if ((empty = alloc_qunit(qctxt, qdata, opc)) == NULL)
                 RETURN(-ENOMEM);
 
@@ -870,8 +936,9 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
         insert_qunit_nolock(qctxt, qunit);
         spin_unlock(&qunit_hash_lock);
 
-        quota_search_lqs(qdata, NULL, qctxt, &lqs);
-        if (lqs) {
+        lqs = quota_search_lqs(LQS_KEY(QDATA_IS_GRP(qdata), qdata->qd_id),
+                               qctxt, 0);
+        if (lqs && !IS_ERR(lqs)) {
                 spin_lock(&lqs->lqs_lock);
                 quota_compute_lqs(qdata, lqs, 1, (opc == QUOTA_DQACQ) ? 1 : 0);
                 /* when this qdata returned from mds, it will call lqs_putref */
@@ -886,7 +953,7 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
         QDATA_DEBUG(qdata, "obd(%s): send %s quota req\n",
                     obd->obd_name, (opc == QUOTA_DQACQ) ? "acq" : "rel");
         /* master is going to dqacq/dqrel from itself */
-        if (is_master(obd, qctxt, qdata->qd_id, QDATA_IS_GRP(qdata))) {
+        if (ismaster) {
                 int rc2;
                 QDATA_DEBUG(qdata, "local %s.\n",
                             opc == QUOTA_DQACQ ? "DQACQ" : "DQREL");
@@ -895,6 +962,17 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
                 rc2 = dqacq_completion(obd, qctxt, qdata, rc, opc);
                 /* this is for qunit_get() */
                 qunit_put(qunit);
+
+                do_gettimeofday(&work_end);
+                timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
+                if (opc == QUOTA_DQACQ)
+                        lprocfs_counter_add(qctxt->lqc_stats,
+                                            wait ? LQUOTA_SYNC_ACQ : LQUOTA_ASYNC_ACQ,
+                                            timediff);
+                else
+                        lprocfs_counter_add(qctxt->lqc_stats,
+                                            wait ? LQUOTA_SYNC_REL : LQUOTA_ASYNC_REL,
+                                            timediff);
                 RETURN(rc ? rc : rc2);
         }
 
@@ -928,7 +1006,8 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
                         l_wait_event(qctxt->lqc_wait_for_qmaster,
                                      check_qm(qctxt), &lwi);
                         CDEBUG(D_QUOTA, "wake up when quota master is back\n");
-                        lc_watchdog_touch(oti->oti_thread->t_watchdog);
+                        lc_watchdog_touch(oti->oti_thread->t_watchdog,
+                                 GET_TIMEOUT(oti->oti_thread->t_svc));
                 } else {
                         spin_unlock(&qctxt->lqc_lock);
                 }
@@ -953,16 +1032,6 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
                 RETURN(-ENOMEM);
         }
 
-        if (QDATA_IS_BLK(qdata))
-                factor = MAX_QUOTA_COUNT32 / qctxt->lqc_bunit_sz *
-                        qctxt->lqc_bunit_sz;
-        else
-                factor = MAX_QUOTA_COUNT32 / qctxt->lqc_iunit_sz *
-                        qctxt->lqc_iunit_sz;
-
-        LASSERTF(!should_translate_quota(imp) || qdata->qd_count <= factor,
-                 "qd_count: "LPU64"; should_translate_quota: %d.\n",
-                 qdata->qd_count, should_translate_quota(imp));
         rc = quota_copy_qdata(req, qdata, QUOTA_REQUEST, QUOTA_IMPORT);
         if (rc < 0) {
                 CDEBUG(D_ERROR, "Can't pack qunit_data(rc: %d)\n", rc);
@@ -972,13 +1041,12 @@ schedule_dqacq(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
                 qunit_put(qunit);
                 RETURN(rc);
         }
-
         ptlrpc_req_set_repsize(req, 2, size);
         req->rq_no_resend = req->rq_no_delay = 1;
         class_import_put(imp);
 
         CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
-        aa = (struct dqacq_async_args *)&req->rq_async_args;
+        aa = ptlrpc_req_async_args(req);
         aa->aa_ctxt = qctxt;
         aa->aa_qunit = qunit;
 
@@ -992,22 +1060,32 @@ wait_completion:
                 struct qunit_data *p = &qunit->lq_data;
 
                 QDATA_DEBUG(p, "qunit(%p) is waiting for dqacq.\n", qunit);
-                l_wait_event(qunit->lq_waitq, got_qunit(qunit), &lwi);
-                /* rc = -EAGAIN, it means a quota req is finished;
+                l_wait_event(qunit->lq_waitq, got_qunit(qunit, ismaster), &lwi);
+                /* rc = -EAGAIN, it means the quota master isn't ready yet
+                 * rc = QUOTA_REQ_RETURNED, it means a quota req is finished;
                  * rc = -EDQUOT, it means out of quota
                  * rc = -EBUSY, it means recovery is happening
                  * other rc < 0, it means real errors, functions who call
                  * schedule_dqacq should take care of this */
                 spin_lock(&qunit->lq_lock);
-                if (qunit->lq_rc == 0)
-                        rc = -EAGAIN;
-                else
-                        rc = qunit->lq_rc;
+                rc = qunit->lq_rc;
                 spin_unlock(&qunit->lq_lock);
                 CDEBUG(D_QUOTA, "qunit(%p) finishes waiting. (rc:%d)\n",
                        qunit, rc);
         }
+
         qunit_put(qunit);
+        do_gettimeofday(&work_end);
+        timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
+        if (opc == QUOTA_DQACQ)
+                lprocfs_counter_add(qctxt->lqc_stats,
+                                    wait ? LQUOTA_SYNC_ACQ : LQUOTA_ASYNC_ACQ,
+                                    timediff);
+        else
+                lprocfs_counter_add(qctxt->lqc_stats,
+                                    wait ? LQUOTA_SYNC_REL : LQUOTA_ASYNC_REL,
+                                    timediff);
+
         RETURN(rc);
 }
 
@@ -1021,8 +1099,7 @@ qctxt_adjust_qunit(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
         struct qunit_data qdata[MAXQUOTAS];
         ENTRY;
 
-        CLASSERT(MAXQUOTAS < 4);
-        if (!sb_any_quota_enabled(qctxt->lqc_sb))
+        if (quota_is_set(obd, uid, gid, isblk ? QB_SET : QI_SET) == 0)
                 RETURN(0);
 
         for (i = 0; i < MAXQUOTAS; i++) {
@@ -1037,8 +1114,8 @@ qctxt_adjust_qunit(struct obd_device *obd, struct lustre_quota_ctxt *qctxt,
                         int opc;
                         /* need acquire or release */
                         opc = rc == 1 ? QUOTA_DQACQ : QUOTA_DQREL;
-                        rc = split_before_schedule_dqacq(obd, qctxt, &qdata[i],
-                                                         opc, wait, oti);
+                        rc = schedule_dqacq(obd, qctxt, &qdata[i], opc,
+                                            wait,oti);
                         if (rc < 0)
                                 RETURN(rc);
                 } else if (wait == 1) {
@@ -1063,6 +1140,7 @@ qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id,
         struct timeval work_end;
         long timediff;
         struct l_wait_info lwi = { 0 };
+        int ismaster = is_master(NULL, qctxt, id, type);
         int rc = 0;
         ENTRY;
 
@@ -1081,15 +1159,12 @@ qctxt_wait_pending_dqacq(struct lustre_quota_ctxt *qctxt, unsigned int id,
                 struct qunit_data *p = &qunit->lq_data;
 
                 QDATA_DEBUG(p, "qunit(%p) is waiting for dqacq.\n", qunit);
-                l_wait_event(qunit->lq_waitq, got_qunit(qunit), &lwi);
+                l_wait_event(qunit->lq_waitq, got_qunit(qunit, ismaster), &lwi);
                 CDEBUG(D_QUOTA, "qunit(%p) finishes waiting. (rc:%d)\n",
                        qunit, qunit->lq_rc);
                 /* keep same as schedule_dqacq() b=17030 */
                 spin_lock(&qunit->lq_lock);
-                if (qunit->lq_rc == 0)
-                        rc = -EAGAIN;
-                else
-                        rc = qunit->lq_rc;
+                rc = qunit->lq_rc;
                 spin_unlock(&qunit->lq_lock);
                 /* this is for dqacq_in_flight() */
                 qunit_put(qunit);
@@ -1126,6 +1201,8 @@ qctxt_init(struct obd_device *obd, dqacq_handler_t handler)
                 RETURN(rc);
 
         cfs_waitq_init(&qctxt->lqc_wait_for_qmaster);
+        cfs_waitq_init(&qctxt->lqc_lqs_waitq);
+        atomic_set(&qctxt->lqc_lqs, 0);
         spin_lock_init(&qctxt->lqc_lock);
         spin_lock(&qctxt->lqc_lock);
         qctxt->lqc_handler = handler;
@@ -1149,7 +1226,9 @@ qctxt_init(struct obd_device *obd, dqacq_handler_t handler)
         qctxt->lqc_sync_blk = 0;
         spin_unlock(&qctxt->lqc_lock);
 
-        qctxt->lqc_lqs_hash = lustre_hash_init("LQS_HASH", 7, 7,
+        qctxt->lqc_lqs_hash = lustre_hash_init("LQS_HASH",
+                                               HASH_LQS_CUR_BITS,
+                                               HASH_LQS_MAX_BITS,
                                                &lqs_hash_ops, 0);
         if (!qctxt->lqc_lqs_hash)
                 CERROR("initialize hash lqs for %s error!\n", obd->obd_name);
@@ -1162,10 +1241,27 @@ qctxt_init(struct obd_device *obd, dqacq_handler_t handler)
         RETURN(rc);
 }
 
+static int check_lqs(struct lustre_quota_ctxt *qctxt)
+{
+        int rc;
+        ENTRY;
+
+        rc = !atomic_read(&qctxt->lqc_lqs);
+
+        RETURN(rc);
+}
+
+
+void hash_put_lqs(void *obj, void *data)
+{
+        lqs_putref((struct lustre_qunit_size *)obj);
+}
+
 void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force)
 {
         struct lustre_qunit *qunit, *tmp;
         struct list_head tmp_list;
+        struct l_wait_info lwi = { 0 };
         int i;
         ENTRY;
 
@@ -1196,8 +1292,6 @@ void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force)
                 qunit_put(qunit);
         }
 
-        lustre_hash_exit(qctxt->lqc_lqs_hash);
-
         /* after qctxt_cleanup, qctxt might be freed, then check_qm() is
          * unpredicted. So we must wait until lqc_wait_for_qmaster is empty */
         while (cfs_waitq_active(&qctxt->lqc_wait_for_qmaster)) {
@@ -1206,6 +1300,10 @@ void qctxt_cleanup(struct lustre_quota_ctxt *qctxt, int force)
                                      cfs_time_seconds(1));
         }
 
+        lustre_hash_for_each_safe(qctxt->lqc_lqs_hash, hash_put_lqs, NULL);
+        l_wait_event(qctxt->lqc_lqs_waitq, check_lqs(qctxt), &lwi);
+        lustre_hash_exit(qctxt->lqc_lqs_hash);
+
         ptlrpcd_decref();
 
 #ifdef LPROCFS
@@ -1248,7 +1346,7 @@ static int qslave_recovery_main(void *arg)
                 int ret;
 
                 LOCK_DQONOFF_MUTEX(dqopt);
-                if (!sb_has_quota_enabled(qctxt->lqc_sb, type)) {
+                if (!ll_sb_has_quota_active(qctxt->lqc_sb, type)) {
                         UNLOCK_DQONOFF_MUTEX(dqopt);
                         break;
                 }
@@ -1281,9 +1379,8 @@ static int qslave_recovery_main(void *arg)
                         if (ret > 0) {
                                 int opc;
                                 opc = ret == 1 ? QUOTA_DQACQ : QUOTA_DQREL;
-                                rc = split_before_schedule_dqacq(obd, qctxt,
-                                                                 &qdata, opc,
-                                                                 0, NULL);
+                                rc = schedule_dqacq(obd, qctxt, &qdata, opc,
+                                                    0, NULL);
                                 if (rc == -EDQUOT)
                                         rc = 0;
                         } else {
@@ -1295,7 +1392,7 @@ static int qslave_recovery_main(void *arg)
                                        "qslave recovery failed! (id:%d type:%d "
                                        " rc:%d)\n", dqid->di_id, type, rc);
 free:
-                        kfree(dqid);
+                        OBD_FREE_PTR(dqid);
                 }
         }
 
@@ -1310,7 +1407,7 @@ qslave_start_recovery(struct obd_device *obd, struct lustre_quota_ctxt *qctxt)
         int rc;
         ENTRY;
 
-        if (!sb_any_quota_enabled(qctxt->lqc_sb))
+        if (!ll_sb_any_quota_active(qctxt->lqc_sb))
                 goto exit;
 
         data.obd = obd;
@@ -1350,18 +1447,15 @@ lqs_hash(lustre_hash_t *lh, void *key, unsigned mask)
 static int
 lqs_compare(void *key, struct hlist_node *hnode)
 {
-        struct quota_adjust_qunit *lqs_key;
         struct lustre_qunit_size *q;
         int rc;
         ENTRY;
 
         LASSERT(key);
-        lqs_key = (struct quota_adjust_qunit *)key;
         q = hlist_entry(hnode, struct lustre_qunit_size, lqs_hash);
 
         spin_lock(&q->lqs_lock);
-        rc = ((lqs_key->qaq_id == q->lqs_id) &&
-              (QAQ_IS_GRP(lqs_key) == LQS_IS_GRP(q)));
+        rc = (q->lqs_key == *((unsigned long long *)key));
         spin_unlock(&q->lqs_lock);
 
         RETURN(rc);
@@ -1370,11 +1464,12 @@ lqs_compare(void *key, struct hlist_node *hnode)
 static void *
 lqs_get(struct hlist_node *hnode)
 {
-        struct lustre_qunit_size *q = 
+        struct lustre_qunit_size *q =
             hlist_entry(hnode, struct lustre_qunit_size, lqs_hash);
         ENTRY;
 
-        atomic_inc(&q->lqs_refcount);
+        if (atomic_inc_return(&q->lqs_refcount) == 2) /* quota_search_lqs */
+                atomic_inc(&q->lqs_ctxt->lqc_lqs);
         CDEBUG(D_QUOTA, "lqs=%p refcount %d\n",
                q, atomic_read(&q->lqs_refcount));
 
@@ -1384,12 +1479,16 @@ lqs_get(struct hlist_node *hnode)
 static void *
 lqs_put(struct hlist_node *hnode)
 {
-        struct lustre_qunit_size *q = 
+        struct lustre_qunit_size *q =
             hlist_entry(hnode, struct lustre_qunit_size, lqs_hash);
         ENTRY;
 
         LASSERT(atomic_read(&q->lqs_refcount) > 0);
-        atomic_dec(&q->lqs_refcount);
+
+        if (atomic_dec_return(&q->lqs_refcount) == 1)
+                if (atomic_dec_and_test(&q->lqs_ctxt->lqc_lqs))
+                        cfs_waitq_signal(&q->lqs_ctxt->lqc_lqs_waitq);
+
         CDEBUG(D_QUOTA, "lqs=%p refcount %d\n",
                q, atomic_read(&q->lqs_refcount));
 
@@ -1403,12 +1502,12 @@ lqs_exit(struct hlist_node *hnode)
         ENTRY;
 
         q = hlist_entry(hnode, struct lustre_qunit_size, lqs_hash);
-        /* 
+        /*
          * Nothing should be left. User of lqs put it and
          * lqs also was deleted from table by this time
          * so we should have 0 refs.
          */
-        LASSERTF(atomic_read(&q->lqs_refcount) == 0, 
+        LASSERTF(atomic_read(&q->lqs_refcount) == 0,
                  "Busy lqs %p with %d refs\n", q,
                  atomic_read(&q->lqs_refcount));
         OBD_FREE_PTR(q);
diff --git a/lustre/quota/quota_ctl.c b/lustre/quota/quota_ctl.c
index b7e4aee..5397b94 100644
--- a/lustre/quota/quota_ctl.c
+++ b/lustre/quota/quota_ctl.c
@@ -43,7 +43,6 @@
 # include <linux/module.h>
 # include <linux/init.h>
 # include <linux/fs.h>
-# include <linux/jbd.h>
 # include <linux/quota.h>
 #  include <linux/smp_lock.h>
 #  include <linux/buffer_head.h>
@@ -64,6 +63,57 @@
 
 #ifdef HAVE_QUOTA_SUPPORT
 #ifdef __KERNEL__
+
+/* When quotaon, build a lqs for every uid/gid who has been set limitation
+ * for quota. After quota_search_lqs, it will hold one ref for the lqs.
+ * It will be released when qctxt_cleanup() is executed b=18574 */
+void build_lqs(struct obd_device *obd)
+{
+        struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
+        struct list_head id_list;
+        int i, rc;
+
+        INIT_LIST_HEAD(&id_list);
+        for (i = 0; i < MAXQUOTAS; i++) {
+                struct dquot_id *dqid, *tmp;
+
+                if (sb_dqopt(qctxt->lqc_sb)->files[i] == NULL)
+                        continue;
+
+#ifndef KERNEL_SUPPORTS_QUOTA_READ
+                rc = fsfilt_qids(obd, sb_dqopt(qctxt->lqc_sb)->files[i], NULL,
+                                 i, &id_list);
+#else
+                rc = fsfilt_qids(obd, NULL, sb_dqopt(qctxt->lqc_sb)->files[i],
+                                 i, &id_list);
+#endif
+                if (rc) {
+                        CDEBUG(D_ERROR, "fail to get %s qids!\n",
+                               i ? "group" : "user");
+                        continue;
+                }
+
+                list_for_each_entry_safe(dqid, tmp, &id_list,
+                                         di_link) {
+                        struct lustre_qunit_size *lqs;
+
+                        list_del_init(&dqid->di_link);
+                        lqs = quota_search_lqs(LQS_KEY(i, dqid->di_id),
+                                               qctxt, 1);
+                        if (lqs && !IS_ERR(lqs)) {
+                                lqs->lqs_flags |= dqid->di_flag;
+                                lqs_putref(lqs);
+                        } else {
+                                CDEBUG(D_ERROR, "fail to create a lqs"
+                                       "(%s id: %u)!\n", i ? "group" : "user",
+                                       dqid->di_id);
+                        }
+
+                        OBD_FREE_PTR(dqid);
+                }
+        }
+}
+
 int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
 {
         struct obd_device *obd = exp->exp_obd;
@@ -80,6 +130,8 @@ int mds_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
         case Q_QUOTAON:
                 oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
                 rc = mds_quota_on(obd, oqctl);
+                /* when quotaon, create lqs for every quota uid/gid b=18574 */
+                build_lqs(obd);
                 break;
         case Q_QUOTAOFF:
                 oqctl->qc_id = obt->obt_qfmt; /* override qfmt version */
@@ -131,6 +183,8 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
         struct obd_device_target *obt = &obd->u.obt;
         struct lvfs_run_ctxt saved;
         struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
+        struct lustre_qunit_size *lqs;
+        void *handle = NULL;
         struct timeval work_start;
         struct timeval work_end;
         long timediff;
@@ -150,6 +204,7 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                 }
                 if (oqctl->qc_cmd == Q_FINVALIDATE &&
                     (obt->obt_qctxt.lqc_flags & UGQUOTA2LQC(oqctl->qc_type))) {
+                        atomic_inc(&obt->obt_quotachecking);
                         rc = -EBUSY;
                         break;
                 }
@@ -162,14 +217,15 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                  * on master enter recovery mode. We must wait for this 
                  * dqacq/dqrel done then return the correct limits to master */
                 if (oqctl->qc_stat == QUOTA_RECOVERING)
-                        qctxt_wait_pending_dqacq(&obd->u.obt.obt_qctxt,
-                                                 oqctl->qc_id, oqctl->qc_type, 
-                                                 1);
+                        handle = quota_barrier(&obd->u.obt.obt_qctxt, oqctl, 1);
 
                 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                 rc = fsfilt_quotactl(obd, obt->obt_sb, oqctl);
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
+                if (oqctl->qc_stat == QUOTA_RECOVERING)
+                        quota_unbarrier(handle);
+
                 if (oqctl->qc_cmd == Q_QUOTAON || oqctl->qc_cmd == Q_QUOTAOFF ||
                     oqctl->qc_cmd == Q_FINVALIDATE) {
                         if (!rc && oqctl->qc_cmd == Q_QUOTAON)
@@ -178,11 +234,14 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                                 obt->obt_qctxt.lqc_flags &= ~UGQUOTA2LQC(oqctl->qc_type);
                         atomic_inc(&obt->obt_quotachecking);
                 }
+
+                /* when quotaon, create lqs for every quota uid/gid b=18574 */
+                if (oqctl->qc_cmd == Q_QUOTAON)
+                        build_lqs(obd);
                 break;
         case Q_SETQUOTA:
                 /* currently, it is only used for nullifying the quota */
-                qctxt_wait_pending_dqacq(&obd->u.obt.obt_qctxt,
-                                         oqctl->qc_id, oqctl->qc_type, 1);
+                handle = quota_barrier(&obd->u.obt.obt_qctxt, oqctl, 1);
 
                 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                 rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
@@ -193,6 +252,17 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                         oqctl->qc_cmd = Q_SETQUOTA;
                 }
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+                quota_unbarrier(handle);
+
+                lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
+                                       qctxt, 0);
+                if (lqs == NULL || IS_ERR(lqs)){
+                        CDEBUG(D_ERROR, "fail to create lqs when setquota\n");
+                } else {
+                        lqs->lqs_flags &= ~QB_SET;
+                        lqs_putref(lqs);
+                }
+
                 break;
         case Q_INITQUOTA:
                 {
@@ -202,15 +272,13 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                 LASSERT(oqctl->qc_dqblk.dqb_valid == QIF_BLIMITS);
                 LASSERT(oqctl->qc_dqblk.dqb_bsoftlimit == 0);
 
-                /* There might be a pending dqacq/dqrel (which is going to
-                 * clear stale limits on slave). we should wait for it's
-                 * completion then initialize limits */
-                qctxt_wait_pending_dqacq(&obd->u.obt.obt_qctxt,
-                                         oqctl->qc_id, oqctl->qc_type, 1);
-
                 if (!oqctl->qc_dqblk.dqb_bhardlimit)
                         goto adjust;
 
+               /* There might be a pending dqacq/dqrel (which is going to
+                 * clear stale limits on slave). we should wait for it's
+                 * completion then initialize limits */
+                handle = quota_barrier(&obd->u.obt.obt_qctxt, oqctl, 1);
                 LASSERT(oqctl->qc_dqblk.dqb_bhardlimit == MIN_QLIMIT);
                 push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                 rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, oqctl);
@@ -223,10 +291,27 @@ int filter_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                         oqctl->qc_cmd = Q_INITQUOTA;
                 }
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+                quota_unbarrier(handle);
 
                 if (rc)
                         RETURN(rc);
 adjust:
+                lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
+                                       qctxt, 1);
+                if (lqs == NULL || IS_ERR(lqs)){
+                        CDEBUG(D_ERROR, "fail to create lqs when setquota\n");
+                        break;
+                } else {
+                        lqs->lqs_flags |= QB_SET;
+                        if (OBD_FAIL_CHECK(OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS)) {
+                                lqs->lqs_bunit_sz = qctxt->lqc_bunit_sz;
+                                lqs->lqs_btune_sz = qctxt->lqc_btune_sz;
+                                lqs->lqs_iunit_sz = qctxt->lqc_iunit_sz;
+                                lqs->lqs_itune_sz = qctxt->lqc_itune_sz;
+                        }
+                        lqs_putref(lqs);
+                }
+
                 /* Trigger qunit pre-acquire */
                 if (oqctl->qc_type == USRQUOTA)
                         uid = oqctl->qc_id;
@@ -324,6 +409,7 @@ int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                 RETURN(-EFAULT);
         }
 
+        obd_getref(obd);
         for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                 int err;
 
@@ -349,6 +435,7 @@ int lov_quota_ctl(struct obd_export *exp, struct obd_quotactl *oqctl)
                         bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit;
                 }
         }
+        obd_putref(obd);
 
         if (oqctl->qc_cmd == Q_GETOQUOTA) {
                 oqctl->qc_dqblk.dqb_curspace = curspace;
diff --git a/lustre/quota/quota_interface.c b/lustre/quota/quota_interface.c
index bc105e2..c941cee 100644
--- a/lustre/quota/quota_interface.c
+++ b/lustre/quota/quota_interface.c
@@ -44,7 +44,6 @@
 # include <linux/module.h>
 # include <linux/init.h>
 # include <linux/fs.h>
-# include <linux/jbd.h>
 #  include <linux/smp_lock.h>
 #  include <linux/buffer_head.h>
 #  include <linux/workqueue.h>
@@ -130,18 +129,19 @@ static int filter_quota_clearinfo(struct obd_export *exp, struct obd_device *obd
 
         /* lquota may be not set up before destroying export, b=14896 */
         if (!obd->obd_set_up)
-                return 0;
+                RETURN(0);
 
         /* when exp->exp_imp_reverse is destroyed, the corresponding lqc_import
          * should be invalid b=12374 */
-        if (qctxt->lqc_import == exp->exp_imp_reverse) {
+        if (qctxt->lqc_import && qctxt->lqc_import == exp->exp_imp_reverse) {
                 spin_lock(&qctxt->lqc_lock);
                 qctxt->lqc_import = NULL;
+                spin_unlock(&qctxt->lqc_lock);
+                ptlrpc_cleanup_imp(exp->exp_imp_reverse);
+                dqacq_interrupt(qctxt);
                 CDEBUG(D_QUOTA, "%s: lqc_import of obd(%p) is invalid now.\n",
                        obd->obd_name, obd);
-                spin_unlock(&qctxt->lqc_lock);
         }
-
         RETURN(0);
 }
 
@@ -149,7 +149,7 @@ static int filter_quota_enforce(struct obd_device *obd, unsigned int ignore)
 {
         ENTRY;
 
-        if (!sb_any_quota_enabled(obd->u.obt.obt_sb))
+        if (!ll_sb_any_quota_active(obd->u.obt.obt_sb))
                 RETURN(0);
 
         if (ignore) {
@@ -162,6 +162,7 @@ static int filter_quota_enforce(struct obd_device *obd, unsigned int ignore)
         RETURN(0);
 }
 
+#define GET_OA_ID(flag, oa) (flag == USRQUOTA ? oa->o_uid : oa->o_gid)
 static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa)
 {
         struct obd_device_target *obt = &obd->u.obt;
@@ -170,7 +171,7 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa)
         struct obd_quotactl *oqctl;
         ENTRY;
 
-        if (!sb_any_quota_enabled(obt->obt_sb))
+        if (!ll_sb_any_quota_active(obt->obt_sb))
                 RETURN(0);
 
         OBD_ALLOC_PTR(oqctl);
@@ -184,14 +185,14 @@ static int filter_quota_getflag(struct obd_device *obd, struct obdo *oa)
         oa->o_flags &= ~(OBD_FL_NO_USRQUOTA | OBD_FL_NO_GRPQUOTA);
 
         for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-                struct quota_adjust_qunit oqaq_tmp;
                 struct lustre_qunit_size *lqs = NULL;
 
-                oqaq_tmp.qaq_flags = cnt;
-                oqaq_tmp.qaq_id = (cnt == USRQUOTA) ? oa->o_uid : oa->o_gid;
-
-                quota_search_lqs(NULL, &oqaq_tmp, qctxt, &lqs);
-                if (lqs) {
+                lqs = quota_search_lqs(LQS_KEY(cnt, GET_OA_ID(cnt, oa)),
+                                       qctxt, 0);
+                if (lqs == NULL || IS_ERR(lqs)) {
+                        rc = PTR_ERR(lqs);
+                        break;
+                } else {
                         spin_lock(&lqs->lqs_lock);
                         if (lqs->lqs_bunit_sz <= qctxt->lqc_sync_blk) {
                                 oa->o_flags |= (cnt == USRQUOTA) ?
@@ -258,10 +259,6 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid,
         int rc = 0, rc2[2] = { 0, 0 };
         ENTRY;
 
-        CLASSERT(MAXQUOTAS < 4);
-        if (!sb_any_quota_enabled(qctxt->lqc_sb))
-                RETURN(rc);
-
         spin_lock(&qctxt->lqc_lock);
         if (!qctxt->lqc_valid){
                 spin_unlock(&qctxt->lqc_lock);
@@ -282,8 +279,8 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid,
                 if (qdata[i].qd_id == 0 && !QDATA_IS_GRP(&qdata[i]))
                         continue;
 
-                quota_search_lqs(&qdata[i], NULL, qctxt, &lqs);
-                if (!lqs)
+                lqs = quota_search_lqs(LQS_KEY(i, id[i]), qctxt, 0);
+                if (lqs == NULL || IS_ERR(lqs))
                         continue;
 
                 rc2[i] = compute_remquota(obd, qctxt, &qdata[i], isblk);
@@ -309,6 +306,23 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid,
                         }
                 }
 
+                /* if xx_rec < 0, that means quota are releasing,
+                 * and it may return before we use quota. So if
+                 * we find this situation, we assuming it has
+                 * returned b=18491 */
+                if (isblk && lqs->lqs_blk_rec < 0) {
+                        if (qdata[i].qd_count < -lqs->lqs_blk_rec)
+                                qdata[i].qd_count = 0;
+                        else
+                                qdata[i].qd_count += lqs->lqs_blk_rec;
+                }
+                if (!isblk && lqs->lqs_ino_rec < 0) {
+                        if (qdata[i].qd_count < -lqs->lqs_ino_rec)
+                                qdata[i].qd_count = 0;
+                        else
+                                qdata[i].qd_count += lqs->lqs_ino_rec;
+                }
+
                 CDEBUG(D_QUOTA, "count=%d lqs_pending=%lu qd_count="LPU64
                        " isblk=%d mb=%d pending[%d]=%d\n", count,
                        isblk ? lqs->lqs_bwrite_pending : lqs->lqs_iwrite_pending,
@@ -323,6 +337,11 @@ static int quota_check_common(struct obd_device *obd, unsigned int uid,
 
                 spin_unlock(&lqs->lqs_lock);
 
+                if (lqs->lqs_blk_rec  < 0 &&
+                    qdata[i].qd_count <
+                    lqs->lqs_bwrite_pending - lqs->lqs_blk_rec - mb)
+                        OBD_FAIL_TIMEOUT(OBD_FAIL_QUOTA_DELAY_REL, 5);
+
                 /* When cycle is zero, lqs_*_pending will be changed. We will
                  * get reference of the lqs here and put reference of lqs in
                  * quota_pending_commit b=14784 */
@@ -374,7 +393,8 @@ static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid,
                         l_wait_event(qctxt->lqc_wait_for_qmaster, check_qm(qctxt),
                                      &lwi);
                         CDEBUG(D_QUOTA, "wake up when quota master is back\n");
-                        lc_watchdog_touch(oti->oti_thread->t_watchdog);
+                        lc_watchdog_touch(oti->oti_thread->t_watchdog,
+                                 GET_TIMEOUT(oti->oti_thread->t_svc));
                 } else {
                         spin_unlock(&qctxt->lqc_lock);
                 }
@@ -388,7 +408,7 @@ static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid,
 
                 /* please reference to dqacq_completion for the below */
                 /* a new request is finished, try again */
-                if (rc == -EAGAIN) {
+                if (rc == QUOTA_REQ_RETURNED) {
                         CDEBUG(D_QUOTA, "finish a quota req, try again\n");
                         continue;
                 }
@@ -405,7 +425,8 @@ static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid,
                         struct l_wait_info lwi;
 
                         if (oti && oti->oti_thread && oti->oti_thread->t_watchdog)
-                                lc_watchdog_touch(oti->oti_thread->t_watchdog);
+                                lc_watchdog_touch(oti->oti_thread->t_watchdog,
+                                         GET_TIMEOUT(oti->oti_thread->t_svc));
                         CDEBUG(D_QUOTA, "rc: %d, count_err: %d\n", rc,
                                count_err++);
 
@@ -415,7 +436,7 @@ static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid,
                         l_wait_event(waitq, 0, &lwi);
                 }
 
-                if (rc < 0 || cycle % 10 == 2) {
+                if (rc < 0 || cycle % 10 == 0) {
                         spin_lock(&last_print_lock);
                         if (last_print == 0 ||
                             cfs_time_before((last_print + cfs_time_seconds(30)),
@@ -443,13 +464,38 @@ static int quota_chk_acq_common(struct obd_device *obd, unsigned int uid,
         RETURN(rc);
 }
 
+int quota_is_set(struct obd_device *obd, unsigned int uid,
+                 unsigned int gid, int flag)
+{
+        struct lustre_qunit_size *lqs;
+        __u32 id[MAXQUOTAS] = { uid, gid };
+        int i, q_set = 0;
+
+        if (!ll_sb_any_quota_active(obd->u.obt.obt_qctxt.lqc_sb))
+                RETURN(0);
+
+        for (i = 0; i < MAXQUOTAS; i++) {
+                lqs = quota_search_lqs(LQS_KEY(i, id[i]),
+                                       &obd->u.obt.obt_qctxt, 0);
+                if (lqs && !IS_ERR(lqs)) {
+                        if (lqs->lqs_flags & flag)
+                                q_set = 1;
+                        lqs_putref(lqs);
+                }
+        }
+
+        return q_set;
+}
+
 static int filter_quota_check(struct obd_device *obd, unsigned int uid,
                               unsigned int gid, int npage, int pending[2],
                               quota_acquire acquire, struct obd_trans_info *oti,
                               struct inode *inode, int frags)
 {
-        return quota_chk_acq_common(obd, uid, gid, npage, pending, LQUOTA_FLAGS_BLK,
-                                    acquire, oti, inode, frags);
+        return quota_is_set(obd, uid, gid, QB_SET) ?
+                quota_chk_acq_common(obd, uid, gid, npage, pending,
+                                     LQUOTA_FLAGS_BLK, acquire, oti, inode,
+                                     frags) : 0;
 }
 
 /* when a block_write or inode_create rpc is finished, adjust the record for
@@ -472,6 +518,7 @@ static int quota_pending_commit(struct obd_device *obd, unsigned int uid,
         do_gettimeofday(&work_start);
         for (i = 0; i < MAXQUOTAS; i++) {
                 struct lustre_qunit_size *lqs = NULL;
+                int flag = 0;
 
                 qdata[i].qd_id = id[i];
                 qdata[i].qd_flags = i;
@@ -482,39 +529,39 @@ static int quota_pending_commit(struct obd_device *obd, unsigned int uid,
                 if (qdata[i].qd_id == 0 && !QDATA_IS_GRP(&qdata[i]))
                         continue;
 
-                quota_search_lqs(&qdata[i], NULL, qctxt, &lqs);
-                if (lqs) {
-                        int flag = 0;
-                        spin_lock(&lqs->lqs_lock);
-                        if (isblk) {
-                                if (lqs->lqs_bwrite_pending >= pending[i]) {
-                                        lqs->lqs_bwrite_pending -= pending[i];
-                                        flag = 1;
-                                } else {
-                                        CERROR("%s: there are too many blocks!\n",
-                                               obd->obd_name);
-                                }
+                lqs = quota_search_lqs(LQS_KEY(i, qdata[i].qd_id), qctxt, 0);
+                if (lqs == NULL || IS_ERR(lqs))
+                        continue;
+
+                spin_lock(&lqs->lqs_lock);
+                if (isblk) {
+                        if (lqs->lqs_bwrite_pending >= pending[i]) {
+                                lqs->lqs_bwrite_pending -= pending[i];
+                                flag = 1;
                         } else {
-                                if (lqs->lqs_iwrite_pending >= pending[i]) {
-                                        lqs->lqs_iwrite_pending -= pending[i];
-                                        flag = 1;
-                                } else {
-                                        CERROR("%s: there are too many files!\n",
-                                               obd->obd_name);
-                                }
+                                CERROR("%s: there are too many blocks!\n",
+                                       obd->obd_name);
                         }
-                        CDEBUG(D_QUOTA, "%s: lqs_pending=%lu pending[%d]=%d isblk=%d\n",
-                               obd->obd_name,
-                               isblk ? lqs->lqs_bwrite_pending : lqs->lqs_iwrite_pending,
-                               i, pending[i], isblk);
+                } else {
+                        if (lqs->lqs_iwrite_pending >= pending[i]) {
+                                lqs->lqs_iwrite_pending -= pending[i];
+                                flag = 1;
+                        } else {
+                                CERROR("%s: there are too many files!\n",
+                                       obd->obd_name);
+                        }
+                }
+                CDEBUG(D_QUOTA, "%s: lqs_pending=%lu pending[%d]=%d isblk=%d\n",
+                       obd->obd_name,
+                       isblk ? lqs->lqs_bwrite_pending : lqs->lqs_iwrite_pending,
+                       i, pending[i], isblk);
 
-                        spin_unlock(&lqs->lqs_lock);
+                spin_unlock(&lqs->lqs_lock);
+                lqs_putref(lqs);
+                /* When lqs_*_pening is changed back, we'll putref lqs
+                 * here b=14784 */
+                if (flag)
                         lqs_putref(lqs);
-                        /* When lqs_*_pening is changed back, we'll putref lqs
-                         * here b=14784 */
-                        if (flag)
-                                lqs_putref(lqs);
-                }
         }
         do_gettimeofday(&work_end);
         timediff = cfs_timeval_sub(&work_end, &work_start, NULL);
@@ -593,8 +640,9 @@ static int mds_quota_check(struct obd_device *obd, unsigned int uid,
                            quota_acquire acquire, struct obd_trans_info *oti,
                            struct inode *inode, int frags)
 {
-        return quota_chk_acq_common(obd, uid, gid, inodes, pending, 0,
-                                    acquire, oti, inode, frags);
+        return quota_is_set(obd, uid, gid, QI_SET) ?
+                quota_chk_acq_common(obd, uid, gid, inodes, pending, 0,
+                                     acquire, oti, inode, frags) : 0;
 }
 
 static int mds_quota_acquire(struct obd_device *obd, unsigned int uid,
diff --git a/lustre/quota/quota_internal.h b/lustre/quota/quota_internal.h
index c1c4baa..4f17e88 100644
--- a/lustre/quota/quota_internal.h
+++ b/lustre/quota/quota_internal.h
@@ -87,14 +87,15 @@
 #define LQS_DEBUG(lqs, fmt, arg...)                                           \
         CDEBUG(D_QUOTA, "lqs(%p) id(%u) flag(%lu) type(%c) bunit(%lu) "       \
                "btune(%lu) iunit(%lu) itune(%lu) lqs_bwrite_pending(%lu) "    \
-               "lqs_iwrite_pending(%lu) ino_rec("LPD64") blk_rec("LPD64" )"   \
+               "lqs_iwrite_pending(%lu) ino_rec(%llu) blk_rec(%llu)"   \
                "refcount(%d): "                                               \
                fmt, lqs, lqs->lqs_id, lqs->lqs_flags,                         \
                LQS_IS_GRP(lqs) ? 'g' : 'u',                                   \
                lqs->lqs_bunit_sz, lqs->lqs_btune_sz, lqs->lqs_iunit_sz,       \
                lqs->lqs_itune_sz, lqs->lqs_bwrite_pending,                    \
-               lqs->lqs_iwrite_pending, lqs->lqs_ino_rec,                     \
-               lqs->lqs_blk_rec, atomic_read(&lqs->lqs_refcount), ## arg);
+               lqs->lqs_iwrite_pending, (__s64)lqs->lqs_ino_rec,              \
+               (__s64)lqs->lqs_blk_rec, atomic_read(&lqs->lqs_refcount),      \
+               ## arg);
 
 
 /* quota_context.c */
@@ -113,6 +114,10 @@ int compute_remquota(struct obd_device *obd,
                      struct lustre_quota_ctxt *qctxt, struct qunit_data *qdata,
                      int isblk);
 int check_qm(struct lustre_quota_ctxt *qctxt);
+void dqacq_interrupt(struct lustre_quota_ctxt *qctxt);
+void* quota_barrier(struct lustre_quota_ctxt *qctxt,
+                    struct obd_quotactl *oqctl, int isblk);
+void quota_unbarrier(void *handle);
 /* quota_master.c */
 int lustre_dquot_init(void);
 void lustre_dquot_exit(void);
@@ -151,17 +156,12 @@ int target_quota_check(struct obd_export *exp, struct obd_quotactl *oqctl);
 
 int quota_adjust_slave_lqs(struct quota_adjust_qunit *oqaq, struct
                           lustre_quota_ctxt *qctxt);
-void qdata_to_oqaq(struct qunit_data *qdata,
-                   struct quota_adjust_qunit *oqaq);
 #ifdef __KERNEL__
-int quota_search_lqs(struct qunit_data *qdata,
-                     struct quota_adjust_qunit *oqaq,
-                     struct lustre_quota_ctxt *qctxt,
-                     struct lustre_qunit_size **lqs_return);
-int quota_create_lqs(struct qunit_data *qdata,
-                     struct quota_adjust_qunit *oqaq,
-                     struct lustre_quota_ctxt *qctxt,
-                     struct lustre_qunit_size **lqs_return);
+int quota_is_set(struct obd_device *obd, unsigned int uid,
+                 unsigned int gid, int flag);
+struct lustre_qunit_size *quota_search_lqs(unsigned long long lqs_key,
+                                           struct lustre_quota_ctxt *qctxt,
+                                           int create);
 void quota_compute_lqs(struct qunit_data *qdata, struct lustre_qunit_size *lqs,
                        int is_chk, int is_acq);
 
@@ -175,6 +175,7 @@ int filter_quota_adjust_qunit(struct obd_export *exp,
                               struct lustre_quota_ctxt *qctxt);
 int lquota_proc_setup(struct obd_device *obd, int is_master);
 int lquota_proc_cleanup(struct lustre_quota_ctxt *qctxt);
+void build_lqs(struct obd_device *obd);
 
 extern cfs_proc_dir_entry_t *lquota_type_proc_dir;
 #endif
@@ -184,6 +185,8 @@ extern cfs_proc_dir_entry_t *lquota_type_proc_dir;
 #define LQS_INO_DECREASE 4
 #define LQS_INO_INCREASE 8
 
+/* the return status of quota operation */
+#define QUOTA_REQ_RETURNED 1
 
 #endif
 int client_quota_adjust_qunit(struct obd_export *exp,
diff --git a/lustre/quota/quota_master.c b/lustre/quota/quota_master.c
index 53ce5c2..24e8131 100644
--- a/lustre/quota/quota_master.c
+++ b/lustre/quota/quota_master.c
@@ -235,8 +235,8 @@ static void init_oqaq(struct quota_adjust_qunit *oqaq,
 
         oqaq->qaq_id = id;
         oqaq->qaq_flags = type;
-        quota_search_lqs(NULL, oqaq, qctxt, &lqs);
-        if (lqs) {
+        lqs = quota_search_lqs(LQS_KEY(type, id), qctxt, 0);
+        if (lqs && !IS_ERR(lqs)) {
                 spin_lock(&lqs->lqs_lock);
                 oqaq->qaq_bunit_sz = lqs->lqs_bunit_sz;
                 oqaq->qaq_iunit_sz = lqs->lqs_iunit_sz;
@@ -440,29 +440,24 @@ out:
                 dqacq_adjust_qunit_sz(obd, qdata->qd_id, QDATA_IS_GRP(qdata),
                                       QDATA_IS_BLK(qdata));
 
-        quota_search_lqs(qdata, NULL, qctxt, &lqs);
-        if (QDATA_IS_BLK(qdata)) {
-                if (!lqs) {
-                        CDEBUG(D_INFO, "Can't find the lustre qunit size!\n");
-                        qdata->qd_qunit  = qctxt->lqc_bunit_sz;
-                } else {
-                        spin_lock(&lqs->lqs_lock);
-                        qdata->qd_qunit  = lqs->lqs_bunit_sz;
-                        spin_unlock(&lqs->lqs_lock);
-                }
-                QDATA_SET_ADJBLK(qdata);
+        lqs = quota_search_lqs(LQS_KEY(QDATA_IS_GRP(qdata), qdata->qd_id),
+                               qctxt, 0);
+        if (lqs == NULL || IS_ERR(lqs)) {
+                CDEBUG(D_INFO, "Can't find the lustre qunit size!\n");
+                qdata->qd_qunit  = QDATA_IS_BLK(qdata) ? qctxt->lqc_bunit_sz :
+                                                         qctxt->lqc_iunit_sz;
         } else {
-                if (!lqs) {
-                        CDEBUG(D_INFO, "Can't find the lustre qunit size!\n");
-                        qdata->qd_qunit  = qctxt->lqc_iunit_sz;
-                } else {
-                        spin_lock(&lqs->lqs_lock);
-                        qdata->qd_qunit  = lqs->lqs_iunit_sz;
-                        spin_unlock(&lqs->lqs_lock);
-                }
-                QDATA_SET_ADJINO(qdata);
+                spin_lock(&lqs->lqs_lock);
+                qdata->qd_qunit  = QDATA_IS_BLK(qdata) ? lqs->lqs_bunit_sz :
+                                                         lqs->lqs_iunit_sz;
+                spin_unlock(&lqs->lqs_lock);
         }
 
+        if (QDATA_IS_BLK(qdata))
+                QDATA_SET_ADJBLK(qdata);
+        else
+                QDATA_SET_ADJINO(qdata);
+
         QDATA_DEBUG(qdata, "alloc/release qunit in dqacq_handler\n");
         if (lqs)
                 lqs_putref(lqs);
@@ -510,8 +505,9 @@ int mds_quota_adjust(struct obd_device *obd, unsigned int qcids[],
         }
 
         if (rc2)
-                CDEBUG(rc2 == -EAGAIN ? D_QUOTA: D_ERROR,
-                       "mds adjust qunit failed! (opc:%d rc:%d)\n", opc, rc2);
+                CDEBUG(rc2 == QUOTA_REQ_RETURNED ? D_QUOTA: D_ERROR,
+                       "mds adjust qunit %ssuccessfully! (opc:%d rc:%d)\n",
+                       rc2 == QUOTA_REQ_RETURNED ? "" : "un", opc, rc2);
         RETURN(0);
 }
 
@@ -548,9 +544,9 @@ int filter_quota_adjust(struct obd_device *obd, unsigned int qcids[],
         if (rc || rc2) {
                 if (!rc)
                         rc = rc2;
-                CDEBUG(rc == -EAGAIN ? D_QUOTA: D_ERROR,
-                       "filter adjust qunit failed! (opc:%d rc%d)\n",
-                       opc, rc);
+                CDEBUG(rc == QUOTA_REQ_RETURNED ? D_QUOTA: D_ERROR,
+                       "filter adjust qunit %ssuccessfully! (opc:%d rc%d)\n",
+                       QUOTA_REQ_RETURNED ? "" : "un", opc, rc);
         }
 
         RETURN(0);
@@ -1121,28 +1117,20 @@ int dquot_create_oqaq(struct lustre_quota_ctxt *qctxt,
 
         }
 
-        if (!dquot->dq_dqb.dqb_bhardlimit && !dquot->dq_dqb.dqb_bsoftlimit &&
-            !dquot->dq_dqb.dqb_ihardlimit && !dquot->dq_dqb.dqb_isoftlimit) {
-                oqaq->qaq_bunit_sz = 0;
-                oqaq->qaq_iunit_sz = 0;
-                QAQ_SET_ADJBLK(oqaq);
-                QAQ_SET_ADJINO(oqaq);
-        }
-
         QAQ_DEBUG(oqaq, "the oqaq computed\n");
 
         RETURN(rc);
 }
 
 static int mds_init_slave_ilimits(struct obd_device *obd,
-                                  struct obd_quotactl *oqctl, int set,
-                                  struct quota_adjust_qunit *oqaq)
+                                  struct obd_quotactl *oqctl, int set)
 {
         /* XXX: for file limits only adjust local now */
         struct obd_device_target *obt = &obd->u.obt;
         struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
         unsigned int uid = 0, gid = 0;
         struct obd_quotactl *ioqc = NULL;
+        struct lustre_qunit_size *lqs;
         int flag;
         int rc;
         ENTRY;
@@ -1164,12 +1152,21 @@ static int mds_init_slave_ilimits(struct obd_device *obd,
         ioqc->qc_dqblk.dqb_valid = QIF_ILIMITS;
         ioqc->qc_dqblk.dqb_ihardlimit = flag ? MIN_QLIMIT : 0;
 
-        if (QAQ_IS_ADJINO(oqaq)) {
-                /* adjust the mds slave's inode qunit size */
-                rc = quota_adjust_slave_lqs(oqaq, qctxt);
-                if (rc < 0)
-                        CDEBUG(D_ERROR, "adjust mds slave's inode qunit size \
-                               failed! (rc:%d)\n", rc);
+        /* build lqs for mds */
+        lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
+                               qctxt, flag ? 1 : 0);
+        if (lqs && !IS_ERR(lqs)) {
+                if (flag)
+                        lqs->lqs_flags |= QI_SET;
+                else
+                        lqs->lqs_flags &= ~QI_SET;
+                lqs_putref(lqs);
+        } else {
+                CERROR("fail to %s lqs for inode(%s id: %u)!\n",
+                       flag ? "create" : "search",
+                       oqctl->qc_type ? "group" : "user",
+                       oqctl->qc_id);
+                GOTO(out, rc = PTR_ERR(lqs));
         }
 
         /* set local limit to MIN_QLIMIT */
@@ -1203,15 +1200,15 @@ out:
 }
 
 static int mds_init_slave_blimits(struct obd_device *obd,
-                                  struct obd_quotactl *oqctl, int set,
-                                  struct quota_adjust_qunit *oqaq)
+                                  struct obd_quotactl *oqctl, int set)
 {
         struct obd_device_target *obt = &obd->u.obt;
         struct lustre_quota_ctxt *qctxt = &obt->obt_qctxt;
         struct mds_obd *mds = &obd->u.mds;
         struct obd_quotactl *ioqc;
+        struct lustre_qunit_size *lqs;
         unsigned int uid = 0, gid = 0;
-        int rc, rc1 = 0;
+        int rc;
         int flag;
         ENTRY;
 
@@ -1231,12 +1228,22 @@ static int mds_init_slave_blimits(struct obd_device *obd,
         ioqc->qc_type = oqctl->qc_type;
         ioqc->qc_dqblk.dqb_valid = QIF_BLIMITS;
         ioqc->qc_dqblk.dqb_bhardlimit = flag ? MIN_QLIMIT : 0;
-        if (QAQ_IS_ADJBLK(oqaq)) {
-                /* adjust the mds slave's block qunit size */
-                rc1 = quota_adjust_slave_lqs(oqaq, qctxt);
-                if (rc1 < 0)
-                        CERROR("adjust mds slave's block qunit size failed!"
-                               "(rc:%d)\n", rc1);
+
+        /* build lqs for mds */
+        lqs = quota_search_lqs(LQS_KEY(oqctl->qc_type, oqctl->qc_id),
+                               qctxt, flag ? 1 : 0);
+        if (lqs && !IS_ERR(lqs)) {
+                if (flag)
+                        lqs->lqs_flags |= QB_SET;
+                else
+                        lqs->lqs_flags &= ~QB_SET;
+                lqs_putref(lqs);
+        } else {
+                CERROR("fail to %s lqs for block(%s id: %u)!\n",
+                       flag ? "create" : "search",
+                       oqctl->qc_type ? "group" : "user",
+                       oqctl->qc_id);
+                GOTO(out, rc = PTR_ERR(lqs));
         }
 
         rc = fsfilt_quotactl(obd, obd->u.obt.obt_sb, ioqc);
@@ -1263,18 +1270,32 @@ static int mds_init_slave_blimits(struct obd_device *obd,
                 GOTO(out, rc);
         }
 
-        /* adjust all slave's qunit size when setting quota
-         * this is will create a lqs for every ost, which will present
-         * certain uid/gid is set quota or not */
-        QAQ_SET_ADJBLK(oqaq);
-        rc = obd_quota_adjust_qunit(mds->mds_osc_exp, oqaq, qctxt);
-
         EXIT;
 out:
         OBD_FREE_PTR(ioqc);
         return rc;
 }
 
+static void adjust_lqs(struct obd_device *obd, struct quota_adjust_qunit *qaq)
+{
+        struct lustre_quota_ctxt *qctxt = &obd->u.obt.obt_qctxt;
+        int rc = 0;
+
+        QAQ_SET_CREATE_LQS(qaq);
+        /* adjust local lqs */
+        rc = quota_adjust_slave_lqs(qaq, qctxt);
+        if (rc < 0)
+                CERROR("adjust master's qunit size failed!(rc=%d)\n", rc);
+
+        /* adjust remote lqs */
+        if (QAQ_IS_ADJBLK(qaq)) {
+                rc = obd_quota_adjust_qunit(obd->u.mds.mds_osc_exp, qaq, qctxt);
+                if (rc < 0)
+                        CERROR("adjust slaves' qunit size failed!(rc=%d)\n", rc);
+
+        }
+}
+
 int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
 {
         struct mds_obd *mds = &obd->u.mds;
@@ -1388,13 +1409,16 @@ int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
         }
 
         up(&mds->mds_qonoff_sem);
+
+        adjust_lqs(obd, oqaq);
+
         orig_set = ihardlimit || isoftlimit;
         now_set  = dqblk->dqb_ihardlimit || dqblk->dqb_isoftlimit;
         if (dqblk->dqb_valid & QIF_ILIMITS && orig_set != now_set) {
                 down(&dquot->dq_sem);
                 dquot->dq_dqb.dqb_curinodes = 0;
                 up(&dquot->dq_sem);
-                rc = mds_init_slave_ilimits(obd, oqctl, orig_set, oqaq);
+                rc = mds_init_slave_ilimits(obd, oqctl, orig_set);
                 if (rc) {
                         CERROR("init slave ilimits failed! (rc:%d)\n", rc);
                         goto revoke_out;
@@ -1407,7 +1431,7 @@ int mds_set_dqblk(struct obd_device *obd, struct obd_quotactl *oqctl)
                 down(&dquot->dq_sem);
                 dquot->dq_dqb.dqb_curspace = 0;
                 up(&dquot->dq_sem);
-                rc = mds_init_slave_blimits(obd, oqctl, orig_set, oqaq);
+                rc = mds_init_slave_blimits(obd, oqctl, orig_set);
                 if (rc) {
                         CERROR("init slave blimits failed! (rc:%d)\n", rc);
                         goto revoke_out;
@@ -1623,17 +1647,18 @@ static int qmaster_recovery_main(void *arg)
 {
         struct qmaster_recov_thread_data *data = arg;
         struct obd_device *obd = data->obd;
+        struct mds_obd *mds = &obd->u.mds;
+        struct lustre_quota_info *qinfo = &mds->mds_quota_info;
         int rc = 0;
         unsigned short type;
         ENTRY;
 
         ptlrpc_daemonize("qmaster_recovd");
 
+        class_incref(obd);
         complete(&data->comp);
 
         for (type = USRQUOTA; type < MAXQUOTAS; type++) {
-                struct mds_obd *mds = &obd->u.mds;
-                struct lustre_quota_info *qinfo = &mds->mds_quota_info;
                 struct list_head id_list;
                 struct dquot_id *dqid, *tmp;
 
@@ -1660,26 +1685,29 @@ static int qmaster_recovery_main(void *arg)
                                 CERROR("qmaster recovery failed! (id:%d type:%d"
                                        " rc:%d)\n", dqid->di_id, type, rc);
 free:
-                        kfree(dqid);
+                        OBD_FREE_PTR(dqid);
                 }
         }
+        class_decref(obd);
         RETURN(rc);
 }
 
 int mds_quota_recovery(struct obd_device *obd)
 {
-        struct lov_obd *lov = &obd->u.mds.mds_osc_obd->u.lov;
+        struct mds_obd *mds = &obd->u.mds;
         struct qmaster_recov_thread_data data;
         int rc = 0;
         ENTRY;
 
-        mutex_down(&lov->lov_lock);
-        if (lov->desc.ld_tgt_count != lov->desc.ld_active_tgt_count) {
-                CWARN("Not all osts are active, abort quota recovery\n");
-                mutex_up(&lov->lov_lock);
+        mutex_down(&obd->obd_dev_sem);
+        if (mds->mds_lov_desc.ld_active_tgt_count != mds->mds_lov_objid_count) {
+                CWARN("Only %u/%u OSTs are active, abort quota recovery\n",
+                      mds->mds_lov_desc.ld_active_tgt_count,
+                      mds->mds_lov_objid_count);
+                mutex_up(&obd->obd_dev_sem);
                 RETURN(rc);
         }
-        mutex_up(&lov->lov_lock);
+        mutex_up(&obd->obd_dev_sem);
 
         data.obd = obd;
         init_completion(&data.comp);
diff --git a/lustre/scripts/Makefile.am b/lustre/scripts/Makefile.am
index 15d05c2..8eebb58 100644
--- a/lustre/scripts/Makefile.am
+++ b/lustre/scripts/Makefile.am
@@ -43,9 +43,9 @@ genscripts = lustre_config lc_modprobe lc_net lc_hb lc_cluman lustre_createcsv \
 sbin_SCRIPTS = $(genscripts) $(sbinscripts)
 bin_SCRIPTS = lustre_req_history
 
-EXTRA_DIST = license-status maketags.sh version_tag.pl.in lc_common \
+EXTRA_DIST = license-status maketags.sh version_tag.pl lc_common \
 	     $(addsuffix .in,$(genscripts)) lc_mon $(sbinscripts) \
-	     $(bin_SCRIPTS)
+	     $(bin_SCRIPTS) tree_status.pl
 
 scriptlibdir = $(libdir)/@PACKAGE@
 scriptlib_DATA = lc_common
@@ -55,3 +55,6 @@ CLEANFILES = $(genscripts)
 $(genscripts): %: %.in
 	sed -e 's#@scriptlibdir@#$(scriptlibdir)#' < $< > $@
 	chmod +x $@
+
+tree_status.pl: version_tag.pl
+	ln version_tag.pl tree_status.pl
diff --git a/lustre/scripts/Makefile.in b/lustre/scripts/Makefile.in
index 9f8abb0..66e793b 100644
--- a/lustre/scripts/Makefile.in
+++ b/lustre/scripts/Makefile.in
@@ -210,9 +210,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -338,9 +338,9 @@ genscripts = lustre_config lc_modprobe lc_net lc_hb lc_cluman lustre_createcsv \
 sbin_SCRIPTS = $(genscripts) $(sbinscripts)
 bin_SCRIPTS = lustre_req_history
 
-EXTRA_DIST = license-status maketags.sh version_tag.pl.in lc_common \
+EXTRA_DIST = license-status maketags.sh version_tag.pl lc_common \
 	     $(addsuffix .in,$(genscripts)) lc_mon $(sbinscripts) \
-	     $(bin_SCRIPTS)
+	     $(bin_SCRIPTS) tree_status.pl
 
 
 scriptlibdir = $(libdir)/@PACKAGE@
@@ -351,13 +351,13 @@ subdir = lustre/scripts
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES = version_tag.pl
+CONFIG_CLEAN_FILES =
 SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS)
 
 DIST_SOURCES =
 DATA = $(scriptlib_DATA)
 
-DIST_COMMON = $(srcdir)/Makefile.in Makefile.am version_tag.pl.in
+DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
 all: all-am
 
 .SUFFIXES:
@@ -366,8 +366,6 @@ $(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.ac $(ACLOCAL_M4)
 	  $(AUTOMAKE) --gnu  lustre/scripts/Makefile
 Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
-version_tag.pl: $(top_builddir)/config.status version_tag.pl.in
-	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 binSCRIPT_INSTALL = $(INSTALL_SCRIPT)
 install-binSCRIPTS: $(bin_SCRIPTS)
 	@$(NORMAL_INSTALL)
@@ -557,6 +555,9 @@ uninstall-am: uninstall-binSCRIPTS uninstall-info-am \
 $(genscripts): %: %.in
 	sed -e 's#@scriptlibdir@#$(scriptlibdir)#' < $< > $@
 	chmod +x $@
+
+tree_status.pl: version_tag.pl
+	ln version_tag.pl tree_status.pl
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
diff --git a/lustre/scripts/lustre_config.in b/lustre/scripts/lustre_config.in
index fcdf45f..c72bd4a 100644
--- a/lustre/scripts/lustre_config.in
+++ b/lustre/scripts/lustre_config.in
@@ -65,6 +65,10 @@ that will be part of the Lustre cluster.
 
 It can also optionally: 
  * upgrade Lustre targets from 1.4 to 1.6
+   It does not support "rolling upgrade". Before upgrading, the entire Lustre
+   filesystem (all servers and clients) need be shut down. After upgrading, old
+   configuration logs for the filesystem would be erased and new configuration
+   logs would be regenerated as Lustre servers restart.
  * verify the network connectivity and hostnames in the cluster
  * configure Linux MD/LVM devices
  * modify /etc/modprobe.conf to add Lustre networking info
@@ -334,6 +338,8 @@ construct_mkfs_cmdline() {
         ;;
     "mdt")
         MKFS_CMD="$MKFS_CMD --mdt"
+        $UPGRADE_TARGET && [ -n "${MGS_NIDS[i]}" ] && \
+        MKFS_CMD="$MKFS_CMD --nomgs"
         ;;
     "mgs")
         MKFS_CMD="$MKFS_CMD --mgs"
diff --git a/lustre/scripts/tree_status.pl b/lustre/scripts/tree_status.pl
new file mode 100644
index 0000000..84365b1
--- /dev/null
+++ b/lustre/scripts/tree_status.pl
@@ -0,0 +1,254 @@
+#!/usr/bin/perl
+# -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
+
+use strict;
+use diagnostics;
+use IO::File;
+use Time::Local;
+
+my $pristine = 1;
+my $kernver = "";
+
+# Use the CVS tag first otherwise use the portals version
+sub get_tag()
+{
+    my $tag;
+    my $line;
+
+    my $tagfile = new IO::File;
+    if (!$tagfile->open("lustre/CVS/Tag")) {
+        # is there a good way to do this with git or should the git case just
+        # fall through to use config.h?  it is always nice to know if we are
+        # working on a tag or branch.
+        my $verfile = new IO::File;
+        if (!$verfile->open("config.h")) {
+          return "UNKNOWN";
+        }
+        while(defined($line = <$verfile>)) {
+            $line =~ /\#define VERSION "(.*)"/;
+            if ($1) {
+                $tag = $1;
+                last;
+            }
+        }
+        $verfile->close();
+        return $tag
+    } else {
+        my $tmp = <$tagfile>;
+        $tagfile->close();
+
+        $tmp =~ m/[TN](.*)/;
+        return $1;
+    }
+}
+
+sub get_latest_mtime()
+{
+    my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
+                "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
+                "Nov" => 10, "Dec" => 11);
+
+    my $last_mtime = 0;
+
+    # a CVS checkout
+    if (-d "CVS") {
+        # if we got here, we are operating in a CVS checkout
+        my @entries = `find . -name Entries`;
+        my $entry_file;
+        foreach $entry_file (@entries) {
+            chomp($entry_file);
+            my $entry = new IO::File;
+            if (!$entry->open($entry_file)) {
+                die "unable to open $entry_file: $!\n";
+            }
+            my $line;
+            while (defined($line = <$entry>)) {
+                chomp($line);
+                #print "line: $line\n";
+                my ($junk, $file, $version, $date) = split(/\//, $line);
+
+                #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
+                #print "last_mtime: " . localtime($last_mtime) . "\n";
+
+                if ($junk eq "D" ||
+                    $file eq "lustre.spec.in") {
+                    # also used to skip: "$file !~ m/\.(c|h|am|in)$/" but I see
+                    # no good reason why only the above file patterns should
+                    # count towards pristine/changed.  it should be any file,
+                    # surely.
+                    next;
+                }
+
+                my $cur_dir = $entry_file;
+                $cur_dir =~ s/\/CVS\/Entries$//;
+                my @statbuf = stat("$cur_dir/$file");
+                my $mtime = $statbuf[9];
+                if (!defined($mtime)) {
+                    next;
+                }
+                my $local_date = gmtime($mtime);
+                if ($local_date ne $date &&
+                    $file ne "lustre.spec.in") {
+                    #print "$file : " . localtime($mtime) . "\n";
+                    $pristine = 0;
+                }
+
+                if ($mtime > $last_mtime) {
+                    $last_mtime = $mtime;
+                }
+
+                if ($date) {
+                    my @t = split(/ +/, $date);
+                    if (int(@t) != 5) {
+                        #print "skipping: $date\n";
+                        next;
+                    }
+                    my ($hours, $min, $sec) = split(/:/, $t[3]);
+                    my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
+                    my $secs = 0;
+                    $mon = $months{$mon};
+                    $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
+                    if ($secs > $last_mtime) {
+                        $last_mtime = $secs;
+                    }
+                }
+            }
+            $entry->close();
+        }
+    } elsif (-d ".git") {
+        # a git checkout
+        # TODO: figure out how to determine the most recently modified file
+        #       in a git working copy.
+        #       NOTE: this is not simply the newest file in the whole tree,
+        #             but the newest file in the tree that is from the
+        #             repository.
+        $last_mtime = time();
+    } else {
+        my $tree_status = new IO::File;
+        if (!$tree_status->open("tree_status")) {
+            die "unable to open the tree_status file: $!\n";
+        }
+        my $line;
+        while (defined($line = <$tree_status>)) {
+            if ($line =~ /^PRISTINE\s*=\s*(\d)/) {
+                $pristine = $1;
+            } elsif  ($line =~ /^MTIME\s*=\s*(\d+)/) {
+                $last_mtime = $1;
+            }
+        }
+    }
+    return $last_mtime;
+
+}
+
+sub get_linuxdir()
+{
+    my $config = new IO::File;
+    my ($line, $dir, $objdir);
+    if (!$config->open("autoMakefile")) {
+        die "Run ./configure first\n";
+    }
+    while (defined($line = <$config>)) {
+        chomp($line);
+        if ($line =~ /LINUX :?= (.*)/) {
+            $dir = $1;
+        } elsif ($line =~ /LINUX_OBJ :?= (.*)/) {
+            $objdir = $1;
+            last;
+        }
+    }
+    $config->close();
+    my $ver = new IO::File;
+    if (!$ver->open("$objdir/include/linux/utsrelease.h") &&
+        !$ver->open("$objdir/include/linux/version.h") &&
+        !$ver->open("$dir/include/linux/utsrelease.h") &&
+        !$ver->open("$dir/include/linux/version.h")) {
+            die "Run make dep on $dir\n";
+        }
+    while(defined($line = <$ver>)) {
+        $line =~ /\#define UTS_RELEASE "(.*)"/;
+        if ($1) {
+            $kernver = $1;
+            last;
+        }
+    }
+    $ver->close();
+    chomp($kernver);
+    $dir =~ s/\//\./g;
+    return $dir;
+}
+
+sub mtime2date($)
+{
+    my $mtime = shift;
+
+    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
+      localtime($mtime);
+    $year += 1900;
+    $mon++;
+    my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday,
+                            $hour, $min, $sec);
+
+    return $show_last;
+}
+
+sub generate_ver($$$)
+{
+    my $tag = shift;
+    my $mtime = shift;
+    my $linuxdir = shift;
+
+    #print "localtime: " . localtime($mtime) . "\n";
+
+    my $lustre_vers = $ENV{LUSTRE_VERS};
+
+    print "#define BUILD_VERSION \"";
+
+    if ($lustre_vers) {
+        print "$tag-$lustre_vers\"\n";
+        return 0;
+    }
+
+    my $show_last = mtime2date($mtime);
+
+    # if we want to get rid of the PRISTINE/CHANGED thing, get rid of these
+    # lines.  maybe we only want to print -CHANGED when something is changed
+    # and print nothing when it's pristine
+    if ($pristine) {
+        print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
+    } else {
+        print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
+    }
+}
+
+my $progname = $0;
+$progname =~ s/.*\///;
+
+if ($progname eq "tree_status.pl" && !-d "CVS" && !-d ".git") {
+    die("a tree status can only be determined in an source code control system checkout\n");
+}
+
+chomp(my $cwd = `pwd`);
+
+# ARGV[0] = srcdir
+# ARGV[1] = builddir
+
+# for get_latest_mtime and get_tag you need to be in srcdir
+
+if ($ARGV[0]) {
+    chdir($ARGV[0]);
+}
+my $tag = get_tag();
+my $mtime = get_latest_mtime()
+    if (!defined($ENV{LUSTRE_VERS}));
+
+if ($progname eq "version_tag.pl") {
+    my $linuxdir = get_linuxdir();
+    $linuxdir =~ s/\//\./g;
+    generate_ver($tag, $mtime, $linuxdir);
+} elsif ($progname eq "tree_status.pl") {
+    print "PRISTINE = $pristine\n";
+    print "MTIME = $mtime\n";
+}
+
+exit(0);
diff --git a/lustre/scripts/version_tag.pl b/lustre/scripts/version_tag.pl
new file mode 100644
index 0000000..84365b1
--- /dev/null
+++ b/lustre/scripts/version_tag.pl
@@ -0,0 +1,254 @@
+#!/usr/bin/perl
+# -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
+
+use strict;
+use diagnostics;
+use IO::File;
+use Time::Local;
+
+my $pristine = 1;
+my $kernver = "";
+
+# Use the CVS tag first otherwise use the portals version
+sub get_tag()
+{
+    my $tag;
+    my $line;
+
+    my $tagfile = new IO::File;
+    if (!$tagfile->open("lustre/CVS/Tag")) {
+        # is there a good way to do this with git or should the git case just
+        # fall through to use config.h?  it is always nice to know if we are
+        # working on a tag or branch.
+        my $verfile = new IO::File;
+        if (!$verfile->open("config.h")) {
+          return "UNKNOWN";
+        }
+        while(defined($line = <$verfile>)) {
+            $line =~ /\#define VERSION "(.*)"/;
+            if ($1) {
+                $tag = $1;
+                last;
+            }
+        }
+        $verfile->close();
+        return $tag
+    } else {
+        my $tmp = <$tagfile>;
+        $tagfile->close();
+
+        $tmp =~ m/[TN](.*)/;
+        return $1;
+    }
+}
+
+sub get_latest_mtime()
+{
+    my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
+                "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
+                "Nov" => 10, "Dec" => 11);
+
+    my $last_mtime = 0;
+
+    # a CVS checkout
+    if (-d "CVS") {
+        # if we got here, we are operating in a CVS checkout
+        my @entries = `find . -name Entries`;
+        my $entry_file;
+        foreach $entry_file (@entries) {
+            chomp($entry_file);
+            my $entry = new IO::File;
+            if (!$entry->open($entry_file)) {
+                die "unable to open $entry_file: $!\n";
+            }
+            my $line;
+            while (defined($line = <$entry>)) {
+                chomp($line);
+                #print "line: $line\n";
+                my ($junk, $file, $version, $date) = split(/\//, $line);
+
+                #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
+                #print "last_mtime: " . localtime($last_mtime) . "\n";
+
+                if ($junk eq "D" ||
+                    $file eq "lustre.spec.in") {
+                    # also used to skip: "$file !~ m/\.(c|h|am|in)$/" but I see
+                    # no good reason why only the above file patterns should
+                    # count towards pristine/changed.  it should be any file,
+                    # surely.
+                    next;
+                }
+
+                my $cur_dir = $entry_file;
+                $cur_dir =~ s/\/CVS\/Entries$//;
+                my @statbuf = stat("$cur_dir/$file");
+                my $mtime = $statbuf[9];
+                if (!defined($mtime)) {
+                    next;
+                }
+                my $local_date = gmtime($mtime);
+                if ($local_date ne $date &&
+                    $file ne "lustre.spec.in") {
+                    #print "$file : " . localtime($mtime) . "\n";
+                    $pristine = 0;
+                }
+
+                if ($mtime > $last_mtime) {
+                    $last_mtime = $mtime;
+                }
+
+                if ($date) {
+                    my @t = split(/ +/, $date);
+                    if (int(@t) != 5) {
+                        #print "skipping: $date\n";
+                        next;
+                    }
+                    my ($hours, $min, $sec) = split(/:/, $t[3]);
+                    my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
+                    my $secs = 0;
+                    $mon = $months{$mon};
+                    $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
+                    if ($secs > $last_mtime) {
+                        $last_mtime = $secs;
+                    }
+                }
+            }
+            $entry->close();
+        }
+    } elsif (-d ".git") {
+        # a git checkout
+        # TODO: figure out how to determine the most recently modified file
+        #       in a git working copy.
+        #       NOTE: this is not simply the newest file in the whole tree,
+        #             but the newest file in the tree that is from the
+        #             repository.
+        $last_mtime = time();
+    } else {
+        my $tree_status = new IO::File;
+        if (!$tree_status->open("tree_status")) {
+            die "unable to open the tree_status file: $!\n";
+        }
+        my $line;
+        while (defined($line = <$tree_status>)) {
+            if ($line =~ /^PRISTINE\s*=\s*(\d)/) {
+                $pristine = $1;
+            } elsif  ($line =~ /^MTIME\s*=\s*(\d+)/) {
+                $last_mtime = $1;
+            }
+        }
+    }
+    return $last_mtime;
+
+}
+
+sub get_linuxdir()
+{
+    my $config = new IO::File;
+    my ($line, $dir, $objdir);
+    if (!$config->open("autoMakefile")) {
+        die "Run ./configure first\n";
+    }
+    while (defined($line = <$config>)) {
+        chomp($line);
+        if ($line =~ /LINUX :?= (.*)/) {
+            $dir = $1;
+        } elsif ($line =~ /LINUX_OBJ :?= (.*)/) {
+            $objdir = $1;
+            last;
+        }
+    }
+    $config->close();
+    my $ver = new IO::File;
+    if (!$ver->open("$objdir/include/linux/utsrelease.h") &&
+        !$ver->open("$objdir/include/linux/version.h") &&
+        !$ver->open("$dir/include/linux/utsrelease.h") &&
+        !$ver->open("$dir/include/linux/version.h")) {
+            die "Run make dep on $dir\n";
+        }
+    while(defined($line = <$ver>)) {
+        $line =~ /\#define UTS_RELEASE "(.*)"/;
+        if ($1) {
+            $kernver = $1;
+            last;
+        }
+    }
+    $ver->close();
+    chomp($kernver);
+    $dir =~ s/\//\./g;
+    return $dir;
+}
+
+sub mtime2date($)
+{
+    my $mtime = shift;
+
+    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
+      localtime($mtime);
+    $year += 1900;
+    $mon++;
+    my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday,
+                            $hour, $min, $sec);
+
+    return $show_last;
+}
+
+sub generate_ver($$$)
+{
+    my $tag = shift;
+    my $mtime = shift;
+    my $linuxdir = shift;
+
+    #print "localtime: " . localtime($mtime) . "\n";
+
+    my $lustre_vers = $ENV{LUSTRE_VERS};
+
+    print "#define BUILD_VERSION \"";
+
+    if ($lustre_vers) {
+        print "$tag-$lustre_vers\"\n";
+        return 0;
+    }
+
+    my $show_last = mtime2date($mtime);
+
+    # if we want to get rid of the PRISTINE/CHANGED thing, get rid of these
+    # lines.  maybe we only want to print -CHANGED when something is changed
+    # and print nothing when it's pristine
+    if ($pristine) {
+        print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
+    } else {
+        print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
+    }
+}
+
+my $progname = $0;
+$progname =~ s/.*\///;
+
+if ($progname eq "tree_status.pl" && !-d "CVS" && !-d ".git") {
+    die("a tree status can only be determined in an source code control system checkout\n");
+}
+
+chomp(my $cwd = `pwd`);
+
+# ARGV[0] = srcdir
+# ARGV[1] = builddir
+
+# for get_latest_mtime and get_tag you need to be in srcdir
+
+if ($ARGV[0]) {
+    chdir($ARGV[0]);
+}
+my $tag = get_tag();
+my $mtime = get_latest_mtime()
+    if (!defined($ENV{LUSTRE_VERS}));
+
+if ($progname eq "version_tag.pl") {
+    my $linuxdir = get_linuxdir();
+    $linuxdir =~ s/\//\./g;
+    generate_ver($tag, $mtime, $linuxdir);
+} elsif ($progname eq "tree_status.pl") {
+    print "PRISTINE = $pristine\n";
+    print "MTIME = $mtime\n";
+}
+
+exit(0);
diff --git a/lustre/scripts/version_tag.pl.in b/lustre/scripts/version_tag.pl.in
deleted file mode 100644
index c341642..0000000
--- a/lustre/scripts/version_tag.pl.in
+++ /dev/null
@@ -1,197 +0,0 @@
-#!/usr/bin/perl
-# -*- Mode: perl; indent-tabs-mode: nil; cperl-indent-level: 4 -*-
-
-use strict;
-use diagnostics;
-use IO::File;
-use Time::Local;
-
-my $pristine = 1;
-my $kernver;
-
-# Use the CVS tag first otherwise use the portals version
-sub get_tag()
-{
-    my $tag;
-    my $line;
-
-    my $tagfile = new IO::File;
-    if (!$tagfile->open("lustre/CVS/Tag")) {
-        my $verfile = new IO::File;
-        if (!$verfile->open("config.h")) {
-          return "UNKNOWN";
-        }
-        while(defined($line = <$verfile>)) {
-            $line =~ /\#define VERSION "(.*)"/;
-            if ($1) {
-                $tag = $1;
-                last;
-            }
-        }
-        $verfile->close();
-        return $tag
-    } else {
-        my $tmp = <$tagfile>;
-        $tagfile->close();
-
-        $tmp =~ m/T(.*)/;
-        return $1;
-    }
-}
-
-sub get_latest_mtime()
-{
-    my %months=("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4,
-                "Jun" => 5, "Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9,
-                "Nov" => 10, "Dec" => 11);
-
-    my $last_mtime = 0;
-    my @entries = `find . -name Entries`;
-    my $entry_file;
-    foreach $entry_file (@entries) {
-        chomp($entry_file);
-        my $entry = new IO::File;
-        if (!$entry->open($entry_file)) {
-            die "unable to open $entry_file: $!\n";
-        }
-        my $line;
-        while (defined($line = <$entry>)) {
-            chomp($line);
-            #print "line: $line\n";
-            my ($junk, $file, $version, $date) = split(/\//, $line);
-
-            #print "junk: $junk\nfile: $file\nver: $version\ndate: $date\n";
-            #print "last_mtime: " . localtime($last_mtime) . "\n";
-
-            if ($junk eq "D" ||
-                $file eq "lustre.spec.in" ||
-                $file !~ m/\.(c|h|am|in)$/) {
-                next;
-            }
-
-            my $cur_dir = $entry_file;
-            $cur_dir =~ s/\/CVS\/Entries$//;
-            my @statbuf = stat("$cur_dir/$file");
-            my $mtime = $statbuf[9];
-            if (!defined($mtime)) {
-                next;
-            }
-            my $local_date = gmtime($mtime);
-            if ($local_date ne $date &&
-                $file ne "lustre.spec.in") {
-                #print "$file : " . localtime($mtime) . "\n";
-                $pristine = 0;
-            }
-
-            if ($mtime > $last_mtime) {
-                $last_mtime = $mtime;
-            }
-
-            if ($date) {
-                my @t = split(/ +/, $date);
-                if (int(@t) != 5) {
-                    #print "skipping: $date\n";
-                    next;
-                }
-                my ($hours, $min, $sec) = split(/:/, $t[3]);
-                my ($mon, $mday, $year) = ($t[1], $t[2], $t[4]);
-                my $secs = 0;
-                $mon = $months{$mon};
-                $secs = timelocal($sec, $min, $hours, $mday, $mon, $year);
-                if ($secs > $last_mtime) {
-                    $last_mtime = $secs;
-                }
-            }
-        }
-        $entry->close();
-    }
-    return $last_mtime;
-}
-
-sub get_linuxdir()
-{
-    my $config = new IO::File;
-    my ($line, $dir);
-    if (!$config->open("Makefile")) {
-        die "Run ./configure first\n";
-    }
-    while (defined($line = <$config>)) {
-        chomp($line);
-        if ($line =~ /LINUX :?= (.*)/) {
-            $dir = $1;
-            last;
-        }
-    }
-    $config->close();
-    my $ver = new IO::File;
-    if (!$ver->open("$dir/include/linux/version.h")) {
-        die "Run make dep on $dir\n";
-    }
-    while(defined($line = <$ver>)) {
-        $line =~ /\#define UTS_RELEASE "(.*)"/;
-        if ($1) {
-            $kernver = $1;
-            last;
-        }
-    }
-    $ver->close();
-    chomp($kernver);
-    $dir =~ s/\//\./g;
-    return $dir;
-}
-
-sub generate_ver($$$)
-{
-    my $tag = shift;
-    my $mtime = shift;
-    my $linuxdir = shift;
-
-    #print "localtime: " . localtime($mtime) . "\n";
-
-    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
-      localtime($mtime);
-    $year += 1900;
-    $mon++;
-    my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday,
-                            $hour, $min, $sec);
-
-    print "#define BUILD_VERSION \"";
-
-    my $lustre_vers = $ENV{LUSTRE_VERS};
-
-    if ($lustre_vers) {
-        print "$tag-$lustre_vers\"\n";
-    } elsif ($pristine) {
-        print "$tag-$show_last-PRISTINE-$linuxdir-$kernver\"\n";
-    } else {
-        print "$tag-$show_last-CHANGED-$linuxdir-$kernver\"\n";
-    }
-}
-chomp(my $cwd = `pwd`);
-
-# ARGV[0] = srcdir
-# ARGV[1] = builddir
-
-# for get_latest_mtime and get_tag you need to be in srcdir
-
-if ($ARGV[0]) {
-    chdir($ARGV[0]);
-}
-my $tag = get_tag();
-my $mtime = get_latest_mtime();
-
-# for get_linuxdir you need to be in builddir
-
-#if ($ARGV[1]) {
-#   chdir($cwd);
-#   chdir($ARGV[1]);
-#}
-#my $linuxdir = get_linuxdir();
-
-my $linuxdir = '@LINUX@';
-$linuxdir =~ s/\//\./g;
-$kernver = '@LINUXRELEASE@';
-
-generate_ver($tag, $mtime, $linuxdir);
-
-exit(0);
diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am
index 8f159b2..4529a8c 100644
--- a/lustre/tests/Makefile.am
+++ b/lustre/tests/Makefile.am
@@ -4,19 +4,23 @@ AM_CFLAGS = $(LLCFLAGS)
 # LDADD = -lldap
 # LDADD := -lreadline -ltermcap # -lefence
 
+DIST_SUBDIRS := mpi
+
 noinst_DATA = disk1_4.zip
-noinst_SCRIPTS = leak_finder.pl llecho.sh llmount.sh llmountcleanup.sh
+noinst_SCRIPTS = leak_finder.pl llmount.sh llmountcleanup.sh functions.sh
 noinst_SCRIPTS += test-framework.sh runvmstat runiozone runtests
 noinst_SCRIPTS += sanity.sh rundbench acceptance-small.sh compile.sh
 noinst_SCRIPTS += conf-sanity.sh insanity.sh lfscktest.sh oos.sh oos2.sh
 noinst_SCRIPTS += llog-test.sh recovery-small.sh replay-dual.sh sanity-quota.sh
 noinst_SCRIPTS += replay-ost-single.sh replay-single.sh run-llog.sh sanityN.sh
-noinst_SCRIPTS += runracer
-noinst_SCRIPTS += performance-sanity.sh mdsrate-create-small.sh
-noinst_SCRIPTS += mdsrate-create-large.sh mdsrate-lookup-1dir.sh
-noinst_SCRIPTS += mdsrate-stat-small.sh mdsrate-stat-large.sh
+noinst_SCRIPTS += large-scale.sh runracer performance-sanity.sh
+noinst_SCRIPTS += mdsrate-create-small.sh mdsrate-create-large.sh
+noinst_SCRIPTS += mdsrate-lookup-1dir.sh mdsrate-lookup-10dirs.sh
+noinst_SCRIPTS += mdsrate-stat-small.sh mdsrate-stat-large.sh replay-vbr.sh
 noinst_SCRIPTS += lockorder.sh socketclient socketserver runmultiop_bg_pause
-noinst_SCRIPTS += parallel-scale.sh
+noinst_SCRIPTS += recovery-mds-scale.sh run_dd.sh run_tar.sh run_iozone.sh
+noinst_SCRIPTS += run_dbench.sh run_IOR.sh recovery-double-scale.sh
+noinst_SCRIPTS += recovery-random-scale.sh parallel-scale.sh
 nobase_noinst_SCRIPTS = cfg/local.sh
 nobase_noinst_SCRIPTS += acl/make-tree acl/run cfg/ncli.sh
 nobase_noinst_SCRIPTS += racer/dir_create.sh racer/file_create.sh racer/file_list.sh
@@ -29,20 +33,20 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(noinst_DATA) \
              $(nobase_noinst_SCRIPTS) $(nobase_noinst_DATA)
 
 if TESTS
-noinst_PROGRAMS = openunlink truncate directio openme writeme mlink utime it_test
-noinst_PROGRAMS += tchmod toexcl fsx test_brw openclose createdestroy
+if MPITESTS
+SUBDIRS = mpi
+endif
+noinst_PROGRAMS = openunlink truncate directio writeme mlink utime it_test
+noinst_PROGRAMS += tchmod fsx test_brw 
 noinst_PROGRAMS += createmany chownmany statmany multifstat createtest
-noinst_PROGRAMS += opendirunlink opendevunlink unlinkmany fchdir_test checkstat
-noinst_PROGRAMS += statone runas openfile getdents o_directory rmdirmany
-noinst_PROGRAMS += small_write multiop sleeptest ll_sparseness_verify cmknod
+noinst_PROGRAMS += opendirunlink opendevunlink unlinkmany checkstat
+noinst_PROGRAMS += statone runas openfile rmdirmany
+noinst_PROGRAMS += small_write multiop ll_sparseness_verify
 noinst_PROGRAMS += ll_sparseness_write mrename ll_dirstripe_verify mkdirmany
 noinst_PROGRAMS += openfilleddirunlink rename_many memhog iopentest1 iopentest2
 noinst_PROGRAMS += mmap_sanity flock_test writemany reads flocks_test
 noinst_PROGRAMS += ll_getstripe_info
-if MPITESTS
-noinst_PROGRAMS += parallel_grouplock write_append_truncate createmany_mpi mdsrate
-endif
-# noinst_PROGRAMS += ldaptest copy_attr mkdirdeep 
+# noinst_PROGRAMS += copy_attr mkdirdeep 
 bin_PROGRAMS = mcreate munlink
 testdir = $(libdir)/lustre/tests
 test_SCRIPTS = $(noinst_SCRIPTS) $(noinst_PROGRAMS)
@@ -56,7 +60,7 @@ mmap_sanity_SOURCES= mmap_sanity.c
 
 LIBLUSTREAPI := $(top_builddir)/lustre/utils/liblustreapi.a
 ll_getstripe_info_LDADD=$(LIBLUSTREAPI)
-multiop_LDADD=$(LIBLUSTREAPI)
+multiop_LDADD=$(LIBLUSTREAPI) -lrt
 
 ll_dirstripe_verify_SOURCES= ll_dirstripe_verify.c
 ll_dirstripe_verify_LDADD= -L$(top_builddir)/lustre/utils -llustreapi
@@ -64,17 +68,4 @@ ll_dirstripe_verify_LDADD= -L$(top_builddir)/lustre/utils -llustreapi
 flocks_test_SOURCES=flocks_test.c
 flocks_test_LDADD=-lpthread
 
-if MPITESTS
-#LAM_LD_FLAGS=-L/opt/lam/lib -lmpi -llam -lpthread
-LAM_LD_FLAGS=-lmpich -lpthread
-write_append_truncate_SOURCES=write_append_truncate.c
-write_append_truncate_LDADD=$(LAM_LD_FLAGS)
-createmany_mpi_SOURCES=createmany-mpi.c
-createmany_mpi_LDADD=$(LAM_LD_FLAGS)
-parallel_grouplock_SOURCES=parallel_grouplock.c lp_utils.c lp_utils.h
-parallel_grouplock_LDADD=$(LAM_LD_FLAGS)
-mdsrate_SOURCES=mdsrate.c
-mdsrate_LDADD=$(LAM_LD_FLAGS) -L$(top_builddir)/lustre/utils -llustreapi
-endif
-
 #copy_attr_LDADD= -lattr
diff --git a/lustre/tests/Makefile.in b/lustre/tests/Makefile.in
index 1aab5b1..9ff38a8 100644
--- a/lustre/tests/Makefile.in
+++ b/lustre/tests/Makefile.in
@@ -38,7 +38,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
- at MPITESTS_TRUE@@TESTS_TRUE at am__append_1 = parallel_grouplock write_append_truncate createmany_mpi mdsrate
 ACLOCAL = @ACLOCAL@
 AC_LUSTRE_CLIENT_URN = @AC_LUSTRE_CLIENT_URN@
 AC_LUSTRE_CLI_VER_OFFSET_WARN = @AC_LUSTRE_CLI_VER_OFFSET_WARN@
@@ -175,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -299,8 +298,10 @@ AM_CFLAGS = $(LLCFLAGS)
 
 # LDADD = -lldap
 # LDADD := -lreadline -ltermcap # -lefence
+DIST_SUBDIRS := mpi
+
 noinst_DATA = disk1_4.zip
-noinst_SCRIPTS = leak_finder.pl llecho.sh llmount.sh llmountcleanup.sh test-framework.sh runvmstat runiozone runtests sanity.sh rundbench acceptance-small.sh compile.sh conf-sanity.sh insanity.sh lfscktest.sh oos.sh oos2.sh llog-test.sh recovery-small.sh replay-dual.sh sanity-quota.sh replay-ost-single.sh replay-single.sh run-llog.sh sanityN.sh runracer performance-sanity.sh mdsrate-create-small.sh mdsrate-create-large.sh mdsrate-lookup-1dir.sh mdsrate-stat-small.sh mdsrate-stat-large.sh lockorder.sh socketclient socketserver runmultiop_bg_pause parallel-scale.sh
+noinst_SCRIPTS = leak_finder.pl llmount.sh llmountcleanup.sh functions.sh test-framework.sh runvmstat runiozone runtests sanity.sh rundbench acceptance-small.sh compile.sh conf-sanity.sh insanity.sh lfscktest.sh oos.sh oos2.sh llog-test.sh recovery-small.sh replay-dual.sh sanity-quota.sh replay-ost-single.sh replay-single.sh run-llog.sh sanityN.sh large-scale.sh runracer performance-sanity.sh mdsrate-create-small.sh mdsrate-create-large.sh mdsrate-lookup-1dir.sh mdsrate-lookup-10dirs.sh mdsrate-stat-small.sh mdsrate-stat-large.sh replay-vbr.sh lockorder.sh socketclient socketserver runmultiop_bg_pause recovery-mds-scale.sh run_dd.sh run_tar.sh run_iozone.sh run_dbench.sh run_IOR.sh recovery-double-scale.sh recovery-random-scale.sh parallel-scale.sh
 nobase_noinst_SCRIPTS = cfg/local.sh acl/make-tree acl/run cfg/ncli.sh racer/dir_create.sh racer/file_create.sh racer/file_list.sh racer/file_rm.sh racer/racer.sh racer/file_concat.sh racer/file_link.sh racer/file_rename.sh racer/file_symlink.sh
 nobase_noinst_DATA = acl/cp.test acl/getfacl-noacl.test acl/inheritance.test acl/misc.test acl/permissions.test acl/setfacl.test
 
@@ -308,8 +309,9 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(noinst_DATA) \
              $(nobase_noinst_SCRIPTS) $(nobase_noinst_DATA)
 
 
- at TESTS_TRUE@noinst_PROGRAMS = openunlink truncate directio openme writeme mlink utime it_test tchmod toexcl fsx test_brw openclose createdestroy createmany chownmany statmany multifstat createtest opendirunlink opendevunlink unlinkmany fchdir_test checkstat statone runas openfile getdents o_directory rmdirmany small_write multiop sleeptest ll_sparseness_verify cmknod ll_sparseness_write mrename ll_dirstripe_verify mkdirmany openfilleddirunlink rename_many memhog iopentest1 iopentest2 mmap_sanity flock_test writemany reads flocks_test ll_getstripe_info $(am__append_1)
-# noinst_PROGRAMS += ldaptest copy_attr mkdirdeep 
+ at MPITESTS_TRUE@@TESTS_TRUE at SUBDIRS = mpi
+ at TESTS_TRUE@noinst_PROGRAMS = openunlink truncate directio writeme mlink utime it_test tchmod fsx test_brw  createmany chownmany statmany multifstat createtest opendirunlink opendevunlink unlinkmany checkstat statone runas openfile rmdirmany small_write multiop ll_sparseness_verify ll_sparseness_write mrename ll_dirstripe_verify mkdirmany openfilleddirunlink rename_many memhog iopentest1 iopentest2 mmap_sanity flock_test writemany reads flocks_test ll_getstripe_info
+# noinst_PROGRAMS += copy_attr mkdirdeep 
 @TESTS_TRUE at bin_PROGRAMS = mcreate munlink
 @TESTS_TRUE at testdir = $(libdir)/lustre/tests
 @TESTS_TRUE at test_SCRIPTS = $(noinst_SCRIPTS) $(noinst_PROGRAMS)
@@ -322,24 +324,13 @@ mmap_sanity_SOURCES = mmap_sanity.c
 
 LIBLUSTREAPI := $(top_builddir)/lustre/utils/liblustreapi.a
 ll_getstripe_info_LDADD = $(LIBLUSTREAPI)
-multiop_LDADD = $(LIBLUSTREAPI)
+multiop_LDADD = $(LIBLUSTREAPI) -lrt
 
 ll_dirstripe_verify_SOURCES = ll_dirstripe_verify.c
 ll_dirstripe_verify_LDADD = -L$(top_builddir)/lustre/utils -llustreapi
 
 flocks_test_SOURCES = flocks_test.c
 flocks_test_LDADD = -lpthread
-
-#LAM_LD_FLAGS=-L/opt/lam/lib -lmpi -llam -lpthread
- at MPITESTS_TRUE@LAM_LD_FLAGS = -lmpich -lpthread
- at MPITESTS_TRUE@write_append_truncate_SOURCES = write_append_truncate.c
- at MPITESTS_TRUE@write_append_truncate_LDADD = $(LAM_LD_FLAGS)
- at MPITESTS_TRUE@createmany_mpi_SOURCES = createmany-mpi.c
- at MPITESTS_TRUE@createmany_mpi_LDADD = $(LAM_LD_FLAGS)
- at MPITESTS_TRUE@parallel_grouplock_SOURCES = parallel_grouplock.c lp_utils.c lp_utils.h
- at MPITESTS_TRUE@parallel_grouplock_LDADD = $(LAM_LD_FLAGS)
- at MPITESTS_TRUE@mdsrate_SOURCES = mdsrate.c
- at MPITESTS_TRUE@mdsrate_LDADD = $(LAM_LD_FLAGS) -L$(top_builddir)/lustre/utils -llustreapi
 subdir = lustre/tests
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -347,90 +338,26 @@ CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 @TESTS_TRUE at bin_PROGRAMS = mcreate$(EXEEXT) munlink$(EXEEXT)
 @TESTS_FALSE at bin_PROGRAMS =
- at MPITESTS_FALSE@@TESTS_TRUE at noinst_PROGRAMS = openunlink$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	truncate$(EXEEXT) directio$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	openme$(EXEEXT) writeme$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	mlink$(EXEEXT) utime$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	it_test$(EXEEXT) tchmod$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	toexcl$(EXEEXT) fsx$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	test_brw$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	openclose$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	createdestroy$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	createmany$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	chownmany$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	statmany$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	multifstat$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	createtest$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	opendirunlink$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	opendevunlink$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	unlinkmany$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	fchdir_test$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	checkstat$(EXEEXT) statone$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	runas$(EXEEXT) openfile$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	getdents$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	o_directory$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	rmdirmany$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	small_write$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	multiop$(EXEEXT) sleeptest$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	ll_sparseness_verify$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	cmknod$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	ll_sparseness_write$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	mrename$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	ll_dirstripe_verify$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	mkdirmany$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	openfilleddirunlink$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	rename_many$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	memhog$(EXEEXT) iopentest1$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	iopentest2$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	mmap_sanity$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	flock_test$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	writemany$(EXEEXT) reads$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	flocks_test$(EXEEXT) \
- at MPITESTS_FALSE@@TESTS_TRUE@	ll_getstripe_info$(EXEEXT)
- at MPITESTS_FALSE@@TESTS_FALSE at noinst_PROGRAMS =
- at MPITESTS_TRUE@@TESTS_TRUE at noinst_PROGRAMS = openunlink$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	truncate$(EXEEXT) directio$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	openme$(EXEEXT) writeme$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	mlink$(EXEEXT) utime$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	it_test$(EXEEXT) tchmod$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	toexcl$(EXEEXT) fsx$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	test_brw$(EXEEXT) openclose$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	createdestroy$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	createmany$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	chownmany$(EXEEXT) statmany$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	multifstat$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	createtest$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	opendirunlink$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	opendevunlink$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	unlinkmany$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	fchdir_test$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	checkstat$(EXEEXT) statone$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	runas$(EXEEXT) openfile$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	getdents$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	o_directory$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	rmdirmany$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	small_write$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	multiop$(EXEEXT) sleeptest$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	ll_sparseness_verify$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	cmknod$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	ll_sparseness_write$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	mrename$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	ll_dirstripe_verify$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	mkdirmany$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	openfilleddirunlink$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	rename_many$(EXEEXT) memhog$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	iopentest1$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	iopentest2$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	mmap_sanity$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	flock_test$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	writemany$(EXEEXT) reads$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	flocks_test$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	ll_getstripe_info$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	parallel_grouplock$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	write_append_truncate$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	createmany_mpi$(EXEEXT) \
- at MPITESTS_TRUE@@TESTS_TRUE@	mdsrate$(EXEEXT)
- at MPITESTS_TRUE@@TESTS_FALSE at noinst_PROGRAMS =
+ at TESTS_TRUE@noinst_PROGRAMS = openunlink$(EXEEXT) truncate$(EXEEXT) \
+ at TESTS_TRUE@	directio$(EXEEXT) writeme$(EXEEXT) mlink$(EXEEXT) \
+ at TESTS_TRUE@	utime$(EXEEXT) it_test$(EXEEXT) tchmod$(EXEEXT) \
+ at TESTS_TRUE@	fsx$(EXEEXT) test_brw$(EXEEXT) createmany$(EXEEXT) \
+ at TESTS_TRUE@	chownmany$(EXEEXT) statmany$(EXEEXT) \
+ at TESTS_TRUE@	multifstat$(EXEEXT) createtest$(EXEEXT) \
+ at TESTS_TRUE@	opendirunlink$(EXEEXT) opendevunlink$(EXEEXT) \
+ at TESTS_TRUE@	unlinkmany$(EXEEXT) checkstat$(EXEEXT) \
+ at TESTS_TRUE@	statone$(EXEEXT) runas$(EXEEXT) openfile$(EXEEXT) \
+ at TESTS_TRUE@	rmdirmany$(EXEEXT) small_write$(EXEEXT) \
+ at TESTS_TRUE@	multiop$(EXEEXT) ll_sparseness_verify$(EXEEXT) \
+ at TESTS_TRUE@	ll_sparseness_write$(EXEEXT) mrename$(EXEEXT) \
+ at TESTS_TRUE@	ll_dirstripe_verify$(EXEEXT) mkdirmany$(EXEEXT) \
+ at TESTS_TRUE@	openfilleddirunlink$(EXEEXT) rename_many$(EXEEXT) \
+ at TESTS_TRUE@	memhog$(EXEEXT) iopentest1$(EXEEXT) \
+ at TESTS_TRUE@	iopentest2$(EXEEXT) mmap_sanity$(EXEEXT) \
+ at TESTS_TRUE@	flock_test$(EXEEXT) writemany$(EXEEXT) \
+ at TESTS_TRUE@	reads$(EXEEXT) flocks_test$(EXEEXT) \
+ at TESTS_TRUE@	ll_getstripe_info$(EXEEXT)
+ at TESTS_FALSE@noinst_PROGRAMS =
 PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
 
 checkstat_SOURCES = checkstat.c
@@ -443,27 +370,11 @@ chownmany_OBJECTS = chownmany.$(OBJEXT)
 chownmany_LDADD = $(LDADD)
 chownmany_DEPENDENCIES =
 chownmany_LDFLAGS =
-cmknod_SOURCES = cmknod.c
-cmknod_OBJECTS = cmknod.$(OBJEXT)
-cmknod_LDADD = $(LDADD)
-cmknod_DEPENDENCIES =
-cmknod_LDFLAGS =
-createdestroy_SOURCES = createdestroy.c
-createdestroy_OBJECTS = createdestroy.$(OBJEXT)
-createdestroy_LDADD = $(LDADD)
-createdestroy_DEPENDENCIES =
-createdestroy_LDFLAGS =
 createmany_SOURCES = createmany.c
 createmany_OBJECTS = createmany.$(OBJEXT)
 createmany_LDADD = $(LDADD)
 createmany_DEPENDENCIES =
 createmany_LDFLAGS =
-am__createmany_mpi_SOURCES_DIST = createmany-mpi.c
- at MPITESTS_TRUE@am_createmany_mpi_OBJECTS = createmany-mpi.$(OBJEXT)
-createmany_mpi_OBJECTS = $(am_createmany_mpi_OBJECTS)
- at MPITESTS_TRUE@createmany_mpi_DEPENDENCIES =
- at MPITESTS_FALSE@createmany_mpi_DEPENDENCIES =
-createmany_mpi_LDFLAGS =
 createtest_SOURCES = createtest.c
 createtest_OBJECTS = createtest.$(OBJEXT)
 createtest_LDADD = $(LDADD)
@@ -474,11 +385,6 @@ directio_OBJECTS = directio.$(OBJEXT)
 directio_LDADD = $(LDADD)
 directio_DEPENDENCIES =
 directio_LDFLAGS =
-fchdir_test_SOURCES = fchdir_test.c
-fchdir_test_OBJECTS = fchdir_test.$(OBJEXT)
-fchdir_test_LDADD = $(LDADD)
-fchdir_test_DEPENDENCIES =
-fchdir_test_LDFLAGS =
 flock_test_SOURCES = flock_test.c
 flock_test_OBJECTS = flock_test.$(OBJEXT)
 flock_test_LDADD = $(LDADD)
@@ -493,11 +399,6 @@ fsx_OBJECTS = fsx.$(OBJEXT)
 fsx_LDADD = $(LDADD)
 fsx_DEPENDENCIES =
 fsx_LDFLAGS =
-getdents_SOURCES = getdents.c
-getdents_OBJECTS = getdents.$(OBJEXT)
-getdents_LDADD = $(LDADD)
-getdents_DEPENDENCIES =
-getdents_LDFLAGS =
 iopentest1_SOURCES = iopentest1.c
 iopentest1_OBJECTS = iopentest1.$(OBJEXT)
 iopentest1_LDADD = $(LDADD)
@@ -537,12 +438,6 @@ mcreate_OBJECTS = mcreate.$(OBJEXT)
 mcreate_LDADD = $(LDADD)
 mcreate_DEPENDENCIES =
 mcreate_LDFLAGS =
-am__mdsrate_SOURCES_DIST = mdsrate.c
- at MPITESTS_TRUE@am_mdsrate_OBJECTS = mdsrate.$(OBJEXT)
-mdsrate_OBJECTS = $(am_mdsrate_OBJECTS)
- at MPITESTS_TRUE@mdsrate_DEPENDENCIES =
- at MPITESTS_FALSE@mdsrate_DEPENDENCIES =
-mdsrate_LDFLAGS =
 memhog_SOURCES = memhog.c
 memhog_OBJECTS = memhog.$(OBJEXT)
 memhog_LDADD = $(LDADD)
@@ -582,16 +477,6 @@ munlink_OBJECTS = munlink.$(OBJEXT)
 munlink_LDADD = $(LDADD)
 munlink_DEPENDENCIES =
 munlink_LDFLAGS =
-o_directory_SOURCES = o_directory.c
-o_directory_OBJECTS = o_directory.$(OBJEXT)
-o_directory_LDADD = $(LDADD)
-o_directory_DEPENDENCIES =
-o_directory_LDFLAGS =
-openclose_SOURCES = openclose.c
-openclose_OBJECTS = openclose.$(OBJEXT)
-openclose_LDADD = $(LDADD)
-openclose_DEPENDENCIES =
-openclose_LDFLAGS =
 opendevunlink_SOURCES = opendevunlink.c
 opendevunlink_OBJECTS = opendevunlink.$(OBJEXT)
 opendevunlink_LDADD = $(LDADD)
@@ -612,24 +497,11 @@ openfilleddirunlink_OBJECTS = openfilleddirunlink.$(OBJEXT)
 openfilleddirunlink_LDADD = $(LDADD)
 openfilleddirunlink_DEPENDENCIES =
 openfilleddirunlink_LDFLAGS =
-openme_SOURCES = openme.c
-openme_OBJECTS = openme.$(OBJEXT)
-openme_LDADD = $(LDADD)
-openme_DEPENDENCIES =
-openme_LDFLAGS =
 openunlink_SOURCES = openunlink.c
 openunlink_OBJECTS = openunlink.$(OBJEXT)
 openunlink_LDADD = $(LDADD)
 openunlink_DEPENDENCIES =
 openunlink_LDFLAGS =
-am__parallel_grouplock_SOURCES_DIST = parallel_grouplock.c lp_utils.c \
-	lp_utils.h
- at MPITESTS_TRUE@am_parallel_grouplock_OBJECTS = \
- at MPITESTS_TRUE@	parallel_grouplock.$(OBJEXT) lp_utils.$(OBJEXT)
-parallel_grouplock_OBJECTS = $(am_parallel_grouplock_OBJECTS)
- at MPITESTS_TRUE@parallel_grouplock_DEPENDENCIES =
- at MPITESTS_FALSE@parallel_grouplock_DEPENDENCIES =
-parallel_grouplock_LDFLAGS =
 reads_SOURCES = reads.c
 reads_OBJECTS = reads.$(OBJEXT)
 reads_LDADD = $(LDADD)
@@ -650,11 +522,6 @@ runas_OBJECTS = runas.$(OBJEXT)
 runas_LDADD = $(LDADD)
 runas_DEPENDENCIES =
 runas_LDFLAGS =
-sleeptest_SOURCES = sleeptest.c
-sleeptest_OBJECTS = sleeptest.$(OBJEXT)
-sleeptest_LDADD = $(LDADD)
-sleeptest_DEPENDENCIES =
-sleeptest_LDFLAGS =
 small_write_SOURCES = small_write.c
 small_write_OBJECTS = small_write.$(OBJEXT)
 small_write_LDADD = $(LDADD)
@@ -680,11 +547,6 @@ test_brw_OBJECTS = test_brw.$(OBJEXT)
 test_brw_LDADD = $(LDADD)
 test_brw_DEPENDENCIES =
 test_brw_LDFLAGS =
-toexcl_SOURCES = toexcl.c
-toexcl_OBJECTS = toexcl.$(OBJEXT)
-toexcl_LDADD = $(LDADD)
-toexcl_DEPENDENCIES =
-toexcl_LDFLAGS =
 truncate_SOURCES = truncate.c
 truncate_OBJECTS = truncate.$(OBJEXT)
 truncate_LDADD = $(LDADD)
@@ -700,13 +562,6 @@ utime_OBJECTS = utime.$(OBJEXT)
 utime_LDADD = $(LDADD)
 utime_DEPENDENCIES =
 utime_LDFLAGS =
-am__write_append_truncate_SOURCES_DIST = write_append_truncate.c
- at MPITESTS_TRUE@am_write_append_truncate_OBJECTS = \
- at MPITESTS_TRUE@	write_append_truncate.$(OBJEXT)
-write_append_truncate_OBJECTS = $(am_write_append_truncate_OBJECTS)
- at MPITESTS_TRUE@write_append_truncate_DEPENDENCIES =
- at MPITESTS_FALSE@write_append_truncate_DEPENDENCIES =
-write_append_truncate_LDFLAGS =
 writemany_SOURCES = writemany.c
 writemany_OBJECTS = writemany.$(OBJEXT)
 writemany_LDADD = $(LDADD)
@@ -725,67 +580,60 @@ DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
 @AMDEP_TRUE at DEP_FILES = ./$(DEPDIR)/checkstat.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/chownmany.Po ./$(DEPDIR)/cmknod.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/createdestroy.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/createmany-mpi.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/createmany.Po ./$(DEPDIR)/createtest.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/directio.Po ./$(DEPDIR)/fchdir_test.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/chownmany.Po ./$(DEPDIR)/createmany.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/createtest.Po ./$(DEPDIR)/directio.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/flock_test.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/flocks_test.Po ./$(DEPDIR)/fsx.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/getdents.Po ./$(DEPDIR)/iopentest1.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/iopentest2.Po ./$(DEPDIR)/it_test.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/iopentest1.Po ./$(DEPDIR)/iopentest2.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/it_test.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/ll_dirstripe_verify.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/ll_getstripe_info.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/ll_sparseness_verify.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/ll_sparseness_write.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/lp_utils.Po ./$(DEPDIR)/mcreate.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/mdsrate.Po ./$(DEPDIR)/memhog.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/mcreate.Po ./$(DEPDIR)/memhog.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/mkdirmany.Po ./$(DEPDIR)/mlink.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/mmap_sanity.Po ./$(DEPDIR)/mrename.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/multifstat.Po ./$(DEPDIR)/multiop.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/munlink.Po ./$(DEPDIR)/o_directory.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/openclose.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/opendevunlink.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/munlink.Po ./$(DEPDIR)/opendevunlink.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/opendirunlink.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/openfile.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/openfilleddirunlink.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/openme.Po ./$(DEPDIR)/openunlink.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/parallel_grouplock.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/reads.Po ./$(DEPDIR)/rename_many.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/rmdirmany.Po ./$(DEPDIR)/runas.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/sleeptest.Po ./$(DEPDIR)/small_write.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/openunlink.Po ./$(DEPDIR)/reads.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/rename_many.Po ./$(DEPDIR)/rmdirmany.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/runas.Po ./$(DEPDIR)/small_write.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/statmany.Po ./$(DEPDIR)/statone.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/tchmod.Po ./$(DEPDIR)/test_brw.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/toexcl.Po ./$(DEPDIR)/truncate.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/unlinkmany.Po ./$(DEPDIR)/utime.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/write_append_truncate.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/writemany.Po ./$(DEPDIR)/writeme.Po
+ at AMDEP_TRUE@	./$(DEPDIR)/truncate.Po ./$(DEPDIR)/unlinkmany.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/utime.Po ./$(DEPDIR)/writemany.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/writeme.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-DIST_SOURCES = checkstat.c chownmany.c cmknod.c createdestroy.c \
-	createmany.c $(am__createmany_mpi_SOURCES_DIST) createtest.c \
-	directio.c fchdir_test.c flock_test.c $(flocks_test_SOURCES) \
-	fsx.c getdents.c iopentest1.c iopentest2.c it_test.c \
+DIST_SOURCES = checkstat.c chownmany.c createmany.c createtest.c \
+	directio.c flock_test.c $(flocks_test_SOURCES) fsx.c \
+	iopentest1.c iopentest2.c it_test.c \
 	$(ll_dirstripe_verify_SOURCES) ll_getstripe_info.c \
-	ll_sparseness_verify.c ll_sparseness_write.c mcreate.c \
-	$(am__mdsrate_SOURCES_DIST) memhog.c mkdirmany.c mlink.c \
-	$(mmap_sanity_SOURCES) mrename.c multifstat.c multiop.c \
-	munlink.c o_directory.c openclose.c opendevunlink.c \
-	opendirunlink.c openfile.c openfilleddirunlink.c openme.c \
-	openunlink.c $(am__parallel_grouplock_SOURCES_DIST) reads.c \
-	rename_many.c rmdirmany.c runas.c sleeptest.c small_write.c \
-	statmany.c statone.c tchmod.c test_brw.c toexcl.c truncate.c \
-	unlinkmany.c utime.c $(am__write_append_truncate_SOURCES_DIST) \
-	writemany.c writeme.c
+	ll_sparseness_verify.c ll_sparseness_write.c mcreate.c memhog.c \
+	mkdirmany.c mlink.c $(mmap_sanity_SOURCES) mrename.c \
+	multifstat.c multiop.c munlink.c opendevunlink.c \
+	opendirunlink.c openfile.c openfilleddirunlink.c openunlink.c \
+	reads.c rename_many.c rmdirmany.c runas.c small_write.c \
+	statmany.c statone.c tchmod.c test_brw.c truncate.c \
+	unlinkmany.c utime.c writemany.c writeme.c
 DATA = $(nobase_noinst_DATA) $(nobase_test_DATA) $(noinst_DATA) \
 	$(test_DATA)
 
+
+RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
+	ps-recursive install-info-recursive uninstall-info-recursive \
+	all-recursive install-data-recursive install-exec-recursive \
+	installdirs-recursive install-recursive uninstall-recursive \
+	check-recursive installcheck-recursive
 DIST_COMMON = README $(srcdir)/Makefile.in Makefile.am
-SOURCES = checkstat.c chownmany.c cmknod.c createdestroy.c createmany.c $(createmany_mpi_SOURCES) createtest.c directio.c fchdir_test.c flock_test.c $(flocks_test_SOURCES) fsx.c getdents.c iopentest1.c iopentest2.c it_test.c $(ll_dirstripe_verify_SOURCES) ll_getstripe_info.c ll_sparseness_verify.c ll_sparseness_write.c mcreate.c $(mdsrate_SOURCES) memhog.c mkdirmany.c mlink.c $(mmap_sanity_SOURCES) mrename.c multifstat.c multiop.c munlink.c o_directory.c openclose.c opendevunlink.c opendirunlink.c openfile.c openfilleddirunlink.c openme.c openunlink.c $(parallel_grouplock_SOURCES) reads.c rename_many.c rmdirmany.c runas.c sleeptest.c small_write.c statmany.c statone.c tchmod.c test_brw.c toexcl.c truncate.c unlinkmany.c utime.c $(write_append_truncate_SOURCES) writemany.c writeme.c
+SOURCES = checkstat.c chownmany.c createmany.c createtest.c directio.c flock_test.c $(flocks_test_SOURCES) fsx.c iopentest1.c iopentest2.c it_test.c $(ll_dirstripe_verify_SOURCES) ll_getstripe_info.c ll_sparseness_verify.c ll_sparseness_write.c mcreate.c memhog.c mkdirmany.c mlink.c $(mmap_sanity_SOURCES) mrename.c multifstat.c multiop.c munlink.c opendevunlink.c opendirunlink.c openfile.c openfilleddirunlink.c openunlink.c reads.c rename_many.c rmdirmany.c runas.c small_write.c statmany.c statone.c tchmod.c test_brw.c truncate.c unlinkmany.c utime.c writemany.c writeme.c
 
-all: all-am
+all: all-recursive
 
 .SUFFIXES:
 .SUFFIXES: .c .o .obj
@@ -827,27 +675,15 @@ checkstat$(EXEEXT): $(checkstat_OBJECTS) $(checkstat_DEPENDENCIES)
 chownmany$(EXEEXT): $(chownmany_OBJECTS) $(chownmany_DEPENDENCIES) 
 	@rm -f chownmany$(EXEEXT)
 	$(LINK) $(chownmany_LDFLAGS) $(chownmany_OBJECTS) $(chownmany_LDADD) $(LIBS)
-cmknod$(EXEEXT): $(cmknod_OBJECTS) $(cmknod_DEPENDENCIES) 
-	@rm -f cmknod$(EXEEXT)
-	$(LINK) $(cmknod_LDFLAGS) $(cmknod_OBJECTS) $(cmknod_LDADD) $(LIBS)
-createdestroy$(EXEEXT): $(createdestroy_OBJECTS) $(createdestroy_DEPENDENCIES) 
-	@rm -f createdestroy$(EXEEXT)
-	$(LINK) $(createdestroy_LDFLAGS) $(createdestroy_OBJECTS) $(createdestroy_LDADD) $(LIBS)
 createmany$(EXEEXT): $(createmany_OBJECTS) $(createmany_DEPENDENCIES) 
 	@rm -f createmany$(EXEEXT)
 	$(LINK) $(createmany_LDFLAGS) $(createmany_OBJECTS) $(createmany_LDADD) $(LIBS)
-createmany_mpi$(EXEEXT): $(createmany_mpi_OBJECTS) $(createmany_mpi_DEPENDENCIES) 
-	@rm -f createmany_mpi$(EXEEXT)
-	$(LINK) $(createmany_mpi_LDFLAGS) $(createmany_mpi_OBJECTS) $(createmany_mpi_LDADD) $(LIBS)
 createtest$(EXEEXT): $(createtest_OBJECTS) $(createtest_DEPENDENCIES) 
 	@rm -f createtest$(EXEEXT)
 	$(LINK) $(createtest_LDFLAGS) $(createtest_OBJECTS) $(createtest_LDADD) $(LIBS)
 directio$(EXEEXT): $(directio_OBJECTS) $(directio_DEPENDENCIES) 
 	@rm -f directio$(EXEEXT)
 	$(LINK) $(directio_LDFLAGS) $(directio_OBJECTS) $(directio_LDADD) $(LIBS)
-fchdir_test$(EXEEXT): $(fchdir_test_OBJECTS) $(fchdir_test_DEPENDENCIES) 
-	@rm -f fchdir_test$(EXEEXT)
-	$(LINK) $(fchdir_test_LDFLAGS) $(fchdir_test_OBJECTS) $(fchdir_test_LDADD) $(LIBS)
 flock_test$(EXEEXT): $(flock_test_OBJECTS) $(flock_test_DEPENDENCIES) 
 	@rm -f flock_test$(EXEEXT)
 	$(LINK) $(flock_test_LDFLAGS) $(flock_test_OBJECTS) $(flock_test_LDADD) $(LIBS)
@@ -857,9 +693,6 @@ flocks_test$(EXEEXT): $(flocks_test_OBJECTS) $(flocks_test_DEPENDENCIES)
 fsx$(EXEEXT): $(fsx_OBJECTS) $(fsx_DEPENDENCIES) 
 	@rm -f fsx$(EXEEXT)
 	$(LINK) $(fsx_LDFLAGS) $(fsx_OBJECTS) $(fsx_LDADD) $(LIBS)
-getdents$(EXEEXT): $(getdents_OBJECTS) $(getdents_DEPENDENCIES) 
-	@rm -f getdents$(EXEEXT)
-	$(LINK) $(getdents_LDFLAGS) $(getdents_OBJECTS) $(getdents_LDADD) $(LIBS)
 iopentest1$(EXEEXT): $(iopentest1_OBJECTS) $(iopentest1_DEPENDENCIES) 
 	@rm -f iopentest1$(EXEEXT)
 	$(LINK) $(iopentest1_LDFLAGS) $(iopentest1_OBJECTS) $(iopentest1_LDADD) $(LIBS)
@@ -884,9 +717,6 @@ ll_sparseness_write$(EXEEXT): $(ll_sparseness_write_OBJECTS) $(ll_sparseness_wri
 mcreate$(EXEEXT): $(mcreate_OBJECTS) $(mcreate_DEPENDENCIES) 
 	@rm -f mcreate$(EXEEXT)
 	$(LINK) $(mcreate_LDFLAGS) $(mcreate_OBJECTS) $(mcreate_LDADD) $(LIBS)
-mdsrate$(EXEEXT): $(mdsrate_OBJECTS) $(mdsrate_DEPENDENCIES) 
-	@rm -f mdsrate$(EXEEXT)
-	$(LINK) $(mdsrate_LDFLAGS) $(mdsrate_OBJECTS) $(mdsrate_LDADD) $(LIBS)
 memhog$(EXEEXT): $(memhog_OBJECTS) $(memhog_DEPENDENCIES) 
 	@rm -f memhog$(EXEEXT)
 	$(LINK) $(memhog_LDFLAGS) $(memhog_OBJECTS) $(memhog_LDADD) $(LIBS)
@@ -911,12 +741,6 @@ multiop$(EXEEXT): $(multiop_OBJECTS) $(multiop_DEPENDENCIES)
 munlink$(EXEEXT): $(munlink_OBJECTS) $(munlink_DEPENDENCIES) 
 	@rm -f munlink$(EXEEXT)
 	$(LINK) $(munlink_LDFLAGS) $(munlink_OBJECTS) $(munlink_LDADD) $(LIBS)
-o_directory$(EXEEXT): $(o_directory_OBJECTS) $(o_directory_DEPENDENCIES) 
-	@rm -f o_directory$(EXEEXT)
-	$(LINK) $(o_directory_LDFLAGS) $(o_directory_OBJECTS) $(o_directory_LDADD) $(LIBS)
-openclose$(EXEEXT): $(openclose_OBJECTS) $(openclose_DEPENDENCIES) 
-	@rm -f openclose$(EXEEXT)
-	$(LINK) $(openclose_LDFLAGS) $(openclose_OBJECTS) $(openclose_LDADD) $(LIBS)
 opendevunlink$(EXEEXT): $(opendevunlink_OBJECTS) $(opendevunlink_DEPENDENCIES) 
 	@rm -f opendevunlink$(EXEEXT)
 	$(LINK) $(opendevunlink_LDFLAGS) $(opendevunlink_OBJECTS) $(opendevunlink_LDADD) $(LIBS)
@@ -929,15 +753,9 @@ openfile$(EXEEXT): $(openfile_OBJECTS) $(openfile_DEPENDENCIES)
 openfilleddirunlink$(EXEEXT): $(openfilleddirunlink_OBJECTS) $(openfilleddirunlink_DEPENDENCIES) 
 	@rm -f openfilleddirunlink$(EXEEXT)
 	$(LINK) $(openfilleddirunlink_LDFLAGS) $(openfilleddirunlink_OBJECTS) $(openfilleddirunlink_LDADD) $(LIBS)
-openme$(EXEEXT): $(openme_OBJECTS) $(openme_DEPENDENCIES) 
-	@rm -f openme$(EXEEXT)
-	$(LINK) $(openme_LDFLAGS) $(openme_OBJECTS) $(openme_LDADD) $(LIBS)
 openunlink$(EXEEXT): $(openunlink_OBJECTS) $(openunlink_DEPENDENCIES) 
 	@rm -f openunlink$(EXEEXT)
 	$(LINK) $(openunlink_LDFLAGS) $(openunlink_OBJECTS) $(openunlink_LDADD) $(LIBS)
-parallel_grouplock$(EXEEXT): $(parallel_grouplock_OBJECTS) $(parallel_grouplock_DEPENDENCIES) 
-	@rm -f parallel_grouplock$(EXEEXT)
-	$(LINK) $(parallel_grouplock_LDFLAGS) $(parallel_grouplock_OBJECTS) $(parallel_grouplock_LDADD) $(LIBS)
 reads$(EXEEXT): $(reads_OBJECTS) $(reads_DEPENDENCIES) 
 	@rm -f reads$(EXEEXT)
 	$(LINK) $(reads_LDFLAGS) $(reads_OBJECTS) $(reads_LDADD) $(LIBS)
@@ -950,9 +768,6 @@ rmdirmany$(EXEEXT): $(rmdirmany_OBJECTS) $(rmdirmany_DEPENDENCIES)
 runas$(EXEEXT): $(runas_OBJECTS) $(runas_DEPENDENCIES) 
 	@rm -f runas$(EXEEXT)
 	$(LINK) $(runas_LDFLAGS) $(runas_OBJECTS) $(runas_LDADD) $(LIBS)
-sleeptest$(EXEEXT): $(sleeptest_OBJECTS) $(sleeptest_DEPENDENCIES) 
-	@rm -f sleeptest$(EXEEXT)
-	$(LINK) $(sleeptest_LDFLAGS) $(sleeptest_OBJECTS) $(sleeptest_LDADD) $(LIBS)
 small_write$(EXEEXT): $(small_write_OBJECTS) $(small_write_DEPENDENCIES) 
 	@rm -f small_write$(EXEEXT)
 	$(LINK) $(small_write_LDFLAGS) $(small_write_OBJECTS) $(small_write_LDADD) $(LIBS)
@@ -968,9 +783,6 @@ tchmod$(EXEEXT): $(tchmod_OBJECTS) $(tchmod_DEPENDENCIES)
 test_brw$(EXEEXT): $(test_brw_OBJECTS) $(test_brw_DEPENDENCIES) 
 	@rm -f test_brw$(EXEEXT)
 	$(LINK) $(test_brw_LDFLAGS) $(test_brw_OBJECTS) $(test_brw_LDADD) $(LIBS)
-toexcl$(EXEEXT): $(toexcl_OBJECTS) $(toexcl_DEPENDENCIES) 
-	@rm -f toexcl$(EXEEXT)
-	$(LINK) $(toexcl_LDFLAGS) $(toexcl_OBJECTS) $(toexcl_LDADD) $(LIBS)
 truncate$(EXEEXT): $(truncate_OBJECTS) $(truncate_DEPENDENCIES) 
 	@rm -f truncate$(EXEEXT)
 	$(LINK) $(truncate_LDFLAGS) $(truncate_OBJECTS) $(truncate_LDADD) $(LIBS)
@@ -980,9 +792,6 @@ unlinkmany$(EXEEXT): $(unlinkmany_OBJECTS) $(unlinkmany_DEPENDENCIES)
 utime$(EXEEXT): $(utime_OBJECTS) $(utime_DEPENDENCIES) 
 	@rm -f utime$(EXEEXT)
 	$(LINK) $(utime_LDFLAGS) $(utime_OBJECTS) $(utime_LDADD) $(LIBS)
-write_append_truncate$(EXEEXT): $(write_append_truncate_OBJECTS) $(write_append_truncate_DEPENDENCIES) 
-	@rm -f write_append_truncate$(EXEEXT)
-	$(LINK) $(write_append_truncate_LDFLAGS) $(write_append_truncate_OBJECTS) $(write_append_truncate_LDADD) $(LIBS)
 writemany$(EXEEXT): $(writemany_OBJECTS) $(writemany_DEPENDENCIES) 
 	@rm -f writemany$(EXEEXT)
 	$(LINK) $(writemany_LDFLAGS) $(writemany_OBJECTS) $(writemany_LDADD) $(LIBS)
@@ -1040,17 +849,12 @@ distclean-compile:
 
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/checkstat.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/chownmany.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cmknod.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/createdestroy.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/createmany-mpi.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/createmany.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/createtest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/directio.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fchdir_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/flock_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/flocks_test.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fsx.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/getdents.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/iopentest1.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/iopentest2.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/it_test.Po at am__quote@
@@ -1058,9 +862,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ll_getstripe_info.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ll_sparseness_verify.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ll_sparseness_write.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lp_utils.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mcreate.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mdsrate.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/memhog.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mkdirmany.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mlink.Po at am__quote@
@@ -1069,30 +871,23 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/multifstat.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/multiop.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/munlink.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/o_directory.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/openclose.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/opendevunlink.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/opendirunlink.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/openfile.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/openfilleddirunlink.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/openme.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/openunlink.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/parallel_grouplock.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/reads.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rename_many.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rmdirmany.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/runas.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/sleeptest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/small_write.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/statmany.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/statone.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tchmod.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_brw.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/toexcl.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/truncate.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/unlinkmany.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/utime.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/write_append_truncate.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/writemany.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/writeme.Po at am__quote@
 
@@ -1155,6 +950,65 @@ uninstall-testDATA:
 	  rm -f $(DESTDIR)$(testdir)/$$f; \
 	done
 
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+	@set fnord $$MAKEFLAGS; amf=$$2; \
+	dot_seen=no; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	rev=''; for subdir in $$list; do \
+	  if test "$$subdir" = "."; then :; else \
+	    rev="$$subdir $$rev"; \
+	  fi; \
+	done; \
+	rev="$$rev ."; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+ctags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+	done
+
 ETAGS = etags
 ETAGSFLAGS =
 
@@ -1172,10 +1026,21 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	       END { for (i in files) print i; }'`; \
 	mkid -fID $$unique
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
+	if (etags --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	else \
+	  include_option=--include; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -f $$subdir/TAGS && \
+	      tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
 	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
 	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@@ -1187,7 +1052,7 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 	     $$tags $$unique
 
 ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
 		$(TAGS_FILES) $(LISP)
 	tags=; \
 	here=`pwd`; \
@@ -1241,21 +1106,35 @@ distdir: $(DISTFILES)
 	    || exit 1; \
 	  fi; \
 	done
+	list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d $(distdir)/$$subdir \
+	    || mkdir $(distdir)/$$subdir \
+	    || exit 1; \
+	    (cd $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$(top_distdir)" \
+	        distdir=../$(distdir)/$$subdir \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
 check-am: all-am
-check: check-am
+check: check-recursive
 all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA)
-
-installdirs:
+installdirs: installdirs-recursive
+installdirs-am:
 	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(testdir) $(DESTDIR)$(testdir) $(DESTDIR)$(testdir) $(DESTDIR)$(testdir)
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
+
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
 
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 
-installcheck: installcheck-am
+installcheck: installcheck-recursive
 install-strip:
 	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
 	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@@ -1272,22 +1151,22 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
+clean: clean-recursive
 
 clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \
 	mostlyclean-am
 
-distclean: distclean-am
+distclean: distclean-recursive
 	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
 
-dvi: dvi-am
+dvi: dvi-recursive
 
 dvi-am:
 
-info: info-am
+info: info-recursive
 
 info-am:
 
@@ -1296,26 +1175,26 @@ install-data-am: install-nobase_testDATA install-nobase_testSCRIPTS \
 
 install-exec-am: install-binPROGRAMS
 
-install-info: install-info-am
+install-info: install-info-recursive
 
 install-man:
 
 installcheck-am:
 
-maintainer-clean: maintainer-clean-am
+maintainer-clean: maintainer-clean-recursive
 	-rm -rf ./$(DEPDIR)
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
-mostlyclean: mostlyclean-am
+mostlyclean: mostlyclean-recursive
 
 mostlyclean-am: mostlyclean-compile mostlyclean-generic
 
-pdf: pdf-am
+pdf: pdf-recursive
 
 pdf-am:
 
-ps: ps-am
+ps: ps-recursive
 
 ps-am:
 
@@ -1323,20 +1202,28 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am \
 	uninstall-nobase_testDATA uninstall-nobase_testSCRIPTS \
 	uninstall-testDATA uninstall-testSCRIPTS
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
-	clean-generic clean-noinstPROGRAMS ctags distclean \
-	distclean-compile distclean-generic distclean-tags distdir dvi \
-	dvi-am info info-am install install-am install-binPROGRAMS \
-	install-data install-data-am install-exec install-exec-am \
-	install-info install-info-am install-man \
+uninstall-info: uninstall-info-recursive
+
+.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
+	clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \
+	clean-recursive ctags ctags-recursive distclean \
+	distclean-compile distclean-generic distclean-recursive \
+	distclean-tags distdir dvi dvi-am dvi-recursive info info-am \
+	info-recursive install install-am install-binPROGRAMS \
+	install-data install-data-am install-data-recursive \
+	install-exec install-exec-am install-exec-recursive \
+	install-info install-info-am install-info-recursive install-man \
 	install-nobase_testDATA install-nobase_testSCRIPTS \
-	install-strip install-testDATA install-testSCRIPTS installcheck \
-	installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
-	uninstall-am uninstall-binPROGRAMS uninstall-info-am \
+	install-recursive install-strip install-testDATA \
+	install-testSCRIPTS installcheck installcheck-am installdirs \
+	installdirs-am installdirs-recursive maintainer-clean \
+	maintainer-clean-generic maintainer-clean-recursive mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-recursive \
+	pdf pdf-am pdf-recursive ps ps-am ps-recursive tags \
+	tags-recursive uninstall uninstall-am uninstall-binPROGRAMS \
+	uninstall-info-am uninstall-info-recursive \
 	uninstall-nobase_testDATA uninstall-nobase_testSCRIPTS \
-	uninstall-testDATA uninstall-testSCRIPTS
+	uninstall-recursive uninstall-testDATA uninstall-testSCRIPTS
 
 
 #copy_attr_LDADD= -lattr
diff --git a/lustre/tests/acceptance-small.sh b/lustre/tests/acceptance-small.sh
index 6b1359d..8d8cc8d 100755
--- a/lustre/tests/acceptance-small.sh
+++ b/lustre/tests/acceptance-small.sh
@@ -23,7 +23,7 @@ fi
 [ "$DEBUG_OFF" ] || DEBUG_OFF="eval lctl set_param debug=\"$DEBUG_LVL\""
 [ "$DEBUG_ON" ] || DEBUG_ON="eval lctl set_param debug=0x33f0484"
 
-export TESTSUITE_LIST="RUNTESTS SANITY DBENCH BONNIE IOZONE FSX SANITYN LFSCK LIBLUSTRE RACER REPLAY_SINGLE CONF_SANITY RECOVERY_SMALL REPLAY_OST_SINGLE REPLAY_DUAL INSANITY SANITY_QUOTA PERFORMANCE_SANITY PARALLEL_SCALE"
+export TESTSUITE_LIST="RUNTESTS SANITY DBENCH BONNIE IOZONE FSX SANITYN LFSCK LIBLUSTRE RACER REPLAY_SINGLE CONF_SANITY RECOVERY_SMALL REPLAY_OST_SINGLE REPLAY_DUAL REPLAY_VBR INSANITY SANITY_QUOTA PERFORMANCE_SANITY LARGE_SCALE RECOVERY_MDS_SCALE RECOVERY_DOUBLE_SCALE RECOVERY_RANDOM_SCALE PARALLEL_SCALE"
 
 if [ "$ACC_SM_ONLY" ]; then
     for O in $TESTSUITE_LIST; do
@@ -269,10 +269,11 @@ for NAME in $CONFIGS; do
 		SPACE=`df -P $MOUNT | tail -n 1 | awk '{ print $4 }'`
 		[ $SPACE -lt $FSX_SIZE ] && FSX_SIZE=$((SPACE * 3 / 4))
 		$DEBUG_OFF
+		FSX_SEED=${FSX_SEED:-$RANDOM}
 		rm -f $MOUNT/fsxfile
 		$LFS setstripe -c -1 $MOUNT/fsxfile
-		echo Using FSX_SIZE=$FSX_SIZE COUNT=$COUNT
-		./fsx -c 50 -p 1000 -P $TMP -l $FSX_SIZE \
+		echo Using FSX_SEED=$FSX_SEED FSX_SIZE=$FSX_SIZE COUNT=$COUNT
+		./fsx -c 50 -p 1000 -S $FSX_SEED -P $TMP -l $FSX_SIZE \
 			-N $(($COUNT * 100)) $MOUNT/fsxfile
 		$DEBUG_ON
 		$CLEANUP
@@ -303,8 +304,8 @@ for NAME in $CONFIGS; do
 		if [ -x /usr/sbin/lfsck ]; then
 			bash lfscktest.sh
 		else
-			log "$(e2fsck -V)"
-			log "SKIP: e2fsck does not support lfsck"
+			log "$($E2FSCK -V)"
+			log "SKIP: $E2FSCK does not support lfsck"
 		fi
 		LFSCK="done"
 	fi
@@ -324,8 +325,12 @@ for NAME in $CONFIGS; do
 		#export LIBLUSTRE_DEBUG_MASK=`lctl get_param -n debug`
 		if [ -x $LIBLUSTRETESTS/sanity ]; then
 			mkdir -p $MOUNT2
-			echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
-			$LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET
+			if [ "$LIBLUSTRE_EXCEPT" ]; then
+				LIBLUSTRE_OPT="$LIBLUSTRE_OPT \
+					$(echo ' '$LIBLUSTRE_EXCEPT  | sed -re 's/\s+/ -e /g')"
+			fi
+			echo $LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET $LIBLUSTRE_OPT
+			$LIBLUSTRETESTS/sanity --target=$LIBLUSTRE_MOUNT_TARGET $LIBLUSTRE_OPT
 		fi
 		$CLEANUP
 		#$SETUP
@@ -340,8 +345,8 @@ for NAME in $CONFIGS; do
 		[ "$SLOW" = "no" ] && DURATION=300
 		RACERCLIENTS=$HOSTNAME
 		[ ! -z ${CLIENTS} ] && RACERCLIENTS=$CLIENTS
-		log "racer on clients: $RACERCLIENTS DURATION=$DURATION"
-		CLIENTS=${RACERCLIENTS} DURATION=$DURATION bash runracer
+		log "racer on clients: $RACERCLIENTS DURATION=$DURATION RACERDIRS=$RACERDIRS"
+		CLIENTS=${RACERCLIENTS} DURATION=$DURATION bash runracer $RACERDIRS
 		$CLEANUP
 		$SETUP
 		RACER="done"
@@ -384,6 +389,13 @@ if [ "$REPLAY_DUAL" != "no" ]; then
         REPLAY_DUAL="done"
 fi
 
+[ "$REPLAY_VBR" != "no" ] && skip_remmds replay-vbr && REPLAY_VBR=no && MSKIPPED=1
+if [ "$REPLAY_VBR" != "no" ]; then
+        title replay-vbr
+        bash replay-vbr.sh
+        REPLAY_VBR="done"
+fi
+
 [ "$INSANITY" != "no" ] && skip_remmds insanity && INSANITY=no && MSKIPPED=1
 [ "$INSANITY" != "no" ] && skip_remost insanity && INSANITY=no && OSKIPPED=1
 if [ "$INSANITY" != "no" ]; then
@@ -410,6 +422,36 @@ if [ "$PERFORMANCE_SANITY" != "no" ]; then
         PERFORMANCE_SANITY="done"
 fi
 
+[ "$LARGE_SCALE" != "no" ] && skip_remmds large-scale && LARGE_SCALE=no && MSKIPPED=1
+if [ "$LARGE_SCALE" != "no" ]; then
+        title large-scale
+        bash large-scale.sh
+        LARGE_SCALE="done"
+fi
+
+[ "$RECOVERY_MDS_SCALE" != "no" ] && skip_remmds recovery-mds-scale && RECOVERY_MDS_SCALE=no && MSKIPPED=1
+[ "$RECOVERY_MDS_SCALE" != "no" ] && skip_remost recovery-mds-scale && RECOVERY_MDS_SCALE=no && OSKIPPED=1
+if [ "$RECOVERY_MDS_SCALE" != "no" ]; then
+        title recovery-mds-scale
+        bash recovery-mds-scale.sh
+        RECOVERY_MDS_SCALE="done"
+fi
+
+[ "$RECOVERY_DOUBLE_SCALE" != "no" ] && skip_remmds recovery-double-scale && RECOVERY_DOUBLE_SCALE=no && MSKIPPED=1
+[ "$RECOVERY_DOUBLE_SCALE" != "no" ] && skip_remost recovery-double-scale && RECOVERY_DOUBLE_SCALE=no && OSKIPPED=1
+if [ "$RECOVERY_DOUBLE_SCALE" != "no" ]; then
+        title recovery-double-scale
+        bash recovery-double-scale.sh
+        RECOVERY_DOUBLE_SCALE="done"
+fi
+
+[ "$RECOVERY_RANDOM_SCALE" != "no" ] && skip_remmds recovery-random-scale && RECOVERY_RANDOM_SCALE=no && MSKIPPED=1
+if [ "$RECOVERY_RANDOM_SCALE" != "no" ]; then
+        title recovery-random-scale
+        bash recovery-random-scale.sh
+        RECOVERY_RANDOM_SCALE="done"
+fi
+
 which mpirun > /dev/null 2>&1 || PARALLEL_SCALE="no"
 if [ "$PARALLEL_SCALE" != "no" ]; then
         title parallel-scale
diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh
index b811dde..7b1f550 100644
--- a/lustre/tests/cfg/local.sh
+++ b/lustre/tests/cfg/local.sh
@@ -15,6 +15,8 @@ MDSDEV=${MDSDEV:-$TMP/${FSNAME}-mdt}
 MDSSIZE=${MDSSIZE:-400000}
 MDSOPT=${MDSOPT:-"--mountfsoptions=acl"}
 
+mdsfailover_dev=${mdsfailover_dev:-$MDSDEV}
+
 OSTCOUNT=${OSTCOUNT:-2}
 OSTDEVBASE=${OSTDEVBASE:-$TMP/${FSNAME}-ost}
 OSTSIZE=${OSTSIZE:-300000}
@@ -36,6 +38,10 @@ SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff}
 
 L_GETGROUPS=${L_GETGROUPS:-`do_facet mds which l_getgroups || echo`}
 
+ENABLE_QUOTA=${ENABLE_QUOTA:-""}
+QUOTA_TYPE=${QUOTA_TYPE:-"ug3"}
+QUOTA_USERS=${QUOTA_USERS:-"quota_usr quota_2usr sanityusr sanityusr1"}
+
 MKFSOPT=""
 [ "x$MDSJOURNALSIZE" != "x" ] &&
     MKFSOPT=$MKFSOPT" -J size=$MDSJOURNALSIZE"
diff --git a/lustre/tests/cfg/ncli.sh b/lustre/tests/cfg/ncli.sh
index c583c5f..a3fff9f 100644
--- a/lustre/tests/cfg/ncli.sh
+++ b/lustre/tests/cfg/ncli.sh
@@ -15,3 +15,10 @@ MPIBIN=${MPIBIN:-/testsuite/tests/`arch`/bin}
 export PATH=:$PATH:$MPIBIN
 MPIRUN=$(which mpirun) || true
 MPI_USER=${MPI_USER:-mpiuser}
+
+# for recovery scale tests
+# default boulder cluster iozone location
+export PATH=/opt/iozone/bin:$PATH
+SHARED_DIRECTORY=${SHARED_DIRECTORY:-""}	# bug 17839 comment 65
+LOADS="dd tar dbench iozone"
+CLIENT_LOADS=($LOADS)
diff --git a/lustre/tests/cmknod.c b/lustre/tests/cmknod.c
deleted file mode 100644
index 49e7ecc..0000000
--- a/lustre/tests/cmknod.c
+++ /dev/null
@@ -1,167 +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  2008 Sun Microsystems, Inc. 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.
- *
- * lustre/tests/cmknod.c
- *
- * Simple test to check that device nodes are correctly created and visible
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#define TEST_MINOR 120
-#define TEST_MAJOR 25
-
-void usage(char *prog)
-{
-	fprintf(stderr, "usage: %s <filename>\n", prog);
-	exit(1);
-}
-
-/* UMKA: This stuff inlined here instead of using appropriate header 
-   to avoid linking to symbols which is not present in newer libc.
-   
-   Currently this is the case, as UML image contains RedHat 9 and 
-   developers use something newer (Fedora, etc.). */
-inline unsigned int
-__gnu_dev_major (unsigned long long int __dev)
-{
-	return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
-}
-
-inline unsigned int
-__gnu_dev_minor (unsigned long long int __dev)
-{
-	return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
-}
-
-inline unsigned long long int
-__gnu_dev_makedev (unsigned int __major, unsigned int __minor)
-{
-	return ((__minor & 0xff) | ((__major & 0xfff) << 8)
-		| (((unsigned long long int) (__minor & ~0xff)) << 12)
-		| (((unsigned long long int) (__major & ~0xfff)) << 32));
-}
-
-#define __minor(dev) __gnu_dev_minor(dev)
-#define __major(dev) __gnu_dev_major(dev)
-#define __makedev(maj, min) __gnu_dev_makedev(maj, min)
-
-int main( int argc, char **argv)
-{
-	char *prog = argv[0];
-	char *filename = argv[1];
-	int rc;
-	struct stat st;
-	dev_t device = __makedev(TEST_MAJOR, TEST_MINOR);
-
-	if (argc != 2) 
-		usage(prog);
-
-	unlink(filename);
-	
-	/* First try block devices */
-	rc = mknod(filename, 0700 | S_IFBLK, device);
-	if ( rc < 0 ) {
-		fprintf(stderr, "%s: mknod(%s) failed: rc %d: %s\n",
-			prog, filename, errno, strerror(errno));
-		return 2;
-	}
-
-	rc = stat(filename, &st);
-	if ( rc < 0 ) {
-		fprintf(stderr, "%s: stat(%s) failed: rc %d: %s\n",
-			prog, filename, errno, strerror(errno));
-		return 3;
-	}
-	
-	if ( st.st_rdev != device) {
-		fprintf(stderr, "%s: created device other than requested: (%u,%u) instead of (%u,%u)\n", 
-			prog, __major(st.st_rdev),__minor(st.st_rdev),__major(device),__minor(device));
-		return 4;
-	}
-	if (!S_ISBLK(st.st_mode)) {
-		fprintf(stderr, "%s: created device of different type. Requested block device, got mode %o\n", prog, st.st_mode);
-		return 5;
-	}
-
-	rc = unlink(filename);
-	if ( rc < 0 ) {
-		fprintf(stderr, "%s: Cannot unlink created device %s, rc %d: %s\n",
-			prog, filename, errno, strerror(errno));
-		return 6;
-	}
-
-	/* Second try char devices */
-	rc = mknod(filename, 0700 | S_IFCHR, device);
-	if ( rc < 0 ) {
-		fprintf(stderr, "%s: mknod(%s) failed: rc %d: %s\n",
-			prog, filename, errno, strerror(errno));
-		return 7;
-	}
-
-	rc = stat(filename, &st);
-	if ( rc < 0 ) {
-		fprintf(stderr, "%s: stat(%s) failed: rc %d: %s\n",
-			prog, filename, errno, strerror(errno));
-		return 8;
-	}
-	if ( st.st_rdev != device) {
-		fprintf(stderr, "%s: created device other than requested: (%u,%u) instead of (%u,%u)\n", 
-			prog, __major(st.st_rdev),__minor(st.st_rdev),__major(device),__minor(device));
-		return 9;
-	}
-	if (!S_ISCHR(st.st_mode)) {
-		fprintf(stderr, "%s: created device of different type. Requested char device, got mode %o\n", prog, st.st_mode);
-		return 10;
-	}
-
-	rc = unlink(filename);
-	if ( rc < 0 ) {
-		fprintf(stderr, "%s: Cannot unlink created device %s, rc %d: %s\n",
-			prog, filename, errno, strerror(errno));
-		return 11;
-	}
-
-	printf("%s: device nodes created correctly\n", prog);
-
-	return 0;
-}
diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh
index f37ed32..a07e9b2 100644
--- a/lustre/tests/conf-sanity.sh
+++ b/lustre/tests/conf-sanity.sh
@@ -47,25 +47,31 @@ reformat() {
 }
 
 writeconf() {
-    local facet=mds
-    shift
-    stop ${facet} -f
-    rm -f ${facet}active
-    # who knows if/where $TUNEFS is installed?  Better reformat if it fails...
-    do_facet ${facet} "$TUNEFS --writeconf $MDSDEV" || echo "tunefs failed, reformatting instead" && reformat
+	local facet=mds
+	shift
+	stop ${facet} -f
+	rm -f ${facet}active
+	# who knows if/where $TUNEFS is installed?  Better reformat if it fails...
+	do_facet ${facet} "$TUNEFS --writeconf $MDSDEV" || echo "tunefs failed, reformatting instead" && reformat
+
+	gen_config
 }
 
 gen_config() {
-        reformat
-        # The MGS must be started before the OSTs for a new fs, so start
-        # and stop to generate the startup logs. 
+	# The MGS must be started before the OSTs for a new fs, so start
+	# and stop to generate the startup logs.
 	start_mds
 	start_ost
-	sleep 5
+	wait_osc_import_state mds ost FULL
 	stop_ost
 	stop_mds
 }
 
+reformat_and_config() {
+	reformat
+	gen_config
+}
+
 start_mds() {
 	echo "start mds service on `facet_active_host mds`"
 	start mds $MDSDEV $MDS_MOUNT_OPTS || return 94
@@ -101,12 +107,12 @@ stop_ost2() {
 
 start_client() {
 	echo "start client on `facet_active_host client`"
-	start client || return 99 
+	start client || return 99
 }
 
 stop_client() {
 	echo "stop client on `facet_active_host client`"
-	stop client || return 100 
+	stop client || return 100
 }
 
 mount_client() {
@@ -143,6 +149,7 @@ setup() {
 	start_ost
 	start_mds
 	mount_client $MOUNT
+	df $MOUNT
 }
 
 setup_noconfig() {
@@ -165,17 +172,17 @@ cleanup() {
 check_mount() {
 	do_facet client "cp /etc/passwd $DIR/a" || return 71
 	do_facet client "rm $DIR/a" || return 72
-	# make sure lustre is actually mounted (touch will block, 
-        # but grep won't, so do it after) 
+	# make sure lustre is actually mounted (touch will block,
+        # but grep won't, so do it after)
         do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
 	echo "setup single mount lustre success"
 }
 
 check_mount2() {
-	do_facet client "touch $DIR/a" || return 71	
-	do_facet client "rm $DIR/a" || return 72	
-	do_facet client "touch $DIR2/a" || return 73	
-	do_facet client "rm $DIR2/a" || return 74	
+	do_facet client "touch $DIR/a" || return 71
+	do_facet client "rm $DIR/a" || return 72
+	do_facet client "touch $DIR2/a" || return 73
+	do_facet client "rm $DIR2/a" || return 74
 	echo "setup double mount lustre success"
 }
 
@@ -193,8 +200,7 @@ fi
 
 #create single point mountpoint
 
-gen_config
-
+reformat_and_config
 
 test_0() {
         setup
@@ -214,7 +220,7 @@ run_test 1 "start up ost twice (should return errors)"
 
 test_2() {
 	start_ost
-	start_mds	
+	start_mds
 	echo "start mds second time.."
 	start_mds
 	mount_client $MOUNT
@@ -301,7 +307,7 @@ test_5b() {
 	grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10
 	mount_client $MOUNT && return 1
 	grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11
-	umount_client $MOUNT	
+	umount_client $MOUNT
 	# stop_mds is a no-op here, and should not fail
 	cleanup_nocli || return $?
 	return 0
@@ -423,9 +429,9 @@ test_16() {
         cleanup || return $?
 
         log "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
-        EXPECTEDOBJECTSMODE=`do_facet mds "debugfs -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
-        EXPECTEDLOGSMODE=`do_facet mds "debugfs -R 'stat LOGS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
-        EXPECTEDPENDINGMODE=`do_facet mds "debugfs -R 'stat PENDING' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
+        EXPECTEDOBJECTSMODE=`do_facet mds "$DEBUGFS -R 'stat OBJECTS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
+        EXPECTEDLOGSMODE=`do_facet mds "$DEBUGFS -R 'stat LOGS' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
+        EXPECTEDPENDINGMODE=`do_facet mds "$DEBUGFS -R 'stat PENDING' $MDSDEV 2> /dev/null" | grep 'Mode: ' | sed -e "s/.*Mode: *//" -e "s/ *Flags:.*//"`
 
         if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
                 log "Success:Lustre change the mode of OBJECTS correctly"
@@ -456,11 +462,11 @@ test_17() {
         fi
 
         echo "Remove mds config log"
-        do_facet mds "debugfs -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
+        do_facet mds "$DEBUGFS -w -R 'unlink CONFIGS/$FSNAME-MDT0000' $MDSDEV || return \$?" || return $?
 
         start_ost
 	start_mds && return 42
-	gen_config
+	reformat_and_config
 }
 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
 
@@ -500,13 +506,13 @@ test_18() {
 
         MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$myMDSSIZE --param sys.timeout=$TIMEOUT $MDSOPT"
 
-        gen_config
+        reformat_and_config
         echo "mount lustre system..."
 	setup
         check_mount || return 41
 
         echo "check journal size..."
-        local FOUNDSIZE=`do_facet mds "debugfs -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
+        local FOUNDSIZE=`do_facet mds "$DEBUGFS -c -R 'stat <8>' $MDSDEV" | awk '/Size: / { print $NF; exit;}'`
         if [ $FOUNDSIZE -gt $((32 * 1024 * 1024)) ]; then
                 log "Success: mkfs creates large journals. Size: $((FOUNDSIZE >> 20))M"
         else
@@ -516,7 +522,7 @@ test_18() {
         cleanup || return $?
 
         MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
-        gen_config
+        reformat_and_config
 }
 run_test 18 "check mkfs creates large journals"
 
@@ -556,6 +562,7 @@ run_test 20 "remount ro,rw mounts work and doesn't break /etc/mtab"
 test_21a() {
         start_mds
 	start_ost
+	wait_osc_import_state mds ost FULL
 	stop_ost
 	stop_mds
 }
@@ -564,6 +571,7 @@ run_test 21a "start mds before ost, stop ost first"
 test_21b() {
         start_ost
 	start_mds
+	wait_osc_import_state mds ost FULL
 	stop_mds
 	stop_ost
 }
@@ -573,6 +581,8 @@ test_21c() {
         start_ost
 	start_mds
 	start_ost2
+	wait_osc_import_state mds ost2 FULL
+
 	stop_ost
 	stop_ost2
 	stop_mds
@@ -586,9 +596,7 @@ test_22() {
 
 	echo Client mount with ost in logs, but none running
 	start_ost
-	# wait until mds connected to ost and open client connection
-	# ping_interval + 1
-	sleep $((TIMEOUT / 4 + 1))
+	wait_osc_import_state mds ost FULL
 	stop_ost
 	mount_client $MOUNT
 	# check_mount will block trying to contact ost
@@ -608,7 +616,7 @@ run_test 22 "start a client before osts (should return errs)"
 test_23a() {	# was test_23
         setup
         # fail mds
-	stop mds   
+	stop mds
 	# force down client so that recovering mds waits for reconnect
 	local running=$(grep -c $MOUNT /proc/mounts) || true
     	if [ $running -ne 0 ]; then
@@ -712,11 +720,11 @@ test_24a() {
 	rm $MOUNT2/b || return 4
 	# 2 is actually mounted
         grep $MOUNT2' ' /proc/mounts > /dev/null || return 5
-	# failover 
+	# failover
 	facet_failover fs2mds
 	facet_failover fs2ost
 	df
- 	umount_client $MOUNT 
+ 	umount_client $MOUNT
 	# the MDS must remain up until last MDT
 	stop_mds
 	MDS=$(do_facet mds "lctl get_param -n devices" | awk '($3 ~ "mdt" && $4 ~ "MDS") { print $4 }')
@@ -734,7 +742,7 @@ test_24b() {
 
 	local fs2mdsdev=${fs2mds_DEV:-${MDSDEV}_2}
 
-	add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10 
+	add fs2mds $MDS_MKFS_OPTS --fsname=${FSNAME}2 --mgs --reformat $fs2mdsdev || exit 10
 	setup
 	start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && return 2
 	cleanup || return 6
@@ -768,7 +776,7 @@ set_and_check() {
 	local myfacet=$1
 	local TEST=$2
 	local PARAM=$3
-	local ORIG=$(do_facet $myfacet "$TEST") 
+	local ORIG=$(do_facet $myfacet "$TEST")
 	if [ $# -gt 3 ]; then
 	    local FINAL=$4
 	else
@@ -784,8 +792,8 @@ set_and_check() {
 test_27a() {
 	start_ost || return 1
 	start_mds || return 2
-	echo "Requeue thread should have started: " 
-	ps -e | grep ll_cfg_requeue 
+	echo "Requeue thread should have started: "
+	ps -e | grep ll_cfg_requeue
 	set_and_check ost1 "lctl get_param -n obdfilter.$FSNAME-OST0000.client_cache_seconds" "$FSNAME-OST0000.ost.client_cache_seconds" || return 3
 	cleanup_nocli
 }
@@ -846,7 +854,7 @@ test_29() {
 	    echo "Live client success: got $RESULT"
 	fi
 
-	# check MDT too 
+	# check MDT too
 	local MPROC="osc.$FSNAME-OST0001-osc.active"
 	local MAX=30
 	local WAIT=0
@@ -885,9 +893,6 @@ test_29() {
 	cleanup_nocli
 	#writeconf to remove all ost2 traces for subsequent tests
 	writeconf
-	start_mds
-	start_ost
-	cleanup
 }
 run_test 29 "permanently remove an OST"
 
@@ -900,10 +905,10 @@ test_30() {
 	for i in ${LIST[@]}; do
 	    set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $i || return 3
 	done
-	# make sure client restart still works 
+	# make sure client restart still works
  	umount_client $MOUNT
 	mount_client $MOUNT || return 4
-	[ "$($TEST)" -ne "$i" ] && return 5   
+	[ "$($TEST)" -ne "$i" ] && return 5
 	set_and_check client "$TEST" "$FSNAME.llite.max_read_ahead_whole_mb" $ORIG || return 6
 	cleanup
 }
@@ -917,7 +922,7 @@ test_31() { # bug 10734
 run_test 31 "Connect to non-existent node (returns errors, should not crash)"
 
 # Use these start32/stop32 fn instead of t-f start/stop fn,
-# for local devices, to skip global facet vars init 
+# for local devices, to skip global facet vars init
 stop32 () {
 	local facet=$1
 	shift
@@ -939,7 +944,7 @@ start32 () {
 	if [ $RC -ne 0 ]; then
 		echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
 		echo "Start of ${device} of local ${facet} failed ${RC}"
-	fi 
+	fi
 	losetup -a
 	return $RC
 }
@@ -978,41 +983,28 @@ test_32a() {
 	# nids are wrong, so client wont work, but server should start
 	start32 mds $tmpdir/mds "-o loop,exclude=lustre-OST0000" && \
 		trap cleanup_32 EXIT INT || return 3
-        
+
 	local UUID=$(lctl get_param -n mds.lustre-MDT0000.uuid)
 	echo MDS uuid $UUID
-	[ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID" 
+	[ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
 
 	$TUNEFS --mgsnode=`hostname` $tmpdir/ost1 || error "tunefs failed"
 	start32 ost1 $tmpdir/ost1 "-o loop" || return 5
 	UUID=$(lctl get_param -n obdfilter.lustre-OST0000.uuid)
 	echo OST uuid $UUID
-	[ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID" 
+	[ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
 
 	local NID=$($LCTL list_nids | head -1)
 
-	echo "OSC changes should return err:" 
+	echo "OSC changes should return err:"
 	$LCTL conf_param lustre-OST0000.osc.max_dirty_mb=15 && return 7
 	$LCTL conf_param lustre-OST0000.failover.node=$NID && return 8
 	echo "ok."
-	echo "MDC changes should succeed:" 
+	echo "MDC changes should succeed:"
 	$LCTL conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
 	$LCTL conf_param lustre-MDT0000.failover.node=$NID || return 10
 	echo "ok."
 
-	# With a new good MDT failover nid, we should be able to mount a client
-	# (but it cant talk to OST)
-	local mountopt="-o exclude=lustre-OST0000"
-
-	local device=`h2$NETTYPE $HOSTNAME`:/lustre
-	echo "Starting local client: $HOSTNAME: $mountopt $device $MOUNT"
-	mount -t lustre $mountopt $device $MOUNT || return 1
-
-	local old=$(lctl get_param -n mdc.*.max_rpcs_in_flight)
-	local new=$((old + 5))
-	lctl conf_param lustre-MDT0000.mdc.max_rpcs_in_flight=$new
-	wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
-
 	cleanup_32
 
 	# mount a second time to make sure we didnt leave upgrade flag on
@@ -1049,7 +1041,7 @@ test_32b() {
 
 	local UUID=$(lctl get_param -n mds.${NEWNAME}-MDT0000.uuid)
 	echo MDS uuid $UUID
-	[ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID" 
+	[ "$UUID" == "mdsA_UUID" ] || error "UUID is wrong: $UUID"
 
 	$TUNEFS --mgsnode=`hostname` --fsname=$NEWNAME --writeconf $tmpdir/ost1 || error "tunefs failed"
 	start32 ost1 $tmpdir/ost1 "-o loop" || return 5
@@ -1057,11 +1049,11 @@ test_32b() {
 	echo OST uuid $UUID
 	[ "$UUID" == "ost1_UUID" ] || error "UUID is wrong: $UUID"
 
-	echo "OSC changes should succeed:" 
+	echo "OSC changes should succeed:"
 	$LCTL conf_param ${NEWNAME}-OST0000.osc.max_dirty_mb=15 || return 7
 	$LCTL conf_param ${NEWNAME}-OST0000.failover.node=$NID || return 8
 	echo "ok."
-	echo "MDC changes should succeed:" 
+	echo "MDC changes should succeed:"
 	$LCTL conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=9 || return 9
 	echo "ok."
 
@@ -1078,7 +1070,7 @@ test_32b() {
 	lctl conf_param ${NEWNAME}-MDT0000.mdc.max_rpcs_in_flight=$new
 	wait_update $HOSTNAME "lctl get_param -n mdc.*.max_rpcs_in_flight" $new || return 11
 
-	[ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12  
+	[ "$(cksum $MOUNT/passwd | cut -d' ' -f 1,2)" == "2479747619 779" ] || return 12
 	echo "ok."
 
 	cleanup_32
@@ -1110,7 +1102,7 @@ test_33a() { # bug 12333, was test_33
         cp /etc/hosts $MOUNT2/. || rc=3
         echo "ok."
 
-        cp /etc/hosts $MOUNT2/ || rc=3 
+        cp /etc/hosts $MOUNT2/ || rc=3
         $LFS getstripe $MOUNT2/hosts
 
         umount -d $MOUNT2
@@ -1162,7 +1154,7 @@ test_34b() {
 	fi
 
 	cleanup
-	return 0	
+	return 0
 }
 run_test 34b "force umount with failed mds should be normal"
 
@@ -1178,7 +1170,7 @@ test_34c() {
 	fi
 
 	cleanup
-	return 0	
+	return 0
 }
 run_test 34c "force umount with failed ost should be normal"
 
@@ -1275,17 +1267,17 @@ test_36() { # 12743
 
         ALLOWANCE=$((64 * $OSTCOUNT))
 
-        if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||  
+        if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||
            [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
                 echo "**** FAIL: df total($DFTOTAL) mismatch OST total($BKTOTAL)"
                 rc=1
         fi
-        if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] || 
+        if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] ||
            [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
                 echo "**** FAIL: df free($DFFREE) mismatch OST free($BKFREE)"
                 rc=2
         fi
-        if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] || 
+        if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] ||
            [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
                 echo "**** FAIL: df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
                 rc=3
@@ -1343,8 +1335,8 @@ test_38() { # bug 14222
 	stop_mds
 	log "rename lov_objid file on MDS"
 	rm -f $TMP/lov_objid.orig
-	do_facet mds "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
-	do_facet mds "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV"
+	do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.orig\\\" $MDSDEV"
+	do_facet mds "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
 
 	do_facet mds "od -Ax -td8 $TMP/lov_objid.orig"
 	# check create in mds_lov_connect
@@ -1354,18 +1346,18 @@ test_38() { # bug 14222
 		[ $V ] && log "verifying $DIR/$tdir/$f"
 		diff -q $f $DIR/$tdir/$f || ERROR=y
 	done
-	do_facet mds "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\"  $MDSDEV"
+	do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new\\\"  $MDSDEV"
 	do_facet mds "od -Ax -td8 $TMP/lov_objid.new"
 	[ "$ERROR" = "y" ] && error "old and new files are different after connect" || true
-	
-	
+
+
 	# check it's updates in sync
 	umount_client $MOUNT
 	stop_mds
-	
+
 	do_facet mds dd if=/dev/zero of=$TMP/lov_objid.clear bs=4096 count=1
-	do_facet mds "debugfs -w -R \\\"rm lov_objid\\\" $MDSDEV"
-	do_facet mds "debugfs -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
+	do_facet mds "$DEBUGFS -w -R \\\"rm lov_objid\\\" $MDSDEV"
+	do_facet mds "$DEBUGFS -w -R \\\"write $TMP/lov_objid.clear lov_objid\\\" $MDSDEV "
 
 	start_mds
 	mount_client $MOUNT
@@ -1373,12 +1365,12 @@ test_38() { # bug 14222
 		[ $V ] && log "verifying $DIR/$tdir/$f"
 		diff -q $f $DIR/$tdir/$f || ERROR=y
 	done
-        do_facet mds "debugfs -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
+        do_facet mds "$DEBUGFS -c -R \\\"dump lov_objid $TMP/lov_objid.new1\\\" $MDSDEV"
 	do_facet mds "od -Ax -td8 $TMP/lov_objid.new1"
 	umount_client $MOUNT
 	stop_mds
 	[ "$ERROR" = "y" ] && error "old and new files are different after sync" || true
-	
+
 	log "files compared the same"
 	cleanup
 }
@@ -1388,7 +1380,7 @@ test_39() { #bug 14413
         PTLDEBUG=+malloc
         setup
         cleanup
-        perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' && 
+        perl $SRCDIR/leak_finder.pl $TMP/debug 2>&1 | egrep '*** Leak:' &&
                 error "memory leak detected" || true
 }
 run_test 39 "leak_finder recognizes both LUSTRE and LNET malloc messages"
@@ -1406,7 +1398,7 @@ test_41() { #bug 14134
         local rc
         start mds $MDSDEV $MDS_MOUNT_OPTS -o nosvc -n
         start ost1 `ostdevname 1` $OST_MOUNT_OPTS
-        start mds $MDSDEV $MDS_MOUNT_OPTS -o nomgs
+        start mds $MDSDEV $MDS_MOUNT_OPTS -o nomgs,force
         mkdir -p $MOUNT
         mount_client $MOUNT || return 1
         sleep 5
@@ -1434,6 +1426,45 @@ test_42() { #bug 14693
 }
 run_test 42 "invalid config param should not prevent client from mounting"
 
+test_43() { #bug 15993
+        setup
+        VERSION_1_8=$(do_facet mds $LCTL get_param version | grep ^lustre.*1\.[78])
+        if [ -z "$VERSION_1_8" ]; then
+                skip "skipping test for non 1.8 MDS"
+                cleanup
+                return 0
+        fi
+
+        check_mount || return 2
+        testfile=$DIR/$tfile
+        lma="this-should-be-removed-after-remount-and-accessed"
+        touch $testfile
+        echo "set/get trusted.lma"
+#define OBD_FAIL_MDS_ALLOW_COMMON_EA_SETTING    0x13f
+        do_facet mds "lctl set_param fail_loc=0x13f"
+        lctl set_param fail_loc=0x13f
+        setfattr -n trusted.lma -v $lma $testfile || error "create common EA"
+        do_facet mds "lctl set_param fail_loc=0"
+        lctl set_param fail_loc=0
+        ATTR=$(getfattr -n trusted.lma $testfile 2> /dev/null | grep trusted.lma)
+        [ "$ATTR" = "trusted.lma=\"$lma\"" ] || error "check common EA"
+        umount_client $MOUNT
+        stop_mds
+        sleep 5
+        start_mds
+        mount_client $MOUNT
+        check_mount || return 3
+#define OBD_FAIL_MDS_REMOVE_COMMON_EA    0x13e
+        do_facet mds "lctl set_param fail_loc=0x13e"
+        stat $testfile
+        do_facet mds "lctl set_param fail_loc=0"
+        getfattr -d -m trusted $testfile 2> /dev/null | \
+            grep "trusted.lma" && error "common EA not removed" || true
+        cleanup
+        return 0
+}
+run_test 43 "remove common EA if it exists"
+
 test_44() { # 16317
         setup
         check_mount || return 2
@@ -1477,17 +1508,19 @@ test_46a() {
 	start_mds || return 1
 	#first client should see only one ost
 	start_ost || return 2
+	wait_osc_import_state mds ost FULL
 	#start_client
 	mount_client $MOUNT || return 3
-	
+
 	start_ost2 || return 4
 	start ost3 `ostdevname 3` $OST_MOUNT_OPTS || return 5
 	start ost4 `ostdevname 4` $OST_MOUNT_OPTS || return 6
 	start ost5 `ostdevname 5` $OST_MOUNT_OPTS || return 7
-	# wait until ost2-5 is sync
-	# ping_interval + 1
-	sleep $((TIMEOUT / 4 + 1))
-	#second client see both ost's
+        wait_osc_import_state mds ost2 FULL
+        wait_osc_import_state mds ost3 FULL
+        wait_osc_import_state mds ost4 FULL
+        wait_osc_import_state mds ost5 FULL
+        #second client see all ost's
 
 	mount_client $MOUNT2 || return 8
 	$LFS setstripe $MOUNT2 -c -1 || return 9
@@ -1496,7 +1529,7 @@ test_46a() {
 	echo "ok" > $MOUNT2/widestripe
 	$LFS getstripe $MOUNT2/widestripe || return 11
 	# fill acl buffer for avoid expand lsm to them
-	awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do  
+	awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
 	    setfacl -m $acl $MOUNT2/widestripe
 	done
 
@@ -1527,7 +1560,7 @@ test_47() { #17674
             lru_size[count]=$lrs
             let count=count+1
         done
-        
+
         facet_failover ost1
         facet_failover mds
         df -h $MOUNT || return 3
@@ -1541,7 +1574,7 @@ test_47() { #17674
             fi
             let count=count+1
         done
-        
+
         cleanup
         return 0
 }
@@ -1552,9 +1585,7 @@ cleanup_48() {
 
 	# reformat after this test is needed - if test will failed
 	# we will have unkillable file at FS
-	reformat
-	setup_noconfig
-	cleanup || error "can't cleanup"
+	reformat_and_config
 }
 
 test_48() { # bug 17636
@@ -1576,12 +1607,239 @@ test_48() { # bug 17636
 	done
 
 	stat $MOUNT/widestripe || return 12
-	
+
 	cleanup_48
 	return 0
 }
 run_test 48 "too many acls on file"
 
+# check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
+test_49() { # bug 17710
+	local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
+	local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
+	local LOCAL_TIMEOUT=20
+
+	OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
+
+	reformat
+	start_mds
+	start_ost
+	mount_client $MOUNT
+	check_mount || return 1
+
+	echo "check ldlm_timout..."
+	LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
+	LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
+	LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
+
+	if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
+		error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
+	fi
+
+	if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
+		error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
+	fi
+
+	umount_client $MOUNT
+	stop_ost || return 2
+	stop_mds || return 3
+
+	OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$((LOCAL_TIMEOUT - 1)) $MKFSOPT $OSTOPT"
+
+	reformat
+	start_mds || return 4
+	start_ost || return 5
+	mount_client $MOUNT || return 6
+	check_mount || return 7
+
+	LDLM_MDS="`do_facet mds lctl get_param -n ldlm_timeout`"
+	LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
+	LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
+
+	if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
+		error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
+	fi
+
+	if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
+		error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
+	fi
+
+	cleanup || return $?
+
+	MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
+	OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
+}
+run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
+
+lazystatfs() {
+        # Test both statfs and lfs df and fail if either one fails
+	multiop_bg_pause $1 f_
+	RC1=$?
+	PID=$!
+	killall -USR1 multiop
+	[ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
+	wait $PID || { RC1=$?; log "multiop return error "; }
+
+	$LFS df &
+	PID=$!
+	sleep 5
+	kill -s 0 $PID
+	RC2=$?
+	if [ $RC2 -eq 0 ]; then
+	    kill -s 9 $PID
+	    log "lazystatfs df failed"
+	fi
+
+	RC=0
+	[[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
+	return $RC
+}
+
+test_50a() {
+	setup
+	lctl set_param llite.$FSNAME-*.lazystatfs=1
+	touch $DIR/$tfile
+
+	lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
+
+	cleanup || return $?
+}
+run_test 50a "lazystatfs all servers available =========================="
+
+test_50b() {
+	setup
+	lctl set_param llite.$FSNAME-*.lazystatfs=1
+	touch $DIR/$tfile
+
+	# Wait for client to detect down OST
+	stop_ost || error "Unable to stop OST1"
+	wait_osc_import_state mds ost DISCONN
+
+	lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
+
+	umount_client $MOUNT || error "Unable to unmount client"
+	stop_mds || error "Unable to stop MDS"
+}
+run_test 50b "lazystatfs all servers down =========================="
+
+test_50c() {
+	start_mds || error "Unable to start MDS"
+	start_ost || error "Unable to start OST1"
+	start_ost2 || error "Unable to start OST2"
+	mount_client $MOUNT || error "Unable to mount client"
+	lctl set_param llite.$FSNAME-*.lazystatfs=1
+	touch $DIR/$tfile
+
+	# Wait for client to detect down OST
+	stop_ost || error "Unable to stop OST1"
+	wait_osc_import_state mds ost DISCONN
+	lazystatfs $MOUNT || error "lazystatfs failed with one down server"
+
+ 	umount_client $MOUNT || error "Unable to unmount client"
+	stop_ost2 || error "Unable to stop OST2"
+	stop_mds || error "Unable to stop MDS"
+}
+run_test 50c "lazystatfs one server down =========================="
+
+test_50d() {
+	start_mds || error "Unable to start MDS"
+	start_ost || error "Unable to start OST1"
+	start_ost2 || error "Unable to start OST2"
+	mount_client $MOUNT || error "Unable to mount client"
+	lctl set_param llite.$FSNAME-*.lazystatfs=1
+	touch $DIR/$tfile
+
+	# Issue the statfs during the window where the client still
+	# belives the OST to be available but it is in fact down.
+	# No failure just a statfs which hangs for a timeout interval.
+	stop_ost || error "Unable to stop OST1"
+	lazystatfs $MOUNT || error "lazystatfs failed with one down server"
+
+ 	umount_client $MOUNT || error "Unable to unmount client"
+	stop_ost2 || error "Unable to stop OST2"
+	stop_mds || error "Unable to stop MDS"
+}
+run_test 50d "lazystatfs client/server conn race =========================="
+
+test_50e() {
+	local RC1
+	local pid
+
+	reformat_and_config
+	start_mds || return 1
+	#first client should see only one ost
+	start_ost || return 2
+	wait_osc_import_state mds ost FULL
+
+	# Wait for client to detect down OST
+	stop_ost || error "Unable to stop OST1"
+	wait_osc_import_state mds ost DISCONN
+
+	mount_client $MOUNT || error "Unable to mount client"
+	lctl set_param llite.$FSNAME-*.lazystatfs=0
+
+	multiop_bg_pause $MOUNT _f
+	RC1=$?
+	pid=$!
+
+	if [ $RC1 -ne 0 ]; then
+		log "lazystatfs multiop failed $RC1"
+	else
+	    kill -USR1 $pid
+	    sleep $(( $TIMEOUT+1 ))
+	    kill -0 $pid
+	    [ $? -ne 0 ] && error "process isn't sleep"
+	    start_ost || error "Unable to start OST1"
+	    wait $pid || error "statfs failed"
+	fi
+
+	umount_client $MOUNT || error "Unable to unmount client"
+	stop_ost || error "Unable to stop OST1"
+	stop_mds || error "Unable to stop MDS"
+}
+run_test 50e "normal statfs all servers down =========================="
+
+test_50f() {
+	local RC1
+	local pid
+	CONN_PROC="osc.$FSNAME-OST0001-osc.ost_server_uuid"
+
+	start_mds || error "Unable to start mds"
+	#first client should see only one ost
+	start_ost || error "Unable to start OST1"
+	wait_osc_import_state mds ost FULL
+
+	start_ost2 || error "Unable to start OST2"
+	wait_osc_import_state mds ost2 FULL
+
+	# Wait for client to detect down OST
+	stop_ost2 || error "Unable to stop OST2"
+	wait_osc_import_state mds ost2 DISCONN
+
+	mount_client $MOUNT || error "Unable to mount client"
+	lctl set_param llite.$FSNAME-*.lazystatfs=0
+
+	multiop_bg_pause $MOUNT _f
+	RC1=$?
+	pid=$!
+
+	if [ $RC1 -ne 0 ]; then
+		log "lazystatfs multiop failed $RC1"
+	else
+	    kill -USR1 $pid
+	    sleep $(( $TIMEOUT+1 ))
+	    kill -0 $pid
+	    [ $? -ne 0 ] && error "process isn't sleep"
+	    start_ost2 || error "Unable to start OST2"
+	    wait $pid || error "statfs failed"
+	    stop_ost2 || error "Unable to stop OST2"
+	fi
+
+	umount_client $MOUNT || error "Unable to unmount client"
+	stop_ost || error "Unable to stop OST1"
+	stop_mds || error "Unable to stop MDS"
+}
+run_test 50f "normal statfs one server in down =========================="
 
 equals_msg `basename $0`: test complete
 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true
diff --git a/lustre/tests/createdestroy.c b/lustre/tests/createdestroy.c
deleted file mode 100644
index bc145e4..0000000
--- a/lustre/tests/createdestroy.c
+++ /dev/null
@@ -1,258 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <time.h>
-#include <sys/time.h>
-
-int thread;
-
-#define BAD_VERBOSE (-999999999)
-
-#define difftime(a, b)                                          \
-        ((double)(a)->tv_sec - (b)->tv_sec +                    \
-         ((double)((a)->tv_usec - (b)->tv_usec) / 1000000))
-
-static char *cmdname(char *func)
-{
-        static char buf[512];
-
-        if (thread) {
-                sprintf(buf, "%s-%d", func, thread);
-                return buf;
-        }
-
-        return func;
-}
-
-static int be_verbose(int verbose, struct timeval *next_time,
-                      unsigned long num, unsigned long *next_num, int num_total)
-{
-        struct timeval now;
-
-        if (!verbose)
-                return 0;
-
-        if (next_time != NULL)
-                gettimeofday(&now, NULL);
-
-        /* A positive verbosity means to print every X iterations */
-        if (verbose > 0 && (num >= *next_num || num >= num_total)) {
-                *next_num += verbose;
-                if (next_time) {
-                        next_time->tv_sec = now.tv_sec - verbose;
-                        next_time->tv_usec = now.tv_usec;
-                }
-                return 1;
-        }
-
-        /* A negative verbosity means to print at most each X seconds */
-        if (verbose < 0 && next_time != NULL && difftime(&now, next_time) >= 0){
-                next_time->tv_sec = now.tv_sec - verbose;
-                next_time->tv_usec = now.tv_usec;
-                *next_num = num;
-                return 1;
-        }
-
-        return 0;
-}
-
-static int get_verbose(char *func, const char *arg)
-{
-        int verbose;
-        char *end;
-
-        if (!arg || arg[0] == 'v')
-                verbose = 1;
-        else if (arg[0] == 's' || arg[0] == 'q')
-                verbose = 0;
-        else {
-                verbose = (int)strtoul(arg, &end, 0);
-                if (*end) {
-                        fprintf(stderr, "%s: error: bad verbose option '%s'\n",
-                                func, arg);
-                        return BAD_VERBOSE;
-                }
-        }
-
-        if (verbose < 0)
-                printf("Print status every %d seconds\n", -verbose);
-        else if (verbose == 1)
-                printf("Print status every operation\n");
-        else if (verbose > 1)
-                printf("Print status every %d operations\n", verbose);
-
-        return verbose;
-}
-
-int main(int argc, char *argv[])
-{
-        char filename[1024];
-        int verbose = 0;
-        unsigned long count, i;
-        int threads = 0;
-        char *end;
-        int rc = 0;
-
-        if (argc < 3 || argc > 5) {
-                fprintf(stderr,
-                        "usage: %s <filename> <count> [verbose [threads]]\n",
-                        argv[0]);
-                exit(1);
-        }
-
-        count = strtoul(argv[2], &end, 0);
-        if (*end) {
-                fprintf(stderr, "%s: error: bad iteration count '%s'\n",
-                        argv[0], argv[1]);
-                exit(2);
-        }
-        if (argc == 4) {
-                verbose = get_verbose(argv[0], argv[3]);
-                if (verbose == BAD_VERBOSE)
-                        exit(2);
-        }
-        if (argc == 5) {
-                threads = strtoul(argv[4], &end, 0);
-                if (*end) {
-                        fprintf(stderr, "%s: error: bad thread count '%s'\n",
-                                argv[0], argv[1]);
-                        exit(2);
-                }
-        }
-
-        for (i = 1; i <= threads; i++) {
-                rc = fork();
-                if (rc < 0) {
-                        fprintf(stderr, "%s: error: #%ld - %s\n",
-                                cmdname(argv[0]), i, strerror(rc = errno));
-                        break;
-                } else if (rc == 0) {
-                        thread = i;
-                        break;
-                } else
-                        printf("%s: thread #%ld (PID %d) started\n",
-                               cmdname(argv[0]), i, rc);
-                rc = 0;
-        }
-
-        if (threads && thread == 0) {   /* parent process */
-                int live_threads = threads;
-
-                while (live_threads > 0) {
-                        int status;
-                        pid_t ret;
-
-                        ret = waitpid(0, &status, 0);
-                        if (ret == 0) {
-                                continue;
-                        }
-
-                        if (ret < 0) {
-                                fprintf(stderr, "%s: error: wait - %s\n",
-                                        argv[0], strerror(errno));
-                                if (!rc)
-                                        rc = errno;
-                        } else {
-                                /*
-                                 * This is a hack.  We _should_ be able to use
-                                 * WIFEXITED(status) to see if there was an
-                                 * error, but it appears to be broken and it
-                                 * always returns 1 (OK).  See wait(2).
-                                 */
-                                int err = WEXITSTATUS(status);
-                                if (err || WIFSIGNALED(status))
-                                        fprintf(stderr,
-                                                "%s: error: PID %d had rc=%d\n",
-                                                argv[0], ret, err);
-                                if (!rc)
-                                        rc = err;
-
-                                live_threads--;
-                        }
-                }
-        } else {
-                struct timeval start, end, next_time;
-                unsigned long next_count;
-                double diff;
-
-                gettimeofday(&start, NULL);
-                next_time.tv_sec = start.tv_sec - verbose;
-                next_time.tv_usec = start.tv_usec;
-
-                for (i = 0, next_count = verbose; i < count; i++) {
-                        if (threads)
-                                sprintf(filename, "%s-%d-%ld",
-                                        argv[1], thread, i);
-                        else
-                                sprintf(filename, "%s-%ld", argv[1], i);
-
-                        rc = mknod(filename, S_IFREG, 0);
-                        if (rc < 0) {
-                                fprintf(stderr, "%s: error: mknod(%s): %s\n",
-                                        cmdname(argv[0]), filename,
-                                        strerror(errno));
-                                rc = errno;
-                                break;
-                        }
-                        if (unlink(filename) < 0) {
-                                fprintf(stderr, "%s: error: unlink(%s): %s\n",
-                                        cmdname(argv[0]), filename,
-                                        strerror(errno));
-                                rc = errno;
-                                break;
-                        }
-                        if (be_verbose(verbose, &next_time,i,&next_count,count))
-                                printf("%s: number %ld\n", cmdname(argv[0]), i);
-                }
-
-                gettimeofday(&end, NULL);
-                diff = difftime(&end, &start);
-
-                printf("%s: %ldx2 files in %.4gs (%.4g ops/s): rc = %d: %s",
-                       cmdname(argv[0]), i, diff, (double)i * 2 / diff,
-                       rc, ctime(&end.tv_sec));
-        }
-        return rc;
-}
diff --git a/lustre/tests/createmany-mpi.c b/lustre/tests/createmany-mpi.c
deleted file mode 100644
index 6e558fc..0000000
--- a/lustre/tests/createmany-mpi.c
+++ /dev/null
@@ -1,176 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <errno.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "mpi.h"
-
-void usage(char *prog)
-{
-        printf("usage: %s {-o|-m|-l<tgt>} filenamefmt count\n", prog);
-        printf("       %s {-o|-m|-l<tgt>} filenamefmt -seconds\n", prog);
-        printf("       %s {-o|-m|-l<tgt>} filenamefmt start count\n", prog);
-}
-
-/* Print process rank, loop count, message, and exit (i.e. a fatal error) */
-int rprintf(int rank, int loop, const char *fmt, ...)
-{
-        va_list       ap;
-
-        printf("rank %d, loop %d: ", rank, loop);
-
-        va_start(ap, fmt);
-
-        printf(fmt, ap);
-
-        MPI_Finalize();
-        exit(1);
-}
-
-int main(int argc, char ** argv)
-{
-        int i, rc = 0, do_open = 0, do_link = 0, rank;
-        char format[4096], *fmt, *tgt;
-        char filename[4096];
-        long start, last, end;
-        long begin = 0, count;
-
-        rc = MPI_Init(&argc, &argv);
-        if (rc != MPI_SUCCESS)
-                rprintf(-1, -1, "MPI_Init failed: %d\n", rc);
-
-        if (argc < 4 || argc > 5) {
-                usage(argv[0]);
-                return 1;
-        }
-
-        if (strcmp(argv[1], "-o") == 0) {
-                do_open = 1;
-                tgt = NULL;
-        } else if (strncmp(argv[1], "-l", 2) == 0 && argv[1][2]) {
-                tgt = argv[1] + 2;
-                do_link = 1;
-        } else if (strcmp(argv[1], "-m") != 0) {
-                usage(argv[0]);
-                return 1;
-        }
-
-        if (strlen(argv[2]) > 4080) {
-                printf("name too long\n");
-                return 1;
-        }
-
-        rc = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-        if (rc != MPI_SUCCESS)
-                rprintf(-1, -1, "MPI_Comm_rank failed: %d\n", rc);
-
-        rc = MPI_Barrier(MPI_COMM_WORLD);
-        if (rc != MPI_SUCCESS)
-                rprintf(rank, -1, "prep MPI_Barrier failed: %d\n", rc);
-
-        start = last = time(0);
-
-        if (argc == 4) {
-                end = strtol(argv[3], NULL, 0);
-        } else {
-                begin = strtol(argv[3], NULL, 0);
-                end = strtol(argv[4], NULL, 0);
-        }
-        if (end > 0) {
-                count = end;
-                end = -1UL >> 1;
-        } else {
-                end = start - end;
-                count = -1UL >> 1;
-        }
-
-        if (strchr(argv[2], '%'))
-                fmt = argv[2];
-        else {
-                sprintf(format, "%s%%d", argv[2]);
-                fmt = format;
-        }
-        printf("starting at %s", ctime(&start));
-        for (i = 0; i < count && time(0) < end; i++, begin++) {
-                sprintf(filename, fmt, begin);
-                if (do_open) {
-                        int fd = open(filename, O_CREAT|O_RDWR, 0644);
-                        if (fd < 0) {
-                                printf("open(%s) error: %s\n", filename,
-                                       strerror(errno));
-                                rc = errno;
-                                break;
-                        }
-                        close(fd);
-                } else if (do_link) {
-                        rc = link(tgt, filename);
-                        if (rc) {
-                                printf("link(%s, %s) error: %s\n",
-                                       tgt, filename, strerror(errno));
-                                rc = errno;
-                                break;
-                        }
-                } else {
-                        rc = mknod(filename, S_IFREG| 0444, 0);
-                        if (rc) {
-                                printf("mknod(%s) error: %s\n",
-                                       filename, strerror(errno));
-                                rc = errno;
-                                break;
-                        }
-                }
-                if ((i % 10000) == 0) {
-                        printf(" - created %d (time %ld total %ld last %ld)\n",
-                               i, time(0), time(0) - start, time(0) - last);
-                        last = time(0);
-                }
-        }
-        printf("total: %d creates in %ld seconds: %f creates/second\n", i,
-               time(0) - start, ((float)i / (time(0) - start)));
-        start = time(0);
-        printf("finish at %s", ctime(&start));
-
-        return rc;
-}
diff --git a/lustre/tests/createtest.c b/lustre/tests/createtest.c
index 6f7ec0d..e320556 100644
--- a/lustre/tests/createtest.c
+++ b/lustre/tests/createtest.c
@@ -93,18 +93,27 @@ int main(int argc, char *argv[])
 					argv[0], name, st.st_mode, mode);
 				exit(12);
 			}
+			if (i == S_IFCHR || i == S_IFBLK) {
+				if (st.st_rdev != 0x1234) {
+					fprintf(stderr, "%s: ERROR rdev %s: "
+						"%llu != 0x1234",
+						argv[0], name,
+						(unsigned long long)st.st_rdev);
+					exit(13);
+				}
+			}
 			rc = unlink(name);
 			if (rc < 0) {
 				fprintf(stderr, "%s: ERROR unlink %s: %s",
 					argv[0], name, strerror(errno));
-				exit(13);
+				exit(14);
 			}
 			break;
 		default:
 			if (rc == 0) {
 				fprintf(stderr, "%s: ERROR: %s created\n",
 					argv[0], name);
-				exit(14);
+				exit(15);
 			}
 		}
 	}
diff --git a/lustre/tests/fchdir_test.c b/lustre/tests/fchdir_test.c
deleted file mode 100644
index b300396..0000000
--- a/lustre/tests/fchdir_test.c
+++ /dev/null
@@ -1,77 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-
-int main(int argc, char **argv)
-{
-        int fd;
-        int rc;
-
-        fd = open(".", O_RDONLY);
-        if (fd < 0) {
-                perror("opening '.' :");
-                exit(2);
-        }
-
-        rc = chdir("/mnt/lustre/subdir/subdir");
-        if (rc) { 
-                perror("cannot chdir subdir:");
-                exit(3);
-        }
-
-        rc = fchdir(fd);
-        if (rc) { 
-                perror("cannot fchdir back\n");
-                exit(4);
-        }
-
-        rc = close(fd);
-        if (rc) { 
-                perror("cannot close '.'\n");
-                exit(5);
-        }
-
-        return(0);
-}
diff --git a/lustre/tests/functions.sh b/lustre/tests/functions.sh
new file mode 100644
index 0000000..83f109d
--- /dev/null
+++ b/lustre/tests/functions.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Simple function used by run_*.sh scripts
+
+assert_env() {
+    local failed=""
+    for name in $@; do
+        if [ -z "${!name}" ]; then
+            echo "$0: $name must be set"
+            failed=1
+        fi
+    done
+    [ $failed ] && exit 1 || true
+}
+
+echoerr () { echo "$@" 1>&2 ; }
+
+signaled() {
+    echoerr "$(date +'%F %H:%M:%S'): client load was signaled to terminate"
+
+    local PGID=$(ps -eo "%c %p %r" | awk "/ $PPID / {print \$3}")
+    kill -TERM -$PGID
+    sleep 5
+    kill -KILL -$PGID
+}
+
+mpi_run () {
+    local mpirun="$MPIRUN $MPIRUN_OPTIONS"
+    local command="$mpirun $@"
+    local mpilog=$TMP/mpi.log
+    local rc
+
+    if [ "$MPI_USER" != root -a $mpirun ]; then
+        echo "+ chmod 0777 $MOUNT"
+        chmod 0777 $MOUNT
+        command="su $MPI_USER sh -c \"$command \""
+    fi
+
+    ls -ald $MOUNT
+    echo "+ $command"
+    eval $command 2>&1 > $mpilog || true
+
+    rc=${PIPESTATUS[0]}
+    if [ $rc -eq 0 ] && grep -q "p4_error: : [^0]" $mpilog ; then
+       rc=1
+    fi
+    cat $mpilog
+    return $rc
+}
+
diff --git a/lustre/tests/getdents.c b/lustre/tests/getdents.c
deleted file mode 100644
index 7237160..0000000
--- a/lustre/tests/getdents.c
+++ /dev/null
@@ -1,67 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <errno.h>
-
-int main(int argc, char **argv)
-{
-        DIR *dir;
-        struct dirent64 *entry;
-
-        if (argc < 2) {
-                fprintf(stderr, "Usage: %s dirname\n", argv[0]);
-                return 1;
-        }
-
-        dir = opendir(argv[1]);
-        if (!dir) {
-                int rc = errno;
-                perror("opendir");
-                return rc;
-        }
-
-        while ((entry = readdir64(dir))) {
-                puts(entry->d_name);
-        }
-        
-        closedir(dir);
-
-        return 0;
-}
-                
diff --git a/lustre/tests/insanity.sh b/lustre/tests/insanity.sh
index fbdfd1b..697b371 100755
--- a/lustre/tests/insanity.sh
+++ b/lustre/tests/insanity.sh
@@ -42,6 +42,7 @@ remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
 FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
 
 DIR=${DIR:-$MOUNT}
+TESTDIR=$DIR/d0.$(basename $0 .sh)
 
 #####
 # fail clients round robin
@@ -60,19 +61,6 @@ set_fail_client() {
     echo "fail $FAIL_CLIENT, next is $FAIL_NEXT"
 }
 
-shutdown_client() {
-    client=$1
-    if [ "$FAILURE_MODE" = HARD ]; then
-       $POWER_DOWN $client
-       while ping -w 3 -c 1 $client > /dev/null 2>&1; do 
-	   echo "waiting for node $client to fail"
-	   sleep 1
-       done  
-    elif [ "$FAILURE_MODE" = SOFT ]; then
-       zconf_umount $client $MOUNT -f
-    fi
-}
-
 fail_clients() {
     num=$1
 
@@ -124,29 +112,28 @@ client_touch() {
     file=$1
     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
 	if echo $DOWN_CLIENTS | grep -q $c; then continue; fi
-	$PDSH $c touch $MOUNT/${c}_$file || return 1
+	$PDSH $c touch $TESTDIR/${c}_$file || return 1
     done
 }
 
 client_rm() {
     file=$1
     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
-	$PDSH $c rm $MOUNT/${c}_$file
+	$PDSH $c rm $TESTDIR/${c}_$file
     done
 }
 
 client_mkdirs() {
     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
-	echo "$c mkdir $MOUNT/$c"
-	$PDSH $c "mkdir $MOUNT/$c"
-	$PDSH $c "ls -l $MOUNT/$c" 
+	echo "$c mkdir $TESTDIR/$c"
+	$PDSH $c "mkdir $TESTDIR/$c && ls -l $TESTDIR/$c"
     done
 }
 
 client_rmdirs() {
     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
-	echo "rmdir $MOUNT/$c"
-	$PDSH $LIVE_CLIENT "rmdir $MOUNT/$c"
+	echo "rmdir $TESTDIR/$c"
+	$PDSH $LIVE_CLIENT "rmdir $TESTDIR/$c"
     done
 }
 
@@ -157,6 +144,9 @@ clients_recover_osts() {
 
 check_and_setup_lustre
 
+rm -rf $TESTDIR
+mkdir -p $TESTDIR
+
 # 9 Different Failure Modes Combinations
 echo "Starting Test 17 at `date`"
 
@@ -416,8 +406,8 @@ test_7() {
     #Check FS
     echo "Test Lustre stability after CLIENTs failure"
     client_df
-    $PDSH $LIVE_CLIENT "ls -l $MOUNT"
-    $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
+    $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
+    $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
     
     #Sleep
     echo "Wait 1 minutes"
@@ -436,8 +426,8 @@ test_7() {
     #Check FS
     echo "Test Lustre stability after MDS failover"
     wait $DFPID || echo "df on down clients fails " || return 1
-    $PDSH $LIVE_CLIENT "ls -l $MOUNT"
-    $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
+    $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
+    $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
 
     #Reintegration
     echo "Reintegrating CLIENTs"
@@ -470,8 +460,8 @@ test_8() {
     #Check FS
     echo "Test Lustre stability after CLIENTs failure"
     client_df
-    $PDSH $LIVE_CLIENT "ls -l $MOUNT"
-    $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
+    $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
+    $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
 
     #Sleep
     echo "Wait 1 minutes"
@@ -495,8 +485,8 @@ test_8() {
     DFPID=$!
     sleep 5
     #non-failout hangs forever here
-    #$PDSH $LIVE_CLIENT "ls -l $MOUNT"
-    #$PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
+    #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
+    #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
     
     #Reintegration
     echo "Reintegrating CLIENTs/OST"
@@ -533,8 +523,8 @@ test_9() {
     #Check FS
     echo "Test Lustre stability after CLIENTs failure"
     client_df
-    $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 1
-    $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 2
+    $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
+    $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
 
     #Sleep
     echo "Wait 1 minutes"
@@ -542,7 +532,7 @@ test_9() {
 
     #Create files
     echo "Verify Lustre filesystem is up and running"
-    $PDSH $LIVE_CLIENT "grep -e $DIR /proc/mounts" || return 3
+    $PDSH $LIVE_CLIENT "grep -e $MOUNT /proc/mounts" || return 3
     $PDSH $LIVE_CLIENT df $MOUNT
     client_touch testfile || return 4
 
@@ -553,8 +543,8 @@ test_9() {
     #Check FS
     echo "Test Lustre stability after CLIENTs failure"
     client_df
-    $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 5
-    $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 6
+    $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
+    $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
 
     #Reintegration
     echo "Reintegrating  CLIENTs/CLIENTs"
diff --git a/lustre/tests/iopentest2.c b/lustre/tests/iopentest2.c
index d38d395..396bb3f 100644
--- a/lustre/tests/iopentest2.c
+++ b/lustre/tests/iopentest2.c
@@ -95,13 +95,12 @@ static char *get_iname(char *fname, const char *mtpt)
 
 int main(int argc, char *argv[])
 {
-        char *fname, *mtpt, *pname;
+        char *fname, *mtpt;
         char *fname_iname, *dir;
         char *dir_iname = NULL, *foo = NULL, *bar = NULL;
         int rc, fd, i, thread = 0;
         int pidlist[10];
 
-        pname = strdup(argv[0]);
         progname = basename(argv[0]);
 
         if (argc != 2) {
diff --git a/lustre/tests/it_test.c b/lustre/tests/it_test.c
index adaccde..a2997a7 100644
--- a/lustre/tests/it_test.c
+++ b/lustre/tests/it_test.c
@@ -84,11 +84,9 @@ static enum interval_iter cb(struct interval_node *n, void *args)
         static int count = 1;
 
         if (node->hit == 1) {
-                dprintf("NODE "__S" has ever been accessed\n",
-                        __F(&n->in_extent));
+                error("A duplicate node "__S" access found\n",
+                       __F(&n->in_extent));
                 return INTERVAL_ITER_CONT;
-                error("duplicate node accessing found\n");
-                return INTERVAL_ITER_STOP;
         }
         
         if (node->valid == 0) {
diff --git a/lustre/tests/large-scale.sh b/lustre/tests/large-scale.sh
new file mode 100644
index 0000000..d647684
--- /dev/null
+++ b/lustre/tests/large-scale.sh
@@ -0,0 +1,257 @@
+#!/bin/bash
+
+set -e
+
+# bug number:
+ALWAYS_EXCEPT="$LARGE_SCALE_EXCEPT"
+
+SAVE_PWD=$PWD
+PTLDEBUG=${PTLDEBUG:--1}
+LUSTRE=${LUSTRE:-`dirname $0`/..}
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
+. $LUSTRE/tests/test-framework.sh
+
+init_test_env $@
+
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+
+remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
+
+[ -n "$CLIENTS" ] || { skip "$0: Need two or more clients" && exit 0; }
+[ $CLIENTCOUNT -ge 2 ] || \
+    { skip "$0: Need two or more clients, have $CLIENTCOUNT" && exit 0; }
+
+#
+[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
+
+MOUNT_2=""
+build_test_filter
+
+check_and_setup_lustre
+rm -rf $DIR/[df][0-9]*
+
+[ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
+
+# VBR scale tests
+check_vbr () {
+    do_nodes $CLIENTS "$LCTL get_param mdc.*.connect_flags | grep version_recovery" 
+}
+
+check_vbr || \
+    { skip "$0: no version_recovery" && exit 0; }
+
+FAKE_NUM_MAX=${FAKE_NUM_MAX:-1000}
+[ "$SLOW" = "no" ] && FAKE_NUM_MAX=100
+
+delete_fake_exports () {
+    NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+
+    OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
+    NEW_AGE=0
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
+    sleep $((NEW_AGE + 3))
+    EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
+    [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
+
+    do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
+}
+
+test_1b() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    local FAKE_NUM
+    local NUM
+
+    for FAKE_NUM in 10 $FAKE_NUM_MAX; do
+        zconf_umount_clients $CLIENTS $DIR
+        zconf_mount $CLIENT1 $DIR
+
+        NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+
+        log "===== CREATE FAKE EXPORTS: $FAKE_NUM ( were $NUM )"
+        create_fake_exports mds $FAKE_NUM
+        NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+        [ $NUM -lt $FAKE_NUM ] && error "fake exports $NUM -ne $FAKE_NUM"
+        echo "===== STALE EXPORTS: FAKE_NUM=$FAKE_NUM NUM=$NUM"
+        local elapsed=$(do_and_time "zconf_mount_clients $CLIENTS $DIR")
+        echo "==== $TESTNAME ===== CONNECTION TIME $elapsed: FAKE_NUM=$FAKE_NUM CLIENTCOUNT=$CLIENTCOUNT"
+
+        # do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
+        delete_fake_exports
+    done
+
+    return 0
+}
+run_test 1b "VBR: connect $CLIENTCOUNT clients with delayed exports"
+
+# Sigh. One more function for mds failover
+# fail fn does not do df on all clients
+fail_mds () {
+    facet_failover mds
+    client_df
+}
+
+test_1c() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    zconf_mount_clients $CLIENTS $DIR
+
+    # sanity mds fail (to exclude the recults on fresh formatted fs)
+    facet_failover mds
+
+    local current_ts
+    local elapsed
+    local FAKE_NUM
+    local NUM
+
+    for FAKE_NUM in 10 $FAKE_NUM_MAX; do
+
+        NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+
+        log "===== CREATE FAKE EXPORTS: $FAKE_NUM ( were $NUM )"
+        create_fake_exports mds $FAKE_NUM
+        NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+        [ $NUM -lt $FAKE_NUM ] && error "fake exports $NUM -ne $FAKE_NUM"
+        echo "===== STALE EXPORTS: FAKE_NUM=$FAKE_NUM NUM=$NUM"
+
+        replay_barrier mds
+        do_nodes $CLIENTS "createmany -o $DIR/$tfile-\\\$(hostname)" 25
+        # XXX For FAILURE_MODE=HARD it is better to exclude
+        # shutdown_facet and reboot_facet time 
+        fail_mds
+
+        local current_ts=`date +%s`
+        local elapsed=`expr $current_ts - $RECOVERY_START_TIME`
+
+        do_nodes $CLIENTS "unlinkmany $DIR/$tfile-\\\$(hostname) 25"
+        echo "==== $TESTNAME ===== RECOVERY TIME $elapsed: FAKE_NUM=$FAKE_NUM CLIENTCOUNT=$CLIENTCOUNT"
+
+        # do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
+        delete_fake_exports
+    done
+
+    return 0
+}
+run_test 1c "VBR: recovery $CLIENTCOUNT clients with delayed exports"
+
+test_1d() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    local FAKE_NUM
+    local NUM
+
+    for FAKE_NUM in 10 $FAKE_NUM_MAX; do
+        zconf_umount_clients $CLIENTS $DIR
+        zconf_mount $CLIENT1 $DIR
+
+        NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+
+        log "===== CREATE FAKE EXPORTS: $FAKE_NUM ( were $NUM )"
+        create_fake_exports mds $FAKE_NUM
+        NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+        [ $NUM -lt $FAKE_NUM ] && error "fake exports $NUM -lt $FAKE_NUM"
+        echo "===== STALE EXPORTS: FAKE_NUM=$FAKE_NUM NUM=$NUM"
+
+        OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
+        echo OLD_AGE=$OLD_AGE
+        NEW_AGE=10
+        do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
+        sleep $((NEW_AGE + 3))
+        EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
+        [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
+
+        local elapsed=$(do_and_time "zconf_mount_clients $CLIENTS $DIR")
+        echo "==== $TESTNAME===== CONNECTION TIME $elapsed: expired FAKE_NUM=$FAKE_NUM CLIENTCOUNT=$CLIENTCOUNT"
+
+        do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
+    done
+
+    return 0
+}
+run_test 1d "VBR: expire exports, connect $CLIENTCOUNT clients"
+# VBR scale tests end
+
+test_3a() {
+    assert_env CLIENTS MDSRATE MPIRUN
+
+    local -a nodes=(${CLIENTS//,/ })
+
+    # INCREMENT is a number of clients 
+    # a half of clients by default
+    increment=${INCREMENT:-$(( CLIENTCOUNT / 2 ))}
+
+    machinefile=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
+    local LOG=$TMP/${TESTSUITE}_$tfile
+
+    local var=mds_svc
+    local procfile="*.${!var}.recovery_status"
+    local iters=${ITERS:-3}
+    local nfiles=${NFILES:-50000}
+    local nthreads=${THREADS_PER_CLIENT:-3}
+
+    local IFree=$(inodes_available)
+    [ $IFree -gt $nfiles ] || nfiles=$IFree
+
+    local dir=$DIR/$tdir
+    mkdir -p $dir
+    chmod 0777 $dir
+
+    local pid
+    local list
+    local -a res
+
+    local num=$increment
+
+    while [ $num -le $CLIENTCOUNT ]; do
+        list=$(comma_list ${nodes[@]:0:$num}) 
+
+        generate_machine_file $list $machinefile ||
+            { error "can not generate machinefile"; exit 1; }
+
+        for i in $(seq $iters); do
+            mdsrate_cleanup $num $machinefile $nfiles $dir 'f%%d' --ignore
+
+            COMMAND="${MDSRATE} --create --nfiles $nfiles --dir $dir --filefmt 'f%%d'"
+            mpi_run -np $((num * nthreads)) -machinefile $machinefile ${COMMAND} | tee ${LOG} &
+
+            pid=$!
+            echo "pid=$pid"
+
+            # 2 threads 100000 creates 117 secs
+            sleep 20
+
+            log "$i : Starting failover on mds"
+            facet_failover mds
+            if ! wait_recovery_complete mds $((TIMEOUT * 10)); then
+                echo "mds recovery is not completed!"
+                kill -9 $pid
+                exit 7
+            fi
+
+            duration=$(do_facet mds lctl get_param -n $procfile | grep recovery_duration)
+            
+            res=( "${res[@]}" "$num" )
+            res=( "${res[@]}" "$duration" )
+            echo "RECOVERY TIME: NFILES=$nfiles number of clients: $num  $duration"
+            wait $pid
+
+        done
+        num=$((num + increment))
+    done
+
+    mdsrate_cleanup $num $machinefile $nfiles $dir 'f%%d' --ignore
+
+    i=0
+    while [ $i -lt ${#res[@]} ]; do
+        echo "RECOVERY TIME: NFILES=$nfiles number of clients: ${res[i]}  ${res[i+1]}"
+        i=$((i+2))
+    done
+}
+
+run_test 3a "recovery time, $CLIENTCOUNT clients"
+
+equals_msg `basename $0`: test complete, cleaning up
+check_and_cleanup_lustre
+[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true
diff --git a/lustre/tests/lfscktest.sh b/lustre/tests/lfscktest.sh
index 67fbd7e..3b7c661 100755
--- a/lustre/tests/lfscktest.sh
+++ b/lustre/tests/lfscktest.sh
@@ -132,7 +132,7 @@ if [ "$LFSCK_SETUP" != "no" ]; then
 	for i in $OST_REMOVE; do
 		echo "rm O/0/d$((i % 32))/$i" >> $DEBUGTMP
 	done
-	debugfs -w -f $DEBUGTMP `echo $OSTDEVS | cut -d' ' -f 1`
+	$DEBUGFS -w -f $DEBUGTMP `echo $OSTDEVS | cut -d' ' -f 1`
 	RET=$?
 	rm $DEBUGTMP
 	[ $RET -ne 0 ] && exit 50
@@ -174,19 +174,19 @@ fi # LFSCK_SETUP
 # a return status of 1 indicates e2fsck successfuly fixed problems found
 set +e
 
-echo "e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV"
+echo "$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV"
 df > /dev/null	# update statfs data on disk
-e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV
+$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV
 RET=$?
-[ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 90 || true
+[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 90 || true
 
 export OSTDB_LIST=""
 i=0
 for OSTDEV in $OSTDEVS; do
 	df > /dev/null	# update statfs data on disk
-	e2fsck -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV
+	$E2FSCK -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV
 	RET=$?
-	[ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 100
+	[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 100
 	OSTDB_LIST="$OSTDB_LIST $OSTDB-$i"
 	i=$((i + 1))
 done
@@ -208,19 +208,19 @@ echo "LFSCK TEST 1 - finished with rc=$RET"
 sync; sleep 2; sync
 
 echo "LFSCK TEST 2"
-echo "e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV"
+echo "$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV"
 df > /dev/null	# update statfs data on disk
-e2fsck -d -v -fn --mdsdb $MDSDB $MDSDEV
+$E2FSCK -d -v -fn --mdsdb $MDSDB $MDSDEV
 RET=$?
-[ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 123 || true
+[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 123 || true
 
 i=0
 export OSTDB_LIST=""
 for OSTDEV in $OSTDEVS; do
 	df > /dev/null	# update statfs data on disk
-	e2fsck -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV
+	$E2FSCK -d -v -fn --mdsdb $MDSDB --ostdb $OSTDB-$i $OSTDEV
 	RET=$?
-	[ $RET -gt $MAX_ERR ] && echo "e2fsck returned $RET" && exit 124
+	[ $RET -gt $MAX_ERR ] && echo "$E2FSCK returned $RET" && exit 124
 	OSTDB_LIST="$OSTDB_LIST $OSTDB-$i"
 	i=$((i + 1))
 done
diff --git a/lustre/tests/ll_dirstripe_verify.c b/lustre/tests/ll_dirstripe_verify.c
index b65c387..77c5512 100644
--- a/lustre/tests/ll_dirstripe_verify.c
+++ b/lustre/tests/ll_dirstripe_verify.c
@@ -238,7 +238,7 @@ int main(int argc, char **argv)
                 return rc;
         }
 
-        lum_size = lov_mds_md_size(MAX_LOV_UUID_COUNT);
+        lum_size = lov_mds_md_size(MAX_LOV_UUID_COUNT, LOV_MAGIC);
         if ((lum_dir = (struct lov_user_md *)malloc(lum_size)) == NULL) {
                 rc = ENOMEM;
                 llapi_err(LLAPI_MSG_ERROR, "error: can't allocate %d bytes "
diff --git a/lustre/tests/ll_getstripe_info.c b/lustre/tests/ll_getstripe_info.c
index 4b61102..ca5093c 100644
--- a/lustre/tests/ll_getstripe_info.c
+++ b/lustre/tests/ll_getstripe_info.c
@@ -64,7 +64,7 @@ int main(int argc, char** argv)
                 return 1;
         }
 
-        lum_size = lov_mds_md_size(MAX_LOV_UUID_COUNT);
+        lum_size = lov_mds_md_size(MAX_LOV_UUID_COUNT, LOV_MAGIC);
 
         if ((lum_file = (struct lov_user_md *)malloc(lum_size)) == NULL) {
                 fprintf(stderr, "unable to allocate memory for ioctl's");
diff --git a/lustre/tests/llecho.sh b/lustre/tests/llecho.sh
deleted file mode 100644
index a345f4f..0000000
--- a/lustre/tests/llecho.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-PATH=`dirname $0`/../utils:$PATH
-
-LCONF=${LCONF:-lconf}
-NAME=${NAME:-echo}
-
-config=$NAME.xml
-mkconfig=$NAME.sh
-
-if [ "$LUSTRE" ]; then
-  lustre_opt="--lustre=$LUSTRE"
-fi
-
-[ -f $config ] || sh -x $mkconfig $config || exit 1
-
-$LCONF $lustre_opt --reformat $@ $OPTS $config || exit 4
-
-cat <<EOF
-
-run getattr tests as:
-`dirname $0`../utils/lctl --device '\$ECHO_$SERVER' test_getattr 1000000
-EOF
diff --git a/lustre/tests/llmount.sh b/lustre/tests/llmount.sh
index b3024aa..82217bc 100755
--- a/lustre/tests/llmount.sh
+++ b/lustre/tests/llmount.sh
@@ -7,5 +7,6 @@ LUSTRE=${LUSTRE:-`dirname $0`/..}
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 
+[ -n "$LOAD" ] && load_modules && exit 0
 [ -z "$NOFORMAT" ] && formatall
 [ -z "$NOSETUP" ] && setupall
diff --git a/lustre/tests/lockorder.sh b/lustre/tests/lockorder.sh
index 4f1ca4b..d4656d3 100644
--- a/lustre/tests/lockorder.sh
+++ b/lustre/tests/lockorder.sh
@@ -7,9 +7,9 @@ STATMANY=${STATMANY:-statmany}
 UNLINKMANY=${UNLINKMANY:-unlinkmany}
 LCTL=${LCTL:-lctl}
 
-MOUNT1=${MOUNT1:-/mnt/lustre1}
+MOUNT=${MOUNT:-/mnt/lustre}
 MOUNT2=${MOUNT2:-/mnt/lustre2}
-DIR=${DIR:-$MOUNT1}
+DIR=${DIR:-$MOUNT}
 DIR2=${DIR2:-$MOUNT2}
 COUNT=${COUNT:-100}
 
diff --git a/lustre/tests/lp_utils.c b/lustre/tests/lp_utils.c
deleted file mode 100644
index 91ae0b0..0000000
--- a/lustre/tests/lp_utils.c
+++ /dev/null
@@ -1,283 +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  2008 Sun Microsystems, Inc. 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.
- *
- * lustre/tests/lp_utils.c
- *
- * Author: You Feng <youfeng at clusterfs.com>
- */
-
-#include <mpi.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "lustre/lustre_user.h"
-#include "lustre/tests/lp_utils.h"
-
-#define MAX_PROCESSES 8
-
-int verbose = 0;
-int debug = 0;
-
-char hostname[1024];
-
-struct timeval t1, t2;
-
-char *timestamp() {
-        static char datestring[80];
-        time_t timestamp;
-
-        fflush(stdout);
-        timestamp = time(NULL);
-        strftime(datestring, 80, "%T", localtime(&timestamp));
-
-        return datestring;
-}
-
-inline void begin(char *str) {
-        if (verbose > 0 && rank == 0) {
-                gettimeofday(&t1, NULL);
-                printf("%s:\tBeginning %s\n", timestamp(), str);
-                fflush(stdout);
-        }
-}
-
-inline void end(char *str) {
-        float elapsed;
-
-        MPI_Barrier(MPI_COMM_WORLD);
-        if (verbose > 0 && rank == 0) {
-                gettimeofday(&t2, NULL);
-                elapsed = (t2.tv_sec + ((float)t2.tv_usec/1000000))
-                          - (t1.tv_sec + ((float)t1.tv_usec/1000000));
-                if (elapsed >= 60) {
-                        printf("%s:\tFinished %-15s(%.2f min)\n",
-                               timestamp(), str, elapsed / 60);
-                } else {
-                        printf("%s:\tFinished %-15s(%.3f sec)\n",
-		               timestamp(), str, elapsed);
-
-                }
-                fflush(stdout);
-        }
-}
-
-void dump_diff(char *orig_buf, char *buf, int size, long _off)
-{
-        int i, diff, off;
-        char *p, *end;
-
-        printf("commpared buf size %d, at offset %lu\n\n", size, _off);
-
-        if (orig_buf) {
-                printf("original buf:\n");
-                p = orig_buf;
-                end = orig_buf + size;
-                i = 1;
-                while (p < end) {
-                        printf(" %8lx", *(long *)p);
-                        p += sizeof(long);
-                        if (i++%8 == 0)
-                                printf("\n");
-                }
-                if (i%8) printf("\n\n");
-                else printf("\n");
-        }
-
-        if (buf) {
-                printf("different data: diff_data(orig_data)\n");
-                diff = 0;
-                off = 0;
-                i = 1;
-                p = buf;
-                end = buf + size;
-                while (p < end) {
-                        if (memcmp(p, orig_buf + off, sizeof(long)) != 0) {
-                                printf("\toff: %5d,\tdata: %8lx (%8lx)\n", off,
-                                       *(unsigned long *)p,
-                                       *(unsigned long *)(orig_buf + off));
-                                diff++;
-                        }
-                        off += sizeof(long);
-                        p += sizeof(long);
-                }
-                printf("\n %d total differents found\n\n", diff);
-        }
-}
-
-void lp_gethostname(void)
-{
-        if (gethostname(hostname, 1024) == -1) {
-                fprintf(stderr, "gethostname: (%d)%s", errno, strerror(errno));
-                MPI_Abort(MPI_COMM_WORLD, 2);
-        }
-}
-
-/* This function does not FAIL if the requested "name" does not exit.
- * This is just to clean up any files or directories left over from
- * previous runs
- */
-void remove_file_or_dir(char *name)
-{
-        struct stat statbuf;
-        char errmsg[MAX_FILENAME_LEN + 20];
-
-        if (stat(name, &statbuf) != -1) {
-                if (S_ISREG(statbuf.st_mode)) {
-                        printf("stale file found\n");
-                        if (unlink(name) == -1) {
-                                sprintf(errmsg, "unlink of %s", name);
-                                FAIL(errmsg);
-                        }
-                }
-                if (S_ISDIR(statbuf.st_mode)) {
-                        printf("stale directory found\n");
-                        if (rmdir(name) == -1) {
-                                sprintf(errmsg, "rmdir of %s", name);
-                                FAIL(errmsg);
-                        }
-                }
-        }
-}
-
-void create_file(char *name, long filesize, int fill)
-{
-        static char filename[MAX_FILENAME_LEN];
-        char errmsg[MAX_FILENAME_LEN + 20];
-        char buf[1024 * 8];
-        char c = 'A' + size;
-        int fd, rc;
-        short zero = 0;
-        long left = filesize;
-
-        /* Process 0 creates the test file(s) */
-        if (rank == 0) {
-                sprintf(filename, "%s/%s", testdir, name);
-                remove_file_or_dir(filename);
-                if ((fd = creat(filename, FILEMODE)) == -1) {
-                        sprintf(errmsg, "create of file %s", filename);
-                        FAIL(errmsg);
-                }
-                if (filesize > 0) {
-                        if (lseek(fd, filesize - 1, SEEK_SET) == -1) {
-                                close(fd);
-                                sprintf(errmsg, "lseek of file %s", filename);
-                                FAIL(errmsg);
-                        }
-                        if (write(fd, &zero, 1) == -1) {
-                                close(fd);
-                                sprintf(errmsg, "write of file %s", filename);
-                                FAIL(errmsg);
-                        }
-                }
-                if (filesize > 0 && fill) {
-                        if (lseek(fd, 0, SEEK_SET) == -1) {
-                                close(fd);
-                                sprintf(errmsg, "lseek of file %s", filename);
-                                FAIL(errmsg);
-                        }
-                        memset(buf, c, 1024);
-                        while (left > 0) {
-                                if ((rc = write(fd, buf,
-                                                left > (1024 * 8) ? (1024 * 8) : left))
-                                    == -1) {
-                                        close(fd);
-                                        sprintf(errmsg, "write of file %s", filename);
-                                        FAIL(errmsg);
-                                }
-                                left -= rc;
-                        }
-                }
-                if (close(fd) == -1) {
-                        sprintf(errmsg, "close of file %s", filename);
-                        FAIL(errmsg);
-                }
-        }
-}
-
-void check_stat(char *filename, struct stat *state, struct stat *old_state)
-{
-        char errmsg[MAX_FILENAME_LEN+20];
-
-        if (stat(filename, state) == -1) {
-                sprintf(errmsg, "stat of file %s", filename);
-                FAIL(errmsg);
-        }
-
-        if (memcmp(state, old_state, sizeof(struct stat)) != 0) {
-                errno = 0;
-                sprintf(errmsg, LP_STAT_FMT, LP_STAT_ARGS);
-                FAIL(errmsg);
-        }
-}
-
-void remove_file(char *name)
-{
-        char filename[MAX_FILENAME_LEN];
-        char errmsg[MAX_FILENAME_LEN + 20];
-
-        /* Process 0 remove the file(s) */
-        if (rank == 0) {
-                sprintf(filename, "%s/%s", testdir, name);
-                if (unlink(filename) == -1) {
-                        sprintf(errmsg, "unlink of file %s", filename);
-                        FAIL(errmsg);
-                }
-        }
-}
-
-void fill_stride(char *buf, int buf_size, long long rank, long long _off)
-{
-        char *p = buf;
-        long long off, data[2];
-        int cp, left = buf_size;
-
-        data[0] = rank;
-        off = _off;
-        while (left > 0) {
-                data[1] = off;
-                cp = left > sizeof(data) ? sizeof(data) : left;
-                memcpy(p, data, cp);
-                off += cp;
-                p += cp;
-                left -= cp;
-        }
-}
diff --git a/lustre/tests/mdsrate-create-large.sh b/lustre/tests/mdsrate-create-large.sh
index 94bb805..c78ce9a 100644
--- a/lustre/tests/mdsrate-create-large.sh
+++ b/lustre/tests/mdsrate-create-large.sh
@@ -52,7 +52,6 @@ else
     mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_SINGLE 'f%%d' --ignore
 
     log "===== $0 ### 1 NODE CREATE ###"
-    echo "Running creates on 1 node(s)."
 
     COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --create --time ${TIME_PERIOD}
                 --nfiles ${NUM_FILES} --dir ${TESTDIR_SINGLE} --filefmt 'f%%d'"
@@ -60,21 +59,25 @@ else
     mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-	[ -f $LOG ] && cat $LOG
-	error "mpirun ... mdsrate ... failed, aborting"
+	[ -f $LOG ] && sed -e "s/^/log: /" $LOG
+	error "mdsrate creates for a single client failed, aborting"
     fi
     
     log "===== $0 ### 1 NODE UNLINK ###"
-    echo "Running unlinks on 1 node(s)."
 
-    COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink --time ${TIME_PERIOD}
+    if [ -f "$LOG" ]; then
+        CREATED=$(awk '/total:/ { print $7 }' $LOG)
+        [ $CREATED -gt 0 ] && NUM_FILES=$CREATED
+    fi
+
+    COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink
                 --nfiles ${NUM_FILES} --dir ${TESTDIR_SINGLE} --filefmt 'f%%d'"
     echo "+ ${COMMAND}"
     mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
  
     if [ ${PIPESTATUS[0]} != 0 ]; then
-	[ -f $LOG ] && cat $LOG
-	error "mpirun ... mdsrate ... failed, aborting"
+	[ -f $LOG ] && sed -e "s/^/log: /" $LOG
+	error "mdsrate unlink on a single client failed, aborting"
     fi
 fi
 
@@ -83,13 +86,13 @@ if [ $IFree -lt $NUM_FILES ]; then
     NUM_FILES=$IFree
 fi
 
+[ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
 if [ -n "$NOMULTI" ]; then
     echo "NO test for create on multiple nodes."
 else
     mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_MULTI 'f%%d' --ignore
 
     log "===== $0 ### $NUM_CLIENTS NODES CREATE ###"
-    echo "Running creates on ${NUM_CLIENTS} node(s)."
 
     COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --create --time ${TIME_PERIOD}
                 --nfiles $NUM_FILES --dir ${TESTDIR_MULTI} --filefmt 'f%%d'"
@@ -97,27 +100,28 @@ else
     mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-	[ -f $LOG ] && cat $LOG
-	error "mpirun ... mdsrate ... failed, aborting"
+	[ -f $LOG ] && sed -e "s/^/log: /" $LOG
+	error "mdsrate create on multiple nodes failed, aborting"
     fi
 
-    echo "Running unlinks on ${NUM_CLIENTS} node(s)."
+    log "===== $0 ### $NUM_CLIENTS NODES UNLINK ###"
 
-    COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink --time ${TIME_PERIOD}
+    if [ -f "$LOG" ]; then
+        CREATED=$(awk '/total:/ { print $7 }' $LOG)
+        [ $CREATED -gt 0 ] && NUM_FILES=$CREATED
+    fi
+
+    COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink
                 --nfiles ${NUM_FILES} --dir ${TESTDIR_MULTI} --filefmt 'f%%d'"
     echo "+ ${COMMAND}"
     mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-	[ -f $LOG ] && cat $LOG
-	error "mpirun ... mdsrate ... failed, aborting"
+	[ -f $LOG ] && sed -e "s/^/log: /" $LOG
+	error "mdsrate unlink on multiple nodes failed, aborting"
     fi
-
 fi
 
-equals_msg `basename $0`: test complete, cleaning up
-mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_SINGLE 'f%%d' --ignore
-mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_MULTI 'f%%d' --ignore
 rm -f $MACHINEFILE
 check_and_cleanup_lustre
 #rm -f $LOG
diff --git a/lustre/tests/mdsrate-create-small.sh b/lustre/tests/mdsrate-create-small.sh
index cb4a1c0..4babb26 100644
--- a/lustre/tests/mdsrate-create-small.sh
+++ b/lustre/tests/mdsrate-create-small.sh
@@ -60,7 +60,6 @@ else
         mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_SINGLE 'f%%d' --ignore
 
         log "===== $0 ### 1 NODE CREATE ###"
-        echo "Running creates on 1 node(s)."
 
         COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --create --time ${TIME_PERIOD}
                     --nfiles $NUM_FILES --dir ${TESTDIR_SINGLE} --filefmt 'f%%d'"
@@ -68,8 +67,8 @@ else
         mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
         if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-            error "mpirun ... mdsrate ... failed, aborting"
+            [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+            error "mdsrate create for a single client failed, aborting"
         fi
     fi
 
@@ -77,16 +76,20 @@ else
         echo "NO Test for unlinks for a single client."
     else
         log "===== $0 ### 1 NODE UNLINK ###"
-        echo "Running unlinks on 1 node(s)."
 
-        COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink --time ${TIME_PERIOD}
+        if [ -f "$LOG" ]; then
+            CREATED=$(awk '/total:/ { print $7 }' $LOG)
+           [ $CREATED -gt 0 ] && NUM_FILES=$CREATED
+        fi
+
+        COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink
                      --nfiles ${NUM_FILES} --dir ${TESTDIR_SINGLE} --filefmt 'f%%d'"
         echo "+ ${COMMAND}"
         mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
         if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-            error "mpirun ... mdsrate ... failed, aborting"
+            [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+            error "mdsrate unlinks for a single client failed, aborting"
         fi
     fi
 fi
@@ -104,8 +107,7 @@ else
     else
         mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_MULTI 'f%%d' --ignore
 
-        log "===== $0 ### $NUM_CLIENTS NODES CREATE ###"
-        echo "Running creates on ${NUM_CLIENTS} node(s) with $THREADS_PER_CLIENT threads per client."
+        log "===== $0 ### $NUM_CLIENTS NODES CREATE with $THREADS_PER_CLIENT threads per client ###"
 
         COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --create --time ${TIME_PERIOD}
                     --nfiles $NUM_FILES --dir ${TESTDIR_MULTI} --filefmt 'f%%d'"
@@ -113,32 +115,34 @@ else
         mpi_run -np $((NUM_CLIENTS * THREADS_PER_CLIENT)) -machinefile ${MACHINEFILE} \
             ${COMMAND} | tee ${LOG}
         if [ ${PIPESTATUS[0]} != 0 ]; then
-            [ -f $LOG ] && cat $LOG
-            error "mpirun ... mdsrate ... failed, aborting"
+            [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+            error "mdsrate create on multiple nodes failed, aborting"
         fi
     fi
 
     if [ -n "$NOUNLINK" ]; then
         echo "NO Test for unlinks multiple nodes."
     else
-        log "===== $0 ### $NUM_CLIENTS NODES UNLINK ###"
-        echo "Running unlinks on ${NUM_CLIENTS} node(s) with $THREADS_PER_CLIENT threads per client."
+        log "===== $0 ### $NUM_CLIENTS NODES UNLINK with $THREADS_PER_CLIENT threads per client ###"
+
+        if [ -f "$LOG" ]; then
+            CREATED=$(awk '/total:/ { print $7 }' $LOG)
+            [ $CREATED -gt 0 ] && NUM_FILES=$CREATED
+        fi
 
-        COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink --time ${TIME_PERIOD}
+        COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --unlink
                       --nfiles ${NUM_FILES} --dir ${TESTDIR_MULTI} --filefmt 'f%%d'"
         echo "+ ${COMMAND}"
         mpi_run -np $((NUM_CLIENTS * THREADS_PER_CLIENT)) -machinefile ${MACHINEFILE} \
             ${COMMAND} | tee ${LOG}
         if [ ${PIPESTATUS[0]} != 0 ]; then
-            [ -f $LOG ] && cat $LOG
-            error "mpirun ... mdsrate ... failed, aborting"
+            [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+            error "mdsrate unlinks multiple nodes failed, aborting"
         fi
     fi
 fi
 
 equals_msg `basename $0`: test complete, cleaning up
-mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_SINGLE 'f%%d' --ignore
-mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR_MULTI 'f%%d' --ignore
 rm -f $MACHINEFILE 
 check_and_cleanup_lustre
 #rm -f $LOG
diff --git a/lustre/tests/mdsrate-lookup-10dirs.sh b/lustre/tests/mdsrate-lookup-10dirs.sh
new file mode 100644
index 0000000..f132055
--- /dev/null
+++ b/lustre/tests/mdsrate-lookup-10dirs.sh
@@ -0,0 +1,124 @@
+#!/bin/bash
+#
+# This test was used in a set of CMD3 tests (cmd3-5 test).
+
+# Directory lookup retrieval rate 10 directories 1 million files each
+# 6000 random lookups/sec per client node 62,000 random lookups/sec aggregate
+# 
+# In 10 dirs containing 1 million files each the mdsrate Test Program will
+# perform lookups for 10 minutes. This test is run from a single node for
+# #1 and from all nodes for #2 aggregate test to measure lookup performance.
+# TEst performs lookups across all 10 directories.
+
+LUSTRE=${LUSTRE:-`dirname $0`/..}
+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+assert_env CLIENTS MDSRATE SINGLECLIENT MPIRUN
+
+MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
+# Do not use name [df][0-9]* to avoid cleanup by rm, bug 18045
+TESTDIR=$MOUNT/mdsrate
+
+# Requirements
+NUM_DIRS=${NIM_DIRS:-10}
+NUM_FILES=${NUM_FILES:-1000000}
+TIME_PERIOD=${TIME_PERIOD:-600}                        # seconds
+
+LOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
+CLIENT=$SINGLECLIENT
+NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
+NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
+
+rm -f $LOG
+
+[ ! -x ${MDSRATE} ] && error "${MDSRATE} not built."
+
+log "===== $0 ====== " 
+
+check_and_setup_lustre
+mkdir -p $TESTDIR
+chmod 0777 $TESTDIR
+
+IFree=$(inodes_available)
+if [ $IFree -lt $((NUM_FILES * NUM_DIRS)) ]; then
+    NUM_FILES=$((IFree / NUM_DIRS))
+fi
+
+generate_machine_file $NODES_TO_USE $MACHINEFILE || error "can not generate machinefile"
+
+$LFS setstripe $TESTDIR -c 1
+get_stripe $TESTDIR
+
+DIRfmt="${TESTDIR}/t6-%d"
+
+if [ -n "$NOCREATE" ]; then
+    echo "NOCREATE=$NOCREATE  => no file creation."
+else
+    # FIXME: does it make sense to add the possibility to unlink dirfmt to mdsrate?
+    for i in $(seq 0 $NUM_DIRS); do
+        mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR/t6-$i 'f%%d' --ignore
+    done
+
+    log "===== $0 Test preparation: creating ${NUM_DIRS} dirs with ${NUM_FILES} files."
+
+    COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --mknod
+                        --ndirs ${NUM_DIRS} --dirfmt '${DIRfmt}'
+                        --nfiles ${NUM_FILES} --filefmt 'f%%d'"
+
+    echo "+" ${COMMAND}
+    # For files creation we can use -np equal to NUM_DIRS 
+    # This is just a test preparation, does not matter how many threads we use for files creation;
+    # we just should be aware that NUM_DIRS is less than or equal to the number of threads np
+    mpi_run -np ${NUM_DIRS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1 
+
+    # No lookup if error occurs on file creation, abort.
+    [ ${PIPESTATUS[0]} != 0 ] && error "mdsrate file creation failed, aborting"
+fi
+
+COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --lookup --time ${TIME_PERIOD} ${SEED_OPTION}
+        --ndirs ${NUM_DIRS} --dirfmt '${DIRfmt}'
+        --nfiles ${NUM_FILES} --filefmt 'f%%d'"
+
+# 1
+if [ -n "$NOSINGLE" ]; then
+    echo "NO Test for lookups on a single client."
+else
+    log "===== $0 ### 1 NODE LOOKUPS ###"
+    echo "+" ${COMMAND}
+    mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
+
+    if [ ${PIPESTATUS[0]} != 0 ]; then
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate lookups on a single client failed, aborting"
+    fi
+fi
+
+# 2
+[ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
+if [ -n "$NOMULTI" ]; then
+    echo "NO test for lookups on multiple nodes."
+else
+    log "===== $0 ### ${NUM_CLIENTS} NODES LOOKUPS ###"
+    echo "+" ${COMMAND}
+    mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
+
+    if [ ${PIPESTATUS[0]} != 0 ]; then
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate lookups on multiple nodes failed, aborting"
+    fi
+fi
+
+equals_msg `basename $0`: test complete, cleaning up
+# FIXME: does it make sense to add the possibility to unlink dirfmt to mdsrate?
+for i in $(seq 0 $NUM_DIRS); do
+    mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR/t6-$i 'f%%d' --ignore
+    rmdir $TESTDIR/t6-$i
+done
+
+rmdir $TESTDIR || true
+rm -f $MACHINEFILE
+check_and_cleanup_lustre
+#rm -f $LOG
+
+exit 0
diff --git a/lustre/tests/mdsrate-lookup-1dir.sh b/lustre/tests/mdsrate-lookup-1dir.sh
index 6276fc4..752deb7 100644
--- a/lustre/tests/mdsrate-lookup-1dir.sh
+++ b/lustre/tests/mdsrate-lookup-1dir.sh
@@ -54,21 +54,14 @@ else
     mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR 'f%%d' --ignore
 
     log "===== $0 Test preparation: creating ${NUM_FILES} files."
-    echo "Test preparation: creating ${NUM_FILES} files."
 
-    MDSCOUNT=1
-    NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
-    NUM_THREADS=$((NUM_CLIENTS * MDSCOUNT))
-    if [ $NUM_CLIENTS -gt 50 ]; then
-        NUM_THREADS=$NUM_CLIENTS
-    fi
     COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --mknod --dir ${TESTDIR}
                         --nfiles ${NUM_FILES} --filefmt 'f%%d'"
     echo "+" ${COMMAND}
-    mpi_run -np ${NUM_THREADS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1 
+    mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1 
 
     # No lockup if error occurs on file creation, abort.
-    [ ${PIPESTATUS[0]} != 0 ] && error "mpirun ... mdsrate ... file creation failed, aborting"
+    [ ${PIPESTATUS[0]} != 0 ] && error "mdsrate file creation failed, aborting"
 fi
 
 COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --lookup --time ${TIME_PERIOD} ${SEED_OPTION}
@@ -79,28 +72,27 @@ if [ -n "$NOSINGLE" ]; then
     echo "NO Test for lookups on a single client."
 else
     log "===== $0 ### 1 NODE LOOKUPS ###"
-    echo "Running lookups on 1 node(s)."
     echo "+" ${COMMAND}
     mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-        error "mpirun ... mdsrate ... failed, aborting"
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate lookups on a single client failed, aborting"
     fi
 fi
 
 # 2
+[ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
 if [ -n "$NOMULTI" ]; then
     echo "NO test for lookups on multiple nodes."
 else
     log "===== $0 ### ${NUM_CLIENTS} NODES LOOKUPS ###"
-    echo "Running lookups on ${NUM_CLIENTS} node(s)."
     echo "+" ${COMMAND}
     mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-        error "mpirun ... mdsrate ... failed, aborting"
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate lookups on multiple nodes failed, aborting"
     fi
 fi
 
diff --git a/lustre/tests/mdsrate-stat-large.sh b/lustre/tests/mdsrate-stat-large.sh
index 5299fc5..730eb01 100644
--- a/lustre/tests/mdsrate-stat-large.sh
+++ b/lustre/tests/mdsrate-stat-large.sh
@@ -59,21 +59,13 @@ else
     mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR 'f%%d' --ignore
 
     log "===== $0 Test preparation: creating ${NUM_FILES} files."
-    echo "Test preparation: creating ${NUM_FILES} files."
 
     COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --create --dir ${TESTDIR}
                         --nfiles ${NUM_FILES} --filefmt 'f%%d'"
     echo "+" ${COMMAND}
 
-    MDSCOUNT=1
-    NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
-    NUM_THREADS=$((NUM_CLIENTS * MDSCOUNT))
-    if [ $NUM_CLIENTS -gt 50 ]; then
-        NUM_THREADS=$NUM_CLIENTS
-    fi
-
-    mpi_run -np ${NUM_THREADS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1
-    [ ${PIPESTATUS[0]} != 0 ] && error "mpirun ... mdsrate ... file creation failed, aborting"
+    mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1
+    [ ${PIPESTATUS[0]} != 0 ] && error "mdsrate file creation failed, aborting"
 
 fi
 
@@ -86,31 +78,29 @@ if [ -n "$NOSINGLE" ]; then
     echo "NO Test for stats on a single client."
 else
     log "===== $0 ### 1 NODE STAT ###"
-    echo "Running stats on 1 node(s)."
     echo "+" ${COMMAND}
 
     mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-        error "mpirun ... mdsrate ... failed, aborting"
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate stats on a single client failed, aborting"
     fi
 fi
 
 # 2
+[ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
 if [ -n "$NOMULTI" ]; then
     echo "NO test for stats on multiple nodes."
 else
     log "===== $0 ### ${NUM_CLIENTS} NODES STAT ###"
-    echo "Running stats on ${NUM_CLIENTS} node(s)."
     echo "+" ${COMMAND}
 
-    NUM_THREADS=$(get_node_count ${NODES_TO_USE//,/ })
-    mpi_run -np ${NUM_THREADS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
+    mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-        error "mpirun ... mdsrate ... failed, aborting"
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate stats on multiple nodes failed, aborting"
     fi
 fi
 
diff --git a/lustre/tests/mdsrate-stat-small.sh b/lustre/tests/mdsrate-stat-small.sh
index 355f408..21e3a03 100644
--- a/lustre/tests/mdsrate-stat-small.sh
+++ b/lustre/tests/mdsrate-stat-small.sh
@@ -59,21 +59,13 @@ else
     mdsrate_cleanup $NUM_CLIENTS $MACHINEFILE $NUM_FILES $TESTDIR 'f%%d' --ignore
 
     log "===== $0 Test preparation: creating ${NUM_FILES} files."
-    echo "Test preparation: creating ${NUM_FILES} files."
 
     COMMAND="${MDSRATE} ${MDSRATE_DEBUG} --mknod --dir ${TESTDIR}
                         --nfiles ${NUM_FILES} --filefmt 'f%%d'"
     echo "+" ${COMMAND}
 
-    MDSCOUNT=1
-    NUM_CLIENTS=$(get_node_count ${NODES_TO_USE//,/ })
-    NUM_THREADS=$((NUM_CLIENTS * MDSCOUNT))
-    if [ $NUM_CLIENTS -gt 50 ]; then
-        NUM_THREADS=$NUM_CLIENTS
-    fi
-
-    mpi_run -np ${NUM_THREADS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1
-    [ ${PIPESTATUS[0]} != 0 ] && error "Error running mdsrate, aborting..."
+    mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} 2>&1
+    [ ${PIPESTATUS[0]} != 0 ] && error "mdsrate file creation failed, aborting"
 
 fi
 
@@ -86,30 +78,29 @@ if [ -n "$NOSINGLE" ]; then
     echo "NO Test for stats on a single client."
 else
     log "===== $0 ### 1 NODE STAT ###"
-    echo "Running stats on 1 node(s)."
     echo "+" ${COMMAND}
 
     mpi_run -np 1 -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
     
     if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-        error "mpirun ... mdsrate ... failed, aborting"
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate on a single client failed, aborting"
     fi
 fi
 
 # 2
+[ $NUM_CLIENTS -eq 1 ] && NOMULTI=yes
 if [ -n "$NOMULTI" ]; then
     echo "NO test for stats on multiple nodes."
 else
     log "===== $0 ### ${NUM_CLIENTS} NODES STAT ###"
-    echo "Running stats on ${NUM_CLIENTS} node(s)."
     echo "+" ${COMMAND}
 
     mpi_run -np ${NUM_CLIENTS} -machinefile ${MACHINEFILE} ${COMMAND} | tee ${LOG}
 
     if [ ${PIPESTATUS[0]} != 0 ]; then
-        [ -f $LOG ] && cat $LOG
-        error "mpirun ... mdsrate ... failed, aborting"
+        [ -f $LOG ] && sed -e "s/^/log: /" $LOG
+        error "mdsrate stats on multiple nodes failed, aborting"
     fi
 fi
 
diff --git a/lustre/tests/mmap_sanity.c b/lustre/tests/mmap_sanity.c
index ea0db2d..1cda15a 100644
--- a/lustre/tests/mmap_sanity.c
+++ b/lustre/tests/mmap_sanity.c
@@ -599,6 +599,67 @@ out:
         return rc;
 }
 
+static int mmap_tst7_func(char *mnt, int rw)
+{
+        char  fname[256];
+        char *buf = MAP_FAILED;
+        ssize_t bytes;
+        int fd = -1;
+        int rc = 0;
+
+        if (snprintf(fname, 256, "%s/mmap_tst7.%s",
+                     mnt, (rw == 0) ? "read":"write") >= 256) {
+                fprintf(stderr, "dir name too long\n");
+                rc = ENAMETOOLONG;
+                goto out;
+        }
+        fd = open(fname, O_RDWR | O_DIRECT | O_CREAT, 0644);
+        if (fd == -1) {
+                perror("open");
+                rc = errno;
+                goto out;
+        }
+        if (ftruncate(fd, 2 * page_size) == -1) {
+                perror("truncate");
+                rc = errno;
+                goto out;
+        }
+        buf = mmap(NULL, 2 * page_size,
+                   PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+        if (buf == MAP_FAILED) {
+                perror("mmap");
+                rc = errno;
+                goto out;
+        }
+        /* ensure the second page isn't mapped */
+        munmap(buf + page_size, page_size);
+        bytes = (rw == 0) ? read(fd, buf, 2 * page_size) :
+                write(fd, buf, 2 * page_size);
+        /* Expected behavior */
+        if (bytes == page_size)
+                goto out;
+        fprintf(stderr, "%s returned %zd, errno = %d\n",
+                (rw == 0)?"read":"write", bytes, errno);
+        rc = EIO;
+out:
+        if (buf != MAP_FAILED)
+                munmap(buf, page_size);
+        if (fd != -1)
+                close(fd);
+        return rc;
+}
+
+static int mmap_tst7(char *mnt)
+{
+        int rc;
+
+        rc = mmap_tst7_func(mnt, 0);
+        if (rc != 0)
+                return rc;
+        rc = mmap_tst7_func(mnt, 1);
+        return rc;
+}
+
 static int remote_tst(int tc, char *mnt)
 {
         int rc = 0;
@@ -634,6 +695,7 @@ struct test_case tests[] = {
              "which mmapped to just this file", mmap_tst5, 1 },
         { 6, "mmap test6: check mmap write/read content on two nodes", 
                 mmap_tst6, 2 },
+        { 7, "mmap test7: file i/o with an unmapped buffer", mmap_tst7, 1},
         { 0, NULL, 0, 0 }
 };
 
diff --git a/lustre/tests/mpi/Makefile.am b/lustre/tests/mpi/Makefile.am
new file mode 100644
index 0000000..805cdd3
--- /dev/null
+++ b/lustre/tests/mpi/Makefile.am
@@ -0,0 +1,15 @@
+# Lustre MPI test Makefile
+AM_CPPFLAGS = $(LLCPPFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DLUSTRE_UTILS
+AM_CFLAGS = $(LLCFLAGS)
+
+CC = @MPICC_WRAPPER@
+
+noinst_PROGRAMS = parallel_grouplock write_append_truncate createmany_mpi mdsrate
+testdir = $(libdir)/lustre/tests
+test_SCRIPTS = $(noinst_PROGRAMS)
+
+write_append_truncate_SOURCES=write_append_truncate.c
+createmany_mpi_SOURCES=createmany-mpi.c
+parallel_grouplock_SOURCES=parallel_grouplock.c lp_utils.c lp_utils.h
+mdsrate_SOURCES=mdsrate.c
+mdsrate_LDADD=-L$(top_builddir)/lustre/utils -llustreapi
diff --git a/lustre/tests/mpi/Makefile.in b/lustre/tests/mpi/Makefile.in
new file mode 100644
index 0000000..65f4927
--- /dev/null
+++ b/lustre/tests/mpi/Makefile.in
@@ -0,0 +1,614 @@
+# Makefile.in generated by automake 1.7.9 from Makefile.am.
+# @configure_input@
+
+# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../../..
+
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+ACLOCAL = @ACLOCAL@
+AC_LUSTRE_CLIENT_URN = @AC_LUSTRE_CLIENT_URN@
+AC_LUSTRE_CLI_VER_OFFSET_WARN = @AC_LUSTRE_CLI_VER_OFFSET_WARN@
+AC_LUSTRE_FIX = @AC_LUSTRE_FIX@
+AC_LUSTRE_LIB_VER_OFFSET_WARN = @AC_LUSTRE_LIB_VER_OFFSET_WARN@
+AC_LUSTRE_MAJOR = @AC_LUSTRE_MAJOR@
+AC_LUSTRE_MDS_URN = @AC_LUSTRE_MDS_URN@
+AC_LUSTRE_MGS_URN = @AC_LUSTRE_MGS_URN@
+AC_LUSTRE_MINOR = @AC_LUSTRE_MINOR@
+AC_LUSTRE_OSS_URN = @AC_LUSTRE_OSS_URN@
+AC_LUSTRE_PATCH = @AC_LUSTRE_PATCH@
+AC_LUSTRE_VERSION_STRING = @AC_LUSTRE_VERSION_STRING@
+AC_LUSTRE_VER_ALLOWED_OFFSET = @AC_LUSTRE_VER_ALLOWED_OFFSET@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+ARCH_UM = @ARCH_UM@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BACKINGFS = @BACKINGFS@
+BLKID_FALSE = @BLKID_FALSE@
+BLKID_TRUE = @BLKID_TRUE@
+BUILD_CIBLND_FALSE = @BUILD_CIBLND_FALSE@
+BUILD_CIBLND_TRUE = @BUILD_CIBLND_TRUE@
+BUILD_GMLND_FALSE = @BUILD_GMLND_FALSE@
+BUILD_GMLND_TRUE = @BUILD_GMLND_TRUE@
+BUILD_IIBLND_FALSE = @BUILD_IIBLND_FALSE@
+BUILD_IIBLND_TRUE = @BUILD_IIBLND_TRUE@
+BUILD_MXLND_FALSE = @BUILD_MXLND_FALSE@
+BUILD_MXLND_TRUE = @BUILD_MXLND_TRUE@
+BUILD_O2IBLND_FALSE = @BUILD_O2IBLND_FALSE@
+BUILD_O2IBLND_TRUE = @BUILD_O2IBLND_TRUE@
+BUILD_OPENIBLND_FALSE = @BUILD_OPENIBLND_FALSE@
+BUILD_OPENIBLND_TRUE = @BUILD_OPENIBLND_TRUE@
+BUILD_PTLLND_FALSE = @BUILD_PTLLND_FALSE@
+BUILD_PTLLND_TRUE = @BUILD_PTLLND_TRUE@
+BUILD_QSWLND_FALSE = @BUILD_QSWLND_FALSE@
+BUILD_QSWLND_TRUE = @BUILD_QSWLND_TRUE@
+BUILD_RALND_FALSE = @BUILD_RALND_FALSE@
+BUILD_RALND_TRUE = @BUILD_RALND_TRUE@
+BUILD_UPTLLND_FALSE = @BUILD_UPTLLND_FALSE@
+BUILD_UPTLLND_TRUE = @BUILD_UPTLLND_TRUE@
+BUILD_USOCKLND_FALSE = @BUILD_USOCKLND_FALSE@
+BUILD_USOCKLND_TRUE = @BUILD_USOCKLND_TRUE@
+BUILD_VIBLND_FALSE = @BUILD_VIBLND_FALSE@
+BUILD_VIBLND_TRUE = @BUILD_VIBLND_TRUE@
+CAP_LIBS = @CAP_LIBS@
+
+CC = @MPICC_WRAPPER@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CIBCPPFLAGS = @CIBCPPFLAGS@
+CIBLND = @CIBLND@
+CLIENT_FALSE = @CLIENT_FALSE@
+CLIENT_TRUE = @CLIENT_TRUE@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CRAY_XT3_FALSE = @CRAY_XT3_FALSE@
+CRAY_XT3_TRUE = @CRAY_XT3_TRUE@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_FALSE = @DARWIN_FALSE@
+DARWIN_TRUE = @DARWIN_TRUE@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DMU_OSD_ENABLED_FALSE = @DMU_OSD_ENABLED_FALSE@
+DMU_OSD_ENABLED_TRUE = @DMU_OSD_ENABLED_TRUE@
+DMU_SRC = @DMU_SRC@
+DOC_FALSE = @DOC_FALSE@
+DOC_TRUE = @DOC_TRUE@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_DOC = @ENABLE_DOC@
+ENABLE_INIT_SCRIPTS = @ENABLE_INIT_SCRIPTS@
+ENABLE_LIBPTHREAD = @ENABLE_LIBPTHREAD@
+EXEEXT = @EXEEXT@
+EXT2FS_DEVEL_FALSE = @EXT2FS_DEVEL_FALSE@
+EXT2FS_DEVEL_TRUE = @EXT2FS_DEVEL_TRUE@
+EXTRA_KCFLAGS = @EXTRA_KCFLAGS@
+EXTRA_KLDFLAGS = @EXTRA_KLDFLAGS@
+EXTRA_KLIBS = @EXTRA_KLIBS@
+EXTRA_LNET_INCLUDE = @EXTRA_LNET_INCLUDE@
+GMCPPFLAGS = @GMCPPFLAGS@
+GMLIBS = @GMLIBS@
+GMLND = @GMLND@
+IIBCPPFLAGS = @IIBCPPFLAGS@
+IIBLND = @IIBLND@
+INCLUDE_RULES = @INCLUDE_RULES@
+INIT_SCRIPTS_FALSE = @INIT_SCRIPTS_FALSE@
+INIT_SCRIPTS_TRUE = @INIT_SCRIPTS_TRUE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDMU_FALSE = @KDMU_FALSE@
+KDMU_TRUE = @KDMU_TRUE@
+KMODEXT = @KMODEXT@
+LDFLAGS = @LDFLAGS@
+LDISKFS_DIR = @LDISKFS_DIR@
+LDISKFS_ENABLED_FALSE = @LDISKFS_ENABLED_FALSE@
+LDISKFS_ENABLED_TRUE = @LDISKFS_ENABLED_TRUE@
+LDISKFS_SUBDIR = @LDISKFS_SUBDIR@
+LIBCFS_INCLUDE_DIR = @LIBCFS_INCLUDE_DIR@
+LIBCFS_SUBDIR = @LIBCFS_SUBDIR@
+LIBEFENCE = @LIBEFENCE@
+LIBLUSTRE_FALSE = @LIBLUSTRE_FALSE@
+LIBLUSTRE_TESTS_FALSE = @LIBLUSTRE_TESTS_FALSE@
+LIBLUSTRE_TESTS_TRUE = @LIBLUSTRE_TESTS_TRUE@
+LIBLUSTRE_TRUE = @LIBLUSTRE_TRUE@
+LIBOBJS = @LIBOBJS@
+LIBPTHREAD_FALSE = @LIBPTHREAD_FALSE@
+LIBPTHREAD_TRUE = @LIBPTHREAD_TRUE@
+LIBREADLINE = @LIBREADLINE@
+LIBS = @LIBS@
+LIBSYSIO_SUBDIR = @LIBSYSIO_SUBDIR@
+LIBWRAP = @LIBWRAP@
+LINUX = @LINUX@
+LINUX25_FALSE = @LINUX25_FALSE@
+LINUX25_TRUE = @LINUX25_TRUE@
+LINUXRELEASE = @LINUXRELEASE@
+LINUX_CONFIG = @LINUX_CONFIG@
+LINUX_FALSE = @LINUX_FALSE@
+LINUX_OBJ = @LINUX_OBJ@
+LINUX_TRUE = @LINUX_TRUE@
+LLCFLAGS = @LLCFLAGS@
+LLCPPFLAGS = @LLCPPFLAGS@
+LTLIBOBJS = @LTLIBOBJS@
+LUSTRE = @LUSTRE@
+LUSTREIOKIT_SUBDIR = @LUSTREIOKIT_SUBDIR@
+MAKEINFO = @MAKEINFO@
+MODULES_FALSE = @MODULES_FALSE@
+MODULES_TRUE = @MODULES_TRUE@
+MODULE_TARGET = @MODULE_TARGET@
+MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
+MPITESTS_FALSE = @MPITESTS_FALSE@
+MPITESTS_TRUE = @MPITESTS_TRUE@
+MXCPPFLAGS = @MXCPPFLAGS@
+MXLIBS = @MXLIBS@
+MXLND = @MXLND@
+NET_SNMP_CFLAGS = @NET_SNMP_CFLAGS@
+NET_SNMP_CONFIG = @NET_SNMP_CONFIG@
+NET_SNMP_LIBS = @NET_SNMP_LIBS@
+O2IBCPPFLAGS = @O2IBCPPFLAGS@
+O2IBLND = @O2IBLND@
+OBJEXT = @OBJEXT@
+OPENIBCPPFLAGS = @OPENIBCPPFLAGS@
+OPENIBLND = @OPENIBLND@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POSIX_OSD_ENABLED_FALSE = @POSIX_OSD_ENABLED_FALSE@
+POSIX_OSD_ENABLED_TRUE = @POSIX_OSD_ENABLED_TRUE@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PTLLND = @PTLLND@
+PTLLNDCPPFLAGS = @PTLLNDCPPFLAGS@
+QSWCPPFLAGS = @QSWCPPFLAGS@
+QSWLND = @QSWLND@
+QUOTA_FALSE = @QUOTA_FALSE@
+QUOTA_TRUE = @QUOTA_TRUE@
+RACPPFLAGS = @RACPPFLAGS@
+RALND = @RALND@
+RANLIB = @RANLIB@
+RELEASE = @RELEASE@
+SERVER_FALSE = @SERVER_FALSE@
+SERVER_TRUE = @SERVER_TRUE@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SNMP_DIST_SUBDIR = @SNMP_DIST_SUBDIR@
+SNMP_SUBDIR = @SNMP_SUBDIR@
+SPL_DIR = @SPL_DIR@
+STRIP = @STRIP@
+SUNOS_FALSE = @SUNOS_FALSE@
+SUNOS_TRUE = @SUNOS_TRUE@
+SYMVERFILE = @SYMVERFILE@
+SYSIO = @SYSIO@
+TESTS_FALSE = @TESTS_FALSE@
+TESTS_TRUE = @TESTS_TRUE@
+UML_CFLAGS = @UML_CFLAGS@
+UPTLLND = @UPTLLND@
+USE_QUILT_FALSE = @USE_QUILT_FALSE@
+USE_QUILT_TRUE = @USE_QUILT_TRUE@
+USOCKLND = @USOCKLND@
+UTILS_FALSE = @UTILS_FALSE@
+UTILS_TRUE = @UTILS_TRUE@
+VERSION = @VERSION@
+VIBCPPFLAGS = @VIBCPPFLAGS@
+VIBLND = @VIBLND@
+ZFS_DIR = @ZFS_DIR@
+ZLIB = @ZLIB@
+ac_configure_args = @ac_configure_args@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+agentdir = @agentdir@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+demodir = @demodir@
+docdir = @docdir@
+enable_uoss = @enable_uoss@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+kextdir = @kextdir@
+lb_target_os = @lb_target_os@
+libdir = @libdir@
+libexecdir = @libexecdir@
+linux25 = @linux25@
+localstatedir = @localstatedir@
+macosdir = @macosdir@
+mandir = @mandir@
+mibdir = @mibdir@
+moduledir = @moduledir@
+modulefsdir = @modulefsdir@
+modulenetdir = @modulenetdir@
+oldincludedir = @oldincludedir@
+pkgexampledir = @pkgexampledir@
+plistdir = @plistdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+rootsbindir = @rootsbindir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+spl_src = @spl_src@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+
+# Lustre MPI test Makefile
+AM_CPPFLAGS = $(LLCPPFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DLUSTRE_UTILS
+AM_CFLAGS = $(LLCFLAGS)
+
+noinst_PROGRAMS = parallel_grouplock write_append_truncate createmany_mpi mdsrate
+testdir = $(libdir)/lustre/tests
+test_SCRIPTS = $(noinst_PROGRAMS)
+
+write_append_truncate_SOURCES = write_append_truncate.c
+createmany_mpi_SOURCES = createmany-mpi.c
+parallel_grouplock_SOURCES = parallel_grouplock.c lp_utils.c lp_utils.h
+mdsrate_SOURCES = mdsrate.c
+mdsrate_LDADD = -L$(top_builddir)/lustre/utils -llustreapi
+subdir = lustre/tests/mpi
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+noinst_PROGRAMS = parallel_grouplock$(EXEEXT) \
+	write_append_truncate$(EXEEXT) createmany_mpi$(EXEEXT) \
+	mdsrate$(EXEEXT)
+PROGRAMS = $(noinst_PROGRAMS)
+
+am_createmany_mpi_OBJECTS = createmany-mpi.$(OBJEXT)
+createmany_mpi_OBJECTS = $(am_createmany_mpi_OBJECTS)
+createmany_mpi_LDADD = $(LDADD)
+createmany_mpi_DEPENDENCIES =
+createmany_mpi_LDFLAGS =
+am_mdsrate_OBJECTS = mdsrate.$(OBJEXT)
+mdsrate_OBJECTS = $(am_mdsrate_OBJECTS)
+mdsrate_DEPENDENCIES =
+mdsrate_LDFLAGS =
+am_parallel_grouplock_OBJECTS = parallel_grouplock.$(OBJEXT) \
+	lp_utils.$(OBJEXT)
+parallel_grouplock_OBJECTS = $(am_parallel_grouplock_OBJECTS)
+parallel_grouplock_LDADD = $(LDADD)
+parallel_grouplock_DEPENDENCIES =
+parallel_grouplock_LDFLAGS =
+am_write_append_truncate_OBJECTS = write_append_truncate.$(OBJEXT)
+write_append_truncate_OBJECTS = $(am_write_append_truncate_OBJECTS)
+write_append_truncate_LDADD = $(LDADD)
+write_append_truncate_DEPENDENCIES =
+write_append_truncate_LDFLAGS =
+SCRIPTS = $(test_SCRIPTS)
+
+
+DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+ at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/createmany-mpi.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/lp_utils.Po ./$(DEPDIR)/mdsrate.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/parallel_grouplock.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/write_append_truncate.Po
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+DIST_SOURCES = $(createmany_mpi_SOURCES) $(mdsrate_SOURCES) \
+	$(parallel_grouplock_SOURCES) $(write_append_truncate_SOURCES)
+DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
+SOURCES = $(createmany_mpi_SOURCES) $(mdsrate_SOURCES) $(parallel_grouplock_SOURCES) $(write_append_truncate_SOURCES)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+$(srcdir)/Makefile.in:  Makefile.am  $(top_srcdir)/configure.ac $(ACLOCAL_M4)
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu  lustre/tests/mpi/Makefile
+Makefile:  $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
+
+clean-noinstPROGRAMS:
+	-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+createmany_mpi$(EXEEXT): $(createmany_mpi_OBJECTS) $(createmany_mpi_DEPENDENCIES) 
+	@rm -f createmany_mpi$(EXEEXT)
+	$(LINK) $(createmany_mpi_LDFLAGS) $(createmany_mpi_OBJECTS) $(createmany_mpi_LDADD) $(LIBS)
+mdsrate$(EXEEXT): $(mdsrate_OBJECTS) $(mdsrate_DEPENDENCIES) 
+	@rm -f mdsrate$(EXEEXT)
+	$(LINK) $(mdsrate_LDFLAGS) $(mdsrate_OBJECTS) $(mdsrate_LDADD) $(LIBS)
+parallel_grouplock$(EXEEXT): $(parallel_grouplock_OBJECTS) $(parallel_grouplock_DEPENDENCIES) 
+	@rm -f parallel_grouplock$(EXEEXT)
+	$(LINK) $(parallel_grouplock_LDFLAGS) $(parallel_grouplock_OBJECTS) $(parallel_grouplock_LDADD) $(LIBS)
+write_append_truncate$(EXEEXT): $(write_append_truncate_OBJECTS) $(write_append_truncate_DEPENDENCIES) 
+	@rm -f write_append_truncate$(EXEEXT)
+	$(LINK) $(write_append_truncate_LDFLAGS) $(write_append_truncate_OBJECTS) $(write_append_truncate_LDADD) $(LIBS)
+testSCRIPT_INSTALL = $(INSTALL_SCRIPT)
+install-testSCRIPTS: $(test_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	$(mkinstalldirs) $(DESTDIR)$(testdir)
+	@list='$(test_SCRIPTS)'; for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f $$d$$p; then \
+	    f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	    echo " $(testSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(testdir)/$$f"; \
+	    $(testSCRIPT_INSTALL) $$d$$p $(DESTDIR)$(testdir)/$$f; \
+	  else :; fi; \
+	done
+
+uninstall-testSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(test_SCRIPTS)'; for p in $$list; do \
+	  f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \
+	  echo " rm -f $(DESTDIR)$(testdir)/$$f"; \
+	  rm -f $(DESTDIR)$(testdir)/$$f; \
+	done
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT) core *.core
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/createmany-mpi.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lp_utils.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mdsrate.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/parallel_grouplock.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/write_append_truncate.Po at am__quote@
+
+.c.o:
+ at am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
+
+.c.obj:
+ at am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
+ at am__fastdepCC_TRUE@	  -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
+ at am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
+ at am__fastdepCC_TRUE@	else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
+ at am__fastdepCC_TRUE@	fi
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
+uninstall-info-am:
+
+ETAGS = etags
+ETAGSFLAGS =
+
+CTAGS = ctags
+CTAGSFLAGS =
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)$$tags$$unique" \
+	  || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	     $$tags $$unique
+
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+
+top_distdir = ../../..
+distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkinstalldirs) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(SCRIPTS)
+
+installdirs:
+	$(mkinstalldirs) $(DESTDIR)$(testdir)
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+	-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
+
+clean-generic:
+
+distclean-generic:
+	-rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-testSCRIPTS
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-testSCRIPTS
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-noinstPROGRAMS ctags distclean distclean-compile \
+	distclean-generic distclean-tags distdir dvi dvi-am info \
+	info-am install install-am install-data install-data-am \
+	install-exec install-exec-am install-info install-info-am \
+	install-man install-strip install-testSCRIPTS installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+	uninstall-am uninstall-info-am uninstall-testSCRIPTS
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/lustre/tests/mpi/createmany-mpi.c b/lustre/tests/mpi/createmany-mpi.c
new file mode 100644
index 0000000..d203fa6
--- /dev/null
+++ b/lustre/tests/mpi/createmany-mpi.c
@@ -0,0 +1,176 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "mpi.h"
+
+void usage(char *prog)
+{
+        printf("usage: %s {-o|-m|-l<tgt>} filenamefmt count\n", prog);
+        printf("       %s {-o|-m|-l<tgt>} filenamefmt -seconds\n", prog);
+        printf("       %s {-o|-m|-l<tgt>} filenamefmt start count\n", prog);
+}
+
+/* Print process rank, loop count, message, and exit (i.e. a fatal error) */
+int rprintf(int rank, int loop, const char *fmt, ...)
+{
+        va_list       ap;
+
+        printf("rank %d, loop %d: ", rank, loop);
+
+        va_start(ap, fmt);
+
+        printf(fmt, ap);
+
+        MPI_Finalize();
+        exit(1);
+}
+
+int main(int argc, char ** argv)
+{
+        int i, rc = 0, do_open = 0, do_link = 0, rank;
+        char format[4096], *fmt, *tgt = NULL;
+        char filename[4096];
+        long start, last, end;
+        long begin = 0, count;
+
+        rc = MPI_Init(&argc, &argv);
+        if (rc != MPI_SUCCESS)
+                rprintf(-1, -1, "MPI_Init failed: %d\n", rc);
+
+        if (argc < 4 || argc > 5) {
+                usage(argv[0]);
+                return 1;
+        }
+
+        if (strcmp(argv[1], "-o") == 0) {
+                do_open = 1;
+                tgt = NULL;
+        } else if (strncmp(argv[1], "-l", 2) == 0 && argv[1][2]) {
+                tgt = argv[1] + 2;
+                do_link = 1;
+        } else if (strcmp(argv[1], "-m") != 0) {
+                usage(argv[0]);
+                return 1;
+        }
+
+        if (strlen(argv[2]) > 4080) {
+                printf("name too long\n");
+                return 1;
+        }
+
+        rc = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+        if (rc != MPI_SUCCESS)
+                rprintf(-1, -1, "MPI_Comm_rank failed: %d\n", rc);
+
+        rc = MPI_Barrier(MPI_COMM_WORLD);
+        if (rc != MPI_SUCCESS)
+                rprintf(rank, -1, "prep MPI_Barrier failed: %d\n", rc);
+
+        start = last = time(0);
+
+        if (argc == 4) {
+                end = strtol(argv[3], NULL, 0);
+        } else {
+                begin = strtol(argv[3], NULL, 0);
+                end = strtol(argv[4], NULL, 0);
+        }
+        if (end > 0) {
+                count = end;
+                end = -1UL >> 1;
+        } else {
+                end = start - end;
+                count = -1UL >> 1;
+        }
+
+        if (strchr(argv[2], '%'))
+                fmt = argv[2];
+        else {
+                sprintf(format, "%s%%d", argv[2]);
+                fmt = format;
+        }
+        printf("starting at %s", ctime(&start));
+        for (i = 0; i < count && time(0) < end; i++, begin++) {
+                sprintf(filename, fmt, begin);
+                if (do_open) {
+                        int fd = open(filename, O_CREAT|O_RDWR, 0644);
+                        if (fd < 0) {
+                                printf("open(%s) error: %s\n", filename,
+                                       strerror(errno));
+                                rc = errno;
+                                break;
+                        }
+                        close(fd);
+                } else if (do_link) {
+                        rc = link(tgt, filename);
+                        if (rc) {
+                                printf("link(%s, %s) error: %s\n",
+                                       tgt, filename, strerror(errno));
+                                rc = errno;
+                                break;
+                        }
+                } else {
+                        rc = mknod(filename, S_IFREG| 0444, 0);
+                        if (rc) {
+                                printf("mknod(%s) error: %s\n",
+                                       filename, strerror(errno));
+                                rc = errno;
+                                break;
+                        }
+                }
+                if ((i % 10000) == 0) {
+                        printf(" - created %d (time %ld total %ld last %ld)\n",
+                               i, time(0), time(0) - start, time(0) - last);
+                        last = time(0);
+                }
+        }
+        printf("total: %d creates in %ld seconds: %f creates/second\n", i,
+               time(0) - start, ((float)i / (time(0) - start)));
+        start = time(0);
+        printf("finish at %s", ctime(&start));
+
+        return rc;
+}
diff --git a/lustre/tests/mpi/lp_utils.c b/lustre/tests/mpi/lp_utils.c
new file mode 100644
index 0000000..068cbf5
--- /dev/null
+++ b/lustre/tests/mpi/lp_utils.c
@@ -0,0 +1,283 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/tests/lp_utils.c
+ *
+ * Author: You Feng <youfeng at clusterfs.com>
+ */
+
+#include <mpi.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "lustre/lustre_user.h"
+#include "lustre/tests/mpi/lp_utils.h"
+
+#define MAX_PROCESSES 8
+
+int verbose = 0;
+int debug = 0;
+
+char hostname[1024];
+
+struct timeval t1, t2;
+
+char *timestamp() {
+        static char datestring[80];
+        time_t timestamp;
+
+        fflush(stdout);
+        timestamp = time(NULL);
+        strftime(datestring, 80, "%T", localtime(&timestamp));
+
+        return datestring;
+}
+
+inline void begin(char *str) {
+        if (verbose > 0 && rank == 0) {
+                gettimeofday(&t1, NULL);
+                printf("%s:\tBeginning %s\n", timestamp(), str);
+                fflush(stdout);
+        }
+}
+
+inline void end(char *str) {
+        float elapsed;
+
+        MPI_Barrier(MPI_COMM_WORLD);
+        if (verbose > 0 && rank == 0) {
+                gettimeofday(&t2, NULL);
+                elapsed = (t2.tv_sec + ((float)t2.tv_usec/1000000))
+                          - (t1.tv_sec + ((float)t1.tv_usec/1000000));
+                if (elapsed >= 60) {
+                        printf("%s:\tFinished %-15s(%.2f min)\n",
+                               timestamp(), str, elapsed / 60);
+                } else {
+                        printf("%s:\tFinished %-15s(%.3f sec)\n",
+		               timestamp(), str, elapsed);
+
+                }
+                fflush(stdout);
+        }
+}
+
+void dump_diff(char *orig_buf, char *buf, int size, long _off)
+{
+        int i, diff, off;
+        char *p, *end;
+
+        printf("commpared buf size %d, at offset %lu\n\n", size, _off);
+
+        if (orig_buf) {
+                printf("original buf:\n");
+                p = orig_buf;
+                end = orig_buf + size;
+                i = 1;
+                while (p < end) {
+                        printf(" %8lx", *(long *)p);
+                        p += sizeof(long);
+                        if (i++%8 == 0)
+                                printf("\n");
+                }
+                if (i%8) printf("\n\n");
+                else printf("\n");
+        }
+
+        if (buf) {
+                printf("different data: diff_data(orig_data)\n");
+                diff = 0;
+                off = 0;
+                i = 1;
+                p = buf;
+                end = buf + size;
+                while (p < end) {
+                        if (memcmp(p, orig_buf + off, sizeof(long)) != 0) {
+                                printf("\toff: %5d,\tdata: %8lx (%8lx)\n", off,
+                                       *(unsigned long *)p,
+                                       *(unsigned long *)(orig_buf + off));
+                                diff++;
+                        }
+                        off += sizeof(long);
+                        p += sizeof(long);
+                }
+                printf("\n %d total differents found\n\n", diff);
+        }
+}
+
+void lp_gethostname(void)
+{
+        if (gethostname(hostname, 1024) == -1) {
+                fprintf(stderr, "gethostname: (%d)%s", errno, strerror(errno));
+                MPI_Abort(MPI_COMM_WORLD, 2);
+        }
+}
+
+/* This function does not FAIL if the requested "name" does not exit.
+ * This is just to clean up any files or directories left over from
+ * previous runs
+ */
+void remove_file_or_dir(char *name)
+{
+        struct stat statbuf;
+        char errmsg[MAX_FILENAME_LEN + 20];
+
+        if (stat(name, &statbuf) != -1) {
+                if (S_ISREG(statbuf.st_mode)) {
+                        printf("stale file found\n");
+                        if (unlink(name) == -1) {
+                                sprintf(errmsg, "unlink of %s", name);
+                                FAIL(errmsg);
+                        }
+                }
+                if (S_ISDIR(statbuf.st_mode)) {
+                        printf("stale directory found\n");
+                        if (rmdir(name) == -1) {
+                                sprintf(errmsg, "rmdir of %s", name);
+                                FAIL(errmsg);
+                        }
+                }
+        }
+}
+
+void create_file(char *name, long filesize, int fill)
+{
+        static char filename[MAX_FILENAME_LEN];
+        char errmsg[MAX_FILENAME_LEN + 20];
+        char buf[1024 * 8];
+        char c = 'A' + size;
+        int fd, rc;
+        short zero = 0;
+        long left = filesize;
+
+        /* Process 0 creates the test file(s) */
+        if (rank == 0) {
+                sprintf(filename, "%s/%s", testdir, name);
+                remove_file_or_dir(filename);
+                if ((fd = creat(filename, FILEMODE)) == -1) {
+                        sprintf(errmsg, "create of file %s", filename);
+                        FAIL(errmsg);
+                }
+                if (filesize > 0) {
+                        if (lseek(fd, filesize - 1, SEEK_SET) == -1) {
+                                close(fd);
+                                sprintf(errmsg, "lseek of file %s", filename);
+                                FAIL(errmsg);
+                        }
+                        if (write(fd, &zero, 1) == -1) {
+                                close(fd);
+                                sprintf(errmsg, "write of file %s", filename);
+                                FAIL(errmsg);
+                        }
+                }
+                if (filesize > 0 && fill) {
+                        if (lseek(fd, 0, SEEK_SET) == -1) {
+                                close(fd);
+                                sprintf(errmsg, "lseek of file %s", filename);
+                                FAIL(errmsg);
+                        }
+                        memset(buf, c, 1024);
+                        while (left > 0) {
+                                if ((rc = write(fd, buf,
+                                                left > (1024 * 8) ? (1024 * 8) : left))
+                                    == -1) {
+                                        close(fd);
+                                        sprintf(errmsg, "write of file %s", filename);
+                                        FAIL(errmsg);
+                                }
+                                left -= rc;
+                        }
+                }
+                if (close(fd) == -1) {
+                        sprintf(errmsg, "close of file %s", filename);
+                        FAIL(errmsg);
+                }
+        }
+}
+
+void check_stat(char *filename, struct stat *state, struct stat *old_state)
+{
+        char errmsg[MAX_FILENAME_LEN+20];
+
+        if (stat(filename, state) == -1) {
+                sprintf(errmsg, "stat of file %s", filename);
+                FAIL(errmsg);
+        }
+
+        if (memcmp(state, old_state, sizeof(struct stat)) != 0) {
+                errno = 0;
+                sprintf(errmsg, LP_STAT_FMT, LP_STAT_ARGS);
+                FAIL(errmsg);
+        }
+}
+
+void remove_file(char *name)
+{
+        char filename[MAX_FILENAME_LEN];
+        char errmsg[MAX_FILENAME_LEN + 20];
+
+        /* Process 0 remove the file(s) */
+        if (rank == 0) {
+                sprintf(filename, "%s/%s", testdir, name);
+                if (unlink(filename) == -1) {
+                        sprintf(errmsg, "unlink of file %s", filename);
+                        FAIL(errmsg);
+                }
+        }
+}
+
+void fill_stride(char *buf, int buf_size, long long rank, long long _off)
+{
+        char *p = buf;
+        long long off, data[2];
+        int cp, left = buf_size;
+
+        data[0] = rank;
+        off = _off;
+        while (left > 0) {
+                data[1] = off;
+                cp = left > sizeof(data) ? sizeof(data) : left;
+                memcpy(p, data, cp);
+                off += cp;
+                p += cp;
+                left -= cp;
+        }
+}
diff --git a/lustre/tests/lp_utils.h b/lustre/tests/mpi/lp_utils.h
similarity index 100%
rename from lustre/tests/lp_utils.h
rename to lustre/tests/mpi/lp_utils.h
diff --git a/lustre/tests/mdsrate.c b/lustre/tests/mpi/mdsrate.c
similarity index 100%
rename from lustre/tests/mdsrate.c
rename to lustre/tests/mpi/mdsrate.c
diff --git a/lustre/tests/mpi/parallel_grouplock.c b/lustre/tests/mpi/parallel_grouplock.c
new file mode 100644
index 0000000..e094d1c
--- /dev/null
+++ b/lustre/tests/mpi/parallel_grouplock.c
@@ -0,0 +1,912 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/tests/parallel_grouplock.c
+ *
+ * Author: You Feng <youfeng at clusterfs.com>
+ */
+
+#include <mpi.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <time.h>
+#include <errno.h>
+#include <lustre/lustre_user.h>
+#include <lustre/tests/mpi/lp_utils.h>
+
+#define LPGL_FILEN 700000
+#define LPGL_TEST_ITEMS 7
+
+#define MAX_GLHOST 4
+
+/* waiting time in 0.1 s */
+#define MAX_WAITING_TIME 20
+int rank = 0;
+int size = 0;
+
+char *testdir = NULL;
+
+/*
+ * process1 attempts CW(gid=1) -- granted immediately
+ * process2 attempts PR -- blocked, goes on waiting list
+ * process3 attempts CW(gid=1) -> should be granted, but may go on
+ *                                the waiting list
+ */
+void grouplock_test1(char *filename, int fd, char *errmsg)
+{
+        int rc, count, gid = 1;
+        char buf[LPGL_FILEN];
+        char zeros[LPGL_FILEN];
+        MPI_Request req1, req2;
+        int temp1, temp2;
+
+        if (rank == 0) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+        if (rank == 1) {
+                memset(zeros, 0x0, sizeof(zeros));
+                lseek(fd, 0, SEEK_SET);
+
+                MPI_Send(&gid, 1, MPI_INT, 2, 1, MPI_COMM_WORLD);
+                count = read(fd, buf, sizeof(buf));
+                if (count != sizeof(buf)) {
+                        if (count > 0)
+                                dump_diff(zeros, buf, count, 0);
+                        sprintf(errmsg, "read of file %s return %d",
+                                filename, count);
+                        FAIL(errmsg);
+                }
+                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 2) {
+                int temp;
+
+                /* Wait for reading task to progress, this is probably somewhat
+                   racey, though, may be adding usleep here would make things
+                   better here. */
+                usleep(100);
+                MPI_Recv(&temp, 1, MPI_INT, 1, 1, MPI_COMM_WORLD,
+                         MPI_STATUS_IGNORE);
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1, flag2;
+
+                /* reading task will tell us when it completes */
+                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
+                /* 2nd locking task will tell us when it completes */
+                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
+
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("2nd locking task is not progressing\n");
+                        }
+                        usleep(100);
+                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                        if (flag1) {
+                                FAIL("PR task progressed even though GROUP lock"
+                                     " is held\n");
+                        }
+                } while (!flag2);
+        }
+
+        /* Now we need to release the lock */
+
+        if (rank == 0 || rank == 2) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1;
+
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("reading task is not progressing even "
+                                     "though GROUP lock was released\n");
+                                break;
+                        }
+                        usleep(100);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                } while (!flag1);
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+}
+
+/*
+ * process1 attempts CW(gid=1) -- granted immediately
+ * process2 attempts CW(gid=2) -- blocked
+ * process3 attempts PR -- blocked
+ * process4 attempts CW(gid=2) -- blocked
+ * process1 releases CW(gid=1) -- this allows process2's CW lock to be granted
+                                  process3 remains blocked
+ */
+void grouplock_test2(char *filename, int fd, char *errmsg)
+{
+        int rc, count, gid = 1;
+        char buf[LPGL_FILEN];
+        char zeros[LPGL_FILEN];
+        MPI_Request req1, req2, req3;
+        int temp1, temp2, temp3;
+
+        if (rank == 0) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+        if (rank == 1 || rank == 3) {
+                gid = 2;
+                if (rank == 3) {
+                        MPI_Recv(&temp1, 1, MPI_INT, 2, 1, MPI_COMM_WORLD,
+                                 MPI_STATUS_IGNORE);
+                        usleep(100);
+                }
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 2) {
+                memset(zeros, 0x0, sizeof(zeros));
+                lseek(fd, 0, SEEK_SET);
+
+                MPI_Send(&gid, 1, MPI_INT, 3, 1, MPI_COMM_WORLD);
+                count = read(fd, buf, sizeof(buf));
+                if (count != sizeof(buf)) {
+                        if (count > 0)
+                                dump_diff(zeros, buf, count, 0);
+                        sprintf(errmsg, "read of file %s return %d",
+                                filename, count);
+                        FAIL(errmsg);
+                }
+                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1, flag2, flag3;
+
+                /* 2nd locking task will tell us when it completes */
+                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
+                /* 3nd locking task will tell us when it completes */
+                MPI_Irecv(&temp2, 1, MPI_INT, 3, 1, MPI_COMM_WORLD, &req2);
+                /* reading task will tell us when it completes */
+                MPI_Irecv(&temp3, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req3);
+
+                do {
+                        iter--;
+                        usleep(100);
+                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                        MPI_Test(&req3, &flag3, MPI_STATUS_IGNORE);
+                        if (flag3) {
+                                FAIL("PR task progressed even though GROUP lock"
+                                     " is held\n");
+                        }
+                        if (flag1 || flag2) {
+                                FAIL("GROUP (gid=2) task progressed even though"
+                                     " GROUP (gid=1) lock is held\n");
+                        }
+
+                } while (iter);
+
+                /* Now let's release first lock */
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+                iter = MAX_WAITING_TIME;
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("GROUP(gid=2) tasks are not progressing\n");
+                        }
+                        usleep(100);
+                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                        MPI_Test(&req3, &flag3, MPI_STATUS_IGNORE);
+                        if (flag3) {
+                                fprintf(stderr, "task1 %d, task3 %d\n", flag1,
+                                        flag2);
+                                FAIL("PR task progressed even though GROUP lock"
+                                     " was on the queue task\n");
+                        }
+                } while (!(flag1 && flag2));
+                MPI_Send(&gid, 1, MPI_INT, 1, 1, MPI_COMM_WORLD);
+                MPI_Send(&gid, 1, MPI_INT, 3, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 1 || rank == 3) {
+                /* Do not release the locks until task 0 is ready to watch
+                   for reading task only */
+                MPI_Recv(&temp1, 1, MPI_INT, 0, 1, MPI_COMM_WORLD,
+                         MPI_STATUS_IGNORE);
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag3;
+
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("reading task is not progressing even "
+                                     "though GROUP locks are released\n");
+                                break;
+                        }
+                        usleep(100);
+                        MPI_Test(&req3, &flag3, MPI_STATUS_IGNORE);
+                } while (!flag3);
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+}
+
+/*
+ * process1 attempts CW(gid=1) -- granted
+ * process2 attempts PR -- blocked
+ * process3 attempts CW(gid=1) -> should be granted
+ * process3 releases CW(gid=1)
+ *   process2 should remain blocked
+ * process1 releases CW(gid=1)
+ *   process2's PR should be granted
+ *
+ * This is a lot like test1.
+ */
+void grouplock_test3(char *filename, int fd, char *errmsg)
+{
+        int rc, count, gid = 1;
+        char buf[LPGL_FILEN];
+        char zeros[LPGL_FILEN];
+        MPI_Request req1, req2;
+        int temp1, temp2;
+
+        if (rank == 0) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+        if (rank == 1) {
+                memset(zeros, 0x0, sizeof(zeros));
+                lseek(fd, 0, SEEK_SET);
+
+                MPI_Send(&gid, 1, MPI_INT, 2, 1, MPI_COMM_WORLD);
+                count = read(fd, buf, sizeof(buf));
+                if (count != sizeof(buf)) {
+                        if (count > 0)
+                                dump_diff(zeros, buf, count, 0);
+                        sprintf(errmsg, "read of file %s return %d",
+                                filename, count);
+                        FAIL(errmsg);
+                }
+                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 2) {
+                int temp;
+
+                /* Wait for reading task to progress, this is probably somewhat
+                   racey, though, may be adding usleep here would make things
+                   better here. */
+                usleep(100);
+                MPI_Recv(&temp, 1, MPI_INT, 1, 1, MPI_COMM_WORLD,
+                         MPI_STATUS_IGNORE);
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1, flag2;
+
+                /* reading task will tell us when it completes */
+                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
+                /* 2nd locking task will tell us when it completes */
+                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
+
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("2nd locking task is not progressing\n");
+                        }
+                        usleep(100);
+                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                        if (flag1) {
+                                FAIL("PR task progressed even though GROUP lock"
+                                     " is held\n");
+                        }
+                } while (!flag2);
+        }
+
+        /* Now we need to release the lock */
+
+        if (rank == 2) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1;
+
+                do {
+                        iter--;
+                        usleep(100);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                } while (!flag1 && iter);
+                if (iter) {
+                        FAIL("reading task is progressing even "
+                             "though GROUP lock was not fully released\n");
+                }
+
+                iter = MAX_WAITING_TIME;
+
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("reading task is not progressing even "
+                                     "though GROUP lock was released\n");
+                                break;
+                        }
+                        usleep(100);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                } while (!flag1);
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+}
+
+/*
+ * process1 attempts CW(gid=1) -- granted
+ * process2 attempts PR on non-blocking fd -> should return -EWOULDBLOCK
+ * process3 attempts CW(gid=2) on non-blocking fd -> should return -EWOULDBLOCK
+ */
+void grouplock_test4(char *filename, int fd, char *errmsg)
+{
+        int rc, count, gid = 1;
+        char buf[LPGL_FILEN];
+        char zeros[LPGL_FILEN];
+
+        if (rank == 0) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+        if (rank == 1) {
+                memset(zeros, 0x0, sizeof(zeros));
+                lseek(fd, 0, SEEK_SET);
+
+                count = read(fd, buf, sizeof(buf));
+                if (count != sizeof(buf)) {
+                        if (count == -1 && errno == EWOULDBLOCK) {
+                                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+                                return;
+                        }
+
+                        if (count > 0)
+                                dump_diff(zeros, buf, count, 0);
+                        sprintf(errmsg, "read of file %s return %d",
+                                filename, count);
+                        FAIL(errmsg);
+                } else {
+                        FAIL("PR lock succeed while incompatible "
+                             "GROUP LOCK (gid=1) is still held\n");
+                }
+        }
+
+        if (rank == 2) {
+                gid = 2;
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        if (errno == EWOULDBLOCK) {
+                                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+                                return;
+                        }
+
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                } else {
+                        FAIL("GROUP_LOCK (gid=2) succeed while incompatible "
+                             "GROUP LOCK (gid=1) is still held\n");
+                }
+        }
+
+
+        if ( rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1, flag2;
+                MPI_Request req1, req2;
+                int temp1, temp2;
+
+                /* reading task will tell us when it completes */
+                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
+                /* 2nd locking task will tell us when it completes */
+                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
+
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("non-blocking tasks are not progressing\n");
+                        }
+                        usleep(100);
+                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                } while (!(flag2 && flag1));
+
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s", filename);
+                        FAIL(errmsg);
+                }
+        }
+}
+
+/*
+ * process1 attempts CW(gid=1) -- granted
+ * process2 attempts CW(gid=2) -- blocked
+ * process3 attempts CW(gid=2) -- blocked
+ * process1 releases CW(gid=1)
+ *   process2's CW(gid=2) should be granted
+ *   process3's CW(gid=2) should be granted
+ *
+ * This is pretty much like test 3
+ */
+void grouplock_test5(char *filename, int fd, char *errmsg)
+{
+        int rc, gid = 1;
+        MPI_Request req1, req2;
+        int temp1, temp2;
+
+        if (rank == 0) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+        if (rank == 2 || rank == 1) {
+                gid = 2;
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
+        }
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1, flag2;
+
+                /* 3rd locking task will tell us when it completes */
+                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
+                /* 2nd locking task will tell us when it completes */
+                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
+
+                do {
+                        iter--;
+                        usleep(100);
+                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                } while (!flag2 && !flag1 && iter);
+                if (iter) {
+                        FAIL("incomptible locking tasks are progressing\n");
+                }
+        }
+
+        /* Now we need to release the lock */
+
+        if (rank == 0) {
+                int iter = MAX_WAITING_TIME;
+                int flag1, flag2;
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+
+                do {
+                        iter--;
+                        if (!iter) {
+                                FAIL("locking tasks are not progressing even "
+                                     "though incompatible lock released\n");
+                        }
+                        usleep(100);
+                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
+                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
+                } while (!(flag1 && flag2));
+
+        }
+
+        if ( rank == 1 || rank == 2) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+}
+
+/*
+ * process1 attempts CW(gid=1) -- granted
+ * process2 attempts PW -- blocked
+ * process2 attempts CW(gid=2) -- blocked
+ * process3 attempts CW(gid=2) -- blocked
+ * process1 releases CW(gid=1)
+ *   process2's CW(gid=2) should be granted
+ *   process3's CW(gid=2) should be granted
+ *
+ * after process1 release CW(gid=1), there are two pathes:
+ *   path 1. process2 get PW
+ *   path 2. process3 get CW(gid=2)
+ *
+ * green: Also about test6 - by definition if P* and CW lock are waiting,
+ *        CW lock have bigger priority and should be granted first when it becomes
+ *        possible. So after process1 releases its CW lock, process3 should always
+ *        get CW lock, and when it will release it, process 2 will proceed with read
+ *        and then with getting CW lock
+ *
+ * XXX This test does not make any sence at all the way it is described right
+ * now, hence disabled.
+ */
+void grouplock_test6(char *filename, int fd, char *errmsg)
+{
+}
+
+/* Just test some error paths with invalid requests */
+void grouplock_errorstest(char *filename, int fd, char *errmsg)
+{
+        int gid = 1;
+        int rc;
+
+        /* To not do lots of separate tests with lots of fd opening/closing,
+           different parts of this test are performed in different processes */
+
+        if (rank == 0 || rank == 1 ) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        /* second group lock on same fd, same gid */
+        if (rank == 0) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
+                        if (errno != EINVAL) {
+                                sprintf(errmsg, "Double GROUP lock failed with errno %d instead of EINVAL\n", errno);
+                                FAIL(errmsg);
+                        }
+                } else {
+                        FAIL("Taking second GROUP lock on same fd succeed\n");
+                }
+        }
+
+        /* second group lock on same fd, different gid */
+        if (rank == 1) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid + 1)) == -1) {
+                        if (errno != EINVAL) {
+                                sprintf(errmsg, "Double GROUP lock different gid failed with errno %d instead of EINVAL\n", errno);
+                                FAIL(errmsg);
+                        }
+                } else {
+                        FAIL("Taking second GROUP lock on same fd, different gid, succeed\n");
+                }
+        }
+
+        /* GROUP unlock with wrong gid */
+        if (rank == 0 || rank == 1) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid + 1)) == -1) {
+                        if (errno != EINVAL) {
+                                sprintf(errmsg, "GROUP unlock with wrong gid failed with errno %d instead of EINVAL\n",
+                                        errno);
+                                FAIL(errmsg);
+                        }
+                } else {
+                        FAIL("GROUP unlock with wrong gid succeed\n");
+                }
+        }
+
+        if (rank == 0 || rank == 1) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
+                                filename, rc);
+                        FAIL(errmsg);
+                }
+        }
+
+        /* unlock of never locked fd */
+        if (rank == 2) {
+                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
+                        if (errno != EINVAL) {
+                                sprintf(errmsg, "GROUP unlock on never locked fd failed with errno %d instead of EINVAL\n",
+                                        errno);
+                                FAIL(errmsg);
+                        }
+                } else {
+                        FAIL("GROUP unlock on never locked fd succeed\n");
+                }
+        }
+}
+
+void grouplock_file(char *name, int items)
+{
+        int fd;
+        char filename[MAX_FILENAME_LEN];
+        char errmsg[MAX_FILENAME_LEN+20];
+
+        sprintf(filename, "%s/%s", testdir, name);
+
+        if (items == 4) {
+                if ((fd = open(filename, O_RDWR | O_NONBLOCK)) == -1) {
+                        sprintf(errmsg, "open of file %s", filename);
+                        FAIL(errmsg);
+                }
+        } else if ((fd = open(filename, O_RDWR)) == -1) {
+                sprintf(errmsg, "open of file %s", filename);
+                FAIL(errmsg);
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+        switch (items) {
+        case 1:
+                grouplock_test1(filename, fd, errmsg);
+                break;
+        case 2:
+                grouplock_test2(filename, fd, errmsg);
+                break;
+        case 3:
+                grouplock_test3(filename, fd, errmsg);
+                break;
+        case 4:
+                grouplock_test4(filename, fd, errmsg);
+                break;
+        case 5:
+                grouplock_test5(filename, fd, errmsg);
+                break;
+        case 6:
+                grouplock_test6(filename, fd, errmsg);
+                break;
+        case 7:
+                grouplock_errorstest(filename, fd, errmsg);
+                break;
+        default:
+                sprintf(errmsg, "wrong test case number %d (should be <= %d)",
+                        items, LPGL_TEST_ITEMS);
+                FAIL(errmsg);
+        }
+
+        MPI_Barrier(MPI_COMM_WORLD);
+
+        if (close(fd) == -1) {
+                sprintf(errmsg, "close of file %s", filename);
+                FAIL(errmsg);
+        }
+
+}
+
+void parallel_grouplock(void)
+{
+        int i;
+
+        for (i = 1;i <= LPGL_TEST_ITEMS;++i) {
+                begin("setup");
+                create_file("parallel_grouplock", LPGL_FILEN, 0);
+                end("setup");
+
+                begin("test");
+                grouplock_file("parallel_grouplock", i);
+                end("test");
+
+                begin("cleanup");
+                remove_file("parallel_grouplock");
+                end("cleanup");
+        }
+}
+
+void usage(char *proc)
+{
+        int i;
+
+        if (rank == 0) {
+                printf("Usage: %s [-h] -d <testdir>\n", proc);
+                printf("           [-n \"13\"] [-v] [-V #] [-g]\n");
+                printf("\t-h: prints this help message\n");
+                printf("\t-d: the directory in which the tests will run\n");
+                printf("\t-n: repeat test # times\n");
+                printf("\t-v: increase the verbositly level by 1\n");
+                printf("\t-V: select a specific verbosity level\n");
+                printf("\t-g: debug mode\n");
+        }
+
+        MPI_Initialized(&i);
+        if (i) MPI_Finalize();
+        exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+        char c;
+        int i, iterations = 1;
+
+        /* Check for -h parameter before MPI_Init so the binary can be
+           called directly, without, for instance, mpirun */
+        for (i = 1; i < argc; ++i) {
+                if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
+                        usage(argv[0]);
+        }
+
+        MPI_Init(&argc, &argv);
+        MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+        MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+//        MPI_Comm_set_attr(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &tr);
+
+        /* Parse command line options */
+        while (1) {
+                c = getopt(argc, argv, "d:ghn:vV:");
+                if (c == -1)
+                        break;
+
+                switch (c) {
+                case 'd':
+                        testdir = optarg;
+                        break;
+                case 'g':
+                        debug = 1;
+                        break;
+                case 'h':
+                        usage(argv[0]);
+                        break;
+                case 'n':
+                        iterations = atoi(optarg);
+                        break;
+                case 'v':
+                        verbose += 1;
+                        break;
+                case 'V':
+                        verbose = atoi(optarg);
+                        break;
+                }
+        }
+
+        if (rank == 0)
+                printf("%s is running with %d process(es) %s\n",
+                       argv[0], size, debug ? "in DEBUG mode" : "\b\b");
+
+        if (size < MAX_GLHOST) {
+                fprintf(stderr, "Error: "
+                        "should be at least four processes to run the test!\n");
+                MPI_Abort(MPI_COMM_WORLD, 2);
+        }
+
+        if (testdir == NULL && rank == 0) {
+                fprintf(stderr, "Please specify a test directory! "
+                        "(\"%s -h\" for help)\n", argv[0]);
+                MPI_Abort(MPI_COMM_WORLD, 2);
+        }
+
+        lp_gethostname();
+
+        for (i = 0; i < iterations; ++i) {
+                if (rank == 0)
+                        printf("%s: Running test #%s(iter %d)\n",
+                               timestamp(), argv[0], i);
+
+                parallel_grouplock();
+                MPI_Barrier(MPI_COMM_WORLD);
+        }
+
+        if (rank == 0) {
+                printf("%s: All tests passed!\n", timestamp());
+        }
+        MPI_Finalize();
+        return 0;
+}
diff --git a/lustre/tests/mpi/write_append_truncate.c b/lustre/tests/mpi/write_append_truncate.c
new file mode 100644
index 0000000..473f33a
--- /dev/null
+++ b/lustre/tests/mpi/write_append_truncate.c
@@ -0,0 +1,558 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/tests/write_append_truncate.c
+ *
+ * Each loop does 3 things:
+ *   - truncate file to zero (not via ftruncate though, to test O_APPEND)
+ *   - write a "chunk" of data (should be at file offset 0 after truncate)
+ *   - on each of two threads either append or truncate-up the file
+ *
+ * If the truncate happened first, we should have a hole in the file.
+ * If the append happened first, we should have truncated the file down.
+ *
+ * WRITE_SIZE_MAX and APPEND_SIZE_MAX are large enough to cross a stripe.
+ *
+ * compile: mpicc -g -Wall -o write_append_truncate write_append_truncate.c
+ * run:     mpirun -np 2 -machlist <hostlist file> write_append_truncate <file>
+ *  or:     pdsh -w <two hosts> write_append_truncate <file>
+ *  or:     prun -n 2 [-N 2] write_append_truncate <file>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <time.h>
+#include <string.h>
+#include <unistd.h>
+#include <getopt.h>
+#include "mpi.h"
+
+#define DEFAULT_ITER    10000
+
+#define WRITE_SIZE_MAX  1234567
+#define APPEND_SIZE_MAX 1234567
+#define TRUNC_SIZE_MAX  1234567
+
+#define STATUS_FMT "WR %c %7d/%#08x, AP %c %7d/%#08x, TR@ %7d/%#08x"
+
+#define HOSTNAME_SIZE 50
+char hostname[HOSTNAME_SIZE];
+#define FNAMES_MAX 256
+
+void usage(char *prog)
+{
+        printf("usage: %s [-a append_max] [-C] [-n nloops] [-s seed]\n"
+               "\t\t[-t trunc_max] [-T] [-v] [-w write_max] <filename> ...\n", prog);
+        printf("\t-a append_max: maximum size of append, default %u bytes\n",
+               APPEND_SIZE_MAX);
+        printf("\t-C: 'classic' checks (on file 0)\n");
+        printf("\t-n nloops: count of loops to run, default %u\n",DEFAULT_ITER);
+        printf("\t-s seed: random seed to use, default {current time}\n");
+        printf("\t-t trunc_max: maximum size of truncate, default %u bytes\n",
+               TRUNC_SIZE_MAX);
+        printf("\t-T: 'classic' truncates (on file 0)\n");
+        printf("\t-w write_max: maximum size of write, default %u bytes\n",
+               WRITE_SIZE_MAX);
+        printf("\t-W: 'classic' writes (on rank 0, file 0)\n");
+        printf("\t-v: run in verbose mode (repeat for more verbosity)\n");
+        printf("\tfilename for each mountpoint of same filesystem on a node\n");
+        printf("\b%s must be run with at least 2 processes\n", prog);
+
+        MPI_Finalize();
+        exit(1);
+}
+
+/* Print process rank, loop count, message, and exit (i.e. a fatal error) */
+void rprintf(int rank, int loop, int error, const char *fmt, ...)
+__attribute__ ((format (printf, 4, 5)));
+
+void rprintf(int rank, int loop, int error, const char *fmt, ...)
+{
+        va_list       ap;
+
+        printf("r=%2u", rank);
+        if (loop >= 0)
+                printf(" l=%04u", loop);
+        if (error != 0)
+                printf(" %s", hostname);
+        printf(": ");
+
+        va_start(ap, fmt);
+
+        vprintf(fmt, ap);
+
+        if (error != 0)
+                MPI_Abort(MPI_COMM_WORLD, error);
+}
+
+int main(int argc, char *argv[])
+{
+        int n, nloops = DEFAULT_ITER;
+        int nfnames = 0, ifnames, fd;
+        int rank = -1, nproc, ret;
+        unsigned write_max = WRITE_SIZE_MAX;
+        unsigned append_max = APPEND_SIZE_MAX;
+        unsigned write_size = 0, append_size = 0, trunc_size = 0;
+        unsigned trunc_max = 0, trunc_offset = 0;
+        char *append_buf;
+        char *write_buf;
+        char *read_buf = NULL;
+        char *trunc_buf = NULL;
+        int seed = time(0);
+        int done;
+        int error;
+        int verbose = 0;
+        int classic_check = 0, classic_trunc = 0, classic_write = 0;
+        char write_char = 'A', append_char = 'a';
+        char *fnames[FNAMES_MAX], *end;
+        char *prog = "write_append_truncate";
+        int c;
+
+        error = MPI_Init(&argc, &argv);
+        if (error != MPI_SUCCESS)
+                printf("%s: MPI_Init failed: %d\n", prog, error);
+        else if (verbose > 2)
+                printf("%s: MPI_Init succeeded\n", prog);
+
+        prog = strrchr(argv[0], '/');
+        if (prog == NULL)
+                prog = argv[0];
+        else
+                prog++;
+
+        while ((c = getopt(argc, argv, "a:cCn:s:t:Tvw:W")) != -1) {
+                switch(c) {
+                case 'a':
+                        append_max = strtoul(optarg, &end, 0);
+                        if (append_max == 0 || *end) {
+                                fprintf(stderr, "%s: bad append option '%s'\n",
+                                        prog, optarg);
+                                usage(prog);
+                        }
+                        break;
+                case 'C':
+                        classic_check++;
+                        break;
+                case 'n':
+                        nloops = strtoul(optarg, &end, 0);
+                        if (nloops == 0 || *end) {
+                                fprintf(stderr, "%s: bad nloops option '%s'\n",
+                                        prog, optarg);
+                                usage(prog);
+                        }
+                        break;
+                case 's':
+                        seed = strtoul(optarg, &end, 0);
+                        if (*end) {
+                                fprintf(stderr, "%s: bad seed option '%s'\n",
+                                        prog, optarg);
+                                usage(prog);
+                        }
+                        break;
+                case 't':
+                        trunc_max = strtoul(optarg, &end, 0);
+                        if (*end) {
+                                fprintf(stderr,"%s: bad truncate option '%s'\n",
+                                        prog, optarg);
+                                usage(prog);
+                        }
+                        break;
+                case 'T':
+                        classic_trunc++;
+                        break;
+                case 'v':
+                        verbose++;
+                        break;
+                case 'w':
+                        write_max = strtoul(optarg, &end, 0);
+                        if (write_max == 0 || *end) {
+                                fprintf(stderr, "%s: bad write option '%s'\n",
+                                        prog, optarg);
+                                usage(prog);
+                        }
+                        break;
+                case 'W':
+                        classic_write++;
+                        break;
+                default:
+                        fprintf(stderr, "%s: unknown option '%c'\n", prog, c);
+                        usage(prog);
+                }
+        }
+
+        srand(seed);
+
+        if (argc == optind) {
+                fprintf(stderr, "%s: missing filename argument\n", prog);
+                usage(prog);
+        }
+
+        if (argc > optind + FNAMES_MAX) {
+                fprintf(stderr, "%s: too many extra options\n", prog);
+                usage(prog);
+        }
+
+        while (optind < argc)
+                fnames[nfnames++] = argv[optind++];
+
+        error = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+        if (verbose > 2 || error != MPI_SUCCESS)
+                rprintf(rank, -1, error != MPI_SUCCESS, "MPI_Comm_rank: %d\n",
+                        error);
+
+        error = MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+        if (verbose > 2 || error != MPI_SUCCESS)
+                rprintf(rank, -1, error != MPI_SUCCESS, "MPI_Comm_size: %d\n",
+                        error);
+
+        if (nproc < 2)
+                rprintf(rank, -1, 1, "%s: must run with at least 2 processes\n",
+                        prog);
+
+        append_buf = malloc(append_max);
+        if (append_buf == NULL)
+                rprintf(rank, -1, 1,"%s: error allocating append_buf %u\n",
+                        prog, append_max);
+
+        write_buf = malloc(write_max);
+        if (write_buf == NULL)
+                rprintf(rank, -1, 1, "%s: error allocating write_buf %u\n",
+                        prog, write_max);
+
+        if (gethostname(hostname, HOSTNAME_SIZE) < 0)
+                rprintf(rank, -1, 1, "%s: gethostname failed: %s\n",
+                        prog, strerror(errno));
+
+        if (rank == 0) {
+                int max_size = write_max + (trunc_max ?: append_max)+append_max;
+
+                fd = open(fnames[0], O_WRONLY|O_CREAT|O_TRUNC, 0666);
+                rprintf(rank,-1, fd<0, "create %s, max size: %u, seed %u: %s\n",
+                        fnames[0], max_size, seed, strerror(errno));
+                close(fd);
+
+                trunc_buf = calloc(1, trunc_max ?: append_max);
+                if (trunc_buf == NULL)
+                        rprintf(rank,-1,1,"%s: error allocating trunc_buf %u\n",
+                                prog, trunc_max ?: append_max);
+
+                /* initial write + truncate up + append */
+                read_buf = malloc(max_size);
+                if (read_buf == NULL)
+                        rprintf(rank,-1,1,"%s: error allocating read_buf %u\n",
+                                prog, max_size);
+        }
+
+        error = MPI_Barrier(MPI_COMM_WORLD);
+        if (verbose > 2 || error != MPI_SUCCESS)
+                rprintf(rank, -1, error != MPI_SUCCESS,
+                        "prep MPI_Barrier: %d\n", error);
+
+        ifnames = rank % nfnames;
+        fd = open(fnames[ifnames], O_RDWR | O_APPEND);
+        if (verbose || fd < 0)
+                rprintf(rank, -1, errno, "open '%s' (%u): %s\n",
+                        fnames[ifnames], ifnames, strerror(errno));
+
+        for (n = 0; n < nloops; n++) {
+                /* Initialized only to quiet stupid GCC warnings */
+                unsigned write_rank = 0, append_rank = n, trunc_rank = n + 1;
+                unsigned mpi_shared_vars[6];
+
+                /* reset the environment */
+                write_char = 'A' + (n % 26);
+                append_char = 'a' + (n % 26);
+
+                if (rank == 0) {
+                        write_size = (rand() % (write_max - 1)) + 1;
+                        append_size = (rand() % (append_max - 1)) + 1;
+                        trunc_size = (rand() % ((trunc_max?: append_size)-1))+1;
+                        trunc_offset = write_size + trunc_size;
+
+                        if (verbose || n % 1000 == 0)
+                                rprintf(rank, n, 0, STATUS_FMT"\n",
+                                        write_char, write_size, write_size,
+                                        append_char, append_size, append_size,
+                                        trunc_offset, trunc_offset);
+
+                        write_rank = (classic_write ? 0 : rand()) % nproc;
+                        do {
+                                append_rank = (classic_write ? n : rand()) %
+                                                                nproc;
+                                /* We can't allow the append rank be the same
+                                 * as the classic_trunc trunc_rank, or we will
+                                 * spin here forever. */
+                        } while (append_rank == (n + 1) % nproc);
+                        do {
+                                trunc_rank = (classic_trunc? (n + 1) : rand()) %
+                                                                nproc;
+                        } while (trunc_rank == append_rank);
+
+                        mpi_shared_vars[0] = write_size;
+                        mpi_shared_vars[1] = append_size;
+                        mpi_shared_vars[2] = trunc_size;
+                        mpi_shared_vars[3] = write_rank;
+                        mpi_shared_vars[4] = append_rank;
+                        mpi_shared_vars[5] = trunc_rank;
+                }
+
+                error = MPI_Bcast(&mpi_shared_vars, 6,
+                                  MPI_INT, 0, MPI_COMM_WORLD);
+                if (verbose > 2 || error != MPI_SUCCESS)
+                        rprintf(rank, n, error != MPI_SUCCESS,
+                                "MPI_Bcast mpi_shared_vars"
+                                "[%u, %u, %u, %u, %u, %u]: %d\n",
+                                mpi_shared_vars[0], mpi_shared_vars[1],
+                                mpi_shared_vars[2], mpi_shared_vars[3],
+                                mpi_shared_vars[4], mpi_shared_vars[5], error);
+
+                if (rank != 0) {
+                        write_size  = mpi_shared_vars[0];
+                        append_size = mpi_shared_vars[1];
+                        trunc_size  = mpi_shared_vars[2];
+                        write_rank  = mpi_shared_vars[3];
+                        append_rank = mpi_shared_vars[4];
+                        trunc_rank  = mpi_shared_vars[5];
+
+                        trunc_offset = write_size + trunc_size;
+                }
+
+                if (rank == write_rank || rank == 0)
+                        memset(write_buf, write_char, write_max);
+
+                if (rank == write_rank) {
+                        ifnames = (classic_write ? 0 : rand()) % nfnames;
+                        ret = truncate(fnames[ifnames], 0);
+                        if (verbose > 1 || ret != 0)
+                                rprintf(rank, n, ret,
+                                        "initial truncate %s (%u) @ 0: %s\n",
+                                        fnames[ifnames], ifnames,
+                                        strerror(errno));
+
+                        done = 0;
+                        do {
+                                ret = write(fd, write_buf+done,write_size-done);
+                                if (verbose > 1 || ret <= 0) {
+                                        rprintf(rank, n, ret <= 0,
+                                                "write %d/%d @ %d: %s\n",
+                                                ret + done, write_size, done,
+                                                strerror(errno));
+                                        if (ret <= 0)
+                                                break;
+                                }
+                                done += ret;
+                        } while (done != write_size);
+                }
+
+                if (rank == append_rank || rank == 0)
+                        memset(append_buf, append_char, append_size);
+
+                error = MPI_Barrier(MPI_COMM_WORLD);
+                if (verbose > 2 || error != MPI_SUCCESS)
+                        rprintf(rank, n, error != MPI_SUCCESS,
+                                "start MPI_Barrier: %d\n", error);
+
+                /* Do the race */
+                if (rank == append_rank) {
+                        done = 0;
+                        do {
+                                ret = write(fd, append_buf + done,
+                                            append_size - done);
+                                if (ret < 0) {
+                                        rprintf(rank, n, ret < 0,
+                                                "append %u/%u: %s\n",
+                                                ret + done, append_size,
+                                                strerror(errno));
+                                        break;
+                                } else if (verbose > 1 || ret != append_size) {
+                                        rprintf(rank, n, ret != append_size,
+                                                "append %u/%u\n",
+                                                ret + done, append_size);
+                                }
+                                done += ret;
+                        } while (done != append_size);
+                } else if (rank == trunc_rank) {
+                        /* XXX: truncating the same file descriptor as the
+                         *      append on a single node causes this test
+                         *      to fail currently (2009-02-01). */
+                        ifnames = (classic_trunc ? rank : rand()) % nfnames;
+                        ret = truncate(fnames[ifnames], trunc_offset);
+                        if (verbose > 1 || ret != 0)
+                                rprintf(rank, n, ret,
+                                        "truncate %s (%u) @ %u: %s\n",
+                                        fnames[ifnames], ifnames,
+                                        trunc_offset, strerror(errno));
+                }
+
+                error = MPI_Barrier(MPI_COMM_WORLD);
+                if (verbose > 2 || error != MPI_SUCCESS)
+                        rprintf(rank, n, error != MPI_SUCCESS,
+                                "end MPI_Barrier: %d\n", error);
+
+                error = 0;
+
+                /* Check the result */
+                if (rank == 0) {
+                        char *tmp_buf;
+                        struct stat st = { 0 };
+
+                        ifnames = classic_check ? 0 : (rand() % nfnames);
+                        ret = stat(fnames[ifnames], &st);
+                        if (verbose > 1 || ret != 0)
+                                rprintf(rank, n, ret,
+                                        "stat %s (%u) size %llu: %s\n",
+                                        fnames[ifnames], ifnames,
+                                        (long long)st.st_size, strerror(errno));
+
+                        ret = lseek(fd, 0, SEEK_SET);
+                        if (ret != 0)
+                                rprintf(rank, n, ret, "lseek 0: %s\n",
+                                        strerror(errno));
+
+                        done = 0;
+                        do {
+                                ret = read(fd, read_buf+done, st.st_size-done);
+                                if (verbose > 1 || ret <= 0) {
+                                        rprintf(rank, n, ret <= 0,
+                                                "read %d/%llu @ %u: %s\n",
+                                                ret, (long long)st.st_size-done,
+                                                done, ret != 0 ?
+                                                strerror(errno) : "short read");
+                                }
+                                done += ret;
+                        } while (done != st.st_size);
+
+                        if (memcmp(read_buf, write_buf, write_size)) {
+                                rprintf(rank, n, 0, "WRITE bad "
+                                        "[0-%d]/[0-%#x] != %c\n",
+                                        write_size - 1, write_size - 1,
+                                        write_char);
+                                error = 1;
+                        }
+
+                        tmp_buf = read_buf + write_size;
+
+                        if (st.st_size == trunc_offset) {
+                                /* Check case 1: first append then truncate */
+                                int tmp_size, tmp_offset;
+
+                                tmp_size = trunc_size < append_size ?
+                                                trunc_size : append_size;
+                                tmp_offset = write_size + tmp_size;
+
+                                if (memcmp(tmp_buf, append_buf, tmp_size)) {
+                                        rprintf(rank, n, 0,"trunc-after-APPEND "
+                                                "bad [%d-%d]/[%#x-%#x] != %c\n",
+                                                write_size, tmp_offset - 1,
+                                                write_size, tmp_offset - 1,
+                                                append_char);
+                                        error = 1;
+                                } else if (trunc_size > append_size &&
+                                           memcmp(tmp_buf+append_size,trunc_buf,
+                                                  trunc_size - append_size)) {
+                                        rprintf(rank, n, 0,"TRUNC-after-append "
+                                                "bad [%d-%d]/[%#x-%#x] != 0\n",
+                                                tmp_offset, trunc_offset - 1,
+                                                tmp_offset, trunc_offset - 1);
+                                        error = 1;
+                                }
+                        } else {
+                                int expected_size = trunc_offset + append_size;
+                                /* Check case 2: first truncate then append */
+                                if (st.st_size != expected_size) {
+                                        rprintf(rank, n, 0,"APPEND-after-trunc "
+                                                "bad file size %llu != %u\n",
+                                                (long long)st.st_size,
+                                                expected_size);
+                                        error = 1;
+                                }
+
+                                if (memcmp(tmp_buf, trunc_buf, trunc_size)) {
+                                        rprintf(rank, n, 0,"append-after-TRUNC "
+                                                "bad [%d-%d]/[%#x-%#x] != 0\n",
+                                                write_size, trunc_offset - 1,
+                                                write_size, trunc_offset - 1);
+                                        error = 1;
+                                } else if (memcmp(read_buf + trunc_offset,
+                                                  append_buf, append_size)) {
+                                        rprintf(rank, n, 0,"APPEND-after-trunc "
+                                                "bad [%d-%d]/[%#x-%#x] != %c\n",
+                                                trunc_offset, expected_size - 1,
+                                                trunc_offset, expected_size - 1,
+                                                append_char);
+                                        error = 1;
+                                }
+                        }
+
+                        if (error == 1) {
+                                char command[4096];
+                                int rc;
+
+                                rprintf(rank, n, 0, STATUS_FMT"\n",
+                                        write_char, write_size, write_size,
+                                        append_char, append_size, append_size,
+                                        trunc_offset, trunc_offset);
+
+                                sprintf(command, "od -Ax -a %s", fnames[0]);
+                                rc = system(command);
+                                MPI_Abort(MPI_COMM_WORLD, 1);
+                        }
+                }
+        }
+
+        if (rank == 0 || verbose)
+                printf("r=%2u n=%4u: "STATUS_FMT"\nPASS\n", rank, n - 1,
+                       write_char, write_size, write_size,
+                       append_char, append_size, append_size,
+                       trunc_offset, trunc_offset);
+
+        close(fd);
+
+        if (rank == 0) {
+                ifnames = rand() % nfnames;
+                ret = unlink(fnames[ifnames]);
+                if (ret != 0)
+                        printf("%s: unlink %s failed: %s\n",
+                               prog, fnames[ifnames], strerror(errno));
+        }
+
+        MPI_Finalize();
+        return 0;
+}
diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c
index b5f745d..a8de99b 100755
--- a/lustre/tests/multiop.c
+++ b/lustre/tests/multiop.c
@@ -44,9 +44,11 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <sys/vfs.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <semaphore.h>
 #include <lustre/liblustreapi.h>
 
 #define T1 "write data before unlink\n"
@@ -54,6 +56,7 @@
 char msg[] = "yabba dabba doo, I'm coming for you, I live in a shoe, I don't know what to do.\n'Bigger, bigger,and bigger yet!' cried the Creator.  'You are not yet substantial enough for my boundless intents!'  And ever greater and greater the object became, until all was lost 'neath its momentus bulk.\n";
 char *buf, *buf_align;
 int bufsize = 0;
+sem_t sem;
 #define ALIGN 65535
 
 char usage[] = 
@@ -63,6 +66,7 @@ char usage[] =
 "        C[num] create with optional stripes\n"
 "        d  mkdir\n"
 "        D  open(O_DIRECTORY)\n"
+"        f  statfs\n"
 "        L  link\n"
 "        l  symlink\n"
 "        m  mknod\n"
@@ -85,10 +89,19 @@ char usage[] =
 "        z[num] seek [optional position, default 0]\n"
 "        _  wait for signal\n";
 
-static int usr1_received;
 void usr1_handler(int unused)
 {
-        usr1_received = 1;
+        int saved_errno = errno;
+
+        /*
+         * signal(7): POSIX.1-2004 ...requires an implementation to guarantee
+         * that the following functions can be safely called inside a signal
+         * handler:
+         *            sem_post()
+         */
+        sem_post(&sem);
+
+        errno = saved_errno;
 }
 
 static const char *
@@ -173,6 +186,7 @@ int main(int argc, char **argv)
         char *fname, *commands;
         const char *newfile;
         struct stat st;
+        struct statfs stfs;
         size_t mmap_len = 0, i;
         unsigned char *mmap_ptr = NULL, junk = 0;
         int rc, len, fd = -1;
@@ -185,22 +199,21 @@ int main(int argc, char **argv)
                 exit(1);
         }
 
-        signal(SIGUSR1, usr1_handler);
-
+        memset(&st, 0, sizeof(st));
+        sem_init(&sem, 0, 0);
+        /* use sigaction instead of signal to avoid SA_ONESHOT semantics */
+        sigaction(SIGUSR1, &(const struct sigaction){.sa_handler = &usr1_handler},
+                  NULL);
         fname = argv[1];
 
         for (commands = argv[2]; *commands; commands++) {
                 switch (*commands) {
                 case '_':
-                        if (usr1_received == 0) {
-                                if (verbose) {
-                                        printf("PAUSING\n");
-                                        fflush(stdout);
-                                }
-                                pause();
+                        if (verbose) {
+                                printf("PAUSING\n");
+                                fflush(stdout);
                         }
-                        usr1_received = 0;
-                        signal(SIGUSR1, usr1_handler);
+                        while (sem_wait(&sem) == -1 && errno == EINTR);
                         break;
                 case 'c':
                         if (close(fd) == -1) {
@@ -235,6 +248,13 @@ int main(int argc, char **argv)
                                 exit(save_errno);
                         }
                         break;
+                case 'f':
+                        if (statfs(fname, &stfs) == -1) {
+                                save_errno = errno;
+                                perror("statfs()");
+                                exit(save_errno);
+                        }
+                        break;
                 case 'l':
                         newfile = POP_ARG();
                         if (!newfile)
@@ -263,6 +283,11 @@ int main(int argc, char **argv)
                         }
                         break;
                 case 'M':
+                        if (st.st_size == 0) {
+                                fprintf(stderr, "mmap without preceeding stat, or on"
+                                        " zero length file.\n");
+                                exit(-1);
+                        }
                         mmap_len = st.st_size;
                         mmap_ptr = mmap(NULL, mmap_len, PROT_WRITE | PROT_READ,
                                         MAP_SHARED, fd, 0);
@@ -293,7 +318,10 @@ int main(int argc, char **argv)
                 case 'o':
                         len = get_flags(commands+1, &flags);
                         commands += len;
-                        fd = open(fname, flags);
+                        if (flags & O_CREAT)
+                                fd = open(fname, flags, 0666);
+                        else
+                                fd = open(fname, flags);
                         if (fd == -1) {
                                 save_errno = errno;
                                 perror("open");
diff --git a/lustre/tests/o_directory.c b/lustre/tests/o_directory.c
deleted file mode 100644
index cb7f913..0000000
--- a/lustre/tests/o_directory.c
+++ /dev/null
@@ -1,85 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-/* for O_DIRECTORY */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-int main(int argc, char **argv)
-{
-        int fd, rc;
-
-        if (argc != 2) {
-                printf("Usage: %s <filename>\n", argv[0]);
-                exit(1);
-        }
-
-        fd = open(argv[1], O_RDONLY | O_CREAT, 0600);
-        if (fd == -1) {
-                printf("Error opening %s for create: %s\n", argv[1],
-                       strerror(errno));
-                exit(1);
-        }
-        rc = close(fd);
-        if (rc < 0) {
-                printf("Error closing %s: %s\n", argv[1], strerror(errno));
-                exit(1);
-        }
-
-        fd = open(argv[1], O_DIRECTORY);
-        if (fd >= 0) {
-                printf("opening %s as directory should have returned an "
-                       "error!\n", argv[1]);
-                exit(1);
-        }
-        if (errno != ENOTDIR) {
-                printf("opening %s as directory, expected -ENOTDIR and got "
-                       "%s\n", argv[1], strerror(errno));
-                exit(1);
-        }
-
-        return 0;
-}
diff --git a/lustre/tests/openclose.c b/lustre/tests/openclose.c
deleted file mode 100644
index 66c05e1..0000000
--- a/lustre/tests/openclose.c
+++ /dev/null
@@ -1,177 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-/* for O_DIRECT */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <sys/ioctl.h>
-
-#include <lustre/lustre_user.h>
-#ifndef O_DIRECT
-#define O_DIRECT 0
-#endif
-
-int main(int argc, char *argv[])
-{
-        char filename[1024];
-        unsigned long count, i;
-        int thread = 0;
-        int threads = 0;
-        int rc = 0;
-        int fd, ioctl_flags = 0;
-
-        if (argc < 3 || argc > 4) {
-                fprintf(stderr, "usage: %s <filename> <iterations> [threads]\n",
-                        argv[0]);
-                exit(1);
-        }
-
-        count = strtoul(argv[2], NULL, 0);
-        if (argc == 4)
-                threads = strtoul(argv[3], NULL, 0);
-
-        for (i = 1; i <= threads; i++) {
-                rc = fork();
-                if (rc < 0) {
-                        fprintf(stderr, "error: %s: #%ld - %s\n", argv[0], i,
-                                strerror(rc = errno));
-                        break;
-                } else if (rc == 0) {
-                        thread = i;
-                        argv[2] = "--device";
-                        break;
-                } else
-                        printf("%s: thread #%ld (PID %d) started\n",
-                               argv[0], i, rc);
-                rc = 0;
-        }
-
-        if (threads && thread == 0) {        /* parent process */
-                int live_threads = threads;
-
-                while (live_threads > 0) {
-                        int status;
-                        pid_t ret;
-
-                        ret = waitpid(0, &status, 0);
-                        if (ret == 0)
-                                continue;
-
-                        if (ret < 0) {
-                                if (!rc)
-                                        rc = errno;
-                                fprintf(stderr, "error: %s: wait - %s\n",
-                                        argv[0], strerror(rc));
-                        } else {
-                                /*
-                                 * This is a hack.  We _should_ be able to use
-                                 * WIFEXITED(status) to see if there was an
-                                 * error, but it appears to be broken and it
-                                 * always returns 1 (OK).  See wait(2).
-                                 */
-                                int err = WEXITSTATUS(status);
-                                if (err || WIFSIGNALED(status))
-                                        fprintf(stderr,
-                                                "%s: PID %d had rc=%d\n",
-                                                argv[0], ret, err);
-                                if (!rc)
-                                        rc = err;
-                        }
-                        live_threads--;
-                }
-        } else {
-                if (threads)
-                        sprintf(filename, "%s-%d", argv[1], thread);
-                else
-                        strcpy(filename, argv[1]);
-
-                fd = open(filename, O_RDWR|O_CREAT, 0644);
-                if (fd < 0) {
-                        rc = errno;
-                        fprintf(stderr, "open(%s, O_CREAT): %s\n", filename,
-                                strerror(rc));
-                        exit(rc);
-                }
-                if (close(fd) < 0) {
-                        rc = errno;
-                        fprintf(stderr, "close(): %s\n", strerror(rc));
-                        goto unlink;
-                }
-
-                for (i = 0; i < count; i++) {
-                        fd = open(filename, O_RDWR|O_LARGEFILE|O_DIRECT);
-                        if (fd < 0) {
-                                rc = errno;
-                                fprintf(stderr, "open(%s, O_RDWR): %s\n",
-                                        filename, strerror(rc));
-                                break;
-                        }
-                        if (ioctl(fd, LL_IOC_SETFLAGS, &ioctl_flags) < 0 &&
-                            errno != ENOTTY) {
-                                rc = errno;
-                                fprintf(stderr, "ioctl(): %s\n", strerror(rc));
-                                break;
-                        }
-                        if (close(fd) < 0) {
-                                rc = errno;
-                                fprintf(stderr, "close(): %s\n", strerror(rc));
-                                break;
-                        }
-                }
-        unlink:
-                if (unlink(filename) < 0) {
-                        rc = errno;
-                        fprintf(stderr, "unlink(%s): %s\n", filename,
-                                strerror(rc));
-                }
-                if (threads)
-                        printf("Thread %d done: rc = %d\n", thread, rc);
-                else
-                        printf("Done: rc = %d\n", rc);
-        }
-        return rc;
-}
diff --git a/lustre/tests/openfile.c b/lustre/tests/openfile.c
index 505dc89..66b48c8 100644
--- a/lustre/tests/openfile.c
+++ b/lustre/tests/openfile.c
@@ -92,13 +92,13 @@ int main(int argc, char** argv)
         int    fd;
         int    flags = 0;
         mode_t mode = 0644;
-        char*  fname = NULL;
+        char  *fname = NULL;
         int    mode_set = 0;
         int    flag_set = 0;
         int    c;
         int    save_errno = 0;
         int    print_usage = 0;
-        char*  cloned_flags = NULL;
+        char  *cloned_flags = NULL;
 
         if (argc == 1)
                 Usage_and_abort();
@@ -123,9 +123,10 @@ int main(int argc, char** argv)
                                 printf("flags = %d\n",flags);
 #endif
                                 break;
-                        } else 
+                        } else {
                                 flags = 0;
-                        
+                        }
+
                         for (tmp = strtok(cloned_flags, ":|"); tmp;
                              tmp = strtok(NULL, ":|")) {
                                 int i = 0;
diff --git a/lustre/tests/openme.c b/lustre/tests/openme.c
deleted file mode 100644
index d3f7b24..0000000
--- a/lustre/tests/openme.c
+++ /dev/null
@@ -1,59 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-int main(int argc, char **argv)
-{
-        int fd; 
-
-        if (argc != 2) { 
-                printf("Usage openme <filename>\n"); 
-                exit(1);
-        }
-
-        fd = open(argv[1], O_RDONLY | O_CREAT, 0600);
-        if (fd == -1) { 
-                printf("Error opening %s\n", argv[1]);
-                exit(1);
-        }
-
-        sleep(10000000); 
-        return 0;
-}
diff --git a/lustre/tests/parallel-scale.sh b/lustre/tests/parallel-scale.sh
index 246fb5e..da4318c 100644
--- a/lustre/tests/parallel-scale.sh
+++ b/lustre/tests/parallel-scale.sh
@@ -2,8 +2,6 @@
 #
 #set -vx
 
-set -e
-
 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
@@ -12,8 +10,7 @@ init_test_env $@
 #
 # compilbench
 #
-# Boulder cluster compilebench default location
-cbench_DIR=${cbench_DIR:-/testsuite/tests/$(arch)/compilebench}
+cbench_DIR=${cbench_DIR:-""}
 cbench_IDIRS=${cbench_IDIRS:-10}
 cbench_RUNS=${cbench_RUNS:-10}	# FIXME: wiki page requirements is 30, do we really need 30 ?
 
@@ -25,8 +22,7 @@ fi
 #
 # metabench
 #
-# Boulder cluster metabench default location
-METABENCH=${METABENCH:-/testsuite/tests/$(arch)/METABENCH/src/metabench}
+METABENCH=${METABENCH:-$(which metabench 2> /dev/null || true)}
 mbench_NFILES=${mbench_NFILES:-30400}
 [ "$SLOW" = "no" ] && mbench_NFILES=10000
 MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
@@ -36,8 +32,7 @@ mbench_THREADS=${mbench_THREADS:-4}
 #
 # simul
 #
-# Boulder cluster default location
-SIMUL=${SIMUL:-/testsuite/tests/$(arch)/simul/simul}
+SIMUL=${SIMUL:=$(which simul 2> /dev/null || true)}
 # threads per client
 simul_THREADS=${simul_THREADS:-2}
 simul_REP=${simul_REP:-20}
@@ -46,16 +41,14 @@ simul_REP=${simul_REP:-20}
 #
 # connectathon
 #
-# Boulder cluster default location
-cnt_DIR=${cnt_DIR:-/testsuite/tests/$(arch)/connectathon}
+cnt_DIR=${cnt_DIR:-""}
 cnt_NRUN=${cnt_NRUN:-10}
 [ "$SLOW" = "no" ] && cnt_NRUN=2
 
 #
 # cascading rw
 #
-# Boulder cluster default location
-CASC_RW=${CASC_RW:-/testsuite/tests/$(arch)/parallel/cascading_rw}
+CASC_RW=${CASC_RW:-$(which cascading_rw 2> /dev/null || true)}
 # threads per client
 casc_THREADS=${casc_THREADS:-2}
 casc_REP=${casc_REP:-300}
@@ -64,8 +57,7 @@ casc_REP=${casc_REP:-300}
 #
 # IOR
 #
-# Boulder cluster default location
-IOR=${IOR:-/testsuite/tests/$(arch)/IOR/src/C/IOR}
+IOR=${IOR:-$(which IOR 2> /dev/null || true)}
 # threads per client
 ior_THREADS=${ior_THREADS:-2}
 ior_blockSize=${ior_blockSize:-6}	# Gb
@@ -83,8 +75,7 @@ write_REP=${write_REP:-10000}
 #
 # write_disjoint
 #
-# Boulder cluster default location
-WRITE_DISJOINT=${WRITE_DISJOINT:-/testsuite/tests/x86_64/lustre/lustre/tests/write_disjoint}
+WRITE_DISJOINT=${WRITE_DISJOINT:-$(which write_disjoint 2> /dev/null || true)}
 # threads per client
 wdisjoint_THREADS=${wdisjoint_THREADS:-4}
 wdisjoint_REP=${wdisjoint_REP:-10000}
@@ -116,8 +107,8 @@ print_opts () {
 test_compilebench() {
     print_opts cbench_DIR cbench_IDIRS cbench_RUNS
 
-    [ -d $cbench_DIR ] || \
-        { skip "No compilebench found" && return; }
+    [ x$cbench_DIR = x ] &&
+        { skip "compilebench not found" && return; }
 
     [ -e $cbench_DIR/compilebench ] || \
         { skip "No compilebench build" && return; }
@@ -154,7 +145,7 @@ test_compilebench() {
 run_test compilebench "compilebench"
 
 test_metabench() {
-    [ -e $METABENCH ] || \
+    [ x$METABENCH = x ] &&
         { skip "metabench not found" && return; }
 
     local clients=$CLIENTS
@@ -191,7 +182,7 @@ test_metabench() {
 run_test metabench "metabench"
 
 test_simul() {
-    [ -e $SIMUL ] || \
+    [ x$SIMUL = x ] &&
         { skip "simul not found" && return; }
 
     local clients=$CLIENTS
@@ -231,8 +222,8 @@ run_test simul "simul"
 test_connectathon() {
     print_opts cnt_DIR cnt_NRUN
 
-    [ -d $cnt_DIR ] || \
-        { skip "No connectathon dir found" && return; }
+    [ x$cnt_DIR = x ] &&
+        { skip "connectathon dir not found" && return; }
 
     [ -e $cnt_DIR/runtests ] || \
         { skip "No connectathon runtests found" && return; }
@@ -264,7 +255,7 @@ test_connectathon() {
 run_test connectathon "connectathon"
 
 test_ior() {
-    [ -e $IOR ] || \
+    [ x$IOR = x ] &&
         { skip "IOR not found" && return; }
 
     local clients=$CLIENTS
@@ -315,7 +306,7 @@ test_ior() {
 run_test ior "ior"
  
 test_cascading_rw() {
-    [ -e $CASC_RW ] || \
+    [ x$CASC_RW = x ] &&
         { skip "cascading_rw not found" && return; }
 
     local clients=$CLIENTS
@@ -394,7 +385,7 @@ test_write_append_truncate() {
 run_test write_append_truncate "write_append_truncate"
 
 test_write_disjoint() {
-    [ -e $WRITE_DISJOINT ] || \
+    [ x$WRITE_DISJOINT = x ] &&
         { skip "write_disjoint not found" && return; }
 
     local clients=$CLIENTS
diff --git a/lustre/tests/parallel_grouplock.c b/lustre/tests/parallel_grouplock.c
deleted file mode 100644
index d88033f..0000000
--- a/lustre/tests/parallel_grouplock.c
+++ /dev/null
@@ -1,912 +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  2008 Sun Microsystems, Inc. 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.
- *
- * lustre/tests/parallel_grouplock.c
- *
- * Author: You Feng <youfeng at clusterfs.com>
- */
-
-#include <mpi.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <time.h>
-#include <errno.h>
-#include <lustre/lustre_user.h>
-#include <lustre/tests/lp_utils.h>
-
-#define LPGL_FILEN 700000
-#define LPGL_TEST_ITEMS 7
-
-#define MAX_GLHOST 4
-
-/* waiting time in 0.1 s */
-#define MAX_WAITING_TIME 20
-int rank = 0;
-int size = 0;
-
-char *testdir = NULL;
-
-/*
- * process1 attempts CW(gid=1) -- granted immediately
- * process2 attempts PR -- blocked, goes on waiting list
- * process3 attempts CW(gid=1) -> should be granted, but may go on
- *                                the waiting list
- */
-void grouplock_test1(char *filename, int fd, char *errmsg)
-{
-        int rc, count, gid = 1;
-        char buf[LPGL_FILEN];
-        char zeros[LPGL_FILEN];
-        MPI_Request req1, req2;
-        int temp1, temp2;
-
-        if (rank == 0) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-        if (rank == 1) {
-                memset(zeros, 0x0, sizeof(zeros));
-                lseek(fd, 0, SEEK_SET);
-
-                MPI_Send(&gid, 1, MPI_INT, 2, 1, MPI_COMM_WORLD);
-                count = read(fd, buf, sizeof(buf));
-                if (count != sizeof(buf)) {
-                        if (count > 0)
-                                dump_diff(zeros, buf, count, 0);
-                        sprintf(errmsg, "read of file %s return %d",
-                                filename, count);
-                        FAIL(errmsg);
-                }
-                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 2) {
-                int temp;
-
-                /* Wait for reading task to progress, this is probably somewhat
-                   racey, though, may be adding usleep here would make things
-                   better here. */
-                usleep(100);
-                MPI_Recv(&temp, 1, MPI_INT, 1, 1, MPI_COMM_WORLD,
-                         MPI_STATUS_IGNORE);
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1, flag2;
-
-                /* reading task will tell us when it completes */
-                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
-                /* 2nd locking task will tell us when it completes */
-                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
-
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("2nd locking task is not progressing\n");
-                        }
-                        usleep(100);
-                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                        if (flag1) {
-                                FAIL("PR task progressed even though GROUP lock"
-                                     " is held\n");
-                        }
-                } while (!flag2);
-        }
-
-        /* Now we need to release the lock */
-
-        if (rank == 0 || rank == 2) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1;
-
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("reading task is not progressing even "
-                                     "though GROUP lock was released\n");
-                                break;
-                        }
-                        usleep(100);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                } while (!flag1);
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-}
-
-/*
- * process1 attempts CW(gid=1) -- granted immediately
- * process2 attempts CW(gid=2) -- blocked
- * process3 attempts PR -- blocked
- * process4 attempts CW(gid=2) -- blocked
- * process1 releases CW(gid=1) -- this allows process2's CW lock to be granted
-                                  process3 remains blocked
- */
-void grouplock_test2(char *filename, int fd, char *errmsg)
-{
-        int rc, count, gid = 1;
-        char buf[LPGL_FILEN];
-        char zeros[LPGL_FILEN];
-        MPI_Request req1, req2, req3;
-        int temp1, temp2, temp3;
-
-        if (rank == 0) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-        if (rank == 1 || rank == 3) {
-                gid = 2;
-                if (rank == 3) {
-                        MPI_Recv(&temp1, 1, MPI_INT, 2, 1, MPI_COMM_WORLD,
-                                 MPI_STATUS_IGNORE);
-                        usleep(100);
-                }
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 2) {
-                memset(zeros, 0x0, sizeof(zeros));
-                lseek(fd, 0, SEEK_SET);
-
-                MPI_Send(&gid, 1, MPI_INT, 3, 1, MPI_COMM_WORLD);
-                count = read(fd, buf, sizeof(buf));
-                if (count != sizeof(buf)) {
-                        if (count > 0)
-                                dump_diff(zeros, buf, count, 0);
-                        sprintf(errmsg, "read of file %s return %d",
-                                filename, count);
-                        FAIL(errmsg);
-                }
-                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1, flag2, flag3;
-
-                /* 2nd locking task will tell us when it completes */
-                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
-                /* 3nd locking task will tell us when it completes */
-                MPI_Irecv(&temp2, 1, MPI_INT, 3, 1, MPI_COMM_WORLD, &req2);
-                /* reading task will tell us when it completes */
-                MPI_Irecv(&temp3, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req3);
-
-                do {
-                        iter--;
-                        usleep(100);
-                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                        MPI_Test(&req3, &flag3, MPI_STATUS_IGNORE);
-                        if (flag3) {
-                                FAIL("PR task progressed even though GROUP lock"
-                                     " is held\n");
-                        }
-                        if (flag1 || flag2) {
-                                FAIL("GROUP (gid=2) task progressed even though"
-                                     " GROUP (gid=1) lock is held\n");
-                        }
-
-                } while (iter);
-
-                /* Now let's release first lock */
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-                iter = MAX_WAITING_TIME;
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("GROUP(gid=2) tasks are not progressing\n");
-                        }
-                        usleep(100);
-                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                        MPI_Test(&req3, &flag3, MPI_STATUS_IGNORE);
-                        if (flag3) {
-                                fprintf(stderr, "task1 %d, task3 %d\n", flag1,
-                                        flag2);
-                                FAIL("PR task progressed even though GROUP lock"
-                                     " was on the queue task\n");
-                        }
-                } while (!(flag1 && flag2));
-                MPI_Send(&gid, 1, MPI_INT, 1, 1, MPI_COMM_WORLD);
-                MPI_Send(&gid, 1, MPI_INT, 3, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 1 || rank == 3) {
-                /* Do not release the locks until task 0 is ready to watch
-                   for reading task only */
-                MPI_Recv(&temp1, 1, MPI_INT, 0, 1, MPI_COMM_WORLD,
-                         MPI_STATUS_IGNORE);
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag3;
-
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("reading task is not progressing even "
-                                     "though GROUP locks are released\n");
-                                break;
-                        }
-                        usleep(100);
-                        MPI_Test(&req3, &flag3, MPI_STATUS_IGNORE);
-                } while (!flag3);
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-}
-
-/*
- * process1 attempts CW(gid=1) -- granted
- * process2 attempts PR -- blocked
- * process3 attempts CW(gid=1) -> should be granted
- * process3 releases CW(gid=1)
- *   process2 should remain blocked
- * process1 releases CW(gid=1)
- *   process2's PR should be granted
- *
- * This is a lot like test1.
- */
-void grouplock_test3(char *filename, int fd, char *errmsg)
-{
-        int rc, count, gid = 1;
-        char buf[LPGL_FILEN];
-        char zeros[LPGL_FILEN];
-        MPI_Request req1, req2;
-        int temp1, temp2;
-
-        if (rank == 0) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-        if (rank == 1) {
-                memset(zeros, 0x0, sizeof(zeros));
-                lseek(fd, 0, SEEK_SET);
-
-                MPI_Send(&gid, 1, MPI_INT, 2, 1, MPI_COMM_WORLD);
-                count = read(fd, buf, sizeof(buf));
-                if (count != sizeof(buf)) {
-                        if (count > 0)
-                                dump_diff(zeros, buf, count, 0);
-                        sprintf(errmsg, "read of file %s return %d",
-                                filename, count);
-                        FAIL(errmsg);
-                }
-                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 2) {
-                int temp;
-
-                /* Wait for reading task to progress, this is probably somewhat
-                   racey, though, may be adding usleep here would make things
-                   better here. */
-                usleep(100);
-                MPI_Recv(&temp, 1, MPI_INT, 1, 1, MPI_COMM_WORLD,
-                         MPI_STATUS_IGNORE);
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1, flag2;
-
-                /* reading task will tell us when it completes */
-                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
-                /* 2nd locking task will tell us when it completes */
-                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
-
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("2nd locking task is not progressing\n");
-                        }
-                        usleep(100);
-                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                        if (flag1) {
-                                FAIL("PR task progressed even though GROUP lock"
-                                     " is held\n");
-                        }
-                } while (!flag2);
-        }
-
-        /* Now we need to release the lock */
-
-        if (rank == 2) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1;
-
-                do {
-                        iter--;
-                        usleep(100);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                } while (!flag1 && iter);
-                if (iter) {
-                        FAIL("reading task is progressing even "
-                             "though GROUP lock was not fully released\n");
-                }
-
-                iter = MAX_WAITING_TIME;
-
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("reading task is not progressing even "
-                                     "though GROUP lock was released\n");
-                                break;
-                        }
-                        usleep(100);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                } while (!flag1);
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-}
-
-/*
- * process1 attempts CW(gid=1) -- granted
- * process2 attempts PR on non-blocking fd -> should return -EWOULDBLOCK
- * process3 attempts CW(gid=2) on non-blocking fd -> should return -EWOULDBLOCK
- */
-void grouplock_test4(char *filename, int fd, char *errmsg)
-{
-        int rc, count, gid = 1;
-        char buf[LPGL_FILEN];
-        char zeros[LPGL_FILEN];
-
-        if (rank == 0) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-        if (rank == 1) {
-                memset(zeros, 0x0, sizeof(zeros));
-                lseek(fd, 0, SEEK_SET);
-
-                count = read(fd, buf, sizeof(buf));
-                if (count != sizeof(buf)) {
-                        if (count == -1 && errno == EWOULDBLOCK) {
-                                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-                                return;
-                        }
-
-                        if (count > 0)
-                                dump_diff(zeros, buf, count, 0);
-                        sprintf(errmsg, "read of file %s return %d",
-                                filename, count);
-                        FAIL(errmsg);
-                } else {
-                        FAIL("PR lock succeed while incompatible "
-                             "GROUP LOCK (gid=1) is still held\n");
-                }
-        }
-
-        if (rank == 2) {
-                gid = 2;
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        if (errno == EWOULDBLOCK) {
-                                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-                                return;
-                        }
-
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                } else {
-                        FAIL("GROUP_LOCK (gid=2) succeed while incompatible "
-                             "GROUP LOCK (gid=1) is still held\n");
-                }
-        }
-
-
-        if ( rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1, flag2;
-                MPI_Request req1, req2;
-                int temp1, temp2;
-
-                /* reading task will tell us when it completes */
-                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
-                /* 2nd locking task will tell us when it completes */
-                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
-
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("non-blocking tasks are not progressing\n");
-                        }
-                        usleep(100);
-                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                } while (!(flag2 && flag1));
-
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s", filename);
-                        FAIL(errmsg);
-                }
-        }
-}
-
-/*
- * process1 attempts CW(gid=1) -- granted
- * process2 attempts CW(gid=2) -- blocked
- * process3 attempts CW(gid=2) -- blocked
- * process1 releases CW(gid=1)
- *   process2's CW(gid=2) should be granted
- *   process3's CW(gid=2) should be granted
- *
- * This is pretty much like test 3
- */
-void grouplock_test5(char *filename, int fd, char *errmsg)
-{
-        int rc, gid = 1;
-        MPI_Request req1, req2;
-        int temp1, temp2;
-
-        if (rank == 0) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-        if (rank == 2 || rank == 1) {
-                gid = 2;
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-                MPI_Send(&gid, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
-        }
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1, flag2;
-
-                /* 3rd locking task will tell us when it completes */
-                MPI_Irecv(&temp1, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &req1);
-                /* 2nd locking task will tell us when it completes */
-                MPI_Irecv(&temp2, 1, MPI_INT, 2, 1, MPI_COMM_WORLD, &req2);
-
-                do {
-                        iter--;
-                        usleep(100);
-                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                } while (!flag2 && !flag1 && iter);
-                if (iter) {
-                        FAIL("incomptible locking tasks are progressing\n");
-                }
-        }
-
-        /* Now we need to release the lock */
-
-        if (rank == 0) {
-                int iter = MAX_WAITING_TIME;
-                int flag1, flag2;
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-
-                do {
-                        iter--;
-                        if (!iter) {
-                                FAIL("locking tasks are not progressing even "
-                                     "though incompatible lock released\n");
-                        }
-                        usleep(100);
-                        MPI_Test(&req1, &flag1, MPI_STATUS_IGNORE);
-                        MPI_Test(&req2, &flag2, MPI_STATUS_IGNORE);
-                } while (!(flag1 && flag2));
-
-        }
-
-        if ( rank == 1 || rank == 2) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-}
-
-/*
- * process1 attempts CW(gid=1) -- granted
- * process2 attempts PW -- blocked
- * process2 attempts CW(gid=2) -- blocked
- * process3 attempts CW(gid=2) -- blocked
- * process1 releases CW(gid=1)
- *   process2's CW(gid=2) should be granted
- *   process3's CW(gid=2) should be granted
- *
- * after process1 release CW(gid=1), there are two pathes:
- *   path 1. process2 get PW
- *   path 2. process3 get CW(gid=2)
- *
- * green: Also about test6 - by definition if P* and CW lock are waiting,
- *        CW lock have bigger priority and should be granted first when it becomes
- *        possible. So after process1 releases its CW lock, process3 should always
- *        get CW lock, and when it will release it, process 2 will proceed with read
- *        and then with getting CW lock
- *
- * XXX This test does not make any sence at all the way it is described right
- * now, hence disabled.
- */
-void grouplock_test6(char *filename, int fd, char *errmsg)
-{
-}
-
-/* Just test some error paths with invalid requests */
-void grouplock_errorstest(char *filename, int fd, char *errmsg)
-{
-        int gid = 1;
-        int rc;
-
-        /* To not do lots of separate tests with lots of fd opening/closing,
-           different parts of this test are performed in different processes */
-
-        if (rank == 0 || rank == 1 ) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_LOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        /* second group lock on same fd, same gid */
-        if (rank == 0) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid)) == -1) {
-                        if (errno != EINVAL) {
-                                sprintf(errmsg, "Double GROUP lock failed with errno %d instead of EINVAL\n", errno);
-                                FAIL(errmsg);
-                        }
-                } else {
-                        FAIL("Taking second GROUP lock on same fd succeed\n");
-                }
-        }
-
-        /* second group lock on same fd, different gid */
-        if (rank == 1) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid + 1)) == -1) {
-                        if (errno != EINVAL) {
-                                sprintf(errmsg, "Double GROUP lock different gid failed with errno %d instead of EINVAL\n", errno);
-                                FAIL(errmsg);
-                        }
-                } else {
-                        FAIL("Taking second GROUP lock on same fd, different gid, succeed\n");
-                }
-        }
-
-        /* GROUP unlock with wrong gid */
-        if (rank == 0 || rank == 1) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid + 1)) == -1) {
-                        if (errno != EINVAL) {
-                                sprintf(errmsg, "GROUP unlock with wrong gid failed with errno %d instead of EINVAL\n",
-                                        errno);
-                                FAIL(errmsg);
-                        }
-                } else {
-                        FAIL("GROUP unlock with wrong gid succeed\n");
-                }
-        }
-
-        if (rank == 0 || rank == 1) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        sprintf(errmsg, "ioctl GROUP_UNLOCK of file %s return %d",
-                                filename, rc);
-                        FAIL(errmsg);
-                }
-        }
-
-        /* unlock of never locked fd */
-        if (rank == 2) {
-                if ((rc = ioctl(fd, LL_IOC_GROUP_UNLOCK, gid)) == -1) {
-                        if (errno != EINVAL) {
-                                sprintf(errmsg, "GROUP unlock on never locked fd failed with errno %d instead of EINVAL\n",
-                                        errno);
-                                FAIL(errmsg);
-                        }
-                } else {
-                        FAIL("GROUP unlock on never locked fd succeed\n");
-                }
-        }
-}
-
-void grouplock_file(char *name, int items)
-{
-        int fd;
-        char filename[MAX_FILENAME_LEN];
-        char errmsg[MAX_FILENAME_LEN+20];
-
-        sprintf(filename, "%s/%s", testdir, name);
-
-        if (items == 4) {
-                if ((fd = open(filename, O_RDWR | O_NONBLOCK)) == -1) {
-                        sprintf(errmsg, "open of file %s", filename);
-                        FAIL(errmsg);
-                }
-        } else if ((fd = open(filename, O_RDWR)) == -1) {
-                sprintf(errmsg, "open of file %s", filename);
-                FAIL(errmsg);
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-        switch (items) {
-        case 1:
-                grouplock_test1(filename, fd, errmsg);
-                break;
-        case 2:
-                grouplock_test2(filename, fd, errmsg);
-                break;
-        case 3:
-                grouplock_test3(filename, fd, errmsg);
-                break;
-        case 4:
-                grouplock_test4(filename, fd, errmsg);
-                break;
-        case 5:
-                grouplock_test5(filename, fd, errmsg);
-                break;
-        case 6:
-                grouplock_test6(filename, fd, errmsg);
-                break;
-        case 7:
-                grouplock_errorstest(filename, fd, errmsg);
-                break;
-        default:
-                sprintf(errmsg, "wrong test case number %d (should be <= %d)",
-                        items, LPGL_TEST_ITEMS);
-                FAIL(errmsg);
-        }
-
-        MPI_Barrier(MPI_COMM_WORLD);
-
-        if (close(fd) == -1) {
-                sprintf(errmsg, "close of file %s", filename);
-                FAIL(errmsg);
-        }
-
-}
-
-void parallel_grouplock(void)
-{
-        int i;
-
-        for (i = 1;i <= LPGL_TEST_ITEMS;++i) {
-                begin("setup");
-                create_file("parallel_grouplock", LPGL_FILEN, 0);
-                end("setup");
-
-                begin("test");
-                grouplock_file("parallel_grouplock", i);
-                end("test");
-
-                begin("cleanup");
-                remove_file("parallel_grouplock");
-                end("cleanup");
-        }
-}
-
-void usage(char *proc)
-{
-        int i;
-
-        if (rank == 0) {
-                printf("Usage: %s [-h] -d <testdir>\n", proc);
-                printf("           [-n \"13\"] [-v] [-V #] [-g]\n");
-                printf("\t-h: prints this help message\n");
-                printf("\t-d: the directory in which the tests will run\n");
-                printf("\t-n: repeat test # times\n");
-                printf("\t-v: increase the verbositly level by 1\n");
-                printf("\t-V: select a specific verbosity level\n");
-                printf("\t-g: debug mode\n");
-        }
-
-        MPI_Initialized(&i);
-        if (i) MPI_Finalize();
-        exit(0);
-}
-
-int main(int argc, char *argv[])
-{
-        char c;
-        int i, iterations = 1;
-
-        /* Check for -h parameter before MPI_Init so the binary can be
-           called directly, without, for instance, mpirun */
-        for (i = 1; i < argc; ++i) {
-                if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
-                        usage(argv[0]);
-        }
-
-        MPI_Init(&argc, &argv);
-        MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-        MPI_Comm_size(MPI_COMM_WORLD, &size);
-
-//        MPI_Comm_set_attr(MPI_COMM_WORLD, MPI_WTIME_IS_GLOBAL, &tr);
-
-        /* Parse command line options */
-        while (1) {
-                c = getopt(argc, argv, "d:ghn:vV:");
-                if (c == -1)
-                        break;
-
-                switch (c) {
-                case 'd':
-                        testdir = optarg;
-                        break;
-                case 'g':
-                        debug = 1;
-                        break;
-                case 'h':
-                        usage(argv[0]);
-                        break;
-                case 'n':
-                        iterations = atoi(optarg);
-                        break;
-                case 'v':
-                        verbose += 1;
-                        break;
-                case 'V':
-                        verbose = atoi(optarg);
-                        break;
-                }
-        }
-
-        if (rank == 0)
-                printf("%s is running with %d process(es) %s\n",
-                       argv[0], size, debug ? "in DEBUG mode" : "\b\b");
-
-        if (size < MAX_GLHOST) {
-                fprintf(stderr, "Error: "
-                        "should be at least four processes to run the test!\n");
-                MPI_Abort(MPI_COMM_WORLD, 2);
-        }
-
-        if (testdir == NULL && rank == 0) {
-                fprintf(stderr, "Please specify a test directory! "
-                        "(\"%s -h\" for help)\n", argv[0]);
-                MPI_Abort(MPI_COMM_WORLD, 2);
-        }
-
-        lp_gethostname();
-
-        for (i = 0; i < iterations; ++i) {
-                if (rank == 0)
-                        printf("%s: Running test #%s(iter %d)\n",
-                               timestamp(), argv[0], i);
-
-                parallel_grouplock();
-                MPI_Barrier(MPI_COMM_WORLD);
-        }
-
-        if (rank == 0) {
-                printf("%s: All tests passed!\n", timestamp());
-        }
-        MPI_Finalize();
-        return 0;
-}
diff --git a/lustre/tests/performance-sanity.sh b/lustre/tests/performance-sanity.sh
index ce3d2f9..1846fd8 100644
--- a/lustre/tests/performance-sanity.sh
+++ b/lustre/tests/performance-sanity.sh
@@ -17,8 +17,8 @@ which mpirun > /dev/null 2>&1 || \
 	FAIL_ON_ERROR=true error "No mpirun program. Aborting." 
 
 # Skip these tests
-# bug number:  15266 15266 15266
-ALWAYS_EXCEPT="1     2     6     $PERFORMANCE_SANITY_EXCEPT"
+# bug number:  15266 15266 
+ALWAYS_EXCEPT="1     2    $PERFORMANCE_SANITY_EXCEPT"
 
 build_test_filter
 
diff --git a/lustre/tests/recovery-double-scale.sh b/lustre/tests/recovery-double-scale.sh
new file mode 100644
index 0000000..04ec0c4
--- /dev/null
+++ b/lustre/tests/recovery-double-scale.sh
@@ -0,0 +1,319 @@
+#!/bin/bash
+
+# All pairwise combinations of node failures.
+# Was cmd3-17
+#
+# Author: Chris Cooper <ccooper at clusterfs.com>
+#
+# Script fails pair of nodes:
+# --  in parallel by default
+# --  in series if SERIAL is set
+
+LUSTRE=${LUSTRE:-`dirname $0`/..}
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
+. $LUSTRE/tests/test-framework.sh
+
+init_test_env $@
+
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-double-scale}
+DEBUGLOG=$TESTSUITELOG.debug
+exec 2>$DEBUGLOG
+echo "--- env ---" >&2
+env >&2
+echo "--- env ---" >&2
+set -x
+
+[ "$SHARED_DIRECTORY" ] || \
+    { skip "$0: Empty SHARED_DIRECTORY" && exit 0; }
+
+[ -n "$CLIENTS" ] || { skip "$0 Need two or more remote clients" && exit 0; }
+[ $CLIENTCOUNT -ge 3 ] || \
+    { skip "$0 Need two or more remote clients, have $CLIENTCOUNT" && exit 0; }
+
+END_RUN_FILE=${END_RUN_FILE:-$SHARED_DIRECTORY/end_run_file}
+LOAD_PID_FILE=${LOAD_PID_FILE:-$TMP/client-load.pid}
+
+remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
+remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
+
+check_timeout || exit 1
+
+build_test_filter
+
+check_and_setup_lustre
+rm -rf $DIR/[df][0-9]*
+
+# the test node needs to be insulated from a lustre failure as much as possible,
+# so not even loading the lustre modules is ideal.
+# -- umount lustre
+# -- remove hostname from clients list
+zconf_umount $(hostname) $MOUNT
+NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
+NODES_TO_USE=$(exclude_items_from_list $NODES_TO_USE $(hostname))
+
+check_progs_installed $NODES_TO_USE ${CLIENT_LOADS[@]}
+
+MDTS=$(get_facets MDS)
+OSTS=$(get_facets OST)
+
+rm -f $END_RUN_FILE
+
+reboot_recover_node () {
+    # item var contains a pair of clients if nodetype=clients
+    # I would prefer to have a list here
+    local item=$1
+    local nodetype=$2	
+    local timeout=$($LCTL get_param  -n timeout)
+
+    # MDS, OST item contains the facet
+    case $nodetype in
+       MDS|OST )    facet_failover $item
+                [ "$SERIAL" ] && wait_recovery_complete $item $((timeout * 4)) || true
+                ;;
+       clients) for c in ${item//,/ }; do
+                      shutdown_client $c
+                      boot_node $c
+                      echo "Reintegrating $c"
+                      # one client fails; need dk logs from this client only 
+                      zconf_mount $c $MOUNT || NODES="$c $(mdts_nodes) $(osts_nodes)" error_exit "zconf_mount failed"
+                 done
+                 start_client_loads $item
+                 ;;
+                # script failure:
+                # don't use error (), the logs from all nodes not needed
+       * )      echo "reboot_recover_node: nodetype=$nodetype. Must be one of 'MDS', 'OST', or 'clients'."
+                exit 1;;
+    esac
+}
+
+get_item_type () {
+    local type=$1
+    local excluded=${2:-""}
+
+    local list
+    case $type in
+       MDS )    list=$MDTS;;
+       OST )    list=$OSTS;;
+       clients) list=$NODES_TO_USE
+                ;;
+                # script failure:
+                # don't use error (), the logs from all nodes not needed
+       * )      echo "Invalid type=$type. Must be one of 'MDS', 'OST', or 'clients'."
+                exit 1;;
+    esac
+
+    [ "$excluded" ] && list=$(exclude_items_from_list $list $excluded)
+    # empty list
+    if [ ! "$(echo $list)" ]; then
+        echo
+        return
+    fi
+
+    item=$(get_random_entry $list)
+    if [ "$type" = clients ] ; then
+        item="$item $(get_random_entry $(exclude_items_from_list $list $item))"
+        item=$(comma_list $item)
+    fi
+    echo $item
+}
+
+# failover_pair
+#
+# for the two nodetypes specified, chooses a random node(s) from each
+# class, reboots the nodes sequentially, and then restarts lustre on
+# the nodes.
+failover_pair() {
+    local type1=$1
+    local type2=$2
+    local title=$3
+
+    local client_nodes=""
+    local item1=
+    local item2=
+    local client1=
+    local client2=
+
+    log "
+==== START === $title "
+
+    item1=$(get_item_type $type1)
+    [ "$item1" ] || \
+        { echo "type1=$type1 item1 is empty" && return 0; }
+    item2=$(get_item_type $type2 $item1)
+    [ "$item2" ] || \
+        { echo "type1=$type1 item1=$item1 type2=$type2 item2=$item2 is empty" && return 0; }
+
+    # Check that our client loads are still running. If any have died,
+    # that means they have died outside of recovery, which is unacceptable.
+    log "==== Checking the clients loads BEFORE failover -- failure NOT OK"
+
+    # FIXME. need print summary on exit
+    if ! check_client_loads $NODES_TO_USE; then
+        exit 4
+    fi
+
+    log "Done checking client loads. Failing type1=$type1 item1=$item1 ... "
+
+    reboot_recover_node $item1 $type1
+
+    # Hendrix test17 description: 
+    # Introduce a failure, wait at
+    # least 5 minutes (for recovery),
+    # introduce a 2nd
+    # failure, and wait another 5
+    # minutes
+
+    # reboot_recover_node waits recovery in according to
+    # SERIAL value.
+    # We have a "double failures" if SERIAL is not set,
+    # do not need a sleep between failures for "double failures"
+
+    log "                            Failing type2=$type2 item2=$item2 ... "    
+    reboot_recover_node $item2 $type2
+
+    # Client loads are allowed to die while in recovery, so we just
+    # restart them.
+    log "==== Checking the clients loads AFTER  failovers -- ERRORS_OK=$ERRORS_OK"
+    restart_client_loads $NODES_TO_USE $ERRORS_OK || return $? 
+    log "Done checking / re-Starting client loads. PASS"
+    return 0
+}
+
+summary_and_cleanup () {
+    local rc=$?
+    trap 0
+
+    # Having not empty END_RUN_FILE means the failed loads only
+    if [ -s $END_RUN_FILE ]; then
+        echo "Found the END_RUN_FILE file: $END_RUN_FILE"
+        cat $END_RUN_FILE
+        local END_RUN_NODE=
+        read END_RUN_NODE < $END_RUN_FILE
+
+        # a client load will end (i.e. fail) if it finds
+        # the end run file.  that does not mean that that client load
+        # actually failed though.  the first node in the END_RUN_NODE is
+        # the one we are really interested in.
+        if [ -n "$END_RUN_NODE" ]; then
+            var=$(client_var_name $END_RUN_NODE)_load
+            echo "Client load failed on node $END_RUN_NODE"
+            echo
+            echo "client $END_RUN_NODE load debug output :"
+            local logfile=${TESTSUITELOG}_run_${!var}.sh-${END_RUN_NODE}.debug 
+            do_node ${END_RUN_NODE} "set -x; [ -e $logfile ] && cat $logfile " || true
+        fi
+        rc=1
+    fi
+
+    echo $(date +'%F %H:%M:%S') Terminating clients loads ...
+    echo "$0" >> $END_RUN_FILE
+    local result=PASS
+    [ $rc -eq 0 ] || result=FAIL
+
+    log "
+Server failover period: $FAILOVER_PERIOD seconds
+Exited after:           $ELAPSED seconds
+Status: $result: rc=$rc"
+
+    # make sure the client loads die
+    do_nodes $NODES_TO_USE "set -x; test -f $TMP/client-load.pid && \
+        { kill -s TERM \$(cat $TMP/client-load.pid) || true; }"
+
+    # and free up the pdshes that started them, if any are still around
+    if [ -n "$CLIENT_LOAD_PIDS" ]; then
+        kill $CLIENT_LOAD_PIDS || true
+        sleep 5
+        kill -9 $CLIENT_LOAD_PIDS || true
+    fi
+    [ $rc -eq 0 ] && zconf_mount $(hostname) $MOUNT
+    exit $rc
+}
+
+trap summary_and_cleanup EXIT TERM INT
+
+#
+# MAIN
+#
+log "-----============= $0 starting =============-----"
+
+START_TS=$(date +%s)
+CURRENT_TS=$START_TS
+ELAPSED=0
+
+# Set SERIAL to serialize the failure through a recovery of the first failure. 
+SERIAL=${SERIAL:-""}
+ERRORS_OK="yes"
+
+[ "$SERIAL" ] && ERRORS_OK="" 
+
+FAILOVER_PERIOD=${FAILOVER_PERIOD:-$((60*5))} # 5 minutes
+
+# Start client loads.
+start_client_loads $NODES_TO_USE
+echo clients load pids:
+if ! do_nodes $NODES_TO_USE "set -x; echo \$(hostname): && cat $TMP/client-load.pid"; then
+    if [ -e $DEBUGLOG ]; then
+        exec 2<&-
+        cat $DEBUGLOG
+        exit 3
+    fi
+fi
+
+# FIXME: Do we want to have an initial sleep period where the clients 
+# just run before introducing a failure?
+sleep $FAILOVER_PERIOD
+
+#CMD_TEST_NUM=17.1
+failover_pair MDS OST     "test 1: failover MDS, then OST =========="
+sleep $FAILOVER_PERIOD
+
+#CMD_TEST_NUM=17.2
+failover_pair MDS clients "test 2: failover MDS, then 2 clients ===="
+sleep $FAILOVER_PERIOD
+
+#CMD_TEST_NUM=17.3
+# No test 3 for 1.8.x lustre version
+
+#CMD_TEST_NUM=17.4
+if [ $OSTCOUNT -gt 1 ]; then
+    failover_pair OST OST     "test 4: failover OST, then another OST =="
+    sleep $FAILOVER_PERIOD
+else
+    skip "$0 : $OSTCOUNT < 2 OSTs, test 4 skipped"
+fi 
+
+#CMD_TEST_NUM=17.5
+failover_pair OST clients "test 5: failover OST, then 2 clients ===="
+sleep $FAILOVER_PERIOD
+
+#CMD_TEST_NUM=17.6
+failover_pair OST MDS     "test 6: failover OST, then MDS =========="
+sleep $FAILOVER_PERIOD
+
+#CMD_TEST_NUM=17.7
+failover_pair clients MDS "test 7: failover 2 clients, then MDS ===="
+sleep $FAILOVER_PERIOD
+
+#CMD_TEST_NUM=17.8
+#failover_pair clients OST "test 8: failover 2 clients, then OST ===="
+sleep $FAILOVER_PERIOD
+
+#CMD_TEST_NUM=17.9
+if [ $CLIENTCOUNT -ge 5 ]; then
+    failover_pair clients clients "test 9: failover 2 clients, then 2 different clients =="
+    sleep $FAILOVER_PERIOD
+fi
+log "==== Checking the clients loads AFTER  all failovers -- failure NOT OK"
+if ! check_client_loads $NODES_TO_USE; then
+    log "Client load failed after failover. Exiting"
+    exit 5
+fi
+
+CURRENT_TS=$(date +%s)
+ELAPSED=$((CURRENT_TS - START_TS))
+
+log "Completed successfully in $ELAPSED seconds"
+
+exit 0
diff --git a/lustre/tests/recovery-mds-scale.sh b/lustre/tests/recovery-mds-scale.sh
new file mode 100644
index 0000000..fd8d32f
--- /dev/null
+++ b/lustre/tests/recovery-mds-scale.sh
@@ -0,0 +1,250 @@
+#!/bin/bash
+
+# Was Test 11 in cmd3.
+# For duration of 24 hours repeatedly failover a random MDS at
+# 10 minute intervals and verify that no application errors occur.
+
+# Test runs one of CLIENT_LOAD progs on remote clients.
+
+LUSTRE=${LUSTRE:-`dirname $0`/..}
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
+. $LUSTRE/tests/test-framework.sh
+
+init_test_env $@
+
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-mds-scale}
+DEBUGLOG=$TESTSUITELOG.debug
+exec 2>$DEBUGLOG
+echo "--- env ---" >&2
+env >&2
+echo "--- env ---" >&2
+set -x
+
+[ "$SHARED_DIRECTORY" ] || \
+    { skip "$0: Empty SHARED_DIRECTORY" && exit 0; }
+
+[ -n "$CLIENTS" ] || { skip "$0 Need two or more remote clients" && exit 0; }
+[ $CLIENTCOUNT -ge 3 ] || \
+    { skip "$0 Need two or more clients, have $CLIENTCOUNT" && exit 0; }
+
+END_RUN_FILE=${END_RUN_FILE:-$SHARED_DIRECTORY/end_run_file}
+LOAD_PID_FILE=${LOAD_PID_FILE:-$TMP/client-load.pid}
+
+remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
+remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
+
+build_test_filter
+
+check_and_setup_lustre
+rm -rf $DIR/[df][0-9]*
+
+# the test node needs to be insulated from a lustre failure as much as possible,
+# so not even loading the lustre modules is ideal.
+# -- umount lustre
+# -- remove hostname from clients list
+zconf_umount $(hostname) $MOUNT
+NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
+NODES_TO_USE=$(exclude_items_from_list $NODES_TO_USE $(hostname))
+
+check_progs_installed $NODES_TO_USE ${CLIENT_LOADS[@]}
+
+MDTS=$(get_facets MDS)
+OSTS=$(get_facets OST)
+
+ERRORS_OK=""    # No application failures should occur during this test.
+FLAVOR=${FLAVOR:-"MDS"}
+
+if [ "$FLAVOR" == "MDS" ]; then
+    SERVERS=$MDTS
+else
+    SERVERS=$OSTS
+fi
+ 
+if [ "$SLOW" = "no" ]; then
+    DURATION=${DURATION:-$((60 * 30))}
+    SERVER_FAILOVER_PERIOD=${SERVER_FAILOVER_PERIOD:-$((60 * 5))}
+else
+    DURATION=${DURATION:-$((60 * 60 * 24))}
+    SERVER_FAILOVER_PERIOD=${SERVER_FAILOVER_PERIOD:-$((60 * 10))} # 10 minutes
+fi
+
+rm -f $END_RUN_FILE
+
+vmstatLOG=${TESTSUITELOG}_$(basename $0 .sh).vmstat
+
+server_numfailovers () {
+    local facet
+    local var
+
+    for facet in $MDTS ${OSTS//,/ }; do
+        var=${facet}_nums
+        val=${!var}
+        if [ "$val" ] ; then
+            echo "$facet failed  over  $val times"
+        fi
+    done
+}
+
+summary_and_cleanup () {
+
+    local rc=$?
+    local var
+    trap 0
+
+    # Having not empty END_RUN_FILE means the failed loads only
+    if [ -s $END_RUN_FILE ]; then
+        echo "Found the END_RUN_FILE file: $END_RUN_FILE"
+        cat $END_RUN_FILE
+        local END_RUN_NODE=
+        read END_RUN_NODE < $END_RUN_FILE
+
+    # a client load will end (i.e. fail) if it finds
+    # the end run file.  that does not mean that that client load
+    # actually failed though.  the first node in the END_RUN_NODE is
+    # the one we are really interested in.
+        if [ -n "$END_RUN_NODE" ]; then
+            var=$(client_var_name $END_RUN_NODE)_load
+            echo "Client load failed on node $END_RUN_NODE" 
+            echo
+            echo "client $END_RUN_NODE load stdout and debug files :
+              ${TESTSUITELOG}_run_${!var}.sh-${END_RUN_NODE}
+              ${TESTSUITELOG}_run_${!var}.sh-${END_RUN_NODE}.debug"
+        fi
+        rc=1
+    fi
+     
+    echo $(date +'%F %H:%M:%S') Terminating clients loads ...
+    echo "$0" >> $END_RUN_FILE
+    local result=PASS
+    [ $rc -eq 0 ] || result=FAIL
+
+    log "Duraion:                $DURATION
+Server failover period: $SERVER_FAILOVER_PERIOD seconds
+Exited after:           $ELAPSED seconds
+Number of failovers before exit:
+$(server_numfailovers)
+Status: $result: rc=$rc"
+
+    # stop the vmstats on the OSTs
+    if [ "$VMSTAT" ]; then
+        do_nodes $(comma_list $(osts_nodes)) "test -f /tmp/vmstat.pid && \
+            { kill -s TERM \$(cat /tmp/vmstat.pid); rm -f /tmp/vmstat.pid; \
+            gzip -f9 $vmstatLOG-\$(hostname); }"
+    fi
+
+    # make sure the client loads die
+    do_nodes $NODES_TO_USE "set -x; test -f $LOAD_PID_FILE && \
+        { kill -s TERM \$(cat $LOAD_PID_FILE) || true; }"
+
+    # and free up the pdshes that started them, if any are still around
+    if [ -n "$CLIENT_LOAD_PIDS" ]; then
+        kill $CLIENT_LOAD_PIDS || true
+        sleep 5
+        kill -9 $CLIENT_LOAD_PIDS || true
+    fi
+    [ $rc -eq 0 ] && zconf_mount $(hostname) $MOUNT
+
+    exit $rc
+}
+
+#
+# MAIN 
+#
+log "-----============= $0 starting =============-----"
+
+trap summary_and_cleanup EXIT INT
+
+ELAPSED=0
+NUM_FAILOVERS=0
+
+# vmstat the osts
+if [ "$VMSTAT" ]; then
+    do_nodes $(comma_list $(osts_nodes)) "vmstat 1 > $vmstatLOG-\$(hostname) 2>/dev/null </dev/null & echo \$! > /tmp/vmstat.pid"
+fi
+
+# Start client loads.
+start_client_loads $NODES_TO_USE
+
+echo clients load pids:
+if ! do_nodes $NODES_TO_USE "set -x; echo \$(hostname): && cat $LOAD_PID_FILE"; then
+    if [ -e $DEBUGLOG ]; then
+        exec 2<&-
+        cat $DEBUGLOG
+        exit 3
+    fi
+fi
+
+START_TS=$(date +%s)
+CURRENT_TS=$START_TS
+
+MINSLEEP=${MINSLEEP:-120}
+REQFAIL_PERCENT=${REQFAIL_PERCENT:-3}	# bug17839 comment 62
+REQFAIL=${REQFAIL:-$(( DURATION / SERVER_FAILOVER_PERIOD * REQFAIL_PERCENT / 100))}
+reqfail=0
+sleep=0
+while [ $ELAPSED -lt $DURATION -a ! -e $END_RUN_FILE ]; do
+
+    # In order to perform the 
+    # expected number of failovers, we need to account the following :
+    # 1) the time that has elapsed during the client load checking
+    # 2) time takes for failover
+
+    it_time_start=$(date +%s)
+    
+    SERVERFACET=$(get_random_entry $SERVERS)
+    var=${SERVERFACET}_nums
+
+    # Check that our client loads are still running. If any have died, 
+    # that means they have died outside of recovery, which is unacceptable.    
+
+    log "==== Checking the clients loads BEFORE failover -- failure NOT OK \
+    ELAPSED=$ELAPSED DURATION=$DURATION PERIOD=$SERVER_FAILOVER_PERIOD" 
+
+    if ! check_client_loads $NODES_TO_USE; then
+        exit 4
+    fi
+
+    log "Starting failover on $SERVERFACET"
+
+    facet_failover "$SERVERFACET" || exit 1
+
+    # Check that our client loads are still running during failover.
+    # No application failures should occur.
+
+    log "==== Checking the clients loads AFTER  failover -- failure NOT OK"
+    if ! check_client_loads $NODES_TO_USE; then
+        log "Client load failed during failover. Exiting"
+        exit 5
+    fi
+
+    # Increment the number of failovers
+    NUM_FAILOVERS=$((NUM_FAILOVERS+1))
+    val=$((${!var} + 1))
+    eval $var=$val
+ 
+    CURRENT_TS=$(date +%s)
+    ELAPSED=$((CURRENT_TS - START_TS))
+ 
+    sleep=$((SERVER_FAILOVER_PERIOD-(CURRENT_TS - it_time_start)))
+
+    # keep count the number of itterations when
+    # time spend to failover and two client loads check exceeded 
+    # the value ( SERVER_FAILOVER_PERIOD - MINSLEEP )
+    if [ $sleep -lt $MINSLEEP ]; then
+        reqfail=$((reqfail +1))
+        log "WARNING: failover and two check_client_loads time exceeded SERVER_FAILOVER_PERIOD - MINSLEEP !
+Failed to meet interval $reqfail times ( REQFAIL=$REQFAIL ); have sleep=$sleep"
+        [ $reqfail -gt $REQFAIL ] && exit 6 
+    fi  
+
+    log "$SERVERFACET has failed over ${!var} times, and counting..."
+    if [ $sleep -gt 0 ]; then 
+        echo "sleeping $sleep seconds ... "
+        sleep $sleep
+    fi
+done
+
+exit 0
diff --git a/lustre/tests/recovery-random-scale.sh b/lustre/tests/recovery-random-scale.sh
new file mode 100644
index 0000000..dfde69a
--- /dev/null
+++ b/lustre/tests/recovery-random-scale.sh
@@ -0,0 +1,303 @@
+#!/bin/bash
+
+# client failure does not affect other clients
+
+# Start load on clients (each client works on it's own directory).
+# At defined (5-10 minutes) interval fail one random client and then fail mds.
+# Reintegrate failed client after recovery completed,
+# application errors are allowed for that client but not on other clients.
+# 10 minute intervals and verify that no application errors occur.
+
+# Test runs one of CLIENT_LOAD progs on remote clients.
+
+LUSTRE=${LUSTRE:-`dirname $0`/..}
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
+. $LUSTRE/tests/test-framework.sh
+
+init_test_env $@
+
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-random-scale}
+DEBUGLOG=$TESTSUITELOG.debug
+exec 2>$DEBUGLOG
+echo "--- env ---" >&2
+env >&2
+echo "--- env ---" >&2
+set -x
+
+[ "$SHARED_DIRECTORY" ] || \
+    { skip "$0: Empty SHARED_DIRECTORY" && exit 0; }
+
+[ -n "$CLIENTS" ] || { skip "$0 Need two or more remote clients" && exit 0; }
+[ $CLIENTCOUNT -ge 3 ] || \
+    { skip "$0 Need two or more clients, have $CLIENTCOUNT" && exit 0; }
+
+END_RUN_FILE=${END_RUN_FILE:-$SHARED_DIRECTORY/end_run_file}
+LOAD_PID_FILE=${LOAD_PID_FILE:-$TMP/client-load.pid}
+
+remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
+
+build_test_filter
+
+check_and_setup_lustre
+rm -rf $DIR/[df][0-9]*
+
+# the test node needs to be insulated from a lustre failure as much as possible,
+# so not even loading the lustre modules is ideal.
+# -- umount lustre
+# -- remove hostname from clients list
+zconf_umount $(hostname) $MOUNT
+NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
+NODES_TO_USE=$(exclude_items_from_list $NODES_TO_USE $(hostname))
+
+check_progs_installed $NODES_TO_USE ${CLIENT_LOADS[@]}
+
+MDTS=$(get_facets MDS)
+
+if [ "$SLOW" = "no" ]; then
+    DURATION=${DURATION:-$((60 * 30))}
+    SERVER_FAILOVER_PERIOD=${SERVER_FAILOVER_PERIOD:-$((60 * 5))}
+else
+    DURATION=${DURATION:-$((60 * 60 * 24))}
+    SERVER_FAILOVER_PERIOD=${SERVER_FAILOVER_PERIOD:-$((60 * 10))} # 10 minutes
+fi
+
+rm -f $END_RUN_FILE
+
+vmstatLOG=${TESTSUITELOG}_$(basename $0 .sh).vmstat
+
+numfailovers () {
+    local facet
+    local var
+
+    for facet in $MDTS ${failed_clients//,/ }; do
+        var=${facet}_nums
+        val=${!var}
+        if [ "$val" ] ; then
+            echo "$facet failed  over  $val times"
+        fi
+    done
+}
+
+# list is comma separated
+print_logs () {
+    local list=$1
+
+    do_nodes $list "node=\\\$(hostname)
+var=\\\${node}_load
+log=${TESTSUITELOG}_run_${!var}.sh-\\\$node.debug
+if [ -e \\\$log ] ; then
+echo Node \\\$node debug log:
+cat \\\$log
+fi"
+}
+
+summary_and_cleanup () {
+
+    local rc=$?
+    local var
+    trap 0
+
+    # Having not empty END_RUN_FILE means the failed loads only
+    if [ -s $END_RUN_FILE ]; then
+        echo "Found the END_RUN_FILE file: $END_RUN_FILE"
+        cat $END_RUN_FILE
+        local END_RUN_NODE=
+        read END_RUN_NODE < $END_RUN_FILE
+
+    # a client load will end (i.e. fail) if it finds
+    # the end run file.  that does not mean that that client load
+    # actually failed though.  the first node in the END_RUN_NODE is
+    # the one we are really interested in.
+        if [ -n "$END_RUN_NODE" ]; then
+            var=$(client_var_name $END_RUN_NODE)_load
+            echo "Client load failed on node $END_RUN_NODE" 
+            echo
+            echo "client $END_RUN_NODE load stdout and debug files :
+              ${TESTSUITELOG}_run_${!var}.sh-${END_RUN_NODE}
+              ${TESTSUITELOG}_run_${!var}.sh-${END_RUN_NODE}.debug"
+        fi
+        rc=1
+    fi
+
+
+    echo $(date +'%F %H:%M:%S') Terminating clients loads ...
+    echo "$0" >> $END_RUN_FILE
+    local result=PASS
+    [ $rc -eq 0 ] || result=FAIL
+
+    log "Duraion:                $DURATION
+Server failover period: $SERVER_FAILOVER_PERIOD seconds
+Exited after:           $ELAPSED seconds
+Number of failovers before exit:
+$(numfailovers)
+Status: $result: rc=$rc"
+
+    # stop the vmstats on the OSTs
+    if [ "$VMSTAT" ]; then
+        do_nodes $(comma_list $(osts_nodes)) "test -f /tmp/vmstat.pid && \
+            { kill -s TERM \$(cat /tmp/vmstat.pid); rm -f /tmp/vmstat.pid; \
+            gzip -f9 $vmstatLOG-\$(hostname); }"
+    fi
+
+    # make sure the client loads die
+    do_nodes $NODES_TO_USE "set -x; test -f $LOAD_PID_FILE && \
+        { kill -s TERM \$(cat $LOAD_PID_FILE) || true; }"
+
+    # and free up the pdshes that started them, if any are still around
+    if [ -n "$CLIENT_LOAD_PIDS" ]; then
+        kill $CLIENT_LOAD_PIDS || true
+        sleep 5
+        kill -9 $CLIENT_LOAD_PIDS || true
+    fi
+
+    if [ $rc -ne 0 ]; then
+        print_logs $NODES_TO_USE
+    fi
+
+    if [ $rc -eq 0 ]; then
+        zconf_mount $(hostname) $MOUNT
+    else
+        error "exited with rc=$rc"
+    fi
+    exit $rc
+}
+
+#
+# MAIN 
+#
+log "-----============= $0 starting =============-----"
+
+trap summary_and_cleanup EXIT # INT
+
+ELAPSED=0
+
+# vmstat the osts
+if [ "$VMSTAT" ]; then
+    do_nodes $(comma_list $(osts_nodes)) "vmstat 1 > $vmstatLOG-\$(hostname) 2>/dev/null </dev/null & echo \$! > /tmp/vmstat.pid"
+fi
+
+# Start client loads.
+start_client_loads $NODES_TO_USE
+
+echo clients load pids:
+if ! do_nodes $NODES_TO_USE "set -x; echo \$(hostname): && cat $LOAD_PID_FILE"; then
+    if [ -e $DEBUGLOG ]; then
+        exec 2<&-
+        cat $DEBUGLOG
+        exit 3
+    fi
+fi
+
+START_TS=$(date +%s)
+CURRENT_TS=$START_TS
+
+MINSLEEP=${MINSLEEP:-120}
+REQFAIL_PERCENT=${REQFAIL_PERCENT:-3}	# bug17839 comment 62
+REQFAIL=${REQFAIL:-$(( DURATION / SERVER_FAILOVER_PERIOD * REQFAIL_PERCENT / 100))}
+reqfail=0
+sleep=0
+
+# This is used for FAIL_CLIENT only
+ERRORS_OK="yes"
+while [ $ELAPSED -lt $DURATION -a ! -e $END_RUN_FILE ]; do
+
+    # In order to perform the 
+    # expected number of failovers, we need to account the following :
+    # 1) the time that has elapsed during the client load checking
+    # 2) time takes for failover
+
+    it_time_start=$(date +%s)
+    
+    FAIL_CLIENT=$(get_random_entry $NODES_TO_USE)
+    client_var=$(client_var_name $FAIL_CLIENT)_nums
+
+    # store the list of failed clients
+    # lists are comma separated
+    failed_clients=$(expand_list $failed_clients $FAIL_CLIENT)
+
+    SERVERFACET=$(get_random_entry $MDTS)
+    var=${SERVERFACET}_nums
+
+    # Check that our client loads are still running. If any have died, 
+    # that means they have died outside of recovery, which is unacceptable.    
+
+    log "==== Checking the clients loads BEFORE failover -- failure NOT OK \
+    ELAPSED=$ELAPSED DURATION=$DURATION PERIOD=$SERVER_FAILOVER_PERIOD" 
+
+    if ! check_client_loads $NODES_TO_USE; then
+        exit 4
+    fi
+
+    log "FAIL CLIENT $FAIL_CLIENT ... "
+    shutdown_client $FAIL_CLIENT
+
+    log "Starting failover on $SERVERFACET"
+
+    facet_failover "$SERVERFACET" || exit 1
+    if ! wait_recovery_complete $SERVERFACET $((TIMEOUT * 10)); then 
+        echo "$SERVERFACET recovery is not completed!"
+        exit 7
+    fi
+ 
+    boot_node $FAIL_CLIENT
+    echo "Reintegrating $FAIL_CLIENT"
+    zconf_mount $FAIL_CLIENT $MOUNT || exit $?
+
+    # Increment the number of failovers
+    val=$((${!var} + 1))
+    eval $var=$val
+    val=$((${!client_var} + 1))
+    eval $client_var=$val
+
+    # load script on failed clients could create END_RUN_FILE
+    # We shuold remove it and ignore the failure if this
+    # file contains the failed client only.
+    # We can not use ERRORS_OK when start all loads at the start of this script
+    # because the application errors allowed for random failed client only, but
+    # not for all clients.
+    if [ -e $END_RUN_FILE ]; then
+        read END_RUN_NODE < $END_RUN_FILE
+        [[ $END_RUN_NODE = $FAIL_CLIENT ]] && 
+            rm -f $END_RUN_FILE || exit 13
+    fi
+   
+    restart_client_loads $FAIL_CLIENT $ERRORS_OK || exit $?
+
+    # Check that not failed clients loads are still running.
+    # No application failures should occur on clients that was not failed.
+
+    log "==== Checking the clients loads AFTER failed client reintegrated -- failure NOT OK"
+    if ! ERRORS_OK= check_client_loads $(exclude_items_from_list $NODES_TO_USE $FAIL_CLIENT); then
+        log "Client load failed. Exiting"
+        exit 5
+    fi
+
+    CURRENT_TS=$(date +%s)
+    ELAPSED=$((CURRENT_TS - START_TS))
+ 
+    sleep=$((SERVER_FAILOVER_PERIOD-(CURRENT_TS - it_time_start)))
+
+    # keep count the number of itterations when
+    # time spend to failover and two client loads check exceeded 
+    # the value ( SERVER_FAILOVER_PERIOD - MINSLEEP )
+    if [ $sleep -lt $MINSLEEP ]; then
+        reqfail=$((reqfail +1))
+        log "WARNING: failover, client reintegration and check_client_loads time
+exceeded SERVER_FAILOVER_PERIOD - MINSLEEP !
+Failed to meet interval $reqfail times ( REQFAIL=$REQFAIL ); have sleep=$sleep"
+        [ $reqfail -gt $REQFAIL ] && exit 6 
+    fi  
+
+    log " Number of failovers:
+$(numfailovers)                and counting..."
+
+    if [ $sleep -gt 0 ]; then 
+        echo "sleeping $sleep seconds ... "
+        sleep $sleep
+    fi
+done
+
+exit 0
diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh
index 552c8c9..a1f67f9 100755
--- a/lustre/tests/recovery-small.sh
+++ b/lustre/tests/recovery-small.sh
@@ -221,7 +221,7 @@ test_17() {
     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
 
     # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
-    if at_is_valid && at_is_enabled; then
+    if at_is_enabled; then
         at_max_saved=$(at_max_get ost1)
         at_max_set $TIMEOUT ost1
     fi
@@ -242,7 +242,7 @@ test_17() {
     # expect cmp to succeed, client resent bulk
     do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
     do_facet client "rm $DIR/$tfile" || return 4
-    [ $at_max_saved -ne 0 ] && $(at_max_set $at_max_saved ost1)
+    [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
     return 0
 }
 run_test 17 "timeout bulk get, don't evict client (2732)"
@@ -1017,6 +1017,31 @@ test_59() { # bug 10589
 }
 run_test 59 "Read cancel race on client eviction"
 
+test_61()
+{
+	local cflags='osc.*-OST0000-osc.connect_flags'
+	do_facet mds "lctl get_param -n $cflags |grep -q skip_orphan"
+	[ $? -ne 0 ] && skip "don't have skip orphan feature" && return
+
+	mkdir -p $DIR/d61 || error "mkdir dir $DIR/d61 failed"
+	# Set the default stripe of $DIR/d61 to put the files to ost1
+	$LFS setstripe -c 1 --index 0 $DIR/d61
+
+	replay_barrier mds
+	createmany -o $DIR/d61/$tfile-%d 10 
+	local oid=`do_facet ost1 "lctl get_param -n obdfilter.*OST0000.last_id"`
+
+	fail_abort mds
+	
+	touch $DIR/d61/$tfile
+	local id=`$LFS getstripe $DIR/d61/$tfile | awk '$2 ~ /^[1-9]+/ {print $2}'`
+	[ $id -le $oid ] && error "the orphan objid was reused, failed"
+
+	# Cleanup
+	rm -rf $DIR/d61
+}
+run_test 61 "Verify to not reuse orphan objects - bug 17485"
+
 equals_msg `basename $0`: test complete, cleaning up
 check_and_cleanup_lustre
 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true
diff --git a/lustre/tests/replay-dual.sh b/lustre/tests/replay-dual.sh
index cbce8ab..eb830dd 100755
--- a/lustre/tests/replay-dual.sh
+++ b/lustre/tests/replay-dual.sh
@@ -2,7 +2,7 @@
 
 set -e
 
-# bug number:  10124 
+# bug number:  10124
 ALWAYS_EXCEPT="15c   $REPLAY_DUAL_EXCEPT"
 
 SAVE_PWD=$PWD
@@ -255,7 +255,7 @@ test_13() {
 }
 run_test 13 "close resend timeout"
 
-test_14() {
+test_14a() {
     replay_barrier mds
     createmany -o $MOUNT1/$tfile- 25
     createmany -o $MOUNT2/$tfile-2- 1
@@ -264,16 +264,46 @@ test_14() {
 
     facet_failover mds
     # expect recovery to fail due to missing client 2
-    df $MOUNT && return 1
+    df $MOUNT1 && return 1
     sleep 1
 
-    # first 25 files should have been replayed 
+    # first 25 files should have been replayed
     unlinkmany $MOUNT1/$tfile- 25 || return 2
 
-    zconf_mount `hostname` $MOUNT2 || error "mount $MOUNT2 fail" 
+    zconf_mount `hostname` $MOUNT2 || error "mount $MOUNT2 fail"
+    return 0
+}
+run_test 14a "timeouts waiting for lost client during replay"
+
+test_14b() {
+    BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
+    #lfs setstripe --index=0 --count=1 $MOUNT1
+    mkdir -p $MOUNT1/$tdir
+    #lfs setstripe --index=0 --count=1 $MOUNT1/$tdir
+    replay_barrier mds
+    createmany -o $MOUNT1/$tfile- 5
+    echo "data" > $MOUNT2/$tdir/$tfile-2
+    createmany -o $MOUNT1/$tfile-3- 5
+    umount $MOUNT2
+
+    facet_failover mds
+    # expect recovery don't fail due to VBR
+    df $MOUNT1 || return 1
+
+    # first 25 files should have been replayed
+    unlinkmany $MOUNT1/$tfile- 5 || return 2
+    unlinkmany $MOUNT1/$tfile-3- 5 || return 3
+
+    zconf_mount `hostname` $MOUNT2 || error "mount $MOUNT2 fail"
+    # give ost time to process llogs
+    sleep 3
+    AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
+    log "before $BEFOREUSED, after $AFTERUSED"
+    [ $AFTERUSED -ne $BEFOREUSED ] && \
+        error "after $AFTERUSED > before $BEFOREUSED" && return 4
     return 0
 }
-run_test 14 "timeouts waiting for lost client during replay"
+run_test 14b "delete ost orphans if gap occured in objids due to VBR"
 
 test_15a() {	# was test_15
     replay_barrier mds
@@ -295,14 +325,14 @@ run_test 15a "timeout waiting for lost client during replay, 1 client completes"
 test_15c() {
     replay_barrier mds
     for ((i = 0; i < 2000; i++)); do
-	echo "data" > "$MOUNT2/${tfile}-$i" || error "create ${tfile}-$i failed"
+        echo "data" > "$MOUNT2/${tfile}-$i" || error "create ${tfile}-$i failed"
     done
-    
+
     umount $MOUNT2
     facet_failover mds
 
     df $MOUNT || return 1
-    
+
     zconf_mount `hostname` $MOUNT2 || error "mount $MOUNT2 fail"
     return 0
 }
@@ -396,7 +426,6 @@ test_20() { #16389
     rm $MOUNT1/a
     zconf_mount `hostname` $MOUNT2 || error "mount $MOUNT2 fail"
     TIER1=$((`date +%s` - BEFORE))
-    echo "First recovery time is $TIER1 sec"
     BEFORE=`date +%s`
     replay_barrier mds
     touch $MOUNT1/a
@@ -407,13 +436,29 @@ test_20() { #16389
     rm $MOUNT1/a
     zconf_mount `hostname` $MOUNT2 || error "mount $MOUNT2 fail"
     TIER2=$((`date +%s` - BEFORE))
-    echo "Second recovery time is $TIER2 sec"
     [ $TIER2 -ge $((TIER1 * 2)) ] && \
         error "recovery time is growing $TIER2 > $TIER1"
     return 0
 }
 run_test 20 "recovery time is not increasing"
 
+test_22() { #bug 18927
+    multiop_bg_pause $MOUNT1/$tfile O_c || return 1
+    pid1=$!
+    multiop_bg_pause $MOUNT2/$tfile O_c || return 2
+    pid2=$!
+    rm -f $MOUNT1/$tfile
+    replay_barrier mds
+    fail mds
+    kill -USR1 $pid1
+    wait $pid1 || return 3
+    kill -USR1 $pid2
+    wait $pid2 || return 4
+    [ -e $MOUNT1/$tfile ] && return 5
+    return 0
+}
+run_test 22 "double open|creat in replay with open orphan from two mntp"
+
 equals_msg `basename $0`: test complete, cleaning up
 SLEEP=$((`date +%s` - $NOW))
 [ $SLEEP -lt $TIMEOUT ] && sleep $SLEEP
diff --git a/lustre/tests/replay-ost-single.sh b/lustre/tests/replay-ost-single.sh
index b5d92d3..d3abacb 100755
--- a/lustre/tests/replay-ost-single.sh
+++ b/lustre/tests/replay-ost-single.sh
@@ -2,7 +2,6 @@
 
 set -e
 
-PTLDEBUG=${PTLDEBUG:--1}
 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
 SETUP=${SETUP:-""}
 CLEANUP=${CLEANUP:-""}
diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh
index 612ada3..94b7425 100755
--- a/lustre/tests/replay-single.sh
+++ b/lustre/tests/replay-single.sh
@@ -19,8 +19,8 @@ GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
 
 # Skip these tests
-# bug number:
-ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT"
+# bug number:  15587 18382
+ALWAYS_EXCEPT="40    48 $REPLAY_SINGLE_EXCEPT"
 
 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
     CONFIG_EXCEPTIONS="0b 42 47 61a 61c"
@@ -50,7 +50,7 @@ run_test 0a "empty replay"
 test_0b() {
     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
 
-    # this test attempts to trigger a race in the precreation code, 
+    # this test attempts to trigger a race in the precreation code,
     # and must run before any other objects are created on the filesystem
     fail ost1
     createmany -o $DIR/$tfile 20 || return 1
@@ -58,6 +58,15 @@ test_0b() {
 }
 run_test 0b "ensure object created after recover exists. (3284)"
 
+test_0c() {
+    replay_barrier mds
+    umount $DIR
+    facet_failover mds
+    zconf_mount `hostname` $DIR || error "mount fails"
+    df $DIR || error "post-failover df failed"
+}
+run_test 0c "expired recovery with no clients"
+
 test_1() {
     replay_barrier mds
     mcreate $DIR/$tfile
@@ -87,12 +96,13 @@ test_2b() {
 run_test 2b "touch"
 
 test_3a() {
+    local file=$DIR/$tfile
     replay_barrier mds
-    mcreate $DIR/$tfile
-    o_directory $DIR/$tfile
+    mcreate $file
+    openfile -f O_DIRECTORY $file
     fail mds
-    $CHECKSTAT -t file $DIR/$tfile || return 2
-    rm $DIR/$tfile
+    $CHECKSTAT -t file $file || return 2
+    rm $file
 }
 run_test 3a "replay failed open(O_DIRECTORY)"
 
@@ -125,11 +135,11 @@ test_4a() {	# was test_4
     replay_barrier mds
     for i in `seq 10`; do
         echo "tag-$i" > $DIR/$tfile-$i
-    done 
+    done
     fail mds
     for i in `seq 10`; do
       grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
-    done 
+    done
 }
 run_test 4a "|x| 10 open(O_CREAT)s"
 
@@ -141,17 +151,17 @@ test_4b() {
 }
 run_test 4b "|x| rm 10 files"
 
-# The idea is to get past the first block of precreated files on both 
+# The idea is to get past the first block of precreated files on both
 # osts, and then replay.
 test_5() {
     replay_barrier mds
     for i in `seq 220`; do
         echo "tag-$i" > $DIR/$tfile-$i
-    done 
+    done
     fail mds
     for i in `seq 220`; do
-      grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
-    done 
+      grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
+    done
     rm -rf $DIR/$tfile-*
     sleep 3
     # waiting for commitment of removal
@@ -176,7 +186,7 @@ test_6b() {
     replay_barrier mds
     rm -rf $DIR/$tdir
     fail mds
-    $CHECKSTAT -t dir $DIR/$tdir && return 1 || true 
+    $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
 }
 run_test 6b "|X| rmdir"
 
@@ -242,7 +252,7 @@ test_11() {
     mv $DIR/$tfile $DIR/$tfile-2
     replay_barrier mds
     echo "new" > $DIR/$tfile
-    grep new $DIR/$tfile 
+    grep new $DIR/$tfile
     grep old $DIR/$tfile-2
     fail mds
     grep new $DIR/$tfile || return 1
@@ -251,7 +261,7 @@ test_11() {
 run_test 11 "create open write rename |X| create-old-name read"
 
 test_12() {
-    mcreate $DIR/$tfile 
+    mcreate $DIR/$tfile
     multiop_bg_pause $DIR/$tfile o_tSc || return 3
     pid=$!
     rm -f $DIR/$tfile
@@ -267,9 +277,9 @@ run_test 12 "open, unlink |X| close"
 
 
 # 1777 - replay open after committed chmod that would make
-#        a regular open a failure    
+#        a regular open a failure
 test_13() {
-    mcreate $DIR/$tfile 
+    mcreate $DIR/$tfile
     multiop_bg_pause $DIR/$tfile O_wc || return 3
     pid=$!
     chmod 0 $DIR/$tfile
@@ -280,6 +290,7 @@ test_13() {
     wait $pid || return 1
 
     $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
+    rm $DIR/$tfile || return 4
     return 0
 }
 run_test 13 "open chmod 0 |x| write close"
@@ -314,7 +325,6 @@ test_15() {
 }
 run_test 15 "open(O_CREAT), unlink |X|  touch new, close"
 
-
 test_16() {
     replay_barrier mds
     mcreate $DIR/$tfile
@@ -402,7 +412,12 @@ test_20b() { # bug 10480
 
     fail mds                            # start orphan recovery
     df -P $DIR || df -P $DIR || true    # reconnect
-    wait_mds_recovery_done || error "MDS recovery not done"
+    wait_recovery_complete mds || error "MDS recovery not done"
+
+    # For interop with 2.0 only:
+    # FIXME just because recovery is done doesn't mean we've finished
+    # orphan cleanup.  Fake it with a sleep for now...
+    sleep 10
 
     AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
     log "before $BEFOREUSED, after $AFTERUSED"
@@ -648,10 +663,10 @@ run_test 32 "close() notices client eviction; close() after client eviction"
 # Abort recovery before client complete
 test_33a() {	# was test_33
     replay_barrier mds
-    createmany -o $DIR/$tfile-%d 100 
+    createmany -o $DIR/$tfile-%d 100
     fail_abort mds
     # this file should be gone, because the replay was aborted
-    $CHECKSTAT -t file $DIR/$tfile-* && return 3 
+    $CHECKSTAT -t file $DIR/$tfile-* && return 3
     unlinkmany $DIR/$tfile-%d 0 100
     return 0
 }
@@ -672,7 +687,7 @@ test_34() {
 }
 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
 
-# bug 2278 - generate one orphan on OST, then destroy it during recovery from llog 
+# bug 2278 - generate one orphan on OST, then destroy it during llog recovery
 test_35() {
     touch $DIR/$tfile
 
@@ -696,7 +711,7 @@ test_36() {
     checkstat $DIR/$tfile
     facet_failover mds
     cancel_lru_locks mdc
-    if dmesg | grep "unknown lock cookie"; then 
+    if dmesg | grep "unknown lock cookie"; then
 	echo "cancel after replay failed"
 	return 1
     fi
@@ -752,7 +767,7 @@ count_ost_writes() {
 
 #b=2477,2532
 test_40(){
-    $LCTL mark multiop $MOUNT/$tfile OS_c 
+    $LCTL mark multiop $MOUNT/$tfile OS_c
     multiop $MOUNT/$tfile OS_c  &
     PID=$!
     writeme -s $MOUNT/${tfile}-2 &
@@ -766,7 +781,7 @@ test_40(){
     sleep $TIMEOUT
     stat2=`count_ost_writes`
     echo "$stat1, $stat2"
-    if [ $stat1 -lt $stat2 ]; then 
+    if [ $stat1 -lt $stat2 ]; then
        echo "writes continuing during recovery"
        RC=0
     else
@@ -775,7 +790,7 @@ test_40(){
     fi
     echo "waiting for writeme $WRITE_PID"
     kill $WRITE_PID
-    wait $WRITE_PID 
+    wait $WRITE_PID
 
     echo "waiting for multiop $PID"
     wait $PID || return 2
@@ -785,7 +800,6 @@ test_40(){
 }
 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
 
-
 #b=2814
 # make sure that a read to one osc doesn't try to double-unlock its page just
 # because another osc is invalid.  trigger_group_io used to mistakenly return
@@ -800,7 +814,7 @@ test_41() {
 
     local f=$MOUNT/$tfile
     # make sure the start of the file is ost1
-    lfs setstripe $f -s $((128 * 1024)) -i 0 
+    lfs setstripe $f -s $((128 * 1024)) -i 0
     do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
     cancel_lru_locks osc
     # fail ost2 and read from ost1
@@ -822,7 +836,7 @@ test_42() {
     debugsave
     lctl set_param debug=-1
     facet_failover ost1
-    
+
     # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
     #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
     #[ $blocks_after -lt $blocks ] || return 1
@@ -857,7 +871,7 @@ test_44a() {	# was test_44
     [ "$mdcdev" ] || exit 2
 
     # adaptive timeouts slow this way down
-    if at_is_valid && at_is_enabled; then
+    if at_is_enabled; then
         at_max_saved=$(at_max_get mds)
         at_max_set 40 mds
     fi
@@ -902,7 +916,7 @@ test_45() {
     multiop_bg_pause $DIR/$tfile O_c || return 1
     pid=$!
 
-    # This will cause the CLOSE to fail before even 
+    # This will cause the CLOSE to fail before even
     # allocating a reply buffer
     $LCTL --device $mdcdev deactivate || return 4
 
@@ -932,7 +946,7 @@ run_test 46 "Don't leak file handle after open resend (3325)"
 test_47() { # bug 2824
     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
 
-    # create some files to make sure precreate has been done on all 
+    # create some files to make sure precreate has been done on all
     # OSTs. (just in case this test is run independently)
     createmany -o $DIR/$tfile 20  || return 1
 
@@ -942,10 +956,10 @@ test_47() { # bug 2824
     df $MOUNT || return 2
 
     # let the MDS discover the OST failure, attempt to recover, fail
-    # and recover again.  
+    # and recover again.
     sleep $((3 * TIMEOUT))
 
-    # Without 2824, this createmany would hang 
+    # Without 2824, this createmany would hang
     createmany -o $DIR/$tfile 20 || return 3
     unlinkmany $DIR/$tfile 20 || return 4
 
@@ -960,8 +974,8 @@ test_48() {
 
     replay_barrier mds
     createmany -o $DIR/$tfile 20  || return 1
-    # OBD_FAIL_OST_EROFS 0x216
     facet_failover mds
+    #define OBD_FAIL_OST_EROFS 0x216
     do_facet ost1 "lctl set_param fail_loc=0x80000216"
     df $MOUNT || return 2
 
@@ -971,11 +985,52 @@ test_48() {
 }
 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
 
+test_49a() {
+    multiop $DIR/$tfile O_c &
+    pid=$!
+    sleep 1
+    rm -rf $DIR/$tfile
+
+#define OBD_FAIL_MDS_ALL_REPLY_NET       0x122
+    do_facet mds "lctl set_param fail_loc=0x80000122"
+    kill -USR1 $pid
+    do_facet mds "lctl set_param fail_loc=0"
+
+    replay_barrier_nodf mds
+    fail mds
+
+    wait $pid || return 1
+    $CHECKSTAT -t file $DIR/$tfile && return 2
+    return 0
+}
+run_test 49a "mds fail after close reply is dropped: open|create "
+
+test_49c() {
+    touch $DIR/$tfile
+    multiop $DIR/$tfile o_c &
+    pid=$!
+    sleep 1
+    rm -rf $DIR/$tfile
+
+#define OBD_FAIL_MDS_ALL_REPLY_NET       0x122
+    do_facet mds "lctl set_param fail_loc=0x80000122"
+    kill -USR1 $pid
+    do_facet mds "lctl set_param fail_loc=0"
+
+    replay_barrier_nodf mds
+    fail mds
+
+    wait $pid || return 1
+    $CHECKSTAT -t file $DIR/$tfile && return 2
+    return 0
+}
+run_test 49c "mds fail after close reply is dropped: open"
+
 test_50() {
     local oscdev=`do_facet mds lctl get_param -n devices | grep ${ost1_svc}-osc | awk '{print $1}' | head -1`
     [ "$oscdev" ] || return 1
-    do_facet mds $LCTL --device $oscdev recover || return 2 
-    do_facet mds $LCTL --device $oscdev recover || return 3 
+    do_facet mds $LCTL --device $oscdev recover || return 2
+    do_facet mds $LCTL --device $oscdev recover || return 3
     # give the mds_lov_sync threads a chance to run
     sleep 5
 }
@@ -1009,10 +1064,10 @@ test_53a() {
     #define OBD_FAIL_MDS_CLOSE_NET 0x115
     do_facet mds "lctl set_param fail_loc=0x80000115"
     kill -USR1 $close_pid
-    cancel_lru_locks MDC # force the close
+    cancel_lru_locks mdc # force the close
     do_facet mds "lctl set_param fail_loc=0"
     mcreate $DIR/${tdir}-2/f || return 1
-    
+
     # close should still be here
     [ -d /proc/$close_pid ] || return 2
     replay_barrier_nodf mds
@@ -1041,7 +1096,7 @@ test_53b() {
 
     do_facet mds "lctl set_param fail_loc=0"
     kill -USR1 $close_pid
-    cancel_lru_locks MDC # force the close
+    cancel_lru_locks mdc # force the close
     wait $close_pid || return 1
     # open should still be here
     [ -d /proc/$open_pid ] || return 2
@@ -1064,14 +1119,16 @@ test_53c() {
     multiop $DIR/${tdir}-1/f O_c &
     close_pid=$!
 
+#define OBD_FAIL_MDS_REINT_NET           0x107
     do_facet mds "lctl set_param fail_loc=0x80000107"
     mcreate $DIR/${tdir}-2/f &
     open_pid=$!
     sleep 1
 
+#define OBD_FAIL_MDS_CLOSE_NET           0x115
     do_facet mds "lctl set_param fail_loc=0x80000115"
     kill -USR1 $close_pid
-    cancel_lru_locks MDC  # force the close
+    cancel_lru_locks mdc  # force the close
 
     replay_barrier_nodf mds
     fail_nodf mds
@@ -1097,13 +1154,13 @@ test_53d() {
     # give multiop a chance to open
     sleep 1
 
-    # define OBD_FAIL_MDS_CLOSE_NET_REP 0X138    
+#define OBD_FAIL_MDS_CLOSE_NET_REP       0x13b
     do_facet mds "lctl set_param fail_loc=0x8000013b"
     kill -USR1 $close_pid
-    cancel_lru_locks MDC  # force the close
+    cancel_lru_locks mdc  # force the close
     do_facet mds "lctl set_param fail_loc=0"
     mcreate $DIR/${tdir}-2/f || return 1
-    
+
     # close should still be here
     [ -d /proc/$close_pid ] || return 2
     replay_barrier_nodf mds
@@ -1129,14 +1186,14 @@ test_53e() {
     mcreate $DIR/${tdir}-2/f &
     open_pid=$!
     sleep 1
-    
+
     do_facet mds "lctl set_param fail_loc=0"
     kill -USR1 $close_pid
-    cancel_lru_locks MDC  # force the close
+    cancel_lru_locks mdc  # force the close
     wait $close_pid || return 1
     # open should still be here
     [ -d /proc/$open_pid ] || return 2
-    
+
     replay_barrier_nodf mds
     fail mds
     wait $open_pid || return 3
@@ -1155,14 +1212,16 @@ test_53f() {
         multiop $DIR/${tdir}-1/f O_c &
         close_pid=$!
 
+#define OBD_FAIL_MDS_REINT_NET_REP       0x119
         do_facet mds "lctl set_param fail_loc=0x80000119"
         mcreate $DIR/${tdir}-2/f &
         open_pid=$!
         sleep 1
 
+#define OBD_FAIL_MDS_CLOSE_NET_REP       0x13b
         do_facet mds "lctl set_param fail_loc=0x8000013b"
         kill -USR1 $close_pid
-        cancel_lru_locks MDC
+        cancel_lru_locks mdc
 
         replay_barrier_nodf mds
         fail_nodf mds
@@ -1186,14 +1245,16 @@ test_53g() {
         multiop $DIR/${tdir}-1/f O_c &
         close_pid=$!
 
+#define OBD_FAIL_MDS_REINT_NET_REP       0x119
         do_facet mds "lctl set_param fail_loc=0x80000119"
         mcreate $DIR/${tdir}-2/f &
         open_pid=$!
         sleep 1
 
+#define OBD_FAIL_MDS_CLOSE_NET           0x115
         do_facet mds "lctl set_param fail_loc=0x80000115"
         kill -USR1 $close_pid
-        cancel_lru_locks MDC # force the close
+        cancel_lru_locks mdc # force the close
 
         do_facet mds "lctl set_param fail_loc=0"
         replay_barrier_nodf mds
@@ -1217,14 +1278,16 @@ test_53h() {
     multiop $DIR/${tdir}-1/f O_c &
     close_pid=$!
 
+#define OBD_FAIL_MDS_REINT_NET           0x107
     do_facet mds "lctl set_param fail_loc=0x80000107"
     mcreate $DIR/${tdir}-2/f &
     open_pid=$!
     sleep 1
-    
+
+#define OBD_FAIL_MDS_CLOSE_NET_REP       0x13b
     do_facet mds "lctl set_param fail_loc=0x8000013b"
     kill -USR1 $close_pid
-    cancel_lru_locks MDC  # force the close
+    cancel_lru_locks mdc  # force the close
     sleep 1
 
     replay_barrier_nodf mds
@@ -1323,7 +1386,7 @@ test_58c() { # bug 16570
         [ x$VAL = x"bar1" ] || return 4
         rm -f $DIR/$tdir/$tfile
         rmdir $DIR/$tdir
-        zconf_umount `hostname` $MOUNT2
+       	zconf_umount `hostname` $MOUNT2
 }
 run_test 58c "resend/reconstruct setxattr op"
 
@@ -1356,7 +1419,7 @@ test_60() {
     fail mds
     unlinkmany $DIR/$tdir/$tfile-%d 100 100
     local no_ctxt=`dmesg | grep "No ctxt"`
-    [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery" 
+    [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
 }
 run_test 60 "test llog post recovery init vs llog unlink"
 
@@ -1366,12 +1429,12 @@ test_61a() {
 
     mkdir -p $DIR/$tdir
     createmany -o $DIR/$tdir/$tfile-%d 800
-    replay_barrier ost1 
-#   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221 
-    unlinkmany $DIR/$tdir/$tfile-%d 800 
+    replay_barrier ost1
+#   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
+    unlinkmany $DIR/$tdir/$tfile-%d 800
     do_facet ost "lctl set_param fail_loc=0x80000221"
     facet_failover ost1
-    sleep 10 
+    sleep 10
     fail ost1
     sleep 30
     do_facet ost "lctl set_param fail_loc=0x0"
@@ -1382,9 +1445,9 @@ run_test 61a "test race llog recovery vs llog cleanup"
 
 #test race  mds llog sync vs llog cleanup
 test_61b() {
-#   OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a 
+#   OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
     do_facet mds "lctl set_param fail_loc=0x8000013a"
-    facet_failover mds 
+    facet_failover mds
     sleep 10
     fail mds
     do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
@@ -1395,10 +1458,10 @@ run_test 61b "test race mds llog sync vs llog cleanup"
 test_61c() {
     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
 
-#   OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222 
-    touch $DIR/$tfile 
+#   OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
+    touch $DIR/$tfile
     do_facet ost "lctl set_param fail_loc=0x80000222"
-    rm $DIR/$tfile    
+    rm $DIR/$tfile
     sleep 10
     fail ost1
 }
@@ -1430,21 +1493,45 @@ run_test 62 "don't mis-drop resent replay"
 
 #Adaptive Timeouts (bug 3055)
 AT_MAX_SET=0
-# Suppose that all osts have the same at_max
-for facet in mds client ost; do
-    eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
-done
+
+at_cleanup () {
+    local var
+    local facet
+    local at_new
+
+    echo "Cleaning up AT ..."
+    if [ -n "$ATOLDBASE" ]; then
+        local at_history=$($LCTL get_param -n at_history)
+        do_facet mds "lctl set_param at_history=$at_history" || true
+        do_facet ost1 "lctl set_param at_history=$at_history" || true
+    fi
+
+    if [ $AT_MAX_SET -ne 0 ]; then
+        for facet in mds client ost; do
+            var=AT_MAX_SAVE_${facet}
+            echo restore AT on $facet to saved value ${!var}
+            at_max_set ${!var} $facet
+            at_new=$(at_max_get $facet)
+            echo Restored AT value on $facet $at_new
+            [ $at_new -eq ${!var} ] || \
+            error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
+        done
+    fi
+}
 
 at_start()
 {
     local at_max_new=600
-    if ! at_is_valid; then
-        skip "AT env is invalid"
-        return 1
-    fi
 
+    # Save at_max original values
+    local facet
+    if [ $AT_MAX_SET -eq 0 ]; then
+        # Suppose that all osts have the same at_max
+        for facet in mds client ost; do
+            eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
+        done
+    fi
     local at_max
-
     for facet in mds client ost; do
         at_max=$(at_max_get $facet)
         if [ $at_max -ne $at_max_new ]; then
@@ -1455,12 +1542,10 @@ at_start()
     done
 
     if [ -z "$ATOLDBASE" ]; then
-	local at_history=$(do_facet mds "find /sys/ -name at_history")
-	[ -z "$at_history" ] && skip "missing /sys/.../at_history " && return 1
-	ATOLDBASE=$(do_facet mds "cat $at_history")
+	ATOLDBASE=$(do_facet mds "lctl get_param -n at_history")
         # speed up the timebase so we can check decreasing AT
-	do_facet mds "echo 8 >> $at_history"
-	do_facet ost1 "echo 8 >> $at_history"
+        do_facet mds "lctl set_param at_history=8" || true
+        do_facet ost1 "lctl set_param at_history=8" || true
 
 	# sleep for a while to cool down, should be > 8s and also allow
 	# at least one ping to be sent. simply use TIMEOUT to be safe.
@@ -1488,7 +1573,7 @@ test_65a() #bug 3055
     createmany -o $DIR/$tfile 10 > /dev/null
     unlinkmany $DIR/$tfile 10 > /dev/null
     # check for log message
-    $LCTL dk | grep "Early reply #" || error "No early reply" 
+    $LCTL dk | grep "Early reply #" || error "No early reply"
     # client should show REQ_DELAY estimates
     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
     sleep 9
@@ -1555,7 +1640,7 @@ test_66a() #bug 3055
     CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
     WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
     echo "Current MDT timeout $CUR, worst $WORST"
-    [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST" 
+    [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
 }
 run_test 66a "AT: verify MDT service time adjusts with no early replies"
 
@@ -1573,7 +1658,7 @@ test_66b() #bug 3055
     CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
     WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
     echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
-    [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG" 
+    [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
 }
 run_test 66b "AT: verify net latency adjusts"
 
@@ -1661,24 +1746,7 @@ test_68 () #bug 13813
 }
 run_test 68 "AT: verify slowing locks"
 
-if [ -n "$ATOLDBASE" ]; then
-    at_history=$(do_facet mds "find /sys/ -name at_history")
-    do_facet mds "echo $ATOLDBASE >> $at_history" || true
-    do_facet ost1 "echo $ATOLDBASE >> $at_history" || true
-fi
-
-if [ $AT_MAX_SET -ne 0 ]; then
-    for facet in mds client ost; do
-        var=AT_MAX_SAVE_${facet}
-        echo restore AT on $facet to saved value ${!var}
-        at_max_set ${!var} $facet
-        AT_NEW=$(at_max_get $facet)
-        echo Restored AT value on $facet $AT_NEW 
-        [ $AT_NEW -ne ${!var} ] && \
-            error "$facet : AT value was not restored SAVED ${!var} NEW $AT_NEW"
-    done
-fi
-
+at_cleanup
 # end of AT tests includes above lines
 
 # start multi-client tests
@@ -1699,7 +1767,7 @@ test_70a () {
 				error "dd failed on $CLIENT"
 	done
 
-	local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/') 
+	local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
 	for C in ${CLIENTS//,/ }; do
 		do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
 			error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
@@ -1711,37 +1779,238 @@ test_70a () {
 run_test 70a "check multi client t-f"
 
 test_70b () {
-	[ -z "$CLIENTS" ] && \
-		{ skip "Need two or more clients." && return; }
-	[ $CLIENTCOUNT -lt 2 ] && \
-		{ skip "Need two or more clients, have $CLIENTCOUNT" && return; }
+	local clients=${CLIENTS:-$HOSTNAME}
 
-	zconf_mount_clients $CLIENTS $DIR
+	zconf_mount_clients $clients $DIR
 	
-	local duration=120
+	local duration=300
 	[ "$SLOW" = "no" ] && duration=60
 	local cmd="rundbench 1 -t $duration"
 	local PID=""
-	do_nodes $CLIENTS "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
+	do_nodes $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
 		PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
 		DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
 		LCTL=$LCTL $cmd" &
 	PID=$!
 	log "Started rundbench load PID=$PID ..."
 
-	sleep $((duration / 4))
-	replay_barrier mds 
-	sleep 3 # give clients a time to do operations
-
-	log "$TESTNAME fail mds 1"
-	fail mds
+	ELAPSED=0
+	NUM_FAILOVERS=0
+	START_TS=$(date +%s)
+	CURRENT_TS=$START_TS
+	while [ $ELAPSED -lt $duration ]; do
+		sleep 1
+		replay_barrier mds
+		sleep 1 # give clients a time to do operations
+		# Increment the number of failovers
+		NUM_FAILOVERS=$((NUM_FAILOVERS+1))
+		log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
+		facet_failover mds
+		CURRENT_TS=$(date +%s)
+		ELAPSED=$((CURRENT_TS - START_TS))
+	done
 
 	wait $PID || error "rundbench load on $CLIENTS failed!"
-
 }
 run_test 70b "mds recovery; $CLIENTCOUNT clients"
 # end multi-client tests
 
+# vbr export handling
+test_71a() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    UUID=$(lctl dl | awk '/mdc.*-mdc-/ { print $5 }')
+    echo "Client UUID is $UUID"
+    replay_barrier mds
+    umount $DIR
+    facet_failover mds
+    zconf_mount `hostname` $DIR || error "mount fails"
+    df $DIR || error "post-failover df failed"
+    do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" || \
+        error "no delayed exports"
+    OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
+    NEW_AGE=10
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
+    sleep $((NEW_AGE + 2))
+    do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep \"$UUID.*EXPIRED\"" || \
+        error "exports didn't expire"
+    do_facet mds "lctl set_param mds.${mds_svc}.evict_client=$UUID"
+    do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" && \
+        error "Export wasn't removed manually"
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
+    return 0;
+}
+run_test 71a "lost client export is kept"
+
+test_71b() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    FAKE_NUM=10
+    create_fake_exports mds $FAKE_NUM
+    NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+    [ $NUM -eq 0 ] && error "no fake exports $NUM - $FAKE_NUM"
+    OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
+    NEW_AGE=10
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
+    sleep $((NEW_AGE + 2))
+    EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
+    [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
+    do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
+    do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep EXPIRED" && \
+        error "Exports weren't flushed"
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
+    return 0;
+}
+run_test 71b "stale exports are expired, lctl flushes them"
+
+test_71c() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    FAKE_NUM=10
+    create_fake_exports mds $FAKE_NUM
+    NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+    [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
+    OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
+    NEW_AGE=10
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
+    sleep $((NEW_AGE + 2))
+    EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
+    [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
+
+    umount $DIR
+    zconf_mount `hostname` $DIR || error "mount fails"
+
+    NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+    [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
+    do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
+    return 0;
+}
+run_test 71c "stale exports are expired, new client connection flush them"
+
+test_71d() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    FAKE_NUM=10
+    create_fake_exports mds $FAKE_NUM
+    NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+    [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
+    OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
+    NEW_AGE=10
+    do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$NEW_AGE"
+    sleep $((NEW_AGE + 2))
+    EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
+    [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
+
+    fail mds
+
+    FAIL_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
+    [ $FAIL_AGE -eq $NEW_AGE ] || error "new age wasn't set after recovery"
+    NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
+    [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
+    do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$OLD_AGE"
+    return 0;
+}
+run_test 71d "expired exports, server init removes them, conf_param works"
+
+# end vbr exports tests
+
+test_72() { #bug 16711
+    replay_barrier mds
+    multiop_bg_pause $DIR/$tfile O_c || return 4
+    pid=$!
+#define OBD_FAIL_TGT_REPLAY_DELAY 0x709
+    do_facet mds "lctl set_param fail_loc=0x80000709"
+    fail mds
+    kill -USR1 $pid || return 1
+    wait $pid || return 2
+    $CHECKSTAT -t file $DIR/$tfile || return 3
+}
+run_test 72 "target_finish_recovery vs process_recovery_queue race"
+
+test_73a() {
+    multiop_bg_pause $DIR/$tfile O_tSc || return 3
+    pid=$!
+    rm -f $DIR/$tfile
+
+    replay_barrier mds
+#define OBD_FAIL_LDLM_ENQUEUE       0x302
+    do_facet mds "lctl set_param fail_loc=0x80000302"
+    fail mds
+    kill -USR1 $pid
+    wait $pid || return 1
+    [ -e $DIR/$tfile ] && return 2
+    return 0
+}
+run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
+
+test_73b() {
+    multiop_bg_pause $DIR/$tfile O_tSc || return 3
+    pid=$!
+    rm -f $DIR/$tfile
+
+    replay_barrier mds
+#define OBD_FAIL_LDLM_REPLY       0x30c
+    do_facet mds "lctl set_param fail_loc=0x8000030c"
+    fail mds
+    kill -USR1 $pid
+    wait $pid || return 1
+    [ -e $DIR/$tfile ] && return 2
+    return 0
+}
+run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
+
+test_73c() {
+    multiop_bg_pause $DIR/$tfile O_tSc || return 3
+    pid=$!
+    rm -f $DIR/$tfile
+
+    replay_barrier mds
+#define OBD_FAIL_TGT_LAST_REPLAY       0x710
+    do_facet mds "lctl set_param fail_loc=0x80000710"
+    fail mds
+    kill -USR1 $pid
+    wait $pid || return 1
+    [ -e $DIR/$tfile ] && return 2
+    return 0
+}
+run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
+
+test_80a() {
+    do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
+
+    replay_barrier ost1
+    lfs setstripe -i 0 -c 1 $DIR/$tfile
+    dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
+    cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
+    cancel_lru_locks osc
+    fail ost1
+    dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
+    cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
+    if [ $cksum != $cksum2 ] ; then
+	error "New checksum $cksum2 does not match original $cksum"
+    fi
+}
+run_test 80a "write replay"
+
+test_80b() {
+    do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
+
+    replay_barrier ost1
+    lfs setstripe -i 0 -c 1 $DIR/$tfile
+    dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
+    sleep 1 # Give it a chance to flush dirty data
+    echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
+    cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
+    cancel_lru_locks osc
+    fail ost1
+    dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
+    cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
+    if [ $cksum != $cksum2 ] ; then
+	error "New checksum $cksum2 does not match original $cksum"
+    fi
+}
+run_test 80b "write replay with changed data (checksum resend)"
+
 test_81a() {
     mkdir -p $DIR/$tdir
     createmany -o $DIR/$tdir/$tfile- 10 || return 1
@@ -1762,6 +2031,51 @@ test_81b() {
 }
 run_test 81b "fail log_add during unlink recovery"
 
+test_82() { #bug 18927
+    multiop_bg_pause $DIR/$tfile O_c || return 1
+    pid1=$!
+    multiop_bg_pause $DIR/$tfile o:O_CREAT:O_RDONLY:_c || return 2
+    pid2=$!
+    rm -f $DIR/$tfile
+    replay_barrier mds
+    fail mds
+    kill -USR1 $pid1
+    wait $pid1 || return 3
+    kill -USR1 $pid2
+    wait $pid2 || return 4
+    [ -e $DIR/$tfile ] && return 5
+    return 0
+}
+run_test 82 "second open|creat in replay with open orphan"
+
+test_83() { #bug 19224
+#define OBD_FAIL_MDS_SPLIT_OPEN  0x142
+    do_facet mds "lctl set_param fail_loc=0x80000142"
+    # open will sleep after first transaction
+    touch $DIR/$tfile &
+    PID=$!
+    sleep 2
+    # set barrier between open transactions
+    replay_barrier_nodf mds
+    createmany -o $DIR/$tfile- 10
+    # open should finish now
+    wait $PID || return 1
+    fail mds
+    rm $DIR/$tfile || return 2
+    unlinkmany $DIR/$tfile- 10 || return 3
+    return 0
+}
+run_test 83 "open replay with barrier between transactions"
+
+test_84() {
+#define OBD_FAIL_OBD_FAIL_MDS_SPLIT_OPEN 0x142
+    do_facet mds "lctl set_param fail_loc=0x80000142"
+    createmany -o $DIR/$tfile- 1 &
+    PID=$!
+    mds_evict_client
+    wait $PID || true
+}
+run_test 84 "stale open during export disconnect"
 
 equals_msg `basename $0`: test complete, cleaning up
 check_and_cleanup_lustre
diff --git a/lustre/tests/replay-vbr.sh b/lustre/tests/replay-vbr.sh
new file mode 100644
index 0000000..95af88b
--- /dev/null
+++ b/lustre/tests/replay-vbr.sh
@@ -0,0 +1,723 @@
+#!/bin/bash
+
+set -e
+
+# bug number: 18946
+ALWAYS_EXCEPT="2 3c 4b 4c 10 $REPLAY_VBR_EXCEPT"
+
+SAVE_PWD=$PWD
+PTLDEBUG=${PTLDEBUG:--1}
+LUSTRE=${LUSTRE:-`dirname $0`/..}
+SETUP=${SETUP:-""}
+CLEANUP=${CLEANUP:-""}
+. $LUSTRE/tests/test-framework.sh
+
+init_test_env $@
+
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+
+[ -n "$CLIENTS" ] || { skip "Need two or more clients" && exit 0; }
+[ $CLIENTCOUNT -ge 2 ] || \
+    { skip "Need two or more clients, have $CLIENTCOUNT" && exit 0; }
+remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
+
+[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
+
+
+[ ! "$NAME" = "ncli" ] && ALWAYS_EXCEPT="$ALWAYS_EXCEPT"
+[ "$NAME" = "ncli" ] && MOUNT_2=""
+MOUNT_2=""
+build_test_filter
+
+check_and_setup_lustre
+rm -rf $DIR/[df][0-9]*
+
+[ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
+
+[ "$CLIENTS" ] && zconf_umount_clients $CLIENTS $DIR
+
+test_1() {
+    echo "mount client $CLIENT1,$CLIENT2..."
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    do_node $CLIENT2 mkdir -p $DIR/$tdir
+    replay_barrier mds
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 1
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
+    zconf_umount $CLIENT2 $DIR
+
+    facet_failover mds
+    # recovery shouldn't fail due to missing client 2
+    do_node $CLIENT1 df $DIR || return 1
+
+    # All 50 files should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
+
+    zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
+    [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
+
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 1 "VBR: client during replay doesn't affect another one"
+
+test_2() {
+    #ls -al $DIR/$tdir/$tfile
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    do_node $CLIENT2 mkdir -p $DIR/$tdir
+    replay_barrier mds
+    do_node $CLIENT2 mcreate $DIR/$tdir/$tfile
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
+    zconf_umount $CLIENT2 $DIR
+
+    facet_failover mds
+    # recovery shouldn't fail due to missing client 2
+    do_node $CLIENT1 df $DIR || return 1
+
+    # All 50 files should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
+
+    do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile && return 4
+
+    zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
+
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 2 "VBR: lost data due to missed REMOTE client during replay"
+
+test_3a() {
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    #make sure the time will change
+    do_facet mds "$LCTL set_param mds.${mds_svc}.atime_diff=0" || return
+    do_node $CLIENT1 touch $DIR/$tfile
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
+    sleep 1
+    replay_barrier mds
+    #change time
+    do_node $CLIENT2 touch $DIR/$tfile
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
+    #another change
+    do_node $CLIENT1 touch $DIR/$tfile
+    #remove file
+    do_node $CLIENT2 rm $DIR/$tfile
+    zconf_umount $CLIENT2 $DIR
+
+    facet_failover mds
+    # recovery shouldn't fail due to missing client 2
+    do_node $CLIENT1 df $DIR || return 1
+    do_node $CLIENT1 $CHECKSTAT $DIR/$tfile && return 2
+
+    zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
+
+    zconf_umount_clients $CLIENTS $DIR
+
+    return 0
+}
+run_test 3a "VBR: setattr of time/size doesn't change version"
+
+test_3b() {
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    #make sure the time will change
+    do_facet mds "$LCTL set_param mds.${mds_svc}.atime_diff=0" || return
+    do_facet mds "$LCTL set_param mds.${mds_svc}.sync_permission=0" || return
+    do_node $CLIENT1 touch $DIR/$tfile
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
+    sleep 1
+    replay_barrier mds
+    #change mode
+    do_node $CLIENT2 chmod +x $DIR/$tfile
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
+    #abother chmod
+    do_node $CLIENT1 chmod -x $DIR/$tfile
+    zconf_umount $CLIENT2 $DIR
+
+    facet_failover mds
+    # recovery should fail due to missing client 2
+    do_node $CLIENT1 df $DIR && return 1
+
+    do_node $CLIENT1 $CHECKSTAT -p 0755 $DIR/$tfile && return 2
+    zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
+
+    zconf_umount_clients $CLIENTS $DIR
+
+    return 0
+}
+run_test 3b "VBR: setattr of permissions changes version"
+
+test_3c() {
+    [ "$FAILURE_MODE" = HARD ] || \
+        { skip "The HARD failure is needed" && return 0; }
+
+    [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    # check that permission changes are synced
+    do_facet mds "$LCTL set_param mds.${mds_svc}.sync_permission=1"
+
+    do_node $CLIENT1 mkdir -p $DIR/d3c/sub || error
+    #chown -R $RUNAS_ID $MOUNT1/d3
+    do_node $CLIENT1 ls -la $DIR/d3c
+
+    # only HARD failure will work as we use sync operation
+    replay_barrier mds
+    do_node $CLIENT2 mcreate $DIR/d3c/$tfile-2
+    #set permissions
+    do_node $CLIENT1 chmod 0700 $UID $DIR/d3c
+    #secret file
+    do_node $CLIENT1 mcreate $DIR/d3c/sub/$tfile
+    do_node $CLIENT1 echo "Top Secret" > $DIR/d3c/sub/$tfile
+    #check user can't access new file
+    do_node $CLIENT2 $RUNAS ls $DIR/d3c && return 3
+    do_node $CLIENT1 $RUNAS ls $DIR/d3c && return 4
+    do_node $CLIENT1 $RUNAS cat $DIR/d3c/sub/$tfile && return 5
+
+    zconf_umount $CLIENT2 $DIR
+
+    facet_failover mds
+    # recovery shouldn't fail due to missing client 2
+    do_node $CLIENT1 df $DIR || return 1
+    sleep 1
+
+    zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
+    do_node $CLIENT1 $RUNAS cat $DIR/d3c/sub/$tfile && return 6
+    do_node $CLIENT2 $RUNAS cat $DIR/d3c/sub/$tfile && return 7
+    do_facet mds "$LCTL set_param mds.${mds_svc}.sync_permission=0"
+
+    return 0
+}
+run_test 3c "VBR: permission dependency failure"
+
+vbr_deactivate_client() {
+    local client=$1
+    echo "Deactivating client $client";
+    do_node $client "sysctl -w lustre.fail_loc=0x50d"
+}
+
+vbr_activate_client() {
+    local client=$1
+    echo "Activating client $client";
+    do_node $client "sysctl -w lustre.fail_loc=0x0"
+}
+
+remote_server ()
+{
+    local client=$1
+    [ -z "$(do_node $client lctl dl | grep mdt)" ] && \
+    [ -z "$(do_node $client lctl dl | grep ost)" ]
+}
+
+test_4a() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    do_node $CLIENT2 mkdir -p $DIR/$tdir
+    replay_barrier mds
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
+    vbr_deactivate_client $CLIENT2
+
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 1
+
+    # All 50 files should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
+
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 4
+    # All 25 files from client2 should have been replayed
+    do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
+
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 4a "fail MDS, delayed recovery"
+
+test_4b() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    replay_barrier mds
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
+    vbr_deactivate_client $CLIENT2
+
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 1
+
+    # create another set of files
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
+
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 2
+
+    # All files from should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 4
+    do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
+
+    zconf_umount_clients $CLIENTS $DIR
+}
+run_test 4b "fail MDS, normal operation, delayed open recovery"
+
+test_4c() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    replay_barrier mds
+    do_node $CLIENT1 createmany -m $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -m $DIR/$tdir/$tfile-2- 25
+    vbr_deactivate_client $CLIENT2
+
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 1
+
+    # create another set of files
+    do_node $CLIENT1 createmany -m $DIR/$tfile-3- 25
+
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 2
+
+    # All files from should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 4
+    do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
+
+    zconf_umount_clients $CLIENTS $DIR
+}
+run_test 4c "fail MDS, normal operation, delayed recovery"
+
+test_5a() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    replay_barrier mds
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -o $DIR/$tfile-2- 1
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 1
+    vbr_deactivate_client $CLIENT2
+
+    facet_failover mds
+    do_node $CLIENT1 df $DIR && return 1
+
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 2
+
+    # First 25 files should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
+    # Third file is failed due to missed client2
+    do_node $CLIENT1 $CHECKSTAT $DIR/$tfile-3-0 && error "$tfile-3-0 exists"
+    # file from client2 should exists
+    do_node $CLIENT2 unlinkmany $DIR/$tfile-2- 1 || return 4
+
+    zconf_umount_clients $CLIENTS $DIR
+}
+run_test 5a "fail MDS, delayed recovery should fail"
+
+test_5b() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    replay_barrier mds
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -o $DIR/$tfile-2- 1
+    vbr_deactivate_client $CLIENT2
+
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 1
+    do_node $CLIENT1 $CHECKSTAT $DIR/$tfile-2-0 && error "$tfile-2-0 exists"
+
+    # create another set of files
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
+
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR && return 4
+    # file from client2 should fail
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile-2-0 && error "$tfile-2-0 exists"
+
+    # All 50 files from client 1 should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
+
+    zconf_umount_clients $CLIENTS $DIR
+}
+run_test 5b "fail MDS, normal operation, delayed recovery should fail"
+
+test_6a() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    do_node $CLIENT2 mkdir -p $DIR/$tdir
+    replay_barrier mds
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
+    vbr_deactivate_client $CLIENT2
+
+    facet_failover mds
+    # replay only 5 requests
+    do_node $CLIENT2 "sysctl -w lustre.fail_val=5"
+#define OBD_FAIL_PTLRPC_REPLAY        0x50e
+    do_node $CLIENT2 "sysctl -w lustre.fail_loc=0x2000050e"
+    do_node $CLIENT2 df $DIR
+    # vbr_activate_client $CLIENT2
+    # need way to know that client stops replays
+    sleep 5
+
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 1
+
+    # All files should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
+    do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
+
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 6a "fail MDS, delayed recovery, fail MDS"
+
+test_7a() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    do_node $CLIENT2 mkdir -p $DIR/$tdir
+    replay_barrier mds
+    do_node $CLIENT1 createmany -o $DIR/$tfile- 25
+    do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
+    do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
+    vbr_deactivate_client $CLIENT2
+
+    facet_failover mds
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 4
+
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 1
+
+    # All files should have been replayed
+    do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
+    do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
+    do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
+
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 7a "fail MDS, delayed recovery, fail MDS"
+
+rmultiop_start() {
+    local client=$1
+    local file=$2
+
+    # We need to run do_node in bg, because pdsh does not exit
+    # if child process of run script exists.
+    # I.e. pdsh does not exit when runmultiop_bg_pause exited,
+    # because of multiop_bg_pause -> $MULTIOP_PROG &
+    # By the same reason we need sleep a bit after do_nodes starts 
+    # to let runmultiop_bg_pause start muliop and
+    # update /tmp/multiop_bg.pid ;
+    # The rm /tmp/multiop_bg.pid guarantees here that 
+    # we have the updated by runmultiop_bg_pause
+    # /tmp/multiop_bg.pid file
+
+    local pid_file=$TMP/multiop_bg.pid.$$
+    do_node $client "rm -f $pid_file && MULTIOP_PID_FILE=$pid_file LUSTRE= runmultiop_bg_pause $file O_tSc" & 
+    local pid=$!
+    sleep 3
+    local multiop_pid
+    multiop_pid=$(do_node $client cat $pid_file)
+    [ -n "$multiop_pid" ] || error "$client : Can not get multiop_pid from $pid_file "
+    eval export $(client_var_name $client)_multiop_pid=$multiop_pid
+    eval export $(client_var_name $client)_do_node_pid=$pid
+    local var=$(client_var_name $client)_multiop_pid
+    echo client $client multiop_bg started multiop_pid=${!var}
+    return $?
+}
+
+rmultiop_stop() {
+    local client=$1
+    local multiop_pid=$(client_var_name $client)_multiop_pid
+    local do_node_pid=$(client_var_name $client)_do_node_pid
+
+    echo "Stopping multiop_pid=${!multiop_pid} (kill ${!multiop_pid} on $client)"
+    do_node $client kill -USR1 ${!multiop_pid}
+
+    wait ${!do_node_pid} || true
+}
+
+test_8a() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    rmultiop_start $CLIENT2 $DIR/$tfile || return 1
+    do_node $CLIENT2 rm -f $DIR/$tfile
+    replay_barrier mds
+    rmultiop_stop $CLIENT2 || return 2
+
+    vbr_deactivate_client $CLIENT2
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 3
+    #client1 is back and will try to open orphan
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 4
+
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 8a "orphans are kept until delayed recovery"
+
+test_8b() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    rmultiop_start $CLIENT2 $DIR/$tfile || return 1
+    replay_barrier mds
+    do_node $CLIENT1 rm -f $DIR/$tfile
+
+    vbr_deactivate_client $CLIENT2
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 2
+    #client1 is back and will try to open orphan
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 3
+
+    rmultiop_stop $CLIENT2 || return 1
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 8b "open1 | unlink2 X delayed_replay1, close1"
+
+test_8c() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    rmultiop_start $CLIENT2 $DIR/$tfile || return 1
+    replay_barrier mds
+    do_node $CLIENT1 rm -f $DIR/$tfile
+    rmultiop_stop $CLIENT2 || return 2
+
+    vbr_deactivate_client $CLIENT2
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 3
+    #client1 is back and will try to open orphan
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 4
+
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 8c "open1 | unlink2, close1 X delayed_replay1"
+
+test_8d() {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    remote_server $CLIENT2 || \
+        { skip "Client $CLIENT2 is on the server node" && return 0; }
+
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    rmultiop_start $CLIENT1 $DIR/$tfile || return 1
+    rmultiop_start $CLIENT2 $DIR/$tfile || return 2
+    replay_barrier mds
+    do_node $CLIENT1 rm -f $DIR/$tfile
+    rmultiop_stop $CLIENT2 || return 3
+    rmultiop_stop $CLIENT1 || return 4
+
+    vbr_deactivate_client $CLIENT2
+    facet_failover mds
+    do_node $CLIENT1 df $DIR || return 6
+
+    #client1 is back and will try to open orphan
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 8
+
+    do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 8d "open1, open2 | unlink2, close1, close2 X delayed_replay1"
+
+test_8e() {
+    zconf_mount $CLIENT1 $DIR
+    zconf_mount $CLIENT2 $DIR
+
+    do_node $CLIENT1 mcreate $DIR/$tfile
+    do_node $CLIENT1 mkdir $DIR/$tfile-2
+    replay_barrier mds
+    # missed replay from client1 will lead to recovery by versions
+    do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
+    do_node $CLIENT2 rm $DIR/$tfile || return 1
+    do_node $CLIENT2 touch $DIR/$tfile || return 2
+
+    zconf_umount $CLIENT1 $DIR
+    facet_failover mds
+    do_node $CLIENT2 df $DIR || return 6
+
+    do_node $CLIENT2 rm $DIR/$tfile || error "$tfile doesn't exists"
+    zconf_umount_clients $CLIENTS $DIR
+    return 0
+}
+run_test 8e "create | unlink, create shouldn't fail"
+
+test_8f() {
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    do_node $CLIENT1 touch $DIR/$tfile
+    do_node $CLIENT1 mkdir $DIR/$tfile-2
+    replay_barrier mds
+    # missed replay from client1 will lead to recovery by versions
+    do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
+    do_node $CLIENT2 rm -f $DIR/$tfile || return 1
+    do_node $CLIENT2 mcreate $DIR/$tfile || return 2
+
+    zconf_umount $CLIENT1 $DIR
+    facet_failover mds
+    do_node $CLIENT2 df $DIR || return 6
+
+    do_node $CLIENT2 rm $DIR/$tfile || error "$tfile doesn't exists"
+    zconf_umount $CLIENT2 $DIR
+    return 0
+}
+run_test 8f "create | unlink, create shouldn't fail"
+
+test_8g() {
+    zconf_mount_clients $CLIENT1 $DIR
+    zconf_mount_clients $CLIENT2 $DIR
+
+    do_node $CLIENT1 touch $DIR/$tfile
+    do_node $CLIENT1 mkdir $DIR/$tfile-2
+    replay_barrier mds
+    # missed replay from client1 will lead to recovery by versions
+    do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
+    do_node $CLIENT2 rm -f $DIR/$tfile || return 1
+    do_node $CLIENT2 mkdir $DIR/$tfile || return 2
+
+    zconf_umount $CLIENT1 $DIR
+    facet_failover mds
+    do_node $CLIENT2 df $DIR || return 6
+
+    do_node $CLIENT2 rmdir $DIR/$tfile || error "$tfile doesn't exists"
+    zconf_umount $CLIENT2 $DIR
+    return 0
+}
+run_test 8g "create | unlink, create shouldn't fail"
+
+test_10 () {
+    delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
+
+    [ -z "$DBENCH_LIB" ] && skip "DBENCH_LIB is not set" && return 0
+
+    zconf_mount_clients $CLIENTS $DIR
+
+    local duration="-t 60"
+    local cmd="rundbench 1 $duration "
+    local PID=""
+    for CLIENT in ${CLIENTS//,/ }; do
+        $PDSH $CLIENT "set -x; PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:${DBENCH_LIB} DBENCH_LIB=${DBENCH_LIB} $cmd" &
+        PID=$!
+        echo $PID >pid.$CLIENT
+        echo "Started load PID=`cat pid.$CLIENT`"
+    done
+
+    replay_barrier mds
+    sleep 3 # give clients a time to do operations
+
+    vbr_deactivate_client $CLIENT2
+
+    log "$TESTNAME fail mds 1"
+    fail mds
+
+# wait for client to reconnect to MDS
+    sleep $TIMEOUT
+
+    vbr_activate_client $CLIENT2
+    do_node $CLIENT2 df $DIR || return 4
+
+    for CLIENT in ${CLIENTS//,/ }; do
+        PID=`cat pid.$CLIENT`
+        wait $PID
+        rc=$?
+        echo "load on ${CLIENT} returned $rc"
+    done
+
+    zconf_umount_clients $CLIENTS $DIR
+}
+run_test 10 "mds version recovery; $CLIENTCOUNT clients"
+
+equals_msg `basename $0`: test complete, cleaning up
+#SLEEP=$((`date +%s` - $NOW))
+#[ $SLEEP -lt $TIMEOUT ] && sleep $SLEEP
+check_and_cleanup_lustre
+[ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true
diff --git a/lustre/tests/run_IOR.sh b/lustre/tests/run_IOR.sh
new file mode 100755
index 0000000..6da7f54
--- /dev/null
+++ b/lustre/tests/run_IOR.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+set -x
+
+TMP=${TMP:-/tmp}
+
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-mds-scale}
+LOG=${TESTSUITELOG}_$(basename $0)-$(hostname)
+DEBUGLOG=${LOG}.debug
+
+mkdir -p ${LOG%/*}
+
+rm -f $LOG $DEBUGLOG
+exec 2>$DEBUGLOG
+
+. $(dirname $0)/functions.sh
+
+IOR=${IOR:-"$(which IOR)"}
+
+assert_env MOUNT END_RUN_FILE LOAD_PID_FILE IOR
+
+trap signaled TERM
+
+# if MACHINEFILE set and exists -- use it
+if [ -z $MACHINEFILE ] || [ ! -e $MACHINEFILE ]; then
+    MACHINEFILE=$TMP/$(basename $0)-$(hostname).machines
+    echo $(hostname) >$MACHINEFILE
+fi
+
+THREADS_PER_CLIENT=${THREADS_PER_CLIENT:-3}
+NUM_CLIENTS=$(cat $MACHINEFILE | wc -l)
+
+# recovery-*-scale scripts use this to signal the client loads to die
+echo $$ >$LOAD_PID_FILE
+
+TESTDIR=${TESTDIR:-$MOUNT/d0.ior-$(hostname)}
+
+CONTINUE=true
+while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
+    echoerr "$(date +'%F %H:%M:%S'): IOR run starting"
+    mkdir -p $TESTDIR
+    # need this only if TESTDIR is not default
+    chmod -R 777 $TESTDIR
+
+    mpi_run -np $((NUM_CLIENTS * THREADS_PER_CLIENT)) -machinefile ${MACHINEFILE} \
+        $IOR -a POSIX -b 1g -o $TESTDIR/IOR-file -s 1 -t 1m -v -w -r 1>$LOG &
+    load_pid=$!
+    wait $load_pid
+    if [ ${PIPESTATUS[0]} -eq 0 ]; then
+	echoerr "$(date +'%F %H:%M:%S'): IOR succeeded"
+	cd $TMP
+	rm -rf $TESTDIR
+	echoerr "$(date +'%F %H:%M:%S'): IOR run finished"
+    else
+	echoerr "$(date +'%F %H:%M:%S'): IOR failed"
+	if [ -z "$ERRORS_OK" ]; then
+	    echo $(hostname) >> $END_RUN_FILE
+	fi
+	if [ $BREAK_ON_ERROR ]; then
+	    # break
+            CONTINUE=false
+	fi
+    fi
+done
+
+echoerr "$(date +'%F %H:%M:%S'): IOR run exiting"
diff --git a/lustre/tests/run_dbench.sh b/lustre/tests/run_dbench.sh
new file mode 100755
index 0000000..f1520e8
--- /dev/null
+++ b/lustre/tests/run_dbench.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+set -x
+
+TMP=${TMP:-/tmp}
+
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-mds-scale}
+LOG=${TESTSUITELOG}_$(basename $0)-$(hostname)
+DEBUGLOG=${LOG}.debug
+
+mkdir -p ${LOG%/*}
+
+rm -f $LOG $DEBUGLOG
+exec 2>$DEBUGLOG
+
+. $(dirname $0)/functions.sh
+
+assert_env MOUNT END_RUN_FILE LOAD_PID_FILE
+
+trap signaled TERM
+
+# recovery-*-scale scripts use this to signal the client loads to die
+echo $$ >$LOAD_PID_FILE
+
+TESTDIR=$MOUNT/d0.dbench-$(hostname)
+
+CONTINUE=true
+
+while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
+    echoerr "$(date +'%F %H:%M:%S'): dbench run starting"
+
+    mkdir -p $TESTDIR
+    rundbench -D $TESTDIR 2 1>$LOG &
+    load_pid=$!
+
+    wait $load_pid
+    if [ ${PIPESTATUS[0]} -eq 0 ]; then
+	echoerr "$(date +'%F %H:%M:%S'): dbench succeeded"
+	cd $TMP
+	rm -rf $TESTDIR
+	echoerr "$(date +'%F %H:%M:%S'): dbench run finished"
+    else
+	echoerr "$(date +'%F %H:%M:%S'): dbench failed"
+	if [ -z "$ERRORS_OK" ]; then
+	    echo $(hostname) >> $END_RUN_FILE
+	fi
+	if [ $BREAK_ON_ERROR ]; then
+	    # break
+            CONTINUE=false
+	fi
+    fi
+done
+
+echoerr "$(date +'%F %H:%M:%S'): dbench run exiting"
diff --git a/lustre/tests/run_dd.sh b/lustre/tests/run_dd.sh
new file mode 100755
index 0000000..d50150e
--- /dev/null
+++ b/lustre/tests/run_dd.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+set -x
+
+TMP=${TMP:-/tmp}
+
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-mds-scale}
+LOG=${TESTSUITELOG}_$(basename $0)-$(hostname)
+DEBUGLOG=${LOG}.debug
+
+mkdir -p ${LOG%/*}
+
+rm -f $LOG $DEBUGLOG
+exec 2>$DEBUGLOG
+
+. $(dirname $0)/functions.sh
+
+assert_env MOUNT END_RUN_FILE LOAD_PID_FILE
+
+trap signaled TERM
+
+# recovery-*-scale scripts use this to signal the client loads to die
+echo $$ >$LOAD_PID_FILE
+
+TESTDIR=$MOUNT/d0.dd-$(hostname)
+
+CONTINUE=true
+while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
+    echoerr "$(date +'%F %H:%M:%S'): dd run starting"
+    mkdir -p $TESTDIR
+    cd $TESTDIR
+    dd bs=4k count=1000000 if=/dev/zero of=$TESTDIR/dd-file 1>$LOG &
+    load_pid=$!
+    wait $load_pid
+
+    if [ $? -eq 0 ]; then
+	echoerr "$(date +'%F %H:%M:%S'): dd succeeded"
+	cd $TMP
+	rm -rf $TESTDIR
+	echoerr "$(date +'%F %H:%M:%S'): dd run finished"
+    else
+	echoerr "$(date +'%F %H:%M:%S'): dd failed"
+	if [ -z "$ERRORS_OK" ]; then
+	    echo $(hostname) >> $END_RUN_FILE
+	fi
+	if [ $BREAK_ON_ERROR ]; then
+	    # break
+            CONTINUE=false
+	fi
+    fi
+done
+
+echoerr "$(date +'%F %H:%M:%S'): dd run exiting"
diff --git a/lustre/tests/run_iozone.sh b/lustre/tests/run_iozone.sh
new file mode 100755
index 0000000..297142d
--- /dev/null
+++ b/lustre/tests/run_iozone.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+set -x
+
+TMP=${TMP:-/tmp}
+
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-mds-scale}
+LOG=${TESTSUITELOG}_$(basename $0)-$(hostname)
+DEBUGLOG=${LOG}.debug
+
+mkdir -p ${LOG%/*}
+
+rm -f $LOG $DEBUGLOG
+exec 2>$DEBUGLOG
+
+. $(dirname $0)/functions.sh
+
+assert_env MOUNT END_RUN_FILE LOAD_PID_FILE
+
+trap signaled TERM
+
+# recovery-*-scale scripts use this to signal the client loads to die
+echo $$ >$LOAD_PID_FILE
+
+TESTDIR=$MOUNT/d0.iozone-$(hostname)
+
+CONTINUE=true
+while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
+    echoerr "$(date +'%F %H:%M:%S'): iozone run starting"
+    mkdir -p $TESTDIR
+    cd $TESTDIR
+    iozone -a -M -R -V 0xab -g 100M -q 512k -i0 -i1 -f $TESTDIR/iozone-file 1>$LOG &
+    load_pid=$!
+    wait $load_pid
+    if [ ${PIPESTATUS[0]} -eq 0 ]; then
+	echoerr "$(date +'%F %H:%M:%S'): iozone succeeded"
+	cd $TMP
+	rm -rf $TESTDIR
+        if [ -d $TESTDIR ]; then
+	    echoerr "$(date +'%F %H:%M:%S'): failed to remove $TESTDIR"
+	    echo $(hostname) >> $END_RUN_FILE
+            CONTINUE=false
+        fi
+	echoerr "$(date +'%F %H:%M:%S'): iozone run finished"
+    else
+	echoerr "$(date +'%F %H:%M:%S'): iozone failed"
+	if [ -z "$ERRORS_OK" ]; then
+	    echo $(hostname) >> $END_RUN_FILE
+	fi
+	if [ $BREAK_ON_ERROR ]; then
+	    # break
+            CONTINUE=false
+	fi
+    fi
+done
+
+echoerr "$(date +'%F %H:%M:%S'): iozone run exiting"
diff --git a/lustre/tests/run_tar.sh b/lustre/tests/run_tar.sh
new file mode 100755
index 0000000..1bc47e9
--- /dev/null
+++ b/lustre/tests/run_tar.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+set -x
+
+TMP=${TMP:-/tmp}
+
+TESTSUITELOG=${TESTSUITELOG:-$TMP/recovery-mds-scale}
+LOG=${TESTSUITELOG}_$(basename $0)-$(hostname)
+DEBUGLOG=${LOG}.debug
+
+mkdir -p ${LOG%/*}
+
+rm -f $LOG $DEBUGLOG
+exec 2>$DEBUGLOG
+
+. $(dirname $0)/functions.sh
+
+assert_env MOUNT END_RUN_FILE LOAD_PID_FILE
+
+trap signaled TERM
+
+# recovery-*-scale scripts use this to signal the client loads to die
+echo $$ >$LOAD_PID_FILE
+
+TESTDIR=$MOUNT/d0.tar-$(hostname)
+
+do_tar() {
+    tar cf - /etc | tar xf - 2>&1 | tee $LOG
+    return ${PIPESTATUS[1]}
+}
+
+CONTINUE=true
+while [ ! -e "$END_RUN_FILE" ] && $CONTINUE; do
+    echoerr "$(date +'%F %H:%M:%S'): tar run starting"
+    mkdir -p $TESTDIR
+    cd $TESTDIR
+    do_tar &
+    wait $!
+    RC=$?
+    PREV_ERRORS=$(grep "exit delayed from previous errors" $LOG) || true
+    if [ $RC -ne 0 -a "$ERRORS_OK" -a "$PREV_ERRORS" ]; then
+        echoerr "$(date +'%F %H:%M:%S'): tar errors earlier, ignoring"
+        RC=0
+    fi
+    if [ $RC -eq 0 ]; then
+	echoerr "$(date +'%F %H:%M:%S'): tar succeeded"
+	cd $TMP
+	rm -rf $TESTDIR
+	echoerr "$(date +'%F %H:%M:%S'): tar run finished"
+    else
+	echoerr "$(date +'%F %H:%M:%S'): tar failed"
+	if [ -z "$ERRORS_OK" ]; then
+	    echo $(hostname) >> $END_RUN_FILE
+	fi
+	if [ $BREAK_ON_ERROR ]; then
+	    # break
+            CONTINUE=false
+	fi
+    fi
+done
+
+echoerr "$(date +'%F %H:%M:%S'): tar run exiting"
diff --git a/lustre/tests/rundbench b/lustre/tests/rundbench
index 92d79ba..d4d6963 100755
--- a/lustre/tests/rundbench
+++ b/lustre/tests/rundbench
@@ -60,8 +60,12 @@ if [ "x$CHROOT" == "xyes" ]; then
 	echo "copying necessary libs to $DIR"
 	cp `which dbench` $DIR
 	LIBS71=$(ldd $DIR/dbench|sed -e 's/\t*//' -e 's/.*=> //' -e 's/ .*//' -e 's/^\///')
-	(cd / && tar chf - $LIBS71) | (cd $DIR && tar xvf -)
-	[ $? != 0 ] && echo "can't copy libs $LIBS71 to $DIR" && exit 1
+	tar -C / -chf - $LIBS71 | tar -C $DIR -xvf -
+	if [ "${PIPESTATUS[*]}" != "0 0" ]; then
+		echo "can't copy libs $LIBS71 to $DIR"
+		rm -f $DIR/dbench
+		exit 1
+	fi
 	RUN="chroot $DIR"
 	PREFIX="in"
 	PATH=.:/:$PATH
@@ -69,9 +73,20 @@ fi
 
 shift $((OPTIND - 1))
 
+trap '
+echo kill dbench main pid=$DBENCHPID
+kill $DBENCHPID
+rm -rf dbench $LIBS71 client.txt
+exit 0
+' TERM
+
 cd $DIR
 echo "running 'dbench $@' $PREFIX $PWD at `date`"
-$RUN dbench -c client.txt $@
+
+$RUN dbench -c client.txt $@ &
+DBENCHPID=$!
+echo "dbench PID=$DBENCHPID"
+wait $DBENCHPID
 RC=$?
 [ $RC -ne 0 ] && killall -9 dbench
 
diff --git a/lustre/tests/runmultiop_bg_pause b/lustre/tests/runmultiop_bg_pause
index 823ebdd..640cc29 100644
--- a/lustre/tests/runmultiop_bg_pause
+++ b/lustre/tests/runmultiop_bg_pause
@@ -7,5 +7,11 @@ PTLDEBUG=${PTLDEBUG:--1}
 LUSTRE=${LUSTRE:-`dirname $0`/..}
 . $LUSTRE/tests/test-framework.sh
 
+TMP=${TMP:-/tmp}
+MULTIOP_PID_FILE=${MULTIOP_PID_FILE:-$TMP/multiop_bg.pid}
+rm -f $MULTIOP_PID_FILE
+
 multiop_bg_pause $*
-exit $?
+rc=$?
+[ "$rc" = 0 ] && echo $! > $MULTIOP_PID_FILE
+exit $rc
diff --git a/lustre/tests/runracer b/lustre/tests/runracer
index fcc26ed..feca24b 100644
--- a/lustre/tests/runracer
+++ b/lustre/tests/runracer
@@ -11,8 +11,15 @@ racer=`which racer.sh`
 [ -z "$racer" ] && echo racer is not installed && exit 1
 
 CLIENTS=${CLIENTS:-$HOSTNAME}
-RDIR=$DIR/racer
-mkdir -p $RDIR
+RACERDIRS=$@
+RACERDIRS=${RACERDIRS:-$DIR}
+echo RACERDIRS=$RACERDIRS
+for d in ${RACERDIRS}; do
+	RDIRS="$RDIRS $d/racer"
+	mkdir -p $d/racer
+#	lfs setstripe $d/racer -c -1
+done
+
 DURATION=${DURATION:-120}
 
 assert_env CLIENTS
@@ -31,6 +38,8 @@ do_racer_cleanup () {
         local pids
 	local rc=0
 
+	local RDIR=$1
+
 	echo "DOING RACER CLEANUP ... "
 
 	# Check if all processes are killed
@@ -81,11 +90,16 @@ racer_cleanup () {
 		echo $timeout killing RACERPID=$RACERPID
 		kill $RACERPID || true
 		sleep 2	# give chance racer to kill it's processes
-		do_racer_cleanup
+		local dir
+		for dir in $RDIRS; do
+			do_racer_cleanup $dir
+		done
 	else
 		echo "Racer completed before DURATION=$DURATION expired. Cleaning up..."
 		kill $TIMERPID
-		do_racer_cleanup
+		for dir in $RDIRS; do
+			do_racer_cleanup $dir
+		done
 	fi
 }
 
@@ -104,10 +118,23 @@ trap racer_timeout ALRM
 
 timer_on $((DURATION + 5))
 
-do_nodes $CLIENTS "DURATION=$DURATION $racer $RDIR" &
-RACERPID=$!
+RACERPID=""
+for rdir in $RDIRS; do
+	do_nodes $CLIENTS "DURATION=$DURATION $racer $rdir $NUM_RACER_THREADS" &
+	pid=$!
+	RACERPID="$RACERPID $pid"
+done
+
 echo RACERPID=$RACERPID
-wait $RACERPID || RC=2
+for rpid in $RACERPID; do
+	wait $rpid
+	rc=$?
+	echo "rpid=$rpid rc=$rc"
+	if [ $rc != 0 ]; then
+		RC=$((RC + 1))
+	fi
+done
+
 racer_cleanup
 echo "$0: completed $RC"
 exit $RC
diff --git a/lustre/tests/runtests b/lustre/tests/runtests
index 8080e31..64426d1 100755
--- a/lustre/tests/runtests
+++ b/lustre/tests/runtests
@@ -14,17 +14,6 @@ export NAME=${NAME:-local}
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 
-SETUP=${SETUP:-setupall}
-FORMAT=${FORMAT:-formatall}
-CLEANUP=${CLEANUP:-stopall}
-
-fail() { 
-	echo "ERROR: $1" 1>&2
-	[ $2 ] && RC=$2 || RC=1
-	exit $RC
-}
-
-ERROR=
 RUNTESTS_SRC=${RUNTESTS_SRC:-"/etc /bin"}
 [ "$COUNT" ] || COUNT=1000
 [ "$SLOW" = "no" ] && COUNT=100
@@ -33,24 +22,7 @@ RUNTESTS_SRC=${RUNTESTS_SRC:-"/etc /bin"}
 
 [ "$MKDIRMANY" ] || MKDIRMANY="createmany -d"
 
-while [ "$1" ]; do
-	case $1 in
-	*.xml) export NAME=`echo $1 | sed "s/.xml//"` ;;
-	*) OPTS="$OPTS $1" ;;
-	esac
-	shift
-done
-
-MOUNTED=$(mounted_lustre_filesystems | head -1)
-if [ -z "$MOUNTED" ]; then
-	formatall
-	setupall
-	MOUNTED="`mounted_lustre_filesystems`"
-	[ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
-	I_MOUNTED=yes
-fi
-
-MOUNT=$MOUNTED
+check_and_setup_lustre
 
 OSCTMP=`echo $MOUNT | tr "/" "."`
 USED=`df | awk "/$OSCTMP/ { print \\$3 }" | tail -n 1`
@@ -59,7 +31,7 @@ USED=`expr $USED + 16`	# Some space for the status file
 # let's start slowly here...
 START=`date +%s`
 log "touching $MOUNT at `date`"
-touch $MOUNT || fail "can't touch $MOUNT" 2
+touch $MOUNT || error "can't touch $MOUNT" 2
 HOSTS=$MOUNT/hosts.$$
 TRUNCSIZE=123
 
@@ -68,18 +40,18 @@ if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
 	log "create an empty file $HOSTS"
 	mcreate $HOSTS
 	log "copying /etc/hosts to $HOSTS"
-	cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS" 3
+	cp /etc/hosts $HOSTS || error "can't cp /etc/hosts to $HOSTS" 3
 	log "comparing /etc/hosts and $HOSTS"
-	diff -u /etc/hosts $HOSTS || fail "$HOSTS different" 4
+	diff -u /etc/hosts $HOSTS || error "$HOSTS different" 4
 	log "renaming $HOSTS to $HOSTS.ren"
-	mv $HOSTS $HOSTS.ren || fail "can't rename $HOSTS to $HOSTS.ren" 5
+	mv $HOSTS $HOSTS.ren || error "can't rename $HOSTS to $HOSTS.ren" 5
 	log "copying /etc/hosts to $HOSTS again"
-	cp /etc/hosts $HOSTS || fail "can't cp /etc/hosts to $HOSTS again" 6
+	cp /etc/hosts $HOSTS || error "can't cp /etc/hosts to $HOSTS again" 6
 	log "truncating $HOSTS"
-	> $HOSTS || fail "can't truncate $HOSTS" 8
+	> $HOSTS || error "can't truncate $HOSTS" 8
 	log "removing $HOSTS"
-	rm $HOSTS || fail "can't remove $HOSTS" 9
-	cp /etc/hosts $HOSTS.2 || fail "can't cp /etc/hosts to $HOSTS.2" 7
+	rm $HOSTS || error "can't remove $HOSTS" 9
+	cp /etc/hosts $HOSTS.2 || error "can't cp /etc/hosts to $HOSTS.2" 7
 	log "truncating $HOSTS.2 to $TRUNCSIZE bytes"
 	truncate $HOSTS.2 $TRUNCSIZE
 fi
@@ -87,60 +59,62 @@ fi
 DST=$MOUNT/runtest.$$
 # let's start slowly here...
 log "creating $DST"
-mkdir $DST || fail "can't mkdir $DST" 10
+mkdir $DST || error "can't mkdir $DST" 10
 
 # ok, that hopefully worked, so let's do a little more, with files that
 # haven't changed in the last day (hopefully they don't change during test)
-FILES=`find $RUNTESTS_SRC -type f -mtime +1 | head -n $COUNT`
-[ -z "$FILES" ] && fail "No unchanged files - is $RUNTESTS_SRC a new dir?"
+FILES=$TMP/runtests.files
+# print0 is to use "NUL" instead of newline as filename terminator, bug 19702 
+find $RUNTESTS_SRC -type f -mtime +1 -print0 | head -n $COUNT > $FILES
+[ -s "$FILES" ] || error "$RUNTESTS_SRC contains only files modifed less than 2 days ago"
 
 log "copying files from $RUNTESTS_SRC to $DST$RUNTESTS_SRC at `date`"
-tar cf - $FILES | tar xvf - -C $DST > /dev/null || fail "copying $RUNTESTS_SRC" 11
+tar cf - --null --files-from $FILES | tar xvf - -C $DST > /dev/null || error "copying $RUNTESTS_SRC" 11
 
 log "comparing newly copied files at `date`"
-for f in $FILES; do
+
+cat $FILES | tr "\0" "\n" | ( rc=0; while read f; do
 	[ $V ] && log "verifying $DST/$f"
-	diff -q $f $DST/$f || ERROR=11
+	diff -q "$f" "$DST/$f" || rc=11
 done
+[ "$rc" = 0 ] || error_exit "old and new files are different: rc=$rc" ) 
 
-[ "$ERROR" ] && fail "old and new files are different" $ERROR
 log "finished at `date` ($(($(date +%s) - START)))"
 
-$CLEANUP || exit 19
-$SETUP || exit 20
+stopall || exit 19
+setupall || exit 20
 
 log "comparing previously copied files"
-for f in $FILES; do
-	[ $V ] && log "verifying $DST/$f"
-	diff -q $f $DST/$f || ERROR=22
+cat $FILES | tr "\0" "\n" | ( rc=0; while read f; do
+        [ $V ] && log "verifying $DST/$f"
+        diff -q "$f" "$DST/$f" || rc=22
 done
+[ "$rc" = 0 ] || error_exit "old and new files are different: rc=$rc" )
 
-[ "$ERROR" ] && fail "old and new files are different on second diff" $ERROR
-
-$CLEANUP || exit 19
-$SETUP || exit 20
+stopall || exit 21
+setupall || exit 22
 
 log "removing $DST"
-rm -r $V $DST || fail "can't remove $DST" 37
+rm -r $V $DST || error "can't remove $DST" 37
 
 if [ $COUNT -gt 10 -o $COUNT -eq 0 ]; then
 	log "renaming $HOSTS.ren to $HOSTS"
-	mv $HOSTS.ren $HOSTS || fail "can't rename $HOSTS.ren to $HOSTS" 32
+	mv $HOSTS.ren $HOSTS || error "can't rename $HOSTS.ren to $HOSTS" 32
 	log "truncating $HOSTS"
-	> $HOSTS || fail "can't truncate $HOSTS" 34
+	> $HOSTS || error "can't truncate $HOSTS" 34
 	log "removing $HOSTS"
-	rm $HOSTS || fail "can't remove $HOSTS again" 36
+	rm $HOSTS || error "can't remove $HOSTS again" 36
 	log "verifying $HOSTS.2 is $TRUNCSIZE bytes"
 	checkstat -s $TRUNCSIZE $HOSTS.2 || \
-		fail "$HOSTS.2 isn't $TRUNCSIZE bytes" 37
-	rm $HOSTS.2 || fail "can't remove $HOSTS.2" 38
+		error "$HOSTS.2 isn't $TRUNCSIZE bytes" 37
+	rm $HOSTS.2 || error "can't remove $HOSTS.2" 38
 fi
 
 # mkdirmany test (bug 589)
 log "running $MKDIRMANY $MOUNT/base$$ 100"
-$MKDIRMANY $MOUNT/base$$ 100 || fail "mkdirmany failed"
+$MKDIRMANY $MOUNT/base$$ 100 || error "mkdirmany failed"
 log "removing mkdirmany directories"
-rmdir $MOUNT/base$$* || fail "mkdirmany cleanup failed"
+rmdir $MOUNT/base$$* || error "mkdirmany cleanup failed"
 
 log "done"
 
@@ -149,6 +123,5 @@ if [ `expr $NOWUSED - $USED` -gt 1024 ]; then
 	echo "Space not all freed: now ${NOWUSED}kB, was ${USED}kB." 1>&2
 fi
 
-if [ "$I_MOUNTED" = "yes" ]; then
-	$CLEANUP
-fi
+rm -f $FILES
+check_and_cleanup_lustre
diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh
index 882c289..c370f01 100644
--- a/lustre/tests/sanity-quota.sh
+++ b/lustre/tests/sanity-quota.sh
@@ -17,7 +17,7 @@ SRCDIR=`dirname $0`
 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
 
 ONLY=${ONLY:-"$*"}
-ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT"
+ALWAYS_EXCEPT="10 $SANITY_QUOTA_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 case `uname -r` in
@@ -41,6 +41,8 @@ IUNIT_SZ=${IUNIT_SZ:-10}	# min inode quota unit
 MAX_DQ_TIME=604800
 MAX_IQ_TIME=604800
 
+unset ENABLE_QUOTA
+
 TRACE=${TRACE:-""}
 LUSTRE=${LUSTRE:-`dirname $0`/..}
 . $LUSTRE/tests/test-framework.sh
@@ -66,7 +68,9 @@ LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
 
 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
+SHOW_QUOTA_USER2="$LFS quota -v -u $TSTUSR2 $DIR"
 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
+SHOW_QUOTA_GROUP2="$LFS quota -v -g $TSTUSR2 $DIR"
 SHOW_QUOTA_INFO="$LFS quota -t -u $DIR; $LFS quota -t -g $DIR"
 
 # control the time of tests
@@ -117,22 +121,24 @@ set_file_unitsz() {
 lustre_fail() {
         local fail_node=$1
 	local fail_loc=$2
+	local fail_val=${3:-0}
 
-	case $fail_node in
-	    "mds" )
-		do_facet mds "lctl set_param fail_loc=$fail_loc" ;;
-	    "ost" )
-		for num in `seq $OSTCOUNT`; do
-		    do_facet ost$num "lctl set_param fail_loc=$fail_loc"
-		done ;;
-	    "mds_ost" )
-		do_facet mds "lctl set_param fail_loc=$fail_loc" ;
-		for num in `seq $OSTCOUNT`; do
-		    do_facet ost$num "lctl set_param fail_loc=$fail_loc"
-		done ;;
-	    * ) echo "usage: lustre_fail fail_node fail_loc" ;
-		return 1 ;;
-	esac
+	if [ $fail_node == "mds" ] || [ $fail_node == "mds_ost" ]; then
+	    if [ $((fail_loc & 0x10000000)) -ne 0  -a $fail_val -gt 0 ] || \
+		[ $((fail_loc)) -eq 0 ]; then
+		do_facet mds "lctl set_param fail_val=$fail_val"
+	    fi
+	    do_facet mds "lctl set_param fail_loc=$fail_loc"
+	fi
+	if [ $fail_node == "ost" ] || [ $fail_node == "mds_ost" ]; then
+	    for num in `seq $OSTCOUNT`; do
+		if [ $((fail_loc & 0x10000000)) -ne 0 -a $fail_val -gt 0 ] || \
+		    [ $((fail_loc)) -eq 0 ]; then
+		    do_facet ost$num "lctl set_param fail_val=$fail_val"
+		fi
+		do_facet ost$num "lctl set_param fail_loc=$fail_loc"
+	    done
+	fi
 }
 
 RUNAS="runas -u $TSTID -g $TSTID"
@@ -160,13 +166,101 @@ run_test_with_stat() {
 	fi
 }
 
+#
+# clear quota limits for a user or a group
+# usage: resetquota -u username
+#        resetquota -g groupname
+
+resetquota() {
+        [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
+        [ "$1" != "-u" -a "$1" != "-g" ] && error "resetquota: wrong specifier $1 passed"
+
+        count=0
+        if at_is_enabled; then
+	    timeout=$(at_max_get mds)
+        else
+	    timeout=$(lctl get_param -n timeout)
+        fi
+
+        while [ $((count++)) -lt $timeout ]; do
+                $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT
+                RC=$?
+                if [ $RC -ne 0 ]; then
+                        if [ $RC -eq 240 ]; then # 240 means -EBUSY
+                                log "resetquota is blocked for quota master recovery, retry after 1 sec"
+                                sleep 1
+                                continue
+                        else
+                                error "resetquota failed: $RC"
+                        fi
+                fi
+                break
+        done
+
+        [ $count -lt $timeout ] || error "resetquota timeout: $timeout"
+}
+
+quota_scan() {
+        LOCAL_UG=$1
+        LOCAL_ID=$2
+
+        if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "u" ]; then
+                log "Files for user ($LOCAL_ID):"
+                ($LFS find -user $LOCAL_ID $DIR | xargs stat 2>/dev/null)
+        fi
+
+        if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "g" ]; then
+                log "Files for group ($LOCAL_ID):"
+                ($LFS find -group $LOCAL_ID $DIR | xargs stat 2>/dev/null)
+        fi
+}
+
+quota_error() {
+        quota_scan $1 $2
+        shift 2
+        error "$*"
+}
+
+quota_log() {
+        quota_scan $1 $2
+        shift 2
+        log "$*"
+}
+
+quota_show_check() {
+        LOCAL_BF=$1
+        LOCAL_UG=$2
+        LOCAL_ID=$3
+	PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
+
+        $LFS quota -v -$LOCAL_UG $LOCAL_ID $DIR
+
+        if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "b" ]; then
+	        USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $2 }'`"
+                if [ -z $USAGE ]; then
+                        quota_error $LOCAL_UG $LOCAL_ID "System is error when query quota for block ($LOCAL_UG:$LOCAL_ID)."
+                else
+                        [ $USAGE -ne 0 ] && quota_log $LOCAL_UG $LOCAL_ID "System is not clean for block ($LOCAL_UG:$LOCAL_ID:$USAGE)."
+                fi
+        fi
+
+        if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "f" ]; then
+	        USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $5 }'`"
+                if [ -z $USAGE ]; then
+                        quota_error $LOCAL_UG $LOCAL_ID "System is error when query quota for file ($LOCAL_UG:$LOCAL_ID)."
+                else
+                        [ $USAGE -ne 0 ] && quota_log $LOCAL_UG $LOCAL_ID "System is not clean for file ($LOCAL_UG:$LOCAL_ID:$USAGE)."
+                fi
+        fi
+}
+
 # set quota
 test_0() {
 	$LFS quotaoff -ug $DIR
 	$LFS quotacheck -ug $DIR
 
- 	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
- 	$LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+ 	resetquota -u $TSTUSR
+ 	resetquota -g $TSTUSR
 
 	lctl set_param debug="+quota"
 	do_facet mds "lctl set_param debug=+quota"
@@ -189,20 +283,20 @@ test_1_sub() {
         log "  User quota (limit: $LIMIT kbytes)"
         $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
 	sleep 3
-        $SHOW_QUOTA_USER
+	quota_show_check b u $TSTUSR
 
         $LFS setstripe $TESTFILE -c 1
         chown $TSTUSR.$TSTUSR $TESTFILE
 
         log "    Write ..."
-        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || error "(usr) write failure, but expect success"
+	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error u $TSTUSR "(usr) write failure, but expect success"
         log "    Done"
         log "    Write out of block quota ..."
 	# this time maybe cache write,  ignore it's failure
         $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
 	# flush cache, ensure noquota flag is setted on client
         cancel_lru_locks osc
-        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && error "(usr) write success, but expect EDQUOT"
+	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && quota_error u $TSTUSR "(usr) write success, but expect EDQUOT"
 
         rm -f $TESTFILE
 	sync; sleep 1; sync;
@@ -210,29 +304,29 @@ test_1_sub() {
 	OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
 	echo $OST0_QUOTA_USED
 	[ $OST0_QUOTA_USED -ne 0 ] && \
-	    ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+	    ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
 	$SHOW_QUOTA_USER
-        $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+        resetquota -u $TSTUSR
 
         # test for group
 	log "--------------------------------------"
         log "  Group quota (limit: $LIMIT kbytes)"
         $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
 	sleep 3
-        $SHOW_QUOTA_GROUP
+        quota_show_check b g $TSTUSR
         TESTFILE="$DIR/$tdir/$tfile-1"
 
         $LFS setstripe $TESTFILE -c 1
         chown $TSTUSR.$TSTUSR $TESTFILE
 
         log "    Write ..."
-        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || error "(grp) write failure, but expect success"
+	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error g $TSTUSR "(grp) write failure, but expect success"
         log "    Done"
         log "    Write out of block quota ..."
 	# this time maybe cache write, ignore it's failure
         $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
         cancel_lru_locks osc
-        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && error "(grp) write success, but expect EDQUOT"
+	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && quota_error g $TSTUSR "(grp) write success, but expect EDQUOT"
 
 	# cleanup
         rm -f $TESTFILE
@@ -241,9 +335,9 @@ test_1_sub() {
 	OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
 	echo $OST0_QUOTA_USED
 	[ $OST0_QUOTA_USED -ne 0 ] && \
-	    ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+	    ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
 	$SHOW_QUOTA_GROUP
-        $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+        resetquota -g $TSTUSR
 }
 
 # block hard limit (normal use and out of quota)
@@ -253,7 +347,7 @@ test_1() {
 	    blk_qunit=$(( $RANDOM % 3072 + 1024 ))
 	    blk_qtune=$(( $RANDOM % $blk_qunit ))
 	    # other osts and mds will occupy at 1M blk quota
-	    b_limit=$(( ($RANDOM - 16384) / 8 +  $OSTCOUNT  * $blk_qunit * 4 ))
+	    b_limit=$(( ($RANDOM - 16384) / 8 +  $OSTCOUNT * $blk_qunit * 4 ))
 	    set_blk_tunesz $blk_qtune
 	    set_blk_unitsz $blk_qunit
 	    echo "cycle: $i(total $cycle) bunit:$blk_qunit, btune:$blk_qtune, blimit:$b_limit"
@@ -278,15 +372,15 @@ test_2_sub() {
         log "  User quota (limit: $LIMIT files)"
         $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
 	sleep 3
-        $SHOW_QUOTA_USER
+        quota_show_check f u $TSTUSR
 
 	log "    Create $LIMIT files ..."
 	$RUNAS createmany -m ${TESTFILE} $LIMIT || \
-		error "(usr) create failure, but expect success"
+		quota_error u $TSTUSR "(usr) create failure, but expect success"
 	log "    Done"
 	log "    Create out of file quota ..."
 	$RUNAS touch ${TESTFILE}_xxx && \
-		error "(usr) touch success, but expect EDQUOT"
+		quota_error u $TSTUSR "(usr) touch success, but expect EDQUOT"
 
 	unlinkmany ${TESTFILE} $LIMIT
 	rm -f ${TESTFILE}_xxx
@@ -296,25 +390,25 @@ test_2_sub() {
 	MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
 	echo $MDS_QUOTA_USED
 	[ $MDS_QUOTA_USED -ne 0 ] && \
-	    ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+	    ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
 	$SHOW_QUOTA_USER
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u $TSTUSR
 
         # test for group
 	log "--------------------------------------"
         log "  Group quota (limit: $LIMIT FILE)"
         $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
 	sleep 3
-        $SHOW_QUOTA_GROUP
+        quota_show_check f g $TSTUSR
         TESTFILE=$DIR/$tdir/$tfile-1
 
 	log "    Create $LIMIT files ..."
 	$RUNAS createmany -m ${TESTFILE} $LIMIT || \
-		error "(usr) create failure, but expect success"
+		quota_error g $TSTUSR "(grp) create failure, but expect success"
 	log "    Done"
 	log "    Create out of file quota ..."
 	$RUNAS touch ${TESTFILE}_xxx && \
-		error "(usr) touch success, but expect EDQUOT"
+		quota_error g $TSTUSR "(grp) touch success, but expect EDQUOT"
 
 	unlinkmany ${TESTFILE} $LIMIT
 	rm -f ${TESTFILE}_xxx
@@ -324,9 +418,9 @@ test_2_sub() {
 	MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
 	echo $MDS_QUOTA_USED
 	[ $MDS_QUOTA_USED -ne 0 ] && \
-	    ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+	    ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
 	$SHOW_QUOTA_GROUP
-        $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+        resetquota -g $TSTUSR
 }
 
 # file hard limit (normal use and out of quota)
@@ -340,7 +434,7 @@ test_2() {
 		# define ino_qunit is between 10 and 100
 		ino_qunit=$(( $RANDOM % 90 + 10 ))
 		ino_qtune=$(( $RANDOM % $ino_qunit ))
-	        # RANDOM's maxium is 32767
+                # RANDOM's maxium is 32767
 		i_limit=$(( $RANDOM % 990 + 10 ))
 	    fi
 
@@ -365,7 +459,7 @@ test_block_soft() {
 	echo "    Write to exceed soft limit"
 	RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
 	$RUNDD count=$((BUNIT_SZ+1)) || \
-	        error "write failure, but expect success"
+		quota_error a $TSTUSR "write failure, but expect success"
 	OFFSET=$((OFFSET + BUNIT_SZ + 1))
         cancel_lru_locks osc
 
@@ -375,7 +469,7 @@ test_block_soft() {
 
 	echo "    Write before timer goes off"
 	$RUNDD count=$BUNIT_SZ seek=$OFFSET || \
-	        error "write failure, but expect success"
+		quota_error a $TSTUSR "write failure, but expect success"
 	OFFSET=$((OFFSET + BUNIT_SZ))
         cancel_lru_locks osc
 	echo "    Done"
@@ -393,7 +487,7 @@ test_block_soft() {
 	OFFSET=$((OFFSET + BUNIT_SZ))
         cancel_lru_locks osc
 	$RUNDD count=$BUNIT_SZ seek=$OFFSET && \
-	        error "write success, but expect EDQUOT"
+		quota_error a $TSTUSR "write success, but expect EDQUOT"
 
         $SHOW_QUOTA_USER
         $SHOW_QUOTA_GROUP
@@ -409,7 +503,7 @@ test_block_soft() {
         $SHOW_QUOTA_INFO
 
 	echo "    Write ..."
-	$RUNDD count=$BUNIT_SZ || error "write failure, but expect success"
+	$RUNDD count=$BUNIT_SZ || quota_error a $TSTUSR "write failure, but expect success"
 	echo "    Done"
 
 	# cleanup
@@ -436,7 +530,7 @@ test_3() {
 	$LFS setquota -u $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
 
 	test_block_soft $TESTFILE $GRACE
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u $TSTUSR
 
 	echo "  Group quota (soft limit: $LIMIT kbytes  grace: $GRACE seconds)"
 	TESTFILE=$DIR/$tdir/$tfile-1
@@ -448,7 +542,7 @@ test_3() {
 	$LFS setquota -g $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
 
 	test_block_soft $TESTFILE $GRACE
-	$LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -g $TSTUSR
 }
 run_test_with_stat 3 "Block soft limit (start timer, timer goes off, stop timer) ==="
 
@@ -461,13 +555,13 @@ test_file_soft() {
 
 	echo "    Create files to exceed soft limit"
 	$RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) || \
-		error "create failure, but expect success"
+		quota_error a $TSTUSR "create failure, but expect success"
 	sync; sleep 1; sync
 	echo "    Done"
 
 	echo "    Create file before timer goes off"
 	$RUNAS touch ${TESTFILE}_before || \
-		error "failed create before timer expired, but expect success"
+		quota_error a $TSTUSR "failed create before timer expired, but expect success"
 	sync; sleep 1; sync
 	echo "    Done"
 
@@ -484,7 +578,7 @@ test_file_soft() {
 	$RUNAS touch ${TESTFILE}_after ${TESTFILE}_after1 ${TESTFILE}_after2 || true
 	sync; sleep 1; sync
 	$RUNAS touch ${TESTFILE}_after3 && \
-		error "create after timer expired, but expect EDQUOT"
+		quota_error a $TSTUSR "create after timer expired, but expect EDQUOT"
 	sync; sleep 1; sync
 
 	$SHOW_QUOTA_USER
@@ -497,7 +591,7 @@ test_file_soft() {
 
 	echo "    Create file"
 	$RUNAS touch ${TESTFILE}_xxx || \
-		error "touch after timer stop failure, but expect success"
+		quota_error a $TSTUSR "touch after timer stop failure, but expect success"
 	sync; sleep 1; sync
 	echo "    Done"
 
@@ -518,19 +612,19 @@ test_4a() {	# was test_4
 	echo "  User quota (soft limit: $LIMIT files  grace: $GRACE seconds)"
 	$LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
 	$LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
-	$SHOW_QUOTA_USER
+        quota_show_check f u $TSTUSR
 
 	test_file_soft $TESTFILE $LIMIT $GRACE
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u $TSTUSR
 
 	echo "  Group quota (soft limit: $LIMIT files  grace: $GRACE seconds)"
 	$LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
 	$LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
-	$SHOW_QUOTA_GROUP
+        quota_show_check f g $TSTUSR
 	TESTFILE=$DIR/$tdir/$tfile-1
 
 	test_file_soft $TESTFILE $LIMIT $GRACE
-	$LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -g $TSTUSR
 
 	# cleanup
 	$LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
@@ -577,8 +671,8 @@ test_5() {
 	echo "  Set quota limit (0 $BLIMIT 0 $ILIMIT) for $TSTUSR.$TSTUSR"
 	$LFS setquota -u $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
 	$LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
-	$SHOW_QUOTA_USER
-	$SHOW_QUOTA_GROUP
+        quota_show_check a u $TSTUSR
+        quota_show_check a g $TSTUSR
 
 	echo "  Create more than $ILIMIT files and more than $BLIMIT kbytes ..."
 	createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) || \
@@ -588,15 +682,15 @@ test_5() {
 	echo "  Chown files to $TSTUSR.$TSTUSR ..."
 	for i in `seq 0 $ILIMIT`; do
 	chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i || \
-			error "chown failure, but expect success"
+			quota_error a $TSTUSR "chown failure, but expect success"
 	done
 
 	# cleanup
 	unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
 	sync; sleep 3; sync;
 
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
-	$LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u $TSTUSR
+	resetquota -g $TSTUSR
 }
 run_test_with_stat 5 "Chown & chgrp successfully even out of block/file quota ==="
 
@@ -619,8 +713,8 @@ test_6() {
 	echo "  Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR"
 	$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
 	$LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-	$SHOW_QUOTA_USER
-	$SHOW_QUOTA_GROUP
+        quota_show_check b u $TSTUSR
+        quota_show_check b g $TSTUSR
 
 	echo "  Create filea on OST0 and fileb on OST1"
 	$LFS setstripe $FILEA -i 0 -c 1
@@ -629,41 +723,80 @@ test_6() {
 	chown $TSTUSR.$TSTUSR $FILEB
 
 	echo "  Exceed quota limit ..."
-        RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ"
+        RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ"
         $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
-                error "write fileb failure, but expect success"
+		quota_error a $TSTUSR "write filea failure, but expect success"
 
         cancel_lru_locks osc
         $SHOW_QUOTA_USER
         $SHOW_QUOTA_GROUP
         $RUNDD seek=$LIMIT count=$((BUNIT_SZ * OSTCOUNT)) && \
-                error "write fileb success, but expect EDQUOT"
+		quota_error a $TSTUSR "write filea success, but expect EDQUOT"
         cancel_lru_locks osc
-	echo "  Write to OST0 return EDQUOT"
+	echo "  Write to OST1 return EDQUOT"
 	# this write maybe cache write, ignore it's failure
-        RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ"
+        RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ"
         $RUNDD count=$(($BUNIT_SZ * 2)) || true
         cancel_lru_locks osc
         $SHOW_QUOTA_USER
         $SHOW_QUOTA_GROUP
         $RUNDD count=$((BUNIT_SZ * 2)) seek=$((BUNIT_SZ *2)) && \
-                error "write filea success, but expect EDQUOT"
+		quota_error a $TSTUSR "write fileb success, but expect EDQUOT"
 
-	echo "  Remove fileb to let OST1 release quota"
-	rm -f $FILEB
-        sync; sleep 10; sync; # need to allow journal commit for small fs
+	echo "  Remove filea to let OST0 release quota"
+	rm -f $FILEA
 
-	echo "  Write to OST0"
+        if at_is_enabled; then
+	    timeout=$(at_max_get mds)
+        else
+	    timeout=$(lctl get_param -n timeout)
+        fi
+        count=$((timeout / 5))
+        OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
+
+        while [ $((count--)) -gt 0 ]; do
+                sync && sleep 5
+
+	        OST0_QUOTA_HOLD=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`
+                if [ -z $OST0_QUOTA_HOLD ]; then
+                        error "System is error when query quota for block (U:$TSTUSR)."
+                else
+                        [ $OST0_QUOTA_HOLD -gt $BUNIT_SZ ] && continue
+                fi
+
+                break
+        done
+
+        [ ! $count -gt 0 ] && error "Release quota for block timeout (U:$TSTUSR)."
+        $SHOW_QUOTA_USER
+
+        while [ $((count--)) -gt 0 ]; do
+                sync && sleep 5
+
+	        OST0_QUOTA_HOLD=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`
+                if [ -z $OST0_QUOTA_HOLD ]; then
+                        error "System is error when query quota for block (G:$TSTUSR)."
+                else
+                        [ $OST0_QUOTA_HOLD -gt $BUNIT_SZ ] && continue
+                fi
+
+                break
+        done
+
+        [ ! $count -gt 0 ] && error "Release quota for block timeout (G:$TSTUSR)."
+        $SHOW_QUOTA_GROUP
+
+	echo "  Write to OST1"
 	$RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
-	        error "write filea failure, expect success"
+		quota_error a $TSTUSR "write fileb failure, expect success"
 	echo "  Done"
 
 	# cleanup
-	rm -f $FILEA
+	rm -f $FILEB
 	sync; sleep 3; sync;
 
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
-	$LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u $TSTUSR
+	resetquota -g $TSTUSR
 	return 0
 }
 run_test_with_stat 6 "Block quota acquire & release ========="
@@ -686,7 +819,7 @@ test_7()
 
 	echo "  Write to OST0..."
 	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ || \
-		error "write failure, but expect success"
+		quota_error u $TSTUSR "write failure, but expect success"
 
 	#define OBD_FAIL_OBD_DQACQ               0x604
 	lustre_fail mds  0x604
@@ -716,7 +849,7 @@ test_7()
 	echo "  limits on $OST0_UUID = $OST0_LIMIT"
 
 	# cleanup
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u $TSTUSR
 }
 run_test_with_stat 7 "Quota recovery (only block limit) ======"
 
@@ -736,11 +869,12 @@ test_8() {
 	chmod 0777 $DIR/$tdir
 	local duration=""
 	[ "$SLOW" = "no" ] && duration=" -t 120"
-	$RUNAS bash rundbench -D $DIR/$tdir 3 $duration || error "dbench failed!"
+	$RUNAS bash rundbench -D $DIR/$tdir 3 $duration || quota_error a $TSTUSR "dbench failed!"
 
+        rm -rf $DIR/$tdir
 	sync; sleep 3; sync;
 
-	return 0 
+	return 0
 }
 run_test_with_stat 8 "Run dbench with quota enabled ==========="
 
@@ -769,8 +903,8 @@ test_9() {
 
 	wait_delete_completed
 
- 	set_blk_tunesz 512
- 	set_blk_unitsz 1024
+	set_blk_tunesz 512
+	set_blk_unitsz 1024
 
 	mkdir -p $DIR/$tdir
 	chmod 0777 $DIR/$tdir
@@ -785,17 +919,17 @@ test_9() {
         log "  Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
         $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
 
+        quota_show_check a u $TSTUSR
+        quota_show_check a g $TSTUSR
+
         echo "  Set stripe"
 	$LFS setstripe $TESTFILE -c 1
         touch $TESTFILE
         chown $TSTUSR.$TSTUSR $TESTFILE
 
-        $SHOW_QUOTA_USER
-        $SHOW_QUOTA_GROUP
-
         log "    Write the big file of 4.5G ..."
         $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$blksize count=$((size_file / blksize)) || \
-               error "(usr) write 4.5G file failure, but expect success"
+	       quota_error a $TSTUSR "(usr) write 4.5G file failure, but expect success"
 
         $SHOW_QUOTA_USER
         $SHOW_QUOTA_GROUP
@@ -824,8 +958,8 @@ test_10() {
 
 	wait_delete_completed
 
- 	set_blk_tunesz 512
- 	set_blk_unitsz 1024
+	set_blk_tunesz 512
+	set_blk_unitsz 1024
 
 	# make qd_count 32 bit
 	lustre_fail mds_ost 0xA00
@@ -840,17 +974,17 @@ test_10() {
 	log "  Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
 	$LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
 
+        quota_show_check a u $TSTUSR
+        quota_show_check a g $TSTUSR
+
 	echo "  Set stripe"
 	$LFS setstripe $TESTFILE -c 1
 	touch $TESTFILE
 	chown $TSTUSR.$TSTUSR $TESTFILE
 
-        $SHOW_QUOTA_USER
-        $SHOW_QUOTA_GROUP
-
         log "    Write the big file of 4.5 G ..."
         $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$blksize count=$((size_file / blksize)) || \
-		error "(usr) write 4.5 G file failure, but expect success"
+		quota_error a $TSTUSR "(usr) write 4.5 G file failure, but expect success"
 
         $SHOW_QUOTA_USER
         $SHOW_QUOTA_GROUP
@@ -952,11 +1086,6 @@ test_12() {
 	[ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \
 		{ skip "Need lustre mounted on $MOUNT2 " && retutn 0; }
 
-	if [ $OSTCOUNT -lt 2 ]; then
-		skip "$OSTCOUNT < 2, too few osts"
-		return 0;
-	fi
-
 	LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
 	TESTFILE="$DIR/$tdir/$tfile-0"
 	TESTFILE2="$DIR2/$tdir/$tfile-1"
@@ -968,11 +1097,12 @@ test_12() {
 
 	$LFS setstripe $TESTFILE -i 0 -c 1
 	chown $TSTUSR.$TSTUSR $TESTFILE
-	$LFS setstripe $TESTFILE2 -i 1 -c 1
+	$LFS setstripe $TESTFILE2 -i 0 -c 1
         chown $TSTUSR2.$TSTUSR2 $TESTFILE2
 
 	#define OBD_FAIL_OST_HOLD_WRITE_RPC      0x21f
-	lustre_fail ost 0x0000021f
+	#define OBD_FAIL_SOME        0x10000000 /* fail N times */
+	lustre_fail ost $((0x0000021f | 0x10000000)) 1
 
 	echo "   step1: write out of block quota ..."
 	$RUNAS2 dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=102400 &
@@ -987,7 +1117,7 @@ test_12() {
 	    count=$[count+1]
 	    if [ $count -gt 64 ]; then
 		lustre_fail ost 0
-		error "dd should be finished!"
+		quota_error u $TSTUSR2 "dd should be finished!"
 	    fi
 	    sleep 1
 	done
@@ -1002,7 +1132,7 @@ test_12() {
 	    if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
 	    count=$[count+1]
 	    if [ $count -gt 150 ]; then
-		error "dd should be finished!"
+		quota_error u $TSTUSR "dd should be finished!"
 	    fi
 	    sleep 1
 	done
@@ -1011,7 +1141,7 @@ test_12() {
 	rm -f $TESTFILE $TESTFILE2
         sync; sleep 3; sync;
 
-        $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+        resetquota -u $TSTUSR
 }
 run_test_with_stat 12 "test a deadlock between quota and journal ==="
 
@@ -1026,7 +1156,7 @@ test_13() {
 
 	echo "   User quota (limit: $LIMIT kbytes)"
 	$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-	$SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
 	$LFS setstripe $TESTFILE -i 0 -c 1
 	chown $TSTUSR.$TSTUSR $TESTFILE
@@ -1046,7 +1176,7 @@ test_13() {
 	    if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
 	    count=$[count+1]
 	    if [ $count -gt 64 ]; then
-		error "dd should be finished!"
+		quota_error u $TSTUSR "dd should be finished!"
 	    fi
 	    sleep 1
 	done
@@ -1057,7 +1187,7 @@ test_13() {
 	    if ! ps -p ${DDPID1} > /dev/null 2>&1 ; then break; fi
 	    count=$[count+1]
 	    if [ $count -gt 64 ]; then
-		error "dd should be finished!"
+		quota_error u $TSTUSR "dd should be finished!"
 	    fi
 	    sleep 1
 	done
@@ -1070,12 +1200,12 @@ test_13() {
 	fz2=`stat -c %s $TESTFILE.2`
 	$SHOW_QUOTA_USER
 	[ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \
-		error "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"
+                quota_error u $TSTUSR "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"
 
 	rm -f $TESTFILE $TESTFILE.2
 	sync; sleep 3; sync;
 
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u $TSTUSR
 }
 run_test_with_stat 13 "test multiple clients write block quota ==="
 
@@ -1110,12 +1240,12 @@ test_14a() {	# was test_14 b=12223 -- setting quota on root
 	# out of root's file and block quota
 	$LFS setquota -u root -b 10 -B 10 -i 10 -I 10 $DIR
 	createmany -m ${TESTFILE} 20 || \
-	    error "unexpected: user(root) create files failly!"
+	    quota_error u root "unexpected: user(root) create files failly!"
 	dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \
-	    error "unexpected: user(root) write files failly!"
+	    quota_error u root "unexpected: user(root) write files failly!"
 	chmod 666 $TESTFILE
 	$RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \
-	    error "unexpected: user(quota_usr) write a file successfully!"
+	    quota_error u root "unexpected: user(quota_usr) write a file successfully!"
 
 	# trigger the llog
 	chmod 777 $DIR
@@ -1124,7 +1254,7 @@ test_14a() {	# was test_14 b=12223 -- setting quota on root
 
 	# do the check
 	dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "err -122 not found in dmesg"
-	$LFS setquota -u root -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -u root
 	#check_if_quota_zero u root
 
 	# clean
@@ -1134,29 +1264,6 @@ test_14a() {	# was test_14 b=12223 -- setting quota on root
 }
 run_test_with_stat 14a "test setting quota on root ==="
 
-# set quota version (both administrative and operational quotas)
-quota_set_version() {
-        do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
-        for j in `seq $OSTCOUNT`; do
-                do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=$1"
-        done
-}
-
-# save quota version (both administrative and operational quotas)
-# the function will also switch to the new version and the new type
-quota_save_version() {
-    local spec=$1
-    local ver=$(tr -c -d "123" <<< $spec)
-    local type=$(tr -c -d "ug" <<< $spec)
-
-    $LFS quotaoff -ug $MOUNT # just in case
-    [ -n "$ver" ] && quota_set_version $ver
-    [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
-
-    do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdt.quota_type=$spec"
-    do_facet mgs "lctl conf_param ${FSNAME}-OST*.ost.quota_type=$spec"
-}
-
 test_14b(){
         local l
         local CURSPACE
@@ -1192,7 +1299,7 @@ test_14b(){
                 l=$[$i*1024*128] # set limits in 128 Mb units
                 $LFS setquota -u quota15_$i -b $l -B $l -i $l -I $l $DIR || error "lfs setquota failed"
                 runas -u quota15_$i dd if=/dev/zero of="$DIR/$tdir/quota15_$i" \
-                      bs=1048576 count=$[($i+1)/2] || error "dd failed"
+                      bs=1048576 count=$[($i+1)/2] || quota_error u quota15_$i "dd failed"
         done
 
         cancel_lru_locks osc
@@ -1224,7 +1331,7 @@ test_14b(){
                 echo "...real is $l"
                 [ "$l" -eq "${CURSPACE[$i]}" ] || error "curspace mismatch"
                 rm $DIR/$tdir/quota15_$i || error "could not remove quota15_$i"
-                $LFS setquota -u quota15_$i -b 0 -B 0 -i 0 -I 0 $DIR || error "ifs setquota clear failed"
+                resetquota -u quota15_$i 
         done
 }
 run_test_with_stat 14b "setting 30 quota entries in quota v1 file before conversion ==="
@@ -1233,26 +1340,34 @@ test_15(){
         LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
         PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
 
-	wait_delete_completed
+        wait_delete_completed
+
+        # force using the latest version in case 14b was omitted
+        $LFS quotaoff -ug $DIR
+        quota_set_version 3 2>&1 | grep "Invalid argument" && quota_set_version 2
+        $LFS quotacheck -ug $DIR || error "quotacheck failed"
 
         # test for user
         $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
         TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
         [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
         echo "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
-        $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+        resetquota -u $TSTUSR
 
         # test for group
         $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
         TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
         [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
         echo "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
-        $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+
+        resetquota -g $TSTUSR
 
         quota_save_version "ug1"
 
         echo "Testing that >4GB quota limits fail on volume with quota v1"
-        ! $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
+        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR && error "no error from setquota, but should have failed"
+
+        return 0
 }
 run_test_with_stat 15 "set block quota more than 4T ==="
 
@@ -1267,10 +1382,10 @@ test_16_tub() {
 	echo "  User quota (limit: $LIMIT kbytes)"
 	if [ $1 == "u" ]; then
 	    $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-	    $SHOW_QUOTA_USER
+            quota_show_check b u $TSTUSR
 	else
 	    $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-	    $SHOW_QUOTA_GROUP
+            quota_show_check b g $TSTUSR
 	fi
 
 	$LFS setstripe $TESTFILE -c 1
@@ -1278,7 +1393,7 @@ test_16_tub() {
 
 	echo "    Write ..."
 	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \
-	    error "(usr) write failure, but expect success"
+	    quota_error a $TSTUSR "(usr) write failure, but expect success"
 	echo "    Done"
 	echo "    Write out of block quota ..."
 	# this time maybe cache write,  ignore it's failure
@@ -1287,15 +1402,15 @@ test_16_tub() {
         cancel_lru_locks osc
 	if [ $2 -eq 1 ]; then
 	    $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \
-		error "(write failure, but expect success"
+		quota_error a $TSTUSR "(write failure, but expect success"
 	else
 	    $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \
-		error "(write success, but expect EDQUOT"
+		quota_error a $TSTUSR "(write success, but expect EDQUOT"
 	fi
 
 	rm -f $TESTFILE
 	sync; sleep 3; sync;
-	$LFS setquota -$1 $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
+	resetquota -$1 $TSTUSR
 }
 
 # test without adjusting qunit
@@ -1338,24 +1453,24 @@ test_17() {
 	log "  Set enough high limit(block:$BLK_LIMIT) for group: $TSTUSR"
 	$LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
 
+        quota_show_check b u $TSTUSR
+        quota_show_check b g $TSTUSR
+
 	touch $TESTFILE
 	chown $TSTUSR.$TSTUSR $TESTFILE
 	touch $TESTFILE2
 	chown $TSTUSR.$TSTUSR $TESTFILE2
 
-        $SHOW_QUOTA_USER
-        $SHOW_QUOTA_GROUP
-
 	log "    Write the test file1 ..."
 	$RUNAS dd if=/dev/zero of=$TESTFILE  bs=$BLK_SZ count=$(( 10 * 1024 )) \
-	    || echo "write 10M file failure"
+	    || quota_error a $TSTUSR "write 10M file failure"
 
         $SHOW_QUOTA_USER
         $SHOW_QUOTA_GROUP
 
 	log "    write the test file2 ..."
 	$RUNAS dd if=/dev/zero of=$TESTFILE2  bs=$BLK_SZ count=$(( 10 * 1024 )) \
-	    || error "write 10M file failure"
+	    || quota_error a $TSTUSR "write 10M file failure"
 
         $SHOW_QUOTA_USER
         $SHOW_QUOTA_GROUP
@@ -1370,8 +1485,8 @@ test_17() {
 	set_blk_unitsz $((128 * 1024))
 	set_blk_tunesz $((128 * 1024 / 2))
 
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
-	$LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+	resetquota -u $TSTUSR
+	resetquota -g $TSTUSR
 
 	return $RC
 }
@@ -1391,7 +1506,7 @@ test_18() {
 
 	log "   User quota (limit: $LIMIT kbytes)"
 	$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-	$SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
 	$LFS setstripe $TESTFILE -i 0 -c 1
 	chown $TSTUSR.$TSTUSR $TESTFILE
@@ -1408,25 +1523,32 @@ test_18() {
 
 	echo  "   step2: testing ......"
 	count=0
-	timeout=$(lctl get_param -n timeout)
+	if at_is_enabled; then
+	    timeout=$(at_max_get mds)
+	else
+	    timeout=$(lctl get_param -n timeout)
+	fi
 	while [ true ]; do
 	    if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
 	    count=$[count+1]
 	    if [ $count -gt $((4 * $timeout)) ]; then
-		error "count=$count dd should be finished!"
+		quota_error u $TSTUSR "count=$count dd should be finished!"
 	    fi
 	    sleep 1
 	done
         log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
+        sync
+        cancel_lru_locks mdc
+        cancel_lru_locks osc
 
         testfile_size=$(stat -c %s $TESTFILE)
         [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
-	    error "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
-	rm -f $TESTFILE
-	sync; sleep 3; sync;
-
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+	    quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
+        $SHOW_QUOTA_USER
+        rm -f $TESTFILE
+        sync
 
+	resetquota -u $TSTUSR
 	set_blk_unitsz $((128 * 1024))
 	set_blk_tunesz $((128 * 1024 / 2))
 }
@@ -1445,7 +1567,7 @@ test_18a() {
 
 	log "   User quota (limit: $LIMIT kbytes)"
 	$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-	$SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
 	$LFS setstripe $TESTFILE -i 0 -c 1
 	chown $TSTUSR.$TSTUSR $TESTFILE
@@ -1459,25 +1581,27 @@ test_18a() {
 
 	echo  "   step2: testing ......"
 	count=0
-	timeout=$(lctl get_param -n timeout)
+	if at_is_enabled; then
+	    timeout=$(at_max_get mds)
+	else
+	    timeout=$(lctl get_param -n timeout)
+	fi
 	while [ true ]; do
 	    if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
 	    count=$[count+1]
 	    if [ $count -gt $((3 * $timeout)) ]; then
 		lustre_fail mds 0
-		error "count=$count dd should be finished!"
+		quota_error u $TSTUSR "count=$count dd should be finished!"
 	    fi
 	    sleep 1
 	done
         log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
 
         lustre_fail mds 0
-
 	rm -f $TESTFILE
-	sync; sleep 3; sync;
-
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+	sync
 
+	resetquota -u $TSTUSR
 	set_blk_unitsz $((128 * 1024))
 	set_blk_tunesz $((128 * 1024 / 2))
 }
@@ -1499,7 +1623,7 @@ test_18bc_sub() {
 
         log "   User quota (limit: $LIMIT kbytes)"
         $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-        $SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
         $LFS setstripe $TESTFILE -i 0 -c 1
         chown $TSTUSR.$TSTUSR $TESTFILE
@@ -1529,6 +1653,11 @@ test_18bc_sub() {
         fi
 
         count=0
+        if at_is_enabled; then
+	    timeout=$(at_max_get mds)
+        else
+	    timeout=$(lctl get_param -n timeout)
+        fi
         while [ true ]; do
 	    if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
             if [ $((++count % (2 * timeout) )) -eq 0 ]; then
@@ -1537,15 +1666,20 @@ test_18bc_sub() {
             sleep 1
         done
         log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
-        sync; sleep 1; sync
+        sync
+        cancel_lru_locks mdc
+        cancel_lru_locks osc
 
         testfile_size=$(stat -c %s $TESTFILE)
         [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
-	    error "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
+	    quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
         $SHOW_QUOTA_USER
-        $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
-        rm -rf $TESTFILE
-        sync; sleep 1; sync
+        rm -f $TESTFILE
+        sync
+
+	resetquota -u $TSTUSR
+	set_blk_unitsz $((128 * 1024))
+	set_blk_tunesz $((128 * 1024 / 2))
 }
 
 # test when mds does failover, the ost still could work well
@@ -1561,7 +1695,7 @@ test_18b() {
 				       print;
 			       }
 		       }' $TMP/lustre-log-${TESTNAME}.log`
-	if [ -n "$watchdog" ]; then error "$watchdog"; fi
+	[ `echo "$watchdog" | wc -l` -ge 3 ] && error "$watchdog"
 	rm -f $TMP/lustre-log-${TESTNAME}.log
 }
 run_test_with_stat 18b "run for fixing bug14840(mds failover, no watchdog) ==========="
@@ -1592,18 +1726,18 @@ run_to_block_limit() {
 
 	echo "  User quota (limit: $LIMIT kbytes)"
 	$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-	$SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 	echo "  Updating quota limits"
 	$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-	$SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
 	RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
-	$RUNDD count=$BUNIT_SZ || error "(usr) write failure, but expect success"
+	$RUNDD count=$BUNIT_SZ || quota_error u $TSTUSR "(usr) write failure, but expect success"
 	# for now page cache of TESTFILE may still be dirty,
 	# let's push it to the corresponding OST, this will also
 	# cache NOQUOTA on the client from OST's reply
 	cancel_lru_locks osc
-	$RUNDD seek=$BUNIT_SZ && error "(usr) write success, should be EDQUOT"
+	$RUNDD seek=$BUNIT_SZ && quota_error u $TSTUSR "(usr) write success, should be EDQUOT"
 }
 
 test_19() {
@@ -1616,7 +1750,7 @@ test_19() {
 
 	# cleanup
 	rm -f $TESTFILE
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+	resetquota -u $TSTUSR
 
 	set_blk_unitsz $((128 * 1024))
 	set_blk_tunesz $((128 * 1024 / 2))
@@ -1641,9 +1775,7 @@ test_20()
             grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \
                  || error "lfs quota output is unexpected"
 
-        $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 \
-                                 $MOUNT || error "could not reset quota limits"
-
+        resetquota -u $TSTUSR
 }
 run_test_with_stat 20 "test if setquota specifiers work properly (15754)"
 
@@ -1699,7 +1831,7 @@ test_21() {
 	    if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
 	    count=$[count+1]
 	    if [ $count -gt 60 ]; then
-		error "dd should be finished!"
+		quota_error a $TSTUSR "dd should be finished!"
 	    fi
 	    sleep 1
 	done
@@ -1710,7 +1842,7 @@ test_21() {
 	    if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
 	    count=$[count+1]
 	    if [ $count -gt 60 ]; then
-		error "dd should be finished!"
+		quota_error a $TSTUSR "dd should be finished!"
 	    fi
 	    sleep 1
 	done
@@ -1718,25 +1850,19 @@ test_21() {
 
 	set_blk_unitsz $((128 * 1024))
 	set_blk_tunesz $((128 * 1024 / 2))
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
-	$LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+	resetquota -u $TSTUSR
+	resetquota -g $TSTUSR
 
 	return $RC
 }
 run_test_with_stat 21 "run for fixing bug16053 ==========="
 
 test_22() {
-        local SAVEREFORMAT
-
-        SAVEREFORMAT=$REFORMAT
-
         quota_save_version "ug1"
 
-        REFORMAT="reformat"
         stopall
         mount
         setupall
-        REFORMAT=$SAVEREFORMAT
 
         echo "checking parameters"
 
@@ -1751,6 +1877,7 @@ test_23_sub() {
 	mkdir -p $DIR/$tdir
 	chmod 0777 $DIR/$tdir
 	TESTFILE="$DIR/$tdir/$tfile-0"
+	rm -f $TESTFILE
 	local bs_unit=$((1024*1024))
 	LIMIT=$1
 
@@ -1760,20 +1887,20 @@ test_23_sub() {
 	log "  User quota (limit: $LIMIT kbytes)"
 	$LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
 	sleep 3
-	$SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
 	$LFS setstripe $TESTFILE -c 1
 	chown $TSTUSR.$TSTUSR $TESTFILE
 
 	log "    Step1: trigger quota with 0_DIRECT"
 	log "      Write half of file"
-	$RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || error "(usr) write failure, but expect success"
+	$RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || quota_error u $TSTUSR "(1) write failure, but expect success: $LIMIT"
 	log "      Write out of block quota ..."
-	$RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && error "(usr) write success, but expect EDQUOT"
+	$RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && quota_error u $TSTUSR "(2) write success, but expect EDQUOT: $LIMIT"
 	log "    Step1: done"
 
 	log "    Step2: rewrite should succeed"
-	$RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit 2>&1 || error "(usr) write failure, but expect success"
+	$RUNAS $DIRECTIO write $TESTFILE 0 1 $bs_unit || quota_error u $TSTUSR "(3) write failure, but expect success: $LIMIT"
 	log "    Step2: done"
 
 	rm -f $TESTFILE
@@ -1782,10 +1909,9 @@ test_23_sub() {
 	OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
 	echo $OST0_QUOTA_USED
 	[ $OST0_QUOTA_USED -ne 0 ] && \
-	    ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+	    ($SHOW_QUOTA_USER; quota_error u $TSTUSR "quota deleted isn't released")
 	$SHOW_QUOTA_USER
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR
-
+	resetquota -u $TSTUSR
 }
 
 test_23() {
@@ -1808,7 +1934,7 @@ test_24() {
 
 	# cleanup
 	rm -f $TESTFILE
-	$LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $MOUNT
+	resetquota -u $TSTUSR
 
 	set_blk_unitsz $((128 * 1024))
 	set_blk_tunesz $((128 * 1024 / 2))
@@ -1816,6 +1942,160 @@ test_24() {
 }
 run_test_with_stat 24 "test if lfs draws an asterix when limit is reached (16646) ==========="
 
+show_quota() {
+        if [ $1 = "-u" ]; then
+                if [ $2 = "$TSTUSR" ]; then
+	                $SHOW_QUOTA_USER
+                else
+                        $SHOW_QUOTA_USER2
+                fi
+        else
+                if [ $2 = "$TSTUSR" ]; then
+                        $SHOW_QUOTA_GROUP
+                else
+                        $SHOW_QUOTA_GROUP2
+                fi
+        fi
+}
+
+test_25_sub() {
+	mkdir -p $DIR/$tdir
+	chmod 0777 $DIR/$tdir
+	TESTFILE="$DIR/$tdir/$tfile-0"
+	rm -f $TESTFILE
+	LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) + 4096 ))
+
+	wait_delete_completed
+
+        # set quota for $TSTUSR
+        log "setquota for $TSTUSR"
+	$LFS setquota $1 $TSTUSR -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
+	sleep 3
+        if [ "$1" == "-u" ]; then
+                quota_show_check a u $TSTUSR
+        else
+                quota_show_check a g $TSTUSR
+        fi
+
+        # set quota for $TSTUSR2
+        log "setquota for $TSTUSR2"
+	$LFS setquota $1 $TSTUSR2 -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
+	sleep 3
+        if [ "$1" == "-u" ]; then
+                quota_show_check a u $TSTUSR2
+        else
+                quota_show_check a g $TSTUSR2
+        fi
+
+        # set stripe index to 0
+        log "setstripe for $DIR/$tdir to 0"
+	$LFS setstripe $DIR/$tdir -c 1 -i 0
+	MDS_UUID=`do_facet mds $LCTL dl | grep -m1 mds | awk '{print $((NF-1))}'`
+	OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
+	MDS_QUOTA_USED_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
+	OST0_QUOTA_USED_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
+	MDS_QUOTA_USED2_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
+	OST0_QUOTA_USED2_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
+
+        # TSTUSR write 4M
+        log "$TSTUSR write 4M to $TESTFILE"
+        $RUNAS dd if=/dev/zero of=$TESTFILE bs=4K count=1K || quota_error a $TSTUSR "dd failed"
+        sync
+	show_quota $1 $TSTUSR
+	show_quota $1 $TSTUSR2
+	MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
+        [ $MDS_QUOTA_USED_NEW -ne $((MDS_QUOTA_USED_OLD + 1)) ] && \
+                quota_error a $TSTUSR "$TSTUSR inode quota usage error: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
+	OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
+        OST0_QUOTA_USED_DELTA=$((OST0_QUOTA_USED_NEW - OST0_QUOTA_USED_OLD))
+        [ $OST0_QUOTA_USED_DELTA -lt 4096 ] && \
+                quota_error a $TSTUSR "$TSTUSR block quota usage error: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
+
+        # chown/chgrp from $TSTUSR to $TSTUSR2
+        if [ $1 = "-u" ]; then
+                log "chown from $TSTUSR to $TSTUSR2"
+                chown $TSTUSR2 $TESTFILE || quota_error u $TSTUSR2 "chown failed"
+        else
+                log "chgrp from $TSTUSR to $TSTUSR2"
+                chgrp $TSTUSR2 $TESTFILE || quota_error g $TSTUSR2 "chgrp failed"
+        fi
+        sync
+	show_quota $1 $TSTUSR
+	show_quota $1 $TSTUSR2
+	MDS_QUOTA_USED2_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
+        [ $MDS_QUOTA_USED2_NEW -ne $((MDS_QUOTA_USED2_OLD + 1)) ] && \
+                quota_error a $TSTUSR2 "$TSTUSR2 inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED2_OLD|$MDS_QUOTA_USED2_NEW]"
+	OST0_QUOTA_USED2_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
+        OST0_QUOTA_USED2_DELTA=$((OST0_QUOTA_USED2_NEW - OST0_QUOTA_USED2_OLD))
+        [ $OST0_QUOTA_USED2_DELTA -ne $OST0_QUOTA_USED_DELTA ] && \
+                quota_error a $TSTUSR2 "$TSTUSR2 block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED2_OLD|$OST0_QUOTA_USED2_NEW]"
+	MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
+        [ $MDS_QUOTA_USED_NEW -ne $MDS_QUOTA_USED_OLD ] && \
+                quota_error a $TSTUSR "$TSTUSR inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
+	OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
+        [ $OST0_QUOTA_USED_NEW -ne $OST0_QUOTA_USED_OLD ] && \
+                quota_error a $TSTUSR "$TSTUSR block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
+
+	rm -f $TESTFILE
+	wait_delete_completed
+	resetquota $1 $TSTUSR
+	resetquota $1 $TSTUSR2
+}
+
+test_25() {
+	log "run for chown case"
+	test_25_sub -u
+
+	log "run for chgrp case"
+	test_25_sub -g
+}
+run_test_with_stat 25 "test whether quota usage is transfered when chown/chgrp (18081) ==========="
+
+test_26() {
+	mkdir -p $DIR/$tdir
+	chmod 0777 $DIR/$tdir
+	TESTFILE="$DIR/$tdir/$tfile-0"
+	TESTFILE2="$DIR/$tdir/$tfile-1"
+	set_blk_tunesz 512
+	set_blk_unitsz 1024
+
+	wait_delete_completed
+
+	# every quota slave gets 20MB
+	b_limit=$((OSTCOUNT * 20 * 1024))
+	log "limit: ${b_limit}KB"
+	$LFS setquota -u $TSTUSR -b 0 -B $b_limit -i 0 -I 0 $DIR
+	sleep 3
+	quota_show_check b u $TSTUSR
+
+	$LFS setstripe $TESTFILE  -c 1 -i 0
+	$LFS setstripe $TESTFILE2 -c 1 -i 0
+	chown $TSTUSR.$TSTUSR $TESTFILE
+	chown $TSTUSR.$TSTUSR $TESTFILE2
+
+	#define OBD_FAIL_QUOTA_DELAY_REL         0xA03
+	lustre_fail ost 0xA03
+
+	log "    Write the first file..."
+	$RUNAS $DIRECTIO write $TESTFILE 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
+	log "    Delete the first file..."
+	rm -f $TESTFILE
+
+
+	wait_delete_completed
+
+	log "    Write the second file..."
+	$RUNAS $DIRECTIO write $TESTFILE2 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
+	log "    Delete the second file..."
+	rm -f $TESTFILE2
+
+	lustre_fail ost 0
+	set_blk_unitsz $((128 * 1024))
+	set_blk_tunesz $((128 * 1024 / 2))
+	resetquota -u $TSTUSR
+}
+run_test_with_stat 26 "test for false quota error(bz18491) ======================================"
+
 test_27() {
         $LFS quota $TSTUSR $DIR && error "lfs succeeded with no type, but should have failed"
         $LFS setquota $TSTUSR $DIR && error "lfs succeeded with no type, but should have failed"
@@ -1823,6 +2103,54 @@ test_27() {
 }
 run_test_with_stat 27 "lfs quota/setquota should handle wrong arguments (19612) ================="
 
+test_28() {
+        BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
+        echo "Step 1: set enough high limit for user [$TSTUSR:$BLK_LIMIT]"
+        $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
+        $SHOW_QUOTA_USER
+
+        echo "Step 2: reset system ..."
+        cleanup_and_setup_lustre
+        test_0
+
+        echo "Step 3: change qunit for user [$TSTUSR:512:1024]"
+        set_blk_tunesz 512
+        set_blk_unitsz 1024
+
+        wait_delete_completed
+
+        #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE
+        lustre_fail ost 0x80000A02
+
+        TESTFILE="$DIR/$tdir/$tfile"
+        mkdir -p $DIR/$tdir
+
+        BLK_LIMIT=$((100 * 1024)) # 100M
+        echo "Step 4: set enough high limit for user [$TSTUSR:$BLK_LIMIT]"
+        $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
+        $SHOW_QUOTA_USER
+
+        touch $TESTFILE
+        chown $TSTUSR.$TSTUSR $TESTFILE
+
+        echo "Step 5: write the test file1 [10M] ..."
+        $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$BLK_SZ count=$(( 10 * 1024 )) \
+	    || quota_error a $TSTUSR "write 10M file failure"
+        $SHOW_QUOTA_USER
+
+        rm -f $TESTFILE
+        sync; sleep 3; sync;
+
+        # make qd_count 64 bit
+        lustre_fail ost 0
+
+        set_blk_unitsz $((128 * 1024))
+        set_blk_tunesz $((128 * 1024 / 2))
+
+        resetquota -u $TSTUSR
+}
+run_test_with_stat 28 "test for consistency for qunit when setquota (18574) ==========="
+
 # turn off quota
 test_99()
 {
diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh
index bdeec2f..5a7c2a4 100644
--- a/lustre/tests/sanity.sh
+++ b/lustre/tests/sanity.sh
@@ -7,8 +7,8 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test:  13297 2108 9789 3637 9789 3561 12622 15528/2330 5188 10764
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27u   42a  42b  42c  42d  45   51d   62         68   75 $SANITY_EXCEPT" }
+# bug number for skipped test:  13297 2108 9789 3637 9789 3561 12622 15528/2330 5188 10764 16410
+ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27u  42a  42b  42c  42d  45   51d   62         68   75    76 $SANITY_EXCEPT"}
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 # Tests that fail on uml, maybe elsewhere, FIXME
@@ -33,7 +33,6 @@ CREATETEST=${CREATETEST:-createtest}
 LFS=${LFS:-lfs}
 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
-LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
 LFIND=${LFIND:-"$LFS find"}
 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
 LSTRIPEINFO=${LSTRIPEINFO:-ll_getstripe_info}
@@ -42,7 +41,6 @@ MCREATE=${MCREATE:-mcreate}
 OPENFILE=${OPENFILE:-openfile}
 OPENUNLINK=${OPENUNLINK:-openunlink}
 READS=${READS:-"reads"}
-TOEXCL=${TOEXCL:-toexcl}
 TRUNCATE=${TRUNCATE:-truncate}
 MUNLINK=${MUNLINK:-munlink}
 SOCKETSERVER=${SOCKETSERVER:-socketserver}
@@ -71,7 +69,7 @@ init_test_env $@
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="24o 27m 36f 36g 51b 51c 60c 63 64b 68 71 73 77f 78 101 103 115 120g 124b"
 
 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
-FAIL_ON_ERROR=false
+FAIL_ON_ERROR=${FAIL_ON_ERROR:-false}
 
 cleanup() {
 	echo -n "cln.."
@@ -91,7 +89,7 @@ check_kernel_version() {
 	WANT_VER=$1
 	GOT_VER=$(lctl get_param -n $VERSION_FILE | awk '/kernel:/ {print $2}')
 	case $GOT_VER in
-	patchless|patchless_client) return 0 ;;
+	patchless|patchless_client) return 0;;
 	*) [ $GOT_VER -ge $WANT_VER ] && return 0 ;;
 	esac
 	log "test needs at least kernel version $WANT_VER, running $GOT_VER"
@@ -452,6 +450,15 @@ test_17g() {
 }
 run_test 17g "symlinks: really long symlink name ==============================="
 
+test_17h() { #bug 17378
+        mkdir -p $DIR/$tdir
+        $SETSTRIPE $DIR/$tdir -c -1
+#define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
+	do_facet mds lctl set_param fail_loc=0x80000141
+        touch $DIR/$tdir/$tfile || true
+}
+run_test 17h "create objects: lov_free_memmd() doesn't lbug"
+
 test_18() {
 	touch $DIR/f
 	ls $DIR || error
@@ -520,12 +527,28 @@ test_22() {
 }
 run_test 22 "unpack tar archive as non-root user ==============="
 
-test_23() {
-	mkdir $DIR/d23
-	$TOEXCL $DIR/d23/f23
-	$TOEXCL -e $DIR/d23/f23 || error
+# was test_23
+test_23a() {
+	mkdir -p $DIR/$tdir
+	local file=$DIR/$tdir/$tfile
+
+	openfile -f O_CREAT:O_EXCL $file || error "$file create failed"
+	openfile -f O_CREAT:O_EXCL $file &&
+		error "$file recreate succeeded" || true
+}
+run_test 23a "O_CREAT|O_EXCL in subdir =========================="
+
+test_23b() { # bug 18988
+	mkdir -p $DIR/$tdir
+	local file=$DIR/$tdir/$tfile
+
+        rm -f $file
+        echo foo > $file || error "write filed"
+        echo bar >> $file || error "append filed"
+        $CHECKSTAT -s 8 $file || error "wrong size"
+        rm $file
 }
-run_test 23 "O_CREAT|O_EXCL in subdir =========================="
+run_test 23b "O_APPEND check =========================="
 
 test_24a() {
 	echo '== rename sanity =============================================='
@@ -609,7 +632,7 @@ test_24i() {
 	mrename $DIR/R9/f $DIR/R9/a
 	$CHECKSTAT -t file $DIR/R9/f || error
 	$CHECKSTAT -t dir  $DIR/R9/a || error
-	$CHECKSTAT -a file $DIR/R9/a/f || error
+	$CHECKSTAT -a $DIR/R9/a/f || error
 }
 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
 
@@ -818,7 +841,7 @@ run_test 27c "create two stripe file f01 ======================="
 
 test_27d() {
 	mkdir -p $DIR/d27
-	$SETSTRIPE $DIR/d27/fdef 0 -1 0 || error "lstripe failed"
+	$SETSTRIPE -c0 -i-1 -s0 $DIR/d27/fdef || error "lstripe failed"
 	$CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
 	dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
 }
@@ -830,7 +853,7 @@ test_27e() {
 	$SETSTRIPE $DIR/d27/f12 -c 2 && error "lstripe succeeded twice"
 	$CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
 }
-run_test 27e "lstripe existing file (should return error) ======"
+run_test 27e "setstripe existing file (should return error) ======"
 
 test_27f() {
 	mkdir -p $DIR/d27
@@ -838,7 +861,7 @@ test_27f() {
 	dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
 	$GETSTRIPE $DIR/d27/fbad || error "lfs getstripe failed"
 }
-run_test 27f "lstripe with bad stripe size (should return error)"
+run_test 27f "setstripe with bad stripe size (should return error)"
 
 test_27g() {
 	mkdir -p $DIR/d27
@@ -857,7 +880,7 @@ test_27j() {
 	mkdir -p $DIR/d27
 	$SETSTRIPE $DIR/d27/f27j -i $OSTCOUNT && error "lstripe failed"||true
 }
-run_test 27j "lstripe with bad stripe offset (should return error)"
+run_test 27j "setstripe with bad stripe offset (should return error)"
 
 test_27k() { # bug 2844
 	mkdir -p $DIR/d27
@@ -928,8 +951,9 @@ exhaust_precreations() {
 		awk '{print $2}' | sed -e 's/_UUID$//')
 
 	# on the mdt's osc
-	local last_id=$(do_facet mds lctl get_param -n osc.${OST}-osc.prealloc_last_id)
-	local next_id=$(do_facet mds lctl get_param -n osc.${OST}-osc.prealloc_next_id)
+	local mdtosc=$(get_mdtosc_proc_path $OST)
+	local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
+	local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
 
 	mkdir -p $DIR/d27/${OST}
 	$SETSTRIPE $DIR/d27/${OST} -i $OSTIDX -c 1
@@ -937,7 +961,7 @@ exhaust_precreations() {
 	do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
 	echo "Creating to objid $last_id on ost $OST..."
 	createmany -o $DIR/d27/${OST}/f $next_id $((last_id - next_id + 2))
-	do_facet mds "lctl get_param -n osc.${OST}-osc.prealloc*" | grep '[0-9]'
+	do_facet mds "lctl get_param -n osc.$mdtosc.prealloc*" | grep '[0-9]'
 	reset_enospc $2 $OSTIDX
 }
 
@@ -1041,7 +1065,7 @@ test_27s() { # bug 10725
 	mkdir -p $DIR/$tdir
 	local stripe_size=$((4096 * 1024 * 1024))	# 2^32
 	local stripe_count=0
-	[ $OSTCOUNT -eq 1 ] || stripe_count=2 
+	[ $OSTCOUNT -eq 1 ] || stripe_count=2
 	$SETSTRIPE $DIR/$tdir -s $stripe_size -c $stripe_count && \
 		error "stripe width >= 2^32 succeeded" || true
 }
@@ -1109,14 +1133,15 @@ run_test 27v "skip object creation on slow OST ================="
 
 test_27w() { # bug 10997
         mkdir -p $DIR/d27w || error "mkdir failed"
-        $LSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed"
+        $SETSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed"
         size=`$LSTRIPEINFO $DIR/d27w/f0 | awk {'print $1'}`
         [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
 
         [ "$OSTCOUNT" -lt "2" ] && skip "skipping multiple stripe count/offset test" && return
         for i in `seq 1 $OSTCOUNT`; do
                 offset=$(($i-1))
-                $LSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
+                log setstripe $DIR/d27w/f$i -c $i -i $offset
+                $SETSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
                 count=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $2'}`
                 index=`$LSTRIPEINFO $DIR/d27w/f$i | awk {'print $3'}`
                 [ $count -ne $i ] && error "stripe count $count != $i" || true
@@ -1125,7 +1150,9 @@ test_27w() { # bug 10997
 }
 run_test 27w "check lfs setstripe -c -s -i options ============="
 
-test_28() {
+# createtest also checks that device nodes are created and
+# then visible correctly (#2091)
+test_28() { # bug 2091
 	mkdir $DIR/d28
 	$CREATETEST $DIR/d28/ct || error
 }
@@ -1139,7 +1166,7 @@ test_29() {
 	ls -l $DIR/d29
 	LOCKCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_count`
 	LOCKUNUSEDCOUNTORIG=`lctl get_param -n ldlm.namespaces.*mdc*.lock_unused_count`
-	[ -z $"LOCKCOUNTORIG" ] && echo "No mdc lock count" && return 1
+	[ -z $"LOCKCOUNTORIG" ] && error "No mdc lock count" && return 1
 	log 'second d29'
 	ls -l $DIR/d29
 	log 'done'
@@ -1465,9 +1492,9 @@ test_33b() {
         rm -fr $DIR/d33
         mkdir -p $DIR/d33
         chown $RUNAS_ID $DIR/d33
-        $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
+        $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 || true
 }
-run_test 33b "test open file with malformed flags (No panic and return error)"
+run_test 33b "test open file with malformed flags (No panic)"
 
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
@@ -1625,9 +1652,15 @@ test_37() {
 run_test 37 "ls a mounted file system to check old content ====="
 
 test_38() {
-	o_directory $DIR/$tfile
+	local file=$DIR/$tfile
+	touch $file
+	openfile -f O_DIRECTORY $file
+	local RC=$?
+	local ENOTDIR=20
+	[ $RC -eq 0 ] && error "opened file $file with O_DIRECTORY" || true
+	[ $RC -eq $ENOTDIR ] || error "error $RC should be ENOTDIR ($ENOTDIR)"
 }
-run_test 38 "open a regular file with O_DIRECTORY =============="
+run_test 38 "open a regular file with O_DIRECTORY should return -ENOTDIR ==="
 
 test_39() {
 	touch $DIR/$tfile
@@ -1701,18 +1734,26 @@ test_39b() {
         echo ${UNLINK_OLD[1]},${UNLINK_NEW[$MTIME]},${UNLINK_NEW2[$MTIME]}
         echo ${RENAME_OLD[1]},${RENAME_NEW[$MTIME]},${RENAME_NEW2[$MTIME]}
 
-
-        [ ${OPEN_NEW2[$MTIME]} -eq ${OPEN_NEW[$MTIME]} ] || \
-                error "open file reverses mtime"
-        [ ${LINK_NEW2[$MTIME]} -eq ${LINK_NEW[$MTIME]} ] || \
-                error "link file reverses mtime"
-        [ ${UNLINK_NEW2[$MTIME]} -eq ${UNLINK_NEW[$MTIME]} ] || \
-                error "unlink file reverses mtime"
-        [ ${RENAME_NEW2[$MTIME]} -eq ${RENAME_NEW[$MTIME]} ] || \
-                error "rename file reverses mtime"
+        [ ${OPEN_NEW2[$MTIME]} -eq ${OPEN_NEW[$MTIME]} ] || error "open file reverses mtime"
+        [ ${LINK_NEW2[$MTIME]} -eq ${LINK_NEW[$MTIME]} ] || error "link file reverses mtime"
+        [ ${UNLINK_NEW2[$MTIME]} -eq ${UNLINK_NEW[$MTIME]} ] || error "unlink file reverses mtime"
+        [ ${RENAME_NEW2[$MTIME]} -eq ${RENAME_NEW[$MTIME]} ] || error "rename file reverses mtime"
 }
 run_test 39b "mtime change on close ============================"
 
+# bug 11063
+test_39c() {
+        touch -m -d "10 years ago" $DIR1/$tfile
+        local MTIME1=`stat -c %y $DIR1/$tfile`
+        echo hello >> $DIR1/$tfile
+        local MTIME2=`stat -c %y $DIR1/$tfile`
+        mv $DIR1/$tfile $DIR1/$tfile-1
+        local MTIME3=`stat -c %y $DIR1/$tfile-1`
+        [ "$MTIME2" = "$MTIME3" ] ||
+                error "mtime ($MTIME2) changed (to $MTIME3) on rename (BZ#11063)"
+}
+run_test 39c "mtime change on rename ==========================="
+
 test_40() {
 	dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
 	$RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
@@ -2015,11 +2056,7 @@ test_46() {
 }
 run_test 46 "dirtying a previously written page ================"
 
-# Check that device nodes are created and then visible correctly (#2091)
-test_47() {
-	cmknod $DIR/test_47_node || error
-}
-run_test 47 "Device nodes check ================================"
+# test_47 is removed "Device nodes check" is moved to test_28
 
 test_48a() { # bug 2399
 	check_kernel_version 34 || return 0
@@ -2210,14 +2247,15 @@ test_52a() {
 	[ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
 	mkdir -p $DIR/d52a
 	touch $DIR/d52a/foo
-	chattr =a $DIR/d52a/foo || error "chattr =a failed"
+	chattr +a $DIR/d52a/foo || error "chattr +a failed"
 	echo bar >> $DIR/d52a/foo || error "append bar failed"
 	cp /etc/hosts $DIR/d52a/foo && error "cp worked"
 	rm -f $DIR/d52a/foo 2>/dev/null && error "rm worked"
 	link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error "link worked"
 	echo foo >> $DIR/d52a/foo || error "append foo failed"
 	mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error "rename worked"
-	lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error "lsattr"
+	# new lsattr displays 'e' flag for extents
+	lsattr $DIR/d52a/foo | egrep -q "^-+a[-e]+ $DIR/d52a/foo" || error "lsattr"
 	chattr -a $DIR/d52a/foo || error "chattr -a failed"
 
 	rm -fr $DIR/d52a || error "cleanup rm failed"
@@ -2228,19 +2266,19 @@ test_52b() {
 	[ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
 	mkdir -p $DIR/d52b
 	touch $DIR/d52b/foo
-	chattr =i $DIR/d52b/foo || error
-	cat test > $DIR/d52b/foo && error
-	cp /etc/hosts $DIR/d52b/foo && error
-	rm -f $DIR/d52b/foo 2>/dev/null && error
-	link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
-	echo foo >> $DIR/d52b/foo && error
-	mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
+	chattr +i $DIR/d52b/foo || error "chattr +i failed"
+	cat test > $DIR/d52b/foo && error "cat test worked"
+	cp /etc/hosts $DIR/d52b/foo && error "cp worked"
+	rm -f $DIR/d52b/foo 2>/dev/null && error "rm worked"
+	link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error "link worked"
+	echo foo >> $DIR/d52b/foo && error "echo worked"
+	mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error "rename worked"
 	[ -f $DIR/d52b/foo ] || error
 	[ -f $DIR/d52b/foo_ren ] && error
-	lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
-	chattr -i $DIR/d52b/foo || error
+	lsattr $DIR/d52b/foo | egrep -q "^-+i[-e]+ $DIR/d52b/foo" || error "lsattr"
+	chattr -i $DIR/d52b/foo || error "chattr failed"
 
-	rm -fr $DIR/d52b || error
+	rm -fr $DIR/d52b || error "remove failed"
 }
 run_test 52b "immutable flag test (should return errors) ======="
 
@@ -2251,9 +2289,10 @@ test_52c() { # 12848 simulating client < 1.4.7
         # skip MDS_BFLAG_EXT_FLAGS in mdc_getattr_pack
 #define OBD_FAIL_MDC_OLD_EXT_FLAGS       0x802
         lctl set_param fail_loc=0x802
-        chattr =i $DIR/d52c/foo || error
-        lsattr $DIR/d52c/foo | egrep -q "^-+i-+ $DIR/d52c/foo" || error
-        chattr -i $DIR/d52c/foo || error
+        chattr +i $DIR/d52c/foo || error "chattr +i failed"
+        lsattr $DIR/d52c/foo | egrep -q "^-+i[-e]+ $DIR/d52c/foo" ||
+		error "lsattr failed"
+        chattr -i $DIR/d52c/foo || error "chattr failed"
         lctl set_param -n fail_loc=0
 
         rm -fr $DIR/d52c || error
@@ -2470,7 +2509,7 @@ setup_56_special() {
 }
 
 test_56g() {
-        $LSTRIPE -d $DIR
+        $SETSTRIPE -d $DIR
 
         setup_56 $NUMFILES $NUMDIRS
 
@@ -2486,7 +2525,7 @@ test_56g() {
 run_test 56g "check lfs find -name ============================="
 
 test_56h() {
-        $LSTRIPE -d $DIR
+        $SETSTRIPE -d $DIR
 
         setup_56 $NUMFILES $NUMDIRS
 
@@ -2626,11 +2665,11 @@ run_test 56q "check lfs find -gid and ! -gid ==============================="
 test_57a() {
 	remote_mds_nodsh && skip "remote MDS with nodsh" && return
 
-	local MNTDEV="mds.*.mntdev"
+	local MNTDEV=$(get_mds_mntdev_proc_path)
 	DEV=$(do_facet mds lctl get_param -n $MNTDEV)
 	[ -z "$DEV" ] && error "can't access $MNTDEV"
 	for DEV in $(do_facet mds lctl get_param -n $MNTDEV); do
-		do_facet mds dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
+		do_facet mds $DUMPE2FS -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
 		DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
 		[ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
 		rm $TMP/t57a.dump
@@ -2647,7 +2686,7 @@ test_57b() {
 
 	rm -rf $dir || error "removing $dir"
 	mkdir -p $dir || error "creating $dir"
-	
+
 	echo "mcreating $FILECOUNT files"
 	createmany -m $dir/f 1 $FILECOUNT || \
 		error "creating files in $dir"
@@ -2656,7 +2695,8 @@ test_57b() {
 	$GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
 	$GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
 
-	local MDSFREE=$(do_facet mds lctl get_param -n mds.*.kbytesfree)
+	local fsstat_dev=$(get_mds_fsstat_proc_path)
+	local MDSFREE=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
 	local MDCFREE=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
 	echo "opening files to create objects/EAs"
 	local FILE
@@ -2669,7 +2709,7 @@ test_57b() {
 	$GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
 
 	sleep 1 # make sure we get new statfs data
-	local MDSFREE2=$(do_facet mds lctl get_param -n mds.*.kbytesfree)
+	local MDSFREE2=$(do_facet mds lctl get_param -n $fsstat_dev.*.kbytesfree)
 	local MDCFREE2=$(lctl get_param -n mdc.*.kbytesfree | head -n 1)
 	if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
 		if [ "$MDSFREE" != "$MDSFREE2" ]; then
@@ -2870,7 +2910,7 @@ test_65e() {
 	touch $DIR/d65/f6
 	$LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
 }
-run_test 65e "directory setstripe 0 -1 0 ======================="
+run_test 65e "directory setstripe defaults ======================="
 
 test_65f() {
 	mkdir -p $DIR/d65f
@@ -2943,9 +2983,9 @@ test_65k() { # bug11679
 run_test 65k "validate manual striping works properly with deactivated OSCs"
 
 test_65l() { # bug 12836
-	mkdir -p $DIR/$tdir
-	$SETSTRIPE $DIR/$tdir -c -1
-	$LFS find -mtime -1 $DIR >/dev/null
+	mkdir -p $DIR/$tdir/test_dir
+	$SETSTRIPE $DIR/$tdir/test_dir -c -1
+	$LFS find -mtime -1 $DIR/$tdir > /dev/null
 }
 run_test 65l "lfs find on -1 stripe dir ========================"
 
@@ -2987,7 +3027,7 @@ test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
 	# needs to be in /etc/groups on MDS, gid == uid
 	# Let's use RUNAS_ID
 	T67_UID=${T67_UID:-$RUNAS_ID}
-	
+
 	[ "$UID" = "$T67_UID" ] && skip "UID = T67_UID = $UID -- skipping" && return
 	check_kernel_version 35 || return 0
 	do_facet mds grep -q ":$T67_UID:$T67_UID" /etc/passwd || \
@@ -3151,9 +3191,9 @@ test_73() {
 
 	sleep 25
 
-	$CHECKSTAT -t file $DIR/d73-1/f73-1 || return 4
-	$CHECKSTAT -t file $DIR/d73-1/f73-2 || return 5
-	$CHECKSTAT -t file $DIR/d73-2/f73-3 || return 6
+	$CHECKSTAT -t file $DIR/d73-1/f73-1 || error "$DIR/d73-1/f73-1 not file"
+	$CHECKSTAT -t file $DIR/d73-1/f73-2 || error "$DIR/d73-1/f73-2 not file"
+	$CHECKSTAT -t file $DIR/d73-2/f73-3 || error "$DIR/d73-2/f73-3 not file"
 
 	rm -rf $DIR/d73-*
 }
@@ -3549,7 +3589,7 @@ test_80() { # bug 10718
         dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
         sync; sleep 1; sync
         local BEFORE=`date +%s`
-        cancel_lru_locks OSC
+        cancel_lru_locks osc
         local AFTER=`date +%s`
         local DIFF=$((AFTER-BEFORE))
         if [ $DIFF -gt 1 ] ; then
@@ -3560,17 +3600,19 @@ test_80() { # bug 10718
 run_test 80 "Page eviction is equally fast at high offsets too  ===="
 
 test_99a() {
+	[ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
 	mkdir -p $DIR/d99cvsroot || error "mkdir $DIR/d99cvsroot failed"
 	chown $RUNAS_ID $DIR/d99cvsroot || error "chown $DIR/d99cvsroot failed"
 	local oldPWD=$PWD	# bug 13584, use $TMP as working dir
 	cd $TMP
-	
+
 	$RUNAS cvs -d $DIR/d99cvsroot init || error "cvs init failed"
 	cd $oldPWD
 }
 run_test 99a "cvs init ========================================="
 
 test_99b() {
+        [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
 	[ ! -d $DIR/d99cvsroot ] && test_99a
 	$RUNAS [ ! -w /tmp ] && skip "/tmp has wrong w permission -- skipping" && return
 	cd /etc/init.d || error "cd /etc/init.d failed"
@@ -3584,6 +3626,7 @@ test_99b() {
 run_test 99b "cvs import ======================================="
 
 test_99c() {
+        [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
 	[ ! -d $DIR/d99cvsroot ] && test_99b
 	cd $DIR || error "cd $DIR failed"
 	mkdir -p $DIR/d99reposname || error "mkdir $DIR/d99reposname failed"
@@ -3595,6 +3638,7 @@ test_99c() {
 run_test 99c "cvs checkout ====================================="
 
 test_99d() {
+        [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
 	[ ! -d $DIR/d99cvsroot ] && test_99c
 	cd $DIR/d99reposname
 	$RUNAS touch foo99
@@ -3603,6 +3647,7 @@ test_99d() {
 run_test 99d "cvs add =========================================="
 
 test_99e() {
+        [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
 	[ ! -d $DIR/d99cvsroot ] && test_99c
 	cd $DIR/d99reposname
 	$RUNAS cvs update
@@ -3610,6 +3655,7 @@ test_99e() {
 run_test 99e "cvs update ======================================="
 
 test_99f() {
+        [ -z "$(which cvs 2>/dev/null)" ] && skip "could not find cvs" && return
 	[ ! -d $DIR/d99cvsroot ] && test_99d
 	cd $DIR/d99reposname
 	$RUNAS cvs commit -m 'nomsg' foo99
@@ -3700,34 +3746,33 @@ test_101() {
 }
 run_test 101 "check read-ahead for random reads ================"
 
-export SETUP_TEST101=no
-setup_test101() {
-	[ "$SETUP_TEST101" = "yes" ] && return
+export SETUP_TEST101b=no
+setup_101b() {
+	[ "$SETUP_TEST101b" = "yes" ] && return
 	mkdir -p $DIR/$tdir
 	STRIPE_SIZE=1048576
 	STRIPE_COUNT=$OSTCOUNT
 	STRIPE_OFFSET=0
 
-	trap cleanup_test101 EXIT
+	trap cleanup_101 EXIT
 	# prepare the read-ahead file
 	$SETSTRIPE $DIR/$tfile -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $OSTCOUNT
 
 	dd if=/dev/zero of=$DIR/$tfile bs=1024k count=100 2> /dev/null
-	SETUP_TEST101=yes
+	SETUP_TEST101b=yes
 }
 
-cleanup_test101() {
-	[ "$SETUP_TEST101" = "yes" ] || return
+cleanup_101() {
 	trap 0
-	rm -rf $DIR/$tdir
-	SETUP_TEST101=no
+	rm -rf $DIR/$tdir $DIR/$tfile
+	SETUP_TEST101b=no
 }
 
 calc_total() {
 	awk 'BEGIN{total=0}; {total+=$1}; END{print total}'
 }
 
-ra_check_101() {
+ra_check_101b() {
 	local READ_SIZE=$1
 	local STRIPE_SIZE=1048576
 	local RA_INC=1048576
@@ -3741,73 +3786,166 @@ ra_check_101() {
 
 	if [ $DISCARD -gt $discard_limit ]; then
 		lctl get_param llite.*.read_ahead_stats
-		error "Too many ($DISCARD) discarded pages with size (${READ_SIZE})"
+		error "Too many ($DISCARD) discarded pages (size ${READ_SIZE})"
 	else
 		echo "Read-ahead success for size ${READ_SIZE}"
 	fi
 }
 
 test_101b() {
-	[ "$OSTCOUNT" -lt "2" ] && skip "skipping stride IO stride-ahead test" && return
+	[ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs for stride-read" && return
 	local STRIPE_SIZE=1048576
 	local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
 	local FILE_LENGTH=$((STRIPE_SIZE*100))
 	local ITERATION=$((FILE_LENGTH/STRIDE_SIZE))
 	# prepare the read-ahead file
-	setup_test101
+	setup_101b
 	cancel_lru_locks osc
-	for BIDX in 2 4 8 16 32 64 128 256
-	do
+	for BIDX in 2 4 8 16 32 64 128 256; do
 		local BSIZE=$((BIDX*4096))
 		local READ_COUNT=$((STRIPE_SIZE/BSIZE))
 		local STRIDE_LENGTH=$((STRIDE_SIZE/BSIZE))
 		local OFFSET=$((STRIPE_SIZE/BSIZE*(OSTCOUNT - 1)))
 		$LCTL set_param -n llite.*.read_ahead_stats 0
 		$READS -f $DIR/$tfile  -l $STRIDE_LENGTH -o $OFFSET \
-			      -s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
+			-s $FILE_LENGTH -b $STRIPE_SIZE -a $READ_COUNT -n $ITERATION
 		cancel_lru_locks osc
-		ra_check_101 $BSIZE
+		ra_check_101b $BSIZE
 	done
-	cleanup_test101
 	true
 }
 run_test 101b "check stride-io mode read-ahead ================="
 
+test_101c() {
+        local STRIPE_SIZE=1048576
+        local FILE_LENGTH=$((STRIPE_SIZE*100))
+        local nreads=10000
+
+        setup_101b
+
+        cancel_lru_locks osc
+        $LCTL set_param osc.*.rpc_stats 0
+        $READS -f $DIR/$tfile -s$FILE_LENGTH -b65536 -n$nreads -t 180
+        for OSC in `$LCTL  get_param -N osc.*`
+        do
+                if [ "$OSC" == "osc.num_refs" ]; then
+                        continue
+                fi
+                lines=`$LCTL get_param -n ${OSC}.rpc_stats | wc | awk '{print $1}'`
+                if [ $lines -le 20 ]; then
+                        continue
+                fi
+
+		rpc4k=$($LCTL get_param -n $OSC | awk '$1 == "1:" { print $2; exit; }')
+                rpc8k=$($LCTL get_param -n $OSC | awk '$1 == "2:" { print $2; exit; }')
+                rpc16k=$($LCTL get_param -n $OSC | awk '$1 == "4:" { print $2; exit; }')
+                rpc32k=$($LCTL get_param -n $OSC | awk '$1 == "8:" { print $2; exit; }')
+
+                [ $rpc4k != 0 ]  && error "Small 4k read IO ${rpc4k}!"
+                [ $rpc8k != 0 ]  && error "Small 8k read IO ${rpc8k}!"
+                [ $rpc16k != 0 ] && error "Small 16k read IO ${rpc16k}!"
+                [ $rpc32k != 0 ] && error "Small 32k read IO ${rpc32k}!"
+
+                echo "Small rpc check passed!"
+       	        rpc64k=$($LCTL get_param -n $OSC | awk '$1 == "16:" { print $2; exit; }')
+                rpc128k=$($LCTL get_param -n $OSC | awk '$1 == "32:" { print $2; exit; }')
+                rpc256k=$($LCTL get_param -n $OSC | awk '$1 == "64:" { print $2; exit; }')
+                rpc512k=$($LCTL get_param -n $OSC | awk '$1 == "128:" { print $2; exit; }')
+                rpc1024k=$($LCTL get_param -n $OSC | awk '$1 == "256:" { print $2; exit; }')
+
+                [ $rpc64k == 0 ]   && error "No 64k readahead IO ${rpc64k}"
+                [ $rpc128k == 0 ]  && error "No 128k readahead IO ${rpc128k}"
+                [ $rpc256k == 0 ]  && error "No 256k readahead IO ${rpc256k}"
+                [ $rpc512k == 0 ]  && error "No 512k readahead IO ${rpc256k}"
+                [ $rpc1024k == 0 ] && error "No 1024k readahead IO ${rpc1024k}"
+                echo "Big rpc check passed!"
+        done
+        cleanup_101
+        true
+}
+run_test 101c "check stripe_size aligned read-ahead ================="
+
+set_read_ahead() {
+   lctl get_param -n llite.*.max_read_ahead_mb | head -n 1
+   lctl set_param -n llite.*.max_read_ahead_mb $1 > /dev/null 2>&1
+}
+
+test_101d() {
+    local file=$DIR/$tfile
+    local size=${FILESIZE_101c:-500}
+    local ra_MB=${READAHEAD_MB:-40}
+
+    local space=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
+    [ $space -gt $((size / 1024)) ] ||
+        { skip "Need free space ${size}M, have $space" && return; }
+
+    echo Creating ${size}M test file $file
+    dd if=/dev/zero of=$file bs=1M count=$size
+    echo Cancel LRU locks on lustre client to flush the client cache
+    cancel_lru_locks osc
+
+    echo Disable read-ahead
+    local old_READAHEAD=$(set_read_ahead 0)
+
+    echo Reading the test file $file with read-ahead disabled
+    time_ra_OFF=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
+
+    echo Cancel LRU locks on lustre client to flush the client cache
+    cancel_lru_locks osc
+    echo Enable read-ahead with ${ra_MB}MB
+    set_read_ahead $ra_MB
+
+    echo Reading the test file $file with read-ahead enabled
+    time_ra_ON=$(do_and_time "dd if=$file of=/dev/null bs=1M count=$size")
+
+    echo read-ahead disabled time read $time_ra_OFF
+    echo read-ahead enabled  time read $time_ra_ON
+
+    set_read_ahead $old_READAHEAD
+    rm -f $file
+
+    [ $time_ra_ON -lt $time_ra_OFF ] ||
+        error "read-ahead enabled  time read (${time_ra_ON}s) is more than
+               read-ahead disabled time read (${time_ra_OFF}s) filesize ${size}M"
+}
+run_test 101d "file read with and without read-ahead enabled  ================="
+
 export SETUP_TEST102=no
 setup_test102() {
 	[ "$SETUP_TEST102" = "yes" ] && return
 	mkdir -p $DIR/$tdir
+	chown $RUNAS_ID $DIR/$tdir
 	STRIPE_SIZE=65536
-	STRIPE_COUNT=4
-	STRIPE_OFFSET=2
+	STRIPE_OFFSET=1
+	STRIPE_COUNT=$OSTCOUNT
+	[ $OSTCOUNT -gt 4 ] && STRIPE_COUNT=4
 
 	trap cleanup_test102 EXIT
 	cd $DIR
-	$SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
+	$1 $SETSTRIPE $tdir -s $STRIPE_SIZE -i $STRIPE_OFFSET -c $STRIPE_COUNT
 	cd $DIR/$tdir
 	for num in 1 2 3 4
 	do
-		for count in 1 2 3 4
+		for count in `seq 1 $STRIPE_COUNT`
 		do
-			for offset in 0 1 2 3
+			for offset in `seq 0 $[$STRIPE_COUNT - 1]`
 			do
 				local stripe_size=`expr $STRIPE_SIZE \* $num`
 				local file=file"$num-$offset-$count"
-				$SETSTRIPE $file -s $stripe_size -i $offset -c $count
+				$1 $SETSTRIPE $file -s $stripe_size -i $offset -c $count
 			done
 		done
 	done
 
 	cd $DIR
-	star -c  f=$TMP/f102.tar $tdir
+	$1 $TAR cf $TMP/f102.tar $tdir --xattrs
 	SETUP_TEST102=yes
 }
 
 cleanup_test102() {
-	[ "$SETUP_TEST102" = "yes" ] || return
 	trap 0
+	[ "$SETUP_TEST102" = "yes" ] || return 0
 	rm -f $TMP/f102.tar
-	rm -rf $DIR/$tdir
 	SETUP_TEST102=no
 }
 
@@ -3818,7 +3956,7 @@ test_102a() {
         touch $testfile
 
 	[ "$UID" != 0 ] && skip "must run as root" && return
-	[ -z "`lctl get_param -n mdc.*[mM][dD][cC]*.connect_flags | grep xattr`" ] &&
+	[ -z "`lctl get_param -n mdc.*.connect_flags | grep xattr`" ] &&
 	skip "must have user_xattr" && return
 	[ -z "$(which setfattr 2>/dev/null)" ] && skip "could not find setfattr" && return
 
@@ -3865,16 +4003,16 @@ test_102b() {
 	echo "get/set/list trusted.lov xattr ..."
 	[ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
 	local testfile=$DIR/$tfile
-	$SETSTRIPE $testfile -s 65536 -i 1 -c 2
+	$SETSTRIPE -s 65536 -i 1 -c 2 $testfile || error "setstripe failed"
 	getfattr -d -m "^trusted" $testfile 2> /dev/null | \
 	grep "trusted.lov" || error "can't get trusted.lov from $testfile"
 
 	local testfile2=${testfile}2
 	local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
 		     grep "trusted.lov" |sed -e 's/[^=]\+=//'`
-	
+
 	$MCREATE $testfile2
-	setfattr -n trusted.lov -v $value $testfile2 	
+	setfattr -n trusted.lov -v $value $testfile2
 	local tmp_file=${testfile}3
 	$GETSTRIPE -v $testfile2 > $tmp_file
 	local stripe_size=`grep "size"  $tmp_file| awk '{print $2}'`
@@ -3891,16 +4029,16 @@ test_102c() {
 	mkdir -p $DIR/$tdir
 	chown $RUNAS_ID $DIR/$tdir
 	local testfile=$DIR/$tdir/$tfile
-	$RUNAS $SETSTRIPE $testfile -s 65536 -i 1 -c 2
+	$RUNAS $SETSTRIPE -s 65536 -i 1 -c 2 $testfile||error "setstripe failed"
 	$RUNAS getfattr -d -m "^lustre" $testfile 2> /dev/null | \
 	grep "lustre.lov" || error "can't get lustre.lov from $testfile"
 
 	local testfile2=${testfile}2
 	local value=`getfattr -n lustre.lov $testfile 2> /dev/null | \
 		     grep "lustre.lov" |sed -e 's/[^=]\+=//'  `
-	
+
 	$RUNAS $MCREATE $testfile2
-	$RUNAS setfattr -n lustre.lov -v $value $testfile2 	
+	$RUNAS setfattr -n lustre.lov -v $value $testfile2
 	local tmp_file=${testfile}3
 	$RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
 	local stripe_size=`grep "size"  $tmp_file| awk '{print $2}'`
@@ -3915,18 +4053,18 @@ compare_stripe_info1() {
 
 	for num in 1 2 3 4
 	do
-		for count in 1 2 3 4
+ 		for count in `seq 1 $STRIPE_COUNT`
 		do
-			for offset in 0 1 2 3
+			for offset in `seq 0 $[$STRIPE_COUNT - 1]`
 			do
 				local size=`expr $STRIPE_SIZE \* $num`
 				local file=file"$num-$offset-$count"
-				get_stripe_info client $PWD/$file
+				get_stripe_info client $PWD/$file "$1"
 				if [ $stripe_size -ne $size ]; then
-					error "$file: different stripe size" && return
+					error "$file: different stripe size $stripe_size, expected $size" && return
 				fi
 				if [ $stripe_count -ne $count ]; then
-					error "$file: different stripe count" && return
+					error "$file: different stripe count $stripe_count, expected $count" && return
 				fi
 				if [ $stripe_index -ne 0 ]; then
 				       stripe_index_all_zero=0
@@ -3938,88 +4076,36 @@ compare_stripe_info1() {
 	return 0
 }
 
-compare_stripe_info2() {
-	for num in 1 2 3 4
-	do
-		for count in 1 2 3 4
-		do
-			for offset in 0 1 2 3
-			do
-				local size=`expr $STRIPE_SIZE \* $num`
-				local file=file"$num-$offset-$count"
-				get_stripe_info client $PWD/$file
-				if [ $stripe_size -ne $size ]; then
-					error "$file: different stripe size" && return	
-				fi
-				if [ $stripe_count -ne $count ]; then
-					error "$file: different stripe count" && return
-				fi
-				if [ $stripe_index -ne $offset ]; then
-					error "$file: different stripe offset" && return
-				fi
-			done
-		done
-	done
+find_lustre_tar() {
+	[ -n "$(which tar 2>/dev/null)" ] && strings $(which tar) | grep -q lustre && echo tar
 }
 
 test_102d() {
-	# b10930: star test for trusted.lov xattr
-	star --xhelp 2>&1 | grep -q nolustre
-	if [ $? -ne 0 ]
-	then
-		skip "being skipped because a lustre-aware star is not installed." && return
-	fi
-	[ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
+	# b10930: tar test for trusted.lov xattr
+	TAR=$(find_lustre_tar)
+	[ -z "$TAR" ] && skip "lustre-aware tar is not installed" && return
+	[ "$OSTCOUNT" -lt "2" ] && skip "skipping N-stripe test" && return
 	setup_test102
 	mkdir -p $DIR/d102d
-	star -x  f=$TMP/f102.tar -C $DIR/d102d
+	$TAR xf $TMP/f102.tar -C $DIR/d102d --xattrs
 	cd $DIR/d102d/$tdir
 	compare_stripe_info1
-
 }
-run_test 102d "star restore stripe info from tarfile,not keep osts ==========="
-
-test_102e() {
-	# b10930: star test for trusted.lov xattr
-	star --xhelp 2>&1 | grep -q nolustre
-	[ $? -ne 0 ] && skip "lustre-aware star is not installed" && return
-	[ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
-	setup_test102
-	mkdir -p $DIR/d102e
-	star -x  -preserve-osts f=$TMP/f102.tar -C $DIR/d102e
-	cd $DIR/d102e/$tdir
-	compare_stripe_info2
-}
-run_test 102e "star restore stripe info from tarfile, keep osts ==========="
+run_test 102d "tar restore stripe info from tarfile,not keep osts ==========="
 
 test_102f() {
-	# b10930: star test for trusted.lov xattr
-	star --xhelp 2>&1 | grep -q nolustre
-	[ $? -ne 0 ] && skip "lustre-aware star is not installed" && return
-	[ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
+	# b10930: tar test for trusted.lov xattr
+	TAR=$(find_lustre_tar)
+	[ -z "$TAR" ] && skip "lustre-aware tar is not installed" && return
+	[ "$OSTCOUNT" -lt "2" ] && skip "skipping N-stripe test" && return
 	setup_test102
 	mkdir -p $DIR/d102f
 	cd $DIR
-	star -copy  $tdir $DIR/d102f
+	$TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/d102f
 	cd $DIR/d102f/$tdir
 	compare_stripe_info1
 }
-run_test 102f "star copy files, not keep osts ==========="
-
-test_102g() {
-	# b10930: star test for trusted.lov xattr
-	star --xhelp 2>&1 | grep -q nolustre
-	[ $? -ne 0 ] && skip "lustre-aware star is not installed" && return
-	[ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
-	setup_test102
-	mkdir -p $DIR/d102g
-	cd $DIR
-	star -copy -preserve-osts $tdir $DIR/d102g
-	cd $DIR/d102g/$tdir
-	compare_stripe_info2
-	cleanup_test102
-}
-run_test 102g "star copy files, keep osts ==========="
+run_test 102f "tar copy files, not keep osts ==========="
 
 test_102h() { # bug 15777
 	[ -z $(lctl get_param -n mdc.*.connect_flags | grep xattr) ] &&
@@ -4074,6 +4160,21 @@ test_102i() { # bug 17038
 }
 run_test 102i "lgetxattr test on symbolic link ============"
 
+test_102j() {
+	TAR=$(find_lustre_tar)
+	[ -z "$TAR" ] && skip "lustre-aware tar is not installed" && return
+	[ "$OSTCOUNT" -lt "2" ] && skip "skipping N-stripe test" && return
+	setup_test102 "$RUNAS"
+	mkdir -p $DIR/d102j
+	chown $RUNAS_ID $DIR/d102j
+	$RUNAS $TAR xf $TMP/f102.tar -C $DIR/d102j --xattrs
+	cd $DIR/d102j/$tdir
+	compare_stripe_info1 "$RUNAS"
+}
+run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
+
+cleanup_test102
+
 run_acl_subtest()
 {
     $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
@@ -4082,7 +4183,7 @@ run_acl_subtest()
 
 test_103 () {
     [ "$UID" != 0 ] && skip "must run as root" && return
-    [ -z "$(lctl get_param mdc.*[mM][dD][cC]*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
+    [ -z "$(lctl get_param mdc.*.connect_flags | grep acl)" ] && skip "must have acl enabled" && return
     [ -z "$(which setfacl 2>/dev/null)" ] && skip "could not find setfacl" && return
 
     SAVE_UMASK=`umask`
@@ -4092,20 +4193,20 @@ test_103 () {
     echo "performing cp ..."
     run_acl_subtest cp || error
     echo "performing getfacl-noacl..."
-    run_acl_subtest getfacl-noacl > /dev/null || error
+    run_acl_subtest getfacl-noacl > /dev/null || error "getfacl-noacl test failed"
     echo "performing misc..."
-    run_acl_subtest misc > /dev/null || error
+    run_acl_subtest misc > /dev/null || error "misc test failed"
 #    XXX add back permission test when we support supplementary groups.
 #    echo "performing permissions..."
 #    run_acl_subtest permissions || error
     echo "performing setfacl..."
-    run_acl_subtest setfacl > /dev/null || error
+    run_acl_subtest setfacl > /dev/null || error "setfacl test failed"
 
     # inheritance test got from HP
     echo "performing inheritance..."
-    cp $LUSTRE/tests/acl/make-tree . || error
-    chmod +x make-tree || error
-    run_acl_subtest inheritance > /dev/null || error
+    cp $LUSTRE/tests/acl/make-tree . || error "cannot copy make-tree"
+    chmod +x make-tree || error "chmod +x failed"
+    run_acl_subtest inheritance > /dev/null || error "inheritance test failed"
     rm -f make-tree
 
     cd $SAVE_PWD
@@ -4121,7 +4222,7 @@ test_104() {
 	lfs df -i $DIR || error "lfs df -i $DIR failed"
 	lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
 	lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
-	
+
 	OSC=`lctl get_param -n devices | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
 	lctl --device %$OSC deactivate
 	lfs df || error "lfs df with deactivated OSC failed"
@@ -4277,7 +4378,7 @@ test_116() {
 	declare -i FILL
 	FILL=$(($MINV / 4))
 	echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
-	$SETSTRIPE $DIR/$tdir/OST${MINI} -i $MINI -c 1
+	$SETSTRIPE -i $MINI -c 1 $DIR/$tdir/OST${MINI}||error "setstripe failed"
 	i=1
 	while [ $FILL -gt 0 ]; do
 	    dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
@@ -4339,6 +4440,8 @@ test_116() {
 	echo "$MAXC files created on larger OST $MAXI1"
 	[ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
 	[ $MAXC -gt $MINC ] || error_ignore "stripe QOS didn't balance free space"
+
+	rm -rf $DIR/$tdir/OST${MINI}
 }
 run_test 116 "stripe QOS: free space balance ==================="
 
@@ -4368,7 +4471,7 @@ reset_async() {
 	FILE=$DIR/reset_async
 
 	# Ensure all OSCs are cleared
-	$LSTRIPE $FILE 0 -1 -1
+	$SETSTRIPE -c -1 $FILE
         dd if=/dev/zero of=$FILE bs=64k count=$OSTCOUNT
 	sync
         rm $FILE
@@ -4377,7 +4480,7 @@ reset_async() {
 test_118a() #bug 11710
 {
 	reset_async
-	
+
  	multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
 	DIRTY=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c dirty)
         WRITEBACK=$(lctl get_param "llite.*.dump_page_cache" | grep -c writeback)
@@ -4419,7 +4522,7 @@ test_118b()
 	# until a subsequent RPC completes successfully without error.
 	multiop $DIR/$tfile Ow4096yc
 	rm -f $DIR/$tfile
-	
+
 	return 0
 }
 run_test 118b "Reclaim dirty pages on fatal error =========="
@@ -4459,7 +4562,7 @@ test_118c()
 	if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
 		error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
 	fi
-	
+
 	rm -f $DIR/$tfile
 	echo "Dirty pages flushed via fsync on EROFS"
 	return 0
@@ -4475,7 +4578,7 @@ test_118d()
 	#define OBD_FAIL_OST_BRW_PAUSE_BULK
 	set_nodes_failloc "$(osts_nodes)" 0x214
 	# multiop should block due to fsync until pages are written
-	multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &	
+	multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
 	MULTIPID=$!
 	sleep 1
 
@@ -4515,7 +4618,7 @@ test_118f() {
 	if [[ $RC -eq 0 ]]; then
 		error "Must return error due to dropped pages, rc=$RC"
 	fi
-	
+
         lctl set_param fail_loc=0x0
 
         LOCKED=$(lctl get_param -n "llite.*.dump_page_cache" | grep -c locked)
@@ -4546,7 +4649,7 @@ test_118g() {
 	# simulate local -ENOMEM
         multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
         RC=$?
-	
+
         lctl set_param fail_loc=0
 	if [[ $RC -eq 0 ]]; then
 		error "Must return error due to dropped pages, rc=$RC"
@@ -4558,7 +4661,7 @@ test_118g() {
 	if [[ $LOCKED -ne 0 ]]; then
 		error "Locked pages remain in cache, locked=$LOCKED"
 	fi
-	
+
 	if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
 		error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
 	fi
@@ -4581,7 +4684,7 @@ test_118h() {
 	# Should simulate ENOMEM error which is recoverable and should be handled by timeout
         multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
         RC=$?
-	
+
         set_nodes_failloc "$(osts_nodes)" 0
 	if [[ $RC -eq 0 ]]; then
 		error "Must return error due to dropped pages, rc=$RC"
@@ -4593,7 +4696,7 @@ test_118h() {
 	if [[ $LOCKED -ne 0 ]]; then
 		error "Locked pages remain in cache, locked=$LOCKED"
 	fi
-	
+
 	if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
 		error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
 	fi
@@ -4612,13 +4715,13 @@ test_118i() {
 
 	#define OBD_FAIL_OST_BRW_WRITE_BULK      0x20e
         set_nodes_failloc "$(osts_nodes)" 0x20e
-	
+
 	# Should simulate ENOMEM error which is recoverable and should be handled by timeout
         multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c &
 	PID=$!
 	sleep 5
 	set_nodes_failloc "$(osts_nodes)" 0
-	
+
 	wait $PID
         RC=$?
 	if [[ $RC -ne 0 ]]; then
@@ -4631,7 +4734,7 @@ test_118i() {
 	if [[ $LOCKED -ne 0 ]]; then
 		error "Locked pages remain in cache, locked=$LOCKED"
 	fi
-	
+
 	if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
 		error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
 	fi
@@ -4665,7 +4768,7 @@ test_118j() {
 	if [[ $LOCKED -ne 0 ]]; then
 		error "Locked pages remain in cache, locked=$LOCKED"
 	fi
-	
+
 	# in recoverable error on OST we want resend and stay until it finished
 	if [[ $DIRTY -ne 0 || $WRITEBACK -ne 0 ]]; then
 		error "Dirty pages not flushed to disk, dirty=$DIRTY, writeback=$WRITEBACK"
@@ -4721,7 +4824,7 @@ test_119b() # bug 11737
 {
         [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
 
-        $SETSTRIPE $DIR/$tfile -c 2
+        $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
         dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
         sync
         multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
@@ -4932,10 +5035,10 @@ test_120g() {
 run_test 120g "Early Lock Cancel: performance test ============="
 
 test_121() { #bug 10589
-	writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out/ {print $1}')
+	writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
 	lctl set_param fail_loc=0x310
 	cancel_lru_locks osc > /dev/null
-	reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in/ {print $1}')
+	reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1 | awk -F '+' '/in$/ {print $1}')
 	lctl set_param fail_loc=0
 	[ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
 }
@@ -5051,7 +5154,7 @@ run_test 123a "verify statahead work"
 test_123b () { # statahead(bug 15027)
 	mkdir -p $DIR/$tdir
 	createmany -o $DIR/$tdir/$tfile-%d 1000
-	
+
         cancel_lru_locks mdc
         cancel_lru_locks osc
 
@@ -5119,7 +5222,7 @@ test_124a() {
         log "LVF=$LVF"
         local OLD_LVF=`lctl get_param -n $NSDIR.pool.lock_volume_factor`
         lctl set_param -n $NSDIR.pool.lock_volume_factor $LVF
-        
+
         # Let's make sure that we really have some margin. Client checks
         # cached locks every 10 sec.
         SLEEP=$((SLEEP+20))
@@ -5237,7 +5340,7 @@ test_126() { # bug 12829/13455
 run_test 126 "check that the fsgid provided by the client is taken into account"
 
 test_127() { # bug 15521
-        $LSTRIPE -i 0 -c 1 $DIR/$tfile
+        $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
         $LCTL set_param osc.*.stats=0
         FSIZE=$((2048 * 1024))
         dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
@@ -5249,7 +5352,7 @@ test_127() { # bug 15521
                 echo "got $COUNT $NAME"
                 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
                 eval $NAME=$COUNT || error "Wrong proc format"
-		
+
                 case $NAME in
                         read_bytes|write_bytes)
                         [ $MIN -lt 4096 ] && error "min is too small: $MIN"
@@ -5283,15 +5386,16 @@ test_128() { # bug 15212
 
 	result=$(grep error $TMP/$tfile.log)
 	rm -f $DIR/$tfile
-	[ -z "$result" ] || error "consecutive find's under interactive lfs failed"
+	[ -z "$result" ] || error "consecutive find with interactive lfs failed"
 }
-run_test 128 "interactive lfs for 2 consecutive find's"
+run_test 128 "interactive lfs for 2 consecutive finds"
 
 test_129() {
         [ "$FSTYPE" != "ldiskfs" ] && skip "not needed for FSTYPE=$FSTYPE" && return 0
         remote_mds_nodsh && skip "remote MDS with nodsh" && return
 
-        DEV=$(basename $(do_facet mds lctl get_param -n mds.*.mntdev))
+        local MNTDEV=$(get_mds_mntdev_proc_path)
+        DEV=$(basename $(do_facet mds lctl get_param -n $MNTDEV))
         [ -z "$DEV" ] && error "can't access mds mntdev"
         EFBIG=27
         LDPROC=/proc/fs/ldiskfs/$DEV/max_dir_size
@@ -5312,7 +5416,7 @@ test_129() {
                         return 0
                 elif [ $rc -ne 0 ]; then
                         do_facet mds "echo 0 >$LDPROC"
-                        error_exit "return code $rc received instead of expected $EFBIG"
+                        error_exit "error $rc instead of expected $EFBIG"
                 fi
                 J=$((J+1))
                 I=$(stat -c%s "$DIR/$tdir")
@@ -5331,13 +5435,15 @@ cleanup_130() {
 
 test_130a() {
 	filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-	[ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
+	[ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
 
 	trap cleanup_130 EXIT RETURN
 
 	local fm_file=$DIR/$tfile
-	lfs setstripe -s 65536 -c 1 $fm_file || error "setstripe failed on $fm_file"
-	dd if=/dev/zero of=$fm_file bs=65536 count=1 || error "dd failed for $fm_file"
+	lfs setstripe -s 65536 -c 1 $fm_file ||
+		error "setstripe failed on $fm_file"
+	dd if=/dev/zero of=$fm_file bs=65536 count=1 ||
+		error "dd failed for $fm_file"
 
 	filefrag -ves $fm_file || error "filefrag $fm_file failed"
 	filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
@@ -5372,16 +5478,18 @@ test_130a() {
 run_test 130a "FIEMAP (1-stripe file)"
 
 test_130b() {
-	[ "$OSTCOUNT" -lt "2" ] && skip "skipping FIEMAP on 2-stripe file test" && return
+	[ "$OSTCOUNT" -lt "2" ] && skip "FIEMAP on 2-stripe file test" && return
 
 	filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-	[ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
+	[ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
 
 	trap cleanup_130 EXIT RETURN
 
 	local fm_file=$DIR/$tfile
-	lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
-	dd if=/dev/zero of=$fm_file bs=1M count=2 || error "dd failed on $fm_file"
+	lfs setstripe -s 65536 -c 2 $fm_file ||
+		error "setstripe failed on $fm_file"
+	dd if=/dev/zero of=$fm_file bs=1M count=2 ||
+		error "dd failed on $fm_file"
 
 	filefrag -ves $fm_file || error "filefrag $fm_file failed"
 	filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
@@ -5391,14 +5499,13 @@ test_130b() {
 	IFS=$'\n'
 	tot_len=0
 	num_luns=1
-	for line in $filefrag_op
-	do
+	for line in $filefrag_op; do
 		frag_lun=`echo $line | cut -d: -f5`
 		ext_len=`echo $line | cut -d: -f4`
 		if (( $frag_lun != $last_lun )); then
 			if (( tot_len != 1024 )); then
 				cleanup_130
-				error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 256"
+				error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 256"
 				return
 			else
 				(( num_luns += 1 ))
@@ -5410,7 +5517,7 @@ test_130b() {
 	done
 	if (( num_luns != 2 || tot_len != 1024 )); then
 		cleanup_130
-		error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
+		error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
 		return
 	fi
 
@@ -5421,16 +5528,18 @@ test_130b() {
 run_test 130b "FIEMAP (2-stripe file)"
 
 test_130c() {
-	[ "$OSTCOUNT" -lt "2" ] && skip "skipping FIEMAP on 2-stripe file with hole test" && return
+	[ "$OSTCOUNT" -lt "2" ] && skip "FIEMAP on 2-stripe hole test" && return
 
 	filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-	[ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
+	[ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
 
 	trap cleanup_130 EXIT RETURN
 
 	local fm_file=$DIR/$tfile
-	lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
-	dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 || error "dd failed on $fm_file"
+	lfs setstripe -s 65536 -c 2 $fm_file ||
+		error "setstripe failed on $fm_file"
+	dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
+		error "dd failed on $fm_file"
 
 	filefrag -ves $fm_file || error "filefrag $fm_file failed"
 	filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
@@ -5448,12 +5557,12 @@ test_130c() {
 			logical=`echo $line | cut -d: -f2 | cut -d. -f1`
 			if (( logical != 512 )); then
 				cleanup_130
-				error "FIEMAP on $fm_file failed; returned logical start for lun $logical instead of 512"
+				error "FIEMAP $fm_file: logical start for LUN $logical instead of 512"
 				return
 			fi
 			if (( tot_len != 512 )); then
 				cleanup_130
-				error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
+				error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
 				return
 			else
 				(( num_luns += 1 ))
@@ -5465,7 +5574,7 @@ test_130c() {
 	done
 	if (( num_luns != 2 || tot_len != 512 )); then
 		cleanup_130
-		error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
+		error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
 		return
 	fi
 
@@ -5476,16 +5585,18 @@ test_130c() {
 run_test 130c "FIEMAP (2-stripe file with hole)"
 
 test_130d() {
-	[ "$OSTCOUNT" -lt "3" ] && skip "skipping FIEMAP on N-stripe file test" && return
+	[ "$OSTCOUNT" -lt "3" ] && skip "FIEMAP on N-stripe file test" && return
 
 	filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-	[ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
+	[ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
 
 	trap cleanup_130 EXIT RETURN
 
 	local fm_file=$DIR/$tfile
-	lfs setstripe -s 65536 -c $OSTCOUNT $fm_file || error "setstripe failed on $fm_file"
-	dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT || error "dd failed on $fm_file"
+	lfs setstripe -s 65536 -c $OSTCOUNT $fm_file ||
+		error "setstripe failed on $fm_file"
+	dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
+		error "dd failed on $fm_file"
 
 	filefrag -ves $fm_file || error "filefrag $fm_file failed"
 	filefrag_op=`filefrag -ve $fm_file | grep -A 100 "ext:" | grep -v "ext:" | grep -v "found"`
@@ -5502,7 +5613,7 @@ test_130d() {
 		if (( $frag_lun != $last_lun )); then
 			if (( tot_len != 1024 )); then
 				cleanup_130
-				error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of 1024"
+				error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of 1024"
 				return
 			else
 				(( num_luns += 1 ))
@@ -5514,7 +5625,7 @@ test_130d() {
 	done
 	if (( num_luns != OSTCOUNT || tot_len != 1024 )); then
 		cleanup_130
-		error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
+		error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
 		return
 	fi
 
@@ -5525,19 +5636,19 @@ test_130d() {
 run_test 130d "FIEMAP (N-stripe file)"
 
 test_130e() {
-	[ "$OSTCOUNT" -lt "2" ] && skip "skipping continuation FIEMAP test" && return
+	[ "$OSTCOUNT" -lt "2" ] && skip "continuation FIEMAP test" && return
 
 	filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-	[ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
+	[ -n "$filefrag_op" ] && skip "filefrag has no FIEMAP support" && return
 
 	trap cleanup_130 EXIT RETURN
 
 	local fm_file=$DIR/$tfile
-	lfs setstripe -s 65536 -c 2 $fm_file || error "setstripe failed on $fm_file"
+	lfs setstripe -s 65536 -c 2 $fm_file ||
+		error "setstripe failed on $fm_file"
 	NUM_BLKS=512
 	EXPECTED_LEN=$(( (NUM_BLKS / 2) * 4 ))
-	for ((i = 0; i < $NUM_BLKS; i++))
-	do
+	for ((i = 0; i < $NUM_BLKS; i++)); do
 		dd if=/dev/zero of=$fm_file count=1 bs=4096 seek=$((2*$i)) conv=notrunc > /dev/null 2>&1
 	done
 
@@ -5556,7 +5667,7 @@ test_130e() {
 		if (( $frag_lun != $last_lun )); then
 			if (( tot_len != $EXPECTED_LEN )); then
 				cleanup_130
-				error "FIEMAP on $fm_file failed; returned len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
+				error "FIEMAP $fm_file: len $tot_len for OST $last_lun instead of $EXPECTED_LEN"
 				return
 			else
 				(( num_luns += 1 ))
@@ -5568,7 +5679,7 @@ test_130e() {
 	done
 	if (( num_luns != 2 || tot_len != $EXPECTED_LEN )); then
 		cleanup_130
-		error "FIEMAP on $fm_file failed; returned wrong number of luns or wrong len for OST $last_lun"
+		error "FIEMAP $fm_file: wrong number of LUNs or wrong len for OST $last_lun"
 		return
 	fi
 
@@ -5583,7 +5694,7 @@ test_140() { #bug-17379
         cd $DIR/$tdir || error "Changing to $DIR/$tdir"
         cp /usr/bin/stat . || error "Copying stat to $DIR/$tdir"
 
-        # VFS limits max symlink depth to 5(4KSTACK) or 8
+        # VFS limits max symlink depth to 5(4KSTACK) or 7(8KSTACK) or 8
         local i=0
         while i=`expr $i + 1`; do
                 mkdir -p $i || error "Creating dir $i"
@@ -5604,15 +5715,151 @@ test_140() { #bug-17379
         done
         i=`expr $i - 1`
         echo "The symlink depth = $i"
-        [ $i -eq 4 -o $i -eq 8 ] || error "Invalid symlink depth"
+        [ $i -eq 5 -o $i -eq 7 -o $i -eq 8 ] || error "Invalid symlink depth"
 }
 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
 
+test_150() {
+	local TF="$TMP/$tfile"
+
+        dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
+        cp $TF $DIR/$tfile
+        cancel_lru_locks osc
+        cmp $TF $DIR/$tfile || error "$TMP/$tfile $DIR/$tfile differ"
+        remount_client $MOUNT
+        cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (remount)"
+
+        $TRUNCATE $TF 6000
+        $TRUNCATE $DIR/$tfile 6000
+        cancel_lru_locks osc
+        cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (truncate1)"
+
+        echo "12345" >>$TF
+        echo "12345" >>$DIR/$tfile
+        cancel_lru_locks osc
+        cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append1)"
+
+        echo "12345" >>$TF
+        echo "12345" >>$DIR/$tfile
+        cancel_lru_locks osc
+        cmp $TF $DIR/$tfile || error "$TF $DIR/$tfile differ (append2)"
+
+        rm -f $TF
+        true
+}
+run_test 150 "truncate/append tests"
+
+function roc_access() {
+	local list=$(comma_list $(osts_nodes))
+	ACCNUM=`do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
+		grep 'cache_access' | awk '{print $2}' | \
+		awk '{sum=sum+$3} END{print sum}'`
+	echo $ACCNUM
+}
+
+function roc_hit() {
+	local list=$(comma_list $(osts_nodes))
+	ACCNUM=`do_nodes $list $LCTL get_param -n obdfilter.*.stats | \
+		grep 'cache_hit' | awk '{print $2}' | \
+		awk '{sum=sum+$1} END{print sum}'`
+	echo $ACCNUM
+}
+
+test_151() {
+	remote_ost_nodsh && skip "remote OST with nodsh" && return
+
+	local list=$(comma_list $(osts_nodes))
+	if ! do_nodes $list grep -q truncate_inode_pages_range /proc/kallsyms; then  #b=18718
+		skip "old RHEL4/SLES9 kernel" && return
+	fi
+
+	local CPAGES=3
+
+	# check whether obdfilter is cache capable at all
+	if ! do_nodes $list $LCTL get_param -n obdfilter.*.read_cache_enable > /dev/null; then
+		echo "not cache-capable obdfilter"
+		return 0
+	fi
+
+	# make sure cache is enabled on all obdfilters
+	do_nodes $list $LCTL set_param obdfilter.*.read_cache_enable=1
+	do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
+
+	# pages should be in the case right after write
+	dd if=/dev/urandom of=$DIR/$tfile bs=4k count=$CPAGES || error "dd failed"
+	local BEFORE=`roc_hit`
+	cancel_lru_locks osc
+	cat $DIR/$tfile >/dev/null
+	local AFTER=`roc_hit`
+	if let "AFTER - BEFORE != CPAGES"; then
+		error "NOT IN CACHE: before: $BEFORE, after: $AFTER"
+	fi
+
+	# the following read invalidates the cache
+	cancel_lru_locks osc
+	do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable 0
+	cat $DIR/$tfile >/dev/null
+
+	# now data shouldn't be found in the cache
+	BEFORE=`roc_hit`
+	cancel_lru_locks osc
+	cat $DIR/$tfile >/dev/null
+	AFTER=`roc_hit`
+	if let "AFTER - BEFORE != 0"; then
+		error "IN CACHE: before: $BEFORE, after: $AFTER"
+	fi
+
+	do_nodes $list $LCTL set_param -n obdfilter.*.read_cache_enable=1
+	do_nodes $list $LCTL set_param obdfilter.*.writethrough_cache_enable=1
+	rm -f $DIR/$tfile
+}
+run_test 151 "test cache on oss and controls ==============================="
+
+test_152() {
+        local TF="$TMP/$tfile"
+
+	# simulate ENOMEM during write
+#define OBD_FAIL_OST_NOMEM     	0x226
+        lctl set_param fail_loc=0x80000226
+        dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
+        cp $TF $DIR/$tfile
+        sync || error "sync failed"
+        lctl set_param fail_loc=0
+
+        # discard client's cache
+        cancel_lru_locks osc
+
+        # simulate ENOMEM during read
+        lctl set_param fail_loc=0x80000226
+        cmp $TF $DIR/$tfile || error "cmp failed"
+        lctl set_param fail_loc=0
+
+	rm -f $TF
+}
+run_test 152 "test read/write with enomem ============================"
+
 test_153() {
         multiop $DIR/$tfile Ow4096Ycu || error "multiop failed"
 }
 run_test 153 "test if fdatasync does not crash ======================="
 
+test_154() {
+	# do directio so as not to populate the page cache
+	log "creating a 10 Mb file"
+	multiop $DIR/$tfile oO_CREAT:O_DIRECT:O_RDWR:w$((10*1048576))c || error "multiop failed while creating a file"
+	log "starting reads"
+	dd if=$DIR/$tfile of=/dev/null bs=4096 &
+	log "truncating the file"
+	multiop $DIR/$tfile oO_TRUNC:c || error "multiop failed while truncating the file"
+	log "killing dd"
+	kill %+ || true # reads might have finished
+	echo "wait until dd is finished"
+	wait
+	log "removing the temporary file"
+	rm -rf $DIR/$tfile || error "tmp file removal failed"
+}
+run_test 154 "parallel read and truncate should not deadlock ==="
+
 test_170() {
         $LCTL clear	# bug 18514
         $LCTL debug_daemon start $TMP/${tfile}_log_good
@@ -5634,36 +5881,208 @@ test_170() {
         $LCTL df $TMP/${tfile}_log_good > $TMP/${tfile}_log_good.out 2>&1
         local good_line2=$(tail -n 1 $TMP/${tfile}_log_good.out | awk '{print $5}')
 
-	[ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] || 
+	[ "$bad_line" ] && [ "$good_line1" ] && [ "$good_line2" ] ||
 		error "bad_line good_line1 good_line2 are empty"
- 
+
+        cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
+        cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt
         cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt
-        cat $TMP/${tfile}_log_bad >> $TMP/${tfile}_logs_corrupt 
-        cat $TMP/${tfile}_log_good >> $TMP/${tfile}_logs_corrupt           
 
         $LCTL df $TMP/${tfile}_logs_corrupt > $TMP/${tfile}_log_bad.out 2>&1
         local bad_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $9}')
         local good_line_new=$(tail -n 1 $TMP/${tfile}_log_bad.out | awk '{print $5}')
 
-	[ "$bad_line_new" ] && [ "$good_line_new" ] || 
+	[ "$bad_line_new" ] && [ "$good_line_new" ] ||
 		error "bad_line_new good_line_new are empty"
- 
+
         local expected_good=$((good_line1 + good_line2*2))
 
         rm -f $TMP/${tfile}*
         if [ $bad_line -ne $bad_line_new ]; then
                 error "expected $bad_line bad lines, but got $bad_line_new"
-                return 1 
+                return 1
         fi
 
         if [ $expected_good -ne $good_line_new ]; then
                 error "expected $expected_good good lines, but got $good_line_new"
-                return 2 
+                return 2
         fi
         true
 }
 run_test 170 "test lctl df to handle corrupted log ====================="
 
+obdecho_create_test() {
+        local OBD=$1
+        local node=$2
+        local rc=0
+        do_facet $node "$LCTL attach echo_client ec ec_uuid" || rc=1
+        [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec setup $OBD" || rc=2; }
+        [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec create 1" || rc=3; }
+        [ $rc -eq 0 ] && { do_facet $node "$LCTL --device ec test_brw 0 w 1" || rc=4; }
+        [ $rc -eq 0 -o $rc -gt 2 ] && { do_facet $node "$LCTL --device ec cleanup" || rc=5; }
+        [ $rc -eq 0 -o $rc -gt 1 ] && { do_facet $node "$LCTL --device ec detach" || rc=6; }
+        return $rc
+}
+
+test_180() {
+        local rc=0
+        local rmmod_local=0
+        local rmmod_remote=0
+
+        lsmod | grep -q obdecho || { load_module obdecho/obdecho && rmmod_local=1; }
+
+        OBD=`$LCTL  dl | awk ' /-osc-/ { print $4; exit; }'`
+        [ "x$OBD" != "x" ] && { obdecho_create_test $OBD client || rc=2; }
+        [ $rmmod_local -eq 1 ] && rmmod obdecho
+        [ $rc -ne 0 ] && return $rc
+
+        do_facet ost "lsmod | grep -q obdecho || { insmod ${LUSTRE}/obdecho/obdecho.ko || modprobe obdecho; }" && rmmod_remote=1
+
+        OBD=$(do_facet ost "$LCTL  dl | awk '/obdfilter/ { print; exit; }'" | awk '{print $4;}')
+        [ "x$OBD" != "x" ] && { obdecho_create_test $OBD ost || rc=3; }
+        [ $rmmod_remote -eq 1 ] && do_facet ost "rmmod obdecho"
+        if [ $rc -ne 0 ]; then
+                 error "obdecho test rc=$rc"
+                 return $rc
+        fi
+        true
+}
+run_test 180 "test obdecho ============================================"
+
+
+POOL=${POOL:-cea1}
+TGT_COUNT=$OSTCOUNT
+TGTPOOL_FIRST=1
+TGTPOOL_MAX=$(($TGT_COUNT - 1))
+TGTPOOL_STEP=2
+TGTPOOL_LIST=`seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`
+POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
+POOL_DIR=$POOL_ROOT/dir_tst
+POOL_FILE=$POOL_ROOT/file_tst
+
+test_pools()
+{
+	[ -z "$($LCTL get_param -n mdc.*.connect_flags | grep pools)" ] &&
+		skip "missing pools support on server" && return 1
+	remote_mgs_nodsh && skip "remote MGS with nodsh" && return 1
+	[ -z "$mdtlov" ] && mdtlov=$(get_mdtlov_proc_path $FSNAME)
+	return 0
+}
+
+check_file_in_pool()
+{
+	file=$1
+	res=$($GETSTRIPE $file | grep 0x | cut -f2)
+	for i in $res
+	do
+		found=$(echo :$TGTPOOL_LIST: | tr " " ":"  | grep :$i:)
+		if [[ "$found" == "" ]]
+		then
+			echo "pool list: $TGTPOOL_LIST"
+			echo "striping: $res"
+			error "$file not allocated in $POOL"
+			return 1
+		fi
+	done
+	return 0
+}
+
+export mdtlov=
+
+test_200a() {
+        test_pools || return 0
+        do_facet mgs $LCTL pool_new $FSNAME.$POOL
+        # get param should return err until pool is created
+        wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "" || error "Pool creation of $POOL failed"
+}
+run_test 200a "Create new pool =========================================="
+
+test_200b() {
+        test_pools || return 0
+        TGT=$(for i in `seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`; do printf "$FSNAME-OST%04x_UUID " $i; done)
+        do_facet mgs $LCTL pool_add $FSNAME.$POOL \
+                $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
+        wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
+}
+run_test 200b "Add targets to a pool ===================================="
+
+test_200c() {
+        test_pools || return 0
+        mkdir -p $POOL_DIR
+        $SETSTRIPE -c 2 -p $POOL $POOL_DIR
+        [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
+}
+run_test 200c "Set pool on a directory ================================="
+
+test_200d() {
+        test_pools || return 0
+	res=$($GETSTRIPE $POOL_DIR | grep pool: | cut -f8 -d " ")
+	[ "$res" = $POOL ] || error "Pool on $POOL_DIR is not $POOL"
+}
+run_test 200d "Check pool on a directory ==============================="
+
+test_200e() {
+        test_pools || return 0
+	failed=0
+	for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
+		file=$POOL_DIR/file-$i
+		touch $file
+		check_file_in_pool $file
+		if [[ $? != 0 ]]; then
+			failed=$(($failed + 1))
+		fi
+	done
+	[ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
+}
+run_test 200e "Check files allocation from directory pool =============="
+
+test_200f() {
+        test_pools || return 0
+	mkdir -p $POOL_FILE
+	failed=0
+	for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
+		file=$POOL_FILE/spoo-$i
+		$SETSTRIPE -p $POOL $file
+		check_file_in_pool $file
+		if [[ $? != 0 ]]; then
+			failed=$(($failed + 1))
+		fi
+	done
+	[ "$failed" = 0 ] || error "$failed files not allocated in $POOL"
+}
+run_test 200f "Create files in a pool ==================================="
+
+test_200g() {
+        test_pools || return 0
+        TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
+        do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
+        wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" || error "$TGT not removed from $FSNAME.$POOL"
+}
+run_test 200g "Remove a target from a pool ============================="
+
+test_200h() {
+        test_pools || return 0
+        for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
+        do
+                do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
+        done
+        wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" ""\
+            || error "Pool $FSNAME.$POOL cannot be drained"
+        # striping on an empty pool should fall back to "pool of everything"
+        $SETSTRIPE -p $POOL ${POOL_FILE}/$tfile || \
+	    error "failed to create file with empty pool"
+}
+run_test 200h "Remove all targets from a pool =========================="
+
+test_200i() {
+        test_pools || return 0
+        do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
+        # get param should return err once pool is gone
+        wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "foo" && return 0
+        error "Pool $FSNAME.$POOL is not destroyed"
+}
+run_test 200i "Remove a pool ============================================"
+
 #
 # tests that do cleanup/setup should be run at the end
 #
diff --git a/lustre/tests/sanityN.sh b/lustre/tests/sanityN.sh
index 52f04a2..fcc3ccd 100644
--- a/lustre/tests/sanityN.sh
+++ b/lustre/tests/sanityN.sh
@@ -3,8 +3,8 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 3192 12652 15528/3811 16929 9977 15528/11549 18080
-ALWAYS_EXCEPT="                14b  14c   19         22    28   29          35    $SANITYN_EXCEPT"
+# bug number for skipped test: 3192 12652  15528/3811 16929 9977 15528/11549  18080
+ALWAYS_EXCEPT="                14b  14c    19         22    28   29           35    $SANITYN_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 # bug number for skipped test:                                                    12652 12652
@@ -18,13 +18,11 @@ PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
 
 SIZE=${SIZE:-40960}
 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
-CREATETEST=${CREATETEST:-createtest}
 GETSTRIPE=${GETSTRIPE:-lfs getstripe}
 SETSTRIPE=${SETSTRIPE:-lstripe}
 MCREATE=${MCREATE:-mcreate}
 OPENFILE=${OPENFILE:-openfile}
 OPENUNLINK=${OPENUNLINK:-openunlink}
-TOEXCL=${TOEXCL:-toexcl}
 TRUNCATE=${TRUNCATE:-truncate}
 export TMP=${TMP:-/tmp}
 MOUNT_2=${MOUNT_2:-"yes"}
@@ -45,7 +43,7 @@ init_test_env $@
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="12 16"
 
 SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
-FAIL_ON_ERROR=false
+FAIL_ON_ERROR=${FAIL_ON_ERROR:-false}
 
 SETUP=${SETUP:-:}
 TRACE=${TRACE:-""}
@@ -131,7 +129,7 @@ run_test 2e "check chmod on root is propagated to others"
 
 test_3() {
 	( cd $DIR1 ; ln -s this/is/good $tfile )
-	[ "this/is/good" = "`perl -e 'print readlink("'$DIR2/$tfile'");'`" ] ||\
+	[ "this/is/good" = "`perl -e 'print readlink("'$DIR2/$tfile'");'`" ] ||
 		error "link $DIR2/$tfile not as expected"
 }
 run_test 3 "symlink on one mtpt, readlink on another ==========="
@@ -425,17 +423,17 @@ test_22() { # Bug 9926
 	cat $DIR2/d21/no_joined || error "cat error"
 	rm -rf $DIR2/d21/no_joined || error "unlink normal file error"
 }
-run_test 22 " After joining in one dir,  open/close unlink file in anther dir" 
+run_test 22 " After joining in one dir,  open/close unlink file in anther dir"
 
 test_23() { # Bug 5972
 	echo "others should see updated atime while another read" > $DIR1/f23
-	
+
 	# clear the lock(mode: LCK_PW) gotten from creating operation
 	cancel_lru_locks osc
-	
-	time1=`date +%s`	
+
+	time1=`date +%s`
 	sleep 2
-	
+
 	multiop_bg_pause $DIR1/f23 or20_c || return 1
 	MULTIPID=$!
 
@@ -460,7 +458,7 @@ test_24() {
 	lfs df -i $DIR2 || error "lfs df -i $DIR2 failed"
 	lfs df $DIR1/$tfile || error "lfs df $DIR1/$tfile failed"
 	lfs df -ih $DIR2/$tfile || error "lfs df -ih $DIR2/$tfile failed"
-	
+
 	OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
 	lctl --device %$OSC deactivate
 	lfs df -i || error "lfs df -i with deactivated OSC failed"
@@ -504,25 +502,25 @@ test_26b() {
         chmod a+x $DIR2/$tfile
         mt1=`stat -c %Y $DIR1/$tfile`
         mt2=`stat -c %Y $DIR2/$tfile`
-        
-        if [ x"$mt1" != x"$mt2" ]; then 
+
+        if [ x"$mt1" != x"$mt2" ]; then
                 error "not equal mtime, client1: "$mt1", client2: "$mt2"."
         fi
 }
 run_test 26b "sync mtime between ost and mds"
 
 test_27() {
-	cancel_lru_locks OSC
+	cancel_lru_locks osc
 	lctl clear
 	dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
 	DD2_PID=$!
 	sleep 0.050s
 	log "dd 1 started"
-	
+
 	dd if=/dev/zero of=$DIR1/$tfile bs=$((16384-1024))k conv=notrunc count=1 seek=4 &
 	DD1_PID=$!
 	log "dd 2 started"
-	
+
 	sleep 1
 	dd if=/dev/zero of=$DIR1/$tfile bs=8k conv=notrunc count=1 seek=0
 	log "dd 3 finished"
@@ -540,7 +538,7 @@ test_28() { # bug 9977
 	dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2
 
 	$LCTL --device $ostID destroy "${tOBJID}"
-    
+
 	# reading of 1st stripe should pass
 	dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
 	# reading of 2nd stripe should fail (this stripe was destroyed)
@@ -593,7 +591,7 @@ run_test 31a "voluntary cancel / blocking ast race=============="
 
 test_31b() {
         remote_ost || { skip "local OST" && return 0; }
-	remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
+        remote_ost_nodsh && skip "remote OST w/o dsh" && return 0
         mkdir -p $DIR1/$tdir || error "Creating dir $DIR1/$tdir"
         lfs setstripe $DIR/$tdir/$tfile -i 0 -c 1
         cp /etc/hosts $DIR/$tdir/$tfile
@@ -616,10 +614,12 @@ enable_lockless_truncate() {
 test_32a() { # bug 11270
         local p="$TMP/sanityN-$TESTNAME.parameters"
         save_lustre_params $HOSTNAME llite.*.lockless_truncate > $p
+        rm -f $DIR1/$tfile
         cancel_lru_locks osc
-        clear_llite_stats
         enable_lockless_truncate 1
+        lfs setstripe -c -1 -s 1m $DIR1/$tfile
         dd if=/dev/zero of=$DIR1/$tfile count=10 bs=1M > /dev/null 2>&1
+        clear_llite_stats
 
         log "checking cached lockless truncate"
         $TRUNCATE $DIR1/$tfile 8000000
@@ -659,7 +659,7 @@ test_32b() { # bug 11270
                 save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
         done
         clear_llite_stats
-        # agressive lockless i/o settings 
+        # agressive lockless i/o settings
         for node in $(osts_nodes); do
                 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
         done
@@ -668,7 +668,7 @@ test_32b() { # bug 11270
                 dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
                 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
         done
-        [ $(calc_llite_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered" 
+        [ $(calc_llite_stats lockless_write_bytes) -ne 0 ] || error "lockless i/o was not triggered"
         # disable lockless i/o (it is disabled by default)
         for node in $(osts_nodes); do
                 do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
@@ -682,7 +682,7 @@ test_32b() { # bug 11270
                 dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > /dev/null 2>&1
         done
         [ $(calc_llite_stats lockless_write_bytes) -eq 0 ] ||
-                error "lockless i/o works when disabled" 
+                error "lockless i/o works when disabled"
         rm -f $DIR1/$tfile
         restore_lustre_params <$p
         rm -f $p
@@ -712,14 +712,12 @@ test_33() { #16129
                 echo writing on client1
                 dd if=/dev/zero of=$DIR1/$tfile count=100 conv=notrunc > /dev/null 2>&1
                 sync &
-                # wait for the flush
-                sleep 1
                 echo reading on client2
                 dd of=/dev/null if=$DIR2/$tfile > /dev/null 2>&1
                 # wait for a lock timeout
                 sleep 4
                 lock_out=$(do_nodes $(osts_nodes) "lctl get_param -n ldlm.namespaces.filter-*.lock_timeouts" | calc_sum)
-                if [ $OPER == "timeout" ] ; then 
+                if [ $OPER == "timeout" ] ; then
                         if [ $lock_in == $lock_out ]; then
                                 error "no lock timeout happened"
                         else
@@ -763,11 +761,11 @@ test_35() { # bug 17645
                 createmany -o $MOUNT2/$tfile/a 4000 &
                 pid1=$!
                 sleep 1
-        
+
                 # Let's make conflict and bl_ast
                 ls -la $MOUNT1/$tfile > /dev/null &
                 pid2=$!
-                
+
                 log "Wait for $pid1 $pid2 for $timeout sec..."
                 sleep $timeout
                 kill -9 $pid1 $pid2 > /dev/null 2>&1
@@ -794,26 +792,36 @@ run_test 35 "-EINTR cp_ast vs. bl_ast race does not evict client"
 
 test_36() { #bug 16417
     local SIZE
-    mkdir -p $MOUNT1/$tdir
-    lfs setstripe -c -1 $MOUNT1/$tdir
+    local SIZE_B
+    local i
+
+    mkdir -p $DIR1/$tdir
+    $LFS setstripe -c -1 $DIR1/$tdir
     i=0
-    SIZE=100
+    SIZE=50
+    let SIZE_B=SIZE*1024*1024
 
     while [ $i -le 10 ]; do
-	lctl mark "start test"
-	before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
-	dd if=/dev/zero of=$MOUNT1/$tdir/file000 bs=1M count=$SIZE
-	dd if=$MOUNT2/$tdir/file000 of=/dev/null bs=1M count=$SIZE &
-	read_pid=$!
-	sleep 0.1
-	rm -f $MOUNT1/$tdir/file000
-	wait $read_pid
-	after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
-	if [ $before -gt $after ]; then
-	    error "space leaked"
-	    exit;
-	fi
-	let i=i+1
+        lctl mark "start test"
+        local before=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
+        dd if=/dev/zero of=$DIR1/$tdir/file000 bs=1M count=$SIZE
+        sync
+        sleep 1
+        local after_dd=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
+        multiop_bg_pause $DIR2/$tdir/file000 O_r${SIZE_B}c || return 3
+        read_pid=$!
+        rm -f $DIR1/$tdir/file000
+        kill -USR1 $read_pid
+        wait $read_pid
+        sleep 1
+        local after=$($LFS df | awk '{if ($1 ~/^filesystem/) {print $5; exit} }')
+        echo "*** cycle($i) *** before($before):after_dd($after_dd):after($after)"
+        # this free space! not used
+        if [ $after_dd -ge $after ]; then
+            error "space leaked"
+            return 1;
+        fi
+        let i=i+1
     done
 }
 run_test 36 "handle ESTALE/open-unlink corectly"
@@ -833,6 +841,23 @@ test_37() { # bug 18695
 }
 run_test 37 "check i_size is not updated for directory on close (bug 18695) =============="
 
+test_39() {
+        local originaltime
+        local updatedtime
+        local delay=3
+
+        touch $DIR1/$tfile
+        originaltime=$(stat -c %Y $DIR1/$tfile)
+        log "original modification time is $originaltime"
+        sleep $delay
+        multiop $DIR1/$tfile oO_DIRECT:O_WRONLY:w$((10*1048576))c || error "multiop has failed"
+        updatedtime=$(stat -c %Y $DIR2/$tfile)
+        log "updated modification time is $updatedtime"
+        [ $((updatedtime - originaltime)) -ge $delay ] || error "invalid modification time"
+        rm -rf $DIR/$tfile
+}
+run_test 39 "direct I/O writes should update mtime ========="
+
 log "cleanup: ======================================================"
 
 check_and_cleanup_lustre
diff --git a/lustre/tests/sleeptest.c b/lustre/tests/sleeptest.c
deleted file mode 100644
index 7e40b24..0000000
--- a/lustre/tests/sleeptest.c
+++ /dev/null
@@ -1,151 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <time.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define BUFSIZE (4096)
-
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
-int main(int argc, char *argv[])
-{
-
-	FILE *w_str;
-	int read_fd;
-	int rc, iter;
-	int line, delta, next;
-	int sleeptime = 0;
-	char *now_time;
-	const char ok_chars[] = "MonTueWedThuFriSatSun"
-				"JanFebMarAprMayJunJulAugSepOctNovDec"
-				"Line 0123456789 of file, written at:\n";
-
-	char buf_r[BUFSIZE];
-
-	char pathname[256] = "/mnt/lustre/linetest_";
-	char *host;
-
-	if (argc > 1) {
-		strncpy(pathname, argv[1], 255);
-		pathname[255] = '\0';
-	}
-
-	host = getenv("HOSTNAME");
-	if (host)
-		strcat(pathname, host);
-
-	if (argc > 2)
-		sleeptime = strtoul(argv[2], NULL, 0);
-
-	if (sleeptime == 0)
-		sleeptime = 30;
-
-	printf("Test file used is: %s at %ds intervals\n", pathname, sleeptime);
-
-	w_str = fopen(pathname, "wb");
-	if (w_str == NULL) {
-		perror("fopen");
-		exit(1);
-	}
-	read_fd = open(pathname, O_RDONLY);
-	if (read_fd < 0) {
-		perror("open");
-		exit(1);
-	}
-
-	next = 1;
-	delta = 17;
-	iter = 1;
-	while (1) {
-		time_t now;
-		struct tm *t;
-		long offset;
-
-		now = time((time_t *)NULL);
-		t = localtime(&now);
-		now_time = asctime(t);
-
-		printf("iter: %d\n", iter);
-
-		for (line=next; line<(next+delta); line++) {
-			rc = fprintf(w_str, "Line %8d of file, written at: %s",
-				     line, now_time);
-			/* \n comes from ctime() result */
-			if (rc <= 0) {
-				perror("fprintf");
-				exit(4);
-			}
-			rc = fflush(w_str);
-			if (rc != 0) {
-				perror("fflush");
-				exit(5);
-			}
-		}
-		next += delta;
-
-		/* Check for corruption */
-		offset = ftell(w_str);
-		rc = lseek(read_fd, offset & ~4095, SEEK_SET);
-		if (rc != (offset & ~4095)) {
-			perror("lseek");
-			exit(7);
-		}
-
-		rc = read(read_fd, buf_r, min(100, offset & 4095));
-		if (rc != min(100, offset & 4095)) {
-			printf("rc: %d, off %lu buf: '%s'\n", rc,offset,buf_r);
-			exit(8);
-		}
-		buf_r[rc] = 0;
-		/* Chars from "C" days/months, and above Line */
-		if (strspn(buf_r, ok_chars) != rc) {
-			printf("Corruption detected at %lu on %s",
-			       offset & ~4095, now_time);
-			exit(9);
-		}
-
-		sleep(sleeptime);
-		iter++;
-	}
-
-}
diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh
index 0cae626..360cd0a 100644
--- a/lustre/tests/test-framework.sh
+++ b/lustre/tests/test-framework.sh
@@ -13,17 +13,9 @@ export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
 #export PDSH="pdsh -S -Rssh -w"
 
-# eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
-assert_env() {
-    local failed=""
-    for name in $@; do
-        if [ -z "${!name}" ]; then
-            echo "$0: $name must be set"
-            failed=1
-        fi
-    done
-    [ $failed ] && exit 1 || true
-}
+# function used by scripts run on remote nodes
+LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+. $LUSTRE/tests/functions.sh
 
 assert_DIR () {
     local failed=""
@@ -81,7 +73,14 @@ init_test_env() {
     export TESTSUITE=`basename $0 .sh`
     export TEST_FAILED=false
 
-    [ -d /r ] && export ROOT=${ROOT:-/r}
+    export MKE2FS=${MKE2FS:-mke2fs}
+    export DEBUGFS=${DEBUGFS:-debugfs}
+    export TUNE2FS=${TUNE2FS:-tune2fs}
+    export E2LABEL=${E2LABEL:-e2label}
+    export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
+    export E2FSCK=${E2FSCK:-e2fsck}
+
+    #[ -d /r ] && export ROOT=${ROOT:-/r}
     export TMP=${TMP:-$ROOT/tmp}
     export TESTSUITELOG=${TMP}/${TESTSUITE}.log
     export HOSTNAME=${HOSTNAME:-`hostname`}
@@ -91,11 +90,14 @@ init_test_env() {
     if ! echo $PATH | grep -q $LUSTRE/test; then
 	export PATH=$PATH:$LUSTRE/tests
     fi
-    export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
+    export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
     [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
     if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
         export PATH=$PATH:$LUSTRE/tests/racer
     fi
+    if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
+        export PATH=$PATH:$LUSTRE/tests/mpi
+    fi
     export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
     export LFS=${LFS:-"$LUSTRE/utils/lfs"}
     [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
@@ -106,10 +108,9 @@ init_test_env() {
     export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
     [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
     export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
-    export FSYTPE=${FSTYPE:-"ldiskfs"}
+    export FSTYPE=${FSTYPE:-"ldiskfs"}
     export NAME=${NAME:-local}
     export DIR2
-    export AT_MAX_PATH
     export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
 
     if [ "$ACCEPTOR_PORT" ]; then
@@ -142,7 +143,6 @@ init_test_env() {
 }
 
 case `uname -r` in
-2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
     *) EXT=".ko"; USE_QUOTA=yes;;
 esac
 
@@ -172,14 +172,21 @@ load_modules() {
 
     echo Loading modules from $LUSTRE
     load_module ../lnet/libcfs/libcfs
-    [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
-    [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
+    [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
+    [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
     local MODPROBECONF=
     [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
     [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
     [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
         LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
     echo $LNETOPTS | grep -q "accept=all"  || LNETOPTS="$LNETOPTS accept=all";
+    # bug 19380
+    # disable it for now since it only hides the stack overflow upon test w/
+    # local servers
+#    if [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "o2ib" -o "$NETTYPE" = "ptl" ]; then
+#        echo $LNETOPTS | grep -q "local_nid_dist_zero=0" ||
+#        LNETOPTS="$LNETOPTS local_nid_dist_zero=0"
+#    fi
     echo "lnet options: '$LNETOPTS'"
     # note that insmod will ignore anything in modprobe.conf
     load_module ../lnet/lnet/lnet $LNETOPTS
@@ -197,6 +204,7 @@ load_modules() {
         load_module mgs/mgs
         load_module mds/mds
         grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
+        grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
         [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
         load_module lvfs/fsfilt_$FSTYPE
         load_module ost/ost
@@ -270,7 +278,7 @@ unload_modules() {
     wait_exit_ST client # bug 12845
 
     lsmod | grep libcfs > /dev/null && $LCTL dl
-    unload_dep_module $FSTYPE
+    [ -z "$CLIENTONLY" ] && unload_dep_module $FSTYPE
     unload_dep_module libcfs
 
     local MODULES=$($LCTL modules | awk '{ print $2 }')
@@ -299,7 +307,7 @@ unload_modules() {
 mount_facet() {
     local facet=$1
     shift
-    local dev=${facet}_dev
+    local dev=$(facet_active $facet)_dev
     local opt=${facet}_opt
     echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
     do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
@@ -308,12 +316,12 @@ mount_facet() {
         echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
         echo "Start of ${!dev} on ${facet} failed ${RC}"
     else
-        do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
-            lctl set_param subsystem_debug=${SUBSYSTEM# }; \
+        do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
+            lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
             lctl set_param debug_mb=${DEBUG_SIZE}; \
             sync"
 
-        label=$(do_facet ${facet} "e2label ${!dev}")
+        label=$(do_facet ${facet} "$E2LABEL ${!dev}")
         [ -z "$label" ] && echo no label for ${!dev} && exit 1
         eval export ${facet}_svc=${label}
         echo Started ${label}
@@ -323,12 +331,20 @@ mount_facet() {
 
 # start facet device options
 start() {
-    facet=$1
+    local facet=$1
     shift
-    device=$1
+    local device=$1
     shift
     eval export ${facet}_dev=${device}
     eval export ${facet}_opt=\"$@\"
+
+    local varname=${facet}failover_dev
+    if [ -n "${!varname}" ] ; then
+        eval export ${facet}failover_dev=${!varname}
+    else
+        eval export ${facet}failover_dev=$device
+    fi
+
     do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
     mount_facet ${facet}
     RC=$?
@@ -354,6 +370,96 @@ stop() {
     wait_exit_ST ${facet}
 }
 
+# set quota version (both administrative and operational quotas)
+quota_set_version() {
+        do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
+        for j in `seq $OSTCOUNT`; do
+                do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=$1"
+        done
+}
+
+# save quota version (both administrative and operational quotas)
+# the function will also switch to the new version and the new type
+quota_save_version() {
+    local spec=$1
+    local ver=$(tr -c -d "123" <<< $spec)
+    local type=$(tr -c -d "ug" <<< $spec)
+
+    $LFS quotaoff -ug $MOUNT # just in case
+    [ -n "$ver" ] && quota_set_version $ver
+    [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
+
+    do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdt.quota_type=$spec"
+    local varsvc
+    local osts=$(get_facets OST)
+    for ost in ${osts//,/ }; do
+        varsvc=${ost}_svc
+        do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
+    done
+}
+
+# client could mount several lustre
+quota_type () {
+    local fsname=${1:-$FSNAME}
+    local rc=0
+    do_facet mgs lctl get_param mds.${fsname}-MDT*.quota_type || rc=$?
+    do_nodes $(comma_list $(osts_nodes)) \
+        lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
+    return $rc
+}
+
+restore_quota_type () {
+   local mntpt=${1:-$MOUNT}
+   local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
+   if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
+        return
+   fi
+   quota_save_version $old_QUOTA_TYPE
+}
+
+setup_quota(){
+    local mntpt=$1
+
+    # We need:
+    # 1. run quotacheck only if quota is off
+    # 2. save the original quota_type params, restore them after testing
+
+    # Suppose that quota type the same on mds and ost
+    local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
+    [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
+    if [ "$quota_type" != "$QUOTA_TYPE" ]; then
+        export old_QUOTA_TYPE=$quota_type
+        quota_save_version $QUOTA_TYPE
+    fi
+
+    local quota_usrs=$QUOTA_USERS
+
+    # get_filesystem_size
+    local disksz=$(lfs df $mntpt | grep "filesystem summary:"  | awk '{print $3}')
+    local blk_soft=$((disksz + 1024))
+    local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
+
+    local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:"  | awk '{print $3}')
+    local i_soft=$Inodes
+    local i_hard=$((i_soft + i_soft / 20))
+
+    echo "Total disk size: $disksz  block-softlimit: $blk_soft block-hardlimit:
+        $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
+
+    local cmd
+    for usr in $quota_usrs; do
+        echo "Setting up quota on $client:$mntpt for $usr..."
+        for type in u g; do
+            cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
+            echo "+ $cmd"
+            eval $cmd || error "$cmd FAILED!"
+        done
+        # display the quota status
+        echo "Quota settings for $usr : "
+        $LFS quota -v -u $usr $mntpt || true
+    done
+}
+
 zconf_mount() {
     local OPTIONS
     local client=$1
@@ -371,11 +477,10 @@ zconf_mount() {
     echo "Starting client: $client: $OPTIONS $device $mnt"
     do_node $client mkdir -p $mnt
     do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
-    do_node $client "lctl set_param debug=$PTLDEBUG;
-        lctl set_param subsystem_debug=${SUBSYSTEM# };
+    do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
+        lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
         lctl set_param debug_mb=${DEBUG_SIZE}"
 
-    [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
     return 0
 }
 
@@ -383,7 +488,7 @@ zconf_umount() {
     local client=$1
     local mnt=$2
     local force
-    local busy 
+    local busy
     local need_kill
 
     [ "$3" ] && force=-f
@@ -406,6 +511,62 @@ zconf_umount() {
     fi
 }
 
+# nodes is comma list
+sanity_mount_check_nodes () {
+    local nodes=$1
+    shift
+    local mnts="$@"
+    local mnt
+
+    # FIXME: assume that all cluster nodes run the same os
+    [ "$(uname)" = Linux ] || return 0
+
+    local rc=0
+    for mnt in $mnts ; do
+        do_nodes $nodes "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
+mpts=\\\$(mount | grep -w -c $mnt);
+if [ \\\$running -ne \\\$mpts ]; then
+    echo \\\$(hostname) env are INSANE!;
+    exit 1;
+fi"
+    [ $? -eq 0 ] || rc=1
+    done
+    return $rc
+}
+
+sanity_mount_check_servers () {
+    echo Checking servers environments
+
+    # FIXME: modify get_facets to display all facets wo params
+    local facets="$(get_facets OST),$(get_facets MDS)"
+    local node
+    local mnt
+    local facet
+    for facet in ${facets//,/ }; do
+        node=$(facet_host ${facet})
+        mnt=${MOUNT%/*}/${facet}
+        sanity_mount_check_nodes $node $mnt ||
+            { error "server $node environments are insane!"; return 1; }
+    done
+}
+
+sanity_mount_check_clients () {
+    local clients=${1:-$CLIENTS}
+    local mntpt=${2:-$MOUNT}
+    local mntpt2=${3:-$MOUNT2}
+
+    [ -z $clients ] && clients=$(hostname)
+    echo Checking clients $clients environments
+
+    sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
+       error "clients environments are insane!"
+}
+
+sanity_mount_check () {
+    sanity_mount_check_servers || return 1
+    sanity_mount_check_clients || return 2
+}
+
 # mount clients if not mouted
 zconf_mount_clients() {
     local OPTIONS
@@ -423,13 +584,22 @@ zconf_mount_clients() {
     fi
 
     echo "Starting client $clients: $OPTIONS $device $mnt"
-    do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
+
+    do_nodes $clients "set -x;
+running=\\\$(mount | grep -c $mnt' ');
+rc=0;
+if [ \\\$running -eq 0 ] ; then
+    mkdir -p $mnt;
+    mount -t lustre $OPTIONS $device $mnt;
+    rc=$?;
+fi;
+exit $rc"
 
     echo "Started clients $clients: "
-    do_nodes $clients "mount | grep $mnt"
+    do_nodes $clients "mount | grep -w $mnt"
 
-    do_nodes $clients "sysctl -w lnet.debug=$PTLDEBUG;
-        sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
+    do_nodes $clients "sysctl -w lnet.debug=\\\"$PTLDEBUG\\\";
+        sysctl -w lnet.subsystem_debug=\\\"${SUBSYSTEM# }\\\";
         sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
 
     return 0
@@ -443,29 +613,54 @@ zconf_umount_clients() {
     [ "$3" ] && force=-f
 
     echo "Stopping clients: $clients $mnt (opts:$force)"
-    do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts)
+    do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
 if [ \\\$running -ne 0 ] ; then
-echo Stopping client \\\$(hostname) client $mnt opts:$force
-lsof -t $mnt || need_kill=no
+echo Stopping client \\\$(hostname) client $mnt opts:$force;
+lsof -t $mnt || need_kill=no;
 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
     pids=\\\$(lsof -t $mnt | sort -u);
-    if [ -n \\\$pids ]; then
-             kill -9 \\\$pids
+    if [ -n \\\"\\\$pids\\\" ]; then
+             kill -9 \\\$pids;
     fi
-fi
-busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy")
+fi;
+busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
 if [ \\\$busy -ne 0 ] ; then
-    echo "$mnt is still busy, wait one second" && sleep 1
-    umount $force $mnt
+    echo "$mnt is still busy, wait one second" && sleep 1;
+    umount $force $mnt;
 fi
 fi"
 }
 
+shudown_node_hard () {
+    local host=$1
+    local attempts=3
+
+    for i in $(seq $attempts) ; do
+        $POWER_DOWN $host
+        sleep 1
+        ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
+        echo "waiting for $host to fail attempts=$attempts"
+        [ $i -lt $attempts ] || \
+            { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
+    done
+}
+
+shutdown_client() {
+    local client=$1
+    local mnt=${2:-$MOUNT}
+    local attempts=3
+
+    if [ "$FAILURE_MODE" = HARD ]; then
+        shudown_node_hard $client
+    else
+       zconf_umount_clients $client $mnt -f
+    fi
+}
+
 shutdown_facet() {
-    facet=$1
+    local facet=$1
     if [ "$FAILURE_MODE" = HARD ]; then
-        $POWER_DOWN `facet_active_host $facet`
-        sleep 2
+        shudown_node_hard $(facet_active_host $facet)
     elif [ "$FAILURE_MODE" = SOFT ]; then
         stop $facet
     fi
@@ -484,8 +679,154 @@ boot_node() {
     local node=$1
     if [ "$FAILURE_MODE" = HARD ]; then
        $POWER_UP $node
+       wait_for_host $node
+    fi
+}
+
+# recovery-scale functions
+check_progs_installed () {
+    local clients=$1
+    shift
+    local progs=$@
+
+    do_nodes $clients "set -x ; PATH=:$PATH; status=true;
+for prog in $progs; do
+    if ! [ \\\"\\\$(which \\\$prog)\\\"  -o  \\\"\\\${!prog}\\\" ]; then
+       echo \\\$prog missing on \\\$(hostname);
+       status=false;
+    fi
+done;
+eval \\\$status"
+}
+
+client_var_name() {
+    echo __$(echo $1 | tr '-' 'X')
+}
+
+start_client_load() {
+    local client=$1
+    local load=$2
+    local var=$(client_var_name $client)_load
+    eval export ${var}=$load
+
+    do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
+                              BREAK_ON_ERROR=$BREAK_ON_ERROR \
+                              END_RUN_FILE=$END_RUN_FILE \
+                              LOAD_PID_FILE=$LOAD_PID_FILE \
+                              TESTSUITELOG=$TESTSUITELOG \
+                              run_${load}.sh" &
+    CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
+    log "Started client load: ${load} on $client"
+
+    return 0
+}
+
+start_client_loads () {
+    local -a clients=(${1//,/ })
+    local numloads=${#CLIENT_LOADS[@]}
+    local testnum
+
+    for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
+        testnum=$((nodenum % numloads))
+        start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
+    done
+}
+
+# only for remote client
+check_client_load () {
+    local client=$1
+    local var=$(client_var_name $client)_load
+    local TESTLOAD=run_${!var}.sh
+
+    ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
+
+    # bug 18914: try to connect several times not only when
+    # check ps, but  while check_catastrophe also
+    local tries=3
+    local RC=254
+    while [ $RC = 254 -a $tries -gt 0 ]; do
+        let tries=$tries-1
+        # assume success
+        RC=0
+        if ! check_catastrophe $client; then
+            RC=${PIPESTATUS[0]}
+            if [ $RC -eq 254 ]; then
+                # FIXME: not sure how long we shuold sleep here
+                sleep 10
+                continue
+            fi
+            echo "check catastrophe failed: RC=$RC "
+            return $RC
+        fi
+    done
+
+    # We can continue try to connect if RC=254
+    # Just print the warning about this
+    if [ $RC = 254 ]; then
+        echo "got a return status of $RC from do_node while checking catastrophe on $client"
+    fi
+
+    # see if the load is still on the client
+    tries=3
+    RC=254
+    while [ $RC = 254 -a $tries -gt 0 ]; do
+        let tries=$tries-1
+        # assume success
+        RC=0
+        if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
+            RC=${PIPESTATUS[0]}
+            sleep 30
+        fi
+    done
+    if [ $RC = 254 ]; then
+        echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
+        # see if we can diagnose a bit why this is
     fi
+
+    return $RC
+}
+check_client_loads () {
+   local clients=${1//,/ }
+   local client=
+   local rc=0
+
+   for client in $clients; do
+      check_client_load $client
+      rc=${PIPESTATUS[0]}
+      if [ "$rc" != 0 ]; then
+        log "Client load failed on node $client, rc=$rc"
+        return $rc
+      fi
+   done
+}
+
+restart_client_loads () {
+    local clients=${1//,/ }
+    local expectedfail=${2:-""}
+    local client=
+    local rc=0
+
+    for client in $clients; do
+        check_client_load $client
+        rc=${PIPESTATUS[0]}
+        if [ "$rc" != 0 -a "$expectedfail" ]; then
+            local var=$(client_var_name $client)_load
+            start_client_load $client ${!var}
+            echo "Restarted client load ${!var}: on $client. Checking ..."
+            check_client_load $client
+            rc=${PIPESTATUS[0]}
+            if [ "$rc" != 0 ]; then
+                log "Client load failed to restart on node $client, rc=$rc"
+                # failure one client load means test fail
+                # we do not need to check other
+                return $rc
+            fi
+        else
+            return $rc
+        fi
+    done
 }
+# End recovery-scale functions
 
 # verify that lustre actually cleaned up properly
 cleanup_check() {
@@ -521,23 +862,24 @@ wait_update () {
         local WAIT=0
         local sleep=5
         while [ true ]; do
-            sleep $sleep
             RESULT=$(do_node $node "$TEST")
-            if [ $RESULT -eq $FINAL ]; then
-                echo "Updated after $WAIT sec: wanted $FINAL got $RESULT"
+            if [ "$RESULT" == "$FINAL" ]; then
+                echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
                 return 0
             fi
             [ $WAIT -ge $MAX ] && break
-            WAIT=$((WAIT + sleep))
             echo "Waiting $((MAX - WAIT)) secs for update"
+            WAIT=$((WAIT + sleep))
+            sleep $sleep
         done
-        echo "Update not seen after $MAX sec: wanted $FINAL got $RESULT"
+        echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
         return 3
 }
 
 wait_update_facet () {
     local facet=$1
-    wait_update  $(facet_host $facet) $@
+    shift
+    wait_update  $(facet_active_host $facet) "$@"
 }
 
 wait_delete_completed () {
@@ -559,32 +901,39 @@ wait_delete_completed () {
 }
 
 wait_for_host() {
-    local HOST=$1
-    check_network "$HOST" 900
-    while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
+    local host=$1
+    check_network "$host" 900
+    while ! do_node $host "ls -d $LUSTRE " > /dev/null; do sleep 5; done
 }
 
 wait_for() {
     local facet=$1
-    local HOST=`facet_active_host $facet`
-    wait_for_host $HOST
+    local host=`facet_active_host $facet`
+    wait_for_host $host
 }
 
-wait_mds_recovery_done () {
-    local timeout=`do_facet mds lctl get_param  -n timeout`
-#define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
-# as we are in process of changing obd_timeout in different ways
-# let's set MAX longer than that
-    local MAX=$(( timeout * 4 ))
+wait_recovery_complete () {
+    local facet=$1
+
+    # Use default policy if $2 is not passed by caller.
+    #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
+    # as we are in process of changing obd_timeout in different ways
+    # let's set MAX longer than that
+    local MAX=${2:-$(( TIMEOUT * 4 ))}
+
+    local var_svc=${facet}_svc
+    local procfile="*.${!var_svc}.recovery_status"
     local WAIT=0
+    local STATUS=
+
     while [ $WAIT -lt $MAX ]; do
-        STATUS=`do_facet mds "lctl get_param -n mds.*-MDT*.recovery_status | grep status"`
-        echo $STATUS | grep COMPLETE && return 0
+        STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
+        [[ $STATUS = "status: COMPLETE" ]] && return 0
         sleep 5
         WAIT=$((WAIT + 5))
-        echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
+        echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
     done
-    echo "MDS recovery not done in $MAX sec"
+    echo "$facet recovery not done in $MAX sec. $STATUS"
     return 1
 }
 
@@ -628,6 +977,7 @@ wait_remote_prog () {
     local pids=$(ps  uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
     [ -z "$pids" ] && return 0
     echo "$PDSH processes still exists after $WAIT seconds.  Still running: $pids"
+    # FIXME: not portable
     for pid in $pids; do
         cat /proc/${pid}/status || true
         cat /proc/${pid}/wchan || true
@@ -671,9 +1021,10 @@ facet_failover() {
     reboot_facet $facet
     client_df &
     DFPID=$!
+    RECOVERY_START_TIME=`date +%s`
     echo "df pid is $DFPID"
     change_active $facet
-    TO=`facet_active_host $facet`
+    local TO=`facet_active_host $facet`
     echo "Failover $facet to $TO"
     wait_for $facet
     mount_facet $facet || error "Restart of $facet failed"
@@ -688,8 +1039,8 @@ replay_barrier() {
     do_facet $facet sync
     df $MOUNT
     local svc=${facet}_svc
-    do_facet $facet $LCTL --device %${!svc} readonly
     do_facet $facet $LCTL --device %${!svc} notransno
+    do_facet $facet $LCTL --device %${!svc} readonly
     do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
     $LCTL mark "local REPLAY BARRIER on ${!svc}"
 }
@@ -699,15 +1050,16 @@ replay_barrier_nodf() {
     do_facet $facet sync
     local svc=${facet}_svc
     echo Replay barrier on ${!svc}
-    do_facet $facet $LCTL --device %${!svc} readonly
     do_facet $facet $LCTL --device %${!svc} notransno
+    do_facet $facet $LCTL --device %${!svc} readonly
     do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
     $LCTL mark "local REPLAY BARRIER on ${!svc}"
 }
 
 mds_evict_client() {
     UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
-    do_facet mds "lctl set_param -n mds.${mds_svc}.evict_client $UUID"
+    local mdtdevice=$(get_mds_mdt_device_proc_path)
+    do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
 }
 
 ost_evict_client() {
@@ -838,17 +1190,17 @@ facet_active_host() {
 
 change_active() {
     local facet=$1
-    failover=${facet}failover
+    local failover=${facet}failover
     host=`facet_host $failover`
     [ -z "$host" ] && return
-    curactive=`facet_active $facet`
+    local curactive=`facet_active $facet`
     if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
         eval export ${facet}active=$facet
     else
         eval export ${facet}active=$failover
     fi
     # save the active host for this facet
-    activevar=${facet}active
+    local activevar=${facet}active
     echo "$activevar=${!activevar}" > $TMP/$activevar
 }
 
@@ -910,9 +1262,9 @@ do_nodes() {
 }
 
 do_facet() {
-    facet=$1
+    local facet=$1
     shift
-    HOST=`facet_active_host $facet`
+    local HOST=`facet_active_host $facet`
     [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
     do_node $HOST "$@"
 }
@@ -945,14 +1297,11 @@ stopall() {
         fail mds
     fi
 
-    # assume client mount is local
-    grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
-    grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
+    local clients=$CLIENTS
+    [ -z $clients ] && clients=$(hostname)
 
-    if [ -n "$CLIENTS" ]; then
-            zconf_umount_clients $CLIENTS $MOUNT "$*" || true
-            [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
-    fi
+    zconf_umount_clients $clients $MOUNT "$*" || true
+    [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
 
     [ "$CLIENTONLY" ] && return
     # The add fn does rm ${facet}active file, this would be enough
@@ -1022,6 +1371,9 @@ writeconf_all () {
 }
 
 setupall() {
+    sanity_mount_check ||
+        error "environments are insane!"
+
     load_modules
     if [ -z "$CLIENTONLY" ]; then
         echo Setup mdt, osts
@@ -1032,7 +1384,9 @@ setupall() {
         start mds $MDSDEV $MDS_MOUNT_OPTS
         # We started mds, now we should set failover variable properly.
         # Set mdsfailover_HOST if it is not set (the default failnode).
-        mdsfailover_HOST=$(facet_host mds)
+        if [ -z "$mdsfailover_HOST" ]; then
+           mdsfailover_HOST=$(facet_host mds)
+        fi
 
         for num in `seq $OSTCOUNT`; do
             DEVNAME=`ostdevname $num`
@@ -1074,7 +1428,7 @@ init_facet_vars () {
     eval export ${facet}_opt=\"$@\"
 
     local dev=${facet}_dev
-    local label=$(do_facet ${facet} "e2label ${!dev}")
+    local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
     [ -z "$label" ] && echo no label for ${!dev} && exit 1
 
     eval export ${facet}_svc=${label}
@@ -1083,10 +1437,21 @@ init_facet_vars () {
     if [ -z "${!varname}" ]; then
        eval $varname=$(facet_host $facet)
     fi
+
+    # ${facet}failover_dev is set in cfg file
+    varname=${facet}failover_dev
+    if [ -n "${!varname}" ] ; then
+        eval export ${facet}failover_dev=${!varname}
+    else
+        eval export ${facet}failover_dev=$device
+    fi
 }
 
 init_facets_vars () {
-    init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
+    remote_mds_nodsh ||
+        init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
+
+    remote_ost_nodsh && return
 
     for num in `seq $OSTCOUNT`; do
         DEVNAME=`ostdevname $num`
@@ -1095,19 +1460,27 @@ init_facets_vars () {
 }
 
 init_param_vars () {
-    export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
-    export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
-    export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
+    if ! remote_ost_nodsh && ! remote_mds_nodsh; then
+        export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
+        export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
+        export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
+    fi
+
+    remote_mds_nodsh ||
+        TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
 
-    TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
     log "Using TIMEOUT=$TIMEOUT"
+
+    if [ "$ENABLE_QUOTA" ]; then
+        setup_quota $MOUNT  || return 2
+    fi
 }
 
 check_config () {
     local mntpt=$1
-    local myMGS_host=$mgs_HOST   
+    local myMGS_host=$mgs_HOST
     if [ "$NETTYPE" = "ptl" ]; then
-        myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//) 
+        myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
     fi
 
     echo Checking config lustre mounted on $mntpt
@@ -1115,10 +1488,12 @@ check_config () {
     mgshost=$(echo $mgshost | awk -F: '{print $1}')
 
     if [ "$mgshost" != "$myMGS_host" ]; then
-        FAIL_ON_ERROR=true \
-            error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
+            log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
                    Please use correct config or set mds_HOST correctly!"
     fi
+
+    sanity_mount_check ||
+        error "environments are insane!"
 }
 
 check_timeout () {
@@ -1142,6 +1517,11 @@ check_and_setup_lustre() {
         check_config $MOUNT
         init_facets_vars
         init_param_vars
+
+        do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
+            lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
+            lctl set_param debug_mb=${DEBUG_SIZE};
+            sync"
     fi
     if [ "$ONLY" == "setup" ]; then
         exit 0
@@ -1162,6 +1542,7 @@ cleanup_and_setup_lustre() {
 check_and_cleanup_lustre() {
     if [ "`mount | grep $MOUNT`" ]; then
         [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
+        [ "$ENABLE_QUOTA" ] && restore_quota_type || true
     fi
     if [ "$I_MOUNTED" = "yes" ]; then
         cleanupall -f || error "cleanup failed"
@@ -1177,8 +1558,7 @@ check_network() {
     local WAIT=0
     local MAX=$2
     while [ $NETWORK -eq 0 ]; do
-        ping -c 1 -w 3 $1 > /dev/null
-        if [ $? -eq 0 ]; then
+        if ping -c 1 -w 3 $1 > /dev/null; then
             NETWORK=1
         else
             WAIT=$((WAIT + 5))
@@ -1208,26 +1588,56 @@ comma_list() {
     echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
 }
 
+# list, excluded are the comma separated lists
+exclude_items_from_list () {
+    local list=$1
+    local excluded=$2
+    local item
+
+    list=${list//,/ }
+    for item in ${excluded//,/ }; do
+        list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
+    done
+    echo $(comma_list $list)
+}
+
+# list, expand  are the comma separated lists
+expand_list () {
+    local list=${1//,/ }
+    local expand=${2//,/ }
+    local expanded=
+
+    expanded=$(for i in $list $expand; do echo $i; done | sort -u)
+    echo $(comma_list $expanded)
+}
+
 absolute_path() {
     (cd `dirname $1`; echo $PWD/`basename $1`)
 }
 
-##################################
-# Adaptive Timeouts funcs
+get_facets () {
+    local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
+    local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
 
-at_is_valid() {
-    if [ -z "$AT_MAX_PATH" ]; then
-        AT_MAX_PATH=$(do_facet mds "find /sys/ -name at_max")
-        [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
-    fi
-    return 0
+    local list=""
+
+    case $type in
+        MDS )    list=mds;;
+        OST )    for ((i=1; i<=$OSTCOUNT; i++)) do
+                    list="$list ${name}$i"
+                 done;;
+          * )    error "Invalid facet type"
+                 exit 1;;
+    esac
+    echo $(comma_list $list)
 }
 
-at_is_enabled() {
-    at_is_valid || error "invalid call"
+##################################
+# Adaptive Timeouts funcs
 
+at_is_enabled() {
     # only check mds, we assume at_max is the same on all nodes
-    local at_max=$(do_facet mds "cat $AT_MAX_PATH")
+    local at_max=$(do_facet mds "lctl get_param -n at_max")
     if [ $at_max -eq 0 ]; then
         return 1
     else
@@ -1238,13 +1648,11 @@ at_is_enabled() {
 at_max_get() {
     local facet=$1
 
-    at_is_valid || error "invalid call"
-
     # suppose that all ost-s has the same at_max set
     if [ $facet == "ost" ]; then
-        do_facet ost1 "cat $AT_MAX_PATH"
+        do_facet ost1 "lctl get_param -n at_max"
     else
-        do_facet $facet "cat $AT_MAX_PATH"
+        do_facet $facet "lctl get_param -n at_max"
     fi
 }
 
@@ -1252,16 +1660,14 @@ at_max_set() {
     local at_max=$1
     shift
 
-    at_is_valid || error "invalid call"
-
     local facet
     for facet in $@; do
         if [ $facet == "ost" ]; then
             for i in `seq $OSTCOUNT`; do
-                do_facet ost$i "echo $at_max > $AT_MAX_PATH"
+                do_facet ost$i "lctl set_param at_max=$at_max"
             done
         else
-            do_facet $facet "echo $at_max > $AT_MAX_PATH"
+            do_facet $facet "lctl set_param at_max=$at_max"
         fi
     done
 }
@@ -1388,6 +1794,16 @@ pgcache_empty() {
     return 0
 }
 
+create_fake_exports () {
+    local facet=$1
+    local num=$2
+#obd_fail_val = num;
+#define OBD_FAIL_TGT_FAKE_EXP 0x708
+    do_facet $facet "lctl set_param fail_val=$num"
+    do_facet $facet "lctl set_param fail_loc=0x80000708"
+    fail $facet
+}
+
 debugsave() {
     DEBUGSAVE="$(lctl get_param -n debug)"
 }
@@ -1539,7 +1955,7 @@ log() {
     lsmod | grep lnet > /dev/null || load_modules
 
     local MSG="$*"
-    # Get rif of '
+    # Get rid of '
     MSG=${MSG//\'/\\\'}
     MSG=${MSG//\(/\\\(}
     MSG=${MSG//\)/\\\)}
@@ -1563,7 +1979,7 @@ trace() {
 }
 
 pass() {
-    $TEST_FAILED && echo -n "FAIL " || echo -n "PASS " 
+    $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
     echo $@
 }
 
@@ -1577,9 +1993,11 @@ reset_fail_loc () {
     local myNODES=$(nodes_list)
     local NODE
 
+    echo -n "Resetting fail_loc on all nodes..."
     for NODE in $myNODES; do
-        do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
+        do_node $NODE "lctl set_param -n fail_loc=0 2>/dev/null || true"
     done
+    echo done.
 }
 
 run_one() {
@@ -1592,7 +2010,8 @@ run_one() {
     umask 0022
 
     local BEFORE=`date +%s`
-    log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
+    echo
+    log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
     #check_mds
     export TESTNAME=test_$testnum
     TEST_FAILED=false
@@ -1705,6 +2124,13 @@ remote_ost_nodsh()
     remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
 }
 
+remote_mgs_nodsh()
+{
+    local MGS
+    MGS=$(facet_host mgs)
+    remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
+}
+
 remote_servers () {
     remote_ost && remote_mds
 }
@@ -1768,6 +2194,18 @@ init_clients_lists () {
     CLIENTCOUNT=$((${#remoteclients[@]} + 1))
 }
 
+get_random_entry () {
+    local rnodes=$1
+
+    rnodes=${rnodes//,/ }
+
+    local -a nodes=($rnodes)
+    local num=${#nodes[@]}
+    local i=$((RANDOM * num * 2 / 65536))
+
+    echo ${nodes[i]}
+}
+
 is_patchless ()
 {
     lctl get_param version | grep -q patchless
@@ -1846,6 +2284,8 @@ multiop_bg_pause() {
     $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
 
     echo "TMPPIPE=${TMPPIPE}"
+    local multiop_output
+
     read -t 60 multiop_output < $TMPPIPE
     if [ $? -ne 0 ]; then
         rm -f $TMPPIPE
@@ -1861,6 +2301,19 @@ multiop_bg_pause() {
     return 0
 }
 
+do_and_time () {
+    local cmd=$1
+    local rc
+
+    SECONDS=0
+    eval '$cmd'
+    
+    [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
+
+    echo $SECONDS
+    return $rc
+}
+
 inodes_available () {
     local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
     echo $IFree
@@ -1904,17 +2357,21 @@ restore_lustre_params() {
         done
 }
 
-check_catastrophe () {
-    local rnodes=$(comma_list $(remote_nodes_list))
+check_catastrophe() {
+    local rnodes=${1:-$(comma_list $(remote_nodes_list))}
+    local C=$CATASTROPHE
+    [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
 
-    [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && return 1
     if [ $rnodes ]; then
-        do_nodes $rnodes "[ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
+        do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
+if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
+exit \\\$rc;"
     fi
 }
 
 # $1 node
 # $2 file
+# $3 $RUNAS
 get_stripe_info() {
 	local tmp_file
 
@@ -1923,7 +2380,7 @@ get_stripe_info() {
 	stripe_index=0
 	tmp_file=$(mktemp)
 
-	do_facet $1 lfs getstripe -v $2 > $tmp_file
+	do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
 
 	stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
 	stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
@@ -1931,22 +2388,155 @@ get_stripe_info() {
 	rm -f $tmp_file
 }
 
-mpi_run () {
-    local mpirun="$MPIRUN $MPIRUN_OPTIONS"
-    local command="$mpirun $@"
+mdsrate_cleanup () {
+    mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
+}
+
+delayed_recovery_enabled () {
+    do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
+}
+
+################################################################################
+# The following functions are used to enable interop testing between
+# 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
+# mds -> mdt
+# {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
+# mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
+# mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
+################################################################################
+
+get_lustre_version () {
+    local node=${1:-"mds"}
+    do_facet $node $LCTL get_param -n version |  awk '/^lustre:/ {print $2}'
+}
 
-    if [ "$MPI_USER" != root -a $mpirun ]; then
-        echo "+ chmod 0777 $MOUNT"
-        chmod 0777 $MOUNT
-        command="su $MPI_USER sh -c \"$command \""
+get_mds_version_major () {
+    local version=$(get_lustre_version mds)
+    echo $version | awk -F. '{print $1}'
+}
+
+get_mds_version_minor () {
+    local version=$(get_lustre_version mds)
+    echo $version | awk -F. '{print $2}'
+}
+
+get_mds_version_patch () {
+    local version=$(get_lustre_version mds)
+    echo $version | awk -F. '{print $3}'
+}
+
+get_mds_version_fix () {
+    local version=$(get_lustre_version mds)
+    echo $version | awk -F. '{print $4}'
+}
+
+get_mds_fsstat_proc_path() {
+    local major=$(get_mds_version_major)
+    local minor=$(get_mds_version_minor)
+    if [ $major -le 1 -a $minor -le 8 ] ; then
+        echo "mds"
+    else
+        echo "osd"
     fi
+}
 
-    ls -ald $MOUNT
-    echo "+ $command"
-    eval $command
+get_mds_mntdev_proc_path() {
+    local fsstat_dev=$(get_mds_fsstat_proc_path)
+    echo "$fsstat_dev.*.mntdev"
 }
 
-mdsrate_cleanup () {
-    mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
+get_mdtlov_proc_path() {
+    local fsname=$1
+    local major=$(get_mds_version_major)
+    local minor=$(get_mds_version_minor)
+    if [ $major -le 1 -a $minor -le 8 ] ; then
+        echo "${fsname}-mdtlov"
+    else
+        echo "${fsname}-MDT0000-mdtlov"
+    fi
 }
 
+get_mdtosc_proc_path() {
+    local ost=$1
+    local major=$(get_mds_version_major)
+    local minor=$(get_mds_version_minor)
+    if [ $major -le 1 -a $minor -le 8 ] ; then
+        echo "${ost}-osc"
+    else
+        echo "${ost}-osc-MDT0000"
+    fi
+}
+
+get_mds_mdt_device_proc_path() {
+    local major=$(get_mds_version_major)
+    local minor=$(get_mds_version_minor)
+    if [ $major -le 1 -a $minor -le 8 ] ; then
+        echo "mds"
+    else
+        echo "mdt"
+    fi
+}
+
+########################
+convert_facet2name() {
+    case "$1" in
+        "ost" ) echo "OST0000" ;;
+        "ost1") echo "OST0000" ;;
+        "ost2") echo "OST0001" ;;
+        "ost3") echo "OST0002" ;;
+        "ost4") echo "OST0003" ;;
+        "ost5") echo "OST0004" ;;
+        *) error "unknown facet!" ;;
+    esac
+}
+
+get_clientosc_proc_path() {
+    local ost=$1
+
+    echo "{$1}-osc-*"
+}
+
+get_osc_import_name() {
+    local node=$1
+    local ost=$2
+    local name=$(convert_facet2name $ost)
+
+    if [ "$node" == "mds" ]; then
+        get_mdtosc_proc_path $name
+        return 0
+    fi
+
+    get_clientosc_proc_path $name
+    return 0
+}
+
+wait_osc_import_state() {
+    local node=$1
+    local ost_facet=$2
+    local expected=$3
+    local ost=$(get_osc_import_name $node $ost_facet)
+    local CONN_PROC
+    local CONN_STATE
+    local i=0
+
+    CONN_PROC="osc.${FSNAME}-${ost}.ost_server_uuid"
+    CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC | cut -f2)
+    while [ "${CONN_STATE}" != "${expected}" ]; do
+        if [ "${expected}" == "DISCONN" ]; then 
+            # for disconn we can check after proc entry is removed
+            [ "x${CONN_STATE}" == "x" ] && return 0
+            #  with AT enabled, we can have connect request timeout near of 
+            # reconnect timeout and test can't see real disconnect
+            [ "${CONN_STATE}" == "CONNECTING" ] && return 0
+        fi
+        # disconnect rpc should be wait not more obd_timeout
+        [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
+            error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
+        sleep 1
+        CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC | cut -f2)
+        i=$(($i + 1))
+    done
+
+    log "${ost_facet} now in ${CONN_STATE} state"
+    return 0
+}
diff --git a/lustre/tests/toexcl.c b/lustre/tests/toexcl.c
deleted file mode 100644
index 43ca4c9..0000000
--- a/lustre/tests/toexcl.c
+++ /dev/null
@@ -1,113 +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  2008 Sun Microsystems, Inc. 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.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-
-void
-usage (char *argv0, int help)
-{
-	char *progname = strrchr(argv0, '/');
-
-	if (progname == NULL)
-		progname = argv0;
-	
-	fprintf (help ? stdout : stderr,
-		 "Usage: %s [-e] file\n", progname);
-	
-	if (!help)
-	{
-		fprintf (stderr, "   or try '-h' for help\n");
-		exit (1);
-	}
-	
-	printf ("Create the given file with O_EXCL...\n");
-	printf (" -e    expect EEXIST\n");
-	printf (" -h    print help");
-	printf (" Exit status is 0 on success, 1 on failure\n");
-}
-
-int main(int argc, char **argv)
-{
-        int rc;
-	int want_eexist = 0;
-	
-	while ((rc = getopt (argc, argv, "eh")) != -1)
-		switch (rc)
-		{
-		case 'e':
-			want_eexist = 1;
-			break;
-		case 'h':
-			usage (argv[1], 1);
-			return (0);
-		default:
-			usage (argv[0], 0);
-		}
-	
-        if (optind != argc - 1) { 
-		usage (argv[0], 0);
-                return 1;
-        }
-
-        rc = open(argv[optind], O_CREAT|O_EXCL, 0644);
-        if (rc == -1)
-	{
-		if (want_eexist && errno == EEXIST)
-		{
-			printf("open failed: %s (expected)\n", strerror(errno));
-			return (0);
-		}
-		printf("open failed: %s\n", strerror(errno));
-		return (1);
-	} else {
-		if (want_eexist)
-		{
-			printf("open success (expecting EEXIST).\n");
-			return (1);
-		}
-		printf("open success.\n");
-		return (0);
-	}
-	
-	return ((rc == 0) ? 0 : 1);
-}
diff --git a/lustre/tests/write_append_truncate.c b/lustre/tests/write_append_truncate.c
deleted file mode 100644
index bae9ba4..0000000
--- a/lustre/tests/write_append_truncate.c
+++ /dev/null
@@ -1,557 +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  2008 Sun Microsystems, Inc. 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.
- *
- * lustre/tests/write_append_truncate.c
- *
- * Each loop does 3 things:
- *   - truncate file to zero (not via ftruncate though, to test O_APPEND)
- *   - write a "chunk" of data (should be at file offset 0 after truncate)
- *   - on each of two threads either append or truncate-up the file
- *
- * If the truncate happened first, we should have a hole in the file.
- * If the append happened first, we should have truncated the file down.
- *
- * WRITE_SIZE_MAX and APPEND_SIZE_MAX are large enough to cross a stripe.
- *
- * compile: mpicc -g -Wall -o write_append_truncate write_append_truncate.c
- * run:     mpirun -np 2 -machlist <hostlist file> write_append_truncate <file>
- *  or:     pdsh -w <two hosts> write_append_truncate <file>
- *  or:     prun -n 2 [-N 2] write_append_truncate <file>
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <time.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-#include "mpi.h"
-
-#define DEFAULT_ITER    10000
-
-#define WRITE_SIZE_MAX  1234567
-#define APPEND_SIZE_MAX 1234567
-#define TRUNC_SIZE_MAX  1234567
-
-#define STATUS_FMT "WR %c %7d/%#08x, AP %c %7d/%#08x, TR@ %7d/%#08x"
-
-#define HOSTNAME_SIZE 50
-char hostname[HOSTNAME_SIZE];
-#define FNAMES_MAX 256
-
-void usage(char *prog)
-{
-        printf("usage: %s [-a append_max] [-C] [-n nloops] [-s seed]\n"
-               "\t\t[-t trunc_max] [-T] [-v] [-w write_max] <filename> ...\n", prog);
-        printf("\t-a append_max: maximum size of append, default %u bytes\n",
-               APPEND_SIZE_MAX);
-        printf("\t-C: 'classic' checks (on file 0)\n");
-        printf("\t-n nloops: count of loops to run, default %u\n",DEFAULT_ITER);
-        printf("\t-s seed: random seed to use, default {current time}\n");
-        printf("\t-t trunc_max: maximum size of truncate, default %u bytes\n",
-               TRUNC_SIZE_MAX);
-        printf("\t-T: 'classic' truncates (on file 0)\n");
-        printf("\t-w write_max: maximum size of write, default %u bytes\n",
-               WRITE_SIZE_MAX);
-        printf("\t-W: 'classic' writes (on rank 0, file 0)\n");
-        printf("\t-v: run in verbose mode (repeat for more verbosity)\n");
-        printf("\tfilename for each mountpoint of same filesystem on a node\n");
-        printf("\b%s must be run with at least 2 processes\n", prog);
-
-        MPI_Finalize();
-        exit(1);
-}
-
-/* Print process rank, loop count, message, and exit (i.e. a fatal error) */
-void rprintf(int rank, int loop, int error, const char *fmt, ...)
-__attribute__ ((format (printf, 4, 5)));
-
-void rprintf(int rank, int loop, int error, const char *fmt, ...)
-{
-        va_list       ap;
-
-        printf("r=%2u", rank);
-        if (loop >= 0)
-                printf(" l=%04u", loop);
-        if (error != 0)
-                printf(" %s", hostname);
-        printf(": ");
-
-        va_start(ap, fmt);
-
-        vprintf(fmt, ap);
-
-        if (error != 0)
-                MPI_Abort(MPI_COMM_WORLD, error);
-}
-
-int main(int argc, char *argv[])
-{
-        int n, nloops = DEFAULT_ITER;
-        int nfnames = 0, ifnames, fd;
-        int rank = -1, nproc, ret;
-        unsigned write_max = WRITE_SIZE_MAX;
-        unsigned append_max = APPEND_SIZE_MAX;
-        unsigned write_size = 0, append_size = 0, trunc_size = 0;
-        unsigned trunc_max = 0, trunc_offset = 0;
-        char *append_buf;
-        char *write_buf;
-        char *read_buf = NULL;
-        char *trunc_buf = NULL;
-        int seed = time(0);
-        int done;
-        int error;
-        int verbose = 0;
-        int classic_check = 0, classic_trunc = 0, classic_write = 0;
-        char write_char = 'A', append_char = 'a';
-        char *fnames[FNAMES_MAX], *end;
-        char *prog = "write_append_truncate";
-        int c;
-
-        error = MPI_Init(&argc, &argv);
-        if (error != MPI_SUCCESS)
-                printf("%s: MPI_Init failed: %d\n", prog, error);
-        else if (verbose > 2)
-                printf("%s: MPI_Init succeeded\n", prog);
-
-        prog = strrchr(argv[0], '/');
-        if (prog == NULL)
-                prog = argv[0];
-        else
-                prog++;
-
-        while ((c = getopt(argc, argv, "a:cCn:s:t:Tvw:W")) != -1) {
-                switch(c) {
-                case 'a':
-                        append_max = strtoul(optarg, &end, 0);
-                        if (append_max == 0 || *end) {
-                                fprintf(stderr, "%s: bad append option '%s'\n",
-                                        prog, optarg);
-                                usage(prog);
-                        }
-                        break;
-                case 'C':
-                        classic_check++;
-                        break;
-                case 'n':
-                        nloops = strtoul(optarg, &end, 0);
-                        if (nloops == 0 || *end) {
-                                fprintf(stderr, "%s: bad nloops option '%s'\n",
-                                        prog, optarg);
-                                usage(prog);
-                        }
-                        break;
-                case 's':
-                        seed = strtoul(optarg, &end, 0);
-                        if (*end) {
-                                fprintf(stderr, "%s: bad seed option '%s'\n",
-                                        prog, optarg);
-                                usage(prog);
-                        }
-                        break;
-                case 't':
-                        trunc_max = strtoul(optarg, &end, 0);
-                        if (*end) {
-                                fprintf(stderr,"%s: bad truncate option '%s'\n",
-                                        prog, optarg);
-                                usage(prog);
-                        }
-                        break;
-                case 'T':
-                        classic_trunc++;
-                        break;
-                case 'v':
-                        verbose++;
-                        break;
-                case 'w':
-                        write_max = strtoul(optarg, &end, 0);
-                        if (write_max == 0 || *end) {
-                                fprintf(stderr, "%s: bad write option '%s'\n",
-                                        prog, optarg);
-                                usage(prog);
-                        }
-                        break;
-                case 'W':
-                        classic_write++;
-                        break;
-                default:
-                        fprintf(stderr, "%s: unknown option '%c'\n", prog, c);
-                        usage(prog);
-                }
-        }
-
-        srand(seed);
-
-        if (argc == optind) {
-                fprintf(stderr, "%s: missing filename argument\n", prog);
-                usage(prog);
-        }
-
-        if (argc > optind + FNAMES_MAX) {
-                fprintf(stderr, "%s: too many extra options\n", prog);
-                usage(prog);
-        }
-
-        while (optind < argc)
-                fnames[nfnames++] = argv[optind++];
-
-        error = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
-        if (verbose > 2 || error != MPI_SUCCESS)
-                rprintf(rank, -1, error != MPI_SUCCESS, "MPI_Comm_rank: %d\n",
-                        error);
-
-        error = MPI_Comm_size(MPI_COMM_WORLD, &nproc);
-        if (verbose > 2 || error != MPI_SUCCESS)
-                rprintf(rank, -1, error != MPI_SUCCESS, "MPI_Comm_size: %d\n",
-                        error);
-
-        if (nproc < 2)
-                rprintf(rank, -1, 1, "%s: must run with at least 2 processes\n",
-                        prog);
-
-        append_buf = malloc(append_max);
-        if (append_buf == NULL)
-                rprintf(rank, -1, 1,"%s: error allocating append_buf %u\n",
-                        prog, append_max);
-
-        write_buf = malloc(write_max);
-        if (write_buf == NULL)
-                rprintf(rank, -1, 1, "%s: error allocating write_buf %u\n",
-                        prog, write_max);
-
-        if (gethostname(hostname, HOSTNAME_SIZE) < 0)
-                rprintf(rank, -1, 1, "%s: gethostname failed: %s\n",
-                        prog, strerror(errno));
-
-        if (rank == 0) {
-                int max_size = write_max + (trunc_max ?: append_max)+append_max;
-
-                fd = open(fnames[0], O_WRONLY|O_CREAT|O_TRUNC, 0666);
-                rprintf(rank,-1, fd<0, "create %s, max size: %u, seed %u: %s\n",
-                        fnames[0], max_size, seed, strerror(errno));
-                close(fd);
-
-                trunc_buf = calloc(1, trunc_max ?: append_max);
-                if (trunc_buf == NULL)
-                        rprintf(rank,-1,1,"%s: error allocating trunc_buf %u\n",
-                                prog, trunc_max ?: append_max);
-
-                /* initial write + truncate up + append */
-                read_buf = malloc(max_size);
-                if (read_buf == NULL)
-                        rprintf(rank,-1,1,"%s: error allocating read_buf %u\n",
-                                prog, max_size);
-        }
-
-        error = MPI_Barrier(MPI_COMM_WORLD);
-        if (verbose > 2 || error != MPI_SUCCESS)
-                rprintf(rank, -1, error != MPI_SUCCESS,
-                        "prep MPI_Barrier: %d\n", error);
-
-        ifnames = rank % nfnames;
-        fd = open(fnames[ifnames], O_RDWR | O_APPEND);
-        if (verbose || fd < 0)
-                rprintf(rank, -1, errno, "open '%s' (%u): %s\n",
-                        fnames[ifnames], ifnames, strerror(errno));
-
-        for (n = 0; n < nloops; n++) {
-                /* Initialized only to quiet stupid GCC warnings */
-                unsigned write_rank = 0, append_rank = n, trunc_rank = n + 1;
-                unsigned mpi_shared_vars[6];
-
-                /* reset the environment */
-                write_char = 'A' + (n % 26);
-                append_char = 'a' + (n % 26);
-
-                if (rank == 0) {
-                        write_size = (rand() % (write_max - 1)) + 1;
-                        append_size = (rand() % (append_max - 1)) + 1;
-                        trunc_size = (rand() % ((trunc_max?: append_size)-1))+1;
-                        trunc_offset = write_size + trunc_size;
-
-                        if (verbose || n % 1000 == 0)
-                                rprintf(rank, n, 0, STATUS_FMT"\n",
-                                        write_char, write_size, write_size,
-                                        append_char, append_size, append_size,
-                                        trunc_offset, trunc_offset);
-
-                        write_rank = (classic_write ? 0 : rand()) % nproc;
-                        do {
-                                append_rank = (classic_write ? n : rand()) %
-                                                                nproc;
-                                /* We can't allow the append rank be the same
-                                 * as the classic_trunc trunc_rank, or we will
-                                 * spin here forever. */
-                        } while (append_rank == (n + 1) % nproc);
-                        do {
-                                trunc_rank = (classic_trunc? (n + 1) : rand()) %
-                                                                nproc;
-                        } while (trunc_rank == append_rank);
-
-                        mpi_shared_vars[0] = write_size;
-                        mpi_shared_vars[1] = append_size;
-                        mpi_shared_vars[2] = trunc_size;
-                        mpi_shared_vars[3] = write_rank;
-                        mpi_shared_vars[4] = append_rank;
-                        mpi_shared_vars[5] = trunc_rank;
-                }
-
-                error = MPI_Bcast(&mpi_shared_vars, 6,
-                                  MPI_INT, 0, MPI_COMM_WORLD);
-                if (verbose > 2 || error != MPI_SUCCESS)
-                        rprintf(rank, n, error != MPI_SUCCESS,
-                                "MPI_Bcast mpi_shared_vars"
-                                "[%u, %u, %u, %u, %u, %u]: %d\n",
-                                mpi_shared_vars[0], mpi_shared_vars[1],
-                                mpi_shared_vars[2], mpi_shared_vars[3],
-                                mpi_shared_vars[4], mpi_shared_vars[5], error);
-
-                if (rank != 0) {
-                        write_size  = mpi_shared_vars[0];
-                        append_size = mpi_shared_vars[1];
-                        trunc_size  = mpi_shared_vars[2];
-                        write_rank  = mpi_shared_vars[3];
-                        append_rank = mpi_shared_vars[4];
-                        trunc_rank  = mpi_shared_vars[5];
-
-                        trunc_offset = write_size + trunc_size;
-                }
-
-                if (rank == write_rank || rank == 0)
-                        memset(write_buf, write_char, write_max);
-
-                if (rank == write_rank) {
-                        ifnames = (classic_write ? 0 : rand()) % nfnames;
-                        ret = truncate(fnames[ifnames], 0);
-                        if (verbose > 1 || ret != 0)
-                                rprintf(rank, n, ret,
-                                        "initial truncate %s (%u) @ 0: %s\n",
-                                        fnames[ifnames], ifnames,
-                                        strerror(errno));
-
-                        done = 0;
-                        do {
-                                ret = write(fd, write_buf+done,write_size-done);
-                                if (verbose > 1 || ret <= 0) {
-                                        rprintf(rank, n, ret <= 0,
-                                                "write %d/%d @ %d: %s\n",
-                                                ret + done, write_size, done,
-                                                strerror(errno));
-                                        if (ret <= 0)
-                                                break;
-                                }
-                                done += ret;
-                        } while (done != write_size);
-                }
-
-                if (rank == append_rank || rank == 0)
-                        memset(append_buf, append_char, append_size);
-
-                error = MPI_Barrier(MPI_COMM_WORLD);
-                if (verbose > 2 || error != MPI_SUCCESS)
-                        rprintf(rank, n, error != MPI_SUCCESS,
-                                "start MPI_Barrier: %d\n", error);
-
-                /* Do the race */
-                if (rank == append_rank) {
-                        done = 0;
-                        do {
-                                ret = write(fd, append_buf + done,
-                                            append_size - done);
-                                if (ret < 0) {
-                                        rprintf(rank, n, ret < 0,
-                                                "append %u/%u: %s\n",
-                                                ret + done, append_size,
-                                                strerror(errno));
-                                        break;
-                                } else if (verbose > 1 || ret != append_size) {
-                                        rprintf(rank, n, ret != append_size,
-                                                "append %u/%u\n",
-                                                ret + done, append_size);
-                                }
-                                done += ret;
-                        } while (done != append_size);
-                } else if (rank == trunc_rank) {
-                        /* XXX: truncating the same file descriptor as the
-                         *      append on a single node causes this test
-                         *      to fail currently (2009-02-01). */
-                        ifnames = (classic_trunc ? rank : rand()) % nfnames;
-                        ret = truncate(fnames[ifnames], trunc_offset);
-                        if (verbose > 1 || ret != 0)
-                                rprintf(rank, n, ret,
-                                        "truncate %s (%u) @ %u: %s\n",
-                                        fnames[ifnames], ifnames,
-                                        trunc_offset, strerror(errno));
-                }
-
-                error = MPI_Barrier(MPI_COMM_WORLD);
-                if (verbose > 2 || error != MPI_SUCCESS)
-                        rprintf(rank, n, error != MPI_SUCCESS,
-                                "end MPI_Barrier: %d\n", error);
-
-                error = 0;
-
-                /* Check the result */
-                if (rank == 0) {
-                        char *tmp_buf;
-                        struct stat st = { 0 };
-
-                        ifnames = classic_check ? 0 : (rand() % nfnames);
-                        ret = stat(fnames[ifnames], &st);
-                        if (verbose > 1 || ret != 0)
-                                rprintf(rank, n, ret,
-                                        "stat %s (%u) size %llu: %s\n",
-                                        fnames[ifnames], ifnames,
-                                        (long long)st.st_size, strerror(errno));
-
-                        ret = lseek(fd, 0, SEEK_SET);
-                        if (ret != 0)
-                                rprintf(rank, n, ret, "lseek 0: %s\n",
-                                        strerror(errno));
-
-                        done = 0;
-                        do {
-                                ret = read(fd, read_buf+done, st.st_size-done);
-                                if (verbose > 1 || ret <= 0) {
-                                        rprintf(rank, n, ret <= 0,
-                                                "read %d/%llu @ %u: %s\n",
-                                                ret, (long long)st.st_size-done,
-                                                done, ret != 0 ?
-                                                strerror(errno) : "short read");
-                                }
-                                done += ret;
-                        } while (done != st.st_size);
-
-                        if (memcmp(read_buf, write_buf, write_size)) {
-                                rprintf(rank, n, 0, "WRITE bad "
-                                        "[0-%d]/[0-%#x] != %c\n",
-                                        write_size - 1, write_size - 1,
-                                        write_char);
-                                error = 1;
-                        }
-
-                        tmp_buf = read_buf + write_size;
-
-                        if (st.st_size == trunc_offset) {
-                                /* Check case 1: first append then truncate */
-                                int tmp_size, tmp_offset;
-
-                                tmp_size = trunc_size < append_size ?
-                                                trunc_size : append_size;
-                                tmp_offset = write_size + tmp_size;
-
-                                if (memcmp(tmp_buf, append_buf, tmp_size)) {
-                                        rprintf(rank, n, 0,"trunc-after-APPEND "
-                                                "bad [%d-%d]/[%#x-%#x] != %c\n",
-                                                write_size, tmp_offset - 1,
-                                                write_size, tmp_offset - 1,
-                                                append_char);
-                                        error = 1;
-                                } else if (trunc_size > append_size &&
-                                           memcmp(tmp_buf+append_size,trunc_buf,
-                                                  trunc_size - append_size)) {
-                                        rprintf(rank, n, 0,"TRUNC-after-append "
-                                                "bad [%d-%d]/[%#x-%#x] != 0\n",
-                                                tmp_offset, trunc_offset - 1,
-                                                tmp_offset, trunc_offset - 1);
-                                        error = 1;
-                                }
-                        } else {
-                                int expected_size = trunc_offset + append_size;
-                                /* Check case 2: first truncate then append */
-                                if (st.st_size != expected_size) {
-                                        rprintf(rank, n, 0,"APPEND-after-trunc "
-                                                "bad file size %llu != %u\n",
-                                                (long long)st.st_size,
-                                                expected_size);
-                                        error = 1;
-                                }
-
-                                if (memcmp(tmp_buf, trunc_buf, trunc_size)) {
-                                        rprintf(rank, n, 0,"append-after-TRUNC "
-                                                "bad [%d-%d]/[%#x-%#x] != 0\n",
-                                                write_size, trunc_offset - 1,
-                                                write_size, trunc_offset - 1);
-                                        error = 1;
-                                } else if (memcmp(read_buf + trunc_offset,
-                                                  append_buf, append_size)) {
-                                        rprintf(rank, n, 0,"APPEND-after-trunc "
-                                                "bad [%d-%d]/[%#x-%#x] != %c\n",
-                                                trunc_offset, expected_size - 1,
-                                                trunc_offset, expected_size - 1,
-                                                append_char);
-                                        error = 1;
-                                }
-                        }
-
-                        if (error == 1) {
-                                char command[4096];
-
-                                rprintf(rank, n, 0, STATUS_FMT"\n",
-                                        write_char, write_size, write_size,
-                                        append_char, append_size, append_size,
-                                        trunc_offset, trunc_offset);
-
-                                sprintf(command, "od -Ax -a %s", fnames[0]);
-                                system(command);
-                                MPI_Abort(MPI_COMM_WORLD, 1);
-                        }
-                }
-        }
-
-        if (rank == 0 || verbose)
-                printf("r=%2u n=%4u: "STATUS_FMT"\nPASS\n", rank, n - 1,
-                       write_char, write_size, write_size,
-                       append_char, append_size, append_size,
-                       trunc_offset, trunc_offset);
-
-        close(fd);
-
-        if (rank == 0) {
-                ifnames = rand() % nfnames;
-                ret = unlink(fnames[ifnames]);
-                if (ret != 0)
-                        printf("%s: unlink %s failed: %s\n",
-                               prog, fnames[ifnames], strerror(errno));
-        }
-
-        MPI_Finalize();
-        return 0;
-}
diff --git a/lustre/tests/writemany.c b/lustre/tests/writemany.c
index c9db9f9..707ab8d 100644
--- a/lustre/tests/writemany.c
+++ b/lustre/tests/writemany.c
@@ -178,6 +178,7 @@ int run_one_child(char *file, int thread, int seconds)
                 maxrand *= 10;
 
         gettimeofday(&start, NULL);
+        cur = start;
 
         while(!rc) {
                 if (usr1_received)
@@ -233,7 +234,8 @@ int run_one_child(char *file, int thread, int seconds)
                 printf("%s: %7ld files, %4ld MB in %.2fs (%7.2f files/s, "
                        "%5.2f MB/s): rc = %d\n",
                        cmdname, nfiles, nbytes >> 20, diff,
-                       (double)nfiles / diff, (double)nbytes/1024/1024 / diff,
+                       diff == 0 ? (double)0 : (double)nfiles / diff,
+                       diff == 0 ? (double)0 : (double)nbytes/1024/1024 / diff,
                        rc);
 
         return rc;
diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am
index 709a7e5..c24c1aa 100644
--- a/lustre/utils/Makefile.am
+++ b/lustre/utils/Makefile.am
@@ -28,19 +28,18 @@ endif # UTILS
 lib_LIBRARIES = liblustreapi.a
 
 lctl_SOURCES = parser.c obd.c lustre_cfg.c lctl.c parser.h obdctl.h platform.h
-lctl_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
-lctl_DEPENDENCIES := $(LIBPTLCTL)
+lctl_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
+lctl_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
 lfs_SOURCES = lfs.c parser.c lustre_cfg.c obd.c
 lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
 lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a 
 
 loadgen_SOURCES = loadgen.c lustre_cfg.c obd.c
-loadgen_LDADD := $(LIBREADLINE) $(LIBPTLCTL) $(PTHREAD_LIBS)
-loadgen_DEPENDENCIES := $(LIBPTLCTL)
+loadgen_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS)
+loadgen_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
-lshowmount_SOURCES    = lshowmount.h lshowmount.c hash.c hash.h \
-			thread.c thread.h hostlist.c hostlist.h
+lshowmount_SOURCES    = lshowmount.c nidlist.c nidlist.h
 
 if EXT2FS_DEVEL
 EXT2FSLIB = -lext2fs
diff --git a/lustre/utils/Makefile.in b/lustre/utils/Makefile.in
index abc60ff..c37ae52 100644
--- a/lustre/utils/Makefile.in
+++ b/lustre/utils/Makefile.in
@@ -177,9 +177,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
@@ -319,20 +319,18 @@ bin_scripts = llstat llobdstat plot-llstat
 lib_LIBRARIES = liblustreapi.a
 
 lctl_SOURCES = parser.c obd.c lustre_cfg.c lctl.c parser.h obdctl.h platform.h
-lctl_LDADD := $(LIBREADLINE) $(LIBPTLCTL)
-lctl_DEPENDENCIES := $(LIBPTLCTL)
+lctl_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
+lctl_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
 lfs_SOURCES = lfs.c parser.c lustre_cfg.c obd.c
 lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL)
 lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a 
 
 loadgen_SOURCES = loadgen.c lustre_cfg.c obd.c
-loadgen_LDADD := $(LIBREADLINE) $(LIBPTLCTL) $(PTHREAD_LIBS)
-loadgen_DEPENDENCIES := $(LIBPTLCTL)
-
-lshowmount_SOURCES = lshowmount.h lshowmount.c hash.c hash.h \
-			thread.c thread.h hostlist.c hostlist.h
+loadgen_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS)
+loadgen_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a
 
+lshowmount_SOURCES = lshowmount.c nidlist.c nidlist.h
 
 @EXT2FS_DEVEL_TRUE at EXT2FSLIB = -lext2fs
 @EXT2FS_DEVEL_FALSE at EXT2FSLIB = 
@@ -471,8 +469,7 @@ lr_reader_OBJECTS = $(am_lr_reader_OBJECTS)
 lr_reader_LDADD = $(LDADD)
 lr_reader_DEPENDENCIES =
 lr_reader_LDFLAGS =
-am_lshowmount_OBJECTS = lshowmount.$(OBJEXT) hash.$(OBJEXT) \
-	thread.$(OBJEXT) hostlist.$(OBJEXT)
+am_lshowmount_OBJECTS = lshowmount.$(OBJEXT) nidlist.$(OBJEXT)
 lshowmount_OBJECTS = $(am_lshowmount_OBJECTS)
 lshowmount_LDADD = $(LDADD)
 lshowmount_DEPENDENCIES =
@@ -520,8 +517,7 @@ SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS)
 DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
- at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/hash.Po ./$(DEPDIR)/hostlist.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/l_getgroups.Po ./$(DEPDIR)/lctl.Po \
+ at AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/l_getgroups.Po ./$(DEPDIR)/lctl.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/lfs.Po ./$(DEPDIR)/liblustreapi.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/ll_recover_lost_found_objs.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/llog_reader.Po ./$(DEPDIR)/llverdev.Po \
@@ -532,10 +528,10 @@ am__depfiles_maybe = depfiles
 @AMDEP_TRUE@	./$(DEPDIR)/mkfs_lustre-mkfs_lustre.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/mkfs_lustre-mount_utils.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/mount_lustre.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/mount_utils.Po ./$(DEPDIR)/obd.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/obdbarrier.Po ./$(DEPDIR)/obdio.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/obdiolib.Po ./$(DEPDIR)/parser.Po \
- at AMDEP_TRUE@	./$(DEPDIR)/thread.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/mount_utils.Po ./$(DEPDIR)/nidlist.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/obd.Po ./$(DEPDIR)/obdbarrier.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/obdio.Po ./$(DEPDIR)/obdiolib.Po \
+ at AMDEP_TRUE@	./$(DEPDIR)/parser.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/tunefs_lustre-mkfs_lustre.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/tunefs_lustre-mount_utils.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/wirecheck-wirecheck.Po \
@@ -776,8 +772,6 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/hash.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/hostlist.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/l_getgroups.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lctl.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/lfs.Po at am__quote@
@@ -795,12 +789,12 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mkfs_lustre-mount_utils.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mount_lustre.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mount_utils.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/nidlist.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/obd.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/obdbarrier.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/obdio.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/obdiolib.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/parser.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/thread.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tunefs_lustre-mkfs_lustre.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tunefs_lustre-mount_utils.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/wirecheck-wirecheck.Po at am__quote@
diff --git a/lustre/utils/hash.c b/lustre/utils/hash.c
deleted file mode 100644
index 0717176..0000000
--- a/lustre/utils/hash.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*****************************************************************************
- *  $Id: hash.c,v 1.1.2.1 2008/11/21 15:27:33 yangsheng Exp $
- *****************************************************************************
- *  Copyright (C) 2003-2005 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Chris Dunlap <cdunlap at llnl.gov>.
- *
- *  This file is from LSD-Tools, the LLNL Software Development Toolbox.
- *
- *  This is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This is distributed in the hope that it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License;
- *  if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
- *  Fifth Floor, Boston, MA  02110-1301  USA.
- *****************************************************************************
- *  Refer to "hash.h" for documentation on public functions.
- *****************************************************************************/
-
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "thread.h"
-#include "hash.h"
-
-
-/*****************************************************************************
- *  Constants
- *****************************************************************************/
-
-#define HASH_ALLOC      1024
-#define HASH_DEF_SIZE   1213
-#define HASH_MAGIC      0xDEADBEEF
-
-
-/*****************************************************************************
- *  Data Types
- *****************************************************************************/
-
-struct hash_node {
-    struct hash_node   *next;           /* next node in list                 */
-    void               *data;           /* ptr to hashed item                */
-    const void         *hkey;           /* ptr to hashed item's key          */
-};
-
-struct hash {
-    int                 count;          /* number of items in hash table     */
-    int                 size;           /* num slots allocated in hash table */
-    struct hash_node  **table;          /* hash table array of node ptrs     */
-    hash_cmp_f          cmp_f;          /* key comparison function           */
-    hash_del_f          del_f;          /* item deletion function            */
-    hash_key_f          key_f;          /* key hash function                 */
-#if WITH_PTHREADS
-    pthread_mutex_t     mutex;          /* mutex to protect access to hash   */
-#endif /* WITH_PTHREADS */
-#ifndef NDEBUG
-    unsigned int        magic;          /* sentinel for asserting validity   */
-#endif /* NDEBUG */
-};
-
-
-/*****************************************************************************
- *  Prototypes
- *****************************************************************************/
-
-static struct hash_node * hash_node_alloc (void);
-
-static void hash_node_free (struct hash_node *node);
-
-
-/*****************************************************************************
- *  Variables
- *****************************************************************************/
-
-#if 0
-static struct hash_node *hash_free_list = NULL;
-#endif
-
-#if WITH_PTHREADS
-static pthread_mutex_t hash_free_lock = PTHREAD_MUTEX_INITIALIZER;
-#endif /* WITH_PTHREADS */
-
-
-/*****************************************************************************
- *  Macros
- *****************************************************************************/
-
-#ifdef WITH_LSD_FATAL_ERROR_FUNC
-#  undef lsd_fatal_error
-   extern void lsd_fatal_error (char *file, int line, char *mesg);
-#else /* !WITH_LSD_FATAL_ERROR_FUNC */
-#  ifndef lsd_fatal_error
-#    define lsd_fatal_error(file, line, mesg) (abort ())
-#  endif /* !lsd_fatal_error */
-#endif /* !WITH_LSD_FATAL_ERROR_FUNC */
-
-#ifdef WITH_LSD_NOMEM_ERROR_FUNC
-#  undef lsd_nomem_error
-   extern void * lsd_nomem_error (char *file, int line, char *mesg);
-#else /* !WITH_LSD_NOMEM_ERROR_FUNC */
-#  ifndef lsd_nomem_error
-#    define lsd_nomem_error(file, line, mesg) (NULL)
-#  endif /* !lsd_nomem_error */
-#endif /* !WITH_LSD_NOMEM_ERROR_FUNC */
-
-
-/*****************************************************************************
- *  Functions
- *****************************************************************************/
-
-hash_t
-hash_create (int size, hash_key_f key_f, hash_cmp_f cmp_f, hash_del_f del_f)
-{
-    hash_t h;
-
-    if (!cmp_f || !key_f) {
-        errno = EINVAL;
-        return (NULL);
-    }
-    if (size <= 0) {
-        size = HASH_DEF_SIZE;
-    }
-    if (!(h = malloc (sizeof (*h)))) {
-        return (lsd_nomem_error (__FILE__, __LINE__, "hash_create"));
-    }
-    if (!(h->table = calloc (size, sizeof (struct hash_node *)))) {
-        free (h);
-        return (lsd_nomem_error (__FILE__, __LINE__, "hash_create"));
-    }
-    h->count = 0;
-    h->size = size;
-    h->cmp_f = cmp_f;
-    h->del_f = del_f;
-    h->key_f = key_f;
-    lsd_mutex_init (&h->mutex);
-    assert (h->magic = HASH_MAGIC);     /* set magic via assert abuse */
-    return (h);
-}
-
-
-void
-hash_destroy (hash_t h)
-{
-    int i;
-    struct hash_node *p, *q;
-
-    if (!h) {
-        errno = EINVAL;
-        return;
-    }
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    for (i = 0; i < h->size; i++) {
-        for (p = h->table[i]; p != NULL; p = q) {
-            q = p->next;
-            if (h->del_f)
-                h->del_f (p->data);
-            hash_node_free (p);
-        }
-    }
-    assert (h->magic = ~HASH_MAGIC);    /* clear magic via assert abuse */
-    lsd_mutex_unlock (&h->mutex);
-    lsd_mutex_destroy (&h->mutex);
-    free (h->table);
-    free (h);
-    return;
-}
-
-
-int
-hash_is_empty (hash_t h)
-{
-    int n;
-
-    if (!h) {
-        errno = EINVAL;
-        return (0);
-    }
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    n = h->count;
-    lsd_mutex_unlock (&h->mutex);
-    return (n == 0);
-}
-
-
-int
-hash_count (hash_t h)
-{
-    int n;
-
-    if (!h) {
-        errno = EINVAL;
-        return (0);
-    }
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    n = h->count;
-    lsd_mutex_unlock (&h->mutex);
-    return (n);
-}
-
-
-void *
-hash_find (hash_t h, const void *key)
-{
-    unsigned int slot;
-    struct hash_node *p;
-    void *data = NULL;
-
-    if (!h || !key) {
-        errno = EINVAL;
-        return (NULL);
-    }
-    errno = 0;
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    slot = h->key_f (key) % h->size;
-    for (p = h->table[slot]; p != NULL; p = p->next) {
-        if (!h->cmp_f (p->hkey, key)) {
-            data = p->data;
-            break;
-        }
-    }
-    lsd_mutex_unlock (&h->mutex);
-    return (data);
-}
-
-
-void *
-hash_insert (hash_t h, const void *key, void *data)
-{
-    struct hash_node *p;
-    unsigned int slot;
-
-    if (!h || !key || !data) {
-        errno = EINVAL;
-        return (NULL);
-    }
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    slot = h->key_f (key) % h->size;
-    for (p = h->table[slot]; p != NULL; p = p->next) {
-        if (!h->cmp_f (p->hkey, key)) {
-            errno = EEXIST;
-            data = NULL;
-            goto end;
-        }
-    }
-    if (!(p = hash_node_alloc ())) {
-        data = lsd_nomem_error (__FILE__, __LINE__, "hash_insert");
-        goto end;
-    }
-    p->hkey = key;
-    p->data = data;
-    p->next = h->table[slot];
-    h->table[slot] = p;
-    h->count++;
-
-end:
-    lsd_mutex_unlock (&h->mutex);
-    return (data);
-}
-
-
-void *
-hash_remove (hash_t h, const void *key)
-{
-    struct hash_node **pp;
-    struct hash_node *p;
-    unsigned int slot;
-    void *data = NULL;
-
-    if (!h || !key) {
-        errno = EINVAL;
-        return (NULL);
-    }
-    errno = 0;
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    slot = h->key_f (key) % h->size;
-    for (pp = &(h->table[slot]); (p = *pp) != NULL; pp = &((*pp)->next)) {
-        if (!h->cmp_f (p->hkey, key)) {
-            data = p->data;
-            *pp = p->next;
-            hash_node_free (p);
-            h->count--;
-            break;
-        }
-    }
-    lsd_mutex_unlock (&h->mutex);
-    return (data);
-}
-
-
-int
-hash_delete_if (hash_t h, hash_arg_f arg_f, void *arg)
-{
-    int i;
-    struct hash_node **pp;
-    struct hash_node *p;
-    int n = 0;
-
-    if (!h || !arg_f) {
-        errno = EINVAL;
-        return (-1);
-    }
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    for (i = 0; i < h->size; i++) {
-        pp = &(h->table[i]);
-        while ((p = *pp) != NULL) {
-            if (arg_f (p->data, p->hkey, arg) > 0) {
-                if (h->del_f)
-                    h->del_f (p->data);
-                *pp = p->next;
-                hash_node_free (p);
-                h->count--;
-                n++;
-            }
-            else {
-                pp = &(p->next);
-            }
-        }
-    }
-    lsd_mutex_unlock (&h->mutex);
-    return (n);
-}
-
-
-int
-hash_for_each (hash_t h, hash_arg_f arg_f, void *arg)
-{
-    int i;
-    struct hash_node *p;
-    int n = 0;
-
-    if (!h || !arg_f) {
-        errno = EINVAL;
-        return (-1);
-    }
-    lsd_mutex_lock (&h->mutex);
-    assert (h->magic == HASH_MAGIC);
-    for (i = 0; i < h->size; i++) {
-        for (p = h->table[i]; p != NULL; p = p->next) {
-            if (arg_f (p->data, p->hkey, arg) > 0) {
-                n++;
-            }
-        }
-    }
-    lsd_mutex_unlock (&h->mutex);
-    return (n);
-}
-
-
-/*****************************************************************************
- *  Hash Functions
- *****************************************************************************/
-
-unsigned int
-hash_key_string (const char *str)
-{
-    unsigned char *p;
-    unsigned int hval = 0;
-    const unsigned int multiplier = 31;
-
-    for (p = (unsigned char *) str; *p != '\0'; p++) {
-        hval += (multiplier * hval) + *p;
-    }
-    return (hval);
-}
-
-
-/*****************************************************************************
- *  Internal Functions
- *****************************************************************************/
-
-static struct hash_node *
-hash_node_alloc (void)
-{
-/*  Allocates a hash node from the freelist.
- *  Memory is allocated in chunks of HASH_ALLOC.
- *  Returns a ptr to the object, or NULL if memory allocation fails.
- */
-#if 0
-    int i;
-#endif
-    struct hash_node *p = NULL;
-
-    assert (HASH_ALLOC > 0);
-    lsd_mutex_lock (&hash_free_lock);
-#if 0
-    if (!hash_free_list) {
-        if ((hash_free_list = malloc (HASH_ALLOC * sizeof (*p)))) {
-            for (i = 0; i < HASH_ALLOC - 1; i++)
-                hash_free_list[i].next = &hash_free_list[i+1];
-            hash_free_list[i].next = NULL;
-        }
-    }
-    if (hash_free_list) {
-        p = hash_free_list;
-        hash_free_list = p->next;
-    }
-    else {
-        errno = ENOMEM;
-    }
-#else
-    if (!(p = malloc (sizeof(*p))))
-        errno = ENOMEM;
-#endif
-    lsd_mutex_unlock (&hash_free_lock);
-    return (p);
-}
-
-
-static void
-hash_node_free (struct hash_node *node)
-{
-/*  De-allocates the object [node], returning it to the freelist.
- */
-    assert (node != NULL);
-    memset (node, 0, sizeof (*node));
-    lsd_mutex_lock (&hash_free_lock);
-#if 0
-    node->next = hash_free_list;
-    hash_free_list = node;
-#else
-    free (node);
-#endif
-    lsd_mutex_unlock (&hash_free_lock);
-    return;
-}
diff --git a/lustre/utils/hash.h b/lustre/utils/hash.h
deleted file mode 100644
index 9926c4a..0000000
--- a/lustre/utils/hash.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*****************************************************************************
- *  $Id: hash.h,v 1.1.2.1 2008/11/21 15:27:33 yangsheng Exp $
- *****************************************************************************
- *  Copyright (C) 2003-2005 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Chris Dunlap <cdunlap at llnl.gov>.
- *
- *  This file is from LSD-Tools, the LLNL Software Development Toolbox.
- *
- *  This is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This is distributed in the hope that it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License;
- *  if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
- *  Fifth Floor, Boston, MA  02110-1301  USA.
- *****************************************************************************/
-
-
-#ifndef LSD_HASH_H
-#define LSD_HASH_H
-
-
-/*****************************************************************************
- *  Notes
- *****************************************************************************/
-/*
- *  If an item's key is modified after insertion, the hash will be unable to
- *  locate it if the new key should hash to a different slot in the table.
- *
- *  If NDEBUG is not defined, internal debug code will be enabled; this is
- *  intended for development use only.  Production code should define NDEBUG.
- *
- *  If WITH_LSD_FATAL_ERROR_FUNC is defined, the linker will expect to
- *  find an external lsd_fatal_error(file,line,mesg) function.  By default,
- *  lsd_fatal_error(file,line,mesg) is a macro definition that aborts.
- *  This macro may be redefined to invoke another routine instead.
- *
- *  If WITH_LSD_NOMEM_ERROR_FUNC is defined, the linker will expect to
- *  find an external lsd_nomem_error(file,line,mesg) function.  By default,
- *  lsd_nomem_error(file,line,mesg) is a macro definition that returns NULL.
- *  This macro may be redefined to invoke another routine instead.
- *
- *  If WITH_PTHREADS is defined, these routines will be thread-safe.
- */
-
-
-/*****************************************************************************
- *  Data Types
- *****************************************************************************/
-
-typedef struct hash * hash_t;
-/*
- *  Hash table opaque data type.
- */
-
-typedef unsigned int (*hash_key_f) (const void *key);
-/*
- *  Function prototype for the hash function responsible for converting
- *    the data's [key] into an unsigned integer hash value.
- */
-
-typedef int (*hash_cmp_f) (const void *key1, const void *key2);
-/*
- *  Function prototype for comparing two keys.
- *  Returns zero if both keys are equal; o/w, returns nonzero.
- */
-
-typedef void (*hash_del_f) (void *data);
-/*
- *  Function prototype for de-allocating a data item stored within a hash.
- *  This function is responsible for freeing all memory associated with
- *    the [data] item, including any subordinate items.
- */
-
-typedef int (*hash_arg_f) (void *data, const void *key, void *arg);
-/*
- *  Function prototype for operating on each element in the hash table.
- *  The function will be invoked once for each [data] item in the hash,
- *    with the item's [key] and the specified [arg] being passed in as args.
- */
-
-
-/*****************************************************************************
- *  Functions
- *****************************************************************************/
-
-hash_t hash_create (int size,
-    hash_key_f key_f, hash_cmp_f cmp_f, hash_del_f del_f);
-/*
- *  Creates and returns a new hash table on success.
- *    Returns lsd_nomem_error() with errno=ENOMEM if memory allocation fails.
- *    Returns NULL with errno=EINVAL if [keyf] or [cmpf] is not specified.
- *  The [size] is the number of slots in the table; a larger table requires
- *    more memory, but generally provide quicker access times.  If set <= 0,
- *    the default size is used.
- *  The [keyf] function converts a key into a hash value.
- *  The [cmpf] function determines whether two keys are equal.
- *  The [delf] function de-allocates memory used by items in the hash;
- *    if set to NULL, memory associated with these items will not be freed
- *    when the hash is destroyed.
- */
-
-void hash_destroy (hash_t h);
-/*
- *  Destroys hash table [h].  If a deletion function was specified when the
- *    hash was created, it will be called for each item contained within.
- *  Abadoning a hash without calling hash_destroy() will cause a memory leak.
- */
-
-int hash_is_empty (hash_t h);
-/*
- *  Returns non-zero if hash table [h] is empty; o/w, returns zero.
- */
-
-int hash_count (hash_t h);
-/*
- *  Returns the number of items in hash table [h].
- */
-
-void * hash_find (hash_t h, const void *key);
-/*
- *  Searches for the item corresponding to [key] in hash table [h].
- *  Returns a ptr to the found item's data on success.
- *    Returns NULL with errno=0 if no matching item is found.
- *    Returns NULL with errno=EINVAL if [key] is not specified.
- */
-
-void * hash_insert (hash_t h, const void *key, void *data);
-/*
- *  Inserts [data] with the corresponding [key] into hash table [h];
- *    note that it is permissible for [key] to be set equal to [data].
- *  Returns a ptr to the inserted item's data on success.
- *    Returns NULL with errno=EEXIST if [key] already exists in the hash.
- *    Returns NULL with errno=EINVAL if [key] or [data] is not specified.
- *    Returns lsd_nomem_error() with errno=ENOMEM if memory allocation fails.
- */
-
-void * hash_remove (hash_t h, const void *key);
-/*
- *  Removes the item corresponding to [key] from hash table [h].
- *  Returns a ptr to the removed item's data on success.
- *    Returns NULL with errno=0 if no matching item is found.
- *    Returns NULL with errno=EINVAL if [key] is not specified.
- */
-
-int hash_delete_if (hash_t h, hash_arg_f argf, void *arg);
-/*
- *  Conditionally deletes (and de-allocates) items from hash table [h].
- *  The [argf] function is invoked once for each item in the hash, with
- *    [arg] being passed in as an argument.  Items for which [argf] returns
- *    greater-than-zero are deleted.
- *  Returns the number of items deleted.
- *    Returns -1 with errno=EINVAL if [argf] is not specified.
- */
-
-int hash_for_each (hash_t h, hash_arg_f argf, void *arg);
-/*
- *  Invokes the [argf] function once for each item in hash table [h],
- *    with [arg] being passed in as an argument.
- *  Returns the number of items for which [argf] returns greater-than-zero.
- *    Returns -1 with errno=EINVAL if [argf] is not specified.
- */
-
-unsigned int hash_key_string (const char *str);
-/*
- *  A hash_key_f function that hashes the string [str].
- */
-
-
-#endif /* !LSD_HASH_H */
diff --git a/lustre/utils/hostlist.c b/lustre/utils/hostlist.c
deleted file mode 100644
index cbddfd2..0000000
--- a/lustre/utils/hostlist.c
+++ /dev/null
@@ -1,2687 +0,0 @@
-/*****************************************************************************\
- *  $Id: hostlist.c,v 1.1.2.1 2008/11/21 15:27:33 yangsheng Exp $
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona at llnl.gov>
- *  UCRL-CODE-2002-040.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#  if HAVE_STRING_H
-#    include <string.h>
-#  endif
-#  if HAVE_PTHREAD_H
-#    include <pthread.h>
-#  endif
-#else                /* !HAVE_CONFIG_H */
-#  include <string.h>
-#  include <pthread.h>
-#endif                /* HAVE_CONFIG_H */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <assert.h>
-#include <errno.h>
-#include <ctype.h>
-#include <sys/param.h>
-#include <unistd.h>
-
-#include "hostlist.h"
-
-/*
- * lsd_fatal_error : fatal error macro
- */
-#ifdef WITH_LSD_FATAL_ERROR_FUNC
-#  undef lsd_fatal_error
-   extern void lsd_fatal_error(char *file, int line, char *mesg);
-#else /* !WITH_LSD_FATAL_ERROR_FUNC */
-#  ifndef lsd_fatal_error
-#    define lsd_fatal_error(file, line, mesg)                                \
-       do {                                                                  \
-           fprintf(stderr, "ERROR: [%s:%d] %s: %s\n",                        \
-           file, line, mesg, strerror(errno));                               \
-       } while (0)
-#  endif /* !lsd_fatal_error */
-#endif /* !WITH_LSD_FATAL_ERROR_FUNC */
-
-/*
- * lsd_nonmem_error
- */
-#ifdef WITH_LSD_NOMEM_ERROR_FUNC
-#  undef lsd_nomem_error
-   extern void * lsd_nomem_error(char *file, int line, char *mesg);
-#else /* !WITH_LSD_NOMEM_ERROR_FUNC */
-#  ifndef lsd_nomem_error
-#    define lsd_nomem_error(file, line, mesg) (NULL)
-#  endif /* !lsd_nomem_error */
-#endif /* !WITH_LSD_NOMEM_ERROR_FUNC */
-
-/*
- * OOM helper function
- *  Automatically call lsd_nomem_error with appropriate args
- *  and set errno to ENOMEM
- */
-#define out_of_memory(mesg)                                                  \
-    do {                                                                     \
-        errno = ENOMEM;                                                      \
-        return(lsd_nomem_error(__FILE__, __LINE__, mesg));                   \
-    } while (0)
-
-/*
- * Some constants and tunables:
- */
-
-/* number of elements to allocate when extending the hostlist array */
-#define HOSTLIST_CHUNK    16
-
-/* max host range: anything larger will be assumed to be an error */
-#define MAX_RANGE    16384    /* 16K Hosts */
-
-/* max host suffix value */
-#define MAX_HOST_SUFFIX 1<<25
-
-/* max number of ranges that will be processed between brackets */
-#define MAX_RANGES    10240    /* 10K Ranges */
-
-/* size of internal hostname buffer (+ some slop), hostnames will probably
- * be truncated if longer than MAXHOSTNAMELEN */
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN    64
-#endif
-
-/* max size of internal hostrange buffer */
-#define MAXHOSTRANGELEN 1024
-
-/* ----[ Internal Data Structures ]---- */
-
-/* hostname type: A convenience structure used in parsing single hostnames */
-struct hostname_components {
-    char *hostname;         /* cache of initialized hostname        */
-    char *prefix;           /* hostname prefix                      */
-    unsigned long num;      /* numeric suffix                       */
-
-    /* string representation of numeric suffix
-     * points into `hostname'                                       */
-    char *suffix;
-};
-
-typedef struct hostname_components *hostname_t;
-
-/* hostrange type: A single prefix with `hi' and `lo' numeric suffix values */
-struct hostrange_components {
-    char *prefix;        /* alphanumeric prefix: */
-
-    /* beginning (lo) and end (hi) of suffix range */
-    unsigned long lo, hi;
-
-    /* width of numeric output format
-     * (pad with zeros up to this width) */
-    int width;
-
-    /* If singlehost is 1, `lo' and `hi' are invalid */
-    unsigned singlehost:1;
-};
-
-typedef struct hostrange_components *hostrange_t;
-
-/* The hostlist type: An array based list of hostrange_t's */
-struct hostlist {
-#ifndef NDEBUG
-#define HOSTLIST_MAGIC    57005
-    int magic;
-#endif
-#if    WITH_PTHREADS
-    pthread_mutex_t mutex;
-#endif                /* WITH_PTHREADS */
-
-    /* current number of elements available in array */
-    int size;
-
-    /* current number of ranges stored in array */
-    int nranges;
-
-    /* current number of hosts stored in hostlist */
-    int nhosts;
-
-    /* pointer to hostrange array */
-    hostrange_t *hr;
-
-    /* list of iterators */
-    struct hostlist_iterator *ilist;
-
-};
-
-
-/* a hostset is a wrapper around a hostlist */
-struct hostset {
-    hostlist_t hl;
-};
-
-struct hostlist_iterator {
-#ifndef NDEBUG
-    int magic;
-#endif
-    /* hostlist we are traversing */
-    hostlist_t hl;
-
-    /* current index of iterator in hl->hr[] */
-    int idx;
-
-    /* current hostrange object in list hl, i.e. hl->hr[idx] */
-    hostrange_t hr;
-
-    /* current depth we've traversed into range hr */
-    int depth;
-
-    /* next ptr for lists of iterators */
-    struct hostlist_iterator *next;
-};
-
-
-/* ---- ---- */
-
-/* ------[ static function prototypes ]------ */
-
-static void _error(char *file, int line, char *mesg, ...);
-static char * _next_tok(char *, char **);
-static int    _zero_padded(unsigned long, int);
-static int    _width_equiv(unsigned long, int *, unsigned long, int *);
-
-static int           host_prefix_end(const char *);
-static hostname_t    hostname_create(const char *);
-static void          hostname_destroy(hostname_t);
-static int           hostname_suffix_is_valid(hostname_t);
-static int           hostname_suffix_width(hostname_t);
-
-static hostrange_t   hostrange_new(void);
-static hostrange_t   hostrange_create_single(const char *);
-static hostrange_t   hostrange_create(char *, unsigned long, unsigned long, int);
-static unsigned long hostrange_count(hostrange_t);
-static hostrange_t   hostrange_copy(hostrange_t);
-static void          hostrange_destroy(hostrange_t);
-static hostrange_t   hostrange_delete_host(hostrange_t, unsigned long);
-static int           hostrange_cmp(hostrange_t, hostrange_t);
-static int           hostrange_prefix_cmp(hostrange_t, hostrange_t);
-static int           hostrange_within_range(hostrange_t, hostrange_t);
-static int           hostrange_width_combine(hostrange_t, hostrange_t);
-static int           hostrange_empty(hostrange_t);
-static char *        hostrange_pop(hostrange_t);
-static char *        hostrange_shift(hostrange_t);
-static int           hostrange_join(hostrange_t, hostrange_t);
-static hostrange_t   hostrange_intersect(hostrange_t, hostrange_t);
-static int           hostrange_hn_within(hostrange_t, hostname_t);
-static size_t        hostrange_to_string(hostrange_t hr, size_t, char *, char *);
-static size_t        hostrange_numstr(hostrange_t, size_t, char *);
-
-static hostlist_t  hostlist_new(void);
-static hostlist_t _hostlist_create_bracketed(const char *, char *, char *);
-static int         hostlist_resize(hostlist_t, size_t);
-static int         hostlist_expand(hostlist_t);
-static int         hostlist_push_range(hostlist_t, hostrange_t);
-static int         hostlist_push_hr(hostlist_t, char *, unsigned long,
-                                    unsigned long, int);
-static int         hostlist_insert_range(hostlist_t, hostrange_t, int);
-static void        hostlist_delete_range(hostlist_t, int n);
-static void        hostlist_coalesce(hostlist_t hl);
-static void        hostlist_collapse(hostlist_t hl);
-static hostlist_t _hostlist_create(const char *, char *, char *);
-static void        hostlist_shift_iterators(hostlist_t, int, int, int);
-static int        _attempt_range_join(hostlist_t, int);
-static int        _is_bracket_needed(hostlist_t, int);
-
-static hostlist_iterator_t hostlist_iterator_new(void);
-static void               _iterator_advance(hostlist_iterator_t);
-static void               _iterator_advance_range(hostlist_iterator_t);
-
-static int hostset_find_host(hostset_t, const char *);
-
-/* ------[ macros ]------ */
-
-#ifdef WITH_PTHREADS
-#  define mutex_init(mutex)                                                  \
-     do {                                                                    \
-        int e = pthread_mutex_init(mutex, NULL);                             \
-        if (e) {                                                             \
-            errno = e;                                                       \
-            lsd_fatal_error(__FILE__, __LINE__, "hostlist mutex init:");     \
-            abort();                                                         \
-        }                                                                    \
-     } while (0)
-
-#  define mutex_lock(mutex)                                                  \
-     do {                                                                    \
-        int e = pthread_mutex_lock(mutex);                                   \
-        if (e) {                                                             \
-           errno = e;                                                        \
-           lsd_fatal_error(__FILE__, __LINE__, "hostlist mutex lock:");      \
-           abort();                                                          \
-        }                                                                    \
-     } while (0)
-
-#  define mutex_unlock(mutex)                                                \
-     do {                                                                    \
-        int e = pthread_mutex_unlock(mutex);                                 \
-        if (e) {                                                             \
-            errno = e;                                                       \
-            lsd_fatal_error(__FILE__, __LINE__, "hostlist mutex unlock:");   \
-            abort();                                                         \
-        }                                                                    \
-     } while (0)
-
-#  define mutex_destroy(mutex)                                               \
-     do {                                                                    \
-        int e = pthread_mutex_destroy(mutex);                                \
-        if (e) {                                                             \
-            errno = e;                                                       \
-            lsd_fatal_error(__FILE__, __LINE__, "hostlist mutex destroy:");  \
-            abort();                                                         \
-        }                                                                    \
-     } while (0)
-
-#else                /* !WITH_PTHREADS */
-
-#  define mutex_init(mutex)
-#  define mutex_lock(mutex)
-#  define mutex_unlock(mutex)
-#  define mutex_destroy(mutex)
-
-#endif                /* WITH_PTHREADS */
-
-#define LOCK_HOSTLIST(_hl)                                                   \
-      do {                                                                   \
-          assert(_hl != NULL);                                               \
-          mutex_lock(&(_hl)->mutex);                                         \
-          assert((_hl)->magic == HOSTLIST_MAGIC);                            \
-      } while (0)
-
-#define UNLOCK_HOSTLIST(_hl)                                                 \
-      do {                                                                   \
-          mutex_unlock(&(_hl)->mutex);                                       \
-      } while (0)
-
-#define seterrno_ret(_errno, _rc)                                            \
-      do {                                                                   \
-          errno = _errno;                                                    \
-          return _rc;                                                        \
-      } while (0)
-
-/* ------[ Function Definitions ]------ */
-
-/* ----[ general utility functions ]---- */
-
-
-/*
- *  Varargs capable error reporting via lsd_fatal_error()
- */
-static void _error(char *file, int line, char *msg, ...)
-{
-    va_list ap;
-    char    buf[1024];
-    int     len = 0;
-    va_start(ap, msg);
-
-    len = vsnprintf(buf, 1024, msg, ap);
-    if ((len < 0) || (len > 1024))
-        buf[1023] = '\0';
-
-    lsd_fatal_error(file, line, buf);
-
-    va_end(ap);
-    return;
-}
-
-static int _advance_past_brackets (char *tok, char **str)
-{
-    /* if _single_ opening bracket exists b/w tok and str, push str
-     * past first closing bracket to next seperator */
-    if (   memchr(tok, '[', *str - tok) != NULL
-        && memchr(tok, ']', *str - tok) == NULL ) {
-        char *q = strchr(*str, ']');
-        if (q && memchr(*str, '[', q - *str) == NULL) {
-            *str = q + 1;
-            return (1);
-        }
-    }
-
-    return 0;
-}
-
-/*
- * Helper function for host list string parsing routines
- * Returns a pointer to the next token; additionally advance *str
- * to the next separator.
- *
- * next_tok was taken directly from pdsh courtesy of Jim Garlick.
- * (with modifications to support bracketed hostlists, i.e.:
- *  xxx[xx,xx,xx] is a single token)
- *
- */
-static char * _next_tok(char *sep, char **str)
-{
-    char *tok;
-
-    /* push str past any leading separators */
-    while (**str != '\0' && strchr(sep, **str) != '\0')
-        (*str)++;
-
-    if (**str == '\0')
-        return NULL;
-
-    /* assign token ptr */
-    tok = *str;
-
-    /*
-     * Advance str past any separators, but if a separator occurs between
-     *  brackets, e.g. foo[0-3,5], then advance str past closing brackets and
-     *  try again.
-     */
-    do {
-        /* push str past token and leave pointing to first separator */
-        while (**str != '\0' && strchr(sep, **str) == '\0')
-            (*str)++;
-    } while (_advance_past_brackets (tok, str));
-
-   /* nullify consecutive separators and push str beyond them */
-    while (**str != '\0' && strchr(sep, **str) != '\0')
-        *(*str)++ = '\0';
-
-    return tok;
-}
-
-
-/* return the number of zeros needed to pad "num" to "width"
- */
-static int _zero_padded(unsigned long num, int width)
-{
-    int n = 1;
-    while (num /= 10L)
-        n++;
-    return width > n ? width - n : 0;
-}
-
-/* test whether two format `width' parameters are "equivalent"
- * The width arguments "wn" and "wm" for integers "n" and "m"
- * are equivalent if:
- *
- *  o  wn == wm  OR
- *
- *  o  applying the same format width (either wn or wm) to both of
- *     'n' and 'm' will not change the zero padding of *either* 'm' nor 'n'.
- *
- *  If this function returns 1 (or true), the appropriate width value
- *  (either 'wm' or 'wn') will have been adjusted such that both format
- *  widths are equivalent.
- */
-static int _width_equiv(unsigned long n, int *wn, unsigned long m, int *wm)
-{
-    int npad, nmpad, mpad, mnpad;
-
-    if (wn == wm)
-        return 1;
-
-    npad = _zero_padded(n, *wn);
-    nmpad = _zero_padded(n, *wm);
-    mpad = _zero_padded(m, *wm);
-    mnpad = _zero_padded(m, *wn);
-
-    if (npad != nmpad && mpad != mnpad)
-        return 0;
-
-    if (npad != nmpad) {
-        if (mpad == mnpad) {
-            *wm = *wn;
-            return 1;
-        } else
-            return 0;
-    } else {        /* mpad != mnpad */
-        if (npad == nmpad) {
-            *wn = *wm;
-            return 1;
-        } else
-            return 0;
-    }
-
-    /* not reached */
-}
-
-
-/* ----[ hostname_t functions ]---- */
-
-/*
- * return the location of the last char in the hostname prefix
- */
-static int host_prefix_end(const char *hostname)
-{
-    int idx = strlen(hostname) - 1;
-
-    while (idx >= 0 && isdigit((char) hostname[idx]))
-        idx--;
-    return idx;
-}
-
-/*
- * create a hostname_t object from a string hostname
- */
-static hostname_t hostname_create(const char *hostname)
-{
-    hostname_t hn = NULL;
-    char *p = '\0';
-    int idx = 0;
-
-    assert(hostname != NULL);
-
-    if (!(hn = (hostname_t) malloc(sizeof(*hn))))
-        out_of_memory("hostname create");
-
-    idx = host_prefix_end(hostname);
-
-    if (!(hn->hostname = strdup(hostname))) {
-        free(hn);
-        out_of_memory("hostname create");
-    }
-
-    hn->num = 0;
-    hn->prefix = NULL;
-    hn->suffix = NULL;
-
-    if (idx == strlen(hostname) - 1) {
-        if ((hn->prefix = strdup(hostname)) == NULL) {
-            hostname_destroy(hn);
-            out_of_memory("hostname prefix create");
-        }
-        return hn;
-    }
-
-    hn->suffix = hn->hostname + idx + 1;
-    hn->num = strtoul(hn->suffix, &p, 10);
-
-    if ((*p == '\0') && (hn->num <= MAX_HOST_SUFFIX)) {
-        if (!(hn->prefix = malloc((idx + 2) * sizeof(char)))) {
-            hostname_destroy(hn);
-            out_of_memory("hostname prefix create");
-        }
-        memcpy(hn->prefix, hostname, idx + 1);
-        hn->prefix[idx + 1] = '\0';
-    } else {
-        if (!(hn->prefix = strdup(hostname))) {
-            hostname_destroy(hn);
-            out_of_memory("hostname prefix create");
-        }
-        hn->suffix = NULL;
-    }
-
-    return hn;
-}
-
-/* free a hostname object
- */
-static void hostname_destroy(hostname_t hn)
-{
-    if (hn == NULL)
-        return;
-    hn->suffix = NULL;
-    if (hn->hostname)
-        free(hn->hostname);
-    if (hn->prefix)
-        free(hn->prefix);
-    free(hn);
-}
-
-/* return true if the hostname has a valid numeric suffix
- */
-static int hostname_suffix_is_valid(hostname_t hn)
-{
-    return hn->suffix != NULL;
-}
-
-/* return the width (in characters) of the numeric part of the hostname
- */
-static int hostname_suffix_width(hostname_t hn)
-{
-    assert(hn->suffix != NULL);
-    return (int) strlen(hn->suffix);
-}
-
-
-/* ----[ hostrange_t functions ]---- */
-
-/* allocate a new hostrange object
- */
-static hostrange_t hostrange_new(void)
-{
-    hostrange_t new = (hostrange_t) malloc(sizeof(*new));
-    if (!new)
-        out_of_memory("hostrange create");
-    return new;
-}
-
-/* Create a hostrange_t containing a single host without a valid suffix
- * hr->prefix will represent the entire hostname.
- */
-static hostrange_t hostrange_create_single(const char *prefix)
-{
-    hostrange_t new;
-
-    assert(prefix != NULL);
-
-    if ((new = hostrange_new()) == NULL)
-        goto error1;
-
-    if ((new->prefix = strdup(prefix)) == NULL)
-        goto error2;
-
-    new->singlehost = 1;
-    new->lo = 0L;
-    new->hi = 0L;
-    new->width = 0;
-
-    return new;
-
-  error2:
-    free(new);
-  error1:
-    out_of_memory("hostrange create single");
-}
-
-
-/* Create a hostrange object with a prefix, hi, lo, and format width
- */
-static hostrange_t
-hostrange_create(char *prefix, unsigned long lo, unsigned long hi, int width)
-{
-    hostrange_t new;
-
-    assert(prefix != NULL);
-
-    if ((new = hostrange_new()) == NULL)
-        goto error1;
-
-    if ((new->prefix = strdup(prefix)) == NULL)
-        goto error2;
-
-    new->lo = lo;
-    new->hi = hi;
-    new->width = width;
-
-    new->singlehost = 0;
-
-    return new;
-
-  error2:
-    free(new);
-  error1:
-    out_of_memory("hostrange create");
-}
-
-
-/* Return the number of hosts stored in the hostrange object
- */
-static unsigned long hostrange_count(hostrange_t hr)
-{
-    assert(hr != NULL);
-    if (hr->singlehost)
-        return 1;
-    else
-        return hr->hi - hr->lo + 1;
-}
-
-/* Copy a hostrange object
- */
-static hostrange_t hostrange_copy(hostrange_t hr)
-{
-    assert(hr != NULL);
-
-    if (hr->singlehost)
-        return hostrange_create_single(hr->prefix);
-    else
-        return hostrange_create(hr->prefix, hr->lo, hr->hi,
-                    hr->width);
-}
-
-
-/* free memory allocated by the hostrange object
- */
-static void hostrange_destroy(hostrange_t hr)
-{
-    if (hr == NULL)
-        return;
-    if (hr->prefix)
-        free(hr->prefix);
-    free(hr);
-}
-
-/* hostrange_delete_host() deletes a specific host from the range.
- * If the range is split into two, the greater range is returned,
- * and `hi' of the lesser range is adjusted accordingly. If the
- * highest or lowest host is deleted from a range, NULL is returned
- * and the hostrange hr is adjusted properly.
- */
-static hostrange_t hostrange_delete_host(hostrange_t hr, unsigned long n)
-{
-    hostrange_t new = NULL;
-
-    assert(hr != NULL);
-    assert(n >= hr->lo && n <= hr->hi);
-
-    if (n == hr->lo)
-        hr->lo++;
-    else if (n == hr->hi)
-        hr->hi--;
-    else {
-        if (!(new = hostrange_copy(hr)))
-            out_of_memory("hostrange copy");
-        hr->hi = n - 1;
-        new->lo = n + 1;
-    }
-
-    return new;
-}
-
-/* hostrange_cmp() is used to sort hostrange objects. It will
- * sort based on the following (in order):
- *  o result of strcmp on prefixes
- *  o if widths are compatible, then:
- *       sort based on lowest suffix in range
- *    else
- *       sort based on width                     */
-static int hostrange_cmp(hostrange_t h1, hostrange_t h2)
-{
-    int retval;
-
-    assert(h1 != NULL);
-    assert(h2 != NULL);
-
-    if ((retval = hostrange_prefix_cmp(h1, h2)) == 0)
-        retval = hostrange_width_combine(h1, h2) ?
-            h1->lo - h2->lo : h1->width - h2->width;
-
-    return retval;
-}
-
-
-/* compare the prefixes of two hostrange objects.
- * returns:
- *    < 0   if h1 prefix is less than h2 OR h1 == NULL.
- *
- *      0   if h1's prefix and h2's prefix match,
- *          UNLESS, either h1 or h2 (NOT both) do not have a valid suffix.
- *
- *    > 0   if h1's prefix is greater than h2's OR h2 == NULL. */
-static int hostrange_prefix_cmp(hostrange_t h1, hostrange_t h2)
-{
-    int retval;
-    if (h1 == NULL)
-        return 1;
-    if (h2 == NULL)
-        return -1;
-
-    retval = strcmp(h1->prefix, h2->prefix);
-    return retval == 0 ? h2->singlehost - h1->singlehost : retval;
-}
-
-/* returns true if h1 and h2 would be included in the same bracketed hostlist.
- * h1 and h2 will be in the same bracketed list iff:
- *
- *  1. h1 and h2 have same prefix
- *  2. neither h1 nor h2 are singlet hosts (i.e. invalid suffix)
- *
- *  (XXX: Should incompatible widths be placed in the same bracketed list?
- *        There's no good reason not to, except maybe aesthetics)
- */
-static int hostrange_within_range(hostrange_t h1, hostrange_t h2)
-{
-    if (hostrange_prefix_cmp(h1, h2) == 0)
-        return h1->singlehost || h2->singlehost ? 0 : 1;
-    else
-        return 0;
-}
-
-
-/* compare two hostrange objects to determine if they are width
- * compatible,  returns:
- *  1 if widths can safely be combined
- *  0 if widths cannot be safely combined
- */
-static int hostrange_width_combine(hostrange_t h0, hostrange_t h1)
-{
-    assert(h0 != NULL);
-    assert(h1 != NULL);
-
-    return _width_equiv(h0->lo, &h0->width, h1->lo, &h1->width);
-}
-
-
-/* Return true if hostrange hr contains no hosts, i.e. hi < lo
- */
-static int hostrange_empty(hostrange_t hr)
-{
-    assert(hr != NULL);
-    return ((hr->hi < hr->lo) || (hr->hi == (unsigned long) -1));
-}
-
-/* return the string representation of the last host in hostrange hr
- * and remove that host from the range (i.e. decrement hi if possible)
- *
- * Returns NULL if malloc fails OR there are no more hosts left
- */
-static char *hostrange_pop(hostrange_t hr)
-{
-    size_t size = 0;
-    char *host = NULL;
-
-    assert(hr != NULL);
-
-    if (hr->singlehost) {
-        hr->lo++;    /* effectively set count == 0 */
-        host = strdup(hr->prefix);
-    } else if (hostrange_count(hr) > 0) {
-        size = strlen(hr->prefix) + hr->width + 16;
-        if (!(host = (char *) malloc(size * sizeof(char))))
-            out_of_memory("hostrange pop");
-        snprintf(host, size, "%s%0*lu", hr->prefix,
-             hr->width, hr->hi--);
-    }
-
-    return host;
-}
-
-/* Same as hostrange_pop(), but remove host from start of range */
-static char *hostrange_shift(hostrange_t hr)
-{
-    size_t size = 0;
-    char *host = NULL;
-
-    assert(hr != NULL);
-
-    if (hr->singlehost) {
-        hr->lo++;
-        if (!(host = strdup(hr->prefix)))
-            out_of_memory("hostrange shift");
-    } else if (hostrange_count(hr) > 0) {
-        size = strlen(hr->prefix) + hr->width + 16;
-        if (!(host = (char *) malloc(size * sizeof(char))))
-            out_of_memory("hostrange shift");
-        snprintf(host, size, "%s%0*lu", hr->prefix,
-             hr->width, hr->lo++);
-    }
-
-    return host;
-}
-
-
-/* join two hostrange objects.
- *
- * returns:
- *
- * -1 if ranges do not overlap (including incompatible zero padding)
- *  0 if ranges join perfectly
- * >0 number of hosts that were duplicated in  h1 and h2
- *
- * h2 will be coalesced into h1 if rc >= 0
- *
- * it is assumed that h1->lo <= h2->lo, i.e. hr1 <= hr2
- *
- */
-static int hostrange_join(hostrange_t h1, hostrange_t h2)
-{
-    int duplicated = -1;
-
-    assert(h1 != NULL);
-    assert(h2 != NULL);
-    assert(hostrange_cmp(h1, h2) <= 0);
-
-    if (hostrange_prefix_cmp(h1, h2) == 0 &&
-        hostrange_width_combine(h1, h2)) {
-
-        if (h1->singlehost && h2->singlehost) {    /* matching singlets  */
-            duplicated = 1;
-        } else if (h1->hi == h2->lo - 1) {    /* perfect join       */
-            h1->hi = h2->hi;
-            duplicated = 0;
-        } else if (h1->hi >= h2->lo) {    /* some duplication   */
-            if (h1->hi < h2->hi) {
-                duplicated = h1->hi - h2->lo + 1;
-                h1->hi = h2->hi;
-            } else
-                duplicated = hostrange_count(h2);
-        }
-    }
-
-    return duplicated;
-}
-
-/* hostrange intersect returns the intersection (common hosts)
- * of hostrange objects h1 and h2. If there is no intersection,
- * NULL is returned.
- *
- * It is assumed that h1 <= h2 (i.e. h1->lo <= h2->lo)
- */
-static hostrange_t hostrange_intersect(hostrange_t h1, hostrange_t h2)
-{
-    hostrange_t new = NULL;
-
-    assert(h1 != NULL);
-    assert(h2 != NULL);
-
-    if (h1->singlehost || h2->singlehost)
-        return NULL;
-
-    assert(hostrange_cmp(h1, h2) <= 0);
-
-    if ((hostrange_prefix_cmp(h1, h2) == 0)
-        && (h1->hi > h2->lo)
-        && (hostrange_width_combine(h1, h2))) {
-
-        if (!(new = hostrange_copy(h1)))
-            return NULL;
-        new->lo = h2->lo;
-        new->hi = h2->hi < h1->hi ? h2->hi : h1->hi;
-    }
-
-    return new;
-}
-
-/* return 1 if hostname hn is within the hostrange hr
- *        0 if not.
- */
-static int hostrange_hn_within(hostrange_t hr, hostname_t hn)
-{
-    int retval = 0;
-
-    if (hr->singlehost && (strcmp(hn->hostname, hr->prefix) == 0))
-        return 1;
-
-    if (strcmp(hr->prefix, hn->prefix) == 0) {
-        if (!hostname_suffix_is_valid(hn)) {
-            if (hr->singlehost)
-                retval = 1;
-        } else if (hn->num <= hr->hi && hn->num >= hr->lo) {
-            int width = hostname_suffix_width(hn);
-            int num = hn->num;
-            retval = _width_equiv(hr->lo, &hr->width, num, &width);
-        }
-    }
-    return retval;
-}
-
-
-/* copy a string representation of the hostrange hr into buffer buf,
- * writing at most n chars including NUL termination
- */
-static size_t
-hostrange_to_string(hostrange_t hr, size_t n, char *buf, char *separator)
-{
-    unsigned long i;
-    int truncated = 0;
-    int len = 0;
-    char sep = separator == NULL ? ',' : separator[0];
-
-    if (n == 0)
-        return 0;
-
-    if (hr->singlehost)
-        return snprintf(buf, n, "%s", hr->prefix);
-
-    for (i = hr->lo; i <= hr->hi; i++) {
-        size_t m = (n - len) <= n ? n - len : 0; /* check for < 0 */
-        int ret = snprintf(buf + len, m, "%s%0*lu",
-                   hr->prefix, hr->width, i);
-        if (ret < 0 || ret >= m) {
-            len = n;
-            truncated = 1;
-            break;
-        }
-        len+=ret;
-        buf[len++] = sep;
-    }
-
-    if (truncated) {
-        buf[n-1] = '\0';
-        return -1;
-    } else {
-        /* back up over final separator */
-        buf[--len] = '\0';
-        return len;
-    }
-}
-
-/* Place the string representation of the numeric part of hostrange into buf
- * writing at most n chars including NUL termination.
- */
-static size_t hostrange_numstr(hostrange_t hr, size_t n, char *buf)
-{
-    int len = 0;
-
-    assert(buf != NULL);
-
-    if (hr->singlehost || n == 0)
-        return 0;
-
-    len = snprintf(buf, n, "%0*lu", hr->width, hr->lo);
-
-    if ((len >= 0) && (len < n) && (hr->lo < hr->hi)) {
-        int len2 = snprintf(buf+len, n-len, "-%0*lu", hr->width, hr->hi);
-        if (len2 < 0)
-            len = -1;
-        else
-            len += len2;
-    }
-
-    return len;
-}
-
-
-/* ----[ hostlist functions ]---- */
-
-/* Create a new hostlist object.
- * Returns an empty hostlist, or NULL if memory allocation fails.
- */
-static hostlist_t hostlist_new(void)
-{
-    int i;
-    hostlist_t new = (hostlist_t) malloc(sizeof(*new));
-    if (!new)
-        goto fail1;
-
-    assert(new->magic = HOSTLIST_MAGIC);
-    mutex_init(&new->mutex);
-
-    new->hr = (hostrange_t *) malloc(HOSTLIST_CHUNK * sizeof(hostrange_t));
-    if (!new->hr)
-        goto fail2;
-
-    /* set entries in hostrange array to NULL */
-    for (i = 0; i < HOSTLIST_CHUNK; i++)
-        new->hr[i] = NULL;
-
-    new->size = HOSTLIST_CHUNK;
-    new->nranges = 0;
-    new->nhosts = 0;
-    new->ilist = NULL;
-    return new;
-
-  fail2:
-    free(new);
-  fail1:
-    out_of_memory("hostlist_create");
-}
-
-
-/* Resize the internal array used to store the list of hostrange objects.
- *
- * returns 1 for a successful resize,
- *         0 if call to _realloc fails
- *
- * It is assumed that the caller has the hostlist hl locked
- */
-static int hostlist_resize(hostlist_t hl, size_t newsize)
-{
-    int i;
-    size_t oldsize;
-    assert(hl != NULL);
-    assert(hl->magic == HOSTLIST_MAGIC);
-    oldsize = hl->size;
-    hl->size = newsize;
-    hl->hr = realloc((void *) hl->hr, hl->size*sizeof(hostrange_t));
-    if (!(hl->hr))
-        return 0;
-
-    for (i = oldsize; i < newsize; i++)
-        hl->hr[i] = NULL;
-
-    return 1;
-}
-
-/* Resize hostlist by one HOSTLIST_CHUNK
- * Assumes that hostlist hl is locked by caller
- */
-static int hostlist_expand(hostlist_t hl)
-{
-    if (!hostlist_resize(hl, hl->size + HOSTLIST_CHUNK))
-        return 0;
-    else
-        return 1;
-}
-
-/* Push a hostrange object onto hostlist hl
- * Returns the number of hosts successfully pushed onto hl
- * or -1 if there was an error allocating memory
- */
-static int hostlist_push_range(hostlist_t hl, hostrange_t hr)
-{
-    hostrange_t tail;
-    int retval;
-
-    assert(hr != NULL);
-    LOCK_HOSTLIST(hl);
-
-    tail = (hl->nranges > 0) ? hl->hr[hl->nranges-1] : hl->hr[0];
-
-    if (hl->size == hl->nranges && !hostlist_expand(hl))
-        goto error;
-
-    if (hl->nranges > 0
-        && hostrange_prefix_cmp(tail, hr) == 0
-        && tail->hi == hr->lo - 1
-        && hostrange_width_combine(tail, hr)) {
-        tail->hi = hr->hi;
-    } else {
-        if ((hl->hr[hl->nranges++] = hostrange_copy(hr)) == NULL)
-            goto error;
-    }
-
-    retval = hl->nhosts += hostrange_count(hr);
-
-    UNLOCK_HOSTLIST(hl);
-
-    return retval;
-
-  error:
-    UNLOCK_HOSTLIST(hl);
-    return -1;
-}
-
-
-
-/* Same as hostlist_push_range() above, but prefix, lo, hi, and width
- * are passed as args
- */
-static int
-hostlist_push_hr(hostlist_t hl, char *prefix, unsigned long lo,
-         unsigned long hi, int width)
-{
-    hostrange_t hr = hostrange_create(prefix, lo, hi, width);
-    int retval = hostlist_push_range(hl, hr);
-    hostrange_destroy(hr);
-    return retval;
-}
-
-/* Insert a range object hr into position n of the hostlist hl
- * Assumes that hl->mutex is already held by calling process
- */
-static int hostlist_insert_range(hostlist_t hl, hostrange_t hr, int n)
-{
-    int i;
-    hostrange_t tmp;
-    hostlist_iterator_t hli;
-
-    assert(hl != NULL);
-    assert(hl->magic == HOSTLIST_MAGIC);
-    assert(hr != NULL);
-
-    if (n > hl->nranges)
-        return 0;
-
-    if (hl->size == hl->nranges && !hostlist_expand(hl))
-        return 0;
-
-    /* copy new hostrange into slot "n" in array */
-    tmp = hl->hr[n];
-    hl->hr[n] = hostrange_copy(hr);
-
-    /* push remaining hostrange entries up */
-    for (i = n + 1; i < hl->nranges + 1; i++) {
-        hostrange_t last = hl->hr[i];
-        hl->hr[i] = tmp;
-        tmp = last;
-    }
-    hl->nranges++;
-
-    /* adjust hostlist iterators if needed */
-    for (hli = hl->ilist; hli; hli = hli->next) {
-        if (hli->idx >= n)
-            hli->hr = hli->hl->hr[++hli->idx];
-    }
-
-    return 1;
-}
-
-/* Delete the range at position n in the range array
- * Assumes the hostlist lock is already held.
- */
-static void hostlist_delete_range(hostlist_t hl, int n)
-{
-    int i;
-    hostrange_t old;
-
-    assert(hl != NULL);
-    assert(hl->magic == HOSTLIST_MAGIC);
-    assert(n < hl->nranges && n >= 0);
-
-    old = hl->hr[n];
-    for (i = n; i < hl->nranges - 1; i++)
-        hl->hr[i] = hl->hr[i + 1];
-    hl->nranges--;
-    hl->hr[hl->nranges] = NULL;
-    hostlist_shift_iterators(hl, n, 0, 1);
-
-    /* XXX caller responsible for adjusting nhosts */
-    /* hl->nhosts -= hostrange_count(old) */
-
-    hostrange_destroy(old);
-}
-
-#if WANT_RECKLESS_HOSTRANGE_EXPANSION
-
-/* The reckless hostrange expansion function.
- * See comment in hostlist.h:hostlist_create() for more info on
- * the different choices for hostlist notation.
- */
-hostlist_t _hostlist_create(const char *hostlist, char *sep, char *r_op)
-{
-    char *str, *orig;
-    char *tok, *cur;
-    int high, low, fmt = 0;
-    char prefix[256] = "";
-    int pos = 0;
-    int error = 0;
-    char range_op = r_op[0];/* XXX support > 1 char range ops in future? */
-
-    hostlist_t new = hostlist_new();
-
-    orig = str = strdup(hostlist);
-
-    /* return an empty list if an empty string was passed in */
-    if (str == NULL || strlen(str) == 0)
-        goto done;
-
-    /* Use hostlist_create_bracketed if we see "[" */
-    if (strchr(str, '[') != NULL)
-        return _hostlist_create_bracketed(hostlist, sep, r_op);
-
-    while ((tok = _next_tok(sep, &str)) != NULL) {
-
-        /* save the current string for error messages */
-        cur = tok;
-
-        high = low = 0;
-
-        /* find end of alpha part
-         *   do this by finding last occurence of range_op in str */
-        pos = strlen(tok) - 1;
-        if (strstr(tok, r_op) != '\0') {
-            while (pos >= 0 && (char) tok[pos] != range_op)
-                pos--;
-        }
-
-        /* now back up past any digits */
-        while (pos >= 0 && isdigit((char) tok[--pos])) {;}
-
-        /* Check for valid x-y range (x must be a digit)
-         *   Reset pos if the range is not valid         */
-        if (!isdigit((char) tok[++pos]))
-            pos = strlen(tok) - 1;
-
-        /* create prefix string
-         * if prefix will be zero length, but prefix already exists
-         * use the previous prefix and fmt
-         */
-        if ((pos > 0) || (prefix[0] == '\0')) {
-            memcpy(prefix, tok, (size_t) pos * sizeof(char));
-            prefix[pos] = '\0';
-
-            /* push pointer past prefix */
-            tok += pos;
-
-            /* count number of digits for ouput fmt */
-            for (fmt = 0; isdigit(tok[fmt]); ++fmt) {;}
-
-            if (fmt == 0)
-                error = 1;
-
-        } else
-            tok += pos;
-
-        /* get lower bound */
-        low = strtoul(tok, (char **) &tok, 10);
-
-        if (*tok == range_op) {    /* now get range upper bound */
-            /* push pointer past range op */
-            ++tok;
-
-            /* find length of alpha part */
-            for (pos = 0; tok[pos] && !isdigit(tok[pos]); ++pos) {;}
-
-            /* alpha part must match prefix or error
-             * this could mean we've got something like "rtr1-a2"
-             * so just record an error
-             */
-            if (pos > 0) {
-                if (pos != strlen(prefix) ||
-                    strncmp(prefix, tok, pos) != 0)
-                    error = 1;
-            }
-
-            if (*tok != '\0')
-                tok += pos;
-
-            /* make sure we have digits to the end */
-            for (pos = 0; tok[pos] && isdigit((char) tok[pos]); ++pos) {;}
-
-            if (pos > 0) {    /* we have digits to process */
-                high = strtoul(tok, (char **) &tok, 10);
-            } else {    /* bad boy, no digits */
-                error = 1;
-            }
-
-            if ((low > high) || (high - low > MAX_RANGE))
-                error = 1;
-
-        } else {    /* single value */
-            high = 0;    /* special case, ugh. */
-        }
-
-        /* error if:
-         * 1. we are not at end of string
-         * 2. upper bound equals lower bound
-         */
-        if (*tok != '\0' || high == low)
-            error = 1;
-
-        if (error) {    /* assume this is not a range on any error */
-            hostlist_push_host(new, cur);
-        } else {
-            if (high < low)
-                high = low;
-            hostlist_push_hr(new, prefix, low, high, fmt);
-        }
-
-        error = 0;
-    }
-
-  done:
-    free(orig);
-
-    return new;
-}
-
-#else                /* !WANT_RECKLESS_HOSTRANGE_EXPANSION */
-
-hostlist_t _hostlist_create(const char *hostlist, char *sep, char *r_op)
-{
-    return _hostlist_create_bracketed(hostlist, sep, r_op);
-}
-
-#endif                /* WANT_RECKLESS_HOSTRANGE_EXPANSION */
-
-struct _range {
-    unsigned long lo, hi;
-    int width;
-};
-
-/* Grab a single range from str
- * returns 1 if str contained a valid number or range,
- *         0 if conversion of str to a range failed.
- */
-static int _parse_single_range(const char *str, struct _range *range)
-{
-    char *p, *q;
-    char *orig = strdup(str);
-    if (!orig)
-        seterrno_ret(ENOMEM, 0);
-
-    if ((p = strchr(str, '-'))) {
-        *p++ = '\0';
-        if (*p == '-')     /* do NOT allow negative numbers */
-            goto error;
-    }
-    range->lo = strtoul(str, &q, 10);
-    if (q == str)
-        goto error;
-
-    range->hi = (p && *p) ? strtoul(p, &q, 10) : range->lo;
-
-    if (q == p || *q != '\0')
-        goto error;
-
-    if (range->lo > range->hi)
-        goto error;
-
-    if (range->hi - range->lo + 1 > MAX_RANGE ) {
-        _error(__FILE__, __LINE__, "Too many hosts in range `%s'", orig);
-        free(orig);
-        seterrno_ret(ERANGE, 0);
-    }
-
-    free(orig);
-    range->width = strlen(str);
-    return 1;
-
-  error:
-    _error(__FILE__, __LINE__, "Invalid range: `%s'", orig);
-    free(orig);
-    seterrno_ret(EINVAL, 0);
-}
-
-
-/*
- * Convert 'str' containing comma separated digits and ranges into an array
- *  of struct _range types (max 'len' elements).
- *
- * Return number of ranges created, or -1 on error.
- */
-static int _parse_range_list(char *str, struct _range *ranges, int len)
-{
-    char *p;
-    int count = 0;
-
-    while (str) {
-        if (count == len)
-            return -1;
-        if ((p = strchr(str, ',')))
-            *p++ = '\0';
-        if (!_parse_single_range(str, &ranges[count++]))
-            return -1;
-        str = p;
-    }
-    return count;
-}
-
-static void
-_push_range_list(hostlist_t hl, char *pfx, struct _range *rng,
-             int n)
-{
-    int i;
-    for (i = 0; i < n; i++) {
-        hostlist_push_hr(hl, pfx, rng->lo, rng->hi, rng->width);
-        rng++;
-    }
-}
-
-static void
-_push_range_list_with_suffix(hostlist_t hl, char *pfx, char *sfx,
-                             struct _range *rng, int n)
-{
-    int i;
-    unsigned long j;
-    for (i = 0; i < n; i++) {
-        for (j = rng->lo; j <= rng->hi; j++) {
-            char host[4096];
-            hostrange_t hr;
-            snprintf (host, 4096, "%s%0*lu%s", pfx, rng->width, j, sfx);
-            hr = hostrange_create_single (host);
-            hostlist_push_range (hl, hr);
-            /*
-             * hr is copied in hostlist_push_range. Need to free here.
-             */
-            hostrange_destroy (hr);
-        }
-        rng++;
-    }
-}
-
-/*
- * Create a hostlist from a string with brackets '[' ']' to aid
- * detection of ranges and compressed lists
- */
-static hostlist_t
-_hostlist_create_bracketed(const char *hostlist, char *sep, char *r_op)
-{
-    hostlist_t new = hostlist_new();
-    struct _range ranges[MAX_RANGES];
-    int nr, err;
-    char *p, *tok, *str, *orig;
-    char cur_tok[1024];
-
-    if (hostlist == NULL)
-        return new;
-
-    if (!(orig = str = strdup(hostlist))) {
-        hostlist_destroy(new);
-        return NULL;
-    }
-
-    while ((tok = _next_tok(sep, &str)) != NULL) {
-        strncpy(cur_tok, tok, 1024);
-
-        if ((p = strchr(tok, '[')) != NULL) {
-            char *q, *prefix = tok;
-            *p++ = '\0';
-
-            if ((q = strchr(p, ']'))) {
-                *q = '\0';
-                nr = _parse_range_list(p, ranges, MAX_RANGES);
-                if (nr < 0)
-                    goto error;
-
-                if (*(++q) != '\0')
-                    _push_range_list_with_suffix (new, prefix, q, ranges, nr);
-                else
-                    _push_range_list(new, prefix, ranges, nr);
-
-
-            } else
-                hostlist_push_host(new, cur_tok);
-
-        } else
-            hostlist_push_host(new, cur_tok);
-    }
-
-    free(orig);
-    return new;
-
-  error:
-    err = errno;
-    hostlist_destroy(new);
-    free(orig);
-    seterrno_ret(err, NULL);
-}
-
-
-
-hostlist_t hostlist_create(const char *str)
-{
-    return _hostlist_create(str, "\t, ", "-");
-}
-
-
-hostlist_t hostlist_copy(const hostlist_t hl)
-{
-    int i;
-    hostlist_t new;
-
-    if (hl == NULL)
-        return NULL;
-
-    LOCK_HOSTLIST(hl);
-    if (!(new = hostlist_new()))
-        goto done;
-
-    new->nranges = hl->nranges;
-    new->nhosts = hl->nhosts;
-    if (new->nranges > new->size)
-        hostlist_resize(new, new->nranges);
-
-    for (i = 0; i < hl->nranges; i++)
-        new->hr[i] = hostrange_copy(hl->hr[i]);
-
-  done:
-    UNLOCK_HOSTLIST(hl);
-    return new;
-}
-
-
-void hostlist_destroy(hostlist_t hl)
-{
-    int i;
-    if (hl == NULL)
-        return;
-    LOCK_HOSTLIST(hl);
-    while (hl->ilist) {
-        mutex_unlock(&hl->mutex);
-        hostlist_iterator_destroy(hl->ilist);
-        mutex_lock(&hl->mutex);
-    }
-    for (i = 0; i < hl->nranges; i++)
-        hostrange_destroy(hl->hr[i]);
-    free(hl->hr);
-    assert(hl->magic = 0x1);
-    UNLOCK_HOSTLIST(hl);
-    mutex_destroy(&hl->mutex);
-    free(hl);
-}
-
-
-int hostlist_push(hostlist_t hl, const char *hosts)
-{
-    hostlist_t new;
-    int retval;
-    if (hosts == NULL)
-        return 0;
-    new = hostlist_create(hosts);
-    if (!new)
-        return 0;
-    mutex_lock(&new->mutex);
-    retval = new->nhosts;
-    mutex_unlock(&new->mutex);
-    hostlist_push_list(hl, new);
-    hostlist_destroy(new);
-    return retval;
-}
-
-int hostlist_push_host(hostlist_t hl, const char *str)
-{
-    hostrange_t hr;
-    hostname_t hn;
-
-    if (str == NULL)
-        return 0;
-
-    hn = hostname_create(str);
-
-    if (hostname_suffix_is_valid(hn)) {
-        hr = hostrange_create(hn->prefix, hn->num, hn->num,
-                      hostname_suffix_width(hn));
-    } else
-        hr = hostrange_create_single(str);
-
-    hostlist_push_range(hl, hr);
-
-    hostrange_destroy(hr);
-    hostname_destroy(hn);
-
-    return 1;
-}
-
-int hostlist_push_list(hostlist_t h1, hostlist_t h2)
-{
-    int i, n = 0;
-
-    if (h2 == NULL)
-        return 0;
-
-    LOCK_HOSTLIST(h2);
-
-    for (i = 0; i < h2->nranges; i++)
-        n += hostlist_push_range(h1, h2->hr[i]);
-
-    UNLOCK_HOSTLIST(h2);
-
-    return n;
-}
-
-
-char *hostlist_pop(hostlist_t hl)
-{
-    char *host = NULL;
-
-    LOCK_HOSTLIST(hl);
-    if (hl->nhosts > 0) {
-        hostrange_t hr = hl->hr[hl->nranges - 1];
-        host = hostrange_pop(hr);
-        hl->nhosts--;
-        if (hostrange_empty(hr)) {
-            hostrange_destroy(hl->hr[--hl->nranges]);
-            hl->hr[hl->nranges] = NULL;
-        }
-    }
-    UNLOCK_HOSTLIST(hl);
-    return host;
-}
-
-/* find all iterators affected by a shift (or deletion) at
- * hl->hr[idx], depth, with the deletion of n ranges */
-static void
-hostlist_shift_iterators(hostlist_t hl, int idx, int depth, int n)
-{
-    hostlist_iterator_t i;
-    for (i = hl->ilist; i; i = i->next) {
-        if (n == 0) {
-            if (i->idx == idx && i->depth >= depth)
-                i->depth = i->depth > -1 ? i->depth - 1 : -1;
-        } else {
-            if (i->idx >= idx) {
-                if ((i->idx -= n) >= 0)
-                    i->hr = i->hl->hr[i->idx];
-                else
-                    hostlist_iterator_reset(i);
-            }
-        }
-    }
-}
-
-char *hostlist_shift(hostlist_t hl)
-{
-    char *host = NULL;
-
-    LOCK_HOSTLIST(hl);
-
-    if (hl->nhosts > 0) {
-        hostrange_t hr = hl->hr[0];
-
-        host = hostrange_shift(hr);
-        hl->nhosts--;
-
-        if (hostrange_empty(hr)) {
-            hostlist_delete_range(hl, 0);
-            /* hl->nranges--; */
-        } else
-            hostlist_shift_iterators(hl, 0, 0, 0);
-    }
-
-    UNLOCK_HOSTLIST(hl);
-
-    return host;
-}
-
-
-char *hostlist_pop_range(hostlist_t hl)
-{
-    int i;
-    char buf[MAXHOSTRANGELEN + 1];
-    hostlist_t hltmp;
-    hostrange_t tail;
-
-    LOCK_HOSTLIST(hl);
-    if (hl->nranges < 1 || !(hltmp = hostlist_new())) {
-        UNLOCK_HOSTLIST(hl);
-        return NULL;
-    }
-
-    i = hl->nranges - 2;
-    tail = hl->hr[hl->nranges - 1];
-    while (i >= 0 && hostrange_within_range(tail, hl->hr[i]))
-        i--;
-
-    for (i++; i < hl->nranges; i++) {
-        hostlist_push_range(hltmp, hl->hr[i]);
-        hostrange_destroy(hl->hr[i]);
-        hl->hr[i] = NULL;
-    }
-    hl->nhosts -= hltmp->nhosts;
-    hl->nranges -= hltmp->nranges;
-
-    UNLOCK_HOSTLIST(hl);
-    hostlist_ranged_string(hltmp, MAXHOSTRANGELEN, buf);
-    hostlist_destroy(hltmp);
-    return strdup(buf);
-}
-
-
-char *hostlist_shift_range(hostlist_t hl)
-{
-    int i;
-    char buf[1024];
-    hostlist_t hltmp = hostlist_new();
-    if (!hltmp)
-        return NULL;
-
-    LOCK_HOSTLIST(hl);
-
-    if (hl->nranges == 0) {
-        hostlist_destroy(hltmp);
-        UNLOCK_HOSTLIST(hl);
-        return NULL;
-    }
-
-    i = 0;
-    do {
-        hostlist_push_range(hltmp, hl->hr[i]);
-        hostrange_destroy(hl->hr[i]);
-    } while ( (++i < hl->nranges)
-            && hostrange_within_range(hltmp->hr[0], hl->hr[i]) );
-
-    hostlist_shift_iterators(hl, i, 0, hltmp->nranges);
-
-    /* shift rest of ranges back in hl */
-    for (; i < hl->nranges; i++) {
-        hl->hr[i - hltmp->nranges] = hl->hr[i];
-        hl->hr[i] = NULL;
-    }
-    hl->nhosts -= hltmp->nhosts;
-    hl->nranges -= hltmp->nranges;
-
-    UNLOCK_HOSTLIST(hl);
-
-    hostlist_ranged_string(hltmp, 1024, buf);
-    hostlist_destroy(hltmp);
-
-    return strdup(buf);
-}
-
-/* XXX: Note: efficiency improvements needed */
-int hostlist_delete(hostlist_t hl, const char *hosts)
-{
-    int n = 0;
-    char *hostname = NULL;
-    hostlist_t hltmp;
-
-    if (!(hltmp = hostlist_create(hosts)))
-        seterrno_ret(EINVAL, 0);
-
-    while ((hostname = hostlist_pop(hltmp)) != NULL) {
-        n += hostlist_delete_host(hl, hostname);
-        free(hostname);
-    }
-    hostlist_destroy(hltmp);
-
-    return n;
-}
-
-
-/* XXX watch out! poor implementation follows! (fix it at some point) */
-int hostlist_delete_host(hostlist_t hl, const char *hostname)
-{
-    int n = hostlist_find(hl, hostname);
-    if (n >= 0)
-        hostlist_delete_nth(hl, n);
-    return n >= 0 ? 1 : 0;
-}
-
-
-static char *
-_hostrange_string(hostrange_t hr, int depth)
-{
-    char buf[MAXHOSTNAMELEN + 16];
-    int  len = snprintf(buf, MAXHOSTNAMELEN + 15, "%s", hr->prefix);
-
-    if (!hr->singlehost)
-        snprintf(buf+len, MAXHOSTNAMELEN+15 - len, "%0*lu",
-                 hr->width, hr->lo + depth);
-    return strdup(buf);
-}
-
-char * hostlist_nth(hostlist_t hl, int n)
-{
-    char *host = NULL;
-    int   i, count;
-
-    LOCK_HOSTLIST(hl);
-    count = 0;
-    for (i = 0; i < hl->nranges; i++) {
-        int num_in_range = hostrange_count(hl->hr[i]);
-
-        if (n <= (num_in_range - 1 + count)) {
-            host = _hostrange_string(hl->hr[i], n - count);
-            break;
-        } else
-            count += num_in_range;
-    }
-
-    UNLOCK_HOSTLIST(hl);
-
-    return host;
-}
-
-
-int hostlist_delete_nth(hostlist_t hl, int n)
-{
-    int i, count;
-
-    LOCK_HOSTLIST(hl);
-    assert(n >= 0 && n <= hl->nhosts);
-
-    count = 0;
-
-    for (i = 0; i < hl->nranges; i++) {
-        int num_in_range = hostrange_count(hl->hr[i]);
-        hostrange_t hr = hl->hr[i];
-
-        if (n <= (num_in_range - 1 + count)) {
-            unsigned long num = hr->lo + n - count;
-            hostrange_t new;
-
-            if (hr->singlehost) { /* this wasn't a range */
-                hostlist_delete_range(hl, i);
-            } else if ((new = hostrange_delete_host(hr, num))) {
-                hostlist_insert_range(hl, new, i + 1);
-                hostrange_destroy(new);
-            } else if (hostrange_empty(hr))
-                hostlist_delete_range(hl, i);
-
-            goto done;
-        } else
-            count += num_in_range;
-
-    }
-
-  done:
-    UNLOCK_HOSTLIST(hl);
-    hl->nhosts--;
-    return 1;
-}
-
-int hostlist_count(hostlist_t hl)
-{
-    int retval;
-    LOCK_HOSTLIST(hl);
-    retval = hl->nhosts;
-    UNLOCK_HOSTLIST(hl);
-    return retval;
-}
-
-int hostlist_find(hostlist_t hl, const char *hostname)
-{
-    int i, count, ret = -1;
-    hostname_t hn;
-
-    if (!hostname)
-        return -1;
-
-    hn = hostname_create(hostname);
-
-    LOCK_HOSTLIST(hl);
-
-    for (i = 0, count = 0; i < hl->nranges; i++) {
-        if (hostrange_hn_within(hl->hr[i], hn)) {
-            if (hostname_suffix_is_valid(hn) && !hl->hr[i]->singlehost)
-                ret = count + hn->num - hl->hr[i]->lo;
-            else
-                ret = count;
-            goto done;
-        } else
-            count += hostrange_count(hl->hr[i]);
-    }
-
-  done:
-    UNLOCK_HOSTLIST(hl);
-    hostname_destroy(hn);
-    return ret;
-}
-
-/* hostrange compare with void * arguments to allow use with
- * libc qsort()
- */
-int _cmp(const void *hr1, const void *hr2)
-{
-    hostrange_t *h1 = (hostrange_t *) hr1;
-    hostrange_t *h2 = (hostrange_t *) hr2;
-    return hostrange_cmp((hostrange_t) * h1, (hostrange_t) * h2);
-}
-
-
-void hostlist_sort(hostlist_t hl)
-{
-    hostlist_iterator_t i;
-    LOCK_HOSTLIST(hl);
-
-    if (hl->nranges <= 1) {
-        UNLOCK_HOSTLIST(hl);
-        return;
-    }
-
-    qsort(hl->hr, hl->nranges, sizeof(hostrange_t), &_cmp);
-
-    /* reset all iterators */
-    for (i = hl->ilist; i; i = i->next)
-        hostlist_iterator_reset(i);
-
-    UNLOCK_HOSTLIST(hl);
-
-    hostlist_coalesce(hl);
-
-}
-
-
-/* search through hostlist for ranges that can be collapsed
- * does =not= delete any hosts
- */
-static void hostlist_collapse(hostlist_t hl)
-{
-    int i;
-
-    LOCK_HOSTLIST(hl);
-    for (i = hl->nranges - 1; i > 0; i--) {
-        hostrange_t hprev = hl->hr[i - 1];
-        hostrange_t hnext = hl->hr[i];
-
-        if (hostrange_prefix_cmp(hprev, hnext) == 0 &&
-            hprev->hi == hnext->lo - 1 &&
-            hostrange_width_combine(hprev, hnext)) {
-            hprev->hi = hnext->hi;
-            hostlist_delete_range(hl, i);
-        }
-    }
-    UNLOCK_HOSTLIST(hl);
-}
-
-/* search through hostlist (hl) for intersecting ranges
- * split up duplicates and coalesce ranges where possible
- */
-static void hostlist_coalesce(hostlist_t hl)
-{
-    int i, j;
-    hostrange_t new;
-
-    LOCK_HOSTLIST(hl);
-
-    for (i = hl->nranges - 1; i > 0; i--) {
-
-        new = hostrange_intersect(hl->hr[i - 1], hl->hr[i]);
-
-        if (new) {
-            hostrange_t hprev = hl->hr[i - 1];
-            hostrange_t hnext = hl->hr[i];
-            j = i;
-
-            if (new->hi < hprev->hi)
-                hnext->hi = hprev->hi;
-
-            hprev->hi = new->lo;
-            hnext->lo = new->hi;
-
-            if (hostrange_empty(hprev))
-                hostlist_delete_range(hl, i);
-
-            while (new->lo <= new->hi) {
-                hostrange_t hr = hostrange_create( new->prefix,
-                                                   new->lo, new->lo,
-                                                   new->width );
-
-                if (new->lo > hprev->hi)
-                    hostlist_insert_range(hl, hr, j++);
-
-                if (new->lo < hnext->lo)
-                    hostlist_insert_range(hl, hr, j++);
-
-                hostrange_destroy(hr);
-
-                new->lo++;
-            }
-            i = hl->nranges;
-            hostrange_destroy(new);
-        }
-    }
-    UNLOCK_HOSTLIST(hl);
-
-    hostlist_collapse(hl);
-
-}
-
-/* attempt to join ranges at loc and loc-1 in a hostlist  */
-/* delete duplicates, return the number of hosts deleted  */
-/* assumes that the hostlist hl has been locked by caller */
-/* returns -1 if no range join occurred */
-static int _attempt_range_join(hostlist_t hl, int loc)
-{
-    int ndup;
-    assert(hl != NULL);
-    assert(hl->magic == HOSTLIST_MAGIC);
-    assert(loc > 0);
-    assert(loc < hl->nranges);
-    ndup = hostrange_join(hl->hr[loc - 1], hl->hr[loc]);
-    if (ndup >= 0) {
-        hostlist_delete_range(hl, loc);
-        hl->nhosts -= ndup;
-    }
-    return ndup;
-}
-
-void hostlist_uniq(hostlist_t hl)
-{
-    int i = 1;
-    hostlist_iterator_t hli;
-    LOCK_HOSTLIST(hl);
-    if (hl->nranges <= 1) {
-        UNLOCK_HOSTLIST(hl);
-        return;
-    }
-    qsort(hl->hr, hl->nranges, sizeof(hostrange_t), &_cmp);
-
-    while (i < hl->nranges) {
-        if (_attempt_range_join(hl, i) < 0) /* No range join occurred */
-            i++;
-    }
-
-    /* reset all iterators */
-    for (hli = hl->ilist; hli; hli = hli->next)
-        hostlist_iterator_reset(hli);
-
-    UNLOCK_HOSTLIST(hl);
-}
-
-
-size_t hostlist_deranged_string(hostlist_t hl, size_t n, char *buf)
-{
-    int i;
-    int len = 0;
-    int truncated = 0;
-
-    LOCK_HOSTLIST(hl);
-    for (i = 0; i < hl->nranges; i++) {
-        size_t m = (n - len) <= n ? n - len : 0;
-        int ret = hostrange_to_string(hl->hr[i], m, buf + len, ",");
-        if (ret < 0 || ret > m) {
-            len = n;
-            truncated = 1;
-            break;
-        }
-        len+=ret;
-        buf[len++] = ',';
-    }
-    UNLOCK_HOSTLIST(hl);
-
-    buf[len > 0 ? --len : 0] = '\0';
-    if (len == n)
-        truncated = 1;
-
-    return truncated ? -1 : len;
-}
-
-/* return true if a bracket is needed for the range at i in hostlist hl */
-static int _is_bracket_needed(hostlist_t hl, int i)
-{
-    hostrange_t h1 = hl->hr[i];
-    hostrange_t h2 = i < hl->nranges - 1 ? hl->hr[i + 1] : NULL;
-    return hostrange_count(h1) > 1 || hostrange_within_range(h1, h2);
-}
-
-/* write the next bracketed hostlist, i.e. prefix[n-m,k,...]
- * into buf, writing at most n chars including the terminating '\0'
- *
- * leaves start pointing to one past last range object in bracketed list,
- * and returns the number of bytes written into buf.
- *
- * Assumes hostlist is locked.
- */
-static int
-_get_bracketed_list(hostlist_t hl, int *start, const size_t n, char *buf)
-{
-    hostrange_t *hr = hl->hr;
-    int i = *start;
-    int m, len = 0;
-    int bracket_needed = _is_bracket_needed(hl, i);
-
-    len = snprintf(buf, n, "%s", hr[i]->prefix);
-
-    if ((len < 0) || (len > n))
-        return n; /* truncated, buffer filled */
-
-    if (bracket_needed && len < n && len >= 0)
-        buf[len++] = '[';
-
-    do {
-        m = (n - len) <= n ? n - len : 0;
-        len += hostrange_numstr(hr[i], m, buf + len);
-        if (len >= n)
-            break;
-        if (bracket_needed) /* Only need commas inside brackets */
-            buf[len++] = ',';
-    } while (++i < hl->nranges && hostrange_within_range(hr[i], hr[i-1]));
-
-    if (bracket_needed && len < n && len > 0) {
-
-        /* Add trailing bracket (change trailing "," from above to "]" */
-        buf[len - 1] = ']';
-
-        /* NUL terminate for safety, but do not add terminator to len */
-        buf[len]   = '\0';
-
-    } else if (len >= n) {
-        if (n > 0)
-            buf[n-1] = '\0';
-
-    } else {
-        /* If len is > 0, NUL terminate (but do not add to len) */
-        buf[len > 0 ? len : 0] = '\0';
-    }
-
-    *start = i;
-    return len;
-}
-
-size_t hostlist_ranged_string(hostlist_t hl, size_t n, char *buf)
-{
-    int i = 0;
-    int len = 0;
-    int truncated = 0;
-
-    LOCK_HOSTLIST(hl);
-    while (i < hl->nranges && len < n) {
-        len += _get_bracketed_list(hl, &i, n - len, buf + len);
-        if ((len > 0) && (len < n) && (i < hl->nranges))
-            buf[len++] = ',';
-    }
-    UNLOCK_HOSTLIST(hl);
-
-    /* NUL terminate */
-    if (len >= n) {
-        truncated = 1;
-        if (n > 0)
-            buf[n-1] = '\0';
-    } else
-        buf[len > 0 ? len : 0] = '\0';
-
-    return truncated ? -1 : len;
-}
-
-/* ----[ hostlist iterator functions ]---- */
-
-static hostlist_iterator_t hostlist_iterator_new(void)
-{
-    hostlist_iterator_t i = (hostlist_iterator_t) malloc(sizeof(*i));
-    if (!i)
-        return NULL;
-    i->hl = NULL;
-    i->hr = NULL;
-    i->idx = 0;
-    i->depth = -1;
-    i->next = i;
-    assert(i->magic = HOSTLIST_MAGIC);
-    return i;
-}
-
-hostlist_iterator_t hostlist_iterator_create(hostlist_t hl)
-{
-    hostlist_iterator_t i;
-
-    if (!(i = hostlist_iterator_new()))
-        out_of_memory("hostlist_iterator_create");
-
-    LOCK_HOSTLIST(hl);
-    i->hl = hl;
-    i->hr = hl->hr[0];
-    i->next = hl->ilist;
-    hl->ilist = i;
-    UNLOCK_HOSTLIST(hl);
-    return i;
-}
-
-hostlist_iterator_t hostset_iterator_create(hostset_t set)
-{
-    return hostlist_iterator_create(set->hl);
-}
-
-void hostlist_iterator_reset(hostlist_iterator_t i)
-{
-    assert(i != NULL);
-    assert(i->magic == HOSTLIST_MAGIC);
-    i->idx = 0;
-    i->hr = i->hl->hr[0];
-    i->depth = -1;
-    return;
-}
-
-void hostlist_iterator_destroy(hostlist_iterator_t i)
-{
-    hostlist_iterator_t *pi;
-    if (i == NULL)
-        return;
-    assert(i != NULL);
-    assert(i->magic == HOSTLIST_MAGIC);
-    LOCK_HOSTLIST(i->hl);
-    for (pi = &i->hl->ilist; *pi; pi = &(*pi)->next) {
-        assert((*pi)->magic == HOSTLIST_MAGIC);
-        if (*pi == i) {
-            *pi = (*pi)->next;
-            break;
-        }
-    }
-    UNLOCK_HOSTLIST(i->hl);
-    assert(i->magic = 0x1);
-    free(i);
-}
-
-static void _iterator_advance(hostlist_iterator_t i)
-{
-    assert(i != NULL);
-    assert(i->magic == HOSTLIST_MAGIC);
-    if (i->idx > i->hl->nranges - 1)
-        return;
-    if (++(i->depth) > (i->hr->hi - i->hr->lo)) {
-        i->depth = 0;
-        i->hr = i->hl->hr[++i->idx];
-    }
-}
-
-/* advance iterator to end of current range (meaning within "[" "]")
- * i.e. advance iterator past all range objects that could be represented
- * in on bracketed hostlist.
- */
-static void _iterator_advance_range(hostlist_iterator_t i)
-{
-    int nr, j;
-    hostrange_t *hr;
-    assert(i != NULL);
-    assert(i->magic == HOSTLIST_MAGIC);
-
-    nr = i->hl->nranges;
-    hr = i->hl->hr;
-    j = i->idx;
-    if (++i->depth > 0) {
-        while (++j < nr && hostrange_within_range(i->hr, hr[j])) {;}
-        i->idx = j;
-        i->hr = i->hl->hr[i->idx];
-        i->depth = 0;
-    }
-}
-
-char *hostlist_next(hostlist_iterator_t i)
-{
-    char *buf = NULL;
-    char suffix[16];
-    int len = 0;
-    assert(i != NULL);
-    assert(i->magic == HOSTLIST_MAGIC);
-    LOCK_HOSTLIST(i->hl);
-    _iterator_advance(i);
-
-    if (i->idx > i->hl->nranges - 1) {
-        UNLOCK_HOSTLIST(i->hl);
-        return NULL;
-    }
-
-    suffix[0] = '\0';
-
-    if (!i->hr->singlehost)
-        snprintf (suffix, 15, "%0*lu", i->hr->width, i->hr->lo + i->depth);
-
-    len = strlen (i->hr->prefix) + strlen (suffix) + 1;
-    if (!(buf = malloc (len)))
-        out_of_memory("hostlist_next");
-
-    buf[0] = '\0';
-    strcat (buf, i->hr->prefix);
-    strcat (buf, suffix);
-
-    UNLOCK_HOSTLIST(i->hl);
-    return (buf);
-}
-
-char *hostlist_next_range(hostlist_iterator_t i)
-{
-    char buf[MAXHOSTRANGELEN + 1];
-    int j;
-
-    assert(i != NULL);
-    assert(i->magic == HOSTLIST_MAGIC);
-    LOCK_HOSTLIST(i->hl);
-
-    _iterator_advance_range(i);
-
-    if (i->idx > i->hl->nranges - 1) {
-        UNLOCK_HOSTLIST(i->hl);
-        return NULL;
-    }
-
-    j = i->idx;
-    _get_bracketed_list(i->hl, &j, MAXHOSTRANGELEN, buf);
-
-    UNLOCK_HOSTLIST(i->hl);
-
-    return strdup(buf);
-}
-
-int hostlist_remove(hostlist_iterator_t i)
-{
-    hostrange_t new;
-    assert(i != NULL);
-    assert(i->magic == HOSTLIST_MAGIC);
-    LOCK_HOSTLIST(i->hl);
-    new = hostrange_delete_host(i->hr, i->hr->lo + i->depth);
-    if (new) {
-        hostlist_insert_range(i->hl, new, i->idx + 1);
-        hostrange_destroy(new);
-        i->hr = i->hl->hr[++i->idx];
-        i->depth = -1;
-    } else if (hostrange_empty(i->hr)) {
-        hostlist_delete_range(i->hl, i->idx);
-    } else
-        i->depth--;
-
-    i->hl->nhosts--;
-    UNLOCK_HOSTLIST(i->hl);
-
-    return 1;
-}
-
-/* ----[ hostset functions ]---- */
-
-hostset_t hostset_create(const char *hostlist)
-{
-    hostset_t new;
-
-    if (!(new = (hostset_t) malloc(sizeof(*new))))
-        goto error1;
-
-    if (!(new->hl = hostlist_create(hostlist)))
-        goto error2;
-
-    hostlist_uniq(new->hl);
-    return new;
-
-  error2:
-    free(new);
-  error1:
-    return NULL;
-}
-
-hostset_t hostset_copy(const hostset_t set)
-{
-    hostset_t new;
-    if (!(new = (hostset_t) malloc(sizeof(*new))))
-        goto error1;
-
-    if (!(new->hl = hostlist_copy(set->hl)))
-        goto error2;
-
-    return new;
-  error2:
-    free(new);
-  error1:
-    return NULL;
-}
-
-void hostset_destroy(hostset_t set)
-{
-    if (set == NULL)
-        return;
-    hostlist_destroy(set->hl);
-    free(set);
-}
-
-/* inserts a single range object into a hostset
- * Assumes that the set->hl lock is already held
- * Updates hl->nhosts
- */
-static int hostset_insert_range(hostset_t set, hostrange_t hr)
-{
-    int i = 0;
-    int inserted = 0;
-    int nhosts = 0;
-    int ndups = 0;
-    hostlist_t hl;
-
-    hl = set->hl;
-
-    if (hl->size == hl->nranges && !hostlist_expand(hl))
-        return 0;
-
-    nhosts = hostrange_count(hr);
-
-    for (i = 0; i < hl->nranges; i++) {
-        if (hostrange_cmp(hr, hl->hr[i]) <= 0) {
-
-            if ((ndups = hostrange_join(hr, hl->hr[i])) >= 0)
-                hostlist_delete_range(hl, i);
-            else if (ndups < 0)
-                ndups = 0;
-
-            hostlist_insert_range(hl, hr, i);
-
-            /* now attempt to join hr[i] and hr[i-1] */
-            if (i > 0) {
-                int m;
-                if ((m = _attempt_range_join(hl, i)) > 0)
-                    ndups += m;
-            }
-            hl->nhosts += nhosts - ndups;
-            inserted = 1;
-            break;
-        }
-    }
-
-    if (inserted == 0) {
-        hl->hr[hl->nranges++] = hostrange_copy(hr);
-        hl->nhosts += nhosts;
-        if (hl->nranges > 1) {
-            if ((ndups = _attempt_range_join(hl, hl->nranges - 1)) <= 0)
-                ndups = 0;
-        }
-    }
-
-    /*
-     *  Return the number of unique hosts inserted
-     */
-    return nhosts - ndups;
-}
-
-int hostset_insert(hostset_t set, const char *hosts)
-{
-    int i, n = 0;
-    hostlist_t hl = hostlist_create(hosts);
-    if (!hl)
-        return 0;
-
-    hostlist_uniq(hl);
-    LOCK_HOSTLIST(set->hl);
-    for (i = 0; i < hl->nranges; i++)
-        n += hostset_insert_range(set, hl->hr[i]);
-    UNLOCK_HOSTLIST(set->hl);
-    hostlist_destroy(hl);
-    return n;
-}
-
-
-/* linear search through N ranges for hostname "host"
- * */
-static int hostset_find_host(hostset_t set, const char *host)
-{
-    int i;
-    int retval = 0;
-    hostname_t hn;
-    LOCK_HOSTLIST(set->hl);
-    hn = hostname_create(host);
-    for (i = 0; i < set->hl->nranges; i++) {
-        if (hostrange_hn_within(set->hl->hr[i], hn)) {
-            retval = 1;
-            goto done;
-        }
-    }
-  done:
-    UNLOCK_HOSTLIST(set->hl);
-    hostname_destroy(hn);
-    return retval;
-}
-
-int hostset_within(hostset_t set, const char *hosts)
-{
-    int nhosts, nfound;
-    hostlist_t hl;
-    char *hostname;
-
-    assert(set->hl->magic == HOSTLIST_MAGIC);
-
-    hl = hostlist_create(hosts);
-    nhosts = hostlist_count(hl);
-    nfound = 0;
-
-    while ((hostname = hostlist_pop(hl)) != NULL) {
-        nfound += hostset_find_host(set, hostname);
-        free(hostname);
-    }
-
-    hostlist_destroy(hl);
-
-    return (nhosts == nfound);
-}
-
-int hostset_delete(hostset_t set, const char *hosts)
-{
-    return hostlist_delete(set->hl, hosts);
-}
-
-int hostset_delete_host(hostset_t set, const char *hostname)
-{
-    return hostlist_delete_host(set->hl, hostname);
-}
-
-char *hostset_shift(hostset_t set)
-{
-    return hostlist_shift(set->hl);
-}
-
-char *hostset_pop(hostset_t set)
-{
-    return hostlist_pop(set->hl);
-}
-
-char *hostset_shift_range(hostset_t set)
-{
-    return hostlist_shift_range(set->hl);
-}
-
-char *hostset_pop_range(hostset_t set)
-{
-    return hostlist_pop_range(set->hl);
-}
-
-int hostset_count(hostset_t set)
-{
-    return hostlist_count(set->hl);
-}
-
-size_t hostset_ranged_string(hostset_t set, size_t n, char *buf)
-{
-    return hostlist_ranged_string(set->hl, n, buf);
-}
-
-size_t hostset_deranged_string(hostset_t set, size_t n, char *buf)
-{
-    return hostlist_deranged_string(set->hl, n, buf);
-}
-
-#if TEST_MAIN
-
-int hostlist_nranges(hostlist_t hl)
-{
-    return hl->nranges;
-}
-
-int hostset_nranges(hostset_t set)
-{
-    return set->hl->nranges;
-}
-
-/* test iterator functionality on the list of hosts represented
- * by list
- */
-int iterator_test(char *list)
-{
-    int j;
-    char buf[1024];
-    hostlist_t hl = hostlist_create(list);
-    hostset_t set = hostset_create(list);
-
-    hostlist_iterator_t i = hostlist_iterator_create(hl);
-    hostlist_iterator_t seti = hostset_iterator_create(set);
-    hostlist_iterator_t i2 = hostlist_iterator_create(hl);
-    char *host;
-
-
-    hostlist_ranged_string(hl, 1024, buf);
-    printf("iterator_test: hl = `%s' passed in `%s'\n", buf, list);
-    host = hostlist_next(i);
-    printf("first host in list hl = `%s'\n", host);
-    free(host);
-
-    /* forge ahead three hosts with i2 */
-    for (j = 0; j < 4; j++) {
-        host = hostlist_next(i2);
-        free(host);
-    }
-
-    host = hostlist_shift(hl);
-    printf("result of shift(hl)   = `%s'\n", host);
-    free(host);
-    host = hostlist_next(i);
-    printf("next host in list hl  = `%s'\n", host);
-    free(host);
-    host = hostlist_next(i2);
-    printf("next host for i2      = `%s'\n", host);
-    free(host);
-
-    hostlist_iterator_destroy(i);
-
-    hostlist_destroy(hl);
-    hostset_destroy(set);
-    return 1;
-}
-
-int main(int ac, char **av)
-{
-    char buf[1024000];
-    int i;
-    char *str;
-
-    hostlist_t hl1, hl2, hl3;
-    hostset_t set, set1;
-    hostlist_iterator_t iter, iter2;
-
-    if (!(hl1 = hostlist_create(ac > 1 ? av[1] : NULL)))
-        perror("hostlist_create");
-    if (!(set = hostset_create(ac > 1 ? av[1] : NULL)))
-        perror("hostlist_create");
-
-    hl3 = hostlist_create("f[0-5]");
-    hostlist_delete(hl3, "f[1-3]");
-    hostlist_ranged_string(hl3, 102400, buf);
-    printf("after delete = `%s'\n", buf);
-    hostlist_destroy(hl3);
-
-    for (i = 2; i < ac; i++) {
-        hostlist_push(hl1, av[i]);
-        hostset_insert(set, av[i]);
-    }
-
-    hostlist_ranged_string(hl1, 102400, buf);
-    printf("ranged   = `%s'\n", buf);
-
-    iterator_test(buf);
-
-    hostlist_deranged_string(hl1, 10240, buf);
-    printf("deranged = `%s'\n", buf);
-
-    hostset_ranged_string(set, 1024, buf);
-    printf("hostset  = `%s'\n", buf);
-
-    hostlist_sort(hl1);
-    hostlist_ranged_string(hl1, 1024, buf);
-    printf("sorted   = `%s'\n", buf);
-
-    hostlist_uniq(hl1);
-    hostlist_ranged_string(hl1, 1024, buf);
-    printf("uniqed   = `%s'\n", buf);
-
-    hl2 = hostlist_copy(hl1);
-    printf("pop_range: ");
-    while ((str = hostlist_pop_range(hl2))) {
-        printf("`%s' ", str);
-        free(str);
-    }
-    hostlist_destroy(hl2);
-    printf("\n");
-
-    hl2 = hostlist_copy(hl1);
-    printf("shift_range: ");
-    while ((str = hostlist_shift_range(hl2))) {
-        printf("`%s' ", str);
-        free(str);
-    }
-    hostlist_destroy(hl2);
-    printf("\n");
-
-    iter = hostset_iterator_create(set);
-    iter2 = hostset_iterator_create(set);
-    hostlist_iterator_destroy(iter2);
-
-    printf("next: ");
-    while ((str = hostlist_next(iter))) {
-        printf("`%s' ", str);
-        free(str);
-    }
-    printf("\n");
-
-    hostlist_iterator_reset(iter);
-    printf("next_range: ");
-    while ((str = hostlist_next_range(iter))) {
-        printf("`%s' ", str);
-        free(str);
-    }
-    printf("\n");
-
-    printf("nranges = %d\n", hostset_nranges(set));
-
-    hostset_ranged_string(set, 1024, buf);
-    printf("set = %s\n", buf);
-
-    hostset_destroy(set);
-    hostlist_destroy(hl1);
-    return 0;
-}
-
-#endif                /* TEST_MAIN */
-
-/*
- * vi: tabstop=4 shiftwidth=4 expandtab
- */
diff --git a/lustre/utils/hostlist.h b/lustre/utils/hostlist.h
deleted file mode 100644
index abf599b..0000000
--- a/lustre/utils/hostlist.h
+++ /dev/null
@@ -1,417 +0,0 @@
-/*****************************************************************************\
- *  $Id: hostlist.h,v 1.1.2.1 2008/11/21 15:27:33 yangsheng Exp $
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Mark Grondona <mgrondona at llnl.gov>
- *  UCRL-CODE-2002-040.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#ifndef _HOSTLIST_H
-#define _HOSTLIST_H
-
-/* Notes:
- *
- * If WITH_LSD_FATAL_ERROR_FUNC is defined, the linker will expect to
- * find and external lsd_fatal_error(file,line,mesg) function. By default,
- * lsd_fatal_error(file,line,mesg) is a macro definition that outputs an
- * error message to stderr. This macro may be redefined to invoke another
- * routine instead. e.g.:
- *
- *    #define lsd_fatal_error(file,line,mesg)  \
- *              error("%s:%s %s\n",file,line,mesg);
- *
- * If WITH_LSD_NOMEM_ERROR_FUNC is defined, the linker will expect to
- * find an external lsd_nomem_error(file,line,mesg) function. By default,
- * lsd_nomem_error(file,line,mesg) is a macro definition that returns NULL.
- * This macro may be redefined to invoke another routine instead.
- *
- * If WITH_PTHREADS is defined, these routines will be thread-safe.
- *
- */
-
-/* The hostlist opaque data type
- *
- * A hostlist is a list of hostnames optimized for a prefixXXXX style
- * naming convention, where XXXX  is a decimal, numeric suffix.
- */
-typedef struct hostlist * hostlist_t;
-
-/* A hostset is a special case of a hostlist. It:
- *
- * 1. never contains duplicates
- * 2. is always sorted
- *    (Note: sort occurs first on alphanumeric prefix -- where prefix
- *     matches, numeric suffixes will be sorted *by value*)
- */
-typedef struct hostset * hostset_t;
-
-/* The hostlist iterator type (may be used with a hostset as well)
- * used for non-destructive access to hostlist members.
- *
- */
-typedef struct hostlist_iterator * hostlist_iterator_t;
-
-/* ----[ hostlist_t functions: ]---- */
-
-/* ----[ hostlist creation and destruction ]---- */
-
-/*
- * hostlist_create():
- *
- * Create a new hostlist from a string representation.
- *
- * The string representation (str) may contain one or more hostnames or
- * bracketed hostlists separated by either `,' or whitespace. A bracketed
- * hostlist is denoted by a common prefix followed by a list of numeric
- * ranges contained within brackets: e.g. "tux[0-5,12,20-25]"
- *
- * Note: if this module is compiled with WANT_RECKLESS_HOSTRANGE_EXPANSION
- * defined, a much more loose interpretation of host ranges is used.
- * Reckless hostrange expansion allows all of the following (in addition to
- * bracketed hostlists):
- *
- *  o tux0-5,tux12,tux20-25
- *  o tux0-tux5,tux12,tux20-tux25
- *  o tux0-5,12,20-25
- *
- * If str is NULL, and empty hostlist is created and returned.
- *
- * If the create fails, hostlist_create() returns NULL.
- *
- * The returned hostlist must be freed with hostlist_destroy()
- *
- */
-hostlist_t hostlist_create(const char *hostlist);
-
-/* hostlist_copy():
- *
- * Allocate a copy of a hostlist object. Returned hostlist must be freed
- * with hostlist_destroy.
- */
-hostlist_t hostlist_copy(const hostlist_t hl);
-
-/* hostlist_destroy():
- *
- * Destroy a hostlist object. Frees all memory allocated to the hostlist.
- */
-void hostlist_destroy(hostlist_t hl);
-
-
-/* ----[ hostlist list operations ]---- */
-
-/* hostlist_push():
- *
- * push a string representation of hostnames onto a hostlist.
- *
- * The hosts argument may take the same form as in hostlist_create()
- *
- * Returns the number of hostnames inserted into the list,
- * or 0 on failure.
- */
-int hostlist_push(hostlist_t hl, const char *hosts);
-
-
-/* hostlist_push_host():
- *
- * Push a single host onto the hostlist hl.
- * This function is more efficient than hostlist_push() for a single
- * hostname, since the argument does not need to be checked for ranges.
- *
- * return value is 1 for success, 0 for failure.
- */
-int hostlist_push_host(hostlist_t hl, const char *host);
-
-
-/* hostlist_push_list():
- *
- * Push a hostlist (hl2) onto another list (hl1)
- *
- * Returns 1 for success, 0 for failure.
- *
- */
-int hostlist_push_list(hostlist_t hl1, hostlist_t hl2);
-
-
-/* hostlist_pop():
- *
- * Returns the string representation of the last host pushed onto the list
- * or NULL if hostlist is empty or there was an error allocating memory.
- * The host is removed from the hostlist.
- *
- * Note: Caller is responsible for freeing the returned memory.
- */
-char * hostlist_pop(hostlist_t hl);
-
-
-char * hostlist_nth(hostlist_t hl, int n);
-
-/* hostlist_shift():
- *
- * Returns the string representation of the first host in the hostlist
- * or NULL if the hostlist is empty or there was an error allocating memory.
- * The host is removed from the hostlist.
- *
- * Note: Caller is responsible for freeing the returned memory.
- */
-char * hostlist_shift(hostlist_t hl);
-
-
-/* hostlist_pop_range():
- *
- * Pop the last bracketed list of hosts of the hostlist hl.
- * Returns the string representation in bracketed list form.
- * All hosts associated with the returned list are removed
- * from hl.
- *
- * Caller is responsible for freeing returned memory
- */
-char * hostlist_pop_range(hostlist_t hl);
-
-/* hostlist_shift_range():
- *
- * Shift the first bracketed hostlist (improperly: range) off the
- * hostlist hl. Returns the string representation in bracketed list
- * form. All hosts associated with the list are removed from the
- * hostlist.
- *
- * Caller is responsible for freeing returned memory.
- */
-char * hostlist_shift_range(hostlist_t hl);
-
-
-/* hostlist_find():
- *
- * Searches hostlist hl for the first host matching hostname
- * and returns position in list if found.
- *
- * Returns -1 if host is not found.
- *
- */
-int hostlist_find(hostlist_t hl, const char *hostname);
-
-/* hostlist_delete():
- *
- * Deletes all hosts in the list represented by `hosts'
- *
- * Returns the number of hosts successfully deleted
- */
-int hostlist_delete(hostlist_t hl, const char *hosts);
-
-
-/* hostlist_delete_host():
- *
- * Deletes the first host that matches `hostname' from the hostlist hl.
- * Note: "hostname" argument cannot contain a range of hosts
- *       (see hostlist_delete() for this functionality.)
- *
- * Returns 1 if successful, 0 if hostname is not found in list.
- */
-int hostlist_delete_host(hostlist_t hl, const char *hostname);
-
-
-/* hostlist_delete_nth():
- *
- * Deletes the host from position n in the hostlist.
- *
- * Returns 1 if successful 0 on error.
- *
- */
-int hostlist_delete_nth(hostlist_t hl, int n);
-
-
-/* hostlist_count():
- *
- * Return the number of hosts in hostlist hl.
- */
-int hostlist_count(hostlist_t hl);
-
-/* hostlist_is_empty(): return true if hostlist is empty. */
-#define hostlist_is_empty(__hl) ( hostlist_count(__hl) == 0 )
-
-/* ----[ Other hostlist operations ]---- */
-
-/* hostlist_sort():
- *
- * Sort the hostlist hl.
- *
- */
-void hostlist_sort(hostlist_t hl);
-
-/* hostlist_uniq():
- *
- * Sort the hostlist hl and remove duplicate entries.
- *
- */
-void hostlist_uniq(hostlist_t hl);
-
-
-/* ----[ hostlist print functions ]---- */
-
-/* hostlist_ranged_string():
- *
- * Write the string representation of the hostlist hl into buf,
- * writing at most n chars. Returns the number of bytes written,
- * or -1 if truncation occurred.
- *
- * The result will be NULL terminated.
- *
- * hostlist_ranged_string() will write a bracketed hostlist representation
- * where possible.
- */
-size_t hostlist_ranged_string(hostlist_t hl, size_t n, char *buf);
-size_t hostset_ranged_string(hostset_t hs, size_t n, char *buf);
-
-/* hostlist_deranged_string():
- *
- * Writes the string representation of the hostlist hl into buf,
- * writing at most n chars. Returns the number of bytes written,
- * or -1 if truncation occurred.
- *
- * hostlist_deranged_string() will not attempt to write a bracketed
- * hostlist representation. Every hostname will be explicitly written.
- */
-size_t hostlist_deranged_string(hostlist_t hl, size_t n, char *buf);
-size_t hostset_deranged_string(hostset_t hs, size_t n, char *buf);
-
-
-/* ----[ hostlist utility functions ]---- */
-
-
-/* hostlist_nranges():
- *
- * Return the number of ranges currently held in hostlist hl.
- */
-int hostlist_nranges(hostlist_t hl);
-
-
-/* ----[ hostlist iterator functions ]---- */
-
-/* hostlist_iterator_create():
- *
- * Creates and returns a hostlist iterator used for non destructive
- * access to a hostlist or hostset. Returns NULL on failure.
- */
-hostlist_iterator_t hostlist_iterator_create(hostlist_t hl);
-
-/* hostset_iterator_create():
- *
- * Same as hostlist_iterator_create(), but creates a hostlist_iterator
- * from a hostset.
- */
-hostlist_iterator_t hostset_iterator_create(hostset_t set);
-
-/* hostlist_iterator_destroy():
- *
- * Destroys a hostlist iterator.
- */
-void hostlist_iterator_destroy(hostlist_iterator_t i);
-
-/* hostlist_iterator_reset():
- *
- * Reset an iterator to the beginning of the list.
- */
-void hostlist_iterator_reset(hostlist_iterator_t i);
-
-/* hostlist_next():
- *
- * Returns a pointer to the  next hostname on the hostlist
- * or NULL at the end of the list
- *
- * The caller is responsible for freeing the returned memory.
- */
-char * hostlist_next(hostlist_iterator_t i);
-
-
-/* hostlist_next_range():
- *
- * Returns the next bracketed hostlist or NULL if the iterator i is
- * at the end of the list.
- *
- * The caller is responsible for freeing the returned memory.
- *
- */
-char * hostlist_next_range(hostlist_iterator_t i);
-
-
-/* hostlist_remove():
- * Removes the last host returned by hostlist iterator i
- *
- * Returns 1 for success, 0 for failure.
- */
-int hostlist_remove(hostlist_iterator_t i);
-
-
-/* ----[ hostset operations ]---- */
-
-/* hostset_create():
- *
- * Create a new hostset object from a string representation of a list of
- * hosts. See hostlist_create() for valid hostlist forms.
- */
-hostset_t hostset_create(const char *hostlist);
-
-/* hostset_copy():
- *
- * Copy a hostset object. Returned set must be freed with hostset_destroy().
- */
-hostset_t hostset_copy(hostset_t set);
-
-/* hostset_destroy():
- */
-void hostset_destroy(hostset_t set);
-
-/* hostset_insert():
- * Add a host or list of hosts into hostset "set."
- *
- * Returns number of hosts successfully added to "set"
- * (insertion of a duplicate is not considered successful)
- */
-int hostset_insert(hostset_t set, const char *hosts);
-
-/* hostset_delete():
- * Delete a host or list of hosts from hostset "set."
- * Returns number of hosts deleted from set.
- */
-int hostset_delete(hostset_t set, const char *hosts);
-
-/* hostset_within():
- * Return 1 if all hosts specified by "hosts" are within the hostset "set"
- * Retrun 0 if every host in "hosts" is not in the hostset "set"
- */
-int hostset_within(hostset_t set, const char *hosts);
-
-/* hostset_shift():
- * hostset equivalent to hostlist_shift()
- */
-char * hostset_shift(hostset_t set);
-
-/* hostset_shift_range():
- * hostset eqivalent to hostlist_shift_range()
- */
-char * hostset_shift_range(hostset_t set);
-
-/* hostset_count():
- * Count the number of hosts currently in hostset
- */
-int hostset_count(hostset_t set);
-
-
-#endif /* !_HOSTLIST_H */
diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c
index dc39fda..84c0c11 100644
--- a/lustre/utils/lctl.c
+++ b/lustre/utils/lctl.c
@@ -212,6 +212,24 @@ command_t cmdlist[] = {
          "get the device info of a attached file\n"
          "usage: blockdev_info <device_name>"},
 
+        /* Pool commands */
+        {"===  Pools ==", jt_noop, 0, "pool management"},
+        {"pool_new", jt_pool_cmd, 0,
+         "add a new pool\n"
+         "usage pool_new <fsname>.<poolname>"},
+        {"pool_add", jt_pool_cmd, 0,
+         "add the named OSTs to the pool\n"
+         "usage pool_add <fsname>.<poolname> <ostname indexed list>"},
+        {"pool_remove", jt_pool_cmd, 0,
+         "remove the named OST from the pool\n"
+         "usage pool_remove <fsname>.<poolname> <ostname indexed list>"},
+        {"pool_destroy", jt_pool_cmd, 0,
+         "destroy a pool\n"
+         "usage pool_destroy <fsname>.<poolname>"},
+        {"pool_list", jt_pool_cmd, 0,
+         "list pools and pools members\n"
+         "usage pool_list  <fsname>[.<poolname>] | <pathname>"},
+
         /* Test only commands */
         {"==== testing (DANGEROUS) ====", jt_noop, 0, "testing (DANGEROUS)"},
         {"--threads", jt_opt_threads, 0,
diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c
index 78b0903..e288707 100644
--- a/lustre/utils/lfs.c
+++ b/lustre/utils/lfs.c
@@ -40,6 +40,11 @@
  * Author: Robert Read <rread at clusterfs.com>
  */
 
+/* for O_DIRECTORY */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <getopt.h>
@@ -50,6 +55,7 @@
 #include <grp.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <time.h>
@@ -65,6 +71,7 @@
 #include <lustre/lustre_idl.h>
 #include <lustre/liblustreapi.h>
 #include <lustre/lustre_user.h>
+#include <lustre_quota.h>
 
 #include "parser.h"
 #include "obdctl.h"
@@ -89,6 +96,7 @@ static int lfs_quota(int argc, char **argv);
 static int lfs_quotainv(int argc, char **argv);
 #endif
 static int lfs_join(int argc, char **argv);
+static int lfs_poollist(int argc, char **argv);
 
 /* all avaialable commands */
 command_t cmdlist[] = {
@@ -96,30 +104,34 @@ command_t cmdlist[] = {
          "Create a new file with a specific striping pattern or\n"
          "set the default striping pattern on an existing directory or\n"
          "delete the default striping pattern from an existing directory\n"
-         "usage: setstripe <filename|dirname> <stripe_size> <stripe_index> <stripe_count>\n"
-         "       or \n"
-         "       setstripe <filename|dirname> [--size|-s stripe_size]\n"
-         "                                    [--index|-i stripe_index]\n"
-         "                                    [--count|-c stripe_count]\n"
+         "usage: setstripe [--size|-s stripe_size] [--offset|-o start_ost]\n"
+         "                 [--count|-c stripe_count] [--pool|-p pool_name]\n"
+         "                 <dir|filename>\n"
          "       or \n"
-         "       setstripe -d <dirname>   (to delete default striping)\n"
+         "       setstripe -d <dir>   (to delete default striping)\n"
          "\tstripe_size:  Number of bytes on each OST (0 filesystem default)\n"
-         "\t              Can be specified with k, m or g (in KB, MB and GB respectively)\n"
-         "\tstripe_index: OST index of first stripe (-1 filesystem default)\n"
-         "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)"},
+         "\t              Can be specified with k, m or g (in KB, MB and GB\n"
+         "\t              respectively)\n"
+         "\tstart_ost:    OST index of first stripe (-1 filesystem default)\n"
+         "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)\n"
+         "\tpool_name:    Name of OST pool"},
         {"getstripe", lfs_getstripe, 0,
-         "To list the striping info for a given filename or files in a\n"
+         "To list the striping info for a given file or files in a\n"
          "directory or recursively for all files in a directory tree.\n"
          "usage: getstripe [--obd|-O <uuid>] [--quiet | -q] [--verbose | -v]\n"
          "                 [--recursive | -r] <dir|file> ..."},
+        {"pool_list", lfs_poollist, 0,
+         "List pools or pool OSTs\n"
+         "usage: pool_list <fsname>[.<poolname>] | <pathname>\n"},
         {"find", lfs_find, 0,
          "To find files that match given parameters recursively in a directory tree.\n"
-         "usage: find <dir/file> ... \n"
+         "usage: find <dir|file> ... \n"
          "     [[!] --atime|-A [+-]N] [[!] --mtime|-M [+-]N] [[!] --ctime|-C [+-]N]\n"
          "     [--maxdepth|-D N] [[!] --name|-n <pattern>] [--print0|-P]\n"
          "     [--print|-p] [--obd|-O <uuid[s]>] [[!] --size|-s [+-]N[bkMGTP]]\n"
          "     [[!] --type|-t <filetype>] [[!] --gid|-g N] [[!] --group|-G <name>]\n"
          "     [[!] --uid|-u N] [[!] --user|-U <name>]\n"
+         "     [[!] --pool <name>]\n"
          "\t !: used before an option indicates 'NOT' the requested attribute\n"
          "\t -: used before an value indicates 'AT MOST' the requested value\n"
          "\t +: used before an option indicates 'AT LEAST' the requested value\n"},
@@ -179,6 +191,21 @@ command_t cmdlist[] = {
         { 0, 0, 0, NULL }
 };
 
+static int isnumber(const char *str)
+{
+        const char *ptr;
+
+        if (str[0] != '-' && !isdigit(str[0]))
+                return 0;
+
+        for (ptr = str + 1; *ptr != '\0'; ptr++) {
+                if (!isdigit(*ptr))
+                        return 0;
+        }
+
+        return 1;
+}
+
 /* functions */
 static int lfs_setstripe(int argc, char **argv)
 {
@@ -192,12 +219,15 @@ static int lfs_setstripe(int argc, char **argv)
         char *stripe_size_arg = NULL;
         char *stripe_off_arg = NULL;
         char *stripe_count_arg = NULL;
+        char *pool_name_arg = NULL;
         unsigned long long size_units;
 
         struct option long_opts[] = {
                 {"size",        required_argument, 0, 's'},
                 {"count",       required_argument, 0, 'c'},
                 {"index",       required_argument, 0, 'i'},
+                {"offset",      required_argument, 0, 'o'},
+                {"pool",        required_argument, 0, 'p'},
                 {"delete",      no_argument,       0, 'd'},
                 {0, 0, 0, 0}
         };
@@ -205,15 +235,12 @@ static int lfs_setstripe(int argc, char **argv)
         st_size = 0;
         st_offset = -1;
         st_count = 0;
-        if (argc == 3 && strcmp(argv[1], "-d") == 0) {
-                /* for compatibility with the existing positional parameter
-                 * usage */
-                fname = argv[2];
-                optind = 2;
-        } else if (argc == 5  && 
-                   (argv[2][0] != '-' || isdigit(argv[2][1])) &&
-                   (argv[3][0] != '-' || isdigit(argv[3][1])) &&
-                   (argv[4][0] != '-' || isdigit(argv[4][1])) ) {
+
+#if LUSTRE_VERSION < OBD_OCD_VERSION(2,1,0,0)
+        if (argc == 5 && argv[1][0] != '-' &&
+            isnumber(argv[2]) && isnumber(argv[3]) && isnumber(argv[4])) {
+                fprintf(stderr, "warning: deprecated usage of setstripe "
+                        "positional parameters.  Use -c, -i, -s instead.\n");
                 /* for compatibility with the existing positional parameter
                  * usage */
                 fname = argv[1];
@@ -221,10 +248,14 @@ static int lfs_setstripe(int argc, char **argv)
                 stripe_off_arg = argv[3];
                 stripe_count_arg = argv[4];
                 optind = 4;
-        } else {
+        } else
+#else
+#warning "remove obsolete positional parameter code"
+#endif
+        {
                 optind = 0;
-                while ((c = getopt_long(argc, argv, "c:di:s:",
-                                                long_opts, NULL)) >= 0) {
+                while ((c = getopt_long(argc, argv, "c:di:o:s:p:",
+                                        long_opts, NULL)) >= 0) {
                         switch (c) {
                         case 0:
                                 /* Long options. */
@@ -237,11 +268,15 @@ static int lfs_setstripe(int argc, char **argv)
                                 delete = 1;
                                 break;
                         case 'i':
+                        case 'o':
                                 stripe_off_arg = optarg;
                                 break;
                         case 's':
                                 stripe_size_arg = optarg;
                                 break;
+                        case 'p':
+                                pool_name_arg = optarg;
+                                break;
                         case '?':
                                 return CMD_HELP;
                         default:
@@ -252,25 +287,21 @@ static int lfs_setstripe(int argc, char **argv)
                         }
                 }
 
-                if (optind < argc)
-                        fname = argv[optind];
-                else
-                        return CMD_HELP;
+                fname = argv[optind];
 
-                if (delete && 
-                    (stripe_size_arg != NULL || stripe_off_arg != NULL || 
-                     stripe_count_arg != NULL)) {
+                if (delete &&
+                    (stripe_size_arg != NULL || stripe_off_arg != NULL ||
+                     stripe_count_arg != NULL || pool_name_arg != NULL)) {
                         fprintf(stderr, "error: %s: cannot specify -d with "
-                                        "-s, -c or -i options\n",
+                                        "-s, -c -o or -p options\n",
                                         argv[0]);
                         return CMD_HELP;
                 }
         }
 
-        if (optind != argc - 1) {
-                fprintf(stderr, "error: %s: only 1 filename|dirname can be "
-                                "specified: '%s'\n",
-                                argv[0], argv[argc-1]);
+        if (optind == argc) {
+                fprintf(stderr, "error: %s: missing filename|dirname\n",
+                        argv[0]);
                 return CMD_HELP;
         }
 
@@ -278,8 +309,8 @@ static int lfs_setstripe(int argc, char **argv)
         if (stripe_size_arg != NULL) {
                 result = parse_size(stripe_size_arg, &st_size, &size_units, 0);
                 if (result) {
-                        fprintf(stderr,"error: bad size '%s'\n",
-                                stripe_size_arg);
+                        fprintf(stderr, "error: %s: bad size '%s'\n",
+                                argv[0], stripe_size_arg);
                         return result;
                 }
         }
@@ -302,19 +333,33 @@ static int lfs_setstripe(int argc, char **argv)
                 }
         }
 
-        result = llapi_file_create(fname, st_size, st_offset, st_count, 0);
-        if (result)
-                fprintf(stderr, "error: %s: create stripe file failed\n",
-                                argv[0]);
+        do {
+                result = llapi_file_create_pool(fname, st_size, st_offset,
+                                                st_count, 0, pool_name_arg);
+                if (result) {
+                        fprintf(stderr,"error: %s: create stripe file '%s' "
+                                "failed\n", argv[0], fname);
+                        break;
+                }
+                fname = argv[++optind];
+        } while (fname != NULL);
 
         return result;
 }
 
+static int lfs_poollist(int argc, char **argv)
+{
+        if (argc != 2)
+                return CMD_HELP;
+
+        return llapi_poollist(argv[1]);
+}
+
 static int set_time(time_t *time, time_t *set, char *str)
 {
         time_t t;
         int res = 0;
-        
+
         if (str[0] == '+')
                 res = 1;
         else if (str[0] == '-')
@@ -392,6 +437,7 @@ static int id2name(char **name, unsigned int id, int type)
         return 0;
 }
 
+#define FIND_POOL_OPT 3
 static int lfs_find(int argc, char **argv)
 {
         int new_fashion = 1;
@@ -410,6 +456,8 @@ static int lfs_find(int argc, char **argv)
                 {"uid",       required_argument, 0, 'u'},
                 {"user",      required_argument, 0, 'U'},
                 {"name",      required_argument, 0, 'n'},
+                /* no short option for pool, p/P already used */
+                {"pool",      required_argument, 0, FIND_POOL_OPT},
                 /* --obd is considered as a new option. */
                 {"obd",       required_argument, 0, 'O'},
                 {"ost",       required_argument, 0, 'O'},
@@ -434,6 +482,7 @@ static int lfs_find(int argc, char **argv)
         time(&t);
 
         optind = 0;
+        /* when getopt_long_only() hits '!' it returns 1 and puts "!" in optarg */
         while ((c = getopt_long_only(argc, argv, "-A:C:D:g:G:M:n:PpO:qrs:t:u:U:v",
                                      long_opts, NULL)) >= 0) {
                 xtime = NULL;
@@ -441,6 +490,12 @@ static int lfs_find(int argc, char **argv)
                 if (neg_opt)
                         --neg_opt;
                 /* '!' is part of option */
+                /* when getopt_long_only() finds a string which is not
+                 * an option nor a known option argument it returns 1
+                 * in that case if we already have found pathstart and pathend
+                 * (i.e. we have the list of pathnames),
+                 * the only supported value is "!"
+                 */
                 isoption = (c != 1) || (strcmp(optarg, "!") == 0);
                 if (!isoption && pathend != -1) {
                         fprintf(stderr, "err: %s: filename|dirname must either "
@@ -462,6 +517,9 @@ static int lfs_find(int argc, char **argv)
                         /* Long options. */
                         break;
                 case 1:
+                        /* unknown; opt is "!" or path component,
+                         * checking done above.
+                         */
                         if (strcmp(optarg, "!") == 0)
                                 neg_opt = 2;
                       break;
@@ -515,8 +573,8 @@ static int lfs_find(int argc, char **argv)
                         new_fashion = 1;
                         param.gid = strtol(optarg, &endptr, 10);
                         if (optarg == endptr) {
-	                        ret = name2id(&param.gid, optarg, GROUP);
-        	                if (ret != 0) {
+                                ret = name2id(&param.gid, optarg, GROUP);
+                                if (ret != 0) {
                                         fprintf(stderr, "Group/GID: %s cannot "
                                                 "be found.\n", optarg);
                                         return -1;
@@ -539,8 +597,8 @@ static int lfs_find(int argc, char **argv)
                         new_fashion = 1;
                         param.uid = strtol(optarg, &endptr, 10);
                         if (optarg == endptr) {
-	                        ret = name2id(&param.uid, optarg, USER);
-        	                if (ret != 0) {
+                                ret = name2id(&param.uid, optarg, USER);
+                                if (ret != 0) {
                                         fprintf(stderr, "User/UID: %s cannot "
                                                 "be found.\n", optarg);
                                         return -1;
@@ -549,6 +607,22 @@ static int lfs_find(int argc, char **argv)
                         param.exclude_uid = !!neg_opt;
                         param.check_uid = 1;
                         break;
+                case FIND_POOL_OPT:
+                        new_fashion = 1;
+                        if (strlen(optarg) > LOV_MAXPOOLNAME) {
+                                fprintf(stderr,
+                                        "Pool name %s is too long"
+                                        " (max is %d)\n", optarg,
+                                        LOV_MAXPOOLNAME);
+                                return -1;
+                        }
+                        /* we do check for empty pool because empty pool
+                         * is used to find V1 lov attributes */
+                        strncpy(param.poolname, optarg, LOV_MAXPOOLNAME);
+                        param.poolname[LOV_MAXPOOLNAME] = '\0';
+                        param.exclude_pool = !!neg_opt;
+                        param.check_pool = 1;
+                        break;
                 case 'n':
                         new_fashion = 1;
                         param.pattern = (char *)optarg;
@@ -565,7 +639,7 @@ static int lfs_find(int argc, char **argv)
                         strcpy(buf, (char *)optarg);
 
                         if (param.num_alloc_obds == 0) {
-                                param.obduuid = (struct obd_uuid *)malloc(FIND_MAX_OSTS *
+                                param.obduuid = malloc(FIND_MAX_OSTS *
                                                        sizeof(struct obd_uuid));
                                 if (param.obduuid == NULL)
                                         return -ENOMEM;
@@ -758,7 +832,7 @@ static int lfs_getstripe(int argc, char **argv)
         } while (++optind < argc && !rc);
 
         if (rc)
-                fprintf(stderr, "error: %s failed for %s.\n", 
+                fprintf(stderr, "error: %s failed for %s.\n",
                         argv[0], argv[optind - 1]);
         return rc;
 }
@@ -1125,7 +1199,8 @@ static int lfs_check(int argc, char **argv)
                 return -1;
         }
 
-        rc = llapi_target_check(num_types, obd_types, mnt->mnt_dir);
+        rc = llapi_target_iterate(num_types, obd_types,
+                                  mnt->mnt_dir, llapi_ping_target);
 
         if (rc)
                 fprintf(stderr, "error: %s: %s status failed\n",
@@ -1408,7 +1483,7 @@ static int lfs_quotaoff(int argc, char **argv)
 
         rc = llapi_quotactl(mnt, &qctl);
         if (rc == -1 && errno == ESRCH) {
-                fprintf(stderr, "\n%s quotas are not enabled.\n", 
+                fprintf(stderr, "\n%s quotas are not enabled.\n",
                         qctl.qc_type == 0x00 ? "user" : "group");
                 return 0;
         }
@@ -1512,7 +1587,7 @@ static unsigned long str2sec(const char* timestr) {
 
                 v = strtoul(timestr, &tail, 10);
                 if (v == ULONG_MAX || *tail == '\0')
-                        /* value too large (ULONG_MAX or more) 
+                        /* value too large (ULONG_MAX or more)
                            or missing specifier */
                         goto error;
 
@@ -2154,7 +2229,7 @@ ug_output:
 
         rc1 = llapi_quotactl(mnt, &qctl);
         if (rc1 == -1 && errno == ESRCH) {
-                fprintf(stderr, "\n%s quotas are not enabled.\n", 
+                fprintf(stderr, "\n%s quotas are not enabled.\n",
                         qctl.qc_type == USRQUOTA ? "user" : "group");
                 goto out;
         }
diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c
index 0585cc6..764b59a 100644
--- a/lustre/utils/liblustreapi.c
+++ b/lustre/utils/liblustreapi.c
@@ -58,7 +58,9 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/syscall.h>
+#include <sys/param.h>
 #include <fnmatch.h>
+#include <glob.h>
 #ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
 #endif
@@ -217,72 +219,103 @@ int parse_size(char *optarg, unsigned long long *size,
         return 0;
 }
 
-int llapi_file_open(const char *name, int flags, int mode,
-                    unsigned long long stripe_size, int stripe_offset,
-                    int stripe_count, int stripe_pattern)
+int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset,
+                             int stripe_count, int stripe_pattern)
 {
-        struct lov_user_md lum = { 0 };
-        int fd, rc = 0;
-        int isdir = 0;
         int page_size;
 
-        fd = open(name, flags | O_LOV_DELAY_CREATE, mode);
-        if (fd < 0 && errno == EISDIR) {
-                fd = open(name, O_DIRECTORY | O_RDONLY);
-                isdir++;
-        }
-
-        if (fd < 0) {
-                rc = -errno;
-                llapi_err(LLAPI_MSG_ERROR, "unable to open '%s'", name);
-                return rc;
-        }
-
         /* 64 KB is the largest common page size I'm aware of (on ia64), but
          * check the local page size just in case. */
         page_size = LOV_MIN_STRIPE_SIZE;
         if (getpagesize() > page_size) {
                 page_size = getpagesize();
-                llapi_err_noerrno(LLAPI_MSG_WARN, 
+                llapi_err_noerrno(LLAPI_MSG_WARN,
                                   "warning: your page size (%u) is "
-                                  "larger than expected (%u)", page_size, 
+                                  "larger than expected (%u)", page_size,
                                   LOV_MIN_STRIPE_SIZE);
         }
         if (stripe_size < 0 || (stripe_size & (LOV_MIN_STRIPE_SIZE - 1))) {
-                errno = rc = -EINVAL;
+                errno = -EINVAL;
                 llapi_err(LLAPI_MSG_ERROR, "error: bad stripe_size %lu, "
-                          "must be an even multiple of %d bytes", 
+                          "must be an even multiple of %d bytes",
                           stripe_size, page_size);
-                goto out;
+                return errno;
         }
         if (stripe_offset < -1 || stripe_offset > MAX_OBD_DEVICES) {
-                errno = rc = -EINVAL;
-                llapi_err(LLAPI_MSG_ERROR, "error: bad stripe offset %d", 
+                errno = -EINVAL;
+                llapi_err(LLAPI_MSG_ERROR, "error: bad stripe offset %d",
                           stripe_offset);
-                goto out;
+                return errno;
         }
         if (stripe_count < -1 || stripe_count > LOV_MAX_STRIPE_COUNT) {
-                errno = rc = -EINVAL;
-                llapi_err(LLAPI_MSG_ERROR, "error: bad stripe count %d", 
+                errno = -EINVAL;
+                llapi_err(LLAPI_MSG_ERROR, "error: bad stripe count %d",
                           stripe_count);
-                goto out;
+                return errno;
         }
-
         if (stripe_size >= (1ULL << 32)) {
-                errno = rc = -EINVAL;
-                llapi_err_noerrno(LLAPI_MSG_ERROR,
-                                  "warning: stripe size larger than 4G "
-                                  "is not currently supported and would wrap");
+                errno = -EINVAL;
+                llapi_err(LLAPI_MSG_ERROR, "warning: stripe size larger than 4G"
+                          " is not currently supported and would wrap");
+                return errno;
+        }
+        return 0;
+}
+
+static int poolpath(char *fsname, char *pathname, char *pool_pathname);
+
+int llapi_file_open_pool(const char *name, int flags, int mode,
+                         unsigned long long stripe_size, int stripe_offset,
+                         int stripe_count, int stripe_pattern, char *pool_name)
+{
+        struct lov_user_md_v3 lum = { 0 };
+        int fd, rc = 0;
+        int isdir = 0;
+        char fsname[MAX_OBD_NAME + 1], *ptr;
+
+        fd = open(name, flags | O_LOV_DELAY_CREATE, mode);
+        if (fd < 0 && errno == EISDIR) {
+                fd = open(name, O_DIRECTORY | O_RDONLY);
+                isdir++;
+        }
+
+        if (fd < 0) {
+                rc = -errno;
+                llapi_err(LLAPI_MSG_ERROR, "unable to open '%s'", name);
+                return rc;
+        }
+
+        if ((rc = llapi_stripe_limit_check(stripe_size, stripe_offset,
+                                           stripe_count, stripe_pattern)) != 0){
+                errno = rc;
                 goto out;
         }
 
         /*  Initialize IOCTL striping pattern structure */
-        lum.lmm_magic = LOV_USER_MAGIC;
+        lum.lmm_magic = LOV_USER_MAGIC_V3;
         lum.lmm_pattern = stripe_pattern;
         lum.lmm_stripe_size = stripe_size;
         lum.lmm_stripe_count = stripe_count;
         lum.lmm_stripe_offset = stripe_offset;
 
+        /* in case user give the full pool name <fsname>.<poolname>, skip
+         * the fsname */
+        if (pool_name != NULL) {
+                ptr = strchr(pool_name, '.');
+                if (ptr != NULL) {
+                        strncpy(fsname, pool_name, ptr - pool_name);
+                        fsname[ptr - pool_name] = '\0';
+                        /* if fsname matches a filesystem skip it
+                         * if not keep the poolname as is */
+                        if (poolpath(fsname, NULL, NULL) == 0)
+                                pool_name = ptr + 1;
+                }
+                strncpy(lum.lmm_pool_name, pool_name, LOV_MAXPOOLNAME);
+        } else {
+                /* If no pool is specified at all, use V1 request */
+                lum.lmm_magic = LOV_USER_MAGIC_V1;
+        }
+
         if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, &lum)) {
                 char *errmsg = "stripe already set";
                 rc = -errno;
@@ -291,7 +324,7 @@ int llapi_file_open(const char *name, int flags, int mode,
 
                 llapi_err_noerrno(LLAPI_MSG_ERROR,
                                   "error on ioctl "LPX64" for '%s' (%d): %s",
-                                  (__u64)LL_IOC_LOV_SETSTRIPE, name, fd, errmsg);
+                                  (__u64)LL_IOC_LOV_SETSTRIPE, name, fd,errmsg);
         }
 out:
         if (rc) {
@@ -302,13 +335,23 @@ out:
         return fd;
 }
 
+int llapi_file_open(const char *name, int flags, int mode,
+                    unsigned long long stripe_size, int stripe_offset,
+                    int stripe_count, int stripe_pattern)
+{
+        return llapi_file_open_pool(name, flags, mode, stripe_size,
+                                    stripe_offset, stripe_count,
+                                    stripe_pattern, NULL);
+}
+
 int llapi_file_create(const char *name, unsigned long long stripe_size,
                       int stripe_offset, int stripe_count, int stripe_pattern)
 {
         int fd;
 
-        fd = llapi_file_open(name, O_CREAT | O_WRONLY, 0644, stripe_size,
-                             stripe_offset, stripe_count, stripe_pattern);
+        fd = llapi_file_open_pool(name, O_CREAT | O_WRONLY, 0644, stripe_size,
+                                  stripe_offset, stripe_count, stripe_pattern,
+                                  NULL);
         if (fd < 0)
                 return fd;
 
@@ -316,6 +359,203 @@ int llapi_file_create(const char *name, unsigned long long stripe_size,
         return 0;
 }
 
+int llapi_file_create_pool(const char *name, unsigned long long stripe_size,
+                           int stripe_offset, int stripe_count,
+                           int stripe_pattern, char *pool_name)
+{
+        int fd;
+
+        fd = llapi_file_open_pool(name, O_CREAT | O_WRONLY, 0644, stripe_size,
+                                  stripe_offset, stripe_count, stripe_pattern,
+                                  pool_name);
+        if (fd < 0)
+                return fd;
+
+        close(fd);
+        return 0;
+}
+
+
+static int print_pool_members(char *fs, char *pool_dir, char *pool_file)
+{
+        char path[MAXPATHLEN + 1];
+        char buf[1024];
+        FILE *fd;
+
+        llapi_printf(LLAPI_MSG_NORMAL, "Pool: %s.%s\n", fs, pool_file);
+        sprintf(path, "%s/%s", pool_dir, pool_file);
+        if ((fd = fopen(path, "r")) == NULL) {
+                llapi_err(LLAPI_MSG_ERROR, "Cannot open %s\n", path);
+                return -EINVAL;
+        }
+        while (fgets(buf, sizeof(buf), fd) != NULL)
+               llapi_printf(LLAPI_MSG_NORMAL, buf);
+
+        fclose(fd);
+        return 0;
+}
+
+/*
+ * search lustre fsname from pathname
+ *
+ */
+static int search_fsname(char *pathname, char *fsname)
+{
+        char *ptr;
+        FILE *fp;
+        struct mntent *mnt = NULL;
+
+        /* get the mount point */
+        fp = setmntent(MOUNTED, "r");
+        if (fp == NULL) {
+                 llapi_err(LLAPI_MSG_ERROR,
+                           "setmntent(%s) failed: %s:", MOUNTED,
+                           strerror (errno));
+                 return -EIO;
+        }
+        mnt = getmntent(fp);
+        while ((feof(fp) == 0) && ferror(fp) == 0) {
+                if (llapi_is_lustre_mnt(mnt)) {
+                        /* search by pathname */
+                        if (strncmp(mnt->mnt_dir, pathname,
+                                    strlen(mnt->mnt_dir)) == 0) {
+                                ptr = strchr(mnt->mnt_fsname, '/');
+                                if (ptr == NULL)
+                                        return -EINVAL;
+                                ptr++;
+                                strcpy(fsname, ptr);
+                                return 0;
+                        }
+                }
+                mnt = getmntent(fp);
+        }
+        endmntent(fp);
+        return -ENOENT;
+
+}
+
+/*
+ * find the pool directory path under /proc
+ * (can be also used to test if a fsname is known)
+ */
+static int poolpath(char *fsname, char *pathname, char *pool_pathname)
+{
+        int rc = 0;
+        glob_t glob_info;
+        char pattern[MAXPATHLEN + 1];
+        char buffer[MAXPATHLEN];
+
+        if (fsname == NULL) {
+                rc = search_fsname(pathname, buffer);
+                if (rc != 0)
+                        return rc;
+                fsname = buffer;
+                strcpy(pathname, fsname);
+        }
+
+        snprintf(pattern, MAXPATHLEN,
+                 "/proc/fs/lustre/lov/%s-*/pools",
+                 fsname);
+        rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
+        if (rc)
+                return -ENOENT;
+
+        if (glob_info.gl_pathc == 0) {
+                globfree(&glob_info);
+                return -ENOENT;
+        }
+
+        /* in fsname test mode, pool_pathname is NULL */
+        if (pool_pathname != NULL)
+                strcpy(pool_pathname, glob_info.gl_pathv[0]);
+
+        return 0;
+}
+
+int llapi_poollist(char *name)
+{
+        char *poolname;
+        char *fsname;
+        char rname[MAXPATHLEN + 1], pathname[MAXPATHLEN + 1];
+        char *ptr;
+        int rc = 0;
+
+        /* is name a pathname ? */
+        ptr = strchr(name, '/');
+        if (ptr != NULL) {
+                /* only absolute pathname is supported */
+                if (*name != '/')
+                        return -EINVAL;
+                if (!realpath(name, rname)) {
+                        rc = -errno;
+                        llapi_err(LLAPI_MSG_ERROR,
+                                  "llapi_poollist: invalid path '%s'",
+                                  name);
+                        return rc;
+                }
+
+                rc = poolpath(NULL, rname, pathname);
+                if (rc != 0) {
+                        errno = -rc;
+                        llapi_err(LLAPI_MSG_ERROR,
+                                  "llapi_poollist: '%s' is not"
+                                  " a Lustre filesystem",
+                                  name);
+                        return rc;
+                }
+                fsname = rname;
+                poolname = NULL;
+        } else {
+                /* name is FSNAME[.POOLNAME] */
+                fsname = name;
+                poolname = strchr(name, '.');
+                if (poolname != NULL) {
+                        *poolname = '\0';
+                        poolname++;
+                }
+                rc = poolpath(fsname, NULL, pathname);
+                if (rc != 0) {
+                        errno = -rc;
+                        llapi_err(LLAPI_MSG_ERROR,
+                                  "llapi_poollist: Lustre filesystem '%s'"
+                                  " not found", name);
+                        return rc;
+                }
+        }
+        if (rc != 0) {
+                errno = -rc;
+                llapi_err(LLAPI_MSG_ERROR,
+                          "llapi_poollist: Lustre filesystem '%s' not found",
+                          name);
+                return rc;
+        }
+
+        if (poolname != NULL) {
+                rc = print_pool_members(fsname, pathname, poolname);
+                poolname--;
+                *poolname = '.';
+        } else {
+                DIR *dir;
+                struct dirent *pool;
+
+                llapi_printf(LLAPI_MSG_NORMAL, "Pools from %s:\n", fsname);
+                if ((dir = opendir(pathname)) == NULL) {
+                        return -EINVAL;
+                }
+                while ((pool = readdir(dir)) != NULL) {
+                        if (!((pool->d_name[0] == '.') &&
+                              (pool->d_name[1] == '\0')) &&
+                            !((pool->d_name[0] == '.') &&
+                              (pool->d_name[1] == '.') &&
+                              (pool->d_name[2] == '\0')))
+                        llapi_printf(LLAPI_MSG_NORMAL, " %s.%s\n",
+                                     fsname, pool->d_name);
+                }
+                closedir(dir);
+        }
+        return rc;
+}
+
 typedef int (semantic_func_t)(char *path, DIR *parent, DIR *d,
                               void *data, struct dirent64 *de);
 
@@ -324,9 +564,9 @@ typedef int (semantic_func_t)(char *path, DIR *parent, DIR *d,
 
 static int common_param_init(struct find_param *param)
 {
-        param->lumlen = lov_mds_md_size(MAX_LOV_UUID_COUNT);
+        param->lumlen = lov_mds_md_size(MAX_LOV_UUID_COUNT, LOV_MAGIC_V3);
         if ((param->lmd = malloc(sizeof(lstat_t) + param->lumlen)) == NULL) {
-                llapi_err(LLAPI_MSG_ERROR, 
+                llapi_err(LLAPI_MSG_ERROR,
                           "error: allocation of %d bytes for ioctl",
                           sizeof(lstat_t) + param->lumlen);
                 return -ENOMEM;
@@ -357,12 +597,6 @@ int llapi_file_fget_lov_uuid(int fd, struct obd_uuid *lov_name)
         return rc;
 }
 
-/* deprecated in favour of llapi_file_fget_lov_uuid() in 1.8 and 2.0 */
-int llapi_file_get_lov_fuuid(int fd, struct obd_uuid *lov_name)
-{
-        return llapi_file_fget_lov_uuid(fd, lov_name);
-}
-
 int llapi_file_get_lov_uuid(const char *path, struct obd_uuid *lov_uuid)
 {
         int fd, rc;
@@ -370,7 +604,7 @@ int llapi_file_get_lov_uuid(const char *path, struct obd_uuid *lov_uuid)
         fd = open(path, O_RDONLY);
         if (fd < 0) {
                 rc = errno;
-                llapi_err(LLAPI_MSG_ERROR, "error opening %s\n", path);
+                llapi_err(LLAPI_MSG_ERROR, "error opening %s", path);
                 return rc;
         }
 
@@ -441,7 +675,7 @@ static int setup_obd_uuid(DIR *dir, char *dname, struct find_param *param)
         if (rc) {
                 if (errno != ENOTTY) {
                         rc = errno;
-                        llapi_err(LLAPI_MSG_ERROR, 
+                        llapi_err(LLAPI_MSG_ERROR,
                                   "error: can't get lov name: %s", dname);
                 } else {
                         rc = 0;
@@ -554,14 +788,89 @@ retry_get_uuids:
         return 0;
 }
 
-void lov_dump_user_lmm_v1(struct lov_user_md_v1 *lum, char *path, int is_dir,
-                          int obdindex, int quiet, int header, int body)
+static void lov_dump_user_lmm_join(struct lov_user_md_v1 *lum, char *path,
+                                   int is_dir, int obdindex, int quiet,
+                                   int header, int body)
+{
+        struct lov_user_md_join *lumj = (struct lov_user_md_join *)lum;
+        int i, obdstripe = 0;
+
+        if (obdindex != OBD_NOT_FOUND) {
+                for (i = 0; i < lumj->lmm_stripe_count; i++) {
+                        if (obdindex == lumj->lmm_objects[i].l_ost_idx) {
+                                llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
+                                obdstripe = 1;
+                                break;
+                        }
+                }
+        } else if (!quiet) {
+                llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
+                obdstripe = 1;
+        }
+
+        if (header && obdstripe == 1) {
+                llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic:          0x%08X\n",
+                             lumj->lmm_magic);
+                llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_gr:      "LPX64"\n",
+                             lumj->lmm_object_gr);
+                llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id:      "LPX64"\n",
+                             lumj->lmm_object_id);
+                llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_count:   %u\n",
+                             (int)lumj->lmm_stripe_count);
+                llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_size:    %u\n",
+                             lumj->lmm_stripe_size);
+                llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_pattern: %x\n",
+                             lumj->lmm_pattern);
+                llapi_printf(LLAPI_MSG_NORMAL, "lmm_extent_count:   %x\n",
+                             lumj->lmm_extent_count);
+        }
+
+        if (body) {
+                unsigned long long start = -1, end = 0;
+                if (!quiet && obdstripe == 1)
+                        llapi_printf(LLAPI_MSG_NORMAL,
+                                     "joined\tobdidx\t\t objid\t\tobjid\t\t "
+                                     "group\t\tstart\t\tend\n");
+                for (i = 0; i < lumj->lmm_stripe_count; i++) {
+                        int idx = lumj->lmm_objects[i].l_ost_idx;
+                        long long oid = lumj->lmm_objects[i].l_object_id;
+                        long long gr = lumj->lmm_objects[i].l_object_gr;
+                        if (obdindex == OBD_NOT_FOUND || obdindex == idx)
+                                llapi_printf(LLAPI_MSG_NORMAL,
+                                             "\t%6u\t%14llu\t%#13llx\t%14llu%s",
+                                             idx, oid, oid, gr,
+                                             obdindex == idx ? " *" : "");
+                        if (start != lumj->lmm_objects[i].l_extent_start ||
+                            end != lumj->lmm_objects[i].l_extent_end) {
+                                start = lumj->lmm_objects[i].l_extent_start;
+                                llapi_printf(LLAPI_MSG_NORMAL, "\t%14llu",
+                                             start);
+                                end = lumj->lmm_objects[i].l_extent_end;
+                                if (end == (unsigned long long)-1)
+                                        llapi_printf(LLAPI_MSG_NORMAL,
+                                                     "\t\tEOF\n");
+                                else
+                                        llapi_printf(LLAPI_MSG_NORMAL,
+                                                     "\t\t%llu\n", end);
+                        } else {
+                                llapi_printf(LLAPI_MSG_NORMAL, "\t\t\t\t\n");
+                        }
+                }
+                llapi_printf(LLAPI_MSG_NORMAL, "\n");
+        }
+}
+
+static void lov_dump_user_lmm_v1v3(struct lov_user_md *lum, char *pool_name,
+                                   struct lov_user_ost_data_v1 *objects,
+                                   char *path,
+                                   int is_dir, int obdindex, int quiet,
+                                   int header, int body)
 {
         int i, obdstripe = 0;
 
         if (obdindex != OBD_NOT_FOUND) {
                 for (i = 0; !is_dir && i < lum->lmm_stripe_count; i++) {
-                        if (obdindex == lum->lmm_objects[i].l_ost_idx) {
+                        if (obdindex == objects[i].l_ost_idx) {
                                 llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
                                 obdstripe = 1;
                                 break;
@@ -579,14 +888,16 @@ void lov_dump_user_lmm_v1(struct lov_user_md_v1 *lum, char *path, int is_dir,
                                 llapi_printf(LLAPI_MSG_NORMAL, "(Default) ");
                                 lum->lmm_object_gr = LOV_OBJECT_GROUP_CLEAR;
                         }
-                        llapi_printf(LLAPI_MSG_NORMAL, 
+                        llapi_printf(LLAPI_MSG_NORMAL,
                                      "stripe_count: %d stripe_size: %u "
-                                     "stripe_offset: %d\n",
+                                     "stripe_offset: %d%s%s\n",
                                      lum->lmm_stripe_count == (__u16)-1 ? -1 :
-                                     lum->lmm_stripe_count,
+                                                        lum->lmm_stripe_count,
                                      lum->lmm_stripe_size,
                                      lum->lmm_stripe_offset == (__u16)-1 ? -1 :
-                                     lum->lmm_stripe_offset);
+                                                        lum->lmm_stripe_offset,
+                                     pool_name != NULL ? " pool: " : "",
+                                     pool_name != NULL ? pool_name : "");
                 }
                 return;
         }
@@ -599,111 +910,47 @@ void lov_dump_user_lmm_v1(struct lov_user_md_v1 *lum, char *path, int is_dir,
                 llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id:      "LPX64"\n",
                              lum->lmm_object_id);
                 llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_count:   %u\n",
-                             (int)lum->lmm_stripe_count);
+                             lum->lmm_stripe_count);
                 llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_size:    %u\n",
                              lum->lmm_stripe_size);
                 llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_pattern: %x\n",
                              lum->lmm_pattern);
+                if (pool_name != NULL)
+                        llapi_printf(LLAPI_MSG_NORMAL,
+                                     "lmm_pool_name:      %s\n", pool_name);
         }
 
         if (body) {
                 if ((!quiet) && (obdstripe == 1))
-                        llapi_printf(LLAPI_MSG_NORMAL, 
+                        llapi_printf(LLAPI_MSG_NORMAL,
                                      "\tobdidx\t\t objid\t\tobjid\t\t group\n");
 
                 for (i = 0; i < lum->lmm_stripe_count; i++) {
-                        int idx = lum->lmm_objects[i].l_ost_idx;
-                        long long oid = lum->lmm_objects[i].l_object_id;
-                        long long gr = lum->lmm_objects[i].l_object_gr;
+                        int idx = objects[i].l_ost_idx;
+                        long long oid = objects[i].l_object_id;
+                        long long gr = objects[i].l_object_gr;
                         if ((obdindex == OBD_NOT_FOUND) || (obdindex == idx))
-                                llapi_printf(LLAPI_MSG_NORMAL, 
-                                             "\t%6u\t%14llu\t%#13llx\t%14llu%s\n",
-                                             idx, oid, oid, gr,
-                                             obdindex == idx ? " *" : "");
+                                llapi_printf(LLAPI_MSG_NORMAL,
+                                           "\t%6u\t%14llu\t%#13llx\t%14llu%s\n",
+                                           idx, oid, oid, gr,
+                                           obdindex == idx ? " *" : "");
                 }
                 llapi_printf(LLAPI_MSG_NORMAL, "\n");
         }
 }
 
-void lov_dump_user_lmm_join(struct lov_user_md_v1 *lum, char *path,
-                            int is_dir, int obdindex, int quiet,
-                            int header, int body)
-{
-        struct lov_user_md_join *lumj = (struct lov_user_md_join *)lum;
-        int i, obdstripe = 0;
-
-        if (obdindex != OBD_NOT_FOUND) {
-                for (i = 0; i < lumj->lmm_stripe_count; i++) {
-                        if (obdindex == lumj->lmm_objects[i].l_ost_idx) {
-                                llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
-                                obdstripe = 1;
-                                break;
-                        }
-                }
-        } else if (!quiet) {
-                llapi_printf(LLAPI_MSG_NORMAL, "%s\n", path);
-                obdstripe = 1;
-        }
-
-        if (header && obdstripe == 1) {
-                llapi_printf(LLAPI_MSG_NORMAL, "lmm_magic:          0x%08X\n",  
-                             lumj->lmm_magic);
-                llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_gr:      "LPX64"\n", 
-                             lumj->lmm_object_gr);
-                llapi_printf(LLAPI_MSG_NORMAL, "lmm_object_id:      "LPX64"\n", 
-                             lumj->lmm_object_id);
-                llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_count:   %u\n", 
-                             (int)lumj->lmm_stripe_count);
-                llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_size:    %u\n",
-                             lumj->lmm_stripe_size);
-                llapi_printf(LLAPI_MSG_NORMAL, "lmm_stripe_pattern: %x\n",
-                             lumj->lmm_pattern);
-                llapi_printf(LLAPI_MSG_NORMAL, "lmm_extent_count:   %x\n",
-                             lumj->lmm_extent_count);
-        }
-
-        if (body) {
-                unsigned long long start = -1, end = 0;
-                if (!quiet && obdstripe == 1)
-                        llapi_printf(LLAPI_MSG_NORMAL, 
-                                     "joined\tobdidx\t\t objid\t\tobjid\t\t group"
-                                     "\t\tstart\t\tend\n");
-                for (i = 0; i < lumj->lmm_stripe_count; i++) {
-                        int idx = lumj->lmm_objects[i].l_ost_idx;
-                        long long oid = lumj->lmm_objects[i].l_object_id;
-                        long long gr = lumj->lmm_objects[i].l_object_gr;
-                        if (obdindex == OBD_NOT_FOUND || obdindex == idx)
-                                llapi_printf(LLAPI_MSG_NORMAL, 
-                                             "\t%6u\t%14llu\t%#13llx\t%14llu%s",
-                                             idx, oid, oid, gr,
-                                             obdindex == idx ? " *" : "");
-                        if (start != lumj->lmm_objects[i].l_extent_start ||
-                            end != lumj->lmm_objects[i].l_extent_end) {
-                                start = lumj->lmm_objects[i].l_extent_start;
-                                llapi_printf(LLAPI_MSG_NORMAL, "\t%14llu", start);
-                                end = lumj->lmm_objects[i].l_extent_end;
-                                if (end == (unsigned long long)-1)
-                                        llapi_printf(LLAPI_MSG_NORMAL, "\t\tEOF\n");
-                                else
-                                        llapi_printf(LLAPI_MSG_NORMAL, "\t\t%llu\n",
-                                                  end);
-                        } else {
-                                llapi_printf(LLAPI_MSG_NORMAL, "\t\t\t\t\n");
-                        }
-                }
-                llapi_printf(LLAPI_MSG_NORMAL, "\n");
-        }
-}
 
 void llapi_lov_dump_user_lmm(struct find_param *param,
                              char *path, int is_dir)
 {
         switch(*(__u32 *)&param->lmd->lmd_lmm) { /* lum->lmm_magic */
         case LOV_USER_MAGIC_V1:
-                lov_dump_user_lmm_v1(&param->lmd->lmd_lmm, path, is_dir,
-                                      param->obdindex, param->quiet,
-                                      param->verbose,
-                                      (param->verbose || !param->obduuid));
+                lov_dump_user_lmm_v1v3(&param->lmd->lmd_lmm, NULL,
+                                       param->lmd->lmd_lmm.lmm_objects,
+                                       path, is_dir,
+                                       param->obdindex, param->quiet,
+                                       param->verbose,
+                                       (param->verbose || !param->obduuid));
                 break;
         case LOV_USER_MAGIC_JOIN:
                 lov_dump_user_lmm_join(&param->lmd->lmd_lmm, path, is_dir,
@@ -711,10 +958,27 @@ void llapi_lov_dump_user_lmm(struct find_param *param,
                                        param->verbose,
                                        (param->verbose || !param->obduuid));
                 break;
+        case LOV_USER_MAGIC_V3: {
+                char pool_name[LOV_MAXPOOLNAME + 1];
+                struct lov_user_ost_data_v1 *objects;
+                struct lov_user_md_v3 *lmmv3 = (void *)&param->lmd->lmd_lmm;
+
+                strncpy(pool_name, lmmv3->lmm_pool_name, LOV_MAXPOOLNAME);
+                pool_name[LOV_MAXPOOLNAME] = '\0';
+                objects = lmmv3->lmm_objects;
+                lov_dump_user_lmm_v1v3(&param->lmd->lmd_lmm, pool_name,
+                                       objects, path, is_dir,
+                                       param->obdindex, param->quiet,
+                                       param->verbose,
+                                       (param->verbose || !param->obduuid));
+                break;
+        }
         default:
-                llapi_printf(LLAPI_MSG_NORMAL, 
-                             "unknown lmm_magic:  %#x (expecting %#x)\n",
-                       *(__u32 *)&param->lmd->lmd_lmm, LOV_USER_MAGIC_V1);
+                llapi_printf(LLAPI_MSG_NORMAL, "unknown lmm_magic:  %#x "
+                             "(expecting one of %#x %#x %#x)\n",
+                             param->lmd->lmd_lmm.lmm_magic,
+                             LOV_USER_MAGIC_V1, LOV_USER_MAGIC_JOIN,
+                             LOV_USER_MAGIC_V3);
                 return;
         }
 }
@@ -799,7 +1063,8 @@ int llapi_mds_getfileinfo(char *path, DIR *parent,
 
         fname = (fname == NULL ? path : fname + 1);
         /* retrieve needed file info */
-        strncpy((char *)lmd, fname, lov_mds_md_size(MAX_LOV_UUID_COUNT));
+        strncpy((char *)lmd, fname, lov_mds_md_size(MAX_LOV_UUID_COUNT,
+                LOV_MAGIC));
         ret = ioctl(dirfd(parent), IOC_MDC_GETFILEINFO, (void *)lmd);
 
         if (ret) {
@@ -808,20 +1073,20 @@ int llapi_mds_getfileinfo(char *path, DIR *parent,
                          * Do the regular lstat(2) instead. */
                         ret = lstat_f(path, st);
                         if (ret) {
-                                llapi_err(LLAPI_MSG_ERROR, 
+                                llapi_err(LLAPI_MSG_ERROR,
                                           "error: %s: lstat failed for %s",
                                           __FUNCTION__, path);
                                 return ret;
                         }
                 } else if (errno == ENOENT) {
-                        llapi_err(LLAPI_MSG_WARN, 
-                                  "warning: %s: %s does not exist", 
+                        llapi_err(LLAPI_MSG_WARN,
+                                  "warning: %s: %s does not exist",
                                   __FUNCTION__, path);
                         return -ENOENT;
                 } else {
-                        llapi_err(LLAPI_MSG_ERROR, 
-                                  "error: %s: IOC_MDC_GETFILEINFO failed for %s",
-                                  __FUNCTION__, path);
+                        llapi_err(LLAPI_MSG_ERROR,
+                                 "error: %s: IOC_MDC_GETFILEINFO failed for %s",
+                                 __FUNCTION__, path);
                         return ret;
                 }
         }
@@ -899,8 +1164,9 @@ static int llapi_semantic_traverse(char *path, int size, DIR *parent,
                                              ((struct find_param *)data)->lmd);
                         if (ret == 0) {
                                 ((struct find_param *)data)->have_fileinfo = 1;
-                                dent->d_type = llapi_filetype_dir_table[st->st_mode &
-                                                                        S_IFMT];
+                                dent->d_type =
+                                        llapi_filetype_dir_table[st->st_mode &
+                                                                 S_IFMT];
                         }
                         if (ret == -ENOENT)
                                 continue;
@@ -908,7 +1174,7 @@ static int llapi_semantic_traverse(char *path, int size, DIR *parent,
 
                 switch (dent->d_type) {
                 case DT_UNKNOWN:
-                        llapi_err(LLAPI_MSG_ERROR, 
+                        llapi_err(LLAPI_MSG_ERROR,
                                   "error: %s: '%s' is UNKNOWN type %d",
                                   __FUNCTION__, dent->d_name, dent->d_type);
                         break;
@@ -1039,6 +1305,7 @@ static int cb_find_init(char *path, DIR *parent, DIR *dir,
                         void *data, struct dirent64 *de)
 {
         struct find_param *param = (struct find_param *)data;
+        struct lov_user_md_v3 *lmmv3 = (void *)&param->lmd->lmd_lmm;
         int decision = 1; /* 1 is accepted; -1 is rejected. */
         lstat_t *st = &param->lmd->lmd_st;
         int lustre_fs = 1;
@@ -1103,18 +1370,18 @@ static int cb_find_init(char *path, DIR *parent, DIR *dir,
                         lustre_fs = 0;
                         ret = lstat_f(path, st);
                         if (ret) {
-                                llapi_err(LLAPI_MSG_ERROR, 
+                                llapi_err(LLAPI_MSG_ERROR,
                                           "error: %s: lstat failed for %s",
                                           __FUNCTION__, path);
                                 return ret;
                         }
                 } else if (errno == ENOENT) {
-                        llapi_err(LLAPI_MSG_WARN, 
+                        llapi_err(LLAPI_MSG_WARN,
                                   "warning: %s: %s does not exist",
                                   __FUNCTION__, path);
                         goto decided;
                 } else {
-                        llapi_err(LLAPI_MSG_ERROR, "error: %s: %s failed for %s",
+                        llapi_err(LLAPI_MSG_ERROR,"error: %s: %s failed for %s",
                                   __FUNCTION__, dir ? "LL_IOC_MDC_GETINFO" :
                                   "IOC_MDC_GETFILEINFO", path);
                         return ret;
@@ -1141,6 +1408,22 @@ static int cb_find_init(char *path, DIR *parent, DIR *dir,
                 }
         }
 
+        if (param->check_pool) {
+                /* empty requested pool is taken as no pool search => V1 */
+                if ((param->lmd->lmd_lmm.lmm_magic == LOV_USER_MAGIC_V1 &&
+                     param->poolname[0] == '\0') ||
+                    (param->lmd->lmd_lmm.lmm_magic == LOV_USER_MAGIC_V3 &&
+                     (strncmp(lmmv3->lmm_pool_name, param->poolname,
+                              LOV_MAXPOOLNAME) == 0 ||
+                      strcmp(param->poolname, "*") == 0))) {
+                        if (param->exclude_pool)
+                                goto decided;
+                } else {
+                        if (!param->exclude_pool)
+                                goto decided;
+                }
+        }
+
         /* Check the time on mds. */
         if (!decision) {
                 int for_mds;
@@ -1201,11 +1484,18 @@ static int cb_find_init(char *path, DIR *parent, DIR *dir,
                         goto decided;
                 } else {
                         int i, j;
+                        struct lov_user_ost_data_v1 *lmm_objects;
+
+                        if (param->lmd->lmd_lmm.lmm_magic == LOV_USER_MAGIC_V3)
+                                lmm_objects = lmmv3->lmm_objects;
+                        else
+                                lmm_objects = param->lmd->lmd_lmm.lmm_objects;
+
                         for (i = 0;
                              i < param->lmd->lmd_lmm.lmm_stripe_count; i++) {
                                 for (j = 0; j < param->num_obds; j++) {
                                         if (param->obdindexes[j] ==
-                                            param->lmd->lmd_lmm.lmm_objects[i].l_ost_idx)
+                                            lmm_objects[i].l_ost_idx)
                                                 goto obd_matches;
                                 }
                         }
@@ -1232,12 +1522,12 @@ obd_matches:
 
                 if (ret) {
                         if (errno == ENOENT) {
-                                llapi_err(LLAPI_MSG_ERROR, 
+                                llapi_err(LLAPI_MSG_ERROR,
                                           "warning: %s: %s does not exist",
                                           __FUNCTION__, path);
                                 goto decided;
                         } else {
-                                llapi_err(LLAPI_MSG_ERROR, 
+                                llapi_err(LLAPI_MSG_ERROR,
                                           "%s: IOC_LOV_GETINFO on %s failed",
                                           __FUNCTION__, path);
                                 return ret;
@@ -1342,20 +1632,20 @@ static int cb_getstripe(char *path, DIR *parent, DIR *d, void *data,
         if (ret) {
                 if (errno == ENODATA) {
                         if (!param->obduuid && !param->quiet)
-                                llapi_printf(LLAPI_MSG_NORMAL, 
+                                llapi_printf(LLAPI_MSG_NORMAL,
                                              "%s has no stripe info\n", path);
                         goto out;
                 } else if (errno == ENOTTY) {
-                        llapi_err(LLAPI_MSG_ERROR, 
+                        llapi_err(LLAPI_MSG_ERROR,
                                   "%s: '%s' not on a Lustre fs?",
                                   __FUNCTION__, path);
                 } else if (errno == ENOENT) {
-                        llapi_err(LLAPI_MSG_WARN, 
+                        llapi_err(LLAPI_MSG_WARN,
                                   "warning: %s: %s does not exist",
                                   __FUNCTION__, path);
                         goto out;
                 } else {
-                        llapi_err(LLAPI_MSG_ERROR, 
+                        llapi_err(LLAPI_MSG_ERROR,
                                   "error: %s: %s failed for %s",
                                    __FUNCTION__, d ? "LL_IOC_LOV_GETSTRIPE" :
                                   "IOC_MDC_GETFILESTRIPE", path);
@@ -1380,7 +1670,7 @@ int llapi_getstripe(char *path, struct find_param *param)
         int ret = 0, len = strlen(path);
 
         if (len > PATH_MAX) {
-                llapi_err(LLAPI_MSG_ERROR, 
+                llapi_err(LLAPI_MSG_ERROR,
                           "%s: Path name '%s' is too long",
                           __FUNCTION__, path);
                 return -EINVAL;
@@ -1426,7 +1716,7 @@ int llapi_obd_statfs(char *path, __u32 type, __u32 index,
         data.ioc_plen2 = sizeof(struct obd_uuid);
 
         if ((rc = obd_ioctl_pack(&data, &rawbuf, sizeof(raw))) != 0) {
-                llapi_err(LLAPI_MSG_ERROR, 
+                llapi_err(LLAPI_MSG_ERROR,
                           "llapi_obd_statfs: error packing ioctl data");
                 return rc;
         }
@@ -1437,7 +1727,7 @@ int llapi_obd_statfs(char *path, __u32 type, __u32 index,
 
         if (fd < 0) {
                 rc = errno ? -errno : -EBADF;
-                llapi_err(LLAPI_MSG_ERROR, "error: %s: opening '%s'", 
+                llapi_err(LLAPI_MSG_ERROR, "error: %s: opening '%s'",
                           __FUNCTION__, path);
                 return rc;
         }
@@ -1473,10 +1763,10 @@ int llapi_ping(char *obd_type, char *obd_name)
 
         if (rc == 1)
                 return 0;
-        return errno;
+        return rc;
 }
 
-int llapi_target_iterate(int type_num, char **obd_type, void *args, llapi_cb_t cb)
+int llapi_target_iterate(int type_num, char **obd_type,void *args,llapi_cb_t cb)
 {
         char buf[MAX_STRING_SIZE];
         FILE *fp = fopen(DEVICES_LIST, "r");
@@ -1530,9 +1820,7 @@ static void do_target_check(char *obd_type_name, char *obd_name,
         int rc;
 
         rc = llapi_ping(obd_type_name, obd_name);
-        if (rc == ENOTCONN || rc == ESHUTDOWN) {
-                llapi_printf(LLAPI_MSG_NORMAL, "%s inactive.\n", obd_name);
-        } else if (rc) {
+        if (rc) {
                 llapi_err(LLAPI_MSG_ERROR, "error: check '%s'", obd_name);
         } else {
                 llapi_printf(LLAPI_MSG_NORMAL, "%s active.\n", obd_name);
@@ -1686,11 +1974,11 @@ static int cb_quotachown(char *path, DIR *parent, DIR *d, void *data,
         if (rc) {
                 if (errno == ENODATA) {
                         if (!param->obduuid && !param->quiet)
-                                llapi_err(LLAPI_MSG_ERROR, 
+                                llapi_err(LLAPI_MSG_ERROR,
                                           "%s has no stripe info", path);
                         rc = 0;
                 } else if (errno == ENOENT) {
-                        llapi_err(LLAPI_MSG_ERROR, 
+                        llapi_err(LLAPI_MSG_ERROR,
                                   "warning: %s: %s does not exist",
                                   __FUNCTION__, path);
                         rc = 0;
@@ -1714,7 +2002,7 @@ static int cb_quotachown(char *path, DIR *parent, DIR *d, void *data,
 
         rc = chmod(path, st->st_mode);
         if (rc)
-                llapi_err(LLAPI_MSG_ERROR, "error: chmod %s (%hu)", 
+                llapi_err(LLAPI_MSG_ERROR, "error: chmod %s (%hu)",
                           path, st->st_mode);
 
         return rc;
diff --git a/lustre/utils/ll_recover_lost_found_objs.c b/lustre/utils/ll_recover_lost_found_objs.c
index 449cfae..85f1e1d 100644
--- a/lustre/utils/ll_recover_lost_found_objs.c
+++ b/lustre/utils/ll_recover_lost_found_objs.c
@@ -401,7 +401,7 @@ int main(int argc, char **argv)
 	struct stat stat_buf;
 	char tmp_path[PATH_MAX];
 	char mount_path[PATH_MAX] = {0};
-	char c;
+	int c;
 	int retval;
 
 	progname = argv[0];
diff --git a/lustre/utils/llog_reader.c b/lustre/utils/llog_reader.c
index b071aa1..64f7015 100644
--- a/lustre/utils/llog_reader.c
+++ b/lustre/utils/llog_reader.c
@@ -167,7 +167,7 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog,
                 recs_pr[i] = cur_rec;
 
                 if (ext2_test_bit(idx, (*llog)->llh_bitmap)) {
-                        if (le32_to_cpu(cur_rec->lrh_type) != OBD_CFG_REC) 
+                        if (le32_to_cpu(cur_rec->lrh_type) != OBD_CFG_REC)
                                 printf("rec #%d type=%x len=%u\n", idx,
                                        cur_rec->lrh_type, cur_rec->lrh_len);
                 } else {
@@ -176,7 +176,7 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog,
                         /* The header counts only set records */
                         i--;
                 }
-                
+
                 ptr += le32_to_cpu(cur_rec->lrh_len);
                 if ((ptr - file_buf) > file_size) {
                         printf("The log is corrupt (too big at %d)\n", i);
@@ -238,7 +238,7 @@ static void print_1_cfg(struct lustre_cfg *lcfg)
 
         if (lcfg->lcfg_nid)
                 printf("nid=%s("LPX64")  ", libcfs_nid2str(lcfg->lcfg_nid),
-                       lcfg->lcfg_nid);
+                       (__u64)lcfg->lcfg_nid);
         if (lcfg->lcfg_nal)
                 printf("nal=%d ", lcfg->lcfg_nal);
         for (i = 0; i <  lcfg->lcfg_bufcount; i++)
@@ -339,7 +339,10 @@ void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip)
         }
         case(LCFG_SET_TIMEOUT):{
                 printf("set_timeout=%d ", lcfg->lcfg_num);
-                print_1_cfg(lcfg);
+                break;
+        }
+        case(LCFG_SET_LDLM_TIMEOUT):{
+                printf("set_ldlm_timeout=%d ", lcfg->lcfg_num);
                 break;
         }
         case(LCFG_SET_UPCALL):{
@@ -368,7 +371,7 @@ void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip)
                 }
 
                 if (marker->cm_flags & CM_EXCLUDE) {
-                        if (marker->cm_flags & CM_START) 
+                        if (marker->cm_flags & CM_START)
                                 printf("EXCLUDE START ");
                         else
                                 printf("EXCLUDE END   ");
@@ -409,6 +412,26 @@ void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip)
                        createtime, canceltime);
                 break;
         }
+        case(LCFG_POOL_NEW):{
+                printf("pool new ");
+                print_1_cfg(lcfg);
+                break;
+        }
+        case(LCFG_POOL_ADD):{
+                printf("pool add ");
+                print_1_cfg(lcfg);
+                break;
+        }
+        case(LCFG_POOL_REM):{
+                printf("pool remove ");
+                print_1_cfg(lcfg);
+                break;
+        }
+        case(LCFG_POOL_DEL):{
+                printf("pool destroy ");
+                print_1_cfg(lcfg);
+                break;
+        }
         default:
                 printf("unsupported cmd_code = %x\n",cmd);
         }
@@ -420,16 +443,16 @@ void print_records(struct llog_rec_hdr **recs, int rec_number)
 {
         __u32 lopt;
         int i, skip = 0;
-        
+
         for(i = 0; i < rec_number; i++) {
                 printf("#%.2d (%.3d)", le32_to_cpu(recs[i]->lrh_index),
                        le32_to_cpu(recs[i]->lrh_len));
 
                 lopt = le32_to_cpu(recs[i]->lrh_type);
 
-                if (recs[i]->padding == CANCELLED) 
+                if (recs[i]->padding == CANCELLED)
                         printf("NOT SET ");
-            
+
                 if (lopt == OBD_CFG_REC) {
                         struct lustre_cfg *lcfg;
                         lcfg = (struct lustre_cfg *)((char*)(recs[i]) +
diff --git a/lustre/utils/llverfs.c b/lustre/utils/llverfs.c
index 613d1b8..4863d86 100644
--- a/lustre/utils/llverfs.c
+++ b/lustre/utils/llverfs.c
@@ -498,10 +498,10 @@ int main(int argc, char **argv)
 	FILE *countfile = NULL;
 	char filecount[PATH_MAX];
 	unsigned long dir_num = 0, dir_num_orig = 0;/* starting directory */
-	char c;
+	int c;
 
 	progname = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0];
-	while ((c = (char)getopt_long(argc, argv, "t:rwvplo:h",
+	while ((c = getopt_long(argc, argv, "t:rwvplo:h",
 				      longopts, NULL)) != -1) {
 		switch (c) {
 		case 'c':
diff --git a/lustre/utils/loadgen.c b/lustre/utils/loadgen.c
index 35ba76b..92f63b5 100644
--- a/lustre/utils/loadgen.c
+++ b/lustre/utils/loadgen.c
@@ -965,7 +965,7 @@ static int loadgen_wait(int argc, char **argv)
 
 static int loadgen_init(int argc, char **argv)
 {
-        char *args[3];
+        char *args[4];
         int rc;
 
         sprintf(cmdname, "%s", argv[0]);
diff --git a/lustre/utils/lr_reader.c b/lustre/utils/lr_reader.c
index 996f4d9..5a2b11f 100644
--- a/lustre/utils/lr_reader.c
+++ b/lustre/utils/lr_reader.c
@@ -39,6 +39,10 @@
  */
  /* Safely read the last_rcvd file from a device */
 
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
@@ -122,8 +126,8 @@ int main(int argc, char *const argv[])
 
         memset(cmd, 0, sizeof(cmd));
         sprintf(cmd,
-                "debugfs -c -R 'dump /%s %s/%s' %s",
-                LAST_RCVD, tmpdir, LAST_RCVD, dev);
+                "%s -c -R 'dump /%s %s/%s' %s",
+                DEBUGFS, LAST_RCVD, tmpdir, LAST_RCVD, dev);
 
         ret = run_command(cmd);
         if (ret) {
@@ -193,8 +197,8 @@ int main(int argc, char *const argv[])
                 /* Construct debugfs command line. */
                 memset(cmd, 0, sizeof(cmd));
                 sprintf(cmd,
-                        "debugfs -c -R 'rdump /%s %s' %s",
-                        MDT_LOGS_DIR, tmpdir, dev);
+                        "%s -c -R 'rdump /%s %s' %s",
+                        DEBUGFS, MDT_LOGS_DIR, tmpdir, dev);
 
                 run_command(cmd);
 
diff --git a/lustre/utils/lshowmount.c b/lustre/utils/lshowmount.c
index 4b2675f..40d219f 100644
--- a/lustre/utils/lshowmount.c
+++ b/lustre/utils/lshowmount.c
@@ -1,3 +1,44 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/utils/lshowmount.h
+ *
+ * Author: Herb Wartens <wartens2 at llnl.gov>
+ * Author: Jim Garlick <garlick at llnl.gov>
+ */
+
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
@@ -13,399 +54,172 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <errno.h>
-#include "lshowmount.h"
-#include "hash.h"
-#include "hostlist.h"
-
-#define PROGNAME "lshowmount"
-
-extern int errno;
-static int enumerate = 0;
-static int lookup    = 0;
-static int verbose   = 0;
+#include <libgen.h>
 
-static int totalexports = 0;
-static int totalfailures = 0;
+#include "nidlist.h"
 
-static struct option long_options[] = {
-    {"enumerate", 0, 0, 'e'},
-    {"help",      0, 0, 'h'},
-    {"lookup",    0, 0, 'l'},
-    {"verbose",   0, 0, 'v'},
-    {0, 0, 0, 0}
-};
-
-inline int
-lshowmount_hash_strcmp(const void *key1, const void *key2)
-{
-    return strcmp((char *) key1, (char *) key2);
+#define PROC_DIRS {                     \
+        "/proc/fs/lustre/mgs",          \
+        "/proc/fs/lustre/mds",          \
+        "/proc/fs/lustre/obdfilter",    \
+        NULL,                           \
 }
+#define PROC_EXPORTS_TMPL       "%s/%s/exports"
+#define PROC_UUID_TMPL          "%s/%s/uuid"
 
-inline void
-lshowmount_hash_hostlist_freeitem(void *data)
-{
-    hostlist_t hl = NULL;
+static void print_nids(NIDList nidlist, int lookup, int enumerate, int indent);
+static int lshowmount(int lookup, int enumerate, int verbose);
+static void read_exports(char *exports, NIDList nidlist);
 
-    if (data == NULL) {
-        return;
-    }
+char *prog;
 
-    hl = (hostlist_t) data;
-    hostlist_destroy(hl);
-}
+#define OPTIONS "ehlv"
+static struct option long_options[] = {
+        {"enumerate", no_argument, 0, 'e'},
+        {"help",      no_argument, 0, 'h'},
+        {"lookup",    no_argument, 0, 'l'},
+        {"verbose",   no_argument, 0, 'v'},
+        {0, 0, 0, 0},
+};
 
-inline int
-is_ipaddress(const char *str)
+static void usage(void)
 {
-    int rc = 0;
-    int quad[4];
-
-    rc = sscanf(str, "%d.%d.%d.%d", &quad[0], &quad[1], &quad[2], &quad[3]);
-    if (rc == 4) {
-        return 1;
-    }
-    return 0;
+        fprintf(stderr, "usage: %s [-e] [-h] [-l] [-v]\n", prog);
+        exit(1);
 }
 
-inline void
-lshowmount_gethostname(const char *src, char *dst, int dstsize)
+int main(int argc, char **argv)
 {
-    struct hostent *hostptr = NULL;
-    char tmpsrc[4];
-    int rc = 0;
-
-    memset(dst, 0, sizeof(char) * dstsize);
-    if (lookup && is_ipaddress(src)) {
-        rc = inet_pton(AF_INET, src, tmpsrc);
-
-        if (rc <= 0) {
-            strncpy(dst, src, dstsize);
-            return;
+        int opt, optidx = 0;
+        int lopt = 0;
+        int vopt = 0;
+        int eopt = 0;
+
+        prog = basename(argv[0]);
+
+        while ((opt = getopt_long(argc, argv, OPTIONS, long_options, &optidx)) != -1) {
+                switch (opt) {
+                        case 'e':       /* --enumerate */
+                                eopt = 1;
+                                break;
+                        case 'l':       /* --lookup */
+                                lopt = 1;
+                                break;
+                        case 'v':       /* --verbose */
+                                vopt = 1;
+                                break;
+                        case 'h':       /* --help */
+                        default:
+                                usage();
+                }
         }
-        else {
-            hostptr = gethostbyaddr(tmpsrc, 4, AF_INET);
-            if (hostptr == NULL) {
-                strncpy(dst, src, dstsize);
-                return;
-            }
-            else {
-                strncpy(dst, hostptr->h_name, dstsize);
-                return;
-            }
+
+        if (lshowmount(lopt, eopt, vopt) == 0) {
+                fprintf(stderr, "%s: lustre server modules not loaded\n", prog);
+                exit(1);
         }
-    }
-    strncpy(dst, src, dstsize);
+        exit(0);
 }
 
-void
-lshowmount_print_hosts(char** network,
-                       hash_t network_hash)
+static void print_nids(NIDList nidlist, int lookup, int enumerate, int indent)
 {
-    hostlist_t hl = NULL;
-    hostlist_iterator_t itr = NULL;
-    char *hosts = NULL;
-    int numnets = 0, numhosts = 0, i = 0;
-
-    if (network == NULL || network_hash == NULL) {
-        return;
-    }
-
-    numnets = hash_count(network_hash);
-    for (i = 0; i < numnets; i++) {
-        errno = 0;
-        hl = hash_remove(network_hash, network[i]);
-        if (hl == NULL) {
-            continue;
-        }
-        hostlist_uniq(hl);
-        numhosts = hostlist_count(hl);
-
-        if (numhosts > 0) {
-            if (enumerate) {
-                itr = hostlist_iterator_create(hl);
-
-                /* setup argument */
-                while ((hosts = hostlist_next(itr)) != NULL) {
-                    printf("    %s@%s\n", hosts, network[i]);
-                }
-                hostlist_iterator_destroy(itr);
-            }
-            else {
-                hosts = malloc(sizeof(char) * (numhosts) * (NID_MAX+1));
-                if (hosts == NULL) {
-                    fprintf(stderr, "warning: could not allocate buffer "
-                                    "to print hostrange\n");
-                    return;
+        char *s, *sep = "\n", *pfx = "";
+
+        if (lookup)
+                nl_lookup_ip(nidlist);
+        nl_sort(nidlist);
+        nl_uniq(nidlist);
+        if (nl_count(nidlist) > 0) {
+                if (indent) {
+                        sep = "\n    ";
+                        pfx = "    ";
                 }
-                hostlist_ranged_string(hl, sizeof(char) *
-                                           numhosts *
-                                           (NID_MAX+1), hosts);
-                printf("    %s@%s\n", hosts, network[i]);
-                free(hosts);
-                hosts = NULL;
-            }
+                if (enumerate)
+                        s = nl_string(nidlist, sep);
+                else
+                        s = nl_xstring(nidlist, sep);
+                printf("%s%s\n", pfx, s);
+                free(s);
         }
-        memset(network[i], 0, sizeof(char) * (LNET_NETWORK_TYPE_MAX+1));
-        lshowmount_hash_hostlist_freeitem(hl);
-    }
 }
 
-void usage(void)
+static int lshowmount(int lookup, int enumerate, int verbose)
 {
-	fprintf(stderr, "usage: %s [-e] [-h] [-l] [-v]\n", PROGNAME);
-}
-
-int getclients(char*  procpath,
-               char** network,
-               hash_t network_hash)
-{
-    DIR *dirp, *dirp2;
-    struct dirent *dp, *dp2;
-    char path[PATH_MAX+1];
-    char nid[NID_MAX+1], addr[NID_MAX+1];
-    int size = PATH_MAX+1, sizeleft, sizeleft2;
-    int tmplen, tmplen2, idx, rc = 0;
-    char *tmp, *tmp2;
-    hostlist_t hl;
-
-    if (procpath == NULL) {
-        return -1;
-    }
-
-    /* It is not an error if we cannot open
-     * procpath since we are not sure if this
-     * node is an mgs, mds, and/or oss */
-    errno = 0;
-    dirp = opendir(procpath);
-    if (dirp == NULL) {
-        return 0;
-    }
-
-    do {
-        errno = 0;
-        dp = readdir(dirp);
-        if (dp != NULL) {
-            if (dp->d_type != DT_DIR ||
-                strncmp(dp->d_name, ".", 2) == 0  ||
-                strncmp(dp->d_name, "..", 3) == 0) {
-                continue;
-            }
-
-            sizeleft = size;
-            tmp = path;
-            memset(tmp, 0, sizeof(char) * sizeleft);
-
-            strncpy(tmp, procpath, sizeleft);
-            tmplen = strnlen(tmp, sizeleft);
-            sizeleft -= tmplen;
-            tmp += tmplen;
-
-            strncpy(tmp, "/", sizeleft);
-            tmplen = strnlen(tmp, sizeleft);
-            sizeleft -= tmplen;
-            tmp += tmplen;
-
-            strncpy(tmp, dp->d_name, sizeleft);
-            tmplen = strnlen(tmp, sizeleft);
-            sizeleft -= tmplen;
-            tmp += tmplen;
-
-            strncpy(tmp, "/", sizeleft);
-            tmplen = strnlen(tmp, sizeleft);
-            sizeleft -= tmplen;
-            tmp += tmplen;
-
-            strncpy(tmp, PROC_EXPORTS, sizeleft);
-            tmplen = strnlen(tmp, sizeleft);
-            sizeleft -= tmplen;
-            tmp += tmplen;
-
-            errno = 0;
-            dirp2 = opendir(path);
-            if (dirp2 == NULL) {
-                fprintf(stderr, "error: could not open: %s\n", path);
-                rc = errno;
-                continue;
-            }
-
-            do {
-                errno = 0;
-                dp2 = readdir(dirp2);
-                if (dp2 != NULL) {
-                    if (strncmp(dp2->d_name, ".", 2) == 0  ||
-                        strncmp(dp2->d_name, "..", 3) == 0 ||
-                        dp2->d_type != DT_DIR) {
-                        continue;
-                    }
-                    totalexports++;
-
-                    sizeleft2 = sizeleft;
-                    tmp2 = tmp;
-                    memset(tmp2, 0, sizeof(char) * sizeleft2);
-
-                    strncpy(tmp2, "/", sizeleft2);
-                    tmplen2 = strnlen(tmp2, sizeleft2);
-                    sizeleft2 -= tmplen2;
-                    tmp2 += tmplen2;
-
-                    strncpy(tmp2, dp2->d_name, sizeleft2);
-                    tmplen2 = strnlen(tmp2, sizeleft2);
-                    sizeleft2 -= tmplen2;
-                    tmp2 += tmplen2;
-
-                    memset(nid, 0, sizeof(char) * (NID_MAX+1));
-                    strncpy(nid, basename(path), sizeof(char) * (NID_MAX+1));
-                    tmp2 = strrchr(nid, '@');
-                    if (tmp2 == NULL) {
-                        totalfailures++;
+        char *dirs[] = PROC_DIRS;
+        char exp[PATH_MAX + 1];
+        NIDList nidlist = NULL;
+        DIR *topdirp;
+        struct dirent *dp;
+        int i;
+        int opens = 0;
+
+        if (!verbose)
+                nidlist = nl_create();
+        for (i = 0; dirs[i] != NULL; i++) {
+                if ((topdirp = opendir(dirs[i])) == NULL)
                         continue;
-                    }
-                    *tmp2 = '\0';
-                    tmp2++;
-                    /* Note that tmp2 should now hold the lnet network */
-
-                    /* Check to see if this lnet network already has a hostset
-                     * associated with it */
-                    errno = 0;
-                    hl = hash_find(network_hash, tmp2);
-                    if (hl == NULL) {
-                        if (hash_count(network_hash) >= NETWORK_MAX) {
-                            (void)closedir(dirp2);
-                            return EINVAL;
-                        }
-
-                        /* Create a new hostset for this hash table and
-                         * insert the first part of the nid into it */
-                        idx = hash_count(network_hash);
-                        strncpy(network[idx], tmp2, LNET_NETWORK_TYPE_MAX);
-                        lshowmount_gethostname(nid, addr, NID_MAX+1);
-                        hl = hostlist_create(addr);
-                        hash_insert(network_hash, network[idx], hl);
-                    }
-                    else {
-                        lshowmount_gethostname(nid, addr, NID_MAX+1);
-                        hostlist_push_host(hl, addr);
-                    }
-                }
-            } while (dp2 != NULL);
-            (void) closedir(dirp2);
-
-            /* If the verbose option is set we want to print
-             * out the hostlist for each mgs, mds, obdfilter */
-            if (verbose) {
-                printf("%s:\n", dp->d_name);
-                if (totalfailures > 0) {
-                    fprintf(stderr, "failures %d of %d exports\n",
-                            totalfailures, totalexports);
+                while ((dp = readdir(topdirp))) {
+                        if (dp->d_type != DT_DIR)
+                                continue;
+                        if (!strcmp(dp->d_name, "."))
+                                continue;
+                        if (!strcmp(dp->d_name, ".."))
+                                continue;
+                        sprintf(exp, PROC_EXPORTS_TMPL, dirs[i], dp->d_name);
+                        if (verbose) {
+                                nidlist = nl_create();
+                                read_exports(exp, nidlist);
+                                printf("%s:\n", dp->d_name);
+                                print_nids(nidlist, lookup, enumerate, 1);
+                                nl_destroy(nidlist);
+                        } else
+                                read_exports(exp, nidlist);
                 }
-
-                if (!rc && totalfailures > 0) {
-                    rc = 1;
-                }
-
-                totalexports = totalfailures = 0;
-                lshowmount_print_hosts(network, network_hash);
-            }
+                closedir(topdirp);
+                opens++;
         }
-    } while (dp != NULL);
-    (void) closedir(dirp);
-
-    if (!rc && totalfailures > 0) {
-        rc = 1;
-    }
-
-    return rc;
+        if (!verbose) {
+                print_nids(nidlist, lookup, enumerate, 0);
+                nl_destroy(nidlist);
+        }
+        return opens;
 }
 
-int main(int argc, char **argv)
+static int empty_proc_file(char *path)
 {
-    int                 opt = 0;
-    int                 optidx = 0;
-    int                 i = 0, rc = 0, rc2 = 0, rc3 = 0;
-    hash_t              network_hash = NULL;
-    char**              network = NULL;
-
-    while ((opt = getopt_long(argc, argv, "ehlv",long_options, &optidx)) != -1) {
-        switch (opt) {
-            case 'e':
-                enumerate = 1;
-                break;
-            case 'h':
-                usage();
-                goto finish;
-                break;
-            case 'l':
-                lookup = 1;
-                break;
-            case 'v':
-                verbose = 1;
-                break;
-            default:
-                usage();
-                rc = -1;
-                goto finish;
-                break;
-        }
-    }
-
-    /* Allocate memory for NETWORK_MAX total possible
-     * lnet networks.  Each network will have its own
-     * hash table so that we can possibly create a ranged
-     * string for it */
-    network = malloc(sizeof(char *) * NETWORK_MAX);
-    if (network == NULL) {
-        rc = ENOMEM;
-        goto finish;
-    }
-    memset(network, 0, sizeof(char *) * NETWORK_MAX);
-    for (i = 0; i < NETWORK_MAX; i++) {
-        network[i] = malloc(sizeof(char) * (LNET_NETWORK_TYPE_MAX+1));
-        if (network[i] == NULL) {
-            rc = ENOMEM;
-            goto finish;
-        }
-        memset(network[i], 0, sizeof(char) * (LNET_NETWORK_TYPE_MAX+1));
-    }
-
-    /* Initialize the network_hash.  This hash table will map
-     * a particular network say elan1 or tcp2 to a hostset */
-    network_hash = hash_create(0,
-                               (hash_key_f) hash_key_string,
-                               lshowmount_hash_strcmp,
-                               lshowmount_hash_hostlist_freeitem);
-
-    rc  = getclients(PROC_DIR_MGS, network, network_hash);
-    rc2 = getclients(PROC_DIR_MDS, network, network_hash);
-    rc3 = getclients(PROC_DIR_OST, network, network_hash);
-    if (rc || rc2 || rc3) {
-        rc = rc2 > rc ? rc2 : rc;
-        rc = rc3 > rc ? rc3 : rc;
-    }
-
-    if (!verbose) {
-        if (totalfailures > 0) {
-            fprintf(stderr, "failures %d of %d exports\n",
-                    totalfailures, totalexports);
-        }
-        lshowmount_print_hosts(network, network_hash);
-    }
+        int empty = 0;
+        char buf[36];
+        int fd;
+
+        if ((fd = open(path, O_RDONLY)) < 0 || read(fd, buf, sizeof(buf)) <= 0)
+                empty = 1;
+        if (fd >= 0)
+                close(fd);
+        return empty;
+}
 
-finish:
-    hash_destroy(network_hash);
-    if (network != NULL) {
-        for (i = 0; i < NETWORK_MAX; i++) {
-            if (network[i] != NULL) {
-                free(network[i]);
-                network[i] = NULL;
-            }
+static void read_exports(char *exports, NIDList nidlist)
+{
+        DIR *dirp;
+        struct dirent *dp;
+        char path[PATH_MAX + 1];
+
+        if ((dirp = opendir(exports))) {
+                while ((dp = readdir(dirp))) {
+                        if (dp->d_type != DT_DIR)
+                                continue;
+                        if (!strcmp(dp->d_name, "."))
+                                continue;
+                        if (!strcmp(dp->d_name, ".."))
+                                continue;
+                        if (strchr(dp->d_name, '@') == NULL)
+                                continue;
+                        sprintf(path, PROC_UUID_TMPL, exports, dp->d_name);
+                        if (empty_proc_file(path))
+                                continue;
+
+                        nl_add(nidlist, dp->d_name);
+                }
+                closedir(dirp);
         }
-        free(network);
-        network = NULL;
-    }
-
-    return rc;
 }
-
-/*
- * vi:tabstop=4 shiftwidth=4 expandtab
- */
diff --git a/lustre/utils/lshowmount.h b/lustre/utils/lshowmount.h
deleted file mode 100644
index 06e1c5d..0000000
--- a/lustre/utils/lshowmount.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __LSHOWMOUNT_H
-#define __LSHOWMOUNT_H
-
-#define PROC_DIR_MGS          "/proc/fs/lustre/mgs"
-#define PROC_DIR_MDS          "/proc/fs/lustre/mds"
-#define PROC_DIR_OST          "/proc/fs/lustre/obdfilter"
-#define PROC_EXPORTS          "exports"
-#define PROC_NID              "nid"
-#define NID_MAX               1024
-#define LNET_NETWORK_TYPE_MAX 32
-#define NETWORK_MAX           128
-
-#endif
-
-/*
- * vi:tabstop=4 shiftwidth=4 expandtab
- */
diff --git a/lustre/utils/lustre_cfg.c b/lustre/utils/lustre_cfg.c
index e517d36..047c0de 100644
--- a/lustre/utils/lustre_cfg.c
+++ b/lustre/utils/lustre_cfg.c
@@ -83,7 +83,7 @@ int lcfg_set_devname(char *name)
                 /* quietly strip the unnecessary '$' */
                 if (*name == '$' || *name == '%')
                         name++;
-                if (isdigit(*name)) { 
+                if (isdigit(*name)) {
                         /* We can't translate from dev # to name */
                         lcfg_devname = NULL;
                 } else {
@@ -91,7 +91,7 @@ int lcfg_set_devname(char *name)
                 }
         } else {
                 lcfg_devname = NULL;
-        } 
+        }
         return 0;
 }
 
@@ -155,8 +155,8 @@ int jt_lcfg_setup(int argc, char **argv)
 
         if (lcfg_devname == NULL) {
                 fprintf(stderr, "%s: please use 'device name' to set the "
-                        "device name for config commands.\n", 
-                        jt_cmdname(argv[0])); 
+                        "device name for config commands.\n",
+                        jt_cmdname(argv[0]));
                 return -EINVAL;
         }
 
@@ -187,8 +187,8 @@ int jt_obd_detach(int argc, char **argv)
 
         if (lcfg_devname == NULL) {
                 fprintf(stderr, "%s: please use 'device name' to set the "
-                        "device name for config commands.\n", 
-                        jt_cmdname(argv[0])); 
+                        "device name for config commands.\n",
+                        jt_cmdname(argv[0]));
                 return -EINVAL;
         }
 
@@ -219,8 +219,8 @@ int jt_obd_cleanup(int argc, char **argv)
 
         if (lcfg_devname == NULL) {
                 fprintf(stderr, "%s: please use 'device name' to set the "
-                        "device name for config commands.\n", 
-                        jt_cmdname(argv[0])); 
+                        "device name for config commands.\n",
+                        jt_cmdname(argv[0]));
                 return -EINVAL;
         }
 
@@ -257,8 +257,8 @@ int jt_obd_cleanup(int argc, char **argv)
         return rc;
 }
 
-static 
-int do_add_uuid(char * func, char *uuid, lnet_nid_t nid) 
+static
+int do_add_uuid(char * func, char *uuid, lnet_nid_t nid)
 {
         int rc;
         struct lustre_cfg_bufs bufs;
@@ -270,7 +270,7 @@ int do_add_uuid(char * func, char *uuid, lnet_nid_t nid)
 
         lcfg = lustre_cfg_new(LCFG_ADD_UUID, &bufs);
         lcfg->lcfg_nid = nid;
-        /* Poison NAL -- pre 1.4.6 will LASSERT on 0 NAL, this way it 
+        /* Poison NAL -- pre 1.4.6 will LASSERT on 0 NAL, this way it
            doesn't work without crashing (bz 10130) */
         lcfg->lcfg_nal = 0x5a;
 
@@ -293,8 +293,8 @@ int do_add_uuid(char * func, char *uuid, lnet_nid_t nid)
 int jt_lcfg_add_uuid(int argc, char **argv)
 {
         lnet_nid_t nid;
-        
-        if (argc != 3) {                
+
+        if (argc != 3) {
                 return CMD_HELP;
         }
 
@@ -326,7 +326,7 @@ int jt_lcfg_del_uuid(int argc, char **argv)
         lustre_cfg_bufs_reset(&bufs, lcfg_devname);
         if (strcmp (argv[1], "_all_"))
                 lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
-        
+
         lcfg = lustre_cfg_new(LCFG_DEL_UUID, &bufs);
         rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
         lustre_cfg_free(lcfg);
@@ -338,9 +338,6 @@ int jt_lcfg_del_uuid(int argc, char **argv)
         return 0;
 }
 
-
-
-
 int jt_lcfg_del_mount_option(int argc, char **argv)
 {
         int rc;
@@ -367,36 +364,12 @@ int jt_lcfg_del_mount_option(int argc, char **argv)
 
 int jt_lcfg_set_timeout(int argc, char **argv)
 {
-        int rc;
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg *lcfg;
-
         fprintf(stderr, "%s has been deprecated. Use conf_param instead.\n"
                 "e.g. conf_param lustre-MDT0000 obd_timeout=50\n",
                 jt_cmdname(argv[0]));
         return CMD_HELP;
-
-
-        if (argc != 2)
-                return CMD_HELP;
-
-        lustre_cfg_bufs_reset(&bufs, lcfg_devname);
-        lcfg = lustre_cfg_new(LCFG_SET_TIMEOUT, &bufs);
-        lcfg->lcfg_num = atoi(argv[1]);
-        
-        rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
-        //rc = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg);
-
-        lustre_cfg_free(lcfg);
-        if (rc < 0) {
-                fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
-                        strerror(rc = errno));
-        }
-        return rc;
 }
 
-
-
 int jt_lcfg_add_conn(int argc, char **argv)
 {
         struct lustre_cfg_bufs bufs;
@@ -413,8 +386,8 @@ int jt_lcfg_add_conn(int argc, char **argv)
 
         if (lcfg_devname == NULL) {
                 fprintf(stderr, "%s: please use 'device name' to set the "
-                        "device name for config commands.\n", 
-                        jt_cmdname(argv[0])); 
+                        "device name for config commands.\n",
+                        jt_cmdname(argv[0]));
                 return -EINVAL;
         }
 
@@ -446,8 +419,8 @@ int jt_lcfg_del_conn(int argc, char **argv)
 
         if (lcfg_devname == NULL) {
                 fprintf(stderr, "%s: please use 'device name' to set the "
-                        "device name for config commands.\n", 
-                        jt_cmdname(argv[0])); 
+                        "device name for config commands.\n",
+                        jt_cmdname(argv[0]));
                 return -EINVAL;
         }
 
@@ -485,7 +458,7 @@ int jt_lcfg_param(int argc, char **argv)
         }
 
         lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
-        
+
         rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
         lustre_cfg_free(lcfg);
         if (rc < 0) {
@@ -578,6 +551,45 @@ static char *strnchr(const char *p, char c, size_t n)
        return (0);
 }
 
+static char *globerrstr(int glob_rc)
+{
+        switch(glob_rc) {
+        case GLOB_NOSPACE:
+                return "Out of memory";
+        case GLOB_ABORTED:
+                return "Read error";
+        case GLOB_NOMATCH:
+                return "Found no match";
+        }
+        return "Unknown error";
+}
+
+static void clean_path(char *path)
+{
+        char *tmp;
+
+        /* If the input is in form Eg. obdfilter.*.stats */
+        if (strchr(path, '.')) {
+                tmp = path;
+                while (*tmp != '\0') {
+                        if ((*tmp == '.') &&
+                            (tmp != path) && (*(tmp - 1) != '\\'))
+                                *tmp = '/';
+                        tmp ++;
+                }
+        }
+        /* get rid of '\', glob doesn't like it */
+        if ((tmp = strrchr(path, '\\')) != NULL) {
+                char *tail = path + strlen(path);
+                while (tmp != path) {
+                        if (*tmp == '\\') {
+                                memmove(tmp, tmp + 1, tail - tmp);
+                                --tail;
+                        }
+                        --tmp;
+                }
+        }
+}
 
 struct param_opts {
         int only_path;
@@ -622,8 +634,8 @@ static int getparam_display(struct param_opts *popt, char *pattern)
         rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
         if (rc) {
                 fprintf(stderr, "error: get_param: %s: %s\n",
-                        pattern, strerror(rc));
-                return rc;
+                        pattern, globerrstr(rc));
+                return -ESRCH;
         }
 
         buf = malloc(CFS_PAGE_SIZE);
@@ -697,7 +709,7 @@ int jt_lcfg_getparam(int argc, char **argv)
         int rc = 0, i;
         struct param_opts popt;
         char pattern[PATH_MAX];
-        char *path, *tmp;
+        char *path;
 
         rc = getparam_cmdline(argc, argv, &popt);
         if (rc < 0 || rc >= argc)
@@ -706,15 +718,7 @@ int jt_lcfg_getparam(int argc, char **argv)
         for (i = rc; i < argc; i++) {
                 path = argv[i];
 
-                /* If the input is in form Eg. obdfilter.*.stats */
-                if (strchr(path, '.')) {
-                        tmp = path;
-                        while (*tmp != '\0') {
-                                if (*tmp == '.')
-                                        *tmp = '/';
-                                tmp ++;
-                        }
-                }
+                clean_path(path);
 
                 /* If the entire path is specified as input */
                 fp = open(path, O_RDONLY);
@@ -765,8 +769,8 @@ static int setparam_display(struct param_opts *popt, char *pattern, char *value)
         rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
         if (rc) {
                 fprintf(stderr, "error: set_param: %s: %s\n",
-                        pattern, strerror(rc));
-                return rc;
+                        pattern, globerrstr(rc));
+                return -ESRCH;
         }
         for (i = 0; i  < glob_info.gl_pathc; i++) {
                 char *valuename = NULL;
@@ -805,7 +809,7 @@ int jt_lcfg_setparam(int argc, char **argv)
         int rc = 0, i;
         struct param_opts popt;
         char pattern[PATH_MAX];
-        char *path = NULL, *value = NULL, *tmp;
+        char *path = NULL, *value = NULL;
 
         rc = setparam_cmdline(argc, argv, &popt);
         if (rc < 0 || rc >= argc)
@@ -827,15 +831,7 @@ int jt_lcfg_setparam(int argc, char **argv)
                         }
                 }
 
-                /* If the input is in form Eg. obdfilter.*.stats */
-                if (strchr(path, '.')) {
-                        tmp = path;
-                        while (*tmp != '\0') {
-                                if (*tmp == '.')
-                                        *tmp = '/';
-                                tmp ++;
-                        }
-                }
+                clean_path(path);
 
                 /* If the entire path is specified as input */
                 fp = open(path, O_RDONLY);
diff --git a/lustre/utils/mkfs_lustre.c b/lustre/utils/mkfs_lustre.c
index 9c62901..9f17c0d 100644
--- a/lustre/utils/mkfs_lustre.c
+++ b/lustre/utils/mkfs_lustre.c
@@ -40,6 +40,10 @@
 
 /* This source file is compiled into both mkfs.lustre and tunefs.lustre */
 
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
@@ -366,22 +370,25 @@ static void disp_old_e2fsprogs_msg(const char *feature, int make_backfs)
         static int msg_displayed;
 
         if (msg_displayed) {
-                fprintf(stderr, "WARNING: e2fsprogs does not support %s "
-                        "feature.\n\n", feature);
+                fprintf(stderr, "WARNING: %s does not support %s "
+                        "feature.\n\n", E2FSPROGS, feature);
                 return;
         }
 
         msg_displayed++;
 
-        fprintf(stderr, "WARNING: The e2fsprogs package currently installed on "
-                "your system does not support \"%s\" feature.\nPlease install "
-                "the latest version of e2fsprogs from http://downloads.lustre.org"
-                "/public/tools/e2fsprogs/\nto enable this feature.\n", feature);
-
+        fprintf(stderr, "WARNING: The %s package currently installed on "
+                "your system does not support \"%s\" feature.\n",
+                E2FSPROGS, feature);
+#if !(HAVE_LDISKFSPROGS)
+        fprintf(stderr, "Please install the latest version of e2fsprogs from\n"
+                "http://downloads.lustre.org/public/tools/e2fsprogs/\n"
+                "to enable this feature.\n");
+#endif
         if (make_backfs)
-                fprintf(stderr, "Feature will not be enabled until e2fsprogs "
-                        "is updated and 'tune2fs -O %s %%{device}' "
-                        "is run.\n\n", feature);
+                fprintf(stderr, "Feature will not be enabled until %s"
+                        "is updated and '%s -O %s %%{device}' "
+                        "is run.\n\n", E2FSPROGS, TUNE2FS, feature);
 }
 
 /* Check whether the file exists in the device */
@@ -394,8 +401,8 @@ static int file_in_dev(char *file_name, char *dev_name)
 
         /* Construct debugfs command line. */
         snprintf(debugfs_cmd, sizeof(debugfs_cmd),
-                "debugfs -c -R 'stat %s' '%s' 2>&1 | egrep '(Inode|unsupported)'",
-                file_name, dev_name);
+                "%s -c -R 'stat %s' '%s' 2>&1 | egrep '(Inode|unsupported)'",
+                DEBUGFS, file_name, dev_name);
 
         fp = popen(debugfs_cmd, "r");
         if (!fp) {
@@ -456,8 +463,8 @@ static int is_e2fsprogs_feature_supp(const char *feature)
         int fd = -1;
         int ret = 0;
 
-        snprintf(cmd, sizeof(cmd),
-                 "debugfs -c -R \"supported_features %s\" 2>&1", feature);
+        snprintf(cmd, sizeof(cmd), "%s -c -R \"supported_features %s\" 2>&1",
+                 DEBUGFS, feature);
 
         /* Using popen() instead of run_command() since debugfs does not return
          * proper error code if command is not supported */
@@ -475,8 +482,8 @@ static int is_e2fsprogs_feature_supp(const char *feature)
         if ((fd = mkstemp(imgname)) < 0)
                 return -1;
 
-        snprintf(cmd, sizeof(cmd), "mke2fs -F -O %s %s 100 >/dev/null 2>&1",
-                 feature, imgname);
+        snprintf(cmd, sizeof(cmd), "%s -F -O %s %s 100 >/dev/null 2>&1",
+                 MKE2FS, feature, imgname);
         /* run_command() displays the output of mke2fs when it fails for
          * some feature, so use system() directly */
         ret = system(cmd);
@@ -498,7 +505,7 @@ static void enable_default_backfs_features(struct mkfs_opts *mop)
         int maj_high, maj_low, min;
         int ret;
 
-        strscat(mop->mo_mkfsopts, " -O dir_index", sizeof(mop->mo_mkfsopts));
+        strscat(mop->mo_mkfsopts, " -O dir_index,extents", sizeof(mop->mo_mkfsopts));
 
         /* Upstream e2fsprogs called our uninit_groups feature uninit_bg,
          * check for both of them when testing e2fsprogs features. */
@@ -642,7 +649,7 @@ int make_lustre_backfs(struct mkfs_opts *mop)
                 strscat(mop->mo_mkfsopts, " -F", sizeof(mop->mo_mkfsopts));
 
                 snprintf(mkfs_cmd, sizeof(mkfs_cmd),
-                         "mkfs.ext2 -j -b %d -L %s ", L_BLOCK_SIZE,
+                         "%s -j -b %d -L %s ", MKE2FS, L_BLOCK_SIZE,
                          mop->mo_ldd.ldd_svname);
 
         } else if (mop->mo_ldd.ldd_mount_type == LDD_MT_REISERFS) {
@@ -870,8 +877,8 @@ int read_local_files(struct mkfs_opts *mop)
                  filesystem */
 
         /* Construct debugfs command line. */
-        snprintf(cmd, cmdsz, "debugfs -c -R 'dump /%s %s/mountdata' '%s'",
-                 MOUNT_DATA_FILE, tmpdir, dev);
+        snprintf(cmd, cmdsz, "%s -c -R 'dump /%s %s/mountdata' '%s'",
+                 DEBUGFS, MOUNT_DATA_FILE, tmpdir, dev);
 
         ret = run_command(cmd, cmdsz);
         if (ret)
@@ -894,8 +901,8 @@ int read_local_files(struct mkfs_opts *mop)
                 sprintf(filepnm, "%s/%s", tmpdir, LAST_RCVD);
 
                 /* Construct debugfs command line. */
-                snprintf(cmd, cmdsz, "debugfs -c -R 'dump /%s %s' %s",
-                         LAST_RCVD, filepnm, dev);
+                snprintf(cmd, cmdsz, "%s -c -R 'dump /%s %s' %s",
+                         DEBUGFS, LAST_RCVD, filepnm, dev);
 
                 ret = run_command(cmd, cmdsz);
                 if (ret) {
@@ -914,7 +921,8 @@ int read_local_files(struct mkfs_opts *mop)
                         snprintf(cmd, cmdsz, "ls -l %s/", tmpdir);
                         run_command(cmd, cmdsz);
                         verrprint("Contents of disk:\n");
-                        snprintf(cmd, cmdsz, "debugfs -c -R 'ls -l /' %s", dev);
+                        snprintf(cmd, cmdsz, "%s -c -R 'ls -l /' %s",
+                                 DEBUGFS, dev);
                         run_command(cmd, cmdsz);
 
                         goto out_rmdir;
@@ -946,8 +954,8 @@ int read_local_files(struct mkfs_opts *mop)
                 } else  {
                         /* If neither is set, we're pre-1.4.6, make a guess. */
                         /* Construct debugfs command line. */
-                        snprintf(cmd, cmdsz, "debugfs -c -R 'rdump /%s %s' %s",
-                                 MDT_LOGS_DIR, tmpdir, dev);
+                        snprintf(cmd, cmdsz, "%s -c -R 'rdump /%s %s' %s",
+                                 DEBUGFS, MDT_LOGS_DIR, tmpdir, dev);
                         run_command(cmd, cmdsz);
 
                         sprintf(filepnm, "%s/%s", tmpdir, MDT_LOGS_DIR);
@@ -1072,6 +1080,11 @@ static char *convert_hostnames(char *s1)
         lnet_nid_t nid;
 
         converted = malloc(left);
+        if (converted == NULL) {
+                fprintf(stderr, "out of memory: needed %d bytes\n",
+                        MAXNIDSTR);
+                return NULL;
+        }
         end = s1 + strlen(s1);
         c = converted;
         while ((left > 0) && (s1 < end)) {
@@ -1081,7 +1094,7 @@ static char *convert_hostnames(char *s1)
                 sep = *s2;
                 *s2 = '\0';
                 nid = libcfs_str2nid(s1);
-                
+
                 if (nid == LNET_NID_ANY) {
                         fprintf(stderr, "%s: Can't parse NID '%s'\n", progname, s1);
                         free(converted);
@@ -1096,7 +1109,7 @@ static char *convert_hostnames(char *s1)
                         free(converted);
                         return NULL;
                 }
-                                        
+
                 c += snprintf(c, left, "%s%c", libcfs_nid2str(nid), sep);
                 left = converted + MAXNIDSTR - c;
                 s1 = s2 + 1;
@@ -1325,6 +1338,10 @@ int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
                 return EINVAL;
         }
 
+        /* single argument: <device> */
+        if (argc == 2)
+                ++print_only;
+
 #ifndef TUNEFS
         if (mop->mo_ldd.ldd_flags & LDD_F_SV_TYPE_MDT && 0 == upcall) {
                 if (access("/usr/sbin/l_getgroups", R_OK | X_OK)) {
diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c
index 191918e..59a6dc2 100644
--- a/lustre/utils/mount_lustre.c
+++ b/lustre/utils/mount_lustre.c
@@ -39,6 +39,7 @@
  * Author: Nathan Rutman <nathan at clusterfs.com>
  */
 
+
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
@@ -82,7 +83,7 @@ void usage(FILE *out)
                 "\t<filesystem>: name of the Lustre filesystem (e.g. lustre1)\n"
                 "\t<mountpt>: filesystem mountpoint (e.g. /mnt/lustre)\n"
                 "\t-f|--fake: fake mount (updates /etc/mtab)\n"
-                "\t--force: force mount even if already in /etc/mtab\n"
+                "\t-o force|--force: force mount even if already in /etc/mtab\n"
                 "\t-h|--help: print this usage message\n"
                 "\t-n|--nomtab: do not update /etc/mtab after mount\n"
                 "\t-v|--verbose: print verbose config settings\n"
@@ -161,6 +162,11 @@ static char *convert_hostnames(char *s1)
         lnet_nid_t nid;
 
         converted = malloc(left);
+        if (converted == NULL) {
+                fprintf(stderr, "out of memory: needed %d bytes\n",
+                        MAXNIDSTR);
+                return NULL;
+        }
         c = converted;
         while ((left > 0) && (*s1 != '/')) {
                 s2 = strpbrk(s1, ",:");
@@ -278,8 +284,11 @@ int parse_options(char *orig_options, int *flagp)
                                 retry = MAX_RETRIES;
                         else if (retry < 0)
                                 retry = 0;
-                }
-                else if (parse_one_option(opt, flagp) == 0) {
+                } else if (strncmp(opt, "force", 5) == 0) {
+                        //XXX special check for 'force' option
+                        ++force;
+                        printf("force: %d\n", force);
+                } else if (parse_one_option(opt, flagp) == 0) {
                         /* pass this on as an option */
                         if (*options)
                                 strcat(options, ",");
@@ -326,7 +335,7 @@ int set_tunables(char *source, int src_len)
         glob_t glob_info;
         struct stat stat_buf;
         char *chk_major, *chk_minor;
-        char *savept, *dev, *s2 = 0;
+        char *savept = NULL, *dev;
         char *ret_path;
         char buf[PATH_MAX] = {'\0'}, path[PATH_MAX] = {'\0'};
         char real_path[PATH_MAX] = {'\0'};
@@ -349,7 +358,7 @@ int set_tunables(char *source, int src_len)
         if (strncmp(real_path, "/dev/loop", 9) == 0)
                 return 0;
 
-        if ((real_path[0] != '/') && ((s2 = strpbrk(real_path, ",:")) != NULL))
+        if ((real_path[0] != '/') && (strpbrk(real_path, ",:") != NULL))
                 return 0;
 
         dev = real_path + src_len - 1;
@@ -513,7 +522,15 @@ int main(int argc, char *const argv[])
         }
 
         usource = argv[optind];
+        if (!usource) {
+                usage(stderr);
+        }
+
         source = convert_hostnames(usource);
+        if (!source) {
+                usage(stderr);
+        }
+
         target = argv[optind + 1];
         ptr = target + strlen(target) - 1;
         while ((ptr > target) && (*ptr == '/')) {
@@ -521,19 +538,18 @@ int main(int argc, char *const argv[])
                 ptr--;
         }
 
-        if (!usource || !source) {
-                usage(stderr);
-        }
-
         if (verbose) {
                 for (i = 0; i < argc; i++)
                         printf("arg[%d] = %s\n", i, argv[i]);
-                printf("source = %s (%s), target = %s\n",
-                       usource, source, target);
+                printf("source = %s (%s), target = %s\n", usource, source, target);
                 printf("options = %s\n", orig_options);
         }
 
         options = malloc(strlen(orig_options) + 1);
+        if (options == NULL) {
+                fprintf(stderr, "can't allocate memory for options\n");
+                return -1;
+        }
         strcpy(options, orig_options);
         rc = parse_options(options, &flags);
         if (rc) {
@@ -572,6 +588,10 @@ int main(int argc, char *const argv[])
            functions.  So we'll stick it on the end of the options. */
         optlen = strlen(options) + strlen(",device=") + strlen(source) + 1;
         optcopy = malloc(optlen);
+        if (optcopy == NULL) {
+                fprintf(stderr, "can't allocate memory to optcopy\n");
+                return -1;
+        }
         strcpy(optcopy, options);
         if (*optcopy)
                 strcat(optcopy, ",");
diff --git a/lustre/utils/mount_utils.c b/lustre/utils/mount_utils.c
index 9929de2..9253251 100644
--- a/lustre/utils/mount_utils.c
+++ b/lustre/utils/mount_utils.c
@@ -34,6 +34,10 @@
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
+#if HAVE_CONFIG_H
+#  include "config.h"
+#endif /* HAVE_CONFIG_H */
+
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
@@ -110,12 +114,12 @@ int get_mountdata(char *dev, struct lustre_disk_data *mo_ldd)
         /* Make a temporary directory to hold Lustre data files. */
         if (!mkdtemp(tmpdir)) {
                 verrprint("%s: Can't create temporary directory %s: %s\n",
-                        progname, tmpdir, strerror(errno));
+			  progname, tmpdir, strerror(errno));
                 return errno;
         }
 
-        snprintf(cmd, cmdsz, "/sbin/debugfs -c -R 'dump /%s %s/mountdata' %s",
-                 MOUNT_DATA_FILE, tmpdir, dev);
+        snprintf(cmd, cmdsz, "%s -c -R 'dump /%s %s/mountdata' %s",
+                 DEBUGFS, MOUNT_DATA_FILE, tmpdir, dev);
 
         ret = run_command(cmd, cmdsz);
         if (ret) {
@@ -133,7 +137,7 @@ int get_mountdata(char *dev, struct lustre_disk_data *mo_ldd)
                 verrprint("%s: Unable to read %d.%d config %s.\n",
                           progname, LUSTRE_MAJOR, LUSTRE_MINOR, filepnm);
                 goto out_close;
-	}	
+	}
 
 out_close:
         fclose(filep);
@@ -199,7 +203,7 @@ static int stclient(char *type, char *arch)
         pclose(fp);
 
         snprintf(cmd, 1024, "/opt/sun/servicetag/bin/stclient -a -p '%s' "
-               "-e %d.%d.%d -t '%s' -S mount.lustre -F '%s' -P '%s' -m SUN "
+               "-e %d.%d.%d -t '%s' -S mount -F '%s' -P '%s' -m SUN "
                "-A %s -z global", product, LUSTRE_MAJOR, LUSTRE_MINOR,
                LUSTRE_PATCH, urn, PARENT_URN, PARENT_PRODUCT, arch);
 
diff --git a/lustre/utils/nidlist.c b/lustre/utils/nidlist.c
new file mode 100644
index 0000000..fb0cbec
--- /dev/null
+++ b/lustre/utils/nidlist.c
@@ -0,0 +1,334 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/utils/nidlist.c
+ *
+ * Author: Jim Garlick <garlick at llnl.gov>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+#include "nidlist.h"
+
+struct nl_struct {
+	char **nids;
+	int len;
+	int count;
+};
+#define NL_CHUNK	64
+
+extern char *prog;
+
+static void nl_oom(void)
+{
+	fprintf(stderr, "%s: out of memory\n", prog);
+	exit(1);
+}
+
+NIDList nl_create(void)
+{
+	struct nl_struct *nl;
+
+	if (!(nl = malloc(sizeof(struct nl_struct))))
+		nl_oom();
+	nl->len = NL_CHUNK;
+	if (!(nl->nids = malloc(nl->len * sizeof(char *))))
+		nl_oom();
+	nl->count = 0;
+
+	return nl;
+}
+
+void nl_destroy(NIDList nl)
+{
+	int i;
+
+	for (i = 0; i < nl->count; i++)
+		free(nl->nids[i]);
+	free(nl->nids);
+	free(nl);
+}
+
+static void nl_grow(NIDList nl, int n)
+{
+	nl->len += n;
+	if (!(nl->nids = realloc(nl->nids, nl->len * sizeof(char *))))
+		nl_oom();
+}
+
+void nl_add(NIDList nl, char *nid)
+{
+	char *cp;
+
+	if (!(cp = strdup(nid)))
+		nl_oom();
+	if (nl->count == nl->len)
+		nl_grow(nl, NL_CHUNK);
+	nl->nids[nl->count++] = cp;
+}
+
+int nl_count(NIDList nl)
+{
+        return nl->count;
+}
+
+static char *nl_nid_addr(char *nid)
+{
+	char *addr, *p;
+
+	if (!(addr = strdup(nid)))
+		nl_oom();
+	if ((p = strchr(addr, '@')))
+		*p = '\0';
+
+	return addr;
+}
+
+static int nl_nid_parse_addr(char *addr)
+{
+	int o;
+
+	for (o = strlen(addr); o > 0; o--)
+                if (!isdigit(addr[o - 1]))
+			break;
+
+	return o;
+}
+
+static int nl_cmp_addr(char *nid1, char *nid2, int *cflagp)
+{
+	char *p1 = nl_nid_addr(nid1);
+	char *p2 = nl_nid_addr(nid2);
+	int res, o1, o2, cflag = 0;
+
+	o1 = nl_nid_parse_addr(p1);
+	o2 = nl_nid_parse_addr(p2);
+
+	if (o1 == o2 && (res = strncmp(p1, p2, o1)) == 0) {
+		res = strtoul(&p1[o1], NULL, 10) - strtoul(&p2[o2], NULL, 10);
+                if (cflagp && strlen(&p1[o1]) > 0 && strlen(&p2[o2]) > 0)
+                        cflag = 1;
+	} else
+                res = strcmp(p1, p2);
+	free(p1);
+	free(p2);
+	if (cflagp)
+		*cflagp = cflag;
+	return res;
+}
+
+static int nl_cmp_lnet(char *nid1, char *nid2)
+{
+	char *s1 = strchr(nid1, '@');
+	char *s2 = strchr(nid2, '@');
+
+	return strcmp(s1 ? s1 + 1 : "", s2 ? s2 + 1 : "");
+}
+
+static int nl_cmp(const void *p1, const void *p2)
+{
+	int res;
+
+	if ((res = nl_cmp_lnet(*(char **)p1, *(char **)p2)) == 0)
+		res = nl_cmp_addr(*(char **)p1, *(char **)p2, NULL);
+	return res;
+}
+
+void nl_sort(NIDList nl)
+{
+	qsort(nl->nids, nl->count, sizeof(char *), nl_cmp);
+}
+
+void nl_uniq(NIDList nl)
+{
+	int i, j;
+
+	for (i = 1; i < nl->count; i++) {
+		if (!strcmp(nl->nids[i], nl->nids[i - 1])) {
+			free(nl->nids[i]);
+			for (j = i; j < nl->count - 1; j++)
+				nl->nids[j] = nl->nids[j + 1];
+			nl->count--;
+			i--;
+		}
+	}
+}
+
+static char *nl_nid_lookup_ipaddr(char *nid)
+{
+        struct addrinfo *ai, *aip;
+        char name[NI_MAXHOST] = "";
+        char *p, *addr, *lnet = NULL, *res = NULL;
+        int len, x;
+
+        addr = nl_nid_addr(nid);
+        if (sscanf(addr, "%d.%d.%d.%d", &x, &x, &x, &x) == 4) {
+                if ((p = strchr(nid, '@')))
+                        lnet = p + 1;
+                if (getaddrinfo(addr, NULL, NULL, &ai) == 0) {
+                        for (aip = ai; aip != NULL; aip = aip->ai_next) {
+                                if (getnameinfo(aip->ai_addr, aip->ai_addrlen,
+                                    name, sizeof(name), NULL, 0,
+                                    NI_NAMEREQD | NI_NOFQDN) == 0) {
+                                        if ((p = strchr(name, '.')))
+                                                *p = '\0';
+                                        len = strlen(name) + strlen(lnet) + 2;
+                                        if (!(res = malloc(len)))
+                                                nl_oom();
+                                        snprintf(res, len, "%s@%s", name, lnet);
+                                        break;
+                                }
+                        }
+                        freeaddrinfo(ai);
+                }
+        }
+        free(addr);
+
+        return res;
+}
+
+void nl_lookup_ip(NIDList nl)
+{
+	int i;
+        char *new;
+
+	for (i = 0; i < nl->count; i++) {
+                if ((new = nl_nid_lookup_ipaddr(nl->nids[i]))) {
+                        free(nl->nids[i]);
+                        nl->nids[i] = new;
+                }
+        }
+}
+
+char *nl_string(NIDList nl, char *sep)
+{
+	int seplen = strlen(sep);
+	int i, len = 1;
+	char *s;
+
+	for (i = 0; i < nl->count; i++)
+		len += strlen(nl->nids[i]) + seplen;
+	if (!(s = malloc(len)))
+		nl_oom();
+	s[0] = '\0';
+	for (i = 0; i < nl->count; i++) {
+		if (i > 0)
+			strcat(s, sep);
+		strcat(s, nl->nids[i]);
+	}
+	return s;
+}
+
+static void nl_strxcat(char *s, char **nids, int len)
+{
+	int i, o, lastn = 0;
+	char *base, *p, *lnet = NULL, *savedn = NULL;
+
+	if ((p = strchr(nids[0], '@')))
+		lnet = p + 1;
+        base = nl_nid_addr(nids[0]);
+        o = nl_nid_parse_addr(base);
+	base[o] = '\0';
+	for (i = 0; i < len; i++) {
+		char *addr = nl_nid_addr(nids[i]);
+		int n = strtoul(&addr[o], NULL, 10);
+
+		if (i == 0)
+			sprintf(s + strlen(s), "%s[%s", base, &addr[o]);
+		else if (i < len) {
+			if (n == lastn + 1) {
+				if (savedn)
+					free(savedn);
+				if (!(savedn = strdup(&addr[o])))
+					nl_oom();
+			} else {
+				if (savedn) {
+					sprintf(s + strlen(s), "-%s", savedn);
+					free(savedn);
+					savedn = NULL;
+				}
+				sprintf(s + strlen(s), ",%s", &addr[o]);
+			}
+		}
+		if (i == len - 1) {
+			if (savedn) {
+				sprintf(s + strlen(s), "-%s", savedn);
+				free(savedn);
+			}
+			strcat(s, "]");
+			if (lnet)
+				sprintf(s + strlen(s), "@%s", lnet);
+		}
+		free(addr);
+		lastn = n;
+	}
+	free(base);
+}
+
+char *nl_xstring(NIDList nl, char *sep)
+{
+	int seplen = strlen(sep);
+	int cflag, i, j, len = 1;
+	char *s;
+
+	for (i = 0; i < nl->count; i++)
+		len += strlen(nl->nids[i]) + seplen;
+	if (!(s = malloc(len)))
+		nl_oom();
+	s[0] = '\0';
+	for (i = 0; i < nl->count; i++) {
+		if (i > 0)
+			strcat(s, sep);
+		for (j = i + 1; j < nl->count; j++) {
+			if (nl_cmp_lnet(nl->nids[i], nl->nids[j]) != 0)
+				break;
+			(void)nl_cmp_addr(nl->nids[i], nl->nids[j], &cflag);
+			if (!cflag)
+				break;
+		}
+		if (j - i > 1)
+			nl_strxcat(s, &nl->nids[i], j - i);
+		else
+			strcat(s, nl->nids[i]);
+		i += j - i - 1;
+	}
+	return s;
+}
diff --git a/lustre/utils/nidlist.h b/lustre/utils/nidlist.h
new file mode 100644
index 0000000..1978736
--- /dev/null
+++ b/lustre/utils/nidlist.h
@@ -0,0 +1,56 @@
+/* -*- 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  2008 Sun Microsystems, Inc. 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.
+ *
+ * lustre/utils/nidlist.h
+ *
+ * Author: Jim Garlick <garlick at llnl.gov>
+ */
+
+#ifndef NIDLIST_H
+#define NIDLIST_H
+
+typedef struct nl_struct *NIDList;
+
+NIDList nl_create(void);
+void nl_destroy(NIDList nl);
+void nl_add(NIDList nl, char *nid);
+int nl_count(NIDList nl);
+void nl_lookup_ip(NIDList nl);
+void nl_sort(NIDList nl);
+void nl_uniq(NIDList nl);
+char *nl_string(NIDList nl, char *sep);
+char *nl_xstring(NIDList nl, char *sep);
+
+#endif
diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c
index 8e6db0b..1f2a5af 100644
--- a/lustre/utils/obd.c
+++ b/lustre/utils/obd.c
@@ -48,9 +48,11 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <signal.h>
+#include <glob.h>
 
 #include "obdctl.h"
 
@@ -64,6 +66,7 @@
 #include <errno.h>
 #include <string.h>
 #include <ctype.h>
+#include <lustre/liblustreapi.h>
 
 #ifdef HAVE_ASM_PAGE_H
 #include <asm/page.h>           /* needed for PAGE_SIZE - rread */
@@ -106,9 +109,7 @@ const int thread = 0;
 const int nthreads = 1;
 #endif
 
-static char rawbuf[8192];
-static char *buf = rawbuf;
-static int max = sizeof(rawbuf);
+#define MAX_IOC_BUFLEN 8192
 
 static int cur_device = -1;
 
@@ -126,42 +127,25 @@ static int l2_ioctl(int dev_id, unsigned int opc, void *buf)
         return l_ioctl(dev_id, opc, buf);
 }
 
-#define IOC_INIT(data)                                                  \
-do {                                                                    \
-        memset(&data, 0, sizeof(data));                                 \
-        data.ioc_dev = cur_device;                                      \
-} while (0)
-
-#define IOC_PACK(func, data)                                            \
-do {                                                                    \
-        memset(buf, 0, sizeof(rawbuf));                                 \
-        if (obd_ioctl_pack(&data, &buf, max)) {                         \
-                fprintf(stderr, "error: %s: invalid ioctl\n",           \
-                        jt_cmdname(func));                                 \
-                return -2;                                              \
-        }                                                               \
-} while (0)
-
-#define IOC_UNPACK(func, data)                                          \
-do {                                                                    \
-        if (obd_ioctl_unpack(&data, buf, max)) {                        \
-                fprintf(stderr, "error: %s: invalid reply\n",           \
-                        jt_cmdname(func));                                 \
-                return -2;                                              \
-        }                                                               \
-} while (0)
-
 int lcfg_ioctl(char * func, int dev_id, struct lustre_cfg *lcfg)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_type = LUSTRE_CFG_TYPE;
         data.ioc_plen1 = lustre_cfg_len(lcfg->lcfg_bufcount,
                                         lcfg->lcfg_buflens);
         data.ioc_pbuf1 = (void *)lcfg;
-        IOC_PACK(func, data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(func));
+                return rc;
+        }
 
         rc =  l_ioctl(dev_id, OBD_IOC_PROCESS_CFG, buf);
 
@@ -170,42 +154,58 @@ int lcfg_ioctl(char * func, int dev_id, struct lustre_cfg *lcfg)
 
 static int do_device(char *func, char *devname);
 
-int lcfg_mgs_ioctl(char *func, int dev_id, struct lustre_cfg *lcfg)
+static int get_mgs_device()
 {
-        struct obd_ioctl_data data;
-        static int mgs_device = -1;
         char mgs[] = "$MGS";
-        int rc;
+        static int mgs_device = -1;
 
-        /* Always operates on MGS dev */
         if (mgs_device == -1) {
+                int rc;
                 do_disconnect(NULL, 1);
                 rc = do_device("mgsioc", mgs);
                 if (rc) {
+                        fprintf(stderr,
+                                "This command must be run on the MGS.\n");
                         errno = ENODEV;
                         return -1;
                 }
                 mgs_device = cur_device;
         }
+        return mgs_device;
+}
+
+/* Returns -1 on error with errno set */
+int lcfg_mgs_ioctl(char *func, int dev_id, struct lustre_cfg *lcfg)
+{
+        struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+        int rc;
 
-        IOC_INIT(data);
-        data.ioc_dev = mgs_device;
+        memset(&data, 0x00, sizeof(data));
+        rc = data.ioc_dev = get_mgs_device();
+        if (rc < 0)
+                goto out;
         data.ioc_type = LUSTRE_CFG_TYPE;
         data.ioc_plen1 = lustre_cfg_len(lcfg->lcfg_bufcount,
                                         lcfg->lcfg_buflens);
         data.ioc_pbuf1 = (void *)lcfg;
-        IOC_PACK(func, data);
-
-        rc =  l_ioctl(dev_id, OBD_IOC_PARAM, buf);
-
-        if (rc == ENODEV)
-                fprintf(stderr, "Is the MGS running on this node?\n");
-        if (rc == ENOSYS)
-                fprintf(stderr, "Make sure cfg_device is set first.\n");
-        if (rc == EINVAL)
-                fprintf(stderr, "cfg_device should be of the form "
-                        "'lustre-MDT0000'\n");
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(func));
+                return rc;
+        }
 
+        rc = l_ioctl(dev_id, OBD_IOC_PARAM, buf);
+out:
+        if (rc) {
+                if (errno == ENOSYS)
+                        fprintf(stderr, "Make sure cfg_device is set first.\n");
+                if (errno == EINVAL)
+                        fprintf(stderr, "cfg_device should be of the form "
+                                "'lustre-MDT0000'\n");
+        }
         return rc;
 }
 
@@ -232,18 +232,30 @@ char *obdo_print(struct obdo *obd)
 static int do_name2dev(char *func, char *name)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
-        IOC_INIT(data);
-
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(name) + 1;
         data.ioc_inlbuf1 = name;
 
-        IOC_PACK(func, data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(func));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_NAME2DEV, buf);
         if (rc < 0)
                 return errno;
-        IOC_UNPACK(func, data);
+        rc = obd_ioctl_unpack(&data, buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid reply\n",
+                        jt_cmdname(func));
+                return rc;
+        }
 
         return data.ioc_dev + N2D_OFF;
 }
@@ -270,7 +282,7 @@ int parse_devname(char *func, char *name)
                         // printf("Name %s is device %d\n", name, ret);
                 } else {
                         fprintf(stderr, "No device found for name %s: %s\n",
-                               name, strerror(rc));
+                                name, strerror(rc));
                 }
         }
         return ret;
@@ -818,14 +830,22 @@ int jt_opt_net(int argc, char **argv)
 int jt_obd_no_transno(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
 
         if (argc != 1)
                 return CMD_HELP;
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_NO_TRANSNO, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
@@ -837,14 +857,22 @@ int jt_obd_no_transno(int argc, char **argv)
 int jt_obd_set_readonly(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
 
         if (argc != 1)
                 return CMD_HELP;
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_SET_READONLY, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
@@ -856,14 +884,22 @@ int jt_obd_set_readonly(int argc, char **argv)
 int jt_obd_abort_recovery(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
 
         if (argc != 1)
                 return CMD_HELP;
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_ABORT_RECOVERY, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
@@ -875,15 +911,15 @@ int jt_obd_abort_recovery(int argc, char **argv)
 int jt_get_version(int argc, char **argv)
 {
         int rc;
-        char buf[8192];
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         struct obd_ioctl_data *data = (struct obd_ioctl_data *)buf;
 
         if (argc != 1)
                 return CMD_HELP;
 
-        memset(buf, 0, sizeof(buf));
+        memset(buf, 0, sizeof(rawbuf));
         data->ioc_version = OBD_IOCTL_VERSION;
-        data->ioc_inllen1 = sizeof(buf) - size_round(sizeof(*data));
+        data->ioc_inllen1 = sizeof(rawbuf) - size_round(sizeof(*data));
         data->ioc_inlbuf1 = buf + size_round(sizeof(*data));
         data->ioc_len = obd_ioctl_packlen(data);
 
@@ -948,7 +984,7 @@ fail:
 int jt_obd_list_ioctl(int argc, char **argv)
 {
         int rc, index;
-        char buf[8192];
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         struct obd_ioctl_data *data = (struct obd_ioctl_data *)buf;
 
         if (argc > 2)
@@ -958,9 +994,9 @@ int jt_obd_list_ioctl(int argc, char **argv)
                 return CMD_HELP;
 
         for (index = 0;; index++) {
-                memset(buf, 0, sizeof(buf));
+                memset(buf, 0, sizeof(rawbuf));
                 data->ioc_version = OBD_IOCTL_VERSION;
-                data->ioc_inllen1 = sizeof(buf) - size_round(sizeof(*data));
+                data->ioc_inllen1 = sizeof(rawbuf) - size_round(sizeof(*data));
                 data->ioc_inlbuf1 = buf + size_round(sizeof(*data));
                 data->ioc_len = obd_ioctl_packlen(data);
                 data->ioc_count = index;
@@ -976,8 +1012,7 @@ int jt_obd_list_ioctl(int argc, char **argv)
                         rc = 0;
                 else
                         fprintf(stderr, "Error getting device list: %s: "
-                                        "check dmesg.\n",
-                                        strerror(errno));
+                                "check dmesg.\n", strerror(errno));
         }
         return rc;
 }
@@ -1015,9 +1050,6 @@ int jt_obd_list(int argc, char **argv)
         return 0;
 }
 
-
-
-
 /* Create one or more objects, arg[4] may describe stripe meta-data.  If
  * not, defaults assumed.  This echo-client instance stashes the stripe
  * object ids.  Use get_stripe on this node to print full lsm and
@@ -1026,13 +1058,15 @@ int jt_obd_list(int argc, char **argv)
 /* create <count> [<file_create_mode>] [q|v|# verbosity] [striping] */
 int jt_obd_create(int argc, char **argv)
 {
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         struct obd_ioctl_data data;
         struct timeval next_time;
         __u64 count = 1, next_count, base_id = 0;
         int verbose = 1, mode = 0100644, rc = 0, i, valid_lsm = 0;
         char *end;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         if (argc < 2 || argc > 5)
                 return CMD_HELP;
 
@@ -1090,9 +1124,15 @@ int jt_obd_create(int argc, char **argv)
                         data.ioc_pbuf1 = (char *)&lsm_buffer;
                 }
 
-                IOC_PACK(argv[0], data);
+                memset(buf, 0, sizeof(rawbuf));
+                rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+                if (rc) {
+                        fprintf(stderr, "error: %s: invalid ioctl\n",
+                                jt_cmdname(argv[0]));
+                        return rc;
+                }
                 rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_CREATE, buf);
-                IOC_UNPACK(argv[0], data);
+                obd_ioctl_unpack(&data, buf, sizeof(rawbuf));
                 shmem_bump();
                 if (rc < 0) {
                         fprintf(stderr, "error: %s: #%d - %s\n",
@@ -1116,10 +1156,12 @@ int jt_obd_create(int argc, char **argv)
 int jt_obd_setattr(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         char *end;
         int rc;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         if (argc != 2)
                 return CMD_HELP;
 
@@ -1137,7 +1179,13 @@ int jt_obd_setattr(int argc, char **argv)
         }
         data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_SETATTR, buf);
         if (rc < 0)
                 fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
@@ -1151,6 +1199,7 @@ int jt_obd_test_setattr(int argc, char **argv)
         struct obd_ioctl_data data;
         struct timeval start, next_time;
         __u64 i, count, next_count;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int verbose = 1;
         obd_id objid = 3;
         char *end;
@@ -1159,7 +1208,8 @@ int jt_obd_test_setattr(int argc, char **argv)
         if (argc < 2 || argc > 4)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         count = strtoull(argv[1], &end, 0);
         if (*end) {
                 fprintf(stderr, "error: %s: invalid iteration count '%s'\n",
@@ -1198,7 +1248,13 @@ int jt_obd_test_setattr(int argc, char **argv)
                 data.ioc_obdo1.o_id = objid;
                 data.ioc_obdo1.o_mode = S_IFREG;
                 data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
-                IOC_PACK(argv[0], data);
+                memset(buf, 0x00, sizeof(rawbuf));
+                rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+                if (rc) {
+                        fprintf(stderr, "error: %s: invalid ioctl\n",
+                                jt_cmdname(argv[0]));
+                        return rc;
+                }
                 rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_SETATTR, &data);
                 shmem_bump();
                 if (rc < 0) {
@@ -1234,13 +1290,15 @@ int jt_obd_destroy(int argc, char **argv)
 {
         struct obd_ioctl_data data;
         struct timeval next_time;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         __u64 count = 1, next_count;
         int verbose = 1;
         __u64 id;
         char *end;
         int rc = 0, i;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         if (argc < 2 || argc > 4)
                 return CMD_HELP;
 
@@ -1275,9 +1333,15 @@ int jt_obd_destroy(int argc, char **argv)
                 data.ioc_obdo1.o_mode = S_IFREG | 0644;
                 data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLMODE;
 
-                IOC_PACK(argv[0], data);
+                memset(buf, 0, sizeof(rawbuf));
+                rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+                if (rc) {
+                        fprintf(stderr, "error: %s: invalid ioctl\n",
+                                jt_cmdname(argv[0]));
+                        return rc;
+                }
                 rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_DESTROY, buf);
-                IOC_UNPACK(argv[0], data);
+                obd_ioctl_unpack(&data, buf, sizeof(rawbuf));
                 shmem_bump();
                 if (rc < 0) {
                         fprintf(stderr, "error: %s: objid "LPX64": %s\n",
@@ -1296,13 +1360,15 @@ int jt_obd_destroy(int argc, char **argv)
 int jt_obd_getattr(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         char *end;
         int rc;
 
         if (argc != 2)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_obdo1.o_id = strtoull(argv[1], &end, 0);
         if (*end) {
                 fprintf(stderr, "error: %s: invalid objid '%s'\n",
@@ -1314,9 +1380,15 @@ int jt_obd_getattr(int argc, char **argv)
         data.ioc_obdo1.o_valid = 0xffffffff;
         printf("%s: object id "LPX64"\n", jt_cmdname(argv[0]),data.ioc_obdo1.o_id);
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_GETATTR, buf);
-        IOC_UNPACK(argv[0], data);
+        obd_ioctl_unpack(&data, buf, sizeof(rawbuf));
         if (rc) {
                 fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
                         strerror(rc = errno));
@@ -1331,6 +1403,7 @@ int jt_obd_test_getattr(int argc, char **argv)
 {
         struct obd_ioctl_data data;
         struct timeval start, next_time;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         __u64 i, count, next_count;
         int verbose = 1;
         obd_id objid = 3;
@@ -1340,7 +1413,8 @@ int jt_obd_test_getattr(int argc, char **argv)
         if (argc < 2 || argc > 4)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         count = strtoull(argv[1], &end, 0);
         if (*end) {
                 fprintf(stderr, "error: %s: invalid iteration count '%s'\n",
@@ -1379,7 +1453,13 @@ int jt_obd_test_getattr(int argc, char **argv)
                 data.ioc_obdo1.o_id = objid;
                 data.ioc_obdo1.o_mode = S_IFREG;
                 data.ioc_obdo1.o_valid = 0xffffffff;
-                IOC_PACK(argv[0], data);
+                memset(buf, 0x00, sizeof(rawbuf));
+                rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+                if (rc) {
+                        fprintf(stderr, "error: %s: invalid ioctl\n",
+                                jt_cmdname(argv[0]));
+                        return rc;
+                }
                 rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_GETATTR, &data);
                 shmem_bump();
                 if (rc < 0) {
@@ -1421,6 +1501,7 @@ int jt_obd_test_brw(int argc, char **argv)
 {
         struct obd_ioctl_data data;
         struct timeval start, next_time;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         __u64 count, next_count, len, stride, thr_offset = 0, objid = 3;
         int write = 0, verbose = 1, cmd, i, rc = 0, pages = 1;
         int offset_pages = 0;
@@ -1511,7 +1592,8 @@ int jt_obd_test_brw(int argc, char **argv)
                 }
         }
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
 
         /* communicate the 'type' of brw test and batching to echo_client.
          * don't start.  we'd love to refactor this lctl->echo_client
@@ -1596,7 +1678,13 @@ int jt_obd_test_brw(int argc, char **argv)
         cmd = write ? OBD_IOC_BRW_WRITE : OBD_IOC_BRW_READ;
         for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
                 data.ioc_obdo1.o_valid &= ~(OBD_MD_FLBLOCKS|OBD_MD_FLGRANT);
-                IOC_PACK(argv[0], data);
+                memset(buf, 0x00, sizeof(rawbuf));
+                rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+                if (rc) {
+                        fprintf(stderr, "error: %s: invalid ioctl\n",
+                                jt_cmdname(argv[0]));
+                        return rc;
+                }
                 rc = l2_ioctl(OBD_DEV_ID, cmd, buf);
                 shmem_bump();
                 if (rc) {
@@ -1656,11 +1744,13 @@ int jt_obd_lov_getconfig(int argc, char **argv)
         struct obd_ioctl_data data;
         struct lov_desc desc;
         struct obd_uuid *uuidarray;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         __u32 *obdgens;
         char *path;
         int rc, fd;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
 
         if (argc != 2)
                 return CMD_HELP;
@@ -1678,7 +1768,6 @@ int jt_obd_lov_getconfig(int argc, char **argv)
         desc.ld_tgt_count = ((OBD_MAX_IOCTL_BUFFER-sizeof(data)-sizeof(desc)) /
                              (sizeof(*uuidarray) + sizeof(*obdgens)));
 
-
 repeat:
         uuidarray = calloc(desc.ld_tgt_count, sizeof(*uuidarray));
         if (!uuidarray) {
@@ -1695,6 +1784,7 @@ repeat:
                 goto out_uuidarray;
         }
 
+        memset(buf, 0x00, sizeof(rawbuf));
         data.ioc_inllen1 = sizeof(desc);
         data.ioc_inlbuf1 = (char *)&desc;
         data.ioc_inllen2 = desc.ld_tgt_count * sizeof(*uuidarray);
@@ -1702,7 +1792,7 @@ repeat:
         data.ioc_inllen3 = desc.ld_tgt_count * sizeof(*obdgens);
         data.ioc_inlbuf3 = (char *)obdgens;
 
-        if (obd_ioctl_pack(&data, &buf, max)) {
+        if (obd_ioctl_pack(&data, &buf, sizeof(rawbuf))) {
                 fprintf(stderr, "error: %s: invalid ioctl\n",
                         jt_cmdname(argv[0]));
                 rc = -EINVAL;
@@ -1721,7 +1811,7 @@ repeat:
                 __u32 *genp;
                 int i;
 
-                if (obd_ioctl_unpack(&data, buf, max)) {
+                if (obd_ioctl_unpack(&data, buf, sizeof(rawbuf))) {
                         fprintf(stderr, "error: %s: invalid reply\n",
                                 jt_cmdname(argv[0]));
                         rc = -EINVAL;
@@ -1757,10 +1847,12 @@ int jt_obd_ldlm_regress_start(int argc, char **argv)
 {
         int rc;
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         char argstring[200];
         int i, count = sizeof(argstring) - 1;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         if (argc > 5)
                 return CMD_HELP;
 
@@ -1777,7 +1869,13 @@ int jt_obd_ldlm_regress_start(int argc, char **argv)
                 data.ioc_inllen1 = strlen(argstring) + 1;
         }
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, IOC_LDLM_REGRESS_START, buf);
         if (rc)
                 fprintf(stderr, "error: %s: test failed: %s\n",
@@ -1789,13 +1887,22 @@ int jt_obd_ldlm_regress_start(int argc, char **argv)
 int jt_obd_ldlm_regress_stop(int argc, char **argv)
 {
         int rc;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         struct obd_ioctl_data data;
-        IOC_INIT(data);
+
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
 
         if (argc != 1)
                 return CMD_HELP;
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, IOC_LDLM_REGRESS_STOP, buf);
 
         if (rc)
@@ -1807,16 +1914,24 @@ int jt_obd_ldlm_regress_stop(int argc, char **argv)
 static int do_activate(int argc, char **argv, int flag)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         if (argc != 1)
                 return CMD_HELP;
 
         /* reuse offset for 'active' */
         data.ioc_offset = flag;
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, IOC_OSC_SET_ACTIVE, buf);
         if (rc)
                 fprintf(stderr, "error: %s: failed: %s\n",
@@ -1838,9 +1953,11 @@ int jt_obd_activate(int argc, char **argv)
 int jt_obd_recover(int argc, char **argv)
 {
         int rc;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         struct obd_ioctl_data data;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         if (argc > 2)
                 return CMD_HELP;
 
@@ -1849,7 +1966,13 @@ int jt_obd_recover(int argc, char **argv)
                 data.ioc_inlbuf1 = argv[1];
         }
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l2_ioctl(OBD_DEV_ID, OBD_IOC_CLIENT_RECOVER, buf);
         if (rc < 0) {
                 fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
@@ -1862,6 +1985,7 @@ int jt_obd_recover(int argc, char **argv)
 int jt_obd_mdc_lookup(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         char *parent, *child;
         int rc, fd, verbose = 1;
 
@@ -1873,12 +1997,19 @@ int jt_obd_mdc_lookup(int argc, char **argv)
         if (argc == 4)
                 verbose = get_verbose(argv[0], argv[3]);
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
 
         data.ioc_inllen1 = strlen(child) + 1;
         data.ioc_inlbuf1 = child;
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
 
         fd = open(parent, O_RDONLY);
         if (fd < 0) {
@@ -1895,7 +2026,12 @@ int jt_obd_mdc_lookup(int argc, char **argv)
         close(fd);
 
         if (verbose) {
-                IOC_UNPACK(argv[0], data);
+                rc = obd_ioctl_unpack(&data, buf, sizeof(rawbuf));
+                if (rc) {
+                        fprintf(stderr, "error: %s: invalid reply\n",
+                                jt_cmdname(argv[0]));
+                        return rc;
+                }
                 printf("%s: mode %o uid %d gid %d\n", child,
                        data.ioc_obdo1.o_mode, data.ioc_obdo1.o_uid,
                        data.ioc_obdo1.o_gid);
@@ -1907,17 +2043,25 @@ int jt_obd_mdc_lookup(int argc, char **argv)
 int jt_cfg_dump_log(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
-        IOC_INIT(data);
 
         if (argc != 2)
                 return CMD_HELP;
 
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
 
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_DUMP_LOG, buf);
         if (rc < 0)
                 fprintf(stderr, "OBD_IOC_DUMP_LOG failed: %s\n",
@@ -1929,15 +2073,22 @@ int jt_cfg_dump_log(int argc, char **argv)
 int jt_llog_catlist(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
         if (argc != 1)
                 return CMD_HELP;
 
-        IOC_INIT(data);
-        data.ioc_inllen1 = max - size_round(sizeof(data));
-        IOC_PACK(argv[0], data);
-
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
+        data.ioc_inllen1 = sizeof(rawbuf) - size_round(sizeof(data));
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_CATLOGLIST, buf);
         if (rc == 0)
                 fprintf(stdout, "%s", ((struct obd_ioctl_data*)buf)->ioc_bulk);
@@ -1951,17 +2102,25 @@ int jt_llog_catlist(int argc, char **argv)
 int jt_llog_info(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
         if (argc != 2)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
-        data.ioc_inllen2 = max - size_round(sizeof(data)) -
+        data.ioc_inllen2 = sizeof(rawbuf) - size_round(sizeof(data)) -
                 size_round(data.ioc_inllen1);
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
 
         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_INFO, buf);
         if (rc == 0)
@@ -1976,12 +2135,14 @@ int jt_llog_info(int argc, char **argv)
 int jt_llog_print(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
         if (argc != 2 && argc != 4)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
         if (argc == 4) {
@@ -1996,11 +2157,17 @@ int jt_llog_print(int argc, char **argv)
                 data.ioc_inllen3 = strlen(to) + 1;
                 data.ioc_inlbuf3 = to;
         }
-        data.ioc_inllen4 = max - size_round(sizeof(data)) -
+        data.ioc_inllen4 = sizeof(rawbuf) - size_round(sizeof(data)) -
                 size_round(data.ioc_inllen1) -
                 size_round(data.ioc_inllen2) -
                 size_round(data.ioc_inllen3);
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
 
         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_PRINT, buf);
         if (rc == 0)
@@ -2015,19 +2182,27 @@ int jt_llog_print(int argc, char **argv)
 int jt_llog_cancel(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
         if (argc != 4)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
         data.ioc_inllen2 = strlen(argv[2]) + 1;
         data.ioc_inlbuf2 = argv[2];
         data.ioc_inllen3 = strlen(argv[3]) + 1;
         data.ioc_inlbuf3 = argv[3];
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
 
         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_CANCEL, buf);
         if (rc == 0)
@@ -2042,12 +2217,14 @@ int jt_llog_cancel(int argc, char **argv)
 int jt_llog_check(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
         if (argc != 2 && argc != 4)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
         if (argc == 4) {
@@ -2062,11 +2239,17 @@ int jt_llog_check(int argc, char **argv)
                 data.ioc_inllen3 = strlen(to) + 1;
                 data.ioc_inlbuf3 = to;
         }
-        data.ioc_inllen4 = max - size_round(sizeof(data)) -
+        data.ioc_inllen4 = sizeof(rawbuf) - size_round(sizeof(data)) -
                 size_round(data.ioc_inllen1) -
                 size_round(data.ioc_inllen2) -
                 size_round(data.ioc_inllen3);
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
 
         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_CHECK, buf);
         if (rc == 0)
@@ -2080,19 +2263,27 @@ int jt_llog_check(int argc, char **argv)
 int jt_llog_remove(int argc, char **argv)
 {
         struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
         int rc;
 
         if (argc != 3 && argc != 2)
                 return CMD_HELP;
 
-        IOC_INIT(data);
+        memset(&data, 0x00, sizeof(data));
+        data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
         if (argc == 3){
                 data.ioc_inllen2 = strlen(argv[2]) + 1;
                 data.ioc_inlbuf2 = argv[2];
         }
-        IOC_PACK(argv[0], data);
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(argv[0]));
+                return rc;
+        }
 
         rc = l_ioctl(OBD_DEV_ID, OBD_IOC_LLOG_REMOVE, buf);
         if (rc == 0) {
@@ -2340,3 +2531,640 @@ void obd_finalize(int argc, char **argv)
         shmem_stop();
         do_disconnect(argv[0], 1);
 }
+
+static int find_target_obdpath(char *fsname, char *path)
+{
+        glob_t glob_info;
+        char pattern[MAXPATHLEN + 1];
+        int rc;
+
+        snprintf(pattern, MAXPATHLEN,
+                 "/proc/fs/lustre/lov/%s-*/target_obd",
+                 fsname);
+        rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
+        if (rc == GLOB_NOMATCH)
+                return -ENODEV;
+        else if (rc)
+                return -EINVAL;
+
+        strcpy(path, glob_info.gl_pathv[0]);
+        globfree(&glob_info);
+        return 0;
+}
+
+static int find_poolpath(char *fsname, char *poolname, char *poolpath)
+{
+        glob_t glob_info;
+        char pattern[MAXPATHLEN + 1];
+        int rc;
+
+        snprintf(pattern, MAXPATHLEN,
+                 "/proc/fs/lustre/lov/%s-*/pools/%s",
+                 fsname, poolname);
+        rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
+        /* If no pools, make sure the lov is available */
+        if ((rc == GLOB_NOMATCH) &&
+            (find_target_obdpath(fsname, poolpath) == -ENODEV))
+                return -ENODEV;
+        if (rc)
+                return -EINVAL;
+
+        strcpy(poolpath, glob_info.gl_pathv[0]);
+        globfree(&glob_info);
+        return 0;
+}
+
+/*
+ * if pool is NULL, search ostname in target_obd
+ * if pool is no NULL
+ *  if pool not found returns < 0
+ *  if ostname is NULL, returns 1 if pool is not empty and 0 if pool empty
+ *  if ostname is not NULL, returns 1 if OST is in pool and 0 if not
+ */
+static int search_ost(char *fsname, char *poolname, char *ostname)
+{
+        FILE *fd;
+        char buffer[MAXPATHLEN + 1];
+        int len = 0, rc;
+
+        if (ostname != NULL)
+                len = strlen(ostname);
+
+        if (poolname == NULL)
+                rc = find_target_obdpath(fsname, buffer);
+        else
+                rc = find_poolpath(fsname, poolname, buffer);
+        if (rc)
+                return rc;
+
+        if ((fd = fopen(buffer, "r")) == NULL)
+                return -EINVAL;
+
+        while (fgets(buffer, sizeof(buffer), fd) != NULL) {
+                if (poolname == NULL) {
+                        char *ptr;
+                        /* Search for an ostname in the list of OSTs
+                           Line format is IDX: fsname-OSTxxxx_UUID STATUS */
+                        ptr = strchr(buffer, ' ');
+                        if ((ptr != NULL) &&
+                            (strncmp(ptr + 1, ostname, len) == 0)) {
+                                fclose(fd);
+                                return 1;
+                        }
+                } else {
+                        /* Search for an ostname in a pool,
+                           (or an existing non-empty pool if no ostname) */
+                        if ((ostname == NULL) ||
+                            (strncmp(buffer, ostname, len) == 0)) {
+                                fclose(fd);
+                                return 1;
+                        }
+                }
+        }
+        fclose(fd);
+        return 0;
+}
+
+static int check_pool_cmd(enum lcfg_command_type cmd,
+                          char *fsname, char *poolname,
+                          char *ostname)
+{
+        int rc = 0;
+
+        switch (cmd) {
+        case LCFG_POOL_NEW: {
+                if (search_ost(fsname, poolname, NULL) >= 0) {
+                        fprintf(stderr, "Pool %s.%s already exists\n",
+                                fsname, poolname);
+                        return -EEXIST;
+                }
+                return 0;
+        }
+        case LCFG_POOL_DEL: {
+                rc = search_ost(fsname, poolname, NULL);
+                if (rc < 0) {
+                        fprintf(stderr, "Pool %s.%s not found\n",
+                                fsname, poolname);
+                        return rc;
+                }
+                if (rc == 1) {
+                        fprintf(stderr, "Pool %s.%s not empty, "
+                                "please remove all members\n",
+                                fsname, poolname);
+                        return -ENOTEMPTY;
+                }
+                return 0;
+        }
+        case LCFG_POOL_ADD: {
+                rc = search_ost(fsname, NULL, ostname);
+                if (rc == 0) {
+                        fprintf(stderr, "OST %s not found in lov of %s\n",
+                                ostname, fsname);
+                        return -ENOENT;
+                }
+                rc = search_ost(fsname, poolname, ostname);
+                if (rc < 0) {
+                        fprintf(stderr, "Pool %s.%s not found\n",
+                                fsname, poolname);
+                        return rc;
+                }
+                if (rc == 1) {
+                        fprintf(stderr, "OST %s already in pool %s.%s\n",
+                                ostname, fsname, poolname);
+                        return -EEXIST;
+                }
+                return 0;
+        }
+        case LCFG_POOL_REM: {
+                rc = search_ost(fsname, poolname, ostname);
+                if (rc < 0) {
+                        fprintf(stderr, "Pool %s.%s not found\n",
+                                fsname, poolname);
+                        return rc;
+                }
+                if (rc == 0) {
+                        fprintf(stderr, "OST %s not found in pool %s.%s\n",
+                                ostname, fsname, poolname);
+                        return -ENOENT;
+                }
+                return 0;
+        }
+        default: {
+        }
+        }
+        return 0;
+}
+
+static void check_pool_cmd_result(enum lcfg_command_type cmd,
+                                  char *fsname, char *poolname,
+                                  char *ostname)
+{
+        int cpt, rc = 0;
+
+        cpt = 10;
+        switch (cmd) {
+        case LCFG_POOL_NEW: {
+                do {
+                        rc = search_ost(fsname, poolname, NULL);
+                        if (rc == -ENODEV)
+                                return;
+                        if (rc < 0)
+                                sleep(2);
+                        cpt--;
+                } while ((rc < 0) && (cpt > 0));
+                if (rc >= 0)
+                        fprintf(stderr, "Pool %s.%s created\n",
+                                fsname, poolname);
+                else
+                        fprintf(stderr, "Warning, pool %s.%s not found\n",
+                                fsname, poolname);
+                return;
+        }
+        case LCFG_POOL_DEL: {
+                do {
+                        rc = search_ost(fsname, poolname, NULL);
+                        if (rc == -ENODEV)
+                                return;
+                        if (rc >= 0)
+                                sleep(2);
+                        cpt--;
+                } while ((rc >= 0) && (cpt > 0));
+                if (rc < 0)
+                        fprintf(stderr, "Pool %s.%s destroyed\n",
+                                fsname, poolname);
+                else
+                        fprintf(stderr, "Warning, pool %s.%s still found\n",
+                                fsname, poolname);
+                return;
+        }
+        case LCFG_POOL_ADD: {
+                do {
+                        rc = search_ost(fsname, poolname, ostname);
+                        if (rc == -ENODEV)
+                                return;
+                        if (rc != 1)
+                                sleep(2);
+                        cpt--;
+                } while ((rc != 1) && (cpt > 0));
+                if (rc == 1)
+                        fprintf(stderr, "OST %s added to pool %s.%s\n",
+                                ostname, fsname, poolname);
+                else
+                        fprintf(stderr, "Warning, OST %s not found in pool %s.%s\n",
+                                ostname, fsname, poolname);
+                return;
+        }
+        case LCFG_POOL_REM: {
+                do {
+                        rc = search_ost(fsname, poolname, ostname);
+                        if (rc == -ENODEV)
+                                return;
+                        if (rc == 1)
+                                sleep(2);
+                        cpt--;
+                } while ((rc == 1) && (cpt > 0));
+                if (rc != 1)
+                        fprintf(stderr, "OST %s removed from pool %s.%s\n",
+                                ostname, fsname, poolname);
+                else
+                        fprintf(stderr, "Warning, OST %s still found in pool %s.%s\n",
+                                ostname, fsname, poolname);
+                return;
+        }
+        default: {
+        }
+        }
+}
+
+static int check_and_complete_ostname(char *fsname, char *ostname)
+{
+        char *ptr;
+        char real_ostname[MAX_OBD_NAME + 1];
+        char i;
+
+        /* if OST name does not start with fsname, we add it */
+        /* if not check if the fsname is the right one */
+        ptr = strchr(ostname, '-');
+        if (ptr == NULL) {
+                sprintf(real_ostname, "%s-%s", fsname, ostname);
+        } else if (strncmp(ostname, fsname, strlen(fsname)) != 0) {
+                fprintf(stderr, "%s does not start with fsname %s\n",
+                        ostname, fsname);
+                return -EINVAL;
+        } else {
+             strcpy(real_ostname, ostname);
+        }
+        /* real_ostname is fsname-????? */
+        ptr = real_ostname + strlen(fsname) + 1;
+        if (strncmp(ptr, "OST", 3) != 0) {
+                fprintf(stderr, "%s does not start by %s-OST nor OST\n",
+                        ostname, fsname);
+                return -EINVAL;
+        }
+        /* real_ostname is fsname-OST????? */
+        ptr += 3;
+        for (i = 0; i < 4; i++) {
+                if (!isxdigit(*ptr)) {
+                        fprintf(stderr,
+                                "ost's index in %s is not an hexa number\n",
+                                ostname);
+                        return -EINVAL;
+                }
+                ptr++;
+        }
+        /* real_ostname is fsname-OSTXXXX????? */
+        /* if OST name does not end with _UUID, we add it */
+        if (*ptr == '\0') {
+                strcat(real_ostname, "_UUID");
+        } else if (strcmp(ptr, "_UUID") != 0) {
+                fprintf(stderr,
+                        "ostname %s does not end with _UUID\n", ostname);
+                return -EINVAL;
+        }
+        /* real_ostname is fsname-OSTXXXX_UUID */
+        strcpy(ostname, real_ostname);
+        return 0;
+}
+
+/* returns 0 or -errno */
+static int pool_cmd(enum lcfg_command_type cmd,
+                    char *cmdname, char *fullpoolname,
+                    char *fsname, char *poolname, char *ostname)
+{
+        int rc = 0;
+        struct obd_ioctl_data data;
+        struct lustre_cfg_bufs bufs;
+        struct lustre_cfg *lcfg;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+
+        rc = check_pool_cmd(cmd, fsname, poolname, ostname);
+        if (rc == -ENODEV)
+                fprintf(stderr, "Can't verify pool command since there "
+                        "is no local MDT or client, proceeding anyhow...\n");
+        else if (rc)
+                return rc;
+
+        lustre_cfg_bufs_reset(&bufs, NULL);
+        lustre_cfg_bufs_set_string(&bufs, 0, cmdname);
+        lustre_cfg_bufs_set_string(&bufs, 1, fullpoolname);
+        if (ostname != NULL)
+                lustre_cfg_bufs_set_string(&bufs, 2, ostname);
+
+        lcfg = lustre_cfg_new(cmd, &bufs);
+        if (IS_ERR(lcfg)) {
+                rc = PTR_ERR(lcfg);
+                return rc;
+        }
+
+        memset(&data, 0x00, sizeof(data));
+        rc = data.ioc_dev = get_mgs_device();
+        if (rc < 0)
+                goto out;
+
+        data.ioc_type = LUSTRE_CFG_TYPE;
+        data.ioc_plen1 = lustre_cfg_len(lcfg->lcfg_bufcount,
+                                        lcfg->lcfg_buflens);
+        data.ioc_pbuf1 = (void *)lcfg;
+
+        memset(buf, 0, sizeof(rawbuf));
+        rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
+        if (rc) {
+                fprintf(stderr, "error: %s: invalid ioctl\n",
+                        jt_cmdname(cmdname));
+                return rc;
+        }
+        rc = l_ioctl(OBD_DEV_ID, OBD_IOC_POOL, buf);
+out:
+        if (rc)
+                rc = -errno;
+        lustre_cfg_free(lcfg);
+        return rc;
+}
+
+/*
+ * this function tranforms a rule [start-end/step] into an array
+ * of matching numbers
+ * supported forms are:
+ * [start]                : just this number
+ * [start-end]            : all numbers from start to end
+ * [start-end/step]       : numbers from start to end with increment of step
+ * on return, format contains a printf format string which can be used
+ * to generate all the strings
+ */
+static int get_array_idx(char *rule, char *format, int **array)
+{
+        char *start, *end, *ptr;
+        unsigned int lo, hi, step;
+        int array_sz = 0;
+        int i, array_idx;
+        int rc;
+
+        start = strchr(rule, '[');
+        end = strchr(rule, ']');
+        if ((start == NULL) || (end == NULL)) {
+                *array = malloc(sizeof(int));
+                if (*array == NULL)
+                        return 0;
+                strcpy(format, rule);
+                array_sz = 1;
+                return array_sz;
+        }
+        *start = '\0';
+        *end = '\0';
+        end++;
+        start++;
+        /* put in format the printf format (the rule without the range) */
+        sprintf(format, "%s%%.4x%s", rule, end);
+
+        array_idx = 0;
+        array_sz = 0;
+        *array = NULL;
+        /* loop on , separator */
+        do {
+                /* extract the 3 fields */
+                rc = sscanf(start, "%x-%x/%u", &lo, &hi, &step);
+                switch (rc) {
+                case 0: {
+                        return 0;
+                }
+                case 1: {
+                        array_sz++;
+                        *array = realloc(*array, array_sz * sizeof(int));
+                        if (*array == NULL)
+                                return 0;
+                        (*array)[array_idx] = lo;
+                        array_idx++;
+                        break;
+                }
+                case 2: {
+                        step = 1;
+                        /* do not break to share code with case 3: */
+                }
+                case 3: {
+                        if ((hi < lo) || (step == 0))
+                                return 0;
+                        array_sz += (hi - lo) / step + 1;
+                        *array = realloc(*array, sizeof(int) * array_sz);
+                        if (*array == NULL)
+                                return 0;
+                        for (i = lo; i <= hi; i+=step, array_idx++)
+                                (*array)[array_idx] = i;
+                        break;
+                }
+                }
+                ptr = strchr(start, ',');
+                if (ptr != NULL)
+                        start = ptr + 1;
+
+        } while (ptr != NULL);
+        return array_sz;
+}
+
+static int extract_fsname_poolname(char *arg, char *fsname, char *poolname)
+{
+        char *ptr;
+        int len;
+        int rc;
+
+        strcpy(fsname, arg);
+        ptr = strchr(fsname, '.');
+        if (ptr == NULL) {
+                fprintf(stderr, ". is missing in %s\n", fsname);
+                rc = -EINVAL;
+                goto err;
+        }
+
+        len = ptr - fsname;
+        if (len == 0) {
+                fprintf(stderr, "fsname is empty\n");
+                rc = -EINVAL;
+                goto err;
+        }
+
+        len = strlen(ptr + 1);
+        if (len == 0) {
+                fprintf(stderr, "poolname is empty\n");
+                rc = -EINVAL;
+                goto err;
+        }
+        if (len > LOV_MAXPOOLNAME) {
+                fprintf(stderr,
+                        "poolname %s is too long (length is %d max is %d)\n",
+                        ptr + 1, len, LOV_MAXPOOLNAME);
+                rc = -ENAMETOOLONG;
+                goto err;
+        }
+        strncpy(poolname, ptr + 1, LOV_MAXPOOLNAME);
+        poolname[LOV_MAXPOOLNAME] = '\0';
+        *ptr = '\0';
+        return 0;
+
+err:
+        fprintf(stderr, "argument %s must be <fsname>.<poolname>\n", arg);
+        return rc;
+}
+
+int jt_pool_cmd(int argc, char **argv)
+{
+        enum lcfg_command_type cmd;
+        char fsname[MAXPATHLEN + 1];
+        char poolname[LOV_MAXPOOLNAME + 1];
+        char *ostnames_buf = NULL;
+        int i, rc;
+        int *array = NULL, array_sz;
+        struct {
+                int     rc;
+                char   *ostname;
+        } *cmds = NULL;
+
+        switch (argc) {
+        case 0:
+        case 1: return CMD_HELP;
+        case 2: {
+                if (strcmp("pool_new", argv[0]) == 0)
+                        cmd = LCFG_POOL_NEW;
+                else if (strcmp("pool_destroy", argv[0]) == 0)
+                        cmd = LCFG_POOL_DEL;
+                else if (strcmp("pool_list", argv[0]) == 0)
+                         return llapi_poollist(argv[1]);
+                else return CMD_HELP;
+
+                rc = extract_fsname_poolname(argv[1], fsname, poolname);
+                if (rc)
+                        break;
+
+                rc = pool_cmd(cmd, argv[0], argv[1], fsname, poolname, NULL);
+                if (rc)
+                        break;
+
+                check_pool_cmd_result(cmd, fsname, poolname, NULL);
+                break;
+        }
+        default: {
+                char format[2*MAX_OBD_NAME];
+
+                if (strcmp("pool_remove", argv[0]) == 0) {
+                        cmd = LCFG_POOL_REM;
+                } else if (strcmp("pool_add", argv[0]) == 0) {
+                        cmd = LCFG_POOL_ADD;
+                } else {
+                        return CMD_HELP;
+                }
+
+                rc = extract_fsname_poolname(argv[1], fsname, poolname);
+                if (rc)
+                        break;
+
+                for (i = 2; i < argc; i++) {
+                        int j;
+
+                        array_sz = get_array_idx(argv[i], format, &array);
+                        if (array_sz == 0)
+                                return CMD_HELP;
+
+                        cmds = malloc(array_sz * sizeof(cmds[0]));
+                        if (cmds != NULL) {
+                                ostnames_buf = malloc(array_sz *
+                                                      (MAX_OBD_NAME + 1));
+                        } else {
+                                free(array);
+                                rc = -ENOMEM;
+                                goto out;
+                        }
+
+                        for (j = 0; j < array_sz; j++) {
+                                char ostname[MAX_OBD_NAME + 1];
+
+                                snprintf(ostname, MAX_OBD_NAME, format,
+                                         array[j]);
+                                ostname[MAX_OBD_NAME] = '\0';
+
+                                rc = check_and_complete_ostname(fsname,ostname);
+                                if (rc) {
+                                        free(array);
+                                        free(cmds);
+                                        if (ostnames_buf)
+                                                free(ostnames_buf);
+                                        goto out;
+                                }
+                                if (ostnames_buf != NULL) {
+                                        cmds[j].ostname =
+                                          &ostnames_buf[(MAX_OBD_NAME + 1) * j];
+                                        strcpy(cmds[j].ostname, ostname);
+                                } else {
+                                        cmds[j].ostname = NULL;
+                                }
+                                cmds[j].rc = pool_cmd(cmd, argv[0], argv[1],
+                                                      fsname, poolname,
+                                                      ostname);
+                        }
+                        for (j = 0; j < array_sz; j++) {
+                                if (!cmds[j].rc) {
+                                        char ostname[MAX_OBD_NAME + 1];
+
+                                        if (!cmds[j].ostname) {
+                                                snprintf(ostname, MAX_OBD_NAME,
+                                                         format, array[j]);
+                                                ostname[MAX_OBD_NAME] = '\0';
+                                                check_and_complete_ostname(
+                                                        fsname, ostname);
+                                        } else {
+                                                strcpy(ostname,
+                                                       cmds[j].ostname);
+                                        }
+                                        check_pool_cmd_result(cmd, fsname,
+                                                              poolname,ostname);
+                                }
+                        }
+                        if (array_sz > 0)
+                                free(array);
+                        if (cmds)
+                                free(cmds);
+                        if (ostnames_buf);
+                                free(ostnames_buf);
+                }
+                return 0;
+        }
+        }
+
+
+out:
+        if ((rc == -EINVAL) || (rc == -ENOENT))
+                fprintf(stderr, "Does the fs, pool or ost exist?\n");
+        if (rc != 0) {
+                errno = -rc;
+                perror(argv[0]);
+        }
+
+        return rc;
+}
+
+void  llapi_ping_target(char *obd_type, char *obd_name,
+                        char *obd_uuid, void *args)
+{
+        int  rc;
+        struct obd_ioctl_data data;
+        char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+
+        memset(&data, 0, sizeof(data));
+        data.ioc_inlbuf4 = obd_name;
+        data.ioc_inllen4 = strlen(obd_name) + 1;
+        data.ioc_dev = OBD_DEV_BY_DEVNAME;
+        memset(buf, 0, sizeof(rawbuf));
+        if (obd_ioctl_pack(&data, &buf, sizeof(rawbuf))) {
+                fprintf(stderr, "error: invalid ioctl\n");
+                return;
+        }
+        rc = l_ioctl(OBD_DEV_ID, OBD_IOC_PING_TARGET, buf);
+        if (rc)
+                rc = errno;
+        if (rc == ENOTCONN || rc == ESHUTDOWN) {
+                printf("%s inactive.\n", obd_name);
+        } else if (rc) {
+                fprintf(stderr, "error: check '%s' %s\n",
+                        obd_name, strerror(errno));
+        } else {
+                printf("%s active.\n", obd_name);
+        }
+
+}
diff --git a/lustre/utils/obdctl.h b/lustre/utils/obdctl.h
index a5fd90a..eeb1bb8 100644
--- a/lustre/utils/obdctl.h
+++ b/lustre/utils/obdctl.h
@@ -119,4 +119,6 @@ int jt_blockdev_attach(int argc, char **argv);
 int jt_blockdev_detach(int argc, char **argv);
 int jt_blockdev_info(int argc, char **argv);
 
+int jt_pool_cmd(int argc, char **argv);
+
 #endif
diff --git a/lustre/utils/thread.c b/lustre/utils/thread.c
deleted file mode 100644
index 64701ec..0000000
--- a/lustre/utils/thread.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*****************************************************************************
- *  $Id: thread.c,v 1.1.2.1 2008/11/21 15:27:33 yangsheng Exp $
- *****************************************************************************
- *  Copyright (C) 2003 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Chris Dunlap <cdunlap at llnl.gov>.
- *
- *  This file is from LSD-Tools, the LLNL Software Development Toolbox.
- *
- *  LSD-Tools is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  LSD-Tools is distributed in the hope that it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- *  more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with LSD-Tools; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *****************************************************************************/
-
-
-#if HAVE_CONFIG_H
-#  include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#include <assert.h>
-#include <errno.h>
-#include <pthread.h>
-#include "thread.h"
-
-
-#if WITH_PTHREADS
-#ifndef NDEBUG
-int
-lsd_mutex_is_locked (pthread_mutex_t *mutex)
-{
-/*  Returns true if the mutex is locked; o/w, returns false.
- */
-    int rc;
-
-    assert (mutex != NULL);
-    rc = pthread_mutex_trylock (mutex);
-    return (rc == EBUSY ? 1 : 0);
-}
-#endif /* !NDEBUG */
-#endif /* WITH_PTHREADS */
diff --git a/lustre/utils/thread.h b/lustre/utils/thread.h
deleted file mode 100644
index 35bdde9..0000000
--- a/lustre/utils/thread.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*****************************************************************************
- *  $Id: thread.h,v 1.1.2.1 2008/11/21 15:27:33 yangsheng Exp $
- *****************************************************************************
- *  Copyright (C) 2003 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Chris Dunlap <cdunlap at llnl.gov>.
- *
- *  This file is from LSD-Tools, the LLNL Software Development Toolbox.
- *
- *  LSD-Tools is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  LSD-Tools is distributed in the hope that it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- *  more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with LSD-Tools; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- *****************************************************************************/
-
-
-#ifndef LSD_THREAD_H
-#define LSD_THREAD_H
-
-#if WITH_PTHREADS
-#  include <errno.h>
-#  include <pthread.h>
-#  include <stdlib.h>
-#endif /* WITH_PTHREADS */
-
-
-/*****************************************************************************
- *  Macros
- *****************************************************************************/
-
-#if WITH_PTHREADS
-
-#  ifdef WITH_LSD_FATAL_ERROR_FUNC
-#    undef lsd_fatal_error
-     extern void lsd_fatal_error (char *file, int line, char *mesg);
-#  else /* !WITH_LSD_FATAL_ERROR_FUNC */
-#    ifndef lsd_fatal_error
-#      define lsd_fatal_error(file, line, mesg) (abort ())
-#    endif /* !lsd_fatal_error */
-#  endif /* !WITH_LSD_FATAL_ERROR_FUNC */
-
-#  define lsd_mutex_init(pmutex)                                              \
-     do {                                                                     \
-         int e = pthread_mutex_init (pmutex, NULL);                           \
-         if (e != 0) {                                                        \
-             errno = e;                                                       \
-             lsd_fatal_error (__FILE__, __LINE__, "mutex_init");              \
-             abort ();                                                        \
-         }                                                                    \
-     } while (0)
-
-#  define lsd_mutex_lock(pmutex)                                              \
-     do {                                                                     \
-         int e = pthread_mutex_lock (pmutex);                                 \
-         if (e != 0) {                                                        \
-             errno = e;                                                       \
-             lsd_fatal_error (__FILE__, __LINE__, "mutex_lock");              \
-             abort ();                                                        \
-         }                                                                    \
-     } while (0)
-
-#  define lsd_mutex_unlock(pmutex)                                            \
-     do {                                                                     \
-         int e = pthread_mutex_unlock (pmutex);                               \
-         if (e != 0) {                                                        \
-             errno = e;                                                       \
-             lsd_fatal_error (__FILE__, __LINE__, "mutex_unlock");            \
-             abort ();                                                        \
-         }                                                                    \
-     } while (0)
-
-#  define lsd_mutex_destroy(pmutex)                                           \
-     do {                                                                     \
-         int e = pthread_mutex_destroy (pmutex);                              \
-         if (e != 0) {                                                        \
-             errno = e;                                                       \
-             lsd_fatal_error (__FILE__, __LINE__, "mutex_destroy");           \
-             abort ();                                                        \
-         }                                                                    \
-     } while (0)
-
-#  ifndef NDEBUG
-     int lsd_mutex_is_locked (pthread_mutex_t *pmutex);
-#  endif /* !NDEBUG */
-
-#else /* !WITH_PTHREADS */
-
-#  define lsd_mutex_init(mutex)
-#  define lsd_mutex_lock(mutex)
-#  define lsd_mutex_unlock(mutex)
-#  define lsd_mutex_destroy(mutex)
-#  define lsd_mutex_is_locked(mutex) (1)
-
-#endif /* !WITH_PTHREADS */
-
-
-#endif /* !LSD_THREAD_H */
diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c
index 1e50887..47bf94b 100644
--- a/lustre/utils/wirecheck.c
+++ b/lustre/utils/wirecheck.c
@@ -191,6 +191,8 @@ check_ptlrpc_body(void)
         CHECK_MEMBER(ptlrpc_body, pb_service_time);
         CHECK_MEMBER(ptlrpc_body, pb_slv);
         CHECK_MEMBER(ptlrpc_body, pb_limit);
+        CHECK_MEMBER(ptlrpc_body, pb_pre_versions);
+        CHECK_MEMBER(ptlrpc_body, pb_padding);
 }
 
 static void check_obd_connect_data(void)
@@ -238,7 +240,9 @@ static void check_obd_connect_data(void)
         CHECK_CDEFINE(OBD_CONNECT_LRU_RESIZE);
         CHECK_CDEFINE(OBD_CONNECT_MDS_MDS);
         CHECK_CDEFINE(OBD_CONNECT_REAL);
+        CHECK_CDEFINE(OBD_CONNECT_FID);
         CHECK_CDEFINE(OBD_CONNECT_CKSUM);
+        CHECK_CDEFINE(OBD_CONNECT_VBR);
 }
 
 static void
@@ -325,6 +329,7 @@ check_obdo(void)
         CHECK_CDEFINE(OBD_FL_TRUNCLOCK);
         CHECK_CDEFINE(OBD_FL_CKSUM_CRC32);
         CHECK_CDEFINE(OBD_FL_CKSUM_ADLER);
+        CHECK_CDEFINE(OBD_FL_SHRINK_GRANT);
         CHECK_CVALUE(OBD_CKSUM_CRC32);
         CHECK_CVALUE(OBD_CKSUM_ADLER);
 }
@@ -367,6 +372,33 @@ check_lov_mds_md_join(void)
 }
 
 static void
+check_lov_mds_md_v3(void)
+{
+        BLANK_LINE();
+        CHECK_STRUCT(lov_mds_md_v3);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_magic);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_pattern);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_object_id);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_object_gr);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_stripe_size);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_stripe_count);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_pool_name);
+        CHECK_MEMBER(lov_mds_md_v3, lmm_objects);
+
+        BLANK_LINE();
+        CHECK_STRUCT(lov_ost_data_v1);
+        CHECK_MEMBER(lov_ost_data_v1, l_object_id);
+        CHECK_MEMBER(lov_ost_data_v1, l_object_gr);
+        CHECK_MEMBER(lov_ost_data_v1, l_ost_gen);
+        CHECK_MEMBER(lov_ost_data_v1, l_ost_idx);
+
+        CHECK_CDEFINE(LOV_MAGIC_V3);
+
+        CHECK_VALUE(LOV_PATTERN_RAID0);
+        CHECK_VALUE(LOV_PATTERN_RAID1);
+}
+
+static void
 check_obd_statfs(void)
 {
         BLANK_LINE();
@@ -866,7 +898,7 @@ check_llog_create_rec(void)
         CHECK_MEMBER(llog_create_rec, lcr_hdr);
         CHECK_MEMBER(llog_create_rec, lcr_fid);
         CHECK_MEMBER(llog_create_rec, lcr_oid);
-        CHECK_MEMBER(llog_create_rec, lcr_ogen);
+        CHECK_MEMBER(llog_create_rec, lcr_ogr);
         CHECK_MEMBER(llog_create_rec, padding);
 }
 
@@ -889,8 +921,8 @@ check_llog_unlink_rec(void)
         CHECK_STRUCT(llog_unlink_rec);
         CHECK_MEMBER(llog_unlink_rec, lur_hdr);
         CHECK_MEMBER(llog_unlink_rec, lur_oid);
-        CHECK_MEMBER(llog_unlink_rec, lur_ogen);
-        CHECK_MEMBER(llog_unlink_rec, padding);
+        CHECK_MEMBER(llog_unlink_rec, lur_ogr);
+        CHECK_MEMBER(llog_unlink_rec, lur_count);
         CHECK_MEMBER(llog_unlink_rec, lur_tail);
 }
 
@@ -901,7 +933,7 @@ check_llog_setattr_rec(void)
         CHECK_STRUCT(llog_setattr_rec);
         CHECK_MEMBER(llog_setattr_rec, lsr_hdr);
         CHECK_MEMBER(llog_setattr_rec, lsr_oid);
-        CHECK_MEMBER(llog_setattr_rec, lsr_ogen);
+        CHECK_MEMBER(llog_setattr_rec, lsr_ogr);
         CHECK_MEMBER(llog_setattr_rec, lsr_uid);
         CHECK_MEMBER(llog_setattr_rec, lsr_gid);
         CHECK_MEMBER(llog_setattr_rec, padding);
@@ -909,6 +941,22 @@ check_llog_setattr_rec(void)
 }
 
 static void
+check_llog_setattr64_rec(void)
+{
+        BLANK_LINE();
+        CHECK_STRUCT(llog_setattr64_rec);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_hdr);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_oid);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_ogr);
+        CHECK_MEMBER(llog_setattr64_rec, padding);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_uid);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_uid_h);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_gid);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_gid_h);
+        CHECK_MEMBER(llog_setattr64_rec, lsr_tail);
+}
+
+static void
 check_llog_size_change_rec(void)
 {
         BLANK_LINE();
@@ -1045,17 +1093,6 @@ check_qunit_data_old2(void)
 }
 
 static void
-check_qunit_data_old(void)
-{
-        BLANK_LINE();
-        CHECK_STRUCT(qunit_data_old);
-        CHECK_MEMBER(qunit_data_old, qd_id);
-        CHECK_MEMBER(qunit_data_old, qd_type);
-        CHECK_MEMBER(qunit_data_old, qd_count);
-        CHECK_MEMBER(qunit_data_old, qd_isblk);
-}
-
-static void
 check_mgs_target_info(void)
 {
         BLANK_LINE();
@@ -1155,16 +1192,15 @@ check_ll_fiemap_extent(void)
         CHECK_CDEFINE(FIEMAP_EXTENT_LAST);
         CHECK_CDEFINE(FIEMAP_EXTENT_UNKNOWN);
         CHECK_CDEFINE(FIEMAP_EXTENT_DELALLOC);
-        CHECK_CDEFINE(FIEMAP_EXTENT_NO_DIRECT);
-        CHECK_CDEFINE(FIEMAP_EXTENT_SECONDARY);
-        CHECK_CDEFINE(FIEMAP_EXTENT_NET);
-        CHECK_CDEFINE(FIEMAP_EXTENT_DATA_COMPRESSED);
+        CHECK_CDEFINE(FIEMAP_EXTENT_ENCODED);
         CHECK_CDEFINE(FIEMAP_EXTENT_DATA_ENCRYPTED);
         CHECK_CDEFINE(FIEMAP_EXTENT_NOT_ALIGNED);
         CHECK_CDEFINE(FIEMAP_EXTENT_DATA_INLINE);
         CHECK_CDEFINE(FIEMAP_EXTENT_DATA_TAIL);
         CHECK_CDEFINE(FIEMAP_EXTENT_UNWRITTEN);
         CHECK_CDEFINE(FIEMAP_EXTENT_MERGED);
+        CHECK_CDEFINE(FIEMAP_EXTENT_NO_DIRECT);
+        CHECK_CDEFINE(FIEMAP_EXTENT_NET);
 }
 
 static void
@@ -1293,6 +1329,10 @@ main(int argc, char **argv)
         CHECK_VALUE(MDS_SET_INFO);
         CHECK_VALUE(MDS_QUOTACHECK);
         CHECK_VALUE(MDS_QUOTACTL);
+        CHECK_VALUE(MDS_GETXATTR);
+        CHECK_VALUE(MDS_SETXATTR);
+        CHECK_VALUE(MDS_WRITEPAGE);
+        CHECK_VALUE(MDS_IS_SUBDIR);
         CHECK_VALUE(MDS_LAST_OPC);
 
         CHECK_VALUE(REINT_SETATTR);
@@ -1301,6 +1341,7 @@ main(int argc, char **argv)
         CHECK_VALUE(REINT_UNLINK);
         CHECK_VALUE(REINT_RENAME);
         CHECK_VALUE(REINT_OPEN);
+        CHECK_VALUE(REINT_SETXATTR);
         CHECK_VALUE(REINT_MAX);
 
         CHECK_VALUE(MGS_CONNECT);
@@ -1353,7 +1394,7 @@ main(int argc, char **argv)
 
         CHECK_VALUE(MGS_CONNECT);
         CHECK_VALUE(MGS_DISCONNECT);
-        CHECK_VALUE(MGS_EXCEPTION);   
+        CHECK_VALUE(MGS_EXCEPTION);
         CHECK_VALUE(MGS_TARGET_REG);
         CHECK_VALUE(MGS_TARGET_DEL);
         CHECK_VALUE(MGS_SET_INFO);
@@ -1370,6 +1411,7 @@ main(int argc, char **argv)
         check_obd_connect_data();
         check_obdo();
         check_lov_mds_md_v1();
+        check_lov_mds_md_v3();
         check_lov_mds_md_join();
         check_obd_statfs();
         check_obd_ioobj();
@@ -1406,6 +1448,7 @@ main(int argc, char **argv)
         check_llog_orphan_rec();
         check_llog_unlink_rec();
         check_llog_setattr_rec();
+        check_llog_setattr64_rec();
         check_llog_size_change_rec();
         check_llog_gen();
         check_llog_gen_rec();
@@ -1417,7 +1460,6 @@ main(int argc, char **argv)
         check_mds_extent_desc();
         check_qunit_data();
         check_qunit_data_old2();
-        check_qunit_data_old();
         check_quota_adjust_qunit();
         check_mgs_target_info();
         check_lustre_disk_data();
diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c
index 44e945b..1585b04 100644
--- a/lustre/utils/wiretest.c
+++ b/lustre/utils/wiretest.c
@@ -59,13 +59,12 @@ int main()
 
         return ret;
 }
-
 void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
          * (make -C lustre/utils newwiretest)
-         * running on Linux xlab.hostel 2.6.23.12-52.fc7 #1 SMP Tue Dec 18 21:18:02 EST 2007 i686 i68
-         * with gcc version 3.4.6 20060404 (Red Hat 3.4.6-7) */
+         * running on Linux localhost.localdomain 2.6.18-prep #3 SMP Sun Nov 23 08:04:44 EST 2008 i68
+         * with gcc version 4.1.1 20061011 (Red Hat 4.1.1-30) */
 
 
         /* Constants... */
@@ -167,7 +166,15 @@ void lustre_assert_wire_constants(void)
                  (long long)MDS_QUOTACHECK);
         LASSERTF(MDS_QUOTACTL == 48, " found %lld\n",
                  (long long)MDS_QUOTACTL);
-        LASSERTF(MDS_LAST_OPC == 51, " found %lld\n",
+        LASSERTF(MDS_GETXATTR == 49, " found %lld\n",
+                 (long long)MDS_GETXATTR);
+        LASSERTF(MDS_SETXATTR == 50, " found %lld\n",
+                 (long long)MDS_SETXATTR);
+        LASSERTF(MDS_WRITEPAGE == 51, " found %lld\n",
+                 (long long)MDS_WRITEPAGE);
+        LASSERTF(MDS_IS_SUBDIR == 52, " found %lld\n",
+                 (long long)MDS_IS_SUBDIR);
+        LASSERTF(MDS_LAST_OPC == 53, " found %lld\n",
                  (long long)MDS_LAST_OPC);
         LASSERTF(REINT_SETATTR == 1, " found %lld\n",
                  (long long)REINT_SETATTR);
@@ -181,7 +188,9 @@ void lustre_assert_wire_constants(void)
                  (long long)REINT_RENAME);
         LASSERTF(REINT_OPEN == 6, " found %lld\n",
                  (long long)REINT_OPEN);
-        LASSERTF(REINT_MAX == 7, " found %lld\n",
+        LASSERTF(REINT_SETXATTR == 7, " found %lld\n",
+                 (long long)REINT_SETXATTR);
+        LASSERTF(REINT_MAX == 8, " found %lld\n",
                  (long long)REINT_MAX);
         LASSERTF(MGS_CONNECT == 250, " found %lld\n",
                  (long long)MGS_CONNECT);
@@ -383,7 +392,7 @@ void lustre_assert_wire_constants(void)
         LASSERT(offsetof(struct lustre_msg_v1, lm_magic) == offsetof(struct lustre_msg_v2, lm_magic));
 
         /* Checks for struct ptlrpc_body */
-        LASSERTF((int)sizeof(struct ptlrpc_body) == 88, " found %lld\n",
+        LASSERTF((int)sizeof(struct ptlrpc_body) == 152, " found %lld\n",
                  (long long)(int)sizeof(struct ptlrpc_body));
         LASSERTF((int)offsetof(struct ptlrpc_body, pb_handle) == 0, " found %lld\n",
                  (long long)(int)offsetof(struct ptlrpc_body, pb_handle));
@@ -449,6 +458,14 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct ptlrpc_body, pb_limit));
         LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_limit) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_limit));
+        LASSERTF((int)offsetof(struct ptlrpc_body, pb_pre_versions) == 88, " found %lld\n",
+                 (long long)(int)offsetof(struct ptlrpc_body, pb_pre_versions));
+        LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_pre_versions) == 32, " found %lld\n",
+                 (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_pre_versions));
+        LASSERTF((int)offsetof(struct ptlrpc_body, pb_padding) == 120, " found %lld\n",
+                 (long long)(int)offsetof(struct ptlrpc_body, pb_padding));
+        LASSERTF((int)sizeof(((struct ptlrpc_body *)0)->pb_padding) == 32, " found %lld\n",
+                 (long long)(int)sizeof(((struct ptlrpc_body *)0)->pb_padding));
 
         /* Checks for struct obd_connect_data */
         LASSERTF((int)sizeof(struct obd_connect_data) == 72, " found %lld\n",
@@ -520,8 +537,8 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_CONNECT_JOIN == 0x2000ULL);
         CLASSERT(OBD_CONNECT_ATTRFID == 0x4000ULL);
         CLASSERT(OBD_CONNECT_NODEVOH == 0x8000ULL);
-        CLASSERT(OBD_CONNECT_LCL_CLIENT == 0x10000ULL);
-        CLASSERT(OBD_CONNECT_RMT_CLIENT == 0x20000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT == 0x10000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT_FORCE == 0x20000ULL);
         CLASSERT(OBD_CONNECT_BRW_SIZE == 0x40000ULL);
         CLASSERT(OBD_CONNECT_QUOTA64 == 0x80000ULL);
         CLASSERT(OBD_CONNECT_MDS_CAPA == 0x100000ULL);
@@ -532,7 +549,9 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_CONNECT_LRU_RESIZE == 0x02000000ULL);
         CLASSERT(OBD_CONNECT_MDS_MDS == 0x04000000ULL);
         CLASSERT(OBD_CONNECT_REAL == 0x08000000ULL);
+        CLASSERT(OBD_CONNECT_FID == 0x40000000ULL);
         CLASSERT(OBD_CONNECT_CKSUM == 0x20000000ULL);
+        CLASSERT(OBD_CONNECT_VBR == 0x80000000ULL);
 
         /* Checks for struct obdo */
         LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",
@@ -701,6 +720,7 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_FL_TRUNCLOCK == (0x00000800));
         CLASSERT(OBD_FL_CKSUM_CRC32 == (0x00001000));
         CLASSERT(OBD_FL_CKSUM_ADLER == (0x00002000));
+        CLASSERT(OBD_FL_SHRINK_GRANT == (0x00020000));
         CLASSERT(OBD_CKSUM_CRC32 == 1);
         CLASSERT(OBD_CKSUM_ADLER == 2);
 
@@ -762,6 +782,67 @@ void lustre_assert_wire_constants(void)
         LASSERTF(LOV_PATTERN_RAID1 == 2, " found %lld\n",
                  (long long)LOV_PATTERN_RAID1);
 
+        /* Checks for struct lov_mds_md_v3 */
+        LASSERTF((int)sizeof(struct lov_mds_md_v3) == 48, " found %lld\n",
+                 (long long)(int)sizeof(struct lov_mds_md_v3));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_magic) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_magic));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_magic) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_magic));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pattern) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pattern));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pattern) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pattern));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_object_id) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_object_id));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_id) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_id));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_object_gr) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_object_gr));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_gr) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_object_gr));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_stripe_size) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_stripe_size));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_size) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_size));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_stripe_count) == 28, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_stripe_count));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_count) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_stripe_count));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pool_name) == 32, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pool_name));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name));
+        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_objects) == 48, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_objects));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects) == 0, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_objects));
+
+        /* Checks for struct lov_ost_data_v1 */
+        LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, " found %lld\n",
+                 (long long)(int)sizeof(struct lov_ost_data_v1));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_id) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_object_id));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_gr) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_object_gr));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_gen) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_gen));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_idx) == 20, " found %lld\n",
+                 (long long)(int)offsetof(struct lov_ost_data_v1, l_ost_idx));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx));
+        CLASSERT(LOV_MAGIC_V3 == 0x0BD30BD0);
+        LASSERTF(LOV_PATTERN_RAID0 == 1, " found %lld\n",
+                 (long long)LOV_PATTERN_RAID0);
+        LASSERTF(LOV_PATTERN_RAID1 == 2, " found %lld\n",
+                 (long long)LOV_PATTERN_RAID1);
+
         /* Checks for struct lov_mds_md_join */
         LASSERTF((int)sizeof(struct lov_mds_md_join) == 56, " found %lld\n",
                  (long long)(int)sizeof(struct lov_mds_md_join));
@@ -1645,6 +1726,38 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_blocks) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct ost_lvb *)0)->lvb_blocks));
 
+        /* Checks for struct cfg_marker */
+        LASSERTF((int)sizeof(struct cfg_marker) == 160, " found %lld\n",
+                 (long long)(int)sizeof(struct cfg_marker));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_step) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_step));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_step) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_step));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_flags) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_flags));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_flags) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_flags));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_vers) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_vers));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_vers) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_vers));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_createtime) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_createtime));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_createtime) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_createtime));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_canceltime) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_canceltime));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_canceltime) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_canceltime));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_tgtname) == 32, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_tgtname));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_tgtname) == 64, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_tgtname));
+        LASSERTF((int)offsetof(struct cfg_marker, cm_comment) == 96, " found %lld\n",
+                 (long long)(int)offsetof(struct cfg_marker, cm_comment));
+        LASSERTF((int)sizeof(((struct cfg_marker *)0)->cm_comment) == 64, " found %lld\n",
+                 (long long)(int)sizeof(((struct cfg_marker *)0)->cm_comment));
+
         /* Checks for struct llog_logid */
         LASSERTF((int)sizeof(struct llog_logid) == 20, " found %lld\n",
                  (long long)(int)sizeof(struct llog_logid));
@@ -1774,10 +1887,10 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct llog_create_rec, lcr_oid));
         LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_oid) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_oid));
-        LASSERTF((int)offsetof(struct llog_create_rec, lcr_ogen) == 40, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_create_rec, lcr_ogen));
-        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_ogen) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_ogen));
+        LASSERTF((int)offsetof(struct llog_create_rec, lcr_ogr) == 40, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_create_rec, lcr_ogr));
+        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_ogr));
         LASSERTF((int)offsetof(struct llog_create_rec, padding) == 44, " found %lld\n",
                  (long long)(int)offsetof(struct llog_create_rec, padding));
         LASSERTF((int)sizeof(((struct llog_create_rec *)0)->padding) == 4, " found %lld\n",
@@ -1818,14 +1931,14 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct llog_unlink_rec, lur_oid));
         LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_oid) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_oid));
-        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_ogen) == 24, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_unlink_rec, lur_ogen));
-        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen));
-        LASSERTF((int)offsetof(struct llog_unlink_rec, padding) == 28, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_unlink_rec, padding));
-        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->padding) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->padding));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_ogr) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_unlink_rec, lur_ogr));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_ogr));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_count) == 28, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_unlink_rec, lur_count));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_count) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_count));
         LASSERTF((int)offsetof(struct llog_unlink_rec, lur_tail) == 32, " found %lld\n",
                  (long long)(int)offsetof(struct llog_unlink_rec, lur_tail));
         LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_tail) == 8, " found %lld\n",
@@ -1842,10 +1955,10 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct llog_setattr_rec, lsr_oid));
         LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_oid) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_oid));
-        LASSERTF((int)offsetof(struct llog_setattr_rec, lsr_ogen) == 24, " found %lld\n",
-                 (long long)(int)offsetof(struct llog_setattr_rec, lsr_ogen));
-        LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogen) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogen));
+        LASSERTF((int)offsetof(struct llog_setattr_rec, lsr_ogr) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr_rec, lsr_ogr));
+        LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_ogr));
         LASSERTF((int)offsetof(struct llog_setattr_rec, lsr_uid) == 28, " found %lld\n",
                  (long long)(int)offsetof(struct llog_setattr_rec, lsr_uid));
         LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_uid) == 4, " found %lld\n",
@@ -1863,6 +1976,46 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct llog_setattr_rec *)0)->lsr_tail) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct llog_setattr_rec *)0)->lsr_tail));
 
+        /* Checks for struct llog_setattr64_rec */
+        LASSERTF((int)sizeof(struct llog_setattr64_rec) == 56, " found %lld\n",
+                 (long long)(int)sizeof(struct llog_setattr64_rec));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_hdr) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_hdr));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_hdr) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_hdr));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_oid) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_oid));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_oid) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_oid));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_ogr) == 24, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_ogr));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_ogr) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_ogr));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, padding) == 28, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, padding));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->padding) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->padding));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_uid) == 32, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_uid));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_uid_h) == 36, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_uid_h));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid_h) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_uid_h));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_gid) == 40, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_gid));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_gid_h) == 44, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_gid_h));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid_h) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_gid_h));
+        LASSERTF((int)offsetof(struct llog_setattr64_rec, lsr_tail) == 48, " found %lld\n",
+                 (long long)(int)offsetof(struct llog_setattr64_rec, lsr_tail));
+        LASSERTF((int)sizeof(((struct llog_setattr64_rec *)0)->lsr_tail) == 8, " found %lld\n",
+                 (long long)(int)sizeof(((struct llog_setattr64_rec *)0)->lsr_tail));
+
         /* Checks for struct llog_size_change_rec */
         LASSERTF((int)sizeof(struct llog_size_change_rec) == 48, " found %lld\n",
                  (long long)(int)sizeof(struct llog_size_change_rec));
@@ -2112,26 +2265,6 @@ void lustre_assert_wire_constants(void)
         LASSERTF((int)sizeof(((struct qunit_data_old2 *)0)->qd_count) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct qunit_data_old2 *)0)->qd_count));
 
-        /* Checks for struct qunit_data_old */
-        LASSERTF((int)sizeof(struct qunit_data_old) == 16, " found %lld\n",
-                 (long long)(int)sizeof(struct qunit_data_old));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_id) == 0, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_id));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_id) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_id));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_type) == 4, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_type));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_type) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_type));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_count) == 8, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_count));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_count) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_count));
-        LASSERTF((int)offsetof(struct qunit_data_old, qd_isblk) == 12, " found %lld\n",
-                 (long long)(int)offsetof(struct qunit_data_old, qd_isblk));
-        LASSERTF((int)sizeof(((struct qunit_data_old *)0)->qd_isblk) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct qunit_data_old *)0)->qd_isblk));
-
         /* Checks for struct quota_adjust_qunit */
         LASSERTF((int)sizeof(struct quota_adjust_qunit) == 32, " found %lld\n",
                  (long long)(int)sizeof(struct quota_adjust_qunit));
@@ -2292,7 +2425,7 @@ void lustre_assert_wire_constants(void)
         CLASSERT(FIEMAP_FLAG_DEVICE_ORDER == 0x40000000);
 
         /* Checks for struct ll_fiemap_extent */
-        LASSERTF((int)sizeof(struct ll_fiemap_extent) == 32, " found %lld\n",
+        LASSERTF((int)sizeof(struct ll_fiemap_extent) == 56, " found %lld\n",
                  (long long)(int)sizeof(struct ll_fiemap_extent));
         LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_logical) == 0, " found %lld\n",
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_logical));
@@ -2306,28 +2439,27 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_length));
         LASSERTF((int)sizeof(((struct ll_fiemap_extent *)0)->fe_length) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct ll_fiemap_extent *)0)->fe_length));
-        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_flags) == 24, " found %lld\n",
+        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_flags) == 40, " found %lld\n",
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_flags));
         LASSERTF((int)sizeof(((struct ll_fiemap_extent *)0)->fe_flags) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct ll_fiemap_extent *)0)->fe_flags));
-        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_device) == 28, " found %lld\n",
+        LASSERTF((int)offsetof(struct ll_fiemap_extent, fe_device) == 44, " found %lld\n",
                  (long long)(int)offsetof(struct ll_fiemap_extent, fe_device));
         LASSERTF((int)sizeof(((struct ll_fiemap_extent *)0)->fe_device) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct ll_fiemap_extent *)0)->fe_device));
         CLASSERT(FIEMAP_EXTENT_LAST == 0x00000001);
         CLASSERT(FIEMAP_EXTENT_UNKNOWN == 0x00000002);
         CLASSERT(FIEMAP_EXTENT_DELALLOC == 0x00000004);
-        CLASSERT(FIEMAP_EXTENT_NO_DIRECT == 0x00000008);
-        CLASSERT(FIEMAP_EXTENT_SECONDARY == 0x00000010);
-        CLASSERT(FIEMAP_EXTENT_NET == 0x00000020);
-        CLASSERT(FIEMAP_EXTENT_DATA_COMPRESSED == 0x00000040);
+        CLASSERT(FIEMAP_EXTENT_ENCODED == 0x00000008);
         CLASSERT(FIEMAP_EXTENT_DATA_ENCRYPTED == 0x00000080);
         CLASSERT(FIEMAP_EXTENT_NOT_ALIGNED == 0x00000100);
         CLASSERT(FIEMAP_EXTENT_DATA_INLINE == 0x00000200);
         CLASSERT(FIEMAP_EXTENT_DATA_TAIL == 0x00000400);
         CLASSERT(FIEMAP_EXTENT_UNWRITTEN == 0x00000800);
         CLASSERT(FIEMAP_EXTENT_MERGED == 0x00001000);
-#ifdef LIBLUSTRE_POSIX_ACL
+        CLASSERT(FIEMAP_EXTENT_NO_DIRECT == 0x40000000);
+        CLASSERT(FIEMAP_EXTENT_NET == 0x80000000);
+#if defined(LIBLUSTRE_POSIX_ACL) && defined(CONFIG_FS_POSIX_ACL)
 
         /* Checks for type posix_acl_xattr_entry */
         LASSERTF((int)sizeof(xattr_acl_entry) == 8, " found %lld\n",
diff --git a/snmp/Makefile.in b/snmp/Makefile.in
index f2041d0..0262108 100644
--- a/snmp/Makefile.in
+++ b/snmp/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/snmp/autoconf/Makefile.in b/snmp/autoconf/Makefile.in
index bd99820..2db0cbe 100644
--- a/snmp/autoconf/Makefile.in
+++ b/snmp/autoconf/Makefile.in
@@ -174,9 +174,9 @@ MODULES_FALSE = @MODULES_FALSE@
 MODULES_TRUE = @MODULES_TRUE@
 MODULE_TARGET = @MODULE_TARGET@
 MOSTLYCLEANFILES = @MOSTLYCLEANFILES@
+MPICC_WRAPPER = @MPICC_WRAPPER@
 MPITESTS_FALSE = @MPITESTS_FALSE@
 MPITESTS_TRUE = @MPITESTS_TRUE@
-MPI_ROOT = @MPI_ROOT@
 MXCPPFLAGS = @MXCPPFLAGS@
 MXLIBS = @MXLIBS@
 MXLND = @MXLND@
diff --git a/tree_status b/tree_status
new file mode 100644
index 0000000..a438433
--- /dev/null
+++ b/tree_status
@@ -0,0 +1,2 @@
+PRISTINE = 1
+MTIME = 1248495737

-- 
Lustre Debian Packaging 



More information about the Pkg-lustre-svn-commit mailing list